diff --git a/Kernel/Process.h b/Kernel/Process.h index 2aeaee2b6e..8186aa64f5 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -416,6 +416,7 @@ public: ErrorOr sys$getkeymap(Userspace); ErrorOr sys$setkeymap(Userspace); ErrorOr sys$profiling_enable(pid_t, Userspace); + ErrorOr profiling_enable(pid_t, u64 event_mask); ErrorOr sys$profiling_disable(pid_t); ErrorOr sys$profiling_free_buffer(pid_t); ErrorOr sys$futex(Userspace); 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(); diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 086242665b..67292fdfa3 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -393,7 +393,7 @@ void init_stage2(void*) dbgln("Starting full system boot profiling"); MutexLocker mutex_locker(Process::current().big_lock()); auto const enable_all = ~(u64)0; - auto result = Process::current().sys$profiling_enable(-1, reinterpret_cast(&enable_all)); + auto result = Process::current().profiling_enable(-1, enable_all); VERIFY(!result.is_error()); }