All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Roger Pau Monne <roger.pau@citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH for-4.9 v4 1/2] x86/vioapic: introduce support for multiple vIO APICS
Date: Wed, 05 Apr 2017 08:10:35 -0600	[thread overview]
Message-ID: <58E516FB020000780014D52C@prv-mh.provo.novell.com> (raw)
In-Reply-To: <20170405092341.20995-2-roger.pau@citrix.com>

>>> On 05.04.17 at 11:23, <roger.pau@citrix.com> wrote:
> +static unsigned int base_gsi(const struct domain *d,
> +                             const struct hvm_vioapic *vioapic)
> +{
> +    unsigned int nr_vioapics = d->arch.hvm_domain.nr_vioapics;
> +    unsigned int base_gsi = 0, i = 0;
> +    const struct hvm_vioapic *tmp;
> +
> +    while ( --nr_vioapics && (tmp = domain_vioapic(d, i++)) != vioapic )
> +        base_gsi += tmp->nr_pins;

While for valid input it should be benign, I think the first part of the
condition would better use post-decrement (or "i < nr_vioapics").
That way you'll return an out of range GSI for a not found vioapic
input.

> @@ -454,32 +523,68 @@ HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, ioapic_load, 1, HVMSR_PER_DOM);
>  
>  void vioapic_reset(struct domain *d)
>  {
> -    struct hvm_vioapic *vioapic = domain_vioapic(d);
> -    uint32_t nr_pins = vioapic->nr_pins;
> -    int i;
> +    unsigned int i;
>  
>      if ( !has_vioapic(d) )
> +    {
> +        ASSERT(!d->arch.hvm_domain.nr_vioapics);
>          return;
> +    }
>  
> -    memset(vioapic, 0, hvm_vioapic_size(nr_pins));
> -    vioapic->domain = d;
> -    vioapic->nr_pins = nr_pins;
> -    for ( i = 0; i < nr_pins; i++ )
> -        vioapic->redirtbl[i].fields.mask = 1;
> -    vioapic->base_address = VIOAPIC_DEFAULT_BASE_ADDRESS;
> +    for ( i = 0; i < d->arch.hvm_domain.nr_vioapics; i++ )
> +    {
> +        struct hvm_vioapic *vioapic = domain_vioapic(d, i);
> +        unsigned int pin, nr_pins = vioapic->nr_pins;
> +
> +        memset(vioapic, 0, hvm_vioapic_size(nr_pins));
> +        for ( pin = 0; pin < nr_pins; pin++ )
> +            vioapic->redirtbl[pin].fields.mask = 1;
> +        ASSERT(!i);
> +        vioapic->base_address = VIOAPIC_DEFAULT_BASE_ADDRESS +
> +                                VIOAPIC_MEM_LENGTH * 0;

Why not simply

        vioapic->base_address = VIOAPIC_DEFAULT_BASE_ADDRESS;

?

With these taken care of (which can be done while committing, if you
agree)
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-04-05 14:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-05  9:23 [PATCH for-4.9 v4 0/2] x86/vioapic: introduce support for multiple vIO APICs Roger Pau Monne
2017-04-05  9:23 ` [PATCH for-4.9 v4 1/2] x86/vioapic: introduce support for multiple vIO APICS Roger Pau Monne
2017-04-05 14:10   ` Jan Beulich [this message]
2017-04-05 14:31     ` Roger Pau Monne
2017-04-05  9:23 ` [PATCH for-4.9 v4 2/2] x86/vioapic: allow PVHv2 Dom0 to have more than one IO APIC Roger Pau Monne

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=58E516FB020000780014D52C@prv-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /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.