From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.skyhub.de ([5.9.137.197]:39092 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726664AbeIYW5M (ORCPT ); Tue, 25 Sep 2018 18:57:12 -0400 Date: Tue, 25 Sep 2018 18:48:54 +0200 From: Borislav Petkov To: Jarkko Sakkinen CC: , , , , , , , , , , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "Konrad Rzeszutek Wilk" , David Woodhouse , David Wang , "Kirill A. Shutemov" , "Levin, Alexander (Sasha Levin)" , Jia Zhang , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Subject: Re: [PATCH v14 04/19] x86/cpufeatures: Add SGX feature bits Message-ID: <20180925164854.GF23986@zn.tnic> References: <20180925130845.9962-1-jarkko.sakkinen@linux.intel.com> <20180925130845.9962-5-jarkko.sakkinen@linux.intel.com> Content-Type: text/plain; charset="utf-8" In-Reply-To: <20180925130845.9962-5-jarkko.sakkinen@linux.intel.com> Sender: List-ID: Return-Path: linux-sgx-owner@vger.kernel.org MIME-Version: 1.0 On Tue, Sep 25, 2018 at 04:06:41PM +0300, Jarkko Sakkinen wrote: > From: Sean Christopherson > > Add SGX feature bits as part of the Linux defined leaf 8, which > currently contains virtualization flags. There are currently four > documented SGX feature bits, with more expected in the not-too-distant > future. ... > +static void detect_sgx(struct cpuinfo_x86 *c) > +{ > +#define _X86_FEATURE_SGX1 BIT(0) > +#define _X86_FEATURE_SGX2 BIT(1) > +#define _X86_FEATURE_SGX_ENCLV BIT(5) > +#define _X86_FEATURE_SGX_ENCLS_C BIT(6) > + > + unsigned int eax; > + > + clear_cpu_cap(c, X86_FEATURE_SGX1); > + clear_cpu_cap(c, X86_FEATURE_SGX2); > + clear_cpu_cap(c, X86_FEATURE_SGX_ENCLV); > + clear_cpu_cap(c, X86_FEATURE_SGX_ENCLS_C); > + > + if (c->cpuid_level < SGX_CPUID) { > + pr_err_once("x86/sgx: cannot enumerate CPUID leaf (0x%x)\n", > + SGX_CPUID); > + clear_cpu_cap(c, X86_FEATURE_SGX); > + return; > + } > + > + eax = cpuid_eax(SGX_CPUID); > + > + if (eax & _X86_FEATURE_SGX1) > + set_cpu_cap(c, X86_FEATURE_SGX1); > + > + if (eax & _X86_FEATURE_SGX2) > + set_cpu_cap(c, X86_FEATURE_SGX2); > + > + if (eax & _X86_FEATURE_SGX_ENCLV) > + set_cpu_cap(c, X86_FEATURE_SGX_ENCLV); > + > + if (eax & _X86_FEATURE_SGX_ENCLS_C) > + set_cpu_cap(c, X86_FEATURE_SGX_ENCLS_C); Look at arch/x86/kernel/cpu/scattered.c for how to do this properly. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.