162306a36Sopenharmony_ci#ifndef _ASM_X86_DISABLED_FEATURES_H
262306a36Sopenharmony_ci#define _ASM_X86_DISABLED_FEATURES_H
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci/* These features, although they might be available in a CPU
562306a36Sopenharmony_ci * will not be used because the compile options to support
662306a36Sopenharmony_ci * them are not present.
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * This code allows them to be checked and disabled at
962306a36Sopenharmony_ci * compile time without an explicit #ifdef.  Use
1062306a36Sopenharmony_ci * cpu_feature_enabled().
1162306a36Sopenharmony_ci */
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#ifdef CONFIG_X86_UMIP
1462306a36Sopenharmony_ci# define DISABLE_UMIP	0
1562306a36Sopenharmony_ci#else
1662306a36Sopenharmony_ci# define DISABLE_UMIP	(1<<(X86_FEATURE_UMIP & 31))
1762306a36Sopenharmony_ci#endif
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#ifdef CONFIG_X86_64
2062306a36Sopenharmony_ci# define DISABLE_VME		(1<<(X86_FEATURE_VME & 31))
2162306a36Sopenharmony_ci# define DISABLE_K6_MTRR	(1<<(X86_FEATURE_K6_MTRR & 31))
2262306a36Sopenharmony_ci# define DISABLE_CYRIX_ARR	(1<<(X86_FEATURE_CYRIX_ARR & 31))
2362306a36Sopenharmony_ci# define DISABLE_CENTAUR_MCR	(1<<(X86_FEATURE_CENTAUR_MCR & 31))
2462306a36Sopenharmony_ci# define DISABLE_PCID		0
2562306a36Sopenharmony_ci#else
2662306a36Sopenharmony_ci# define DISABLE_VME		0
2762306a36Sopenharmony_ci# define DISABLE_K6_MTRR	0
2862306a36Sopenharmony_ci# define DISABLE_CYRIX_ARR	0
2962306a36Sopenharmony_ci# define DISABLE_CENTAUR_MCR	0
3062306a36Sopenharmony_ci# define DISABLE_PCID		(1<<(X86_FEATURE_PCID & 31))
3162306a36Sopenharmony_ci#endif /* CONFIG_X86_64 */
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
3462306a36Sopenharmony_ci# define DISABLE_PKU		0
3562306a36Sopenharmony_ci# define DISABLE_OSPKE		0
3662306a36Sopenharmony_ci#else
3762306a36Sopenharmony_ci# define DISABLE_PKU		(1<<(X86_FEATURE_PKU & 31))
3862306a36Sopenharmony_ci# define DISABLE_OSPKE		(1<<(X86_FEATURE_OSPKE & 31))
3962306a36Sopenharmony_ci#endif /* CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS */
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#ifdef CONFIG_X86_5LEVEL
4262306a36Sopenharmony_ci# define DISABLE_LA57	0
4362306a36Sopenharmony_ci#else
4462306a36Sopenharmony_ci# define DISABLE_LA57	(1<<(X86_FEATURE_LA57 & 31))
4562306a36Sopenharmony_ci#endif
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci#ifdef CONFIG_PAGE_TABLE_ISOLATION
4862306a36Sopenharmony_ci# define DISABLE_PTI		0
4962306a36Sopenharmony_ci#else
5062306a36Sopenharmony_ci# define DISABLE_PTI		(1 << (X86_FEATURE_PTI & 31))
5162306a36Sopenharmony_ci#endif
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci#ifdef CONFIG_RETPOLINE
5462306a36Sopenharmony_ci# define DISABLE_RETPOLINE	0
5562306a36Sopenharmony_ci#else
5662306a36Sopenharmony_ci# define DISABLE_RETPOLINE	((1 << (X86_FEATURE_RETPOLINE & 31)) | \
5762306a36Sopenharmony_ci				 (1 << (X86_FEATURE_RETPOLINE_LFENCE & 31)))
5862306a36Sopenharmony_ci#endif
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci#ifdef CONFIG_RETHUNK
6162306a36Sopenharmony_ci# define DISABLE_RETHUNK	0
6262306a36Sopenharmony_ci#else
6362306a36Sopenharmony_ci# define DISABLE_RETHUNK	(1 << (X86_FEATURE_RETHUNK & 31))
6462306a36Sopenharmony_ci#endif
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci#ifdef CONFIG_CPU_UNRET_ENTRY
6762306a36Sopenharmony_ci# define DISABLE_UNRET		0
6862306a36Sopenharmony_ci#else
6962306a36Sopenharmony_ci# define DISABLE_UNRET		(1 << (X86_FEATURE_UNRET & 31))
7062306a36Sopenharmony_ci#endif
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci#ifdef CONFIG_CALL_DEPTH_TRACKING
7362306a36Sopenharmony_ci# define DISABLE_CALL_DEPTH_TRACKING	0
7462306a36Sopenharmony_ci#else
7562306a36Sopenharmony_ci# define DISABLE_CALL_DEPTH_TRACKING	(1 << (X86_FEATURE_CALL_DEPTH & 31))
7662306a36Sopenharmony_ci#endif
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci#ifdef CONFIG_ADDRESS_MASKING
7962306a36Sopenharmony_ci# define DISABLE_LAM		0
8062306a36Sopenharmony_ci#else
8162306a36Sopenharmony_ci# define DISABLE_LAM		(1 << (X86_FEATURE_LAM & 31))
8262306a36Sopenharmony_ci#endif
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci#ifdef CONFIG_INTEL_IOMMU_SVM
8562306a36Sopenharmony_ci# define DISABLE_ENQCMD		0
8662306a36Sopenharmony_ci#else
8762306a36Sopenharmony_ci# define DISABLE_ENQCMD		(1 << (X86_FEATURE_ENQCMD & 31))
8862306a36Sopenharmony_ci#endif
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci#ifdef CONFIG_X86_SGX
9162306a36Sopenharmony_ci# define DISABLE_SGX	0
9262306a36Sopenharmony_ci#else
9362306a36Sopenharmony_ci# define DISABLE_SGX	(1 << (X86_FEATURE_SGX & 31))
9462306a36Sopenharmony_ci#endif
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci#ifdef CONFIG_XEN_PV
9762306a36Sopenharmony_ci# define DISABLE_XENPV		0
9862306a36Sopenharmony_ci#else
9962306a36Sopenharmony_ci# define DISABLE_XENPV		(1 << (X86_FEATURE_XENPV & 31))
10062306a36Sopenharmony_ci#endif
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci#ifdef CONFIG_INTEL_TDX_GUEST
10362306a36Sopenharmony_ci# define DISABLE_TDX_GUEST	0
10462306a36Sopenharmony_ci#else
10562306a36Sopenharmony_ci# define DISABLE_TDX_GUEST	(1 << (X86_FEATURE_TDX_GUEST & 31))
10662306a36Sopenharmony_ci#endif
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci#ifdef CONFIG_X86_USER_SHADOW_STACK
10962306a36Sopenharmony_ci#define DISABLE_USER_SHSTK	0
11062306a36Sopenharmony_ci#else
11162306a36Sopenharmony_ci#define DISABLE_USER_SHSTK	(1 << (X86_FEATURE_USER_SHSTK & 31))
11262306a36Sopenharmony_ci#endif
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci#ifdef CONFIG_X86_KERNEL_IBT
11562306a36Sopenharmony_ci#define DISABLE_IBT	0
11662306a36Sopenharmony_ci#else
11762306a36Sopenharmony_ci#define DISABLE_IBT	(1 << (X86_FEATURE_IBT & 31))
11862306a36Sopenharmony_ci#endif
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci/*
12162306a36Sopenharmony_ci * Make sure to add features to the correct mask
12262306a36Sopenharmony_ci */
12362306a36Sopenharmony_ci#define DISABLED_MASK0	(DISABLE_VME)
12462306a36Sopenharmony_ci#define DISABLED_MASK1	0
12562306a36Sopenharmony_ci#define DISABLED_MASK2	0
12662306a36Sopenharmony_ci#define DISABLED_MASK3	(DISABLE_CYRIX_ARR|DISABLE_CENTAUR_MCR|DISABLE_K6_MTRR)
12762306a36Sopenharmony_ci#define DISABLED_MASK4	(DISABLE_PCID)
12862306a36Sopenharmony_ci#define DISABLED_MASK5	0
12962306a36Sopenharmony_ci#define DISABLED_MASK6	0
13062306a36Sopenharmony_ci#define DISABLED_MASK7	(DISABLE_PTI)
13162306a36Sopenharmony_ci#define DISABLED_MASK8	(DISABLE_XENPV|DISABLE_TDX_GUEST)
13262306a36Sopenharmony_ci#define DISABLED_MASK9	(DISABLE_SGX)
13362306a36Sopenharmony_ci#define DISABLED_MASK10	0
13462306a36Sopenharmony_ci#define DISABLED_MASK11	(DISABLE_RETPOLINE|DISABLE_RETHUNK|DISABLE_UNRET| \
13562306a36Sopenharmony_ci			 DISABLE_CALL_DEPTH_TRACKING|DISABLE_USER_SHSTK)
13662306a36Sopenharmony_ci#define DISABLED_MASK12	(DISABLE_LAM)
13762306a36Sopenharmony_ci#define DISABLED_MASK13	0
13862306a36Sopenharmony_ci#define DISABLED_MASK14	0
13962306a36Sopenharmony_ci#define DISABLED_MASK15	0
14062306a36Sopenharmony_ci#define DISABLED_MASK16	(DISABLE_PKU|DISABLE_OSPKE|DISABLE_LA57|DISABLE_UMIP| \
14162306a36Sopenharmony_ci			 DISABLE_ENQCMD)
14262306a36Sopenharmony_ci#define DISABLED_MASK17	0
14362306a36Sopenharmony_ci#define DISABLED_MASK18	(DISABLE_IBT)
14462306a36Sopenharmony_ci#define DISABLED_MASK19	0
14562306a36Sopenharmony_ci#define DISABLED_MASK20	0
14662306a36Sopenharmony_ci#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21)
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci#endif /* _ASM_X86_DISABLED_FEATURES_H */
149