18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Access to user system call parameters and results 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * See asm-generic/syscall.h for function descriptions. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (C) 2015 Mickaël Salaün <mic@digikod.net> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef __UM_SYSCALL_GENERIC_H 118c2ecf20Sopenharmony_ci#define __UM_SYSCALL_GENERIC_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <asm/ptrace.h> 148c2ecf20Sopenharmony_ci#include <linux/err.h> 158c2ecf20Sopenharmony_ci#include <linux/sched.h> 168c2ecf20Sopenharmony_ci#include <sysdep/ptrace.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistatic inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs) 198c2ecf20Sopenharmony_ci{ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci return PT_REGS_SYSCALL_NR(regs); 228c2ecf20Sopenharmony_ci} 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cistatic inline void syscall_rollback(struct task_struct *task, 258c2ecf20Sopenharmony_ci struct pt_regs *regs) 268c2ecf20Sopenharmony_ci{ 278c2ecf20Sopenharmony_ci /* do nothing */ 288c2ecf20Sopenharmony_ci} 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistatic inline long syscall_get_error(struct task_struct *task, 318c2ecf20Sopenharmony_ci struct pt_regs *regs) 328c2ecf20Sopenharmony_ci{ 338c2ecf20Sopenharmony_ci const long error = regs_return_value(regs); 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci return IS_ERR_VALUE(error) ? error : 0; 368c2ecf20Sopenharmony_ci} 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_cistatic inline long syscall_get_return_value(struct task_struct *task, 398c2ecf20Sopenharmony_ci struct pt_regs *regs) 408c2ecf20Sopenharmony_ci{ 418c2ecf20Sopenharmony_ci return regs_return_value(regs); 428c2ecf20Sopenharmony_ci} 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistatic inline void syscall_set_return_value(struct task_struct *task, 458c2ecf20Sopenharmony_ci struct pt_regs *regs, 468c2ecf20Sopenharmony_ci int error, long val) 478c2ecf20Sopenharmony_ci{ 488c2ecf20Sopenharmony_ci PT_REGS_SET_SYSCALL_RETURN(regs, (long) error ?: val); 498c2ecf20Sopenharmony_ci} 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_cistatic inline void syscall_get_arguments(struct task_struct *task, 528c2ecf20Sopenharmony_ci struct pt_regs *regs, 538c2ecf20Sopenharmony_ci unsigned long *args) 548c2ecf20Sopenharmony_ci{ 558c2ecf20Sopenharmony_ci const struct uml_pt_regs *r = ®s->regs; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci *args++ = UPT_SYSCALL_ARG1(r); 588c2ecf20Sopenharmony_ci *args++ = UPT_SYSCALL_ARG2(r); 598c2ecf20Sopenharmony_ci *args++ = UPT_SYSCALL_ARG3(r); 608c2ecf20Sopenharmony_ci *args++ = UPT_SYSCALL_ARG4(r); 618c2ecf20Sopenharmony_ci *args++ = UPT_SYSCALL_ARG5(r); 628c2ecf20Sopenharmony_ci *args = UPT_SYSCALL_ARG6(r); 638c2ecf20Sopenharmony_ci} 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistatic inline void syscall_set_arguments(struct task_struct *task, 668c2ecf20Sopenharmony_ci struct pt_regs *regs, 678c2ecf20Sopenharmony_ci const unsigned long *args) 688c2ecf20Sopenharmony_ci{ 698c2ecf20Sopenharmony_ci struct uml_pt_regs *r = ®s->regs; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci UPT_SYSCALL_ARG1(r) = *args++; 728c2ecf20Sopenharmony_ci UPT_SYSCALL_ARG2(r) = *args++; 738c2ecf20Sopenharmony_ci UPT_SYSCALL_ARG3(r) = *args++; 748c2ecf20Sopenharmony_ci UPT_SYSCALL_ARG4(r) = *args++; 758c2ecf20Sopenharmony_ci UPT_SYSCALL_ARG5(r) = *args++; 768c2ecf20Sopenharmony_ci UPT_SYSCALL_ARG6(r) = *args; 778c2ecf20Sopenharmony_ci} 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* See arch/x86/um/asm/syscall.h for syscall_get_arch() definition. */ 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#endif /* __UM_SYSCALL_GENERIC_H */ 82