/* * Instead of the generic __SYSCALL_DEFINEx() definition, the x86 version takes * struct pt_regs *regs as the only argument of the syscall stub(s) named as: * __x64_sys_*() - 64-bit native syscall * __ia32_sys_*() - 32-bit native syscall or common compat syscall * __ia32_compat_sys_*() - 32-bit compat syscall * __x64_compat_sys_*() - 64-bit X32 compat syscall * * The registers are decoded according to the ABI: * 64-bit: RDI, RSI, RDX, R10, R8, R9 * 32-bit: EBX, ECX, EDX, ESI, EDI, EBP * * The stub then passes the decoded arguments to the __se_sys_*() wrapper to * perform sign-extension (omitted for zero-argument syscalls). Finally the * arguments are passed to the __do_sys_*() function which is the actual * syscall. These wrappers are marked as inline so the compiler can optimize * the functions where appropriate. * * Example assembly (slightly re-ordered for better readability): * * <__x64_sys_recv>: <-- syscall with 4 parameters * callq <__fentry__> * * mov 0x70(%rdi),%rdi <-- decode regs->di * mov 0x68(%rdi),%rsi <-- decode regs->si * mov 0x60(%rdi),%rdx <-- decode regs->dx * mov 0x38(%rdi),%rcx <-- decode regs->r10 * * xor %r9d,%r9d <-- clear %r9 * xor %r8d,%r8d <-- clear %r8 * * callq __sys_recvfrom <-- do the actual work in __sys_recvfrom() * which takes 6 arguments * * cltq <-- extend return value to 64-bit * retq <-- return * * This approach avoids leaking random user-provided register content down * the call chain.
*/
/* Mapping of registers to parameters for syscalls on x86-64 and x32 */ #define SC_X86_64_REGS_TO_ARGS(x, ...) \
__MAP(x,__SC_ARGS \
,,regs->di,,regs->si,,regs->dx \
,,regs->r10,,regs->r8,,regs->r9) \
#ifdef CONFIG_IA32_EMULATION /* * For IA32 emulation, we need to handle "compat" syscalls *and* create * additional wrappers (aptly named __ia32_sys_xyzzy) which decode the * ia32 regs in the proper order for shared or "common" syscalls. As some * syscalls may not be implemented, we need to expand COND_SYSCALL in * kernel/sys_ni.c to cover this case as well.
*/ #define __IA32_COMPAT_SYS_STUB0(name) \
__SYS_STUB0(ia32, compat_sys_##name)
#ifdef CONFIG_X86_X32_ABI /* * For the x32 ABI, we need to create a stub for compat_sys_*() which is aware * of the x86-64-style parameter ordering of x32 syscalls. The syscalls common * with x86_64 obviously do not need such care.
*/ #define __X32_COMPAT_SYS_STUB0(name) \
__SYS_STUB0(x64, compat_sys_##name)
#ifdef CONFIG_COMPAT /* * Compat means IA32_EMULATION and/or X86_X32. As they use a different * mapping of registers to parameters, we need to generate stubs for each * of them.
*/ #define COMPAT_SYSCALL_DEFINE0(name) \ staticlong \
__do_compat_sys_##name(conststruct pt_regs *__unused); \
__IA32_COMPAT_SYS_STUB0(name) \
__X32_COMPAT_SYS_STUB0(name) \ staticlong \
__do_compat_sys_##name(conststruct pt_regs *__unused)
/* * As some compat syscalls may not be implemented, we need to expand * COND_SYSCALL_COMPAT in kernel/sys_ni.c to cover this case as well.
*/ #define COND_SYSCALL_COMPAT(name) \
__IA32_COMPAT_COND_SYSCALL(name) \
__X32_COMPAT_COND_SYSCALL(name)
/* * As the generic SYSCALL_DEFINE0() macro does not decode any parameters for * obvious reasons, and passing struct pt_regs *regs to it in %rdi does not * hurt, we only need to re-define it here to keep the naming congruent to * SYSCALL_DEFINEx() -- which is essential for the COND_SYSCALL() macro * to work correctly.
*/ #define SYSCALL_DEFINE0(sname) \
SYSCALL_METADATA(_##sname, 0); \ staticlong __do_sys_##sname(conststruct pt_regs *__unused); \
__X64_SYS_STUB0(sname) \
__IA32_SYS_STUB0(sname) \ staticlong __do_sys_##sname(conststruct pt_regs *__unused)
/* * For VSYSCALLS, we need to declare these three syscalls with the new * pt_regs-based calling convention for in-kernel use.
*/ long __x64_sys_getcpu(conststruct pt_regs *regs); long __x64_sys_gettimeofday(conststruct pt_regs *regs); long __x64_sys_time(conststruct pt_regs *regs);
#endif/* _ASM_X86_SYSCALL_WRAPPER_H */
Messung V0.5
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.