From 4654f94dc795a180d3438fc24d7a29aac1224f41 Mon Sep 17 00:00:00 2001 From: Jarkko Sakkinen Date: Thu, 11 Mar 2021 07:19:16 +0800 Subject: [PATCH 2584/2944] x86/cpu/intel: Add a nosgx kernel parameter to #32051961 commit 38853a303982e3be3eccb1a1132399a5c5e2d806 upstream. Add a kernel parameter to disable SGX kernel support and document it. [ bp: Massage. ] Signed-off-by: Jarkko Sakkinen Signed-off-by: Borislav Petkov Reviewed-by: Sean Christopherson Acked-by: Jethro Beekman Tested-by: Sean Christopherson Link: https://lkml.kernel.org/r/20201112220135.165028-9-jarkko@kernel.org Signed-off-by: Di Jin Signed-off-by: GuoRui.Yu Reviewed-by: Jia Zhang --- Documentation/admin-guide/kernel-parameters.txt | 2 ++ arch/x86/kernel/cpu/feat_ctl.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 59b53b8..581f215 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3070,6 +3070,8 @@ nosep [BUGS=X86-32] Disables x86 SYSENTER/SYSEXIT support. + nosgx [X86-64,SGX] Disables Intel SGX kernel support. + nosmp [SMP] Tells an SMP kernel to act as a UP kernel, and disable the IO APIC. legacy for "maxcpus=0". diff --git a/arch/x86/kernel/cpu/feat_ctl.c b/arch/x86/kernel/cpu/feat_ctl.c index 221f4a9..0cf7bf66 100644 --- a/arch/x86/kernel/cpu/feat_ctl.c +++ b/arch/x86/kernel/cpu/feat_ctl.c @@ -11,6 +11,15 @@ static void clear_sgx_caps(void) setup_clear_cpu_cap(X86_FEATURE_SGX_LC); } +static int __init nosgx(char *str) +{ + clear_sgx_caps(); + + return 0; +} + +early_param("nosgx", nosgx); + void init_ia32_feat_ctl(struct cpuinfo_x86 *c) { bool enable_sgx; -- 1.8.3.1