Thread (155 messages) 155 messages, 7 authors, 2021-02-05

Re: [RFC PATCH v3 01/27] x86/cpufeatures: Add SGX1 and SGX2 sub-features

From: Jarkko Sakkinen <jarkko@kernel.org>
Date: 2021-01-30 13:21:42

On Wed, Jan 27, 2021 at 12:18:32PM +1300, Kai Huang wrote:
On Tue, 2021-01-26 at 07:34 -0800, Dave Hansen wrote:
quoted
On 1/26/21 1:30 AM, Kai Huang wrote:
quoted
From: Sean Christopherson <seanjc@google.com>

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.

?
quoted
quoted
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 */
(EDMM)

/Jarkko
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help