Path: blob/master/arch/um/sys-i386/shared/sysdep/stub.h
17659 views
/*1* Copyright (C) 2004 Jeff Dike ([email protected])2* Licensed under the GPL3*/45#ifndef __SYSDEP_STUB_H6#define __SYSDEP_STUB_H78#include <sys/mman.h>9#include <asm/ptrace.h>10#include <asm/unistd.h>11#include "as-layout.h"12#include "stub-data.h"13#include "kern_constants.h"1415extern void stub_segv_handler(int sig);16extern void stub_clone_handler(void);1718#define STUB_SYSCALL_RET EAX19#define STUB_MMAP_NR __NR_mmap220#define MMAP_OFFSET(o) ((o) >> UM_KERN_PAGE_SHIFT)2122static inline long stub_syscall0(long syscall)23{24long ret;2526__asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall));2728return ret;29}3031static inline long stub_syscall1(long syscall, long arg1)32{33long ret;3435__asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1));3637return ret;38}3940static inline long stub_syscall2(long syscall, long arg1, long arg2)41{42long ret;4344__asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),45"c" (arg2));4647return ret;48}4950static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)51{52long ret;5354__asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),55"c" (arg2), "d" (arg3));5657return ret;58}5960static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,61long arg4)62{63long ret;6465__asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),66"c" (arg2), "d" (arg3), "S" (arg4));6768return ret;69}7071static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,72long arg4, long arg5)73{74long ret;7576__asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),77"c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5));7879return ret;80}8182static inline void trap_myself(void)83{84__asm("int3");85}8687static inline void remap_stack(int fd, unsigned long offset)88{89__asm__ volatile ("movl %%eax,%%ebp ; movl %0,%%eax ; int $0x80 ;"90"movl %7, %%ebx ; movl %%eax, (%%ebx)"91: : "g" (STUB_MMAP_NR), "b" (STUB_DATA),92"c" (UM_KERN_PAGE_SIZE),93"d" (PROT_READ | PROT_WRITE),94"S" (MAP_FIXED | MAP_SHARED), "D" (fd),95"a" (offset),96"i" (&((struct stub_data *) STUB_DATA)->err)97: "memory");98}99100#endif101102103