All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	Keir Fraser <keir@xen.org>,
	David Vrabel <david.vrabel@citrix.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: Re: [PATCH] xen: correctly check for pending events when restoring irq flags
Date: Fri, 27 Apr 2012 14:51:35 +0100	[thread overview]
Message-ID: <4F9AC08702000078000807B1@nat28.tlf.novell.com> (raw)
In-Reply-To: <1335532197.28015.205.camel@zakaz.uk.xensource.com>

>>> On 27.04.12 at 15:09, Ian Campbell <Ian.Campbell@citrix.com> wrote:
> On Fri, 2012-04-27 at 13:46 +0100, Jan Beulich wrote:
>> >>> On 27.04.12 at 13:58, Ian Campbell <Ian.Campbell@citrix.com> wrote:
>> > On Fri, 2012-04-27 at 12:42 +0100, Jan Beulich wrote:
>> >> >>> On 27.04.12 at 10:47, Ian Campbell <Ian.Campbell@citrix.com> wrote:
>> > Hrm, has it ever not been 1 in practice?
>> 
>> I don't think so.
>> 
>> > i.e. could we legitimately tighten the spec?
>> 
>> I wouldn't want to recommend this. In particular, we can't all of the
>> sudden keep guests from storing other non-zero values in here.
> 
> Could they be doing this? Whatever they put there is going to get
> clobbered by Xen whenever it injects an event, isn't it? Or do you mean
> that a guest can force an upcall by writing non-zero itself? Do guests
> actually do that? (why?)

Yes, there is such a case even in Linux - see unmask_evtchn(). And
tightening an existing spec in ways that affect things we don't
control seems undesirable (and unnecessary here).

>> While I'm not in favor of this either, what we could do is specify that
>> Xen will only ever write 0 or 1 in here, while other non-zero values
>> are okay to be used by guests.
> 
> Does Xen ever clear an upcall, isn't that always the guest? Xen only
> ever writes 1, at least as far as I can see...

Oh, yes, you're right of course.

> What do you think of the following?

Reads okay.

Jan

> --- a/xen/include/public/xen.h	Thu Apr 26 10:03:08 2012 +0100
> +++ b/xen/include/public/xen.h	Fri Apr 27 14:09:00 2012 +0100
> @@ -559,16 +559,18 @@ typedef struct vcpu_time_info vcpu_time_
>  
>  struct vcpu_info {
>      /*
> -     * 'evtchn_upcall_pending' is written non-zero by Xen to indicate
> -     * a pending notification for a particular VCPU. It is then cleared 
> -     * by the guest OS /before/ checking for pending work, thus avoiding
> -     * a set-and-check race. Note that the mask is only accessed by Xen
> -     * on the CPU that is currently hosting the VCPU. This means that the
> -     * pending and mask flags can be updated by the guest without special
> -     * synchronisation (i.e., no need for the x86 LOCK prefix).
> -     * This may seem suboptimal because if the pending flag is set by
> -     * a different CPU then an IPI may be scheduled even when the mask
> -     * is set. However, note:
> +     * 'evtchn_upcall_pending' is written to '1' by Xen to indicate a
> +     * pending notification for a particular VCPU. Xen will never
> +     * write any other value but it is legitimate for a guest to store
> +     * any other non-zero value here to trigger an upcall. It is then
> +     * cleared by the guest OS /before/ checking for pending work,
> +     * thus avoiding a set-and-check race. Note that the mask is only
> +     * accessed by Xen on the CPU that is currently hosting the
> +     * VCPU. This means that the pending and mask flags can be updated
> +     * by the guest without special synchronisation (i.e., no need for
> +     * the x86 LOCK prefix).  This may seem suboptimal because if the
> +     * pending flag is set by a different CPU then an IPI may be
> +     * scheduled even when the mask is set. However, note:
>       *  1. The task of 'interrupt holdoff' is covered by the per-event-
>       *     channel mask bits. A 'noisy' event that is continually being
>       *     triggered can be masked at source at this very precise

      reply	other threads:[~2012-04-27 13:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-26 18:44 [PATCH] xen: correctly check for pending events when restoring irq flags David Vrabel
2012-04-26 20:08 ` Konrad Rzeszutek Wilk
2012-04-27  8:47 ` Ian Campbell
2012-04-27 11:41   ` David Vrabel
2012-04-27 11:42   ` Jan Beulich
2012-04-27 11:58     ` Ian Campbell
2012-04-27 12:46       ` Jan Beulich
2012-04-27 13:09         ` Ian Campbell
2012-04-27 13:51           ` Jan Beulich [this message]

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=4F9AC08702000078000807B1@nat28.tlf.novell.com \
    --to=jbeulich@suse.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=david.vrabel@citrix.com \
    --cc=keir@xen.org \
    --cc=konrad.wilk@oracle.com \
    --cc=xen-devel@lists.xensource.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.