Re: [PATCH v4 07/17] x86/split_lock: Enumerate #AC for split lock by MSR IA32_CORE_CAPABILITY

Dave Hansen
2019-03-04T18:58:01Z

> * Clear/Set all flags overridden by options, after probe.
> diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c
> index 2c0bd38a44ab..5ba11ce99f92 100644
> --- a/arch/x86/kernel/cpu/cpuid-deps.c
> +++ b/arch/x86/kernel/cpu/cpuid-deps.c
> @@ -59,6 +59,7 @@ static const struct cpuid_dep cpuid_deps[] = {
> { X86_FEATURE_AVX512_4VNNIW, X86_FEATURE_AVX512F },
> { X86_FEATURE_AVX512_4FMAPS, X86_FEATURE_AVX512F },
> { X86_FEATURE_AVX512_VPOPCNTDQ, X86_FEATURE_AVX512F },
> + { X86_FEATURE_SPLIT_LOCK_DETECT, X86_FEATURE_CORE_CAPABILITY},
> {}
> };

Please reindent the rest of the structure whenever you break the record
for name length.

> diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
> index fc3c07fe7df5..0c44c49f6005 100644
> --- a/arch/x86/kernel/cpu/intel.c
> +++ b/arch/x86/kernel/cpu/intel.c
> @@ -1029,3 +1029,24 @@ static const struct cpu_dev intel_cpu_dev = {
>
> cpu_dev_register(intel_cpu_dev);
>
> +/**
> + * init_core_capability - enumerate features supported in IA32_CORE_CAPABILITY
> + * @c: pointer to cpuinfo_x86
> + *
> + * Return: void
> + */
> +void init_core_capability(struct cpuinfo_x86 *c)
> +{
> + /*
> + * If MSR_IA32_CORE_CAPABILITY exists, enumerate features that are
> + * reported in the MSR.
> + */
> + if (c == &boot_cpu_data && cpu_has(c, X86_FEATURE_CORE_CAPABILITY)) {

First of all, please endeavor to leave the main flow of the function at
the first indent.

*If* you were to do this, it would look like:

if (c != &boot_cpu_data)
return;
if (!cpu_has(c, X86_FEATURE_CORE_CAPABILITY))
return;

rdmsrl(...);

But, it goes unmentioned why you do the boot-cpu-only restriction here.
It doesn't match the behavior of the two functions called before
init_core_capability():

init_scattered_cpuid_features(c);
init_speculation_control(c);

So why is this new function special?

> + u64 val;
> +
> + rdmsrl(MSR_IA32_CORE_CAPABILITY, val);
> +
> + if (val & CORE_CAP_SPLIT_LOCK_DETECT)
> + setup_force_cpu_cap(X86_FEATURE_SPLIT_LOCK_DETECT);
> + }
> +}
>