Use 0 instead of syscall_invalid in syscall jump list

This commit is contained in:
Justin C. Miller
2019-05-18 18:11:08 -07:00
parent ce035d2a43
commit a653c55941
2 changed files with 8 additions and 5 deletions

View File

@@ -145,15 +145,14 @@ syscall_enable()
static constexpr unsigned num_calls =
static_cast<unsigned>(syscall::MAX);
for (unsigned i = 0; i < num_calls; ++i) {
syscall_registry[i] = reinterpret_cast<uintptr_t>(syscall_invalid);
syscall_names[i] = nullptr;
}
kutil::memset(&syscall_registry, 0, sizeof(syscall_registry));
kutil::memset(&syscall_names, 0, sizeof(syscall_names));
#define SYSCALL(id, name, result, ...) \
syscall_registry[id] = reinterpret_cast<uintptr_t>(syscalls::name); \
syscall_names[id] = #name; \
static_assert( id <= num_calls, "Syscall " #name " has id > syscall::MAX" );
static_assert( id <= num_calls, "Syscall " #name " has id > syscall::MAX" ); \
log::debug(logs::syscall, "Enabling syscall 0x%02x as " #name , id);
#include "syscalls.inc"
#undef SYSCALL
}

View File

@@ -34,12 +34,16 @@ syscall_handler_prelude:
cmp rax, MAX_SYSCALLS
jle .ok_syscall
.bad_syscall:
mov rdi, rax
call syscall_invalid
.ok_syscall:
lea r11, [rel syscall_registry]
mov r11, [r11 + rax * 8]
cmp r11, 0
je .bad_syscall
call r11
inc qword [rel __counter_syscall_sysret]