public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Pending interrupt may be delivered after INIT
@ 2014-06-30  8:35 Nadav Amit
  2014-06-30  8:47 ` Gleb Natapov
  0 siblings, 1 reply; 4+ messages in thread
From: Nadav Amit @ 2014-06-30  8:35 UTC (permalink / raw)
  To: pbonzini; +Cc: gleb, tglx, mingo, x86, kvm, linux-kernel, Nadav Amit

We encountered a scenario in which after an INIT is delivered, a pending
interrupt is delivered, although it was sent before the INIT.  As the SDM
states in section 10.4.7.1, the ISR and the IRR should be cleared after INIT as
KVM does.  This also means that pending interrupts should be cleared.  This
patch clears upon reset (and INIT) the pending interrupts; and at the same
occassion clears the pending exceptions, since they may cause a similar issue.

Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
---
 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 f32a025..863ac07 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6835,6 +6835,8 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu)
 	atomic_set(&vcpu->arch.nmi_queued, 0);
 	vcpu->arch.nmi_pending = 0;
 	vcpu->arch.nmi_injected = false;
+	vcpu->arch.interrupt.pending = false;
+	vcpu->arch.exception.pending = false;
 
 	memset(vcpu->arch.db, 0, sizeof(vcpu->arch.db));
 	vcpu->arch.dr6 = DR6_FIXED_1;
-- 
1.9.1


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

* Re: [PATCH] KVM: x86: Pending interrupt may be delivered after INIT
  2014-06-30  8:35 [PATCH] KVM: x86: Pending interrupt may be delivered after INIT Nadav Amit
@ 2014-06-30  8:47 ` Gleb Natapov
  2014-06-30  9:03   ` [PATCH v2] " Nadav Amit
  0 siblings, 1 reply; 4+ messages in thread
From: Gleb Natapov @ 2014-06-30  8:47 UTC (permalink / raw)
  To: Nadav Amit; +Cc: pbonzini, tglx, mingo, x86, kvm, linux-kernel

On Mon, Jun 30, 2014 at 11:35:27AM +0300, Nadav Amit wrote:
> We encountered a scenario in which after an INIT is delivered, a pending
> interrupt is delivered, although it was sent before the INIT.  As the SDM
> states in section 10.4.7.1, the ISR and the IRR should be cleared after INIT as
> KVM does.  This also means that pending interrupts should be cleared.  This
> patch clears upon reset (and INIT) the pending interrupts; and at the same
> occassion clears the pending exceptions, since they may cause a similar issue.
> 
> Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
> ---
>  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 f32a025..863ac07 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -6835,6 +6835,8 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu)
>  	atomic_set(&vcpu->arch.nmi_queued, 0);
>  	vcpu->arch.nmi_pending = 0;
>  	vcpu->arch.nmi_injected = false;
> +	vcpu->arch.interrupt.pending = false;
> +	vcpu->arch.exception.pending = false;
kvm_clear_interrupt_queue(vcpu);
kvm_clear_exception_queue(vcpu);

>  
>  	memset(vcpu->arch.db, 0, sizeof(vcpu->arch.db));
>  	vcpu->arch.dr6 = DR6_FIXED_1;
> -- 
> 1.9.1
> 

--
			Gleb.

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

* [PATCH v2] KVM: x86: Pending interrupt may be delivered after INIT
  2014-06-30  8:47 ` Gleb Natapov
@ 2014-06-30  9:03   ` Nadav Amit
  2014-07-09 16:10     ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Nadav Amit @ 2014-06-30  9:03 UTC (permalink / raw)
  To: pbonzini; +Cc: gleb, tglx, mingo, x86, kvm, linux-kernel, Nadav Amit

We encountered a scenario in which after an INIT is delivered, a pending
interrupt is delivered, although it was sent before the INIT.  As the SDM
states in section 10.4.7.1, the ISR and the IRR should be cleared after INIT as
KVM does.  This also means that pending interrupts should be cleared.  This
patch clears upon reset (and INIT) the pending interrupts; and at the same
occassion clears the pending exceptions, since they may cause a similar issue.

Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
---
 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 f32a025..6425a31 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6835,6 +6835,8 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu)
 	atomic_set(&vcpu->arch.nmi_queued, 0);
 	vcpu->arch.nmi_pending = 0;
 	vcpu->arch.nmi_injected = false;
+	kvm_clear_interrupt_queue(vcpu);
+	kvm_clear_exception_queue(vcpu);
 
 	memset(vcpu->arch.db, 0, sizeof(vcpu->arch.db));
 	vcpu->arch.dr6 = DR6_FIXED_1;
-- 
1.9.1


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

* Re: [PATCH v2] KVM: x86: Pending interrupt may be delivered after INIT
  2014-06-30  9:03   ` [PATCH v2] " Nadav Amit
@ 2014-07-09 16:10     ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2014-07-09 16:10 UTC (permalink / raw)
  To: Nadav Amit; +Cc: gleb, tglx, mingo, x86, kvm, linux-kernel

Il 30/06/2014 11:03, Nadav Amit ha scritto:
> We encountered a scenario in which after an INIT is delivered, a pending
> interrupt is delivered, although it was sent before the INIT.  As the SDM
> states in section 10.4.7.1, the ISR and the IRR should be cleared after INIT as
> KVM does.  This also means that pending interrupts should be cleared.  This
> patch clears upon reset (and INIT) the pending interrupts; and at the same
> occassion clears the pending exceptions, since they may cause a similar issue.
>
> Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
> ---
>  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 f32a025..6425a31 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -6835,6 +6835,8 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu)
>  	atomic_set(&vcpu->arch.nmi_queued, 0);
>  	vcpu->arch.nmi_pending = 0;
>  	vcpu->arch.nmi_injected = false;
> +	kvm_clear_interrupt_queue(vcpu);
> +	kvm_clear_exception_queue(vcpu);
>
>  	memset(vcpu->arch.db, 0, sizeof(vcpu->arch.db));
>  	vcpu->arch.dr6 = DR6_FIXED_1;
>

Applied to kvm/queue, thanks.

Paolo

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

end of thread, other threads:[~2014-07-09 16:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-30  8:35 [PATCH] KVM: x86: Pending interrupt may be delivered after INIT Nadav Amit
2014-06-30  8:47 ` Gleb Natapov
2014-06-30  9:03   ` [PATCH v2] " Nadav Amit
2014-07-09 16:10     ` Paolo Bonzini

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