From patchwork Tue Dec 6 14:12:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9462665 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EBEA560231 for ; Tue, 6 Dec 2016 14:14:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA266283FC for ; Tue, 6 Dec 2016 14:14:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE1A1283FE; Tue, 6 Dec 2016 14:14:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 152E2283FC for ; Tue, 6 Dec 2016 14:14:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cEGU4-0001OF-Sy; Tue, 06 Dec 2016 14:12:40 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cEGU3-0001Nv-DF for xen-devel@lists.xenproject.org; Tue, 06 Dec 2016 14:12:39 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id E9/6D-25811-657C6485; Tue, 06 Dec 2016 14:12:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDIsWRWlGSWpSXmKPExsXS6fjDSzf0uFu EwZduC4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNePr88uMBd19jBXL+m+wNTA2+HcxcnIICeRJ /F2zgxXE5hWwk9ja2MkEYksIGEo8fX+dDcRmEVCVeHjtDzOIzSagLtH2bDtQPQeHiICBxLmjS SAms4C+xLZ1LCAVwgLuEh8+/AGrEAKa2PleGyTMKWAv8atnIgtImFdAUOLvDmGQMDNQxYO+1e wTGHlmIWRmIclA2FoSD3/dYoGwtSWWLXzNPAtsrbTE8n8cEGF7iQsrdrOjKgGxvSQOTrzIsoC RYxWjRnFqUVlqka6RpV5SUWZ6RkluYmaOrqGBsV5uanFxYnpqTmJSsV5yfu4mRmCo1jMwMO5g bNrrd4hRkoNJSZRXxdItQogvKT+lMiOxOCO+qDQntfgQowwHh5IE782jQDnBotT01Iq0zBxg1 MCkJTh4lER4rx4DSvMWFyTmFmemQ6ROMSpKifNGgiQEQBIZpXlwbbBIvcQoKyXMy8jAwCDEU5 BalJtZgir/ilGcg1FJmJcLZApPZl4J3PRXQIuZgBafOO4MsrgkESEl1cDI3ZJ5npd7ooT29ws nGI69rZ51oEXjy3+xGxfuVxbGLFr067DepuOFv7yvtgrfPjWN21rITzrytk9F0xsX6apDx8U0 5Pbt9Tv/f9HN2ttb3f5qWcxmsPnFxZa39OQDB1bJjyvjBO/+e9M/c5X5hktzJ3KY72K64OX4p 6/ZULPsaa5SU2z3vgY7JZbijERDLeai4kQAcuMJn88CAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1481033555!16638638!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15622 invoked from network); 6 Dec 2016 14:12:37 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-4.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 6 Dec 2016 14:12:37 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Tue, 06 Dec 2016 07:12:35 -0700 Message-Id: <5846D5610200007800125C1F@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.1 Date: Tue, 06 Dec 2016 07:12:33 -0700 From: "Jan Beulich" To: "xen-devel" References: <5846D3810200007800125BF8@prv-mh.provo.novell.com> In-Reply-To: <5846D3810200007800125BF8@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH 3/6] x86emul: simplify FPU destination operand handling X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Consolidate the copying of ea to dst: There's no need to set the type to OP_MEM, and instead the load cases setting it to OP_NONE allows the copying to be done just once per major opcode. Signed-off-by: Jan Beulich x86emul: simplify FPU destination operand handling Consolidate the copying of ea to dst: There's no need to set the type to OP_MEM, and instead the load cases setting it to OP_NONE allows the copying to be done just once per major opcode. Signed-off-by: Jan Beulich --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -3758,6 +3758,7 @@ x86_emulate( break; default: generate_exception_if(ea.type != OP_MEM, EXC_UD); + dst = ea; switch ( modrm_reg & 7 ) { case 0: /* fld m32fp */ @@ -3765,18 +3766,15 @@ x86_emulate( 4, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("flds", src.val); + dst.type = OP_NONE; break; case 2: /* fstp m32fp */ - ea.bytes = 4; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fsts", dst.val); + dst.bytes = 4; break; case 3: /* fstp m32fp */ - ea.bytes = 4; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fstps", dst.val); + dst.bytes = 4; break; case 4: /* fldenv - TODO */ goto cannot_emulate; @@ -3785,14 +3783,13 @@ x86_emulate( 2, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("fldcw", src.val); + dst.type = OP_NONE; break; case 6: /* fnstenv - TODO */ goto cannot_emulate; case 7: /* fnstcw m2byte */ - ea.bytes = 2; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fnstcw", dst.val); + dst.bytes = 2; break; default: generate_exception_if(true, EXC_UD); @@ -3872,6 +3869,7 @@ x86_emulate( break; default: generate_exception_if(ea.type != OP_MEM, EXC_UD); + dst = ea; switch ( modrm_reg & 7 ) { case 0: /* fild m32i */ @@ -3879,37 +3877,31 @@ x86_emulate( 4, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("fildl", src.val); + dst.type = OP_NONE; break; case 1: /* fisttp m32i */ host_and_vcpu_must_have(sse3); - ea.bytes = 4; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fisttpl", dst.val); + dst.bytes = 4; break; case 2: /* fist m32i */ - ea.bytes = 4; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fistl", dst.val); + dst.bytes = 4; break; case 3: /* fistp m32i */ - ea.bytes = 4; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fistpl", dst.val); + dst.bytes = 4; break; case 5: /* fld m80fp */ if ( (rc = ops->read(ea.mem.seg, ea.mem.off, &src.val, 10, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("fldt", src.val); + dst.type = OP_NONE; break; case 7: /* fstp m80fp */ - ea.bytes = 10; - dst.type = OP_MEM; - dst = ea; emulate_fpu_insn_memdst("fstpt", dst.val); + dst.bytes = 10; break; default: generate_exception_if(true, EXC_UD); @@ -3980,6 +3972,7 @@ x86_emulate( break; default: generate_exception_if(ea.type != OP_MEM, EXC_UD); + dst = ea; switch ( modrm_reg & 7 ) { case 0: /* fld m64fp */; @@ -3987,34 +3980,27 @@ x86_emulate( 8, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("fldl", src.val); + dst.type = OP_NONE; break; case 1: /* fisttp m64i */ host_and_vcpu_must_have(sse3); - ea.bytes = 8; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fisttpll", dst.val); + dst.bytes = 8; break; case 2: /* fst m64fp */ - ea.bytes = 8; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fstl", dst.val); + dst.bytes = 8; break; case 3: /* fstp m64fp */ - ea.bytes = 8; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fstpl", dst.val); + dst.bytes = 8; break; case 4: /* frstor - TODO */ case 6: /* fnsave - TODO */ goto cannot_emulate; case 7: /* fnstsw m2byte */ - ea.bytes = 2; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fnstsw", dst.val); + dst.bytes = 2; break; default: generate_exception_if(true, EXC_UD); @@ -4092,6 +4078,7 @@ x86_emulate( break; default: generate_exception_if(ea.type != OP_MEM, EXC_UD); + dst = ea; switch ( modrm_reg & 7 ) { case 0: /* fild m16i */ @@ -4099,49 +4086,42 @@ x86_emulate( 2, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("filds", src.val); + dst.type = OP_NONE; break; case 1: /* fisttp m16i */ host_and_vcpu_must_have(sse3); - ea.bytes = 2; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fisttps", dst.val); + dst.bytes = 2; break; case 2: /* fist m16i */ - ea.bytes = 2; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fists", dst.val); + dst.bytes = 2; break; case 3: /* fistp m16i */ - ea.bytes = 2; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fistps", dst.val); + dst.bytes = 2; break; case 4: /* fbld m80dec */ if ( (rc = ops->read(ea.mem.seg, ea.mem.off, &src.val, 10, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("fbld", src.val); + dst.type = OP_NONE; break; case 5: /* fild m64i */ if ( (rc = ops->read(ea.mem.seg, ea.mem.off, &src.val, 8, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("fildll", src.val); + dst.type = OP_NONE; break; case 6: /* fbstp packed bcd */ - ea.bytes = 10; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fbstp", dst.val); + dst.bytes = 10; break; case 7: /* fistp m64i */ - ea.bytes = 8; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fistpll", dst.val); + dst.bytes = 8; break; } } Reviewed-by: Andrew Cooper --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -3758,6 +3758,7 @@ x86_emulate( break; default: generate_exception_if(ea.type != OP_MEM, EXC_UD); + dst = ea; switch ( modrm_reg & 7 ) { case 0: /* fld m32fp */ @@ -3765,18 +3766,15 @@ x86_emulate( 4, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("flds", src.val); + dst.type = OP_NONE; break; case 2: /* fstp m32fp */ - ea.bytes = 4; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fsts", dst.val); + dst.bytes = 4; break; case 3: /* fstp m32fp */ - ea.bytes = 4; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fstps", dst.val); + dst.bytes = 4; break; case 4: /* fldenv - TODO */ goto cannot_emulate; @@ -3785,14 +3783,13 @@ x86_emulate( 2, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("fldcw", src.val); + dst.type = OP_NONE; break; case 6: /* fnstenv - TODO */ goto cannot_emulate; case 7: /* fnstcw m2byte */ - ea.bytes = 2; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fnstcw", dst.val); + dst.bytes = 2; break; default: generate_exception_if(true, EXC_UD); @@ -3872,6 +3869,7 @@ x86_emulate( break; default: generate_exception_if(ea.type != OP_MEM, EXC_UD); + dst = ea; switch ( modrm_reg & 7 ) { case 0: /* fild m32i */ @@ -3879,37 +3877,31 @@ x86_emulate( 4, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("fildl", src.val); + dst.type = OP_NONE; break; case 1: /* fisttp m32i */ host_and_vcpu_must_have(sse3); - ea.bytes = 4; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fisttpl", dst.val); + dst.bytes = 4; break; case 2: /* fist m32i */ - ea.bytes = 4; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fistl", dst.val); + dst.bytes = 4; break; case 3: /* fistp m32i */ - ea.bytes = 4; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fistpl", dst.val); + dst.bytes = 4; break; case 5: /* fld m80fp */ if ( (rc = ops->read(ea.mem.seg, ea.mem.off, &src.val, 10, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("fldt", src.val); + dst.type = OP_NONE; break; case 7: /* fstp m80fp */ - ea.bytes = 10; - dst.type = OP_MEM; - dst = ea; emulate_fpu_insn_memdst("fstpt", dst.val); + dst.bytes = 10; break; default: generate_exception_if(true, EXC_UD); @@ -3980,6 +3972,7 @@ x86_emulate( break; default: generate_exception_if(ea.type != OP_MEM, EXC_UD); + dst = ea; switch ( modrm_reg & 7 ) { case 0: /* fld m64fp */; @@ -3987,34 +3980,27 @@ x86_emulate( 8, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("fldl", src.val); + dst.type = OP_NONE; break; case 1: /* fisttp m64i */ host_and_vcpu_must_have(sse3); - ea.bytes = 8; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fisttpll", dst.val); + dst.bytes = 8; break; case 2: /* fst m64fp */ - ea.bytes = 8; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fstl", dst.val); + dst.bytes = 8; break; case 3: /* fstp m64fp */ - ea.bytes = 8; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fstpl", dst.val); + dst.bytes = 8; break; case 4: /* frstor - TODO */ case 6: /* fnsave - TODO */ goto cannot_emulate; case 7: /* fnstsw m2byte */ - ea.bytes = 2; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fnstsw", dst.val); + dst.bytes = 2; break; default: generate_exception_if(true, EXC_UD); @@ -4092,6 +4078,7 @@ x86_emulate( break; default: generate_exception_if(ea.type != OP_MEM, EXC_UD); + dst = ea; switch ( modrm_reg & 7 ) { case 0: /* fild m16i */ @@ -4099,49 +4086,42 @@ x86_emulate( 2, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("filds", src.val); + dst.type = OP_NONE; break; case 1: /* fisttp m16i */ host_and_vcpu_must_have(sse3); - ea.bytes = 2; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fisttps", dst.val); + dst.bytes = 2; break; case 2: /* fist m16i */ - ea.bytes = 2; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fists", dst.val); + dst.bytes = 2; break; case 3: /* fistp m16i */ - ea.bytes = 2; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fistps", dst.val); + dst.bytes = 2; break; case 4: /* fbld m80dec */ if ( (rc = ops->read(ea.mem.seg, ea.mem.off, &src.val, 10, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("fbld", src.val); + dst.type = OP_NONE; break; case 5: /* fild m64i */ if ( (rc = ops->read(ea.mem.seg, ea.mem.off, &src.val, 8, ctxt)) != X86EMUL_OKAY ) goto done; emulate_fpu_insn_memsrc("fildll", src.val); + dst.type = OP_NONE; break; case 6: /* fbstp packed bcd */ - ea.bytes = 10; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fbstp", dst.val); + dst.bytes = 10; break; case 7: /* fistp m64i */ - ea.bytes = 8; - dst = ea; - dst.type = OP_MEM; emulate_fpu_insn_memdst("fistpll", dst.val); + dst.bytes = 8; break; } }