---
 i386/i386/mp_desc.c     | 6 ++++++
 i386/i386at/model_dep.c | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c
index fff31822..6e13390b 100644
--- a/i386/i386/mp_desc.c
+++ b/i386/i386/mp_desc.c
@@ -284,8 +284,14 @@ start_other_cpus(void)
          return;
 
        //Copy cpu initialization assembly routine
+#ifdef __x86_64__
+       memcpy((void*) phystokv(apboot_addr), (void*) phystokv(&apboot),
+              (uintptr_t)&apbootend - (uintptr_t)&apboot);
+#endif
+#ifdef __i386__
        memcpy((void*) phystokv(apboot_addr), (void*) &apboot,
               (uintptr_t)&apbootend - (uintptr_t)&apboot);
+#endif
 
        unsigned cpu = cpu_number_slow();
 
diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c
index fb3c93d4..7af08550 100644
--- a/i386/i386at/model_dep.c
+++ b/i386/i386at/model_dep.c
@@ -222,9 +222,16 @@ void machine_init(void)
         * Patch the realmode gdt with the correct offset and the first jmp to
         * protected mode with the correct target.
         */
+#ifdef __i386__
        gdt_descr_tmp.linear_base += (uint32_t)apboot_addr;
        apboot_jmp_offset += (uint32_t)apboot_addr;
 #endif
+#ifdef __x86_64__
+       uintptr_t gdtptr = (uintptr_t)phystokv(&gdt_descr_tmp) + 2;
+       *(uint32_t *)gdtptr += (uint32_t)apboot_addr;
+       *(uint32_t *)phystokv(&apboot_jmp_offset) += (uint32_t)apboot_addr;
+#endif
+#endif
 
 #ifdef APIC
        /*
-- 
2.45.2



Reply via email to