WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: About enabling x2apic in Intel x86_64 architecture  (Read 192 times)

Offline petrol33

  • Newbie
  • *
  • Posts: 1
About enabling x2apic in Intel x86_64 architecture
« on: August 13, 2024, 07:44:39 AM »
Hello Admin,
Let me ask you one question about supporting x2apic in x86_64 architecture.
Condition)
- Kernel file name : linux-6.6.8-patched.txz, or linux-5.15.10-patched.txz

Question)
From the file, ./arch/x86/kernel/x86_init.c, please see the following red color function.

bool __init bool_x86_init_noop(void) { return false; }

        .hyper = {
                .init_platform          = x86_init_noop,
                .guest_late_init        = x86_init_noop,
                .x2apic_available       = bool_x86_init_noop,
                .msi_ext_dest_id        = bool_x86_init_noop,
                .init_mem_mapping       = x86_init_noop,
                .init_after_bootmem     = x86_init_noop,
        },

And also, please see the following function,try_to_enable_x2apic() from the file, ./arch/x86/kernel/apic/apic.c".

static __init void try_to_enable_x2apic(int remap_mode)
{
        if (x2apic_state == X2APIC_DISABLED)
                return;

        if (remap_mode != IRQ_REMAP_X2APIC_MODE) {
                u32 apic_limit = 255;

                /*
                 * Using X2APIC without IR is not architecturally supported
                 * on bare metal but may be supported in guests.
                 */
                if (!x86_init.hyper.x2apic_available()) {
                        pr_info("x2apic: IRQ remapping doesn't support X2APIC mode\n");
                        x2apic_disable();
                        return;
                }

                /*
                 * If the hypervisor supports extended destination ID in
                 * MSI, that increases the maximum APIC ID that can be
                 * used for non-remapped IRQ domains.
                 */
                if (x86_init.hyper.msi_ext_dest_id()) {
                        virt_ext_dest_id = 1;
                        apic_limit = 32767;
                }

                /*
                 * Without IR, all CPUs can be addressed by IOAPIC/MSI only
                 * in physical mode, and CPUs with an APIC ID that cannot
                 * be addressed must not be brought online.
                 */
                x2apic_set_max_apicid(apic_limit);
                x2apic_phys = 1;
        }
        x2apic_enable();
}

And please check the above red color part, if (!x86_init.hyper.x2apic_available()) {.
It's always returned with "false" value from the function, bool_x86_init_noop().
So, the version, linux-5.15.10(or 6.6.8), cannot support x2apic in x86_64 architecture.

Do you have any idea?

Thanks a lot.
Petro / Korea