Re: [PATCH v2 1/5] x86/topology: Export helper to get CPU number from APIC ID

From: Yazen Ghannam
Date: Fri Jul 12 2024 - 10:28:41 EST


On Mon, Jul 01, 2024 at 09:07:04PM +0200, Borislav Petkov wrote:
> On Mon, Jul 01, 2024 at 01:51:42PM -0400, Yazen Ghannam wrote:
> > X86_LOCAL_APIC depends on the logical OR of a bunch of options. So it
> > depends on "any one" of the options to be enabled. But it doesn't need
> > all of them.
>
> Yes, I can see that.
>
> How does any of that info answer your initial question?
>
> IOW, if you don't have LAPIC support in the kernel, what CPU number should we
> return for any APIC ID serving as input, and why?
>

I still think it should return an error code, because theoretically
LAPIC can be disabled and SMP can be enabled.

But I spent some time trying to see if this would work in practice, and
it looks like you can't disable X86_LOCAL_APIC without hitting a bunch
of build errors on x86_64. It seems like a lot of common APIC and SMP
code implicitly depends on X86_LOCAL_APIC. This was true even for a tiny
config. However, this worked for an i386 build (with SMP=n).

I think the most practical option is to keep the local search routine in
mce/apei. I don't think all the additional complexity is worth it for a
simple for-loop.

Regarding the X86_LOCAL_APIC=n build issues, should these be
investigated?

Thanks,
Yazen