summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/profiling.cpp
diff options
context:
space:
mode:
authorSamuel Bowman <sam@sambowman.tech>2022-08-20 21:55:55 -0400
committerAndreas Kling <kling@serenityos.org>2022-08-23 11:48:50 +0200
commit91574ed6778f7c7fb7e574d9bcdd87804103d04f (patch)
treedc3f0f2094bfe51c830465685443c35557fdc8a7 /Kernel/Syscalls/profiling.cpp
parent0abe4d8b97e825af5ce5a120c695dd299814039a (diff)
downloadserenity-91574ed6778f7c7fb7e574d9bcdd87804103d04f.zip
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<u64 const*>. It's a bit of a hack, but it works.
Diffstat (limited to 'Kernel/Syscalls/profiling.cpp')
-rw-r--r--Kernel/Syscalls/profiling.cpp7
1 files changed, 7 insertions, 0 deletions
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<FlatPtr> Process::sys$profiling_enable(pid_t pid, Userspace<u64 const*>
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<FlatPtr> Process::profiling_enable(pid_t pid, u64 event_mask)
+{
+ VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this);
if (pid == -1) {
auto credentials = this->credentials();