All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] x86/sgx: Warn explicitly if X86_FEATURE_SGX_LC is not enabled
@ 2025-03-09 17:22 Vladis Dronov
  2025-03-10  1:37 ` Huang, Kai
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Vladis Dronov @ 2025-03-09 17:22 UTC (permalink / raw)
  To: linux-sgx, Jarkko Sakkinen, Dave Hansen
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
	H. Peter Anvin, linux-kernel, 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_enclave file 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.

Signed-off-by: Vladis Dronov <vdronov@redhat.com>
---

an out-of-commit-message note:

I've hit this issue myself and have spent some time researching where is
my /dev/sgx_enclave file 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/20180827185507.17087-3-jarkko.sakkinen@linux.intel.com/

 arch/x86/kernel/cpu/sgx/driver.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/sgx/driver.c b/arch/x86/kernel/cpu/sgx/driver.c
index 22b65a5f5ec6..df4fbfaa6616 100644
--- a/arch/x86/kernel/cpu/sgx/driver.c
+++ b/arch/x86/kernel/cpu/sgx/driver.c
@@ -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);
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-03-10 15:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-09 17:22 [PATCH v2] x86/sgx: Warn explicitly if X86_FEATURE_SGX_LC is not enabled Vladis Dronov
2025-03-10  1:37 ` Huang, Kai
2025-03-10  8:42   ` [PATCH -v3] " Ingo Molnar
2025-03-10 10:54     ` Huang, Kai
2025-03-10 15:39       ` Vladis Dronov
2025-03-10  8:57 ` [tip: x86/urgent] " tip-bot2 for Vladis Dronov
2025-03-10 11:40 ` tip-bot2 for Vladis Dronov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.