:: commit 87a88bf565b9c51c00e3b756a55eda9469f32d61

mintsuki <mintsuki@protonmail.com> — 2023-09-23 18:27

parents: 3fde8f0158

smp: Remove dead 32-bit trampoline code

diff --git a/common/protos/limine.c b/common/protos/limine.c
index 37e93ba0..a7798e30 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -951,7 +951,7 @@ FEAT_START
 #if defined (__x86_64__) || defined (__i386__)
     uint32_t bsp_lapic_id;
     smp_info = init_smp(&cpu_count, &bsp_lapic_id,
-                        true, paging_mode,
+                        paging_mode,
                         pagemap, smp_request->flags & LIMINE_SMP_X2APIC, nx_available,
                         direct_map_offset, true);
 #elif defined (__aarch64__)
diff --git a/common/sys/smp.c b/common/sys/smp.c
index d01b94e0..e81a46cc 100644
--- a/common/sys/smp.c
+++ b/common/sys/smp.c
@@ -33,7 +33,7 @@ struct trampoline_passed_info {
 
 static bool smp_start_ap(uint32_t lapic_id, struct gdtr *gdtr,
                          struct limine_smp_info *info_struct,
-                         bool longmode, int paging_mode, uint32_t pagemap,
+                         int paging_mode, uint32_t pagemap,
                          bool x2apic, bool nx, uint64_t hhdm, bool wp) {
     // Prepare the trampoline
     static void *trampoline = NULL;
@@ -53,10 +53,9 @@ static bool smp_start_ap(uint32_t lapic_id, struct gdtr *gdtr,
     passed_info->smp_tpl_booted_flag = 0;
     passed_info->smp_tpl_pagemap     = pagemap;
     passed_info->smp_tpl_target_mode = ((uint32_t)x2apic << 2)
-                                     | ((uint32_t)paging_mode << 1)
+                                     | ((uint32_t)(paging_mode == PAGING_MODE_X86_64_5LVL) << 1)
                                      | ((uint32_t)nx << 3)
-                                     | ((uint32_t)wp << 4)
-                                     | ((uint32_t)longmode << 0);
+                                     | ((uint32_t)wp << 4);
     passed_info->smp_tpl_gdt = *gdtr;
     passed_info->smp_tpl_hhdm = hhdm;
 
@@ -92,7 +91,6 @@ static bool smp_start_ap(uint32_t lapic_id, struct gdtr *gdtr,
 
 struct limine_smp_info *init_smp(size_t   *cpu_count,
                                  uint32_t *_bsp_lapic_id,
-                                 bool      longmode,
                                  int       paging_mode,
                                  pagemap_t pagemap,
                                  bool      x2apic,
@@ -200,7 +198,7 @@ struct limine_smp_info *init_smp(size_t   *cpu_count,
 
                 // Try to start the AP
                 if (!smp_start_ap(lapic->lapic_id, &gdtr, info_struct,
-                                  longmode, paging_mode, (uintptr_t)pagemap.top_level,
+                                  paging_mode, (uintptr_t)pagemap.top_level,
                                   x2apic, nx, hhdm, wp)) {
                     print("smp: FAILED to bring-up AP\n");
                     continue;
@@ -237,7 +235,7 @@ struct limine_smp_info *init_smp(size_t   *cpu_count,
 
                 // Try to start the AP
                 if (!smp_start_ap(x2lapic->x2apic_id, &gdtr, info_struct,
-                                  longmode, paging_mode, (uintptr_t)pagemap.top_level,
+                                  paging_mode, (uintptr_t)pagemap.top_level,
                                   true, nx, hhdm, wp)) {
                     print("smp: FAILED to bring-up AP\n");
                     continue;
diff --git a/common/sys/smp.h b/common/sys/smp.h
index c2f706d1..77a64235 100644
--- a/common/sys/smp.h
+++ b/common/sys/smp.h
@@ -12,7 +12,6 @@
 
 struct limine_smp_info *init_smp(size_t   *cpu_count,
                                  uint32_t *_bsp_lapic_id,
-                                 bool      longmode,
                                  int       paging_mode,
                                  pagemap_t pagemap,
                                  bool      x2apic,
diff --git a/common/sys/smp_trampoline.asm_x86 b/common/sys/smp_trampoline.asm_x86
index 59f581b0..688b333d 100644
--- a/common/sys/smp_trampoline.asm_x86
+++ b/common/sys/smp_trampoline.asm_x86
@@ -56,9 +56,6 @@ smp_trampoline_start:
   .nox2apic:
     lea esp, [ebx + (temp_stack.top - smp_trampoline_start)]
 
-    test dword [ebx + (passed_info.target_mode - smp_trampoline_start)], (1 << 0)
-    jz parking32
-
     mov eax, cr4
     bts eax, 5
     mov cr4, eax
@@ -123,34 +120,6 @@ smp_trampoline_start:
 
     jmp rax
 
-bits 32
-parking32:
-    mov edi, dword [ebx + (passed_info.smp_info_struct - smp_trampoline_start)]
-    mov eax, 1
-    lock xchg dword [ebx + (passed_info.booted_flag - smp_trampoline_start)], eax
-
-    xor eax, eax
-  .loop:
-    lock xadd dword [edi + 16], eax
-    test eax, eax
-    jnz .out
-    pause
-    jmp .loop
-
-  .out:
-    mov esp, dword [edi + 8]
-    push 0
-    push edi
-    push eax
-    xor eax, eax
-    xor ebx, ebx
-    xor ecx, ecx
-    xor edx, edx
-    xor esi, esi
-    xor edi, edi
-    xor ebp, ebp
-    ret
-
 bits 64
 parking64:
     mov ebx, ebx
tab: 248 wrap: offon