From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9560EC433E0 for ; Wed, 27 Jan 2021 04:23:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 448A320709 for ; Wed, 27 Jan 2021 04:23:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238434AbhA0EWz (ORCPT ); Tue, 26 Jan 2021 23:22:55 -0500 Received: from mga11.intel.com ([192.55.52.93]:37060 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731222AbhAZXUc (ORCPT ); Tue, 26 Jan 2021 18:20:32 -0500 IronPort-SDR: FvSb8HqeuE7rULHCiHbHIY6HiDMn27xiXvdKn/Cu2PdsyrWvQKvAMNYHuh5sBSC24nf+ycBMNx 5kKrUNmL9rJQ== X-IronPort-AV: E=McAfee;i="6000,8403,9876"; a="176478212" X-IronPort-AV: E=Sophos;i="5.79,377,1602572400"; d="scan'208";a="176478212" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2021 15:18:37 -0800 IronPort-SDR: TB0ILoE4neBV5jpHdaXohUbBOuzfJmaZ8dPlKgnyb/UBhFWYhJd2zIaahMJExqSqxxJGvHfwQh An5bBX40KOKQ== X-IronPort-AV: E=Sophos;i="5.79,377,1602572400"; d="scan'208";a="574196941" Received: from rsperry-desk.amr.corp.intel.com ([10.251.7.187]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2021 15:18:34 -0800 Message-ID: <3a82563d5a25b52f0b5f01560d70c50a2323f7e5.camel@intel.com> Subject: Re: [RFC PATCH v3 01/27] x86/cpufeatures: Add SGX1 and SGX2 sub-features From: Kai Huang To: Dave Hansen , linux-sgx@vger.kernel.org, kvm@vger.kernel.org, x86@kernel.org Cc: seanjc@google.com, jarkko@kernel.org, luto@kernel.org, haitao.huang@intel.com, pbonzini@redhat.com, bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com Date: Wed, 27 Jan 2021 12:18:32 +1300 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.3 (3.38.3-1.fc33) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Tue, 2021-01-26 at 07:34 -0800, Dave Hansen wrote: > On 1/26/21 1:30 AM, Kai Huang wrote: > > From: Sean Christopherson > > > > Add SGX1 and SGX2 feature flags, via CPUID.0x12.0x0.EAX, as scattered > > features, since adding a new leaf for only two bits would be wasteful. > > As part of virtualizing SGX, KVM will expose the SGX CPUID leafs to its > > guest, and to do so correctly needs to query hardware and kernel support > > for SGX1 and SGX2. > > It's also not _just_ exposing the CPUID leaves. There are some checks > here when KVM is emulating some SGX instructions too, right? I would say trapping instead of emulating, but yes KVM will do more. However those are quite details, and I don't think we should put lots of details here. Or perhaps we can use 'for instance' as brief description: As part of virtualizing SGX, KVM will need to use the two flags, for instance, to expose them to guest. ? > > > diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h > > index 84b887825f12..18b2d0c8bbbe 100644 > > --- a/arch/x86/include/asm/cpufeatures.h > > +++ b/arch/x86/include/asm/cpufeatures.h > > @@ -292,6 +292,8 @@ > >  #define X86_FEATURE_FENCE_SWAPGS_KERNEL (11*32+ 5) /* "" LFENCE in kernel entry SWAPGS path */ > >  #define X86_FEATURE_SPLIT_LOCK_DETECT (11*32+ 6) /* #AC for split lock */ > >  #define X86_FEATURE_PER_THREAD_MBA (11*32+ 7) /* "" Per-thread Memory Bandwidth Allocation */ > > +#define X86_FEATURE_SGX1 (11*32+ 8) /* Software Guard Extensions sub-feature SGX1 */ > > +#define X86_FEATURE_SGX2 (11*32+ 9) /* Software Guard Extensions sub-feature SGX2 */ > > FWIW, I'm not sure how valuable it is to spell the SGX acronym out three > times. Can't we use those bytes to put something more useful in that > comment? I think we can remove comment for SGX1, since it is basically SGX. For SGX2, how about below? /* SGX Enclave Dynamic Memory Management */