mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-21 10:05:00 +08:00
cfcbadb49d
This will let us specify something like 'sys_xyz/foo' instead of 'sys_xyz' in the syscall table, where the 'foo' qualifier conveys some extra information to the C code. The intent is to allow things like sys_execve/ptregs to indicate that sys_execve() touches pt_regs. Signed-off-by: Andy Lutomirski <luto@kernel.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/2de06e33dce62556b3ec662006fcb295504e296e.1454022279.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
96 lines
2.3 KiB
C
96 lines
2.3 KiB
C
#include <stdio.h>
|
|
#include <stddef.h>
|
|
#include <signal.h>
|
|
#include <sys/poll.h>
|
|
#include <sys/mman.h>
|
|
#include <sys/user.h>
|
|
#define __FRAME_OFFSETS
|
|
#include <asm/ptrace.h>
|
|
#include <asm/types.h>
|
|
|
|
#ifdef __i386__
|
|
#define __SYSCALL_I386(nr, sym, qual) [nr] = 1,
|
|
static char syscalls[] = {
|
|
#include <asm/syscalls_32.h>
|
|
};
|
|
#else
|
|
#define __SYSCALL_64(nr, sym, qual) [nr] = 1,
|
|
static char syscalls[] = {
|
|
#include <asm/syscalls_64.h>
|
|
};
|
|
#endif
|
|
|
|
#define DEFINE(sym, val) \
|
|
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
|
|
|
|
#define DEFINE_LONGS(sym, val) \
|
|
asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
|
|
|
|
void foo(void)
|
|
{
|
|
#ifdef __i386__
|
|
DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct));
|
|
DEFINE_LONGS(HOST_FPX_SIZE, sizeof(struct user_fpxregs_struct));
|
|
|
|
DEFINE(HOST_IP, EIP);
|
|
DEFINE(HOST_SP, UESP);
|
|
DEFINE(HOST_EFLAGS, EFL);
|
|
DEFINE(HOST_AX, EAX);
|
|
DEFINE(HOST_BX, EBX);
|
|
DEFINE(HOST_CX, ECX);
|
|
DEFINE(HOST_DX, EDX);
|
|
DEFINE(HOST_SI, ESI);
|
|
DEFINE(HOST_DI, EDI);
|
|
DEFINE(HOST_BP, EBP);
|
|
DEFINE(HOST_CS, CS);
|
|
DEFINE(HOST_SS, SS);
|
|
DEFINE(HOST_DS, DS);
|
|
DEFINE(HOST_FS, FS);
|
|
DEFINE(HOST_ES, ES);
|
|
DEFINE(HOST_GS, GS);
|
|
DEFINE(HOST_ORIG_AX, ORIG_EAX);
|
|
#else
|
|
DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
|
|
DEFINE_LONGS(HOST_BX, RBX);
|
|
DEFINE_LONGS(HOST_CX, RCX);
|
|
DEFINE_LONGS(HOST_DI, RDI);
|
|
DEFINE_LONGS(HOST_SI, RSI);
|
|
DEFINE_LONGS(HOST_DX, RDX);
|
|
DEFINE_LONGS(HOST_BP, RBP);
|
|
DEFINE_LONGS(HOST_AX, RAX);
|
|
DEFINE_LONGS(HOST_R8, R8);
|
|
DEFINE_LONGS(HOST_R9, R9);
|
|
DEFINE_LONGS(HOST_R10, R10);
|
|
DEFINE_LONGS(HOST_R11, R11);
|
|
DEFINE_LONGS(HOST_R12, R12);
|
|
DEFINE_LONGS(HOST_R13, R13);
|
|
DEFINE_LONGS(HOST_R14, R14);
|
|
DEFINE_LONGS(HOST_R15, R15);
|
|
DEFINE_LONGS(HOST_ORIG_AX, ORIG_RAX);
|
|
DEFINE_LONGS(HOST_CS, CS);
|
|
DEFINE_LONGS(HOST_SS, SS);
|
|
DEFINE_LONGS(HOST_EFLAGS, EFLAGS);
|
|
#if 0
|
|
DEFINE_LONGS(HOST_FS, FS);
|
|
DEFINE_LONGS(HOST_GS, GS);
|
|
DEFINE_LONGS(HOST_DS, DS);
|
|
DEFINE_LONGS(HOST_ES, ES);
|
|
#endif
|
|
|
|
DEFINE_LONGS(HOST_IP, RIP);
|
|
DEFINE_LONGS(HOST_SP, RSP);
|
|
#endif
|
|
|
|
DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct));
|
|
DEFINE(UM_POLLIN, POLLIN);
|
|
DEFINE(UM_POLLPRI, POLLPRI);
|
|
DEFINE(UM_POLLOUT, POLLOUT);
|
|
|
|
DEFINE(UM_PROT_READ, PROT_READ);
|
|
DEFINE(UM_PROT_WRITE, PROT_WRITE);
|
|
DEFINE(UM_PROT_EXEC, PROT_EXEC);
|
|
|
|
DEFINE(__NR_syscall_max, sizeof(syscalls) - 1);
|
|
DEFINE(NR_syscalls, sizeof(syscalls));
|
|
}
|