From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752819AbbH1Obw (ORCPT ); Fri, 28 Aug 2015 10:31:52 -0400 Received: from www.sr71.net ([198.145.64.142]:49408 "EHLO blackbird.sr71.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752506AbbH1Obu (ORCPT ); Fri, 28 Aug 2015 10:31:50 -0400 Message-ID: <55E070D3.1060208@sr71.net> Date: Fri, 28 Aug 2015 07:31:47 -0700 From: Dave Hansen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Ingo Molnar CC: dave.hansen@linux.intel.com, bp@alien8.de, fenghua.yu@intel.com, hpa@zytor.com, x86@kernel.org, tim.c.chen@linux.intel.com, linux-kernel@vger.kernel.org, Linus Torvalds , "Kleen, Andi" Subject: Re: [PATCH 09/11] x86, fpu: correct and check XSAVE xstate size calculations References: <20150827171102.1BDF27E5@viggo.jf.intel.com> <20150827171110.ADA00471@viggo.jf.intel.com> <20150828045427.GB25556@gmail.com> In-Reply-To: <20150828045427.GB25556@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/27/2015 09:54 PM, Ingo Molnar wrote: > > * Dave Hansen wrote: > >> +static int xfeature_is_supervisor(int xfeature_nr) >> +{ >> + /* >> + * We currently do not suport supervisor states, but if >> + * we did, we could find out like this. >> + * >> + * SDM says: If state component i is a user state component, >> + * ECX[0] return 0; if state component i is a supervisor >> + * state component, ECX[0] returns 1. >> + u32 eax, ebx, ecx, edx; >> + cpuid_count(XSTATE_CPUID, xfeature_nr, &eax, &ebx, &ecx, &edx); >> + return !!(ecx & 1); >> + */ >> + return 0; >> +} > > So if this CPUID is documented to work, why not use it to sanity check things? > > I.e. do something like: > > u32 eax, ebx, ecx, edx; > > cpuid_count(XSTATE_CPUID, xfeature_nr, &eax, &ebx, &ecx, &edx); > > /* Linux doesn't support supervisor states (yet): */ > WARN_ON_ONCE(ecx & 1); > > return 0; > > That would give us a gentle way to double check our assumptions here. Actually, the newest state that you will see in the wild is for Processor Trace, and it _is_ a supervisor state. However, we don't use it in Linux for our Processor Trace support, and Andi says we probably never will. So we probably shouldn't warn on it.