Skip to content

Commit 9bcbb61

Browse files
lokeshv-devMarc Zyngier
authored andcommitted
KVM: arm64: Flush hyp bss section after initialization of variables in bss
To determine CPU features during initialization, the nVHE hypervisor utilizes sanitized values of the host's CPU features registers. These values, stored in u64 idaa64*_el1_sys_val variables are updated by the kvm_hyp_init_symbols() function at EL1. To ensure EL2 visibility with the MMU off, the data cache needs to be flushed after these updates. However, individually flushing each variable using kvm_flush_dcache_to_poc() is inefficient. These cpu feature variables would be part of the bss section of the hypervisor. Hence, flush the entire bss section of hypervisor once the initialization is complete. Fixes: 6c30bfb ("KVM: arm64: Add handlers for protected VM System Registers") Suggested-by: Fuad Tabba <[email protected]> Signed-off-by: Lokesh Vutla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 01009b0 commit 9bcbb61

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arch/arm64/kvm/arm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,6 +2400,13 @@ static void kvm_hyp_init_symbols(void)
24002400
kvm_nvhe_sym(id_aa64smfr0_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64SMFR0_EL1);
24012401
kvm_nvhe_sym(__icache_flags) = __icache_flags;
24022402
kvm_nvhe_sym(kvm_arm_vmid_bits) = kvm_arm_vmid_bits;
2403+
2404+
/*
2405+
* Flush entire BSS since part of its data containing init symbols is read
2406+
* while the MMU is off.
2407+
*/
2408+
kvm_flush_dcache_to_poc(kvm_ksym_ref(__hyp_bss_start),
2409+
kvm_ksym_ref(__hyp_bss_end) - kvm_ksym_ref(__hyp_bss_start));
24032410
}
24042411

24052412
static int __init kvm_hyp_init_protection(u32 hyp_va_bits)

0 commit comments

Comments
 (0)