From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751492AbbH1Eyd (ORCPT ); Fri, 28 Aug 2015 00:54:33 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:34079 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750698AbbH1Eyc (ORCPT ); Fri, 28 Aug 2015 00:54:32 -0400 Date: Fri, 28 Aug 2015 06:54:28 +0200 From: Ingo Molnar To: Dave Hansen 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 Subject: Re: [PATCH 09/11] x86, fpu: correct and check XSAVE xstate size calculations Message-ID: <20150828045427.GB25556@gmail.com> References: <20150827171102.1BDF27E5@viggo.jf.intel.com> <20150827171110.ADA00471@viggo.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150827171110.ADA00471@viggo.jf.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * 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. Thanks, Ingo