From: "H. Peter Anvin (Intel)" <hpa@zytor.com>
Required and disabled feature masks completely rely on build configs,
i.e., once a build config is fixed, so are the feature masks. To
prepare for auto-generating a header with required and disabled feature
masks based on a build config, add feature Kconfig items:
- X86_REQUIRED_FEATURE_x
- X86_DISABLED_FEATURE_x
each of which may be set to "y" if and only if its preconditions from
current build config are met.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Xin Li (Intel) <xin@zytor.com>
---
Changes in v6:
* Move changes to X86_CMPXCHG64 to a separate patch (Borislav Petkov).
* Keep X86_{CX8,CMOV} and define X86_REQUIRED_FEATURE_{CX8,CMOV} on top
(Borislav Petkov).
Changes in v2:
* Keep the X86_{REQUIRED,DISABLED}_FEATURE_ prefixes solely in
arch/x86/Kconfig.cpufeatures (Borislav Petkov).
* Explain how config option names X86_{REQUIRED,DISABLED}_FEATURE_<name>
are formed (Borislav Petkov).
---
arch/x86/Kconfig | 2 +
arch/x86/Kconfig.cpufeatures | 197 +++++++++++++++++++++++++++++++++++
2 files changed, 199 insertions(+)
create mode 100644 arch/x86/Kconfig.cpufeatures
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 1e50da06ffc4..1b12725cac8c 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -3130,4 +3130,6 @@ config HAVE_ATOMIC_IOMAP
source "arch/x86/kvm/Kconfig"
+source "arch/x86/Kconfig.cpufeatures"
+
source "arch/x86/Kconfig.assembler"
diff --git a/arch/x86/Kconfig.cpufeatures b/arch/x86/Kconfig.cpufeatures
new file mode 100644
index 000000000000..5dcc49d928c5
--- /dev/null
+++ b/arch/x86/Kconfig.cpufeatures
@@ -0,0 +1,197 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# x86 feature bits (see arch/x86/include/asm/cpufeatures.h) that are
+# either REQUIRED to be enabled, or DISABLED (always ignored) for this
+# particular compile-time configuration. The tests for these features
+# are turned into compile-time constants via the generated
+# <asm/featuremasks.h>.
+#
+# The naming of these variables *must* match asm/cpufeatures.h, e.g.,
+# X86_FEATURE_ALWAYS <==> X86_REQUIRED_FEATURE_ALWAYS
+# X86_FEATURE_FRED <==> X86_DISABLED_FEATURE_FRED
+#
+# And these REQUIRED and DISABLED config options are manipulated in an
+# AWK script as the following example:
+#
+# +----------------------+
+# | X86_FRED = y ? |
+# +----------------------+
+# / \
+# Y / \ N
+# +-------------------------------------+ +-------------------------------+
+# | X86_DISABLED_FEATURE_FRED undefined | | X86_DISABLED_FEATURE_FRED = y |
+# +-------------------------------------+ +-------------------------------+
+# |
+# |
+# +-------------------------------------------+ |
+# | X86_FEATURE_FRED: feature word 12, bit 17 | ---->|
+# +-------------------------------------------+ |
+# |
+# |
+# +-------------------------------+
+# | set bit 17 of DISABLED_MASK12 |
+# +-------------------------------+
+#
+
+config X86_REQUIRED_FEATURE_ALWAYS
+ def_bool y
+
+config X86_REQUIRED_FEATURE_NOPL
+ def_bool y
+ depends on X86_64 || X86_P6_NOP
+
+config X86_REQUIRED_FEATURE_CX8
+ def_bool y
+ depends on X86_CX8
+
+# this should be set for all -march=.. options where the compiler
+# generates cmov.
+config X86_REQUIRED_FEATURE_CMOV
+ def_bool y
+ depends on X86_CMOV
+
+# this should be set for all -march= options where the compiler
+# generates movbe.
+config X86_REQUIRED_FEATURE_MOVBE
+ def_bool y
+ depends on MATOM
+
+config X86_REQUIRED_FEATURE_CPUID
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_UP
+ def_bool y
+ depends on !SMP
+
+config X86_REQUIRED_FEATURE_FPU
+ def_bool y
+ depends on !MATH_EMULATION
+
+config X86_REQUIRED_FEATURE_PAE
+ def_bool y
+ depends on X86_64 || X86_PAE
+
+config X86_REQUIRED_FEATURE_PSE
+ def_bool y
+ depends on X86_64 && !PARAVIRT_XXL
+
+config X86_REQUIRED_FEATURE_PGE
+ def_bool y
+ depends on X86_64 && !PARAVIRT_XXL
+
+config X86_REQUIRED_FEATURE_MSR
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_FXSR
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_XMM
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_XMM2
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_LM
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_UMIP
+ def_bool y
+ depends on !X86_UMIP
+
+config X86_DISABLED_FEATURE_VME
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_K6_MTRR
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_CYRIX_ARR
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_CENTAUR_MCR
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_PCID
+ def_bool y
+ depends on !X86_64
+
+config X86_DISABLED_FEATURE_PKU
+ def_bool y
+ depends on !X86_INTEL_MEMORY_PROTECTION_KEYS
+
+config X86_DISABLED_FEATURE_OSPKE
+ def_bool y
+ depends on !X86_INTEL_MEMORY_PROTECTION_KEYS
+
+config X86_DISABLED_FEATURE_LA57
+ def_bool y
+ depends on !X86_5LEVEL
+
+config X86_DISABLED_FEATURE_PTI
+ def_bool y
+ depends on !MITIGATION_PAGE_TABLE_ISOLATION
+
+config X86_DISABLED_FEATURE_RETPOLINE
+ def_bool y
+ depends on !MITIGATION_RETPOLINE
+
+config X86_DISABLED_FEATURE_RETPOLINE_LFENCE
+ def_bool y
+ depends on !MITIGATION_RETPOLINE
+
+config X86_DISABLED_FEATURE_RETHUNK
+ def_bool y
+ depends on !MITIGATION_RETHUNK
+
+config X86_DISABLED_FEATURE_UNRET
+ def_bool y
+ depends on !MITIGATION_UNRET_ENTRY
+
+config X86_DISABLED_FEATURE_CALL_DEPTH
+ def_bool y
+ depends on !MITIGATION_CALL_DEPTH_TRACKING
+
+config X86_DISABLED_FEATURE_LAM
+ def_bool y
+ depends on !ADDRESS_MASKING
+
+config X86_DISABLED_FEATURE_ENQCMD
+ def_bool y
+ depends on !INTEL_IOMMU_SVM
+
+config X86_DISABLED_FEATURE_SGX
+ def_bool y
+ depends on !X86_SGX
+
+config X86_DISABLED_FEATURE_XENPV
+ def_bool y
+ depends on !XEN_PV
+
+config X86_DISABLED_FEATURE_TDX_GUEST
+ def_bool y
+ depends on !INTEL_TDX_GUEST
+
+config X86_DISABLED_FEATURE_USER_SHSTK
+ def_bool y
+ depends on !X86_USER_SHADOW_STACK
+
+config X86_DISABLED_FEATURE_IBT
+ def_bool y
+ depends on !X86_KERNEL_IBT
+
+config X86_DISABLED_FEATURE_FRED
+ def_bool y
+ depends on !X86_FRED
+
+config X86_DISABLED_FEATURE_SEV_SNP
+ def_bool y
+ depends on !KVM_AMD_SEV
--
2.48.1
The following commit has been merged into the x86/core branch of tip:
Commit-ID: 3d37d9396eb37a62ba75bf8f3bd934500cf64bf0
Gitweb: https://git.kernel.org/tip/3d37d9396eb37a62ba75bf8f3bd934500cf64bf0
Author: H. Peter Anvin (Intel) <hpa@zytor.com>
AuthorDate: Fri, 28 Feb 2025 00:23:35 -08:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 19 Mar 2025 11:15:11 +01:00
x86/cpufeatures: Add {REQUIRED,DISABLED} feature configs
Required and disabled feature masks completely rely on build configs,
i.e., once a build config is fixed, so are the feature masks.
To prepare for auto-generating the <asm/cpufeaturemasks.h> header
with required and disabled feature masks based on a build config,
add feature Kconfig items:
- X86_REQUIRED_FEATURE_x
- X86_DISABLED_FEATURE_x
each of which may be set to "y" if and only if its preconditions from
current build config are met.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Xin Li (Intel) <xin@zytor.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250228082338.73859-3-xin@zytor.com
---
arch/x86/Kconfig | 2 +-
arch/x86/Kconfig.cpufeatures | 201 ++++++++++++++++++++++++++++++++++-
2 files changed, 203 insertions(+)
create mode 100644 arch/x86/Kconfig.cpufeatures
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index ddef352..98bd493 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -3130,4 +3130,6 @@ config HAVE_ATOMIC_IOMAP
source "arch/x86/kvm/Kconfig"
+source "arch/x86/Kconfig.cpufeatures"
+
source "arch/x86/Kconfig.assembler"
diff --git a/arch/x86/Kconfig.cpufeatures b/arch/x86/Kconfig.cpufeatures
new file mode 100644
index 0000000..e12d5b7
--- /dev/null
+++ b/arch/x86/Kconfig.cpufeatures
@@ -0,0 +1,201 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# x86 feature bits (see arch/x86/include/asm/cpufeatures.h) that are
+# either REQUIRED to be enabled, or DISABLED (always ignored) for this
+# particular compile-time configuration. The tests for these features
+# are turned into compile-time constants via the generated
+# <asm/cpufeaturemasks.h>.
+#
+# The naming of these variables *must* match asm/cpufeatures.h, e.g.,
+# X86_FEATURE_ALWAYS <==> X86_REQUIRED_FEATURE_ALWAYS
+# X86_FEATURE_FRED <==> X86_DISABLED_FEATURE_FRED
+#
+# And these REQUIRED and DISABLED config options are manipulated in an
+# AWK script as the following example:
+#
+# +----------------------+
+# | X86_FRED = y ? |
+# +----------------------+
+# / \
+# Y / \ N
+# +-------------------------------------+ +-------------------------------+
+# | X86_DISABLED_FEATURE_FRED undefined | | X86_DISABLED_FEATURE_FRED = y |
+# +-------------------------------------+ +-------------------------------+
+# |
+# |
+# +-------------------------------------------+ |
+# | X86_FEATURE_FRED: feature word 12, bit 17 | ---->|
+# +-------------------------------------------+ |
+# |
+# |
+# +-------------------------------+
+# | set bit 17 of DISABLED_MASK12 |
+# +-------------------------------+
+#
+
+config X86_REQUIRED_FEATURE_ALWAYS
+ def_bool y
+
+config X86_REQUIRED_FEATURE_NOPL
+ def_bool y
+ depends on X86_64 || X86_P6_NOP
+
+config X86_REQUIRED_FEATURE_CX8
+ def_bool y
+ depends on X86_CX8
+
+# this should be set for all -march=.. options where the compiler
+# generates cmov.
+config X86_REQUIRED_FEATURE_CMOV
+ def_bool y
+ depends on X86_CMOV
+
+# this should be set for all -march= options where the compiler
+# generates movbe.
+config X86_REQUIRED_FEATURE_MOVBE
+ def_bool y
+ depends on MATOM
+
+config X86_REQUIRED_FEATURE_CPUID
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_UP
+ def_bool y
+ depends on !SMP
+
+config X86_REQUIRED_FEATURE_FPU
+ def_bool y
+ depends on !MATH_EMULATION
+
+config X86_REQUIRED_FEATURE_PAE
+ def_bool y
+ depends on X86_64 || X86_PAE
+
+config X86_REQUIRED_FEATURE_PSE
+ def_bool y
+ depends on X86_64 && !PARAVIRT_XXL
+
+config X86_REQUIRED_FEATURE_PGE
+ def_bool y
+ depends on X86_64 && !PARAVIRT_XXL
+
+config X86_REQUIRED_FEATURE_MSR
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_FXSR
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_XMM
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_XMM2
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_LM
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_UMIP
+ def_bool y
+ depends on !X86_UMIP
+
+config X86_DISABLED_FEATURE_VME
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_K6_MTRR
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_CYRIX_ARR
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_CENTAUR_MCR
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_PCID
+ def_bool y
+ depends on !X86_64
+
+config X86_DISABLED_FEATURE_PKU
+ def_bool y
+ depends on !X86_INTEL_MEMORY_PROTECTION_KEYS
+
+config X86_DISABLED_FEATURE_OSPKE
+ def_bool y
+ depends on !X86_INTEL_MEMORY_PROTECTION_KEYS
+
+config X86_DISABLED_FEATURE_LA57
+ def_bool y
+ depends on !X86_5LEVEL
+
+config X86_DISABLED_FEATURE_PTI
+ def_bool y
+ depends on !MITIGATION_PAGE_TABLE_ISOLATION
+
+config X86_DISABLED_FEATURE_RETPOLINE
+ def_bool y
+ depends on !MITIGATION_RETPOLINE
+
+config X86_DISABLED_FEATURE_RETPOLINE_LFENCE
+ def_bool y
+ depends on !MITIGATION_RETPOLINE
+
+config X86_DISABLED_FEATURE_RETHUNK
+ def_bool y
+ depends on !MITIGATION_RETHUNK
+
+config X86_DISABLED_FEATURE_UNRET
+ def_bool y
+ depends on !MITIGATION_UNRET_ENTRY
+
+config X86_DISABLED_FEATURE_CALL_DEPTH
+ def_bool y
+ depends on !MITIGATION_CALL_DEPTH_TRACKING
+
+config X86_DISABLED_FEATURE_LAM
+ def_bool y
+ depends on !ADDRESS_MASKING
+
+config X86_DISABLED_FEATURE_ENQCMD
+ def_bool y
+ depends on !INTEL_IOMMU_SVM
+
+config X86_DISABLED_FEATURE_SGX
+ def_bool y
+ depends on !X86_SGX
+
+config X86_DISABLED_FEATURE_XENPV
+ def_bool y
+ depends on !XEN_PV
+
+config X86_DISABLED_FEATURE_TDX_GUEST
+ def_bool y
+ depends on !INTEL_TDX_GUEST
+
+config X86_DISABLED_FEATURE_USER_SHSTK
+ def_bool y
+ depends on !X86_USER_SHADOW_STACK
+
+config X86_DISABLED_FEATURE_IBT
+ def_bool y
+ depends on !X86_KERNEL_IBT
+
+config X86_DISABLED_FEATURE_FRED
+ def_bool y
+ depends on !X86_FRED
+
+config X86_DISABLED_FEATURE_SEV_SNP
+ def_bool y
+ depends on !KVM_AMD_SEV
+
+config X86_DISABLED_FEATURE_INVLPGB
+ def_bool y
+ depends on !BROADCAST_TLB_FLUSH
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: dc6e8bfc0c9e27cbfed27c7ed50c71205a7c9551
Gitweb: https://git.kernel.org/tip/dc6e8bfc0c9e27cbfed27c7ed50c71205a7c9551
Author: H. Peter Anvin (Intel) <hpa@zytor.com>
AuthorDate: Fri, 28 Feb 2025 00:23:35 -08:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 10 Mar 2025 09:02:30 +01:00
x86/cpufeatures: Add {REQUIRED,DISABLED} feature configs
Required and disabled feature masks completely rely on build configs,
i.e., once a build config is fixed, so are the feature masks.
To prepare for auto-generating the <asm/cpufeaturemasks.h> header
with required and disabled feature masks based on a build config,
add feature Kconfig items:
- X86_REQUIRED_FEATURE_x
- X86_DISABLED_FEATURE_x
each of which may be set to "y" if and only if its preconditions from
current build config are met.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Xin Li (Intel) <xin@zytor.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250228082338.73859-3-xin@zytor.com
---
arch/x86/Kconfig | 2 +-
arch/x86/Kconfig.cpufeatures | 201 ++++++++++++++++++++++++++++++++++-
2 files changed, 203 insertions(+)
create mode 100644 arch/x86/Kconfig.cpufeatures
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 017035f..7caf2fd 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -3128,4 +3128,6 @@ config HAVE_ATOMIC_IOMAP
source "arch/x86/kvm/Kconfig"
+source "arch/x86/Kconfig.cpufeatures"
+
source "arch/x86/Kconfig.assembler"
diff --git a/arch/x86/Kconfig.cpufeatures b/arch/x86/Kconfig.cpufeatures
new file mode 100644
index 0000000..e12d5b7
--- /dev/null
+++ b/arch/x86/Kconfig.cpufeatures
@@ -0,0 +1,201 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# x86 feature bits (see arch/x86/include/asm/cpufeatures.h) that are
+# either REQUIRED to be enabled, or DISABLED (always ignored) for this
+# particular compile-time configuration. The tests for these features
+# are turned into compile-time constants via the generated
+# <asm/cpufeaturemasks.h>.
+#
+# The naming of these variables *must* match asm/cpufeatures.h, e.g.,
+# X86_FEATURE_ALWAYS <==> X86_REQUIRED_FEATURE_ALWAYS
+# X86_FEATURE_FRED <==> X86_DISABLED_FEATURE_FRED
+#
+# And these REQUIRED and DISABLED config options are manipulated in an
+# AWK script as the following example:
+#
+# +----------------------+
+# | X86_FRED = y ? |
+# +----------------------+
+# / \
+# Y / \ N
+# +-------------------------------------+ +-------------------------------+
+# | X86_DISABLED_FEATURE_FRED undefined | | X86_DISABLED_FEATURE_FRED = y |
+# +-------------------------------------+ +-------------------------------+
+# |
+# |
+# +-------------------------------------------+ |
+# | X86_FEATURE_FRED: feature word 12, bit 17 | ---->|
+# +-------------------------------------------+ |
+# |
+# |
+# +-------------------------------+
+# | set bit 17 of DISABLED_MASK12 |
+# +-------------------------------+
+#
+
+config X86_REQUIRED_FEATURE_ALWAYS
+ def_bool y
+
+config X86_REQUIRED_FEATURE_NOPL
+ def_bool y
+ depends on X86_64 || X86_P6_NOP
+
+config X86_REQUIRED_FEATURE_CX8
+ def_bool y
+ depends on X86_CX8
+
+# this should be set for all -march=.. options where the compiler
+# generates cmov.
+config X86_REQUIRED_FEATURE_CMOV
+ def_bool y
+ depends on X86_CMOV
+
+# this should be set for all -march= options where the compiler
+# generates movbe.
+config X86_REQUIRED_FEATURE_MOVBE
+ def_bool y
+ depends on MATOM
+
+config X86_REQUIRED_FEATURE_CPUID
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_UP
+ def_bool y
+ depends on !SMP
+
+config X86_REQUIRED_FEATURE_FPU
+ def_bool y
+ depends on !MATH_EMULATION
+
+config X86_REQUIRED_FEATURE_PAE
+ def_bool y
+ depends on X86_64 || X86_PAE
+
+config X86_REQUIRED_FEATURE_PSE
+ def_bool y
+ depends on X86_64 && !PARAVIRT_XXL
+
+config X86_REQUIRED_FEATURE_PGE
+ def_bool y
+ depends on X86_64 && !PARAVIRT_XXL
+
+config X86_REQUIRED_FEATURE_MSR
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_FXSR
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_XMM
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_XMM2
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_LM
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_UMIP
+ def_bool y
+ depends on !X86_UMIP
+
+config X86_DISABLED_FEATURE_VME
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_K6_MTRR
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_CYRIX_ARR
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_CENTAUR_MCR
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_PCID
+ def_bool y
+ depends on !X86_64
+
+config X86_DISABLED_FEATURE_PKU
+ def_bool y
+ depends on !X86_INTEL_MEMORY_PROTECTION_KEYS
+
+config X86_DISABLED_FEATURE_OSPKE
+ def_bool y
+ depends on !X86_INTEL_MEMORY_PROTECTION_KEYS
+
+config X86_DISABLED_FEATURE_LA57
+ def_bool y
+ depends on !X86_5LEVEL
+
+config X86_DISABLED_FEATURE_PTI
+ def_bool y
+ depends on !MITIGATION_PAGE_TABLE_ISOLATION
+
+config X86_DISABLED_FEATURE_RETPOLINE
+ def_bool y
+ depends on !MITIGATION_RETPOLINE
+
+config X86_DISABLED_FEATURE_RETPOLINE_LFENCE
+ def_bool y
+ depends on !MITIGATION_RETPOLINE
+
+config X86_DISABLED_FEATURE_RETHUNK
+ def_bool y
+ depends on !MITIGATION_RETHUNK
+
+config X86_DISABLED_FEATURE_UNRET
+ def_bool y
+ depends on !MITIGATION_UNRET_ENTRY
+
+config X86_DISABLED_FEATURE_CALL_DEPTH
+ def_bool y
+ depends on !MITIGATION_CALL_DEPTH_TRACKING
+
+config X86_DISABLED_FEATURE_LAM
+ def_bool y
+ depends on !ADDRESS_MASKING
+
+config X86_DISABLED_FEATURE_ENQCMD
+ def_bool y
+ depends on !INTEL_IOMMU_SVM
+
+config X86_DISABLED_FEATURE_SGX
+ def_bool y
+ depends on !X86_SGX
+
+config X86_DISABLED_FEATURE_XENPV
+ def_bool y
+ depends on !XEN_PV
+
+config X86_DISABLED_FEATURE_TDX_GUEST
+ def_bool y
+ depends on !INTEL_TDX_GUEST
+
+config X86_DISABLED_FEATURE_USER_SHSTK
+ def_bool y
+ depends on !X86_USER_SHADOW_STACK
+
+config X86_DISABLED_FEATURE_IBT
+ def_bool y
+ depends on !X86_KERNEL_IBT
+
+config X86_DISABLED_FEATURE_FRED
+ def_bool y
+ depends on !X86_FRED
+
+config X86_DISABLED_FEATURE_SEV_SNP
+ def_bool y
+ depends on !KVM_AMD_SEV
+
+config X86_DISABLED_FEATURE_INVLPGB
+ def_bool y
+ depends on !BROADCAST_TLB_FLUSH
On March 10, 2025 1:18:29 AM PDT, "tip-bot2 for H. Peter Anvin (Intel)" <tip-bot2@linutronix.de> wrote:
>The following commit has been merged into the x86/cpu branch of tip:
>
>Commit-ID: dc6e8bfc0c9e27cbfed27c7ed50c71205a7c9551
>Gitweb: https://git.kernel.org/tip/dc6e8bfc0c9e27cbfed27c7ed50c71205a7c9551
>Author: H. Peter Anvin (Intel) <hpa@zytor.com>
>AuthorDate: Fri, 28 Feb 2025 00:23:35 -08:00
>Committer: Ingo Molnar <mingo@kernel.org>
>CommitterDate: Mon, 10 Mar 2025 09:02:30 +01:00
>
>x86/cpufeatures: Add {REQUIRED,DISABLED} feature configs
>
>Required and disabled feature masks completely rely on build configs,
>i.e., once a build config is fixed, so are the feature masks.
>
>To prepare for auto-generating the <asm/cpufeaturemasks.h> header
>with required and disabled feature masks based on a build config,
>add feature Kconfig items:
>
> - X86_REQUIRED_FEATURE_x
> - X86_DISABLED_FEATURE_x
>
>each of which may be set to "y" if and only if its preconditions from
>current build config are met.
>
>Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
>Signed-off-by: Xin Li (Intel) <xin@zytor.com>
>Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
>Signed-off-by: Ingo Molnar <mingo@kernel.org>
>Cc: Linus Torvalds <torvalds@linux-foundation.org>
>Link: https://lore.kernel.org/r/20250228082338.73859-3-xin@zytor.com
>---
> arch/x86/Kconfig | 2 +-
> arch/x86/Kconfig.cpufeatures | 201 ++++++++++++++++++++++++++++++++++-
> 2 files changed, 203 insertions(+)
> create mode 100644 arch/x86/Kconfig.cpufeatures
>
>diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
>index 017035f..7caf2fd 100644
>--- a/arch/x86/Kconfig
>+++ b/arch/x86/Kconfig
>@@ -3128,4 +3128,6 @@ config HAVE_ATOMIC_IOMAP
>
> source "arch/x86/kvm/Kconfig"
>
>+source "arch/x86/Kconfig.cpufeatures"
>+
> source "arch/x86/Kconfig.assembler"
>diff --git a/arch/x86/Kconfig.cpufeatures b/arch/x86/Kconfig.cpufeatures
>new file mode 100644
>index 0000000..e12d5b7
>--- /dev/null
>+++ b/arch/x86/Kconfig.cpufeatures
>@@ -0,0 +1,201 @@
>+# SPDX-License-Identifier: GPL-2.0
>+#
>+# x86 feature bits (see arch/x86/include/asm/cpufeatures.h) that are
>+# either REQUIRED to be enabled, or DISABLED (always ignored) for this
>+# particular compile-time configuration. The tests for these features
>+# are turned into compile-time constants via the generated
>+# <asm/cpufeaturemasks.h>.
>+#
>+# The naming of these variables *must* match asm/cpufeatures.h, e.g.,
>+# X86_FEATURE_ALWAYS <==> X86_REQUIRED_FEATURE_ALWAYS
>+# X86_FEATURE_FRED <==> X86_DISABLED_FEATURE_FRED
>+#
>+# And these REQUIRED and DISABLED config options are manipulated in an
>+# AWK script as the following example:
>+#
>+# +----------------------+
>+# | X86_FRED = y ? |
>+# +----------------------+
>+# / \
>+# Y / \ N
>+# +-------------------------------------+ +-------------------------------+
>+# | X86_DISABLED_FEATURE_FRED undefined | | X86_DISABLED_FEATURE_FRED = y |
>+# +-------------------------------------+ +-------------------------------+
>+# |
>+# |
>+# +-------------------------------------------+ |
>+# | X86_FEATURE_FRED: feature word 12, bit 17 | ---->|
>+# +-------------------------------------------+ |
>+# |
>+# |
>+# +-------------------------------+
>+# | set bit 17 of DISABLED_MASK12 |
>+# +-------------------------------+
>+#
>+
>+config X86_REQUIRED_FEATURE_ALWAYS
>+ def_bool y
>+
>+config X86_REQUIRED_FEATURE_NOPL
>+ def_bool y
>+ depends on X86_64 || X86_P6_NOP
>+
>+config X86_REQUIRED_FEATURE_CX8
>+ def_bool y
>+ depends on X86_CX8
>+
>+# this should be set for all -march=.. options where the compiler
>+# generates cmov.
>+config X86_REQUIRED_FEATURE_CMOV
>+ def_bool y
>+ depends on X86_CMOV
>+
>+# this should be set for all -march= options where the compiler
>+# generates movbe.
>+config X86_REQUIRED_FEATURE_MOVBE
>+ def_bool y
>+ depends on MATOM
>+
>+config X86_REQUIRED_FEATURE_CPUID
>+ def_bool y
>+ depends on X86_64
>+
>+config X86_REQUIRED_FEATURE_UP
>+ def_bool y
>+ depends on !SMP
>+
>+config X86_REQUIRED_FEATURE_FPU
>+ def_bool y
>+ depends on !MATH_EMULATION
>+
>+config X86_REQUIRED_FEATURE_PAE
>+ def_bool y
>+ depends on X86_64 || X86_PAE
>+
>+config X86_REQUIRED_FEATURE_PSE
>+ def_bool y
>+ depends on X86_64 && !PARAVIRT_XXL
>+
>+config X86_REQUIRED_FEATURE_PGE
>+ def_bool y
>+ depends on X86_64 && !PARAVIRT_XXL
>+
>+config X86_REQUIRED_FEATURE_MSR
>+ def_bool y
>+ depends on X86_64
>+
>+config X86_REQUIRED_FEATURE_FXSR
>+ def_bool y
>+ depends on X86_64
>+
>+config X86_REQUIRED_FEATURE_XMM
>+ def_bool y
>+ depends on X86_64
>+
>+config X86_REQUIRED_FEATURE_XMM2
>+ def_bool y
>+ depends on X86_64
>+
>+config X86_REQUIRED_FEATURE_LM
>+ def_bool y
>+ depends on X86_64
>+
>+config X86_DISABLED_FEATURE_UMIP
>+ def_bool y
>+ depends on !X86_UMIP
>+
>+config X86_DISABLED_FEATURE_VME
>+ def_bool y
>+ depends on X86_64
>+
>+config X86_DISABLED_FEATURE_K6_MTRR
>+ def_bool y
>+ depends on X86_64
>+
>+config X86_DISABLED_FEATURE_CYRIX_ARR
>+ def_bool y
>+ depends on X86_64
>+
>+config X86_DISABLED_FEATURE_CENTAUR_MCR
>+ def_bool y
>+ depends on X86_64
>+
>+config X86_DISABLED_FEATURE_PCID
>+ def_bool y
>+ depends on !X86_64
>+
>+config X86_DISABLED_FEATURE_PKU
>+ def_bool y
>+ depends on !X86_INTEL_MEMORY_PROTECTION_KEYS
>+
>+config X86_DISABLED_FEATURE_OSPKE
>+ def_bool y
>+ depends on !X86_INTEL_MEMORY_PROTECTION_KEYS
>+
>+config X86_DISABLED_FEATURE_LA57
>+ def_bool y
>+ depends on !X86_5LEVEL
>+
>+config X86_DISABLED_FEATURE_PTI
>+ def_bool y
>+ depends on !MITIGATION_PAGE_TABLE_ISOLATION
>+
>+config X86_DISABLED_FEATURE_RETPOLINE
>+ def_bool y
>+ depends on !MITIGATION_RETPOLINE
>+
>+config X86_DISABLED_FEATURE_RETPOLINE_LFENCE
>+ def_bool y
>+ depends on !MITIGATION_RETPOLINE
>+
>+config X86_DISABLED_FEATURE_RETHUNK
>+ def_bool y
>+ depends on !MITIGATION_RETHUNK
>+
>+config X86_DISABLED_FEATURE_UNRET
>+ def_bool y
>+ depends on !MITIGATION_UNRET_ENTRY
>+
>+config X86_DISABLED_FEATURE_CALL_DEPTH
>+ def_bool y
>+ depends on !MITIGATION_CALL_DEPTH_TRACKING
>+
>+config X86_DISABLED_FEATURE_LAM
>+ def_bool y
>+ depends on !ADDRESS_MASKING
>+
>+config X86_DISABLED_FEATURE_ENQCMD
>+ def_bool y
>+ depends on !INTEL_IOMMU_SVM
>+
>+config X86_DISABLED_FEATURE_SGX
>+ def_bool y
>+ depends on !X86_SGX
>+
>+config X86_DISABLED_FEATURE_XENPV
>+ def_bool y
>+ depends on !XEN_PV
>+
>+config X86_DISABLED_FEATURE_TDX_GUEST
>+ def_bool y
>+ depends on !INTEL_TDX_GUEST
>+
>+config X86_DISABLED_FEATURE_USER_SHSTK
>+ def_bool y
>+ depends on !X86_USER_SHADOW_STACK
>+
>+config X86_DISABLED_FEATURE_IBT
>+ def_bool y
>+ depends on !X86_KERNEL_IBT
>+
>+config X86_DISABLED_FEATURE_FRED
>+ def_bool y
>+ depends on !X86_FRED
>+
>+config X86_DISABLED_FEATURE_SEV_SNP
>+ def_bool y
>+ depends on !KVM_AMD_SEV
>+
>+config X86_DISABLED_FEATURE_INVLPGB
>+ def_bool y
>+ depends on !BROADCAST_TLB_FLUSH
I think it is worth noting that the list here was intentionally unchanged from the previous definitions, but that several of these could and probably should be overhauled.
For example, CPUID is actually required by any i586+ configuration.
* H. Peter Anvin <hpa@zytor.com> wrote: > >+config X86_DISABLED_FEATURE_FRED > >+ def_bool y > >+ depends on !X86_FRED > >+ > >+config X86_DISABLED_FEATURE_SEV_SNP > >+ def_bool y > >+ depends on !KVM_AMD_SEV > >+ > >+config X86_DISABLED_FEATURE_INVLPGB > >+ def_bool y > >+ depends on !BROADCAST_TLB_FLUSH > > I think it is worth noting that the list here was intentionally > unchanged from the previous definitions, but that several of these > could and probably should be overhauled. Yeah, note that this list was *not* unchanged since the -v1 submission, there's two new dependencies we added since -v1 which ended with the FRED entry: - X86_DISABLED_FEATURE_INVLPGB dependency we added today, which is due to a new feature freshly merged into tip:x86/mm. - X86_DISABLED_FEATURE_SEV_SNP was added a bit back - that too is a fresh sub-feature. So we are aware, but we are also limited by what we notice. :-) > For example, CPUID is actually required by any i586+ configuration. Mind sending patches for anything you can think of? This series is now headed for v6.15 via tip:x86/cpu, modulo any unexpected catastrophes in -next testing. Thanks, Ingo
On Mon, Mar 10, 2025 at 07:43:44AM -0700, H. Peter Anvin wrote:
> I think it is worth noting that the list here was intentionally unchanged
> from the previous definitions, but that several of these could and probably
> should be overhauled.
Sure, send patches.
:-P
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: cf304a054d99c4df6203508cc08055539564debb
Gitweb: https://git.kernel.org/tip/cf304a054d99c4df6203508cc08055539564debb
Author: H. Peter Anvin (Intel) <hpa@zytor.com>
AuthorDate: Fri, 28 Feb 2025 00:23:35 -08:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Fri, 28 Feb 2025 12:08:12 +01:00
x86/cpufeatures: Add {required,disabled} feature configs
Required and disabled feature masks completely rely on build configs,
i.e., once a build config is fixed, so are the feature masks. To
prepare for auto-generating a header with required and disabled feature
masks based on a build config, add feature Kconfig items:
- X86_REQUIRED_FEATURE_x
- X86_DISABLED_FEATURE_x
each of which may be set to "y" if and only if its preconditions from
current build config are met.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Xin Li (Intel) <xin@zytor.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20250228082338.73859-3-xin@zytor.com
---
arch/x86/Kconfig | 2 +-
arch/x86/Kconfig.cpufeatures | 197 ++++++++++++++++++++++++++++++++++-
2 files changed, 199 insertions(+)
create mode 100644 arch/x86/Kconfig.cpufeatures
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 017035f..7caf2fd 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -3128,4 +3128,6 @@ config HAVE_ATOMIC_IOMAP
source "arch/x86/kvm/Kconfig"
+source "arch/x86/Kconfig.cpufeatures"
+
source "arch/x86/Kconfig.assembler"
diff --git a/arch/x86/Kconfig.cpufeatures b/arch/x86/Kconfig.cpufeatures
new file mode 100644
index 0000000..5dcc49d
--- /dev/null
+++ b/arch/x86/Kconfig.cpufeatures
@@ -0,0 +1,197 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# x86 feature bits (see arch/x86/include/asm/cpufeatures.h) that are
+# either REQUIRED to be enabled, or DISABLED (always ignored) for this
+# particular compile-time configuration. The tests for these features
+# are turned into compile-time constants via the generated
+# <asm/featuremasks.h>.
+#
+# The naming of these variables *must* match asm/cpufeatures.h, e.g.,
+# X86_FEATURE_ALWAYS <==> X86_REQUIRED_FEATURE_ALWAYS
+# X86_FEATURE_FRED <==> X86_DISABLED_FEATURE_FRED
+#
+# And these REQUIRED and DISABLED config options are manipulated in an
+# AWK script as the following example:
+#
+# +----------------------+
+# | X86_FRED = y ? |
+# +----------------------+
+# / \
+# Y / \ N
+# +-------------------------------------+ +-------------------------------+
+# | X86_DISABLED_FEATURE_FRED undefined | | X86_DISABLED_FEATURE_FRED = y |
+# +-------------------------------------+ +-------------------------------+
+# |
+# |
+# +-------------------------------------------+ |
+# | X86_FEATURE_FRED: feature word 12, bit 17 | ---->|
+# +-------------------------------------------+ |
+# |
+# |
+# +-------------------------------+
+# | set bit 17 of DISABLED_MASK12 |
+# +-------------------------------+
+#
+
+config X86_REQUIRED_FEATURE_ALWAYS
+ def_bool y
+
+config X86_REQUIRED_FEATURE_NOPL
+ def_bool y
+ depends on X86_64 || X86_P6_NOP
+
+config X86_REQUIRED_FEATURE_CX8
+ def_bool y
+ depends on X86_CX8
+
+# this should be set for all -march=.. options where the compiler
+# generates cmov.
+config X86_REQUIRED_FEATURE_CMOV
+ def_bool y
+ depends on X86_CMOV
+
+# this should be set for all -march= options where the compiler
+# generates movbe.
+config X86_REQUIRED_FEATURE_MOVBE
+ def_bool y
+ depends on MATOM
+
+config X86_REQUIRED_FEATURE_CPUID
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_UP
+ def_bool y
+ depends on !SMP
+
+config X86_REQUIRED_FEATURE_FPU
+ def_bool y
+ depends on !MATH_EMULATION
+
+config X86_REQUIRED_FEATURE_PAE
+ def_bool y
+ depends on X86_64 || X86_PAE
+
+config X86_REQUIRED_FEATURE_PSE
+ def_bool y
+ depends on X86_64 && !PARAVIRT_XXL
+
+config X86_REQUIRED_FEATURE_PGE
+ def_bool y
+ depends on X86_64 && !PARAVIRT_XXL
+
+config X86_REQUIRED_FEATURE_MSR
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_FXSR
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_XMM
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_XMM2
+ def_bool y
+ depends on X86_64
+
+config X86_REQUIRED_FEATURE_LM
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_UMIP
+ def_bool y
+ depends on !X86_UMIP
+
+config X86_DISABLED_FEATURE_VME
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_K6_MTRR
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_CYRIX_ARR
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_CENTAUR_MCR
+ def_bool y
+ depends on X86_64
+
+config X86_DISABLED_FEATURE_PCID
+ def_bool y
+ depends on !X86_64
+
+config X86_DISABLED_FEATURE_PKU
+ def_bool y
+ depends on !X86_INTEL_MEMORY_PROTECTION_KEYS
+
+config X86_DISABLED_FEATURE_OSPKE
+ def_bool y
+ depends on !X86_INTEL_MEMORY_PROTECTION_KEYS
+
+config X86_DISABLED_FEATURE_LA57
+ def_bool y
+ depends on !X86_5LEVEL
+
+config X86_DISABLED_FEATURE_PTI
+ def_bool y
+ depends on !MITIGATION_PAGE_TABLE_ISOLATION
+
+config X86_DISABLED_FEATURE_RETPOLINE
+ def_bool y
+ depends on !MITIGATION_RETPOLINE
+
+config X86_DISABLED_FEATURE_RETPOLINE_LFENCE
+ def_bool y
+ depends on !MITIGATION_RETPOLINE
+
+config X86_DISABLED_FEATURE_RETHUNK
+ def_bool y
+ depends on !MITIGATION_RETHUNK
+
+config X86_DISABLED_FEATURE_UNRET
+ def_bool y
+ depends on !MITIGATION_UNRET_ENTRY
+
+config X86_DISABLED_FEATURE_CALL_DEPTH
+ def_bool y
+ depends on !MITIGATION_CALL_DEPTH_TRACKING
+
+config X86_DISABLED_FEATURE_LAM
+ def_bool y
+ depends on !ADDRESS_MASKING
+
+config X86_DISABLED_FEATURE_ENQCMD
+ def_bool y
+ depends on !INTEL_IOMMU_SVM
+
+config X86_DISABLED_FEATURE_SGX
+ def_bool y
+ depends on !X86_SGX
+
+config X86_DISABLED_FEATURE_XENPV
+ def_bool y
+ depends on !XEN_PV
+
+config X86_DISABLED_FEATURE_TDX_GUEST
+ def_bool y
+ depends on !INTEL_TDX_GUEST
+
+config X86_DISABLED_FEATURE_USER_SHSTK
+ def_bool y
+ depends on !X86_USER_SHADOW_STACK
+
+config X86_DISABLED_FEATURE_IBT
+ def_bool y
+ depends on !X86_KERNEL_IBT
+
+config X86_DISABLED_FEATURE_FRED
+ def_bool y
+ depends on !X86_FRED
+
+config X86_DISABLED_FEATURE_SEV_SNP
+ def_bool y
+ depends on !KVM_AMD_SEV
© 2016 - 2025 Red Hat, Inc.