aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/include
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2014-01-14 14:13:10 -0500
committerMarc Zyngier <marc.zyngier@arm.com>2014-03-02 20:15:22 -0500
commit159793001d7d85af17855630c94f0a176848e16b (patch)
tree535b618f36564c3a87e7146efa65523917fff28f /arch/arm/include
parent9d218a1fcf4c6b759d442ef702842fae92e1ea61 (diff)
ARM: KVM: force cache clean on page fault when caches are off
In order for a guest with caches disabled to observe data written contained in a given page, we need to make sure that page is committed to memory, and not just hanging in the cache (as guest accesses are completely bypassing the cache until it decides to enable it). For this purpose, hook into the coherent_cache_guest_page function and flush the region if the guest SCTLR register doesn't show the MMU and caches as being enabled. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm/include')
-rw-r--r--arch/arm/include/asm/kvm_mmu.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/arch/arm/include/asm/kvm_mmu.h b/arch/arm/include/asm/kvm_mmu.h
index eb85b81eea6f..5c7aa3c1519f 100644
--- a/arch/arm/include/asm/kvm_mmu.h
+++ b/arch/arm/include/asm/kvm_mmu.h
@@ -129,9 +129,19 @@ static inline void kvm_set_s2pmd_writable(pmd_t *pmd)
129 129
130struct kvm; 130struct kvm;
131 131
132#define kvm_flush_dcache_to_poc(a,l) __cpuc_flush_dcache_area((a), (l))
133
134static inline bool vcpu_has_cache_enabled(struct kvm_vcpu *vcpu)
135{
136 return (vcpu->arch.cp15[c1_SCTLR] & 0b101) == 0b101;
137}
138
132static inline void coherent_cache_guest_page(struct kvm_vcpu *vcpu, hva_t hva, 139static inline void coherent_cache_guest_page(struct kvm_vcpu *vcpu, hva_t hva,
133 unsigned long size) 140 unsigned long size)
134{ 141{
142 if (!vcpu_has_cache_enabled(vcpu))
143 kvm_flush_dcache_to_poc((void *)hva, size);
144
135 /* 145 /*
136 * If we are going to insert an instruction page and the icache is 146 * If we are going to insert an instruction page and the icache is
137 * either VIPT or PIPT, there is a potential problem where the host 147 * either VIPT or PIPT, there is a potential problem where the host
@@ -152,7 +162,6 @@ static inline void coherent_cache_guest_page(struct kvm_vcpu *vcpu, hva_t hva,
152 } 162 }
153} 163}
154 164
155#define kvm_flush_dcache_to_poc(a,l) __cpuc_flush_dcache_area((a), (l))
156#define kvm_virt_to_phys(x) virt_to_idmap((unsigned long)(x)) 165#define kvm_virt_to_phys(x) virt_to_idmap((unsigned long)(x))
157 166
158void stage2_flush_vm(struct kvm *kvm); 167void stage2_flush_vm(struct kvm *kvm);