1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:07:45 +00:00

Kernel: Make some of the assembly code position-independent on x86_64

This commit is contained in:
Gunnar Beutner 2021-07-23 14:11:28 +02:00 committed by Andreas Kling
parent 412ce31f7f
commit a6c4a4d2fc
2 changed files with 5 additions and 5 deletions

View file

@ -141,7 +141,7 @@ apic_ap_start64:
/* push the Processor pointer this CPU is going to use */ /* push the Processor pointer this CPU is going to use */
movq (ap_cpu_init_processor_info_array - apic_ap_start)(%ebp), %rax movq (ap_cpu_init_processor_info_array - apic_ap_start)(%ebp), %rax
movabsq $(kernel_base), %r8 leaq kernel_base(%rip), %r8
movq (%r8), %r8 movq (%r8), %r8
addq %r8, %rax addq %r8, %rax
movq 0(%rax, %rsi, 4), %rax movq 0(%rax, %rsi, 4), %rax
@ -157,9 +157,9 @@ apic_ap_start64:
/* We are in identity mapped P0x8000 and the BSP will unload this code /* We are in identity mapped P0x8000 and the BSP will unload this code
once all APs are initialized, so call init_ap but return to our once all APs are initialized, so call init_ap but return to our
infinite loop */ infinite loop */
movabs $loop, %rax leaq loop(%rip), %rax
pushq %rax pushq %rax
movabs $init_ap, %rax leaq init_ap(%rip), %rax
jmp *(%rax) jmp *(%rax)
loop: loop:

View file

@ -47,7 +47,7 @@ NAKED void do_assume_context(Thread*, u32)
" movq %r12, %rsi \n" // from_thread " movq %r12, %rsi \n" // from_thread
" pushq %r12 \n" // to_thread (for thread_context_first_enter) " pushq %r12 \n" // to_thread (for thread_context_first_enter)
" pushq %r12 \n" // from_thread (for thread_context_first_enter) " pushq %r12 \n" // from_thread (for thread_context_first_enter)
" movabs $thread_context_first_enter, %r12 \n" // should be same as regs.rip " leaq thread_context_first_enter(%rip), %r12 \n" // should be same as regs.rip
" pushq %r12 \n" " pushq %r12 \n"
" jmp enter_thread_context \n"); " jmp enter_thread_context \n");
// clang-format on // clang-format on
@ -191,7 +191,7 @@ void Processor::switch_context(Thread*& from_thread, Thread*& to_thread)
"pushq %%r14 \n" "pushq %%r14 \n"
"pushq %%r15 \n" "pushq %%r15 \n"
"movq %%rsp, %[from_rsp] \n" "movq %%rsp, %[from_rsp] \n"
"movabs $1f, %%rbx \n" "leaq 1f(%%rip), %%rbx \n"
"movq %%rbx, %[from_rip] \n" "movq %%rbx, %[from_rip] \n"
"movq %[to_rsp0], %%rbx \n" "movq %[to_rsp0], %%rbx \n"
"movl %%ebx, %[tss_rsp0l] \n" "movl %%ebx, %[tss_rsp0l] \n"