From: "Jan Beulich" Subject: [PATCH v2] nested VMX: fix I/O port exit emulation Date: Tue, 03 Dec 2013 14:06:38 +0000 Message-ID: <529DF37E02000078001096F9@nat28.tlf.novell.com> References: <529DEE4E0200007800109691@nat28.tlf.novell.com> <529DE2D0.8090305@citrix.com> <529DF27E02000078001096DC@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part3C0FFE7E.3__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Vnqce-00054f-GR for xen-devel@lists.xenproject.org; Tue, 03 Dec 2013 14:06:44 +0000 In-Reply-To: <529DF27E02000078001096DC@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: xen-devel Cc: Andrew Cooper , Matthew Daley , Eddie Dong , Jun Nakajima List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part3C0FFE7E.3__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 =3D &vcpu_nestedhvm(v); struct nestedvmx *nvmx =3D &vcpu_2_nvmx(v); u32 ctrl; - u8 *bitmap; =20 nvcpu->nv_vmexit_pending =3D 0; nvmx->intr.intr_info =3D 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; =20 __vmread(EXIT_QUALIFICATION, &qual); port =3D qual >> 16; - bitmap =3D nvmx->iobitmap[port >> 15]; - if ( bitmap[(port & 0x7fff) >> 3] & (1 << (port & 0x7)) ) - nvcpu->nv_vmexit_pending =3D 1; + size =3D (qual & 7) + 1; + do { + const u8 *bitmap =3D nvmx->iobitmap[port >> 15]; + + if ( bitmap[(port & 0x7fff) >> 3] & (1 << (port & 7)) ) + nvcpu->nv_vmexit_pending =3D 1; + if ( !--size ) + break; + if ( !++port ) + nvcpu->nv_vmexit_pending =3D 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 =3D 1; --=__Part3C0FFE7E.3__= Content-Type: text/plain; name="nVMX-IO-port-multiple.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="nVMX-IO-port-multiple.patch" nested VMX: fix I/O port exit emulation=0A=0AFor multi-byte operations all = affected ports' bits in the bitmap need=0Ato be checked, not just the = first port's one.=0A=0AReported-by: Matthew Daley =0ASig= ned-off-by: Jan Beulich =0A---=0Av2: Fix loop construct.= =0A=0A--- a/xen/arch/x86/hvm/vmx/vvmx.c=0A+++ b/xen/arch/x86/hvm/vmx/vvmx.c= =0A@@ -2134,7 +2134,6 @@ int nvmx_n2_vmexit_handler(struct cpu_us=0A = struct nestedvcpu *nvcpu =3D &vcpu_nestedhvm(v);=0A struct nestedvmx = *nvmx =3D &vcpu_2_nvmx(v);=0A u32 ctrl;=0A- u8 *bitmap;=0A =0A = nvcpu->nv_vmexit_pending =3D 0;=0A nvmx->intr.intr_info =3D 0;=0A@@ = -2220,15 +2219,23 @@ int nvmx_n2_vmexit_handler(struct cpu_us=0A = if ( ctrl & CPU_BASED_ACTIVATE_IO_BITMAP )=0A {=0A = unsigned long qual;=0A- u16 port;=0A+ u16 port, = size;=0A =0A __vmread(EXIT_QUALIFICATION, &qual);=0A = port =3D qual >> 16;=0A- bitmap =3D nvmx->iobitmap[port >> = 15];=0A- if ( bitmap[(port & 0x7fff) >> 3] & (1 << (port & = 0x7)) )=0A- nvcpu->nv_vmexit_pending =3D 1;=0A+ = size =3D (qual & 7) + 1;=0A+ do {=0A+ const u8 = *bitmap =3D nvmx->iobitmap[port >> 15];=0A+=0A+ if ( = bitmap[(port & 0x7fff) >> 3] & (1 << (port & 7)) )=0A+ = nvcpu->nv_vmexit_pending =3D 1;=0A+ if ( !--size )=0A+ = break;=0A+ if ( !++port )=0A+ = nvcpu->nv_vmexit_pending =3D 1;=0A+ } while ( !nvcpu->nv_vmex= it_pending );=0A if ( !nvcpu->nv_vmexit_pending )=0A- = gdprintk(XENLOG_WARNING, "L0 PIO %x.\n", port);=0A+ = printk(XENLOG_G_WARNING "L0 PIO %04x\n", port);=0A }=0A = else if ( ctrl & CPU_BASED_UNCOND_IO_EXITING )=0A nvcpu->nv_vme= xit_pending =3D 1;=0A --=__Part3C0FFE7E.3__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part3C0FFE7E.3__=--