arm/arm64: kvm: Use virt_to_idmap instead of virt_to_phys for idmap mappings
authorSantosh Shilimkar <santosh.shilimkar@ti.com>
Tue, 19 Nov 2013 19:59:12 +0000 (14:59 -0500)
committerChristoffer Dall <christoffer.dall@linaro.org>
Thu, 2 Oct 2014 15:18:20 +0000 (17:18 +0200)
KVM initialisation fails on architectures implementing virt_to_idmap()
because virt_to_phys() on such architectures won't fetch you the correct
idmap page.

So update the KVM ARM code to use the virt_to_idmap() to fix the issue.
Since the KVM code is shared between arm and arm64, we create
kvm_virt_to_phys() and handle the redirection in respective headers.

Cc: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
(cherry picked from commit 4fda342cc7f577599c53fd27b99c953c7b1da18a)
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
arch/arm/include/asm/kvm_mmu.h
arch/arm/kvm/mmu.c
arch/arm64/include/asm/kvm_mmu.h

index 77de4a41cc5045bd3b778f98396a454d23767467..2d122adcdb22108984a46f8483b5d2ed6b37b811 100644 (file)
@@ -140,6 +140,7 @@ static inline void coherent_icache_guest_page(struct kvm *kvm, hva_t hva,
 }
 
 #define kvm_flush_dcache_to_poc(a,l)   __cpuc_flush_dcache_area((a), (l))
+#define kvm_virt_to_phys(x)            virt_to_idmap((unsigned long)(x))
 
 #endif /* !__ASSEMBLY__ */
 
index 580906989db1091eb034ada5cc60570505de8cd1..659db0ed1370969320c3f13ff6fbbd030604bb63 100644 (file)
@@ -916,9 +916,9 @@ int kvm_mmu_init(void)
 {
        int err;
 
-       hyp_idmap_start = virt_to_phys(__hyp_idmap_text_start);
-       hyp_idmap_end = virt_to_phys(__hyp_idmap_text_end);
-       hyp_idmap_vector = virt_to_phys(__kvm_hyp_init);
+       hyp_idmap_start = kvm_virt_to_phys(__hyp_idmap_text_start);
+       hyp_idmap_end = kvm_virt_to_phys(__hyp_idmap_text_end);
+       hyp_idmap_vector = kvm_virt_to_phys(__kvm_hyp_init);
 
        if ((hyp_idmap_start ^ hyp_idmap_end) & PAGE_MASK) {
                /*
@@ -945,7 +945,7 @@ int kvm_mmu_init(void)
                 */
                kvm_flush_dcache_to_poc(init_bounce_page, len);
 
-               phys_base = virt_to_phys(init_bounce_page);
+               phys_base = kvm_virt_to_phys(init_bounce_page);
                hyp_idmap_vector += phys_base - hyp_idmap_start;
                hyp_idmap_start = phys_base;
                hyp_idmap_end = phys_base + len;
index 680f74e674971ab5062047369d6994edddc64e8e..7f1f9408ff66e897e8988d0b844ab9a3e8f903a0 100644 (file)
@@ -136,6 +136,7 @@ static inline void coherent_icache_guest_page(struct kvm *kvm, hva_t hva,
 }
 
 #define kvm_flush_dcache_to_poc(a,l)   __flush_dcache_area((a), (l))
+#define kvm_virt_to_phys(x)            __virt_to_phys((unsigned long)(x))
 
 #endif /* __ASSEMBLY__ */
 #endif /* __ARM64_KVM_MMU_H__ */