Skip to content

Commit b8921dc

Browse files
sean-jcsuryasaimadhu
authored andcommitted
x86/cpufeatures: Add SGX1 and SGX2 sub-features
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. Suppress both SGX1 and SGX2 from /proc/cpuinfo. SGX1 basically means SGX, and for SGX2 there is no concrete use case of using it in /proc/cpuinfo. Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Kai Huang <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Dave Hansen <[email protected]> Acked-by: Jarkko Sakkinen <[email protected]> Link: https://lkml.kernel.org/r/d787827dbfca6b3210ac3e432e3ac1202727e786.1616136308.git.kai.huang@intel.com
1 parent e9a15a4 commit b8921dc

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

arch/x86/include/asm/cpufeatures.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@
290290
#define X86_FEATURE_FENCE_SWAPGS_KERNEL (11*32+ 5) /* "" LFENCE in kernel entry SWAPGS path */
291291
#define X86_FEATURE_SPLIT_LOCK_DETECT (11*32+ 6) /* #AC for split lock */
292292
#define X86_FEATURE_PER_THREAD_MBA (11*32+ 7) /* "" Per-thread Memory Bandwidth Allocation */
293+
#define X86_FEATURE_SGX1 (11*32+ 8) /* "" Basic SGX */
294+
#define X86_FEATURE_SGX2 (11*32+ 9) /* "" SGX Enclave Dynamic Memory Management (EDMM) */
293295

294296
/* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */
295297
#define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */

arch/x86/kernel/cpu/cpuid-deps.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ static const struct cpuid_dep cpuid_deps[] = {
7373
{ X86_FEATURE_ENQCMD, X86_FEATURE_XSAVES },
7474
{ X86_FEATURE_PER_THREAD_MBA, X86_FEATURE_MBA },
7575
{ X86_FEATURE_SGX_LC, X86_FEATURE_SGX },
76+
{ X86_FEATURE_SGX1, X86_FEATURE_SGX },
77+
{ X86_FEATURE_SGX2, X86_FEATURE_SGX1 },
7678
{}
7779
};
7880

arch/x86/kernel/cpu/scattered.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ static const struct cpuid_bit cpuid_bits[] = {
3636
{ X86_FEATURE_CDP_L2, CPUID_ECX, 2, 0x00000010, 2 },
3737
{ X86_FEATURE_MBA, CPUID_EBX, 3, 0x00000010, 0 },
3838
{ X86_FEATURE_PER_THREAD_MBA, CPUID_ECX, 0, 0x00000010, 3 },
39+
{ X86_FEATURE_SGX1, CPUID_EAX, 0, 0x00000012, 0 },
40+
{ X86_FEATURE_SGX2, CPUID_EAX, 1, 0x00000012, 0 },
3941
{ X86_FEATURE_HW_PSTATE, CPUID_EDX, 7, 0x80000007, 0 },
4042
{ X86_FEATURE_CPB, CPUID_EDX, 9, 0x80000007, 0 },
4143
{ X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 },

0 commit comments

Comments
 (0)