From bd3113be0b435143e4bbc7b4acef0c5dbb3cf644 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Fri, 4 Aug 2017 10:07:07 +0200 Subject: [PATCH] initialize APIC after the intialization of IDT & GDT - fix problems with Qemu --- arch/x86/kernel/apic.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c index 1192490b8..f75d7fff7 100644 --- a/arch/x86/kernel/apic.c +++ b/arch/x86/kernel/apic.c @@ -905,12 +905,7 @@ extern int set_idle_task(void); #if MAX_CORES > 1 int smp_start(void) { - x2apic_enable(); - - // reset APIC and set id - lapic_reset(); - - LOG_DEBUG("Processor %d (local id %d) is entering its idle task\n", apic_cpu_id(), atomic_int32_read(¤t_boot_id)); + LOG_DEBUG("Try to initialize processor (local id %d)\n", atomic_int32_read(¤t_boot_id)); // use the same gdt like the boot processors gdt_flush(); @@ -921,6 +916,12 @@ int smp_start(void) // enable additional cpu features cpu_detection(); + x2apic_enable(); + + // reset APIC + lapic_reset(); + + LOG_DEBUG("Processor %d (local id %d) is entering its idle task\n", apic_cpu_id(), atomic_int32_read(¤t_boot_id)); LOG_DEBUG("CR0 of core %u: 0x%x\n", atomic_int32_read(¤t_boot_id), read_cr0()); online[atomic_int32_read(¤t_boot_id)] = 1;