From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] qemu-kvm: Enable xsave related CPUID Date: Wed, 19 May 2010 19:58:02 +0300 Message-ID: <4BF4189A.4030000@redhat.com> References: <1274258090-12247-1-git-send-email-sheng@linux.intel.com> <1274258090-12247-2-git-send-email-sheng@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm@vger.kernel.org, qemu-devel@nongnu.org To: Sheng Yang Return-path: Received: from mx1.redhat.com ([209.132.183.28]:26438 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752869Ab0ESQ6G (ORCPT ); Wed, 19 May 2010 12:58:06 -0400 In-Reply-To: <1274258090-12247-2-git-send-email-sheng@linux.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On 05/19/2010 11:34 AM, Sheng Yang wrote: > Signed-off-by: Sheng Yang > --- > target-i386/cpuid.c | 32 ++++++++++++++++++++++++++++++++ > Can send to Anthony directly, while tcg doesn't support xsave/ymm, all the code here is generic. > 1 files changed, 32 insertions(+), 0 deletions(-) > > diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c > index eebf038..21e94f3 100644 > --- a/target-i386/cpuid.c > +++ b/target-i386/cpuid.c > @@ -1067,6 +1067,38 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, > *ecx = 0; > *edx = 0; > break; > + case 0xD: > + /* Processor Extended State */ > + if (!(env->cpuid_ext_features& CPUID_EXT_XSAVE)) { > + *eax = 0; > + *ebx = 0; > + *ecx = 0; > + *edx = 0; > + break; > + } > + if (count == 0) { > + *eax = 0x7; > + *ebx = 0x340; > + *ecx = 0x340; > + *edx = 0; > + } else if (count == 1) { > + /* eax = 1, so we can continue with others */ > + *eax = 1; > + *ebx = 0; > + *ecx = 0; > + *edx = 0; > + } else if (count == 2) { > + *eax = 0x100; > + *ebx = 0x240; > + *ecx = 0; > + *edx = 0; > + } else { > + *eax = 0; > + *ebx = 0; > + *ecx = 0; > + *edx = 0; > + } > + break; > Lots of magic numbers. Symbolic constants or explanatory comments. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.