Re: [PATCH v4 1/1] x86/cpufeatures: Implement Predictive Store Forwarding control.
From: Reiji Watanabe
Date: Fri Apr 30 2021 - 15:43:08 EST
> +static int __init psf_cmdline(char *str)
> +{
> + u64 tmp = 0;
> +
> + if (!boot_cpu_has(X86_FEATURE_PSFD))
> + return 0;
> +
> + if (!str)
> + return -EINVAL;
> +
> + if (!strcmp(str, "off")) {
> + set_cpu_cap(&boot_cpu_data, X86_FEATURE_MSR_SPEC_CTRL);
> + rdmsrl(MSR_IA32_SPEC_CTRL, tmp);
> + tmp |= SPEC_CTRL_PSFD;
> + x86_spec_ctrl_base |= tmp;
> + wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base);
> + }
> +
> + return 0;
> +}
Shouldn't X86_FEATURE_MSR_SPEC_CTRL always be set if the CPU has
X86_FEATURE_PSFD even if the new kernel parameter is not used ?
(e.g. set X86_FEATURE_MSR_SPEC_CTRL in init_speculation_control()
and have psf_cmdline() do the rest)
Considering KVM/virtualization for a CPU that has X86_FEATURE_PSFD
but no other existing feature with MSR_IA32_SPEC_CTRL, if a host
doesn't enable PSFD with the new parameter, the host doesn't have
X86_FEATURE_MSR_SPEC_CTRL. Then, it would be a problem if its
guests want to use PSFD looking at x86_virt_spec_ctrl().
(I'm not sure how you will change your previous KVM patch though)
Thanks,
Reiji