From 91574ed6778f7c7fb7e574d9bcdd87804103d04f Mon Sep 17 00:00:00 2001 From: Samuel Bowman Date: Sat, 20 Aug 2022 21:55:55 -0400 Subject: Kernel: Fix boot profiling Boot profiling was previously broken due to init_stage2() passing the event mask to sys$profiling_enable() via kernel pointer, but a user pointer is expected. To fix this, I added Process::profiling_enable() as an alternative to Process::sys$profiling_enable which takes a u64 rather than a Userspace. It's a bit of a hack, but it works. --- Kernel/Syscalls/profiling.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Kernel/Syscalls/profiling.cpp') diff --git a/Kernel/Syscalls/profiling.cpp b/Kernel/Syscalls/profiling.cpp index efba20f338..869ccf7dd2 100644 --- a/Kernel/Syscalls/profiling.cpp +++ b/Kernel/Syscalls/profiling.cpp @@ -24,6 +24,13 @@ ErrorOr Process::sys$profiling_enable(pid_t pid, Userspace TRY(require_no_promises()); auto const event_mask = TRY(copy_typed_from_user(userspace_event_mask)); + return profiling_enable(pid, event_mask); +} + +// NOTE: This second entrypoint exists to allow the kernel to invoke the syscall to enable boot profiling. +ErrorOr Process::profiling_enable(pid_t pid, u64 event_mask) +{ + VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this); if (pid == -1) { auto credentials = this->credentials(); -- cgit v1.2.3