Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: arm64: Provide I-cache invalidation by virtual address at EL2

In preparation for handling cache maintenance of guest pages from within
the pKVM hypervisor at EL2, introduce an EL2 copy of icache_inval_pou()
which will later be plumbed into the stage-2 page-table cache
maintenance callbacks, ensuring that the initial contents of pages
mapped as executable into the guest stage-2 page-table is visible to the
instruction fetcher.

Tested-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20221110190259.26861-17-will@kernel.org

authored by

Will Deacon and committed by
Marc Zyngier
13e248aa 6c165223

+16 -3
+1
arch/arm64/include/asm/kvm_hyp.h
··· 123 123 extern u64 kvm_nvhe_sym(id_aa64mmfr1_el1_sys_val); 124 124 extern u64 kvm_nvhe_sym(id_aa64mmfr2_el1_sys_val); 125 125 126 + extern unsigned long kvm_nvhe_sym(__icache_flags); 126 127 #endif /* __ARM64_KVM_HYP_H__ */
-3
arch/arm64/kernel/image-vars.h
··· 71 71 /* Vectors installed by hyp-init on reset HVC. */ 72 72 KVM_NVHE_ALIAS(__hyp_stub_vectors); 73 73 74 - /* Kernel symbol used by icache_is_vpipt(). */ 75 - KVM_NVHE_ALIAS(__icache_flags); 76 - 77 74 /* VMID bits set by the KVM VMID allocator */ 78 75 KVM_NVHE_ALIAS(kvm_arm_vmid_bits); 79 76
+1
arch/arm64/kvm/arm.c
··· 1894 1894 kvm_nvhe_sym(id_aa64mmfr0_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1); 1895 1895 kvm_nvhe_sym(id_aa64mmfr1_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64MMFR1_EL1); 1896 1896 kvm_nvhe_sym(id_aa64mmfr2_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64MMFR2_EL1); 1897 + kvm_nvhe_sym(__icache_flags) = __icache_flags; 1897 1898 } 1898 1899 1899 1900 static int kvm_hyp_init_protection(u32 hyp_va_bits)
+11
arch/arm64/kvm/hyp/nvhe/cache.S
··· 12 12 ret 13 13 SYM_FUNC_END(__pi_dcache_clean_inval_poc) 14 14 SYM_FUNC_ALIAS(dcache_clean_inval_poc, __pi_dcache_clean_inval_poc) 15 + 16 + SYM_FUNC_START(__pi_icache_inval_pou) 17 + alternative_if ARM64_HAS_CACHE_DIC 18 + isb 19 + ret 20 + alternative_else_nop_endif 21 + 22 + invalidate_icache_by_line x0, x1, x2, x3 23 + ret 24 + SYM_FUNC_END(__pi_icache_inval_pou) 25 + SYM_FUNC_ALIAS(icache_inval_pou, __pi_icache_inval_pou)
+3
arch/arm64/kvm/hyp/nvhe/pkvm.c
··· 12 12 #include <nvhe/pkvm.h> 13 13 #include <nvhe/trap_handler.h> 14 14 15 + /* Used by icache_is_vpipt(). */ 16 + unsigned long __icache_flags; 17 + 15 18 /* 16 19 * Set trap register values based on features in ID_AA64PFR0. 17 20 */