Re: [PATCH] x86/apic: Switch to x2apic driver early if x2apic is enabled

From: Grzegorz Jaszczyk

Date: Thu Sep 24 2026 - 07:13:47 EST


On Wed, Sep 16, 2026 at 11:20 PM Thomas Gleixner <tglx@xxxxxxxxxx> wrote:
>
> On Fri, Sep 11 2026 at 17:17, Grzegorz Jaszczyk wrote:
> > On Fri, Sep 11, 2026 at 2:51 PM Thomas Gleixner <tglx@xxxxxxxxxx> wrote:
> >>
> >> On Thu, Sep 10 2026 at 09:04, Grzegorz Jaszczyk wrote:
> >> > To prevent this, check if x2apic is enabled in hardware during early APIC
> >> > call setup in apic_setup_apic_calls() and switch the default APIC driver
> >> > from apic_physflat to apic_x2apic_phys immediately. This ensures that any
> >> > early EOI writes use safe MSR-based accesses. The driver can still be
> >> > upgraded later during the normal APIC probe phase.
> >>
> >> That's really the wrong place. Initializing those calls has absolutely
> >> nothing to do with the driver probing.
> >>
> >> There is quite some historical ballast in this whole APIC driver
> >> probing, which I never came around to clean up.
> >>
> >> I'll have a look how this can be done sanely without replicating half of
> >> the existing code just to paper over the real issue.
> >>
> > Ok, understood. Thank you. Let me know when you have something to look
> > at or test.
>
> It actually needs a larger overhaul because when the x2apic_phys driver
> is installed early on then its probe function will prevent installing
> the cluster driver.
>
> So your claim that any other driver can still be selected is only true
> when ACPI invokes the MADT check function, but not via the probe
> mechanism.
>
> I'm not really happy about the untested below, but something like that
> should solve your problem and still keep all options open. That patch
> needs to be split up in more digestable pieces.
>
> FYI, I'm on vacation and only sporadically at the keyboard. So if you
> get it working feel free to polish it up and submit the whole pile with
> a "Suggested-by: tglx..." tag. It definitely needs some eyeballs and
> testing time in tip.

Thank you. I've just sent v2:
https://lore.kernel.org/all/20260924104102.3534474-1-jaszczyk@xxxxxxxxxxxx/
based on the above with some modifications described in the cover
letter.

Thank you,
Grzegorz

Grzegorz