---
i386/i386/mp_desc.c | 8 ++++++++
i386/i386at/model_dep.c | 11 ++++++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c
index fff31822..6e250be6 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..8268e721 100644
--- a/i386/i386at/model_dep.c
+++ b/i386/i386at/model_dep.c
@@ -131,7 +131,7 @@ extern char version[];
extern struct pseudo_descriptor gdt_descr_tmp;
/* Realmode relocated jmp */
-extern uint32_t apboot_jmp_offset;
+extern uintptr_t apboot_jmp_offset;
/* If set, reboot the system on ctrl-alt-delete. */
boolean_t rebootflag = FALSE; /* exported to kdintr */
@@ -222,9 +222,18 @@ 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. */
+ uintptr_t gdtptr = (uintptr_t)phystokv(&gdt_descr_tmp) + 2;
+ *(uint32_t *)gdtptr += apboot_addr;
+ *(uint32_t *)phystokv(&apboot_jmp_offset) += apboot_addr;
+#endif
+#endif
#ifdef APIC
/*
--
2.51.0