Message ID | 20250121044016.2219256-1-lokeshvutla@google.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v2] KVM: arm64: Flush hyp bss section after initialization of variables in bss | expand |
On Tue, 21 Jan 2025 04:40:16 +0000, Lokesh Vutla wrote: > 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. > > [...] Applied to fixes, thanks! [1/1] KVM: arm64: Flush hyp bss section after initialization of variables in bss commit: 9bcbb6104a344d3526e185ee1e7b985509914e90 Cheers, M.
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index a102c3aebdbc..caacb2da8e09 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -2410,6 +2410,13 @@ static void kvm_hyp_init_symbols(void) kvm_nvhe_sym(id_aa64smfr0_el1_sys_val) = read_sanitised_ftr_reg(SYS_ID_AA64SMFR0_EL1); kvm_nvhe_sym(__icache_flags) = __icache_flags; kvm_nvhe_sym(kvm_arm_vmid_bits) = kvm_arm_vmid_bits; + + /* + * Flush entire BSS since part of its data containing init symbols is read + * while the MMU is off. + */ + kvm_flush_dcache_to_poc(kvm_ksym_ref(__hyp_bss_start), + kvm_ksym_ref(__hyp_bss_end) - kvm_ksym_ref(__hyp_bss_start)); } static int __init kvm_hyp_init_protection(u32 hyp_va_bits)
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: 6c30bfb18d0b ("KVM: arm64: Add handlers for protected VM System Registers") Suggested-by: Fuad Tabba <tabba@google.com> Signed-off-by: Lokesh Vutla <lokeshvutla@google.com> --- v1: https://lore.kernel.org/kvmarm/20250120151514.1769597-1-lokeshvutla@google.com/ - Applies on top of Linux 6.13 tag. Changes since v1: * Updated Commit message based on review * Updated kvm_flush_dcache_to_poc() to call from kvm_hyp_init_symbols() arch/arm64/kvm/arm.c | 7 +++++++ 1 file changed, 7 insertions(+)