From patchwork Thu Sep 8 13:18:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9321389 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 8CEF9607D3 for ; Thu, 8 Sep 2016 13:21:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E1832983A for ; Thu, 8 Sep 2016 13:21:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7311A29880; Thu, 8 Sep 2016 13:21:13 +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 4A6D62983A for ; Thu, 8 Sep 2016 13:21:12 +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 1bhzED-0001oO-IJ; Thu, 08 Sep 2016 13:18:53 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhzEC-0001o2-Da for xen-devel@lists.xenproject.org; Thu, 08 Sep 2016 13:18:52 +0000 Received: from [85.158.139.211] by server-4.bemta-5.messagelabs.com id 66/3D-12285-B3561D75; Thu, 08 Sep 2016 13:18:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRWlGSWpSXmKPExsXS6fjDS9c69WK 4wWJ3i+9bJjM5MHoc/nCFJYAxijUzLym/IoE148TtMywF8yUqfl9PbWDcJdjFyMkhJJAncW/j FiYQm1fATmL61UdgtoSAocTT99fZQGwWAVWJJbu2s4DYbALqEm3PtrN2MXJwiAgYSJw7mgRiM gvoS2xbxwJiCgvoSdy44QQx3E7i2amDYI2cAvYSX1rnMIKU8AoISvzdIQwSZgYqmbj4L+sERp 5ZCJlZSDIQtpbEw1+3WCBsbYllC18zzwJbKy2x/B8HRNhUom/hTlZUJSC2g8Szbd9ZFzByrGL UKE4tKkst0jU01ksqykzPKMlNzMzRNTQw1ctNLS5OTE/NSUwq1kvOz93ECAxSBiDYwfhvm+ch RkkOJiVRXp/iC+FCfEn5KZUZicUZ8UWlOanFhxhlODiUJHj1Ui6GCwkWpaanVqRl5gDjBSYtw cGjJMKrApLmLS5IzC3OTIdInWJUlBLn/ZkMlBAASWSU5sG1wWL0EqOslDAvI9AhQjwFqUW5mS Wo8q8YxTkYlYR5b4FM4cnMK4Gb/gpoMRPQYqFT50EWlyQipKQaGEPzynPWcG/krH8QFpv7rj/ ENufz4395H/WvVexVv6CzxTkozPvexWe17rsuvJ8a4vtwr7rD6XTpNWLxxe+/J4qvU3fn2qGp qPOjvuyZf/LmU4bff1+reWT5OFCcU6YhbvYSm00VnBMqvc+/aNr6tfuH0GW1wyuCZJ8wh25Tk bzjcvyClNrb9UosxRmJhlrMRcWJAFo+PHDMAgAA X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-15.tower-206.messagelabs.com!1473340728!44739103!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4670 invoked from network); 8 Sep 2016 13:18:50 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-15.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 8 Sep 2016 13:18:50 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Thu, 08 Sep 2016 07:18:48 -0600 Message-Id: <57D18158020000780010D1DE@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.1 Date: Thu, 08 Sep 2016 07:18:48 -0600 From: "Jan Beulich" To: "xen-devel" References: <57D17C78020000780010D127@prv-mh.provo.novell.com> In-Reply-To: <57D17C78020000780010D127@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH 14/17] x86emul: support XSETBV 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 This is a prereq for switching PV privileged op emulation to the generic instruction emulator. Since handle_xsetbv() is already capable of dealing with all guest kinds, avoid introducing another hook here. Signed-off-by: Jan Beulich x86emul: support XSETBV This is a prereq for switching PV privileged op emulation to the generic instruction emulator. Since handle_xsetbv() is already capable of dealing with all guest kinds, avoid introducing another hook here. Signed-off-by: Jan Beulich --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -4174,6 +4174,24 @@ x86_emulate( switch( modrm ) { +#ifdef __XEN__ + case 0xd1: /* xsetbv */ + { + unsigned long cr4; + + if ( vex.pfx ) + break; + if ( !ops->read_cr || ops->read_cr(4, &cr4, ctxt) != X86EMUL_OKAY ) + cr4 = 0; + generate_exception_if(!(cr4 & X86_CR4_OSXSAVE), EXC_UD, -1); + generate_exception_if(!mode_ring0() || + handle_xsetbv(_regs._ecx, + _regs._eax | (_regs.rdx << 32)), + EXC_GP, 0); + goto no_writeback; + } +#endif + case 0xdf: /* invlpga */ generate_exception_if(!in_protmode(ctxt, ops), EXC_UD, -1); generate_exception_if(!mode_ring0(), EXC_GP, 0); --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -4174,6 +4174,24 @@ x86_emulate( switch( modrm ) { +#ifdef __XEN__ + case 0xd1: /* xsetbv */ + { + unsigned long cr4; + + if ( vex.pfx ) + break; + if ( !ops->read_cr || ops->read_cr(4, &cr4, ctxt) != X86EMUL_OKAY ) + cr4 = 0; + generate_exception_if(!(cr4 & X86_CR4_OSXSAVE), EXC_UD, -1); + generate_exception_if(!mode_ring0() || + handle_xsetbv(_regs._ecx, + _regs._eax | (_regs.rdx << 32)), + EXC_GP, 0); + goto no_writeback; + } +#endif + case 0xdf: /* invlpga */ generate_exception_if(!in_protmode(ctxt, ops), EXC_UD, -1); generate_exception_if(!mode_ring0(), EXC_GP, 0);