All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] KVM: VMX: Do not fully reset PI descriptor on vCPU reset
@ 2017-10-25 14:43 Jan H. Schönherr
  2017-10-25 14:43 ` [PATCH 2/2] KVM: x86: Update APICv on APIC reset Jan H. Schönherr
  0 siblings, 1 reply; 2+ messages in thread
From: Jan H. Schönherr @ 2017-10-25 14:43 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Jan H. Schönherr, Joerg Roedel, kvm

Parts of the posted interrupt descriptor configure host behavior,
such as the notification vector and destination. Overwriting them
with zero as done during vCPU reset breaks posted interrupts.
KVM (re-)writes these fields on certain occasions and belatedly fixes
the situation in many cases. However, if you have a guest configured
with "idle=poll", for example, the fields might stay zero forever.

Do not reset the full descriptor in vmx_vcpu_reset(). Instead,
reset only the outstanding notifications and leave everything
else untouched.

Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de>
---
 arch/x86/kvm/vmx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index e6c8ffa..2e008e4 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5618,8 +5618,10 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
 
 	kvm_make_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu);
 
-	if (kvm_vcpu_apicv_active(vcpu))
-		memset(&vmx->pi_desc, 0, sizeof(struct pi_desc));
+	if (kvm_vcpu_apicv_active(vcpu)) {
+		pi_clear_on(&vmx->pi_desc);
+		memset(vmx->pi_desc.pir, 0, sizeof(vmx->pi_desc.pir));
+	}
 
 	if (vmx->vpid != 0)
 		vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid);
-- 
2.3.1.dirty

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

* [PATCH 2/2] KVM: x86: Update APICv on APIC reset
  2017-10-25 14:43 [PATCH 1/2] KVM: VMX: Do not fully reset PI descriptor on vCPU reset Jan H. Schönherr
@ 2017-10-25 14:43 ` Jan H. Schönherr
  0 siblings, 0 replies; 2+ messages in thread
From: Jan H. Schönherr @ 2017-10-25 14:43 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Jan H. Schönherr, Joerg Roedel, kvm

In kvm_apic_set_state() we update the hardware virtualized APIC after
the full APIC state has been overwritten. Do the same, when the full
APIC state has been reset in kvm_lapic_reset().

This updates some hardware state that was previously forgotten, as
far as I can tell. Also, this allows removing some APIC-related reset
code from vmx_vcpu_reset().

Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de>
---
 arch/x86/kvm/lapic.c | 5 +++++
 arch/x86/kvm/vmx.c   | 5 -----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index a778f1a..943acbf 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -2041,6 +2041,11 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu, bool init_event)
 				vcpu->arch.apic_base | MSR_IA32_APICBASE_BSP);
 	vcpu->arch.pv_eoi.msr_val = 0;
 	apic_update_ppr(apic);
+	if (vcpu->arch.apicv_active) {
+		kvm_x86_ops->apicv_post_state_restore(vcpu);
+		kvm_x86_ops->hwapic_irr_update(vcpu, -1);
+		kvm_x86_ops->hwapic_isr_update(vcpu, -1);
+	}
 
 	vcpu->arch.apic_arb_prio = 0;
 	vcpu->arch.apic_attention = 0;
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 2e008e4..7c3522a 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5618,11 +5618,6 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
 
 	kvm_make_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu);
 
-	if (kvm_vcpu_apicv_active(vcpu)) {
-		pi_clear_on(&vmx->pi_desc);
-		memset(vmx->pi_desc.pir, 0, sizeof(vmx->pi_desc.pir));
-	}
-
 	if (vmx->vpid != 0)
 		vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid);
 
-- 
2.3.1.dirty

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

end of thread, other threads:[~2017-10-25 14:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-25 14:43 [PATCH 1/2] KVM: VMX: Do not fully reset PI descriptor on vCPU reset Jan H. Schönherr
2017-10-25 14:43 ` [PATCH 2/2] KVM: x86: Update APICv on APIC reset Jan H. Schönherr

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.