Skip to content

Commit cde5042

Browse files
willdeaconMarc Zyngier
authored andcommitted
KVM: arm64: Ignore 'kvm-arm.mode=protected' when using VHE
Ignore 'kvm-arm.mode=protected' when using VHE so that kvm_get_mode() only returns KVM_MODE_PROTECTED on systems where the feature is available. Cc: David Brazdil <[email protected]> Acked-by: Mark Rutland <[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 fa7a172 commit cde5042

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2469,7 +2469,6 @@
24692469

24702470
protected: nVHE-based mode with support for guests whose
24712471
state is kept private from the host.
2472-
Not valid if the kernel is running in EL2.
24732472

24742473
Defaults to VHE/nVHE based on hardware support. Setting
24752474
mode to "protected" will disable kexec and hibernation

arch/arm64/kernel/cpufeature.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,15 +1974,7 @@ static void cpu_enable_mte(struct arm64_cpu_capabilities const *cap)
19741974
#ifdef CONFIG_KVM
19751975
static bool is_kvm_protected_mode(const struct arm64_cpu_capabilities *entry, int __unused)
19761976
{
1977-
if (kvm_get_mode() != KVM_MODE_PROTECTED)
1978-
return false;
1979-
1980-
if (is_kernel_in_hyp_mode()) {
1981-
pr_warn("Protected KVM not available with VHE\n");
1982-
return false;
1983-
}
1984-
1985-
return true;
1977+
return kvm_get_mode() == KVM_MODE_PROTECTED;
19861978
}
19871979
#endif /* CONFIG_KVM */
19881980

arch/arm64/kvm/arm.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2273,7 +2273,11 @@ static int __init early_kvm_mode_cfg(char *arg)
22732273
return -EINVAL;
22742274

22752275
if (strcmp(arg, "protected") == 0) {
2276-
kvm_mode = KVM_MODE_PROTECTED;
2276+
if (!is_kernel_in_hyp_mode())
2277+
kvm_mode = KVM_MODE_PROTECTED;
2278+
else
2279+
pr_warn_once("Protected KVM not available with VHE\n");
2280+
22772281
return 0;
22782282
}
22792283

0 commit comments

Comments
 (0)