Skip to content

Commit 4bf6104

Browse files
committed
x86/cpufeature: Document cpu_feature_enabled() as the default to use
cpu_feature_enabled() should be used in most cases when CPU feature support needs to be tested in code. Document that. Reported-by: Sohil Mehta <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Sohil Mehta <[email protected]> Acked-by: Dave Hansen <[email protected]> Link: https://lore.kernel.org/r/20241031103401.GBZyNdGQ-ZyXKyzC_z@fat_crate.local
1 parent 29188c1 commit 4bf6104

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

arch/x86/include/asm/cpufeature.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,12 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
132132
x86_this_cpu_test_bit(bit, cpu_info.x86_capability))
133133

134134
/*
135-
* This macro is for detection of features which need kernel
136-
* infrastructure to be used. It may *not* directly test the CPU
137-
* itself. Use the cpu_has() family if you want true runtime
138-
* testing of CPU features, like in hypervisor code where you are
139-
* supporting a possible guest feature where host support for it
135+
* This is the default CPU features testing macro to use in code.
136+
*
137+
* It is for detection of features which need kernel infrastructure to be
138+
* used. It may *not* directly test the CPU itself. Use the cpu_has() family
139+
* if you want true runtime testing of CPU features, like in hypervisor code
140+
* where you are supporting a possible guest feature where host support for it
140141
* is not relevant.
141142
*/
142143
#define cpu_feature_enabled(bit) \
@@ -161,13 +162,6 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit);
161162
#define setup_force_cpu_bug(bit) setup_force_cpu_cap(bit)
162163

163164
/*
164-
* Static testing of CPU features. Used the same as boot_cpu_has(). It
165-
* statically patches the target code for additional performance. Use
166-
* static_cpu_has() only in fast paths, where every cycle counts. Which
167-
* means that the boot_cpu_has() variant is already fast enough for the
168-
* majority of cases and you should stick to using it as it is generally
169-
* only two instructions: a RIP-relative MOV and a TEST.
170-
*
171165
* Do not use an "m" constraint for [cap_byte] here: gcc doesn't know
172166
* that this is only used on a fallback path and will sometimes cause
173167
* it to manifest the address of boot_cpu_data in a register, fouling

0 commit comments

Comments
 (0)