public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: Fix CPUHP logic for protected KVM
@ 2023-07-19 17:54 Raghavendra Rao Ananta
  2023-07-19 20:48 ` Oliver Upton
  0 siblings, 1 reply; 3+ messages in thread
From: Raghavendra Rao Ananta @ 2023-07-19 17:54 UTC (permalink / raw)
  To: Oliver Upton, Marc Zyngier
  Cc: James Morse, Suzuki K Poulose, Will Deacon, Fuad Tabba,
	Jing Zhang, Colton Lewis, Reiji Watanabe, Raghavendra Rao Anata,
	kvmarm, linux-kernel, kvm

For protected kvm, the CPU hotplug 'down' logic currently brings
down the timer and vGIC, essentially disabling interrupts. However,
because of how the 'kvm_arm_hardware_enabled' flag is designed, it
never re-enables them back on the CPU hotplug 'up' path. Hence,
clean up the logic to maintain the CPU hotplug up/down symmetry.

Fixes: 466d27e48d7c ("KVM: arm64: Simplify the CPUHP logic")
Reported-by: Oliver Upton <oliver.upton@linux.dev>
Suggested-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Raghavendra Rao Ananta <rananta@google.com>
---
 arch/arm64/kvm/arm.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index c2c14059f6a8..010ebfa69650 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -1867,14 +1867,10 @@ static void _kvm_arch_hardware_enable(void *discard)
 
 int kvm_arch_hardware_enable(void)
 {
-	int was_enabled = __this_cpu_read(kvm_arm_hardware_enabled);
-
 	_kvm_arch_hardware_enable(NULL);
 
-	if (!was_enabled) {
-		kvm_vgic_cpu_up();
-		kvm_timer_cpu_up();
-	}
+	kvm_vgic_cpu_up();
+	kvm_timer_cpu_up();
 
 	return 0;
 }
@@ -1889,10 +1885,8 @@ static void _kvm_arch_hardware_disable(void *discard)
 
 void kvm_arch_hardware_disable(void)
 {
-	if (__this_cpu_read(kvm_arm_hardware_enabled)) {
-		kvm_timer_cpu_down();
-		kvm_vgic_cpu_down();
-	}
+	kvm_timer_cpu_down();
+	kvm_vgic_cpu_down();
 
 	if (!is_protected_kvm_enabled())
 		_kvm_arch_hardware_disable(NULL);
-- 
2.41.0.487.g6d72f3e995-goog


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

end of thread, other threads:[~2023-07-19 21:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-19 17:54 [PATCH] KVM: arm64: Fix CPUHP logic for protected KVM Raghavendra Rao Ananta
2023-07-19 20:48 ` Oliver Upton
2023-07-19 21:16   ` Raghavendra Rao Ananta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox