diff --git a/arch/x86/kernel/include/syscall_list.h b/arch/x86/kernel/include/syscall_list.h index ef14d8df..8c69af87 100644 --- a/arch/x86/kernel/include/syscall_list.h +++ b/arch/x86/kernel/include/syscall_list.h @@ -90,6 +90,7 @@ SYSCALL_HANDLED(289, signalfd4) #ifdef DCFA_KMOD SYSCALL_HANDLED(303, mod_call) #endif +SYSCALL_HANDLED(309, getcpu) SYSCALL_HANDLED(601, pmc_init) SYSCALL_HANDLED(602, pmc_start) SYSCALL_HANDLED(603, pmc_stop) diff --git a/kernel/syscall.c b/kernel/syscall.c index 3c72eda8..5a9173a5 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -3869,6 +3869,34 @@ out: return ret; } +SYSCALL_DECLARE(getcpu) +{ + const uintptr_t cpup = ihk_mc_syscall_arg0(ctx); + const uintptr_t nodep = ihk_mc_syscall_arg1(ctx); + struct process *proc = cpu_local_var(current); + const int cpu = ihk_mc_get_processor_id(); + const int node = 0; + int error; + + if (cpup) { + error = copy_to_user(proc, (void *)cpup, &cpu, sizeof(cpu)); + if (error) { + goto out; + } + } + + if (nodep) { + error = copy_to_user(proc, (void *)nodep, &node, sizeof(node)); + if (error) { + goto out; + } + } + + error = 0; +out: + return error; +} /* sys_getcpu() */ + #ifdef DCFA_KMOD #ifdef CMD_DCFA