Skip to content

Commit

Permalink
KVM: arm64: Ignore kvm-arm.mode if !is_hyp_mode_available()
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
eberman-quic authored and Marc Zyngier committed Sep 26, 2022
1 parent 096560d commit b2a4d00
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions arch/arm64/kvm/arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2270,6 +2270,16 @@ static int __init early_kvm_mode_cfg(char *arg)
if (!arg)
return -EINVAL;

if (strcmp(arg, "none") == 0) {
kvm_mode = KVM_MODE_NONE;
return 0;
}

if (!is_hyp_mode_available()) {
pr_warn_once("KVM is not available. Ignoring kvm-arm.mode\n");
return 0;
}

if (strcmp(arg, "protected") == 0) {
if (!is_kernel_in_hyp_mode())
kvm_mode = KVM_MODE_PROTECTED;
Expand All @@ -2284,11 +2294,6 @@ static int __init early_kvm_mode_cfg(char *arg)
return 0;
}

if (strcmp(arg, "none") == 0) {
kvm_mode = KVM_MODE_NONE;
return 0;
}

return -EINVAL;
}
early_param("kvm-arm.mode", early_kvm_mode_cfg);
Expand Down

0 comments on commit b2a4d00

Please sign in to comment.