---
 i386/i386/mp_desc.c     | 8 ++++++++
 i386/i386at/model_dep.c | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c
index b481ef64..1343861c 100644
--- a/i386/i386/mp_desc.c
+++ b/i386/i386/mp_desc.c
@@ -284,8 +284,16 @@ start_other_cpus(void)
          return;
 
        //Copy cpu initialization assembly routine
+#ifdef __i386__
        memcpy((void*) phystokv(apboot_addr), (void*) &apboot,
               (uintptr_t)&apbootend - (uintptr_t)&apboot);
+#endif
+#ifdef __x86_64__
+       /* apboot is located in section .boot.text which is at a 32 bit offset.
+        * To access it here, we need to add KERNEL_MAP_BASE. */
+       memcpy((void*) phystokv(apboot_addr), (void*) phystokv(&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 e713cc8a..1c70acc2 100644
--- a/i386/i386at/model_dep.c
+++ b/i386/i386at/model_dep.c
@@ -222,9 +222,17 @@ 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 += apboot_addr;
        apboot_jmp_offset += apboot_addr;
 #endif
+#ifdef __x86_64__
+       /* Section .boot.text is located at a 32 bit offset.
+        * To access it here, we need to add KERNEL_MAP_BASE to pointers. */
+       *(uint32_t *)phystokv(&gdt_descr_tmp.linear_base) += apboot_addr;
+       *(uint32_t *)phystokv(&apboot_jmp_offset) += apboot_addr;
+#endif
+#endif
 
 #ifdef APIC
        /*
-- 
2.51.0



Reply via email to