public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@qumranet.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Chris Wright <chrisw@redhat.com>, kvm@vger.kernel.org
Subject: Re: [patch 2/2] KVM: close timer injection race window in __vcpu_run
Date: Sun, 08 Jun 2008 10:17:15 +0300	[thread overview]
Message-ID: <484B877B.1080108@qumranet.com> (raw)
In-Reply-To: <20080606194010.961258871@localhost.localdomain>

Marcelo Tosatti wrote:
> If a timer fires after kvm_inject_pending_timer_irqs() but before
> local_irq_disable() the code will enter guest mode and only inject such
> timer interrupt the next time an unrelated event causes an exit.
>
> It would be simpler if the timer->pending irq conversion could be done
> with IRQ's disabled, so that the above problem cannot happen.
>
> For now introduce a new vcpu requests bit to cancel guest entry.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
>   

Applied this too.

> Index: kvm/arch/x86/kvm/i8254.c
> ===================================================================
> --- kvm.orig/arch/x86/kvm/i8254.c
> +++ kvm/arch/x86/kvm/i8254.c
> @@ -200,9 +200,12 @@ static int __pit_timer_fn(struct kvm_kpi
>  
>  	atomic_inc(&pt->pending);
>  	smp_mb__after_atomic_inc();
> -	if (vcpu0 && waitqueue_active(&vcpu0->wq)) {
> -		vcpu0->arch.mp_state = KVM_MP_STATE_RUNNABLE;
> -		wake_up_interruptible(&vcpu0->wq);
> +	if (vcpu0) {
> +		set_bit(KVM_REQ_PENDING_TIMER, &vcpu0->requests);
> +		if (waitqueue_active(&vcpu0->wq)) {
> +			vcpu0->arch.mp_state = KVM_MP_STATE_RUNNABLE;
> +			wake_up_interruptible(&vcpu0->wq);
> +		}
>  	}
>  
>   

We probably ought to wakeup only if pt->pending was zero, no?

-- 
error compiling committee.c: too many arguments to function


  reply	other threads:[~2008-06-08  7:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-06 19:37 [patch 0/2] timer injection races Marcelo Tosatti
2008-06-06 19:37 ` [patch 1/2] KVM: consolidate check for pending vcpu requests Marcelo Tosatti
2008-06-08  7:10   ` Avi Kivity
2008-06-06 19:37 ` [patch 2/2] KVM: close timer injection race window in __vcpu_run Marcelo Tosatti
2008-06-08  7:17   ` Avi Kivity [this message]
2008-06-08 15:08     ` Marcelo Tosatti
2008-06-09  3:29       ` Marcelo Tosatti

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=484B877B.1080108@qumranet.com \
    --to=avi@qumranet.com \
    --cc=chrisw@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox