From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A8E4204F75; Mon, 17 Mar 2025 16:38:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742229520; cv=none; b=jGFl03EdloHohMK0qdLfZ1wOBv31Iss2Nad0Zl6mtXwNPTMBfOuKd6Spc1f8TKYEXUwc+7vGISvX5rg6QYAPauMJ8dqYo0Ouj2YR1VCQija0d9SuHOAZKwPqhygVxoqFQHhhH/lYsHtONeJPtary8xKgveMN0xgIhqh/w5h5DCI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742229520; c=relaxed/simple; bh=22zivszfsLHVUqSvsfQBBD0P2PKD7+iel7RGGmGOg2M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UsD5QHQi4y6+//qEIy+gFH5/9q4aKosMhsSjShw6/0Qd9Xcxw1z1loie53/qRTE8owGaQ4r12D3TtKt+XhxhIrdQCojSP6XzasOXwjjzL9ez5Q1+H0OVyeMuLGKCMnL+4OzJUiNE00qjD0871yakhj3YCCvaQVYhx34ANT6klIM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bv70RRZg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bv70RRZg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35117C4CEEC; Mon, 17 Mar 2025 16:38:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742229520; bh=22zivszfsLHVUqSvsfQBBD0P2PKD7+iel7RGGmGOg2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bv70RRZggyN6ep77819i4RPLlsC5beDsaicTK+GuGJ39zpMe4B9z4UjYPwTQoMsIm WgXKWbAsXcLv747iKk5ZljmVnf2LpQov3JwAeGCiH8OHccoGanBehp4widJxedEVMs PQuDAe5wXbnS0JdAhETcfsS+ESdfuxxuC4tniOwdQbrCN8Rzatgp3lAJuXQj8pKgHU yUsshkpoDyRaSWn2OUwjVqUwn4SZdiOEU9h28i1ERoXr38UJLvFcZlg7QXx3WMmfJz ENjFKcEOjCf0mznV7YV5AQU4vz6PF7SYIJAb4mZAaWZjQO2dN+2XGs6LKxt3zDZVWr E+GGhA+Sesfvg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vladis Dronov , Ingo Molnar , Kai Huang , Jarkko Sakkinen , Andy Lutomirski , Sean Christopherson , Linus Torvalds , Peter Zijlstra , Sasha Levin , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, linux-sgx@vger.kernel.org Subject: [PATCH AUTOSEL 6.12 08/13] x86/sgx: Warn explicitly if X86_FEATURE_SGX_LC is not enabled Date: Mon, 17 Mar 2025 12:38:13 -0400 Message-Id: <20250317163818.1893102-8-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250317163818.1893102-1-sashal@kernel.org> References: <20250317163818.1893102-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.12.19 Content-Transfer-Encoding: 8bit From: Vladis Dronov [ Upstream commit 65be5c95d08eedda570a6c888a12384c77fe7614 ] The kernel requires X86_FEATURE_SGX_LC to be able to create SGX enclaves, not just X86_FEATURE_SGX. There is quite a number of hardware which has X86_FEATURE_SGX but not X86_FEATURE_SGX_LC. A kernel running on such hardware does not create the /dev/sgx_enclave file and does so silently. Explicitly warn if X86_FEATURE_SGX_LC is not enabled to properly notify users that the kernel disabled the SGX driver. The X86_FEATURE_SGX_LC, a.k.a. SGX Launch Control, is a CPU feature that enables LE (Launch Enclave) hash MSRs to be writable (with additional opt-in required in the 'feature control' MSR) when running enclaves, i.e. using a custom root key rather than the Intel proprietary key for enclave signing. I've hit this issue myself and have spent some time researching where my /dev/sgx_enclave file went on SGX-enabled hardware. Related links: 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/ [ mingo: Made the error message a bit more verbose, and added other cases where the kernel fails to create the /dev/sgx_enclave device node. ] Signed-off-by: Vladis Dronov Signed-off-by: Ingo Molnar Acked-by: Kai Huang Cc: Jarkko Sakkinen Cc: Andy Lutomirski Cc: Sean Christopherson Cc: Linus Torvalds Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20250309172215.21777-2-vdronov@redhat.com Signed-off-by: Sasha Levin --- arch/x86/kernel/cpu/sgx/driver.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/driver.c b/arch/x86/kernel/cpu/sgx/driver.c index 22b65a5f5ec6c..7f8d1e11dbee2 100644 --- a/arch/x86/kernel/cpu/sgx/driver.c +++ b/arch/x86/kernel/cpu/sgx/driver.c @@ -150,13 +150,15 @@ 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_info("SGX disabled: SGX launch control CPU feature is not available, /dev/sgx_enclave disabled.\n"); return -ENODEV; + } cpuid_count(SGX_CPUID, 0, &eax, &ebx, &ecx, &edx); if (!(eax & 1)) { - pr_err("SGX disabled: SGX1 instruction support not available.\n"); + pr_info("SGX disabled: SGX1 instruction support not available, /dev/sgx_enclave disabled.\n"); return -ENODEV; } @@ -173,8 +175,10 @@ int __init sgx_drv_init(void) } ret = misc_register(&sgx_dev_enclave); - if (ret) + if (ret) { + pr_info("SGX disabled: Unable to register the /dev/sgx_enclave driver (%d).\n", ret); return ret; + } return 0; } -- 2.39.5