Skip to content

Commit a79f7b4

Browse files
author
Marc Zyngier
committed
KVM: arm64: pkvm: Don't reprobe for ICH_VTR_EL2.TDS on CPU hotplug
Hotplugging a CPU off and back on fails with pKVM, as we try to probe for ICH_VTR_EL2.TDS. In a non-VHE setup, this is achieved by using an EL2 stub helper. However, the stubs are out of reach once pKVM has deprivileged the kernel. The CPU never boots. Since pKVM doesn't allow late onlining of CPUs, we can detect that protected mode is enforced early on, and return the current state of the capability. Fixes: 2a28810 ("KVM: arm64: GICv3: Detect and work around the lack of ICV_DIR_EL1 trapping") Reported-by: Vincent Donnefort <[email protected]> Tested-by: Vincent Donnefort <[email protected]> Reviewed-by: Suzuki K Poulose <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: [email protected]
1 parent 6da5e53 commit a79f7b4

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

arch/arm64/kernel/cpufeature.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,6 +2345,15 @@ static bool can_trap_icv_dir_el1(const struct arm64_cpu_capabilities *entry,
23452345
!is_midr_in_range_list(has_vgic_v3))
23462346
return false;
23472347

2348+
/*
2349+
* pKVM prevents late onlining of CPUs. This means that whatever
2350+
* state the capability is in after deprivilege cannot be affected
2351+
* by a new CPU booting -- this is garanteed to be a CPU we have
2352+
* already seen, and the cap is therefore unchanged.
2353+
*/
2354+
if (system_capabilities_finalized() && is_protected_kvm_enabled())
2355+
return cpus_have_final_cap(ARM64_HAS_ICH_HCR_EL2_TDIR);
2356+
23482357
if (is_kernel_in_hyp_mode())
23492358
res.a1 = read_sysreg_s(SYS_ICH_VTR_EL2);
23502359
else

0 commit comments

Comments
 (0)