From patchwork Wed Jun 21 12:07:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9801705 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 3A332600C5 for ; Wed, 21 Jun 2017 12:09:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28F5E28595 for ; Wed, 21 Jun 2017 12:09:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DAC8285AF; Wed, 21 Jun 2017 12:09: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 963DD28595 for ; Wed, 21 Jun 2017 12:09:52 +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 1dNeQS-0000X0-3c; Wed, 21 Jun 2017 12:08:00 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNeQQ-0000WD-Mi for xen-devel@lists.xenproject.org; Wed, 21 Jun 2017 12:07:58 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 15/25-26749-D916A495; Wed, 21 Jun 2017 12:07:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKIsWRWlGSWpSXmKPExsXS6fjDS3duole kwbFfHBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0bP/Ea2gvPCFUs6m5kaGJsEuhg5OYQE8iSW /GtjAbF5BewkGv+uZgOxJQQMJU4vvAkWZxFQlXj84ywjiM0moC7R9mw7axcjB4eIgIHEuaNJI CazgL7EtnVg1cJAU46tnswOMb1I4mjrXrA4p4C9xJKuj2wg5bwCghJ/dwhDdNpJnFrMOYGRZx ZCYhZCYhZQK7OAlsTDX7dYIGxtiWULXzNDlEhLLP/HAVe92hhVBYjtKfGo5RzzAkaOVYwaxal FZalFukYGeklFmekZJbmJmTm6hgbGermpxcWJ6ak5iUnFesn5uZsYgUFaz8DAuIOx+YTfIUZJ DiYlUd5yb69IIb6k/JTKjMTijPii0pzU4kOMGhwcApvXrr7AKMWSl5+XqiTBey8BqE6wKDU9t SItMwcYRzClEhw8SiK8bgFAad7igsTc4sx0iNQpRkUpcd7pIH0CIImM0jy4NljsXmKUlRLmZW RgYBDiKUgtys0sQZV/xSjOwagkzNsJMoUnM68EbvoroMVMQItfHPEAWVySiJCSamDkcDu7mH/ aZZ9TvxdNYt7y1frb4/6f2sLi+3/z9XywPlId8OLEZMEPFQu3PQvmcC+/Ev576o3lLjcic+fn 1T24/XrC0iXvnsw5Gd525ffLO1WlGYpruNKy3q9I7p+9fMtCzkuBtQE6kWsSbz4RvdXg8clqC utZlqZGlTKOvo0eZXxZrcW8r49cU2Ipzkg01GIuKk4EAMIBElnYAgAA X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1498046875!99106831!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.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7926 invoked from network); 21 Jun 2017 12:07:56 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-16.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 21 Jun 2017 12:07:56 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Wed, 21 Jun 2017 06:07:54 -0600 Message-Id: <594A7DB902000078001653B2@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.2 Date: Wed, 21 Jun 2017 06:07:53 -0600 From: "Jan Beulich" To: "xen-devel" References: <594A733B020000780016527C@prv-mh.provo.novell.com> <594A733B020000780016527C@prv-mh.provo.novell.com> In-Reply-To: <594A733B020000780016527C@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH 15/17] x86emul: adjust_bnd() should check XCR0 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 Experimentally MPX instructions have been confirmed to behave as NOPs unless both related XCR0 bits are set to 1. By implication branches then also don't clear BNDn. Signed-off-by: Jan Beulich x86emul: adjust_bnd() should check XCR0 Experimentally MPX instructions have been confirmed to behave as NOPs unless both related XCR0 bits are set to 1. By implication branches then also don't clear BNDn. Signed-off-by: Jan Beulich --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -2141,12 +2141,16 @@ static bool umip_active(struct x86_emula static void adjust_bnd(struct x86_emulate_ctxt *ctxt, const struct x86_emulate_ops *ops, enum vex_pfx pfx) { - uint64_t bndcfg; + uint64_t xcr0, bndcfg; int rc; if ( pfx == vex_f2 || !cpu_has_mpx || !vcpu_has_mpx() ) return; + if ( !ops->read_xcr || ops->read_xcr(0, &xcr0, ctxt) != X86EMUL_OKAY || + !(xcr0 & XSTATE_BNDREGS) || !(xcr0 & XSTATE_BNDCSR) ) + return; + if ( !mode_ring0() ) bndcfg = read_bndcfgu(); else if ( !ops->read_msr || --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -2141,12 +2141,16 @@ static bool umip_active(struct x86_emula static void adjust_bnd(struct x86_emulate_ctxt *ctxt, const struct x86_emulate_ops *ops, enum vex_pfx pfx) { - uint64_t bndcfg; + uint64_t xcr0, bndcfg; int rc; if ( pfx == vex_f2 || !cpu_has_mpx || !vcpu_has_mpx() ) return; + if ( !ops->read_xcr || ops->read_xcr(0, &xcr0, ctxt) != X86EMUL_OKAY || + !(xcr0 & XSTATE_BNDREGS) || !(xcr0 & XSTATE_BNDCSR) ) + return; + if ( !mode_ring0() ) bndcfg = read_bndcfgu(); else if ( !ops->read_msr ||