From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shuai Ruan Subject: [V11 3/3] libxc: expose xsaves/xgetbv1/xsavec to hvm guest Date: Fri, 20 Nov 2015 09:18:02 +0800 Message-ID: <1447982282-7437-4-git-send-email-shuai.ruan@linux.intel.com> References: <1447982282-7437-1-git-send-email-shuai.ruan@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1447982282-7437-1-git-send-email-shuai.ruan@linux.intel.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@lists.xen.org Cc: kevin.tian@intel.com, wei.liu2@citrix.com, Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com, jun.nakajima@intel.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, jbeulich@suse.com, keir@xen.org List-Id: xen-devel@lists.xenproject.org From: Shuai Ruan This patch exposes xsaves/xgetbv1/xsavec to hvm guest. The reserved bits of eax/ebx/ecx/edx must be cleaned up when call cpuid(0dh) with leaf 1 or 2..63. According to the spec the following bits must be reserved: For leaf 1, bits 03-04/08-31 of ecx is reserved. Edx is reserved. For leaf 2...63, bits 01-31 of ecx is reserved, Edx is reserved. But as no XSS festures are currently supported, even in HVM guests, for leaf 2...63, ecx should be zero at the moment. Signed-off-by: Shuai Ruan Acked-by: Ian Campbell --- tools/libxc/xc_cpuid_x86.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c index 031c848..8882c01 100644 --- a/tools/libxc/xc_cpuid_x86.c +++ b/tools/libxc/xc_cpuid_x86.c @@ -282,6 +282,9 @@ static void intel_xc_cpuid_policy(xc_interface *xch, } #define XSAVEOPT (1 << 0) +#define XSAVEC (1 << 1) +#define XGETBV1 (1 << 2) +#define XSAVES (1 << 3) /* Configure extended state enumeration leaves (0x0000000D for xsave) */ static void xc_cpuid_config_xsave(xc_interface *xch, const struct cpuid_domain_info *info, @@ -318,8 +321,11 @@ static void xc_cpuid_config_xsave(xc_interface *xch, regs[1] = 512 + 64; /* FP/SSE + XSAVE.HEADER */ break; case 1: /* leaf 1 */ - regs[0] &= XSAVEOPT; - regs[1] = regs[2] = regs[3] = 0; + regs[0] &= (XSAVEOPT | XSAVEC | XGETBV1 | XSAVES); + if ( !info->hvm ) + regs[0] &= ~XSAVES; + regs[2] &= info->xfeature_mask; + regs[3] = 0; break; case 2 ... 63: /* sub-leaves */ if ( !(info->xfeature_mask & (1ULL << input[1])) ) -- 1.9.1