cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

ptrace.h (2015B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2#ifndef __SYSDEP_X86_PTRACE_H
      3#define __SYSDEP_X86_PTRACE_H
      4
      5#include <generated/user_constants.h>
      6#include <sysdep/faultinfo.h>
      7
      8#define MAX_REG_OFFSET (UM_FRAME_SIZE)
      9#define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long))
     10
     11#define REGS_IP(r) ((r)[HOST_IP])
     12#define REGS_SP(r) ((r)[HOST_SP])
     13#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
     14#define REGS_AX(r) ((r)[HOST_AX])
     15#define REGS_BX(r) ((r)[HOST_BX])
     16#define REGS_CX(r) ((r)[HOST_CX])
     17#define REGS_DX(r) ((r)[HOST_DX])
     18#define REGS_SI(r) ((r)[HOST_SI])
     19#define REGS_DI(r) ((r)[HOST_DI])
     20#define REGS_BP(r) ((r)[HOST_BP])
     21#define REGS_CS(r) ((r)[HOST_CS])
     22#define REGS_SS(r) ((r)[HOST_SS])
     23#define REGS_DS(r) ((r)[HOST_DS])
     24#define REGS_ES(r) ((r)[HOST_ES])
     25
     26#define UPT_IP(r) REGS_IP((r)->gp)
     27#define UPT_SP(r) REGS_SP((r)->gp)
     28#define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp)
     29#define UPT_AX(r) REGS_AX((r)->gp)
     30#define UPT_BX(r) REGS_BX((r)->gp)
     31#define UPT_CX(r) REGS_CX((r)->gp)
     32#define UPT_DX(r) REGS_DX((r)->gp)
     33#define UPT_SI(r) REGS_SI((r)->gp)
     34#define UPT_DI(r) REGS_DI((r)->gp)
     35#define UPT_BP(r) REGS_BP((r)->gp)
     36#define UPT_CS(r) REGS_CS((r)->gp)
     37#define UPT_SS(r) REGS_SS((r)->gp)
     38#define UPT_DS(r) REGS_DS((r)->gp)
     39#define UPT_ES(r) REGS_ES((r)->gp)
     40
     41#ifdef __i386__
     42#include "ptrace_32.h"
     43#else
     44#include "ptrace_64.h"
     45#endif
     46
     47struct syscall_args {
     48	unsigned long args[6];
     49};
     50
     51#define SYSCALL_ARGS(r) ((struct syscall_args) \
     52			 { .args = { UPT_SYSCALL_ARG1(r),	 \
     53				     UPT_SYSCALL_ARG2(r),	 \
     54				     UPT_SYSCALL_ARG3(r),	 \
     55				     UPT_SYSCALL_ARG4(r),	 \
     56				     UPT_SYSCALL_ARG5(r),	 \
     57				     UPT_SYSCALL_ARG6(r) } } )
     58
     59struct uml_pt_regs {
     60	unsigned long gp[MAX_REG_NR];
     61	unsigned long fp[MAX_FP_NR];
     62	struct faultinfo faultinfo;
     63	long syscall;
     64	int is_user;
     65};
     66
     67#define EMPTY_UML_PT_REGS { }
     68
     69#define UPT_SYSCALL_NR(r) ((r)->syscall)
     70#define UPT_FAULTINFO(r) (&(r)->faultinfo)
     71#define UPT_IS_USER(r) ((r)->is_user)
     72
     73extern int user_context(unsigned long sp);
     74
     75#endif /* __SYSDEP_X86_PTRACE_H */