All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: Report Protected KVM cap only if KVM is enabled
@ 2022-09-02  4:01 ` Elliot Berman
  0 siblings, 0 replies; 9+ messages in thread
From: Elliot Berman @ 2022-09-02  4:01 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Marc Zyngier, James Morse,
	Alexandru Elisei, Suzuki K Poulose
  Cc: Elliot Berman, linux-kernel, linux-arm-kernel, kvmarm

If "kvm-arm.mode=protected" is present on kernel command line, but the
kernel doesn't actually support KVM because it booted from EL1, the
ARM64_KVM_PROTECTED_MODE capability is misleadingly reported as present.
Fix this by adding a check whether we booted from EL2.

Cc: Will Deacon <will@kernel.org>
Cc: David Brazdil <dbrazdil@google.com>
Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
---
 arch/arm64/kernel/cpufeature.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 8d88433de81d..866667be0651 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1974,7 +1974,7 @@ static void cpu_enable_mte(struct arm64_cpu_capabilities const *cap)
 #ifdef CONFIG_KVM
 static bool is_kvm_protected_mode(const struct arm64_cpu_capabilities *entry, int __unused)
 {
-	return kvm_get_mode() == KVM_MODE_PROTECTED;
+	return is_hyp_mode_available() && kvm_get_mode() == KVM_MODE_PROTECTED;
 }
 #endif /* CONFIG_KVM */
 

base-commit: 0982c8d859f8f7022b9fd44d421c7ec721bb41f9
-- 
2.25.1

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-09-09 12:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-02  4:01 [PATCH] KVM: arm64: Report Protected KVM cap only if KVM is enabled Elliot Berman
2022-09-02  4:01 ` Elliot Berman
2022-09-02  4:01 ` Elliot Berman
2022-09-09 12:44 ` Catalin Marinas
2022-09-09 12:44   ` Catalin Marinas
2022-09-09 12:44   ` Catalin Marinas
2022-09-09 12:47   ` Marc Zyngier
2022-09-09 12:47     ` Marc Zyngier
2022-09-09 12:47     ` Marc Zyngier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.