Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[sfrench/cifs-2.6.git] / arch / arm64 / include / asm / kvm_mmu.h
index 91d93a5d8fd308cf91723047599c279b9113288c..a89cc22abadcaced0ee272ec38eb8e490292fd8d 100644 (file)
@@ -108,7 +108,7 @@ alternative_else_nop_endif
 #else
 
 #include <asm/pgalloc.h>
-#include <asm/cachetype.h>
+#include <asm/cache.h>
 #include <asm/cacheflush.h>
 #include <asm/mmu_context.h>
 #include <asm/pgtable.h>
@@ -241,12 +241,13 @@ static inline void __coherent_cache_guest_page(struct kvm_vcpu *vcpu,
 
        kvm_flush_dcache_to_poc(va, size);
 
-       if (!icache_is_aliasing()) {            /* PIPT */
-               flush_icache_range((unsigned long)va,
-                                  (unsigned long)va + size);
-       } else if (!icache_is_aivivt()) {       /* non ASID-tagged VIVT */
+       if (icache_is_aliasing()) {
                /* any kind of VIPT cache */
                __flush_icache_all();
+       } else if (is_kernel_in_hyp_mode() || !icache_is_vpipt()) {
+               /* PIPT or VPIPT at EL2 (see comment in __kvm_tlb_flush_vmid_ipa) */
+               flush_icache_range((unsigned long)va,
+                                  (unsigned long)va + size);
        }
 }
 
@@ -306,7 +307,7 @@ static inline void __kvm_extend_hypmap(pgd_t *boot_hyp_pgd,
 
 static inline unsigned int kvm_get_vmid_bits(void)
 {
-       int reg = read_system_reg(SYS_ID_AA64MMFR1_EL1);
+       int reg = read_sanitised_ftr_reg(SYS_ID_AA64MMFR1_EL1);
 
        return (cpuid_feature_extract_unsigned_field(reg, ID_AA64MMFR1_VMIDBITS_SHIFT) == 2) ? 16 : 8;
 }