boot: fix crash on early memory allocations
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
be49cc4839
commit
1d1dad34ce
10 changed files with 120 additions and 32 deletions
|
|
@ -105,13 +105,16 @@ _timer_handler:
|
|||
jz 1f
|
||||
swapgs
|
||||
1:
|
||||
mov rdi, gs:[0] /* cur_thread */
|
||||
test rdi, rdi
|
||||
jz .Lno_thread
|
||||
|
||||
sub rsp, 8 /* reserve return address slot */
|
||||
push_all
|
||||
|
||||
lea rax, [rip + 2f]
|
||||
mov [rsp + 120], rax /* return address */
|
||||
|
||||
mov rdi, gs:[0] /* cur_thread */
|
||||
mov [rdi + 8], rsp /* cur_thread->kstack_ptr */
|
||||
call sched_add_thread
|
||||
call lapic_eoi
|
||||
|
|
@ -125,6 +128,14 @@ _timer_handler:
|
|||
3:
|
||||
iretq
|
||||
|
||||
.Lno_thread:
|
||||
call lapic_eoi
|
||||
test qword ptr [rsp + 8], 3
|
||||
jz 4f
|
||||
swapgs
|
||||
4:
|
||||
iretq
|
||||
|
||||
.global sched_restore_state
|
||||
sched_restore_state:
|
||||
mov rsp, [rdi + 8] /* load RSP from thread->kstack_ptr */
|
||||
|
|
|
|||
Loading…
Reference in a new issue