summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/cpu
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-11-17 21:15:55 -0500
committerIan Moffett <ian@osmora.org>2025-11-17 21:15:55 -0500
commita9d1f332d91a801ff04e2b9f2475d733b2898134 (patch)
tree9e9d7269831db7e15f5a3e00ddad53208e7fd9e8 /sys/arch/amd64/cpu
parent36c81aeaef9c633f80374f9107d3c0116b0cafdb (diff)
kern/amd64: mp: Make AP bring up more stable
- Move BUDA to 0x9000 - Move the BUA to 0x8000 - Serialize bring up with is_booted flag - Map whole 2 megs of lower address space Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch/amd64/cpu')
-rw-r--r--sys/arch/amd64/cpu/mp.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/arch/amd64/cpu/mp.c b/sys/arch/amd64/cpu/mp.c
index 247313a..5c45788 100644
--- a/sys/arch/amd64/cpu/mp.c
+++ b/sys/arch/amd64/cpu/mp.c
@@ -49,11 +49,11 @@
* within a page and be no larger and no smaller.
*/
#define AP_BUA_LEN 0x1000 /* Bring up area length in bytes */
-#define AP_BUA_PADDR 0x1000 /* Bring up area [physical] */
+#define AP_BUA_PADDR 0x8000 /* Bring up area [physical] */
#define AP_BUA_VADDR PHYS_TO_VIRT(AP_BUA_PADDR) /* Bring up area [virtual] */
/* Bring up descriptor area */
-#define AP_BUDA_PADDR 0x3000
+#define AP_BUDA_PADDR 0x9000
#define AP_BUDA_VADDR PHYS_TO_VIRT(AP_BUDA_PADDR)
/*
@@ -74,6 +74,7 @@ struct __packed ap_buda {
uint64_t cr3; /* 0x00 */
uint64_t rsp; /* 0x08 */
uint64_t lm_entry; /* 0x10 */
+ uint64_t is_booted; /* 0x18 */
};
/*
@@ -150,7 +151,7 @@ cpu_init_bootspace(struct ap_bootspace *bs)
new_pml4[0] = bs->pml3 | 3; /* P+RW */
pml3[0] = bs->pml2 | 3; /* P+RW */
pml2[0] = bs->pml1 | 3; /* P+RW */
- for (uint8_t i = 0; i < 4; ++i) {
+ for (uint16_t i = 0; i < 256; ++i) {
pml1[i] = (0x1000 * i) | 3; /* P+RW */
}
return 0;
@@ -244,7 +245,10 @@ cpu_lapic_cb(struct apic_header *h, size_t arg)
hpet_msleep(2);
}
- dtrace("bootstrapping lapic %d\n", lapic->apic_id);
+ /* Wait until AP is booted */
+ while (!buda->is_booted);
+ buda->is_booted = 0;
+
return -1; /* Keep going */
}