Re: [PATCH] x86/cpufeature: Document cpu_feature_enabled() as the default to use
From: Sohil Mehta
Date: Thu Oct 31 2024 - 14:26:53 EST
On 10/31/2024 3:34 AM, Borislav Petkov wrote:
> From: "Borislav Petkov (AMD)" <bp@xxxxxxxxx>
>
> 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 <sohil.mehta@xxxxxxxxx>
> Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
> ---
> arch/x86/include/asm/cpufeature.h | 18 ++++++------------
> 1 file changed, 6 insertions(+), 12 deletions(-)
>
Looks good (a minor nit below),
Reviewed-by: Sohil Mehta <sohil.mehta@xxxxxxxxx>
> diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
> index 0b9611da6c53..de1ad09fe8d7 100644
> --- a/arch/x86/include/asm/cpufeature.h
> +++ b/arch/x86/include/asm/cpufeature.h
> @@ -132,11 +132,12 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
> x86_this_cpu_test_bit(bit, cpu_info.x86_capability))
>
> /*
> - * This macro is for detection of features which need kernel
> - * infrastructure to be used. It may *not* directly test the CPU
> - * itself. Use the cpu_has() family if you want true runtime
> - * testing of CPU features, like in hypervisor code where you are
> - * supporting a possible guest feature where host support for it
> + * This is the default CPU features testing macro to use in code.
> + *
Does "default CPU feature testing macro" roll better than "default CPU
features testing macro"?
> + * It is for detection of features which need kernel infrastructure to be
> + * used. It may *not* directly test the CPU itself. Use the cpu_has() family
> + * if you want true runtime testing of CPU features, like in hypervisor code
> + * where you are supporting a possible guest feature where host support for it
> * is not relevant.
> */