public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH MANUALSEL 5.18 1/3] KVM: x86: disable preemption while updating apicv inhibition
@ 2022-06-21 21:21 Sasha Levin
  2022-06-21 21:21 ` [PATCH MANUALSEL 5.18 2/3] KVM: x86: disable preemption around the call to kvm_arch_vcpu_{un|}blocking Sasha Levin
  2022-06-21 21:21 ` [PATCH MANUALSEL 5.18 3/3] KVM: selftests: Restrict test region to 48-bit physical addresses when using nested Sasha Levin
  0 siblings, 2 replies; 3+ messages in thread
From: Sasha Levin @ 2022-06-21 21:21 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Maxim Levitsky, Paolo Bonzini, Sasha Levin, tglx, mingo, bp,
	dave.hansen, x86, kvm

From: Maxim Levitsky <mlevitsk@redhat.com>

[ Upstream commit 66c768d30e64e1280520f34dbef83419f55f3459 ]

Currently nothing prevents preemption in kvm_vcpu_update_apicv.

On SVM, If the preemption happens after we update the
vcpu->arch.apicv_active, the preemption itself will
'update' the inhibition since the AVIC will be first disabled
on vCPU unload and then enabled, when the current task
is loaded again.

Then we will try to update it again, which will lead to a warning
in __avic_vcpu_load, that the AVIC is already enabled.

Fix this by disabling preemption in this code.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20220606180829.102503-6-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/x86/kvm/x86.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 558d1f2ab5b4..5523bd4b3702 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -9765,6 +9765,7 @@ void kvm_vcpu_update_apicv(struct kvm_vcpu *vcpu)
 		return;
 
 	down_read(&vcpu->kvm->arch.apicv_update_lock);
+	preempt_disable();
 
 	activate = kvm_apicv_activated(vcpu->kvm);
 	if (vcpu->arch.apicv_active == activate)
@@ -9784,6 +9785,7 @@ void kvm_vcpu_update_apicv(struct kvm_vcpu *vcpu)
 		kvm_make_request(KVM_REQ_EVENT, vcpu);
 
 out:
+	preempt_enable();
 	up_read(&vcpu->kvm->arch.apicv_update_lock);
 }
 EXPORT_SYMBOL_GPL(kvm_vcpu_update_apicv);
-- 
2.35.1


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

end of thread, other threads:[~2022-06-21 21:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-21 21:21 [PATCH MANUALSEL 5.18 1/3] KVM: x86: disable preemption while updating apicv inhibition Sasha Levin
2022-06-21 21:21 ` [PATCH MANUALSEL 5.18 2/3] KVM: x86: disable preemption around the call to kvm_arch_vcpu_{un|}blocking Sasha Levin
2022-06-21 21:21 ` [PATCH MANUALSEL 5.18 3/3] KVM: selftests: Restrict test region to 48-bit physical addresses when using nested Sasha Levin

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