All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: "Wu, Feng" <feng.wu@intel.com>
Cc: "Nakajima, Jun" <jun.nakajima@intel.com>,
	xen-devel <xen-devel@lists.xenproject.org>,
	"Auld, Will" <will.auld@intel.com>,
	"Zhang, Xiantao" <xiantao.zhang@intel.com>,
	Jan Beulich <JBeulich@suse.com>
Subject: Re: [PATCH v4] x86: properly handle MSI-X unmask operation from guests
Date: Sat, 23 Nov 2013 16:19:48 +0000	[thread overview]
Message-ID: <5290D5A4.50908@citrix.com> (raw)
In-Reply-To: <E959C4978C3B6342920538CF579893F001CC5DA4@SHSMSX104.ccr.corp.intel.com>

On 23/11/13 01:40, Wu, Feng wrote:
>
>> -----Original Message-----
>> From: Jan Beulich [mailto:JBeulich@suse.com]
>> Sent: Saturday, November 23, 2013 12:19 AM
>> To: Wu, Feng
>> Cc: Nakajima, Jun; Auld, Will; Zhang, Xiantao; xen-devel
>> Subject: Re: [PATCH v4] x86: properly handle MSI-X unmask operation from
>> guests
>>
>>>>> On 22.11.13 at 02:08, "Wu, Feng" <feng.wu@intel.com> wrote:
>>> v1: Initial patch to handle this issue involving changing the hypercall interface
>>> v2:Totally handled inside hypervisor.
>>> v3:Change some logics of handling msi-x pending unmask operations.
>>> v4:Some changes related to coding style according to Andrew Cooper's
>> comments
>>
>> So this is _much_ less intrusive than what you did before - good!
>>
>>> --- a/xen/arch/x86/hvm/io.c
>>> +++ b/xen/arch/x86/hvm/io.c
>>> @@ -297,6 +297,9 @@ void hvm_io_assist(ioreq_t *p)
>>>          break;
>>>      }
>>>
>>> +    if ( msix_post_handler(curr) )
>>> +        gdprintk(XENLOG_ERR, "msix_post_handler error\n");
>>> +
>>>      if ( p->state == STATE_IOREQ_NONE )
>>>          vcpu_end_shutdown_deferral(curr);
>> I think the addition should be moved into the body of this if(),
>> so that it gets executed only upon completion of I/O, not when
>> it e.g. need retrying.
>>
>> Also, XENLOG_ERR seems to heavy a message. XENLOG_WARN
>> would be the highest I'd accept.
>>
>>> +int msix_post_handler(struct vcpu *v)
>>> +{
>>> +    int rc;
>>> +
>>> +    if ( v->arch.pending_msix_unmask.valid == 0 )
>> Iff you keep this (see below), then boolean checks are
>> conventionally done with ! rather than == 0.
>>
>>> +        return 0;
>>> +
>>> +    v->arch.pending_msix_unmask.valid = 0;
>>> +
>>> +    rc = msixtbl_write(v, v->arch.pending_msix_unmask.ctrl_address, 4, 0);
>>> +    return rc != X86EMUL_OKAY ? -1 : 0;
>> Make the function return bool_t, and then simply
>>
>>    return msixtbl_write(v, v->arch.pending_msix_unmask.ctrl_address, 4, 0) ==
>> X86EMUL_OKAY;
>>
>>> +struct pending_msix_unmask_info
>>> +{
>>> +    unsigned long ctrl_address;
>>> +    bool_t valid;
>>> +};
>>> +
>>>  struct arch_vcpu
>>>  {
>>>      /*
>>> @@ -439,6 +445,8 @@ struct arch_vcpu
>>>
>>>      /* A secondary copy of the vcpu time info. */
>>>      XEN_GUEST_HANDLE(vcpu_time_info_t) time_info_guest;
>>> +
>>> +    struct pending_msix_unmask_info pending_msix_unmask;
>> I don't think you need a separate boolean here - for one I don't
>> think the address can reasonably be zero, and even if you have
>> the bottom two bits available (as it being 4-byte aligned gets
>> checked before you consume it).
>
> The boolean variant "valid", which is set in msixtbl_write(), means whether there is a
> msix pending unmask, if there is, just clean this flag and unmask the msix in hardware,
> otherwise we just do nothing. If removing "valid", how can I know whether there is a
> msix pending unmask operation ? Thanks you!

Address can't reasonably be 0, meaning that an address of 0 indicates
that an unmask is not pending.

~Andrew

  reply	other threads:[~2013-11-23 16:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-22  1:08 [PATCH v4] x86: properly handle MSI-X unmask operation from guests Wu, Feng
2013-11-22 10:49 ` Andrew Cooper
2013-11-22 13:39   ` Wu, Feng
2013-11-22 13:52     ` Andrew Cooper
2013-11-22 14:05       ` Wu, Feng
2013-11-22 16:18 ` Jan Beulich
2013-11-23  1:40   ` Wu, Feng
2013-11-23 16:19     ` Andrew Cooper [this message]
2013-11-24  6:52       ` Wu, Feng
2013-11-25  9:29     ` Jan Beulich
2013-11-25 12:09       ` Wu, Feng

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=5290D5A4.50908@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=feng.wu@intel.com \
    --cc=jun.nakajima@intel.com \
    --cc=will.auld@intel.com \
    --cc=xen-devel@lists.xenproject.org \
    --cc=xiantao.zhang@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.