xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Kevin Tian <kevin.tian@intel.com>, Keir Fraser <keir@xen.org>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Campbell <Ian.Campbell@eu.citrix.com>,
	Stefano Stabellini <stefano.stabellini@citrix.com>,
	Yang Z Zhang <yang.z.zhang@intel.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 3/3] pt-irq fixes and improvements
Date: Tue, 3 Jun 2014 15:50:43 +0100	[thread overview]
Message-ID: <538DE0C3.5010203@citrix.com> (raw)
In-Reply-To: <538DF12A020000780001769C@mail.emea.novell.com>

On 03/06/14 15:00, Jan Beulich wrote:

> Tools side:
> - don't silently ignore unrecognized PT_IRQ_TYPE_* values
> - respect that the interface type contains a union, making the code at
>   once no longer depend on the hypervisor ignoring the bus field of the
>   PCI portion of the interface structure)
>
> Hypervisor side:
> - don't ignore the PCI bus number passed in
> - don't store values (gsi, link) calculated from other stored values
> - avoid calling xfree() with a spin lock held where easily possible
> - have pt_irq_destroy_bind() respect the passed in type
> - scope reduction and constification of various variables
> - use switch instead of if/else-if chains
> - formatting
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>   with a few
suggestions for further cleanup...

> --- a/tools/libxc/xc_domain.c
> +++ b/tools/libxc/xc_domain.c
> @@ -1702,15 +1702,20 @@ int xc_domain_bind_pt_irq(
>      bind->hvm_domid = domid;
>      bind->irq_type = irq_type;
>      bind->machine_irq = machine_irq;
> -    if ( irq_type == PT_IRQ_TYPE_PCI ||
> -         irq_type == PT_IRQ_TYPE_MSI_TRANSLATE )
> +    switch ( irq_type )
>      {
> +    case PT_IRQ_TYPE_PCI:
> +    case PT_IRQ_TYPE_MSI_TRANSLATE:
>          bind->u.pci.bus = bus;
>          bind->u.pci.device = device;    

Given all this other cleanup, can you nuke the trailing whitespace here...

>          bind->u.pci.intx = intx;
> -    } 
> -    else if ( irq_type == PT_IRQ_TYPE_ISA )
> +    case PT_IRQ_TYPE_ISA:
>          bind->u.isa.isa_irq = isa_irq;
> +        break;
> +    default:
> +        errno = EINVAL;
> +        return -1;
> +    }
>      

... and here.

>      rc = do_domctl(xch, &domctl);
>      return rc;
> @@ -1737,10 +1742,21 @@ int xc_domain_unbind_pt_irq(
>      bind->hvm_domid = domid;
>      bind->irq_type = irq_type;
>      bind->machine_irq = machine_irq;
> -    bind->u.pci.bus = bus;
> -    bind->u.pci.device = device;    
> -    bind->u.pci.intx = intx;
> -    bind->u.isa.isa_irq = isa_irq;
> +    switch ( irq_type )
> +    {
> +    case PT_IRQ_TYPE_PCI:
> +    case PT_IRQ_TYPE_MSI_TRANSLATE:
> +        bind->u.pci.bus = bus;
> +        bind->u.pci.device = device;
> +        bind->u.pci.intx = intx;
> +        break;
> +    case PT_IRQ_TYPE_ISA:
> +        bind->u.isa.isa_irq = isa_irq;
> +        break;
> +    default:
> +        errno = EINVAL;
> +        return -1;
> +    }
>      

And here in this function.

> @@ -96,13 +93,9 @@ void free_hvm_irq_dpci(struct hvm_irq_dp
>  int pt_irq_create_bind(
>      struct domain *d, xen_domctl_bind_pt_irq_t *pt_irq_bind)
>  {
> -    struct hvm_irq_dpci *hvm_irq_dpci = NULL;
> +    struct hvm_irq_dpci *hvm_irq_dpci;
>      struct hvm_pirq_dpci *pirq_dpci;
>      struct pirq *info;
> -    uint32_t guest_gsi;
> -    uint32_t device, intx, link;
> -    struct dev_intx_gsi_link *digl;
> -    struct hvm_girq_dpci_mapping *girq;
>      int rc, pirq = pt_irq_bind->machine_irq;
>  
>      if ( pirq < 0 || pirq >= d->nr_pirqs )

Given all the cleanup, there is a further piece which could be done
between these two hunks.

There is an int i (declared in a for loop initialiser, despite our
fairly consistent C89 style), which should be unsigned.

> @@ -136,7 +129,9 @@ int pt_irq_create_bind(
>      }
>      pirq_dpci = pirq_dpci(info);
>  
> -    if ( pt_irq_bind->irq_type == PT_IRQ_TYPE_MSI )
> +    switch ( pt_irq_bind->irq_type )
> +    {
> +    case PT_IRQ_TYPE_MSI:
>      {
>          uint8_t dest, dest_mode;
>          int dest_vcpu_id;
>

  reply	other threads:[~2014-06-03 14:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-03 13:52 [PATCH 0/3] XSA-96 follow-ups Jan Beulich
2014-06-03 13:58 ` [PATCH 1/3] x86/HVM: properly propagate errors from HVMOP_inject_msi Jan Beulich
2014-06-03 14:05   ` Andrew Cooper
2014-06-03 13:59 ` [PATCH 2/3] x86/HVM: make vmsi_deliver() return proper error values Jan Beulich
2014-06-03 14:13   ` Andrew Cooper
2014-06-03 14:00 ` [PATCH 3/3] pt-irq fixes and improvements Jan Beulich
2014-06-03 14:50   ` Andrew Cooper [this message]
2014-06-04  8:24     ` [PATCH v2 " Jan Beulich
2014-06-10  0:32       ` Zhang, Yang Z
2014-06-11 12:32       ` Ping [tools]: " Jan Beulich
2014-06-11 16:54         ` Ian Campbell
2014-06-12  9:02       ` Ian Campbell

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=538DE0C3.5010203@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Campbell@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=keir@xen.org \
    --cc=kevin.tian@intel.com \
    --cc=stefano.stabellini@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    --cc=yang.z.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).