From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH] x86: clear CPUID output of leaf 0xd for Dom0 when xsave is disabled Date: Wed, 18 May 2011 10:53:27 +0100 Message-ID: <4DD3B3370200007800041DB6@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part664AF507.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part664AF507.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Linux starting with 2.6.36 uses the XSAVEOPT instruction and has certain code paths that look only at the feature bit reported through CPUID leaf 0xd sub-leaf 1 (i.e. without qualifying the check with one evaluating leaf 4 output). Consequently the hypervisor ought to mimic actual hardware in clearing leaf 0xd output when not supporting xsave. (Note that this is only a minimal fix. It may be necessary, e.g. for LWP, to also adjust sub-leaf 0's bit masks and perhaps zap output of sub-leaves > 1 when the respective bit in sub-leaf 0 is getting cleared.) Signed-off-by: Jan Beulich --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -836,6 +836,10 @@ static void pv_cpuid(struct cpu_user_reg __clear_bit(X86_FEATURE_NODEID_MSR % 32, &c); __clear_bit(X86_FEATURE_TOPOEXT % 32, &c); break; + case 0xd: /* XSAVE */ + if ( xsave_enabled(current) ) + break; + /* fall through */ case 5: /* MONITOR/MWAIT */ case 0xa: /* Architectural Performance Monitor Features */ case 0x8000000a: /* SVM revision and features */ --=__Part664AF507.0__= Content-Type: text/plain; name="x86-cpuid-xsave-hide.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-cpuid-xsave-hide.patch" Linux starting with 2.6.36 uses the XSAVEOPT instruction and has=0Acertain = code paths that look only at the feature bit reported through=0ACPUID leaf = 0xd sub-leaf 1 (i.e. without qualifying the check with one=0Aevaluating = leaf 4 output). Consequently the hypervisor ought to mimic=0Aactual = hardware in clearing leaf 0xd output when not supporting xsave.=0A=0A(Note = that this is only a minimal fix. It may be necessary, e.g. for=0ALWP, to = also adjust sub-leaf 0's bit masks and perhaps zap output of=0Asub-leaves = > 1 when the respective bit in sub-leaf 0 is getting=0Acleared.)=0A=0ASigne= d-off-by: Jan Beulich =0A=0A--- a/xen/arch/x86/traps.c= =0A+++ b/xen/arch/x86/traps.c=0A@@ -836,6 +836,10 @@ static void pv_cpuid(s= truct cpu_user_reg=0A __clear_bit(X86_FEATURE_NODEID_MSR % 32, = &c);=0A __clear_bit(X86_FEATURE_TOPOEXT % 32, &c);=0A = break;=0A+ case 0xd: /* XSAVE */=0A+ if ( xsave_enabled(current) = )=0A+ break;=0A+ /* fall through */=0A case 5: /* = MONITOR/MWAIT */=0A case 0xa: /* Architectural Performance Monitor = Features */=0A case 0x8000000a: /* SVM revision and features */=0A --=__Part664AF507.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__Part664AF507.0__=--