mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:17:42 +00:00
Kernel: Fixed argument passing for profiling_enable syscall
Arguments larger than 32bit need to be passed as a pointer on a 32bit architectures. sys$profiling_enable has u64 event_mask argument, which means that it needs to be passed as an pointer. Previously upper 32bits were filled by garbage.
This commit is contained in:
parent
0f2e18403c
commit
895a050e04
4 changed files with 9 additions and 4 deletions
|
@ -390,7 +390,7 @@ public:
|
||||||
ErrorOr<FlatPtr> sys$getrandom(Userspace<void*>, size_t, unsigned int);
|
ErrorOr<FlatPtr> sys$getrandom(Userspace<void*>, size_t, unsigned int);
|
||||||
ErrorOr<FlatPtr> sys$getkeymap(Userspace<const Syscall::SC_getkeymap_params*>);
|
ErrorOr<FlatPtr> sys$getkeymap(Userspace<const Syscall::SC_getkeymap_params*>);
|
||||||
ErrorOr<FlatPtr> sys$setkeymap(Userspace<const Syscall::SC_setkeymap_params*>);
|
ErrorOr<FlatPtr> sys$setkeymap(Userspace<const Syscall::SC_setkeymap_params*>);
|
||||||
ErrorOr<FlatPtr> sys$profiling_enable(pid_t, u64);
|
ErrorOr<FlatPtr> sys$profiling_enable(pid_t, Userspace<u64 const*>);
|
||||||
ErrorOr<FlatPtr> sys$profiling_disable(pid_t);
|
ErrorOr<FlatPtr> sys$profiling_disable(pid_t);
|
||||||
ErrorOr<FlatPtr> sys$profiling_free_buffer(pid_t);
|
ErrorOr<FlatPtr> sys$profiling_free_buffer(pid_t);
|
||||||
ErrorOr<FlatPtr> sys$futex(Userspace<const Syscall::SC_futex_params*>);
|
ErrorOr<FlatPtr> sys$futex(Userspace<const Syscall::SC_futex_params*>);
|
||||||
|
|
|
@ -16,11 +16,15 @@ bool g_profiling_all_threads;
|
||||||
PerformanceEventBuffer* g_global_perf_events;
|
PerformanceEventBuffer* g_global_perf_events;
|
||||||
u64 g_profiling_event_mask;
|
u64 g_profiling_event_mask;
|
||||||
|
|
||||||
ErrorOr<FlatPtr> Process::sys$profiling_enable(pid_t pid, u64 event_mask)
|
// NOTE: event_mask needs to be passed as a pointer as u64
|
||||||
|
// does not fit into a register on 32bit architectures.
|
||||||
|
ErrorOr<FlatPtr> Process::sys$profiling_enable(pid_t pid, Userspace<u64 const*> userspace_event_mask)
|
||||||
{
|
{
|
||||||
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
||||||
TRY(require_no_promises());
|
TRY(require_no_promises());
|
||||||
|
|
||||||
|
const auto event_mask = TRY(copy_typed_from_user(userspace_event_mask));
|
||||||
|
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
if (!is_superuser())
|
if (!is_superuser())
|
||||||
return EPERM;
|
return EPERM;
|
||||||
|
|
|
@ -373,7 +373,8 @@ void init_stage2(void*)
|
||||||
if (boot_profiling) {
|
if (boot_profiling) {
|
||||||
dbgln("Starting full system boot profiling");
|
dbgln("Starting full system boot profiling");
|
||||||
MutexLocker mutex_locker(Process::current().big_lock());
|
MutexLocker mutex_locker(Process::current().big_lock());
|
||||||
auto result = Process::current().sys$profiling_enable(-1, ~0ull);
|
const auto enable_all = ~(u64)0;
|
||||||
|
auto result = Process::current().sys$profiling_enable(-1, reinterpret_cast<FlatPtr>(&enable_all));
|
||||||
VERIFY(!result.is_error());
|
VERIFY(!result.is_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ int disown(pid_t pid)
|
||||||
|
|
||||||
int profiling_enable(pid_t pid, uint64_t event_mask)
|
int profiling_enable(pid_t pid, uint64_t event_mask)
|
||||||
{
|
{
|
||||||
int rc = syscall(SC_profiling_enable, pid, event_mask);
|
int rc = syscall(SC_profiling_enable, pid, &event_mask);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue