Re: [PATCH 1/1] x86/CPU/AMD: Avoid racy updates to MSR_K7_HWCR in set_cpuid_faulting()

From: Borislav Petkov

Date: Tue Jun 09 2026 - 17:41:54 EST


On Tue, Jun 09, 2026 at 02:15:47PM -0700, Jim Mattson wrote:
> + unsigned long flags;
> +
> + local_irq_save(flags);
> if (on)
> msr_set_bit(MSR_K7_HWCR, MSR_K7_HWCR_CPUID_USER_DIS_BIT);
> else
> msr_clear_bit(MSR_K7_HWCR, MSR_K7_HWCR_CPUID_USER_DIS_BIT);
> + local_irq_restore(flags);
> }

Can we carve out this logic that modifies bits in HWCR into a separate
function and call it from everywhere it needs so that it is very obvious that
synchronization needs to happen?

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette