linux/arch/x86/um/shared/sysdep/ptrace_64.h
<<
>>
Prefs
   1/*
   2 * Copyright 2003 PathScale, Inc.
   3 * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
   4 *
   5 * Licensed under the GPL
   6 */
   7
   8#ifndef __SYSDEP_X86_64_PTRACE_H
   9#define __SYSDEP_X86_64_PTRACE_H
  10
  11#include <generated/user_constants.h>
  12#include "sysdep/faultinfo.h"
  13
  14#define MAX_REG_OFFSET (UM_FRAME_SIZE)
  15#define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long))
  16
  17#define REGS_IP(r) ((r)[HOST_IP])
  18#define REGS_SP(r) ((r)[HOST_SP])
  19
  20#define REGS_RBX(r) ((r)[HOST_BX])
  21#define REGS_RCX(r) ((r)[HOST_CX])
  22#define REGS_RDX(r) ((r)[HOST_DX])
  23#define REGS_RSI(r) ((r)[HOST_SI])
  24#define REGS_RDI(r) ((r)[HOST_DI])
  25#define REGS_RBP(r) ((r)[HOST_BP])
  26#define REGS_RAX(r) ((r)[HOST_AX])
  27#define REGS_R8(r) ((r)[HOST_R8])
  28#define REGS_R9(r) ((r)[HOST_R9])
  29#define REGS_R10(r) ((r)[HOST_R10])
  30#define REGS_R11(r) ((r)[HOST_R11])
  31#define REGS_R12(r) ((r)[HOST_R12])
  32#define REGS_R13(r) ((r)[HOST_R13])
  33#define REGS_R14(r) ((r)[HOST_R14])
  34#define REGS_R15(r) ((r)[HOST_R15])
  35#define REGS_CS(r) ((r)[HOST_CS])
  36#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
  37#define REGS_SS(r) ((r)[HOST_SS])
  38
  39#define HOST_FS_BASE 21
  40#define HOST_GS_BASE 22
  41#define HOST_DS 23
  42#define HOST_ES 24
  43#define HOST_FS 25
  44#define HOST_GS 26
  45
  46/* Also defined in asm/ptrace-x86_64.h, but not in libc headers.  So, these
  47 * are already defined for kernel code, but not for userspace code.
  48 */
  49#ifndef FS_BASE
  50/* These aren't defined in ptrace.h, but exist in struct user_regs_struct,
  51 * which is what x86_64 ptrace actually uses.
  52 */
  53#define FS_BASE (HOST_FS_BASE * sizeof(long))
  54#define GS_BASE (HOST_GS_BASE * sizeof(long))
  55#define DS (HOST_DS * sizeof(long))
  56#define ES (HOST_ES * sizeof(long))
  57#define FS (HOST_FS * sizeof(long))
  58#define GS (HOST_GS * sizeof(long))
  59#endif
  60
  61#define REGS_FS_BASE(r) ((r)[HOST_FS_BASE])
  62#define REGS_GS_BASE(r) ((r)[HOST_GS_BASE])
  63#define REGS_DS(r) ((r)[HOST_DS])
  64#define REGS_ES(r) ((r)[HOST_ES])
  65#define REGS_FS(r) ((r)[HOST_FS])
  66#define REGS_GS(r) ((r)[HOST_GS])
  67
  68#define REGS_ORIG_RAX(r) ((r)[HOST_ORIG_AX])
  69
  70#define REGS_SET_SYSCALL_RETURN(r, res) REGS_RAX(r) = (res)
  71
  72#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
  73#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
  74
  75#define REGS_FAULT_ADDR(r) ((r)->fault_addr)
  76
  77#define REGS_FAULT_WRITE(r) FAULT_WRITE((r)->fault_type)
  78
  79#define REGS_TRAP(r) ((r)->trap_type)
  80
  81#define REGS_ERR(r) ((r)->fault_type)
  82
  83struct uml_pt_regs {
  84        unsigned long gp[MAX_REG_NR];
  85        unsigned long fp[HOST_FP_SIZE];
  86        struct faultinfo faultinfo;
  87        long syscall;
  88        int is_user;
  89};
  90
  91#define EMPTY_UML_PT_REGS { }
  92
  93#define UPT_RBX(r) REGS_RBX((r)->gp)
  94#define UPT_RCX(r) REGS_RCX((r)->gp)
  95#define UPT_RDX(r) REGS_RDX((r)->gp)
  96#define UPT_RSI(r) REGS_RSI((r)->gp)
  97#define UPT_RDI(r) REGS_RDI((r)->gp)
  98#define UPT_RBP(r) REGS_RBP((r)->gp)
  99#define UPT_RAX(r) REGS_RAX((r)->gp)
 100#define UPT_R8(r) REGS_R8((r)->gp)
 101#define UPT_R9(r) REGS_R9((r)->gp)
 102#define UPT_R10(r) REGS_R10((r)->gp)
 103#define UPT_R11(r) REGS_R11((r)->gp)
 104#define UPT_R12(r) REGS_R12((r)->gp)
 105#define UPT_R13(r) REGS_R13((r)->gp)
 106#define UPT_R14(r) REGS_R14((r)->gp)
 107#define UPT_R15(r) REGS_R15((r)->gp)
 108#define UPT_CS(r) REGS_CS((r)->gp)
 109#define UPT_FS_BASE(r) REGS_FS_BASE((r)->gp)
 110#define UPT_FS(r) REGS_FS((r)->gp)
 111#define UPT_GS_BASE(r) REGS_GS_BASE((r)->gp)
 112#define UPT_GS(r) REGS_GS((r)->gp)
 113#define UPT_DS(r) REGS_DS((r)->gp)
 114#define UPT_ES(r) REGS_ES((r)->gp)
 115#define UPT_CS(r) REGS_CS((r)->gp)
 116#define UPT_SS(r) REGS_SS((r)->gp)
 117#define UPT_ORIG_RAX(r) REGS_ORIG_RAX((r)->gp)
 118
 119#define UPT_IP(r) REGS_IP((r)->gp)
 120#define UPT_SP(r) REGS_SP((r)->gp)
 121
 122#define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp)
 123#define UPT_SYSCALL_NR(r) ((r)->syscall)
 124#define UPT_SYSCALL_RET(r) UPT_RAX(r)
 125
 126extern int user_context(unsigned long sp);
 127
 128#define UPT_IS_USER(r) ((r)->is_user)
 129
 130#define UPT_SYSCALL_ARG1(r) UPT_RDI(r)
 131#define UPT_SYSCALL_ARG2(r) UPT_RSI(r)
 132#define UPT_SYSCALL_ARG3(r) UPT_RDX(r)
 133#define UPT_SYSCALL_ARG4(r) UPT_R10(r)
 134#define UPT_SYSCALL_ARG5(r) UPT_R8(r)
 135#define UPT_SYSCALL_ARG6(r) UPT_R9(r)
 136
 137struct syscall_args {
 138        unsigned long args[6];
 139};
 140
 141#define SYSCALL_ARGS(r) ((struct syscall_args) \
 142                         { .args = { UPT_SYSCALL_ARG1(r),        \
 143                                     UPT_SYSCALL_ARG2(r),        \
 144                                     UPT_SYSCALL_ARG3(r),        \
 145                                     UPT_SYSCALL_ARG4(r),        \
 146                                     UPT_SYSCALL_ARG5(r),        \
 147                                     UPT_SYSCALL_ARG6(r) } } )
 148
 149#define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->gp)
 150
 151#define UPT_FAULTINFO(r) (&(r)->faultinfo)
 152
 153static inline void arch_init_registers(int pid)
 154{
 155}
 156
 157#endif
 158