All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Nadav Amit <namit@cs.technion.ac.il>
Cc: kvm@vger.kernel.org, wanpeng.li@linux.intel.com, nadav.amit@gmail.com
Subject: Re: [PATCH] KVM: x86: Fix lost interrupt on irr_pending race
Date: Tue, 18 Nov 2014 20:51:04 +0100	[thread overview]
Message-ID: <546BA328.9010009@redhat.com> (raw)
In-Reply-To: <1416174547-5309-1-git-send-email-namit@cs.technion.ac.il>



On 16/11/2014 22:49, Nadav Amit wrote:
> @@ -374,13 +378,15 @@ static inline void apic_clear_irr(int vec, struct kvm_lapic *apic)
>  
>  	vcpu = apic->vcpu;
>  
> -	apic_clear_vector(vec, apic->regs + APIC_IRR);
> -	if (unlikely(kvm_apic_vid_enabled(vcpu->kvm)))
> +	if (unlikely(kvm_apic_vid_enabled(vcpu->kvm))) {
>  		/* try to update RVI */
> +		apic_clear_vector(vec, apic->regs + APIC_IRR);
>  		kvm_make_request(KVM_REQ_EVENT, vcpu);
> -	else {
> -		vec = apic_search_irr(apic);
> -		apic->irr_pending = (vec != -1);
> +	} else {
> +		apic->irr_pending = false;
> +		apic_clear_vector(vec, apic->regs + APIC_IRR);
> +		if (apic_search_irr(apic) != -1)
> +			apic->irr_pending = true;
>  	}
>  }

This is even more tricky than it looks like. :)

No one can concurrently look at apic->irr_pending while it is false, in
particular apic_sync_pv_eoi_to_guest cannot enable PV EOI by mistake
just because it sees a false irr_pending.  So it's okay if it is first
set to false and then to true.

I'll apply the patch tomorrow.

Paolo

  parent reply	other threads:[~2014-11-18 19:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-16 21:49 [PATCH] KVM: x86: Fix lost interrupt on irr_pending race Nadav Amit
2014-11-18 15:03 ` Radim Krčmář
2014-11-18 19:51 ` Paolo Bonzini [this message]
2014-11-18 21:31   ` Radim Krčmář

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=546BA328.9010009@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=nadav.amit@gmail.com \
    --cc=namit@cs.technion.ac.il \
    --cc=wanpeng.li@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.