From: "Jan Beulich" Subject: [PATCH 6/6] x86_emulate: fold wide reads Date: Thu, 19 Sep 2013 16:46:05 +0100 Message-ID: <523B385D02000078000F4BB9@nat28.tlf.novell.com> References: <523B36F902000078000F4B9A@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part3003542D.0__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VMgQk-0004k6-Mf for xen-devel@lists.xenproject.org; Thu, 19 Sep 2013 15:46:10 +0000 In-Reply-To: <523B36F902000078000F4B9A@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: Keir Fraser 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. --=__Part3003542D.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline With HVM's MMIO operand handling now being capable of splitting large reads, there's no need to issue at most machine word size reads when we really need wider operands. Not that this is not done everywhere - there are a couple of cases where keeping the reads separate is more natural (and folding them would complicate the code rather than simplifying it). Signed-off-by: Jan Beulich --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -1116,7 +1116,6 @@ protmode_load_seg( { struct segment_register desctab, ss, segr; struct { uint32_t a, b; } desc; - unsigned long val; uint8_t dpl, rpl, cpl; uint32_t new_desc_b, a_flag =3D 0x100; int rc, fault_type =3D EXC_GP; @@ -1143,14 +1142,9 @@ protmode_load_seg( if ( ((sel & 0xfff8) + 7) > desctab.limit ) goto raise_exn; =20 - if ( (rc =3D read_ulong(x86_seg_none, desctab.base + (sel & 0xfff8), - &val, 4, ctxt, ops)) ) + if ( (rc =3D ops->read(x86_seg_none, desctab.base + (sel & 0xfff8), + &desc, sizeof(desc), ctxt)) ) return rc; - desc.a =3D val; - if ( (rc =3D read_ulong(x86_seg_none, desctab.base + (sel & 0xfff8) + = 4, - &val, 4, ctxt, ops)) ) - return rc; - desc.b =3D val; =20 /* Segment present in memory? */ if ( !(desc.b & (1u<<15)) ) @@ -4454,7 +4448,6 @@ x86_emulate( =20 case 0xc7: /* Grp9 (cmpxchg8b/cmpxchg16b) */ { unsigned long old[2], exp[2], new[2]; - unsigned int i; =20 generate_exception_if((modrm_reg & 7) !=3D 1, EXC_UD, -1); generate_exception_if(ea.type !=3D OP_MEM, EXC_UD, -1); @@ -4463,10 +4456,9 @@ x86_emulate( op_bytes *=3D 2; =20 /* Get actual old value. */ - for ( i =3D 0; i < (op_bytes/sizeof(long)); i++ ) - if ( (rc =3D read_ulong(ea.mem.seg, ea.mem.off + i*sizeof(long= ), - &old[i], sizeof(long), ctxt, ops)) !=3D = 0 ) - goto done; + if ( (rc =3D ops->read(ea.mem.seg, ea.mem.off, old, op_bytes, + ctxt)) !=3D 0 ) + goto done; =20 /* Get expected and proposed values. */ if ( op_bytes =3D=3D 8 ) --=__Part3003542D.0__= Content-Type: text/plain; name="x86-emul-fold-reads.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-emul-fold-reads.patch" x86_emulate: fold wide reads=0A=0AWith HVM's MMIO operand handling now = being capable of splitting large=0Areads, there's no need to issue at most = machine word size reads when=0Awe really need wider operands.=0A=0ANot = that this is not done everywhere - there are a couple of cases=0Awhere = keeping the reads separate is more natural (and folding them=0Awould = complicate the code rather than simplifying it).=0A=0ASigned-off-by: Jan = Beulich =0A=0A--- a/xen/arch/x86/x86_emulate/x86_emulate= .c=0A+++ b/xen/arch/x86/x86_emulate/x86_emulate.c=0A@@ -1116,7 +1116,6 @@ = protmode_load_seg(=0A {=0A struct segment_register desctab, ss, = segr;=0A struct { uint32_t a, b; } desc;=0A- unsigned long val;=0A = uint8_t dpl, rpl, cpl;=0A uint32_t new_desc_b, a_flag =3D 0x100;=0A = int rc, fault_type =3D EXC_GP;=0A@@ -1143,14 +1142,9 @@ protmode_load_s= eg(=0A if ( ((sel & 0xfff8) + 7) > desctab.limit )=0A goto = raise_exn;=0A =0A- if ( (rc =3D read_ulong(x86_seg_none, desctab.base + = (sel & 0xfff8),=0A- &val, 4, ctxt, ops)) )=0A+ = if ( (rc =3D ops->read(x86_seg_none, desctab.base + (sel & 0xfff8),=0A+ = &desc, sizeof(desc), ctxt)) )=0A return = rc;=0A- desc.a =3D val;=0A- if ( (rc =3D read_ulong(x86_seg_none, = desctab.base + (sel & 0xfff8) + 4,=0A- &val, 4, = ctxt, ops)) )=0A- return rc;=0A- desc.b =3D val;=0A =0A /* = Segment present in memory? */=0A if ( !(desc.b & (1u<<15)) )=0A@@ = -4454,7 +4448,6 @@ x86_emulate(=0A =0A case 0xc7: /* Grp9 (cmpxchg8b/cm= pxchg16b) */ {=0A unsigned long old[2], exp[2], new[2];=0A- = unsigned int i;=0A =0A generate_exception_if((modrm_reg & 7) !=3D = 1, EXC_UD, -1);=0A generate_exception_if(ea.type !=3D OP_MEM, = EXC_UD, -1);=0A@@ -4463,10 +4456,9 @@ x86_emulate(=0A op_bytes = *=3D 2;=0A =0A /* Get actual old value. */=0A- for ( i =3D = 0; i < (op_bytes/sizeof(long)); i++ )=0A- if ( (rc =3D = read_ulong(ea.mem.seg, ea.mem.off + i*sizeof(long),=0A- = &old[i], sizeof(long), ctxt, ops)) !=3D 0 )=0A- = goto done;=0A+ if ( (rc =3D ops->read(ea.mem.seg, ea.mem.off, = old, op_bytes,=0A+ ctxt)) !=3D 0 )=0A+ = goto done;=0A =0A /* Get expected and proposed values. */=0A = if ( op_bytes =3D=3D 8 )=0A --=__Part3003542D.0__= 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 --=__Part3003542D.0__=--