From patchwork Mon Jan 11 08:52:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liang Li X-Patchwork-Id: 7999951 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C4477BEEE5 for ; Mon, 11 Jan 2016 08:59:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 08EDB20259 for ; Mon, 11 Jan 2016 08:59:10 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 157E820256 for ; Mon, 11 Jan 2016 08:59:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aIYGN-00055e-N9; Mon, 11 Jan 2016 08:55:43 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aIYGM-00055Z-JF for xen-devel@lists.xen.org; Mon, 11 Jan 2016 08:55:42 +0000 Received: from [85.158.143.35] by server-3.bemta-4.messagelabs.com id E8/B0-31122-D0E63965; Mon, 11 Jan 2016 08:55:41 +0000 X-Env-Sender: liang.z.li@intel.com X-Msg-Ref: server-16.tower-21.messagelabs.com!1452502540!4984827!1 X-Originating-IP: [192.55.52.120] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 36064 invoked from network); 11 Jan 2016 08:55:41 -0000 Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by server-16.tower-21.messagelabs.com with SMTP; 11 Jan 2016 08:55:41 -0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP; 11 Jan 2016 00:55:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,551,1444719600"; d="scan'208";a="724510458" Received: from ll.sh.intel.com (HELO localhost) ([10.239.13.27]) by orsmga003.jf.intel.com with ESMTP; 11 Jan 2016 00:55:37 -0800 From: Liang Li To: xen-devel@lists.xen.org Date: Mon, 11 Jan 2016 16:52:10 +0800 Message-Id: <1452502330-2630-1-git-send-email-liang.z.li@intel.com> X-Mailer: git-send-email 1.9.1 Cc: wei.liu2@citrix.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, Liang Li , ian.jackson@eu.citrix.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH] libxc: Expose the MPX cpuid flag to guest X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If hardware support memory protect externsion, expose this feature to guest by default. Users don't have to use a 'cpuid= ' option in config file to turn it on. Signed-off-by: Liang Li Reviewed-by: Andrew Cooper --- tools/libxc/xc_cpufeature.h | 1 + tools/libxc/xc_cpuid_x86.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/tools/libxc/xc_cpufeature.h b/tools/libxc/xc_cpufeature.h index c3ddc80..cda9305 100644 --- a/tools/libxc/xc_cpufeature.h +++ b/tools/libxc/xc_cpufeature.h @@ -137,6 +137,7 @@ #define X86_FEATURE_ERMS 9 /* Enhanced REP MOVSB/STOSB */ #define X86_FEATURE_INVPCID 10 /* Invalidate Process Context ID */ #define X86_FEATURE_RTM 11 /* Restricted Transactional Memory */ +#define X86_FEATURE_MPX 14 /* Memory Protection Extensions */ #define X86_FEATURE_RDSEED 18 /* RDSEED instruction */ #define X86_FEATURE_ADX 19 /* ADCX, ADOX instructions */ #define X86_FEATURE_SMAP 20 /* Supervisor Mode Access Protection */ diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c index 8882c01..4c88db4 100644 --- a/tools/libxc/xc_cpuid_x86.c +++ b/tools/libxc/xc_cpuid_x86.c @@ -423,6 +423,8 @@ static void xc_cpuid_hvm_policy(xc_interface *xch, bitmaskof(X86_FEATURE_ERMS) | bitmaskof(X86_FEATURE_INVPCID) | bitmaskof(X86_FEATURE_RTM) | + ((info->xfeature_mask != 0) ? + bitmaskof(X86_FEATURE_MPX) : 0) | bitmaskof(X86_FEATURE_RDSEED) | bitmaskof(X86_FEATURE_ADX) | bitmaskof(X86_FEATURE_SMAP) | @@ -538,6 +540,7 @@ static void xc_cpuid_pv_policy(xc_interface *xch, case 0x00000007: if ( input[1] == 0 ) + { regs[1] &= (bitmaskof(X86_FEATURE_BMI1) | bitmaskof(X86_FEATURE_HLE) | bitmaskof(X86_FEATURE_AVX2) | @@ -547,6 +550,9 @@ static void xc_cpuid_pv_policy(xc_interface *xch, bitmaskof(X86_FEATURE_RDSEED) | bitmaskof(X86_FEATURE_ADX) | bitmaskof(X86_FEATURE_FSGSBASE)); + if ( info->xfeature_mask == 0 ) + clear_bit(X86_FEATURE_MPX, regs[1]); + } else regs[1] = 0; regs[0] = regs[2] = regs[3] = 0;