Skip to content

Commit 13e248a

Browse files
willdeaconMarc Zyngier
authored andcommitted
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 <[email protected]> Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6c16522 commit 13e248a

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

arch/arm64/include/asm/kvm_hyp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,5 @@ extern u64 kvm_nvhe_sym(id_aa64mmfr0_el1_sys_val);
123123
extern u64 kvm_nvhe_sym(id_aa64mmfr1_el1_sys_val);
124124
extern u64 kvm_nvhe_sym(id_aa64mmfr2_el1_sys_val);
125125

126+
extern unsigned long kvm_nvhe_sym(__icache_flags);
126127
#endif /* __ARM64_KVM_HYP_H__ */

arch/arm64/kernel/image-vars.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ KVM_NVHE_ALIAS(nvhe_hyp_panic_handler);
7171
/* Vectors installed by hyp-init on reset HVC. */
7272
KVM_NVHE_ALIAS(__hyp_stub_vectors);
7373

74-
/* Kernel symbol used by icache_is_vpipt(). */
75-
KVM_NVHE_ALIAS(__icache_flags);
76-
7774
/* VMID bits set by the KVM VMID allocator */
7875
KVM_NVHE_ALIAS(kvm_arm_vmid_bits);
7976

arch/arm64/kvm/arm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,6 +1894,7 @@ static void kvm_hyp_init_symbols(void)
18941894
kvm_nvhe_sym(id_aa64mmfr0_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1);
18951895
kvm_nvhe_sym(id_aa64mmfr1_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64MMFR1_EL1);
18961896
kvm_nvhe_sym(id_aa64mmfr2_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64MMFR2_EL1);
1897+
kvm_nvhe_sym(__icache_flags) = __icache_flags;
18971898
}
18981899

18991900
static int kvm_hyp_init_protection(u32 hyp_va_bits)

arch/arm64/kvm/hyp/nvhe/cache.S

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,14 @@ SYM_FUNC_START(__pi_dcache_clean_inval_poc)
1212
ret
1313
SYM_FUNC_END(__pi_dcache_clean_inval_poc)
1414
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)

arch/arm64/kvm/hyp/nvhe/pkvm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include <nvhe/pkvm.h>
1313
#include <nvhe/trap_handler.h>
1414

15+
/* Used by icache_is_vpipt(). */
16+
unsigned long __icache_flags;
17+
1518
/*
1619
* Set trap register values based on features in ID_AA64PFR0.
1720
*/

0 commit comments

Comments
 (0)