summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliot Berman <quic_eberman@quicinc.com>2022-09-20 12:06:58 -0700
committerTreehugger Robot <treehugger-gerrit@google.com>2023-03-07 19:36:52 +0000
commit4e11c7b3b1d87f40a70787eed1dfa470f37d79df (patch)
tree8c27fbe396ace55dc727bb29806dc902264ce4fa
parent57877cc46f439b2764b63d0bc2e1f117ae73811b (diff)
downloadcommon-4e11c7b3b1d87f40a70787eed1dfa470f37d79df.tar.gz
FROMGIT: 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 <quic_eberman@quicinc.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20220920190658.2880184-1-quic_eberman@quicinc.com Bug: 249052880 Bug: 271556415 (cherry picked from commit b2a4d007c347b4cb4c60f7512733c3f8300a129c https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next) Change-Id: I196649fc00537e563a1fab0a22bf23c5b7abe00d Signed-off-by: Elliot Berman <quic_eberman@quicinc.com> (cherry picked from commit 8015dd49c00e036b214801b34a727b7c98aa84e3)
-rw-r--r--arch/arm64/kvm/arm.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 20974e71c9a6..67c20d4d6ade 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -2142,6 +2142,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) {
kvm_mode = KVM_MODE_PROTECTED;
return 0;
@@ -2152,11 +2162,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);