Re: [PATCH v2 1/2] x86/cpu: Disable CR pinning during CPU bringup
From: Sohil Mehta
Date: Fri Mar 13 2026 - 14:08:24 EST
On 3/13/2026 1:35 AM, Nikunj A. Dadhania wrote:
> @@ -2413,6 +2407,16 @@ void cpu_init_exception_handling(bool boot_cpu)
> /* GHCB needs to be setup to handle #VC. */
> setup_ghcb();
>
> + /*
> + * CPUs that support FSGSBASE may use RDGSBASE/WRGSBASE in
> + * paranoid_entry(). Enable the feature before any exceptions
> + * occur.
> + */
> + if (cpu_feature_enabled(X86_FEATURE_FSGSBASE)) {
> + cr4_set_bits(X86_CR4_FSGSBASE);
> + elf_hwcap2 |= HWCAP2_FSGSBASE;
> + }
> +
There is already a lot happening in this function. If we end up going
this route, I would suggest moving this to a small wrapper function such
as setup_fsgsbase() or enable_fsgsbase().
cpu_init_exception_handling() doesn't seem to be in a hot-path and
cpu_feature_enabled(X86_FEATURE_FSGSBASE) is generally expected to be
true on modern CPUs.
> if (cpu_feature_enabled(X86_FEATURE_FRED)) {
> /* The boot CPU has enabled FRED during early boot */
> if (!boot_cpu)
>
> Regards,
> Nikunj
>
>