mirror of
https://github.com/memtest86plus/memtest86plus.git
synced 2025-02-25 18:55:23 -06:00
Extend the use of the startup mutex to cover the entire startup code.
There is more in the startup code that isn't thread safe than just the use of the temporary stack. So take the mutex for the whole time. The code isn't that long, so it's not worth trying to cover just the critical sections.
This commit is contained in:
@@ -76,13 +76,15 @@ first_start:
|
||||
|
||||
.globl startup
|
||||
startup:
|
||||
# Use the startup stack until we pick the correct one. We
|
||||
# need to take the mutex to protect our use of the stack.
|
||||
# Some of the startup actions are not thread safe. Use a mutex
|
||||
# to protect this section of code.
|
||||
|
||||
leal (startup_stack_mutex - startup)(%edi), %eax
|
||||
leal (startup_mutex - startup)(%edi), %eax
|
||||
0: lock btsl $0, (%eax)
|
||||
jc 0b
|
||||
|
||||
# Use the startup stack until we pick the correct one.
|
||||
|
||||
leal (startup_stack_top - startup)(%edi), %esp
|
||||
|
||||
# Load the GOT pointer.
|
||||
@@ -107,10 +109,6 @@ startup:
|
||||
leal _stacks@GOTOFF(%ebx), %esp
|
||||
addl %eax, %esp
|
||||
|
||||
# Release the mutex that protects the startup stack.
|
||||
|
||||
movl $0, startup_stack_mutex@GOTOFF(%ebx)
|
||||
|
||||
# Initialise the GDT descriptor.
|
||||
|
||||
leal gdt@GOTOFF(%ebx), %eax
|
||||
@@ -228,6 +226,10 @@ flush: movw $KERNEL_DS, %ax
|
||||
|
||||
1: movl %edi, %ebx
|
||||
|
||||
# Release the startup mutex.
|
||||
|
||||
movl $0, startup_mutex@GOTOFF(%ebx)
|
||||
|
||||
# Run the application.
|
||||
|
||||
call main
|
||||
@@ -563,7 +565,7 @@ ap_trampoline_end:
|
||||
boot_params_addr:
|
||||
.long 0
|
||||
|
||||
startup_stack_mutex:
|
||||
startup_mutex:
|
||||
.long 0
|
||||
|
||||
first_boot:
|
||||
|
||||
@@ -142,11 +142,14 @@ efi_handover:
|
||||
|
||||
.globl startup
|
||||
startup:
|
||||
# Use the startup stack until we pick the correct one. We
|
||||
# need to take a mutex to protect our use of the stack.
|
||||
# Some of the startup actions are not thread safe. Use a mutex
|
||||
# to protect this section of code.
|
||||
|
||||
0: lock btsl $0, startup_stack_mutex(%rip)
|
||||
0: lock btsl $0, startup_mutex(%rip)
|
||||
jc 0b
|
||||
|
||||
# Use the startup stack until we pick the correct one.
|
||||
|
||||
leaq startup_stack_top(%rip), %rsp
|
||||
|
||||
# Pick the correct stack.
|
||||
@@ -159,9 +162,6 @@ startup:
|
||||
leaq _stacks(%rip), %rsp
|
||||
addq %rax, %rsp
|
||||
|
||||
# Release the mutex that protects the startup stack.
|
||||
movl $0, startup_stack_mutex(%rip)
|
||||
|
||||
# Initialise the pml4 and pdp tables.
|
||||
|
||||
leaq pml4(%rip), %rcx
|
||||
@@ -267,6 +267,10 @@ flush: movw $KERNEL_DS, %ax
|
||||
|
||||
call reloc
|
||||
|
||||
# Release the startup mutex.
|
||||
|
||||
movl $0, startup_mutex(%rip)
|
||||
|
||||
# Run the application.
|
||||
|
||||
call main
|
||||
@@ -599,7 +603,7 @@ ap_trampoline_end:
|
||||
boot_params_addr:
|
||||
.quad 0
|
||||
|
||||
startup_stack_mutex:
|
||||
startup_mutex:
|
||||
.long 0
|
||||
|
||||
first_boot:
|
||||
|
||||
Reference in New Issue
Block a user