[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a7be319d-381f-469d-9d5b-ddcf43d884e4@intel.com>
Date: Fri, 6 Feb 2026 11:19:35 -0800
From: Dave Hansen <dave.hansen@...el.com>
To: "Xin Li (Intel)" <xin@...or.com>, linux-kernel@...r.kernel.org
Cc: tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
peterz@...radead.org, andrew.cooper3@...rix.com, sohil.mehta@...el.com,
nikunj@....com, thomas.lendacky@....com, seanjc@...gle.com,
stable@...r.kernel.org
Subject: Re: [PATCH v1] x86/smp: Set up exception handling before cr4_init()
> + /*
> + * AP startup assembly code has setup the following before calling
> + * start_secondary() on 64-bit:
> + *
> + * 1) CS set to __KERNEL_CS.
> + * 2) CR3 switched to the init_top_pgt.
> + * 3) CR4.PAE, CR4.PSE and CR4.PGE are set.
> + * 4) GDT set to per-CPU gdt_page.
> + * 5) ALL data segments set to the NULL descriptor.
> + * 6) MSR_GS_BASE set to per-CPU offset.
> + * 7) IDT set to bringup IDT.
> + * 8) CR0 set to CR0_STATE.
> + *
> + * So it's ready to setup exception handling.
> + */
> cpu_init_exception_handling(false);
This is fine because very little of that ^ is ever going to change. It's
not great that it duplicates the assembly logic, but it's good
documentation I guess.
> + /*
> + * Ensure bits set in cr4_pinned_bits are set in CR4.
> + *
> + * cr4_pinned_bits is a subset of cr4_pinned_mask, which includes
> + * the following bits:
> + * X86_CR4_SMEP
> + * X86_CR4_SMAP
> + * X86_CR4_UMIP
> + * X86_CR4_FSGSBASE
> + * X86_CR4_CET
> + * X86_CR4_FRED
> + */
> + cr4_init();
I'm not as big of a fan of this comment. The next pinned bit that gets
added will make this stale. Could we try to make this more timeless, please?
I'm also not sure I like the asymmetry of this between the boot and
secondary CPUs. On a boot CPU, CR4.SMEP will get set via
identify_boot_cpu() and eventually setup_smep(). On a secondary CPU,
it'll get set in cr4_init() and *not* in setup_smep().
This asymmetry is (I think) part of what the root of the problem is here
and how this bug came to be.
I really think the current pinning behavior is too invasive. It has zero
benefit to be pinning CR bits this early in bringup. It's only causing pain.
I _really_ think we need a defined per-cpu point where pinning comes
into effect. Marking the CPU online is one idea.
Thoughts?
Powered by blists - more mailing lists