Skip to contentSkip to conversation

x86/sgx: Warn explicitly if X86_FEATURE_SGX_LC is not enabled

PATCH Superseded Vladis Dronov 2 participants 2 messages Mar 9, 2025 – Mar 10, 2025

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/sgx: Warn explicitly if X86_FEATURE_SGX_LC is not enabled

A kernel requires X86_FEATURE_SGX_LC to be able to create SGX enclaves. There is quite a number of hardware which has X86_FEATURE_SGX but not X86_FEATURE_SGX_LC. A kernel running on such a hardware does not create /dev/sgx* devices silently. Explicitly warn if X86_FEATURE_SGX_LC is not enabled to properly nofity a user about this condition.

The X86_FEATURE_SGX_LC is a CPU feature that enables LE hash MSRs to be writable when running native enclaves, i.e. using a custom root key rather than the Intel proprietary key for enclave signing.

---

an out-of-commit-message note:

I've hit this issue myself and have spent some time researching where are my /dev/sgx* devices on an SGX-enabled hardware, so this is a bit personal.

Links related:
https://github.com/intel/linux-sgx/issues/837
https://patchwork.kernel.org/project/platform-driver-x86/patch/[email protected]/

 arch/x86/kernel/cpu/sgx/driver.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/sgx/driver.c +3 -1
index 22b65a5f5ec6..df4fbfaa6616 100644
@@ -150,8 +150,10 @@ int __init sgx_drv_init(void)
 	u64 xfrm_mask;
 	int ret;
 
-	if (!cpu_feature_enabled(X86_FEATURE_SGX_LC))
+	if (!cpu_feature_enabled(X86_FEATURE_SGX_LC)) {
+		pr_err("SGX disabled: SGX launch control is not available.\n");
 		return -ENODEV;
+	}
 
 	cpuid_count(SGX_CPUID, 0, &eax, &ebx, &ecx, &edx);
 
Signature · 1 line
2.48.1
maintainer
#1 lore raw
Quoted 5 lines · Vladis Dronov

A kernel requires X86_FEATURE_SGX_LC to be able to create SGX enclaves. There is quite a number of hardware which has X86_FEATURE_SGX but not X86_FEATURE_SGX_LC. A kernel running on such a hardware does not create /dev/sgx* devices silently. Explicitly warn if X86_FEATURE_SGX_LC is not enabled to properly nofity a user about this condition.

                      ~~~~~~
		      notify
Quoted 25 lines

The X86_FEATURE_SGX_LC is a CPU feature that enables LE hash MSRs to be writable when running native enclaves, i.e. using a custom root key rather than the Intel proprietary key for enclave signing.

---

an out-of-commit-message note:

I've hit this issue myself and have spent some time researching where are my /dev/sgx* devices on an SGX-enabled hardware, so this is a bit personal.

Links related:
https://github.com/intel/linux-sgx/issues/837
https://patchwork.kernel.org/project/platform-driver-x86/patch/[email protected]/

 arch/x86/kernel/cpu/sgx/driver.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/sgx/driver.c +0 -0
index 22b65a5f5ec6..df4fbfaa6616 100644

arch/x86/kernel/cpu/sgx/driver.c int __init sgx_drv_init(void) · line 154

Quoted 6 lines
arch/x86/kernel/cpu/sgx/driver.c +2 -1
@@ -150,8 +150,10 @@ int __init sgx_drv_init(void)
 	u64 xfrm_mask;
 	int ret;
 
-	if (!cpu_feature_enabled(X86_FEATURE_SGX_LC))
+	if (!cpu_feature_enabled(X86_FEATURE_SGX_LC)) {
+		pr_err("SGX disabled: SGX launch control is not available.\n");

I think this should not be error, as the system is not failing.

Since it is informative, it should be info-level message.

Quoted 8 lines
arch/x86/kernel/cpu/sgx/driver.c +1 -0
 		return -ENODEV;
+	}
 
 	cpuid_count(SGX_CPUID, 0, &eax, &ebx, &ecx, &edx);
 
Signature · 1 line
2.48.1

BR, Jarkko