From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Egger, Christoph" Subject: Re: [PATCH v2] nested VMX: fix I/O port exit emulation Date: Wed, 4 Dec 2013 10:51:15 +0100 Message-ID: <529EFB13.5000300@amazon.de> References: <529DEE4E0200007800109691@nat28.tlf.novell.com> <529DE2D0.8090305@citrix.com> <529DF27E02000078001096DC@nat28.tlf.novell.com> <529DF37E02000078001096F9@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Vo97C-0000iE-5g for xen-devel@lists.xenproject.org; Wed, 04 Dec 2013 09:51:30 +0000 In-Reply-To: <529DF37E02000078001096F9@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich , xen-devel Cc: Andrew Cooper , Matthew Daley , Eddie Dong , Jun Nakajima List-Id: xen-devel@lists.xenproject.org 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 > Signed-off-by: Jan Beulich > --- > 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