Kernel: Rename rsp->sp and rip->ip

This makes more sense if we support i386
This commit is contained in:
2024-03-22 14:48:33 +02:00
parent 3e4d410646
commit fe17958b9f
13 changed files with 108 additions and 112 deletions

View File

@@ -161,24 +161,24 @@ namespace Kernel
if (tid)
{
Thread::current().set_return_rsp(interrupt_stack.rsp);
Thread::current().set_return_rip(interrupt_stack.rip);
Thread::current().set_return_sp(interrupt_stack.sp);
Thread::current().set_return_ip(interrupt_stack.ip);
if (isr == ISR::PageFault)
{
// Check if stack is OOB
auto& stack = Thread::current().stack();
auto& istack = Thread::current().interrupt_stack();
if (stack.vaddr() < interrupt_stack.rsp && interrupt_stack.rsp <= stack.vaddr() + stack.size())
if (stack.vaddr() < interrupt_stack.sp && interrupt_stack.sp <= stack.vaddr() + stack.size())
; // using normal stack
else if (istack.vaddr() < interrupt_stack.rsp && interrupt_stack.rsp <= istack.vaddr() + istack.size())
else if (istack.vaddr() < interrupt_stack.sp && interrupt_stack.sp <= istack.vaddr() + istack.size())
; // using interrupt stack
else
{
derrorln("Stack pointer out of bounds!");
derrorln("rip {H}", interrupt_stack.rip);
derrorln("rip {H}", interrupt_stack.ip);
derrorln("rsp {H}, stack {H}->{H}, istack {H}->{H}",
interrupt_stack.rsp,
interrupt_stack.sp,
stack.vaddr(), stack.vaddr() + stack.size(),
istack.vaddr(), istack.vaddr() + istack.size()
);
@@ -225,9 +225,9 @@ namespace Kernel
#endif
}
if (PageTable::current().get_page_flags(interrupt_stack.rip & PAGE_ADDR_MASK) & PageTable::Flags::Present)
if (PageTable::current().get_page_flags(interrupt_stack.ip & PAGE_ADDR_MASK) & PageTable::Flags::Present)
{
auto* machine_code = (const uint8_t*)interrupt_stack.rip;
auto* machine_code = (const uint8_t*)interrupt_stack.ip;
dwarnln("While executing: {2H}{2H}{2H}{2H}{2H}{2H}{2H}{2H}",
machine_code[0],
machine_code[1],
@@ -308,8 +308,8 @@ done:
if (Scheduler::current_tid())
{
Thread::current().set_return_rsp(interrupt_stack.rsp);
Thread::current().set_return_rip(interrupt_stack.rip);
Thread::current().set_return_sp(interrupt_stack.sp);
Thread::current().set_return_ip(interrupt_stack.ip);
}
if (!InterruptController::get().is_in_service(irq))

View File

@@ -6,7 +6,7 @@ sys_fork_trampoline:
pushq %r13
pushq %r14
pushq %r15
call read_rip
call read_ip
testq %rax, %rax
je .done
movq %rax, %rsi

View File

@@ -1,6 +1,6 @@
# uint64_t read_rip()
.global read_rip
read_rip:
# uint64_t read_()
.global read_ip
read_ip:
popq %rax
jmp *%rax
@@ -8,7 +8,7 @@ exit_thread_trampoline:
movq 8(%rsp), %rdi
ret
# void start_thread(uint64_t rsp, uint64_t rip)
# void start_thread(uint64_t sp, uint64_t ip)
.global start_thread
start_thread:
movq %rdi, %rsp
@@ -18,14 +18,14 @@ start_thread:
sti
jmp *%rsi
# void continue_thread(uint64_t rsp, uint64_t rip)
# void continue_thread(uint64_t sp, uint64_t ip)
.global continue_thread
continue_thread:
movq %rdi, %rsp
movq $0, %rax
jmp *%rsi
# void thread_userspace_trampoline(uint64_t rsp, uint64_t rip, int argc, char** argv, char** envp)
# void thread_userspace_trampoline(uint64_t sp, uint64_t ip, int argc, char** argv, char** envp)
.global thread_userspace_trampoline
thread_userspace_trampoline:
pushq $0x23