All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Egger, Christoph" <chegger@amazon.de>
To: Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Matthew Daley <mattd@bugfuzz.com>,
	Eddie Dong <eddie.dong@intel.com>,
	Jun Nakajima <jun.nakajima@intel.com>
Subject: Re: [PATCH v2] nested VMX: fix I/O port exit emulation
Date: Wed, 4 Dec 2013 10:51:15 +0100	[thread overview]
Message-ID: <529EFB13.5000300@amazon.de> (raw)
In-Reply-To: <529DF37E02000078001096F9@nat28.tlf.novell.com>

On 03.12.13 15:06, Jan Beulich wrote:
> For multi-byte operations all affected ports' bits in the bitmap need
> to be checked, not just the first port's one.
> 
> Reported-by: Matthew Daley <mattd@bugfuzz.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> v2: Fix loop construct.
> 
> --- a/xen/arch/x86/hvm/vmx/vvmx.c
> +++ b/xen/arch/x86/hvm/vmx/vvmx.c
> @@ -2134,7 +2134,6 @@ int nvmx_n2_vmexit_handler(struct cpu_us
>      struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
>      struct nestedvmx *nvmx = &vcpu_2_nvmx(v);
>      u32 ctrl;
> -    u8 *bitmap;
>  
>      nvcpu->nv_vmexit_pending = 0;
>      nvmx->intr.intr_info = 0;
> @@ -2220,15 +2219,23 @@ int nvmx_n2_vmexit_handler(struct cpu_us
>          if ( ctrl & CPU_BASED_ACTIVATE_IO_BITMAP )
>          {
>              unsigned long qual;
> -            u16 port;
> +            u16 port, size;
>  
>              __vmread(EXIT_QUALIFICATION, &qual);
>              port = qual >> 16;
> -            bitmap = nvmx->iobitmap[port >> 15];
> -            if ( bitmap[(port & 0x7fff) >> 3] & (1 << (port & 0x7)) )
> -                nvcpu->nv_vmexit_pending = 1;
> +            size = (qual & 7) + 1;
> +            do {
> +                const u8 *bitmap = nvmx->iobitmap[port >> 15];
> +
> +                if ( bitmap[(port & 0x7fff) >> 3] & (1 << (port & 7)) )
> +                    nvcpu->nv_vmexit_pending = 1;
> +                if ( !--size )
> +                    break;
> +                if ( !++port )
> +                    nvcpu->nv_vmexit_pending = 1;
> +            } while ( !nvcpu->nv_vmexit_pending );
>              if ( !nvcpu->nv_vmexit_pending )
> -               gdprintk(XENLOG_WARNING, "L0 PIO %x.\n", port);
> +                printk(XENLOG_G_WARNING "L0 PIO %04x\n", port);
>          }
>          else if ( ctrl & CPU_BASED_UNCOND_IO_EXITING )
>              nvcpu->nv_vmexit_pending = 1;
> 

Can you use #define's for the bit operations, please?
That makes the code more readable and avoids copy & paste errors.

Christoph

  parent reply	other threads:[~2013-12-04  9:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-03 13:44 [PATCH] nested VMX: fix I/O port exit emulation Jan Beulich
2013-12-03 13:55 ` Andrew Cooper
2013-12-03 14:02   ` Jan Beulich
2013-12-03 14:06     ` [PATCH v2] " Jan Beulich
2013-12-03 14:30       ` Andrew Cooper
2013-12-03 15:55         ` Jan Beulich
2013-12-03 15:58           ` Andrew Cooper
2013-12-04  1:51       ` Zhang, Yang Z
2013-12-04  2:08         ` Andrew Cooper
2013-12-04  2:16           ` Zhang, Yang Z
2013-12-04  7:52         ` Jan Beulich
2013-12-04  8:07           ` Zhang, Yang Z
2013-12-04  8:51             ` Jan Beulich
2013-12-05  1:38               ` Zhang, Yang Z
2013-12-04  8:34       ` Dong, Eddie
2013-12-04  9:51       ` Egger, Christoph [this message]
2013-12-04 10:05         ` Jan Beulich

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=529EFB13.5000300@amazon.de \
    --to=chegger@amazon.de \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=eddie.dong@intel.com \
    --cc=jun.nakajima@intel.com \
    --cc=mattd@bugfuzz.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.