Skip to content

Commit b2a4d00

Browse files
eberman-quicMarc Zyngier
authored andcommitted
KVM: arm64: Ignore kvm-arm.mode if !is_hyp_mode_available()
Ignore kvm-arm.mode if !is_hyp_mode_available(). Specifically, we want to avoid switching kvm_mode to KVM_MODE_PROTECTED if hypervisor mode is not available. This prevents "Protected KVM" cpu capability being reported when Linux is booting in EL1 and would not have KVM enabled. Reasonably though, we should warn if the command line is requesting a KVM mode at all if KVM isn't actually available. Allow "kvm-arm.mode=none" to skip the warning since this would disable KVM anyway. Signed-off-by: Elliot Berman <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 096560d commit b2a4d00

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

arch/arm64/kvm/arm.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,16 @@ static int __init early_kvm_mode_cfg(char *arg)
22702270
if (!arg)
22712271
return -EINVAL;
22722272

2273+
if (strcmp(arg, "none") == 0) {
2274+
kvm_mode = KVM_MODE_NONE;
2275+
return 0;
2276+
}
2277+
2278+
if (!is_hyp_mode_available()) {
2279+
pr_warn_once("KVM is not available. Ignoring kvm-arm.mode\n");
2280+
return 0;
2281+
}
2282+
22732283
if (strcmp(arg, "protected") == 0) {
22742284
if (!is_kernel_in_hyp_mode())
22752285
kvm_mode = KVM_MODE_PROTECTED;
@@ -2284,11 +2294,6 @@ static int __init early_kvm_mode_cfg(char *arg)
22842294
return 0;
22852295
}
22862296

2287-
if (strcmp(arg, "none") == 0) {
2288-
kvm_mode = KVM_MODE_NONE;
2289-
return 0;
2290-
}
2291-
22922297
return -EINVAL;
22932298
}
22942299
early_param("kvm-arm.mode", early_kvm_mode_cfg);

0 commit comments

Comments
 (0)