162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef __SYSDEP_X86_PTRACE_H 362306a36Sopenharmony_ci#define __SYSDEP_X86_PTRACE_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <generated/user_constants.h> 662306a36Sopenharmony_ci#include <sysdep/faultinfo.h> 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#define MAX_REG_OFFSET (UM_FRAME_SIZE) 962306a36Sopenharmony_ci#define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long)) 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#define REGS_IP(r) ((r)[HOST_IP]) 1262306a36Sopenharmony_ci#define REGS_SP(r) ((r)[HOST_SP]) 1362306a36Sopenharmony_ci#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS]) 1462306a36Sopenharmony_ci#define REGS_AX(r) ((r)[HOST_AX]) 1562306a36Sopenharmony_ci#define REGS_BX(r) ((r)[HOST_BX]) 1662306a36Sopenharmony_ci#define REGS_CX(r) ((r)[HOST_CX]) 1762306a36Sopenharmony_ci#define REGS_DX(r) ((r)[HOST_DX]) 1862306a36Sopenharmony_ci#define REGS_SI(r) ((r)[HOST_SI]) 1962306a36Sopenharmony_ci#define REGS_DI(r) ((r)[HOST_DI]) 2062306a36Sopenharmony_ci#define REGS_BP(r) ((r)[HOST_BP]) 2162306a36Sopenharmony_ci#define REGS_CS(r) ((r)[HOST_CS]) 2262306a36Sopenharmony_ci#define REGS_SS(r) ((r)[HOST_SS]) 2362306a36Sopenharmony_ci#define REGS_DS(r) ((r)[HOST_DS]) 2462306a36Sopenharmony_ci#define REGS_ES(r) ((r)[HOST_ES]) 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci#define UPT_IP(r) REGS_IP((r)->gp) 2762306a36Sopenharmony_ci#define UPT_SP(r) REGS_SP((r)->gp) 2862306a36Sopenharmony_ci#define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp) 2962306a36Sopenharmony_ci#define UPT_AX(r) REGS_AX((r)->gp) 3062306a36Sopenharmony_ci#define UPT_BX(r) REGS_BX((r)->gp) 3162306a36Sopenharmony_ci#define UPT_CX(r) REGS_CX((r)->gp) 3262306a36Sopenharmony_ci#define UPT_DX(r) REGS_DX((r)->gp) 3362306a36Sopenharmony_ci#define UPT_SI(r) REGS_SI((r)->gp) 3462306a36Sopenharmony_ci#define UPT_DI(r) REGS_DI((r)->gp) 3562306a36Sopenharmony_ci#define UPT_BP(r) REGS_BP((r)->gp) 3662306a36Sopenharmony_ci#define UPT_CS(r) REGS_CS((r)->gp) 3762306a36Sopenharmony_ci#define UPT_SS(r) REGS_SS((r)->gp) 3862306a36Sopenharmony_ci#define UPT_DS(r) REGS_DS((r)->gp) 3962306a36Sopenharmony_ci#define UPT_ES(r) REGS_ES((r)->gp) 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci#ifdef __i386__ 4262306a36Sopenharmony_ci#include "ptrace_32.h" 4362306a36Sopenharmony_ci#else 4462306a36Sopenharmony_ci#include "ptrace_64.h" 4562306a36Sopenharmony_ci#endif 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_cistruct syscall_args { 4862306a36Sopenharmony_ci unsigned long args[6]; 4962306a36Sopenharmony_ci}; 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#define SYSCALL_ARGS(r) ((struct syscall_args) \ 5262306a36Sopenharmony_ci { .args = { UPT_SYSCALL_ARG1(r), \ 5362306a36Sopenharmony_ci UPT_SYSCALL_ARG2(r), \ 5462306a36Sopenharmony_ci UPT_SYSCALL_ARG3(r), \ 5562306a36Sopenharmony_ci UPT_SYSCALL_ARG4(r), \ 5662306a36Sopenharmony_ci UPT_SYSCALL_ARG5(r), \ 5762306a36Sopenharmony_ci UPT_SYSCALL_ARG6(r) } } ) 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_cistruct uml_pt_regs { 6062306a36Sopenharmony_ci unsigned long gp[MAX_REG_NR]; 6162306a36Sopenharmony_ci unsigned long fp[MAX_FP_NR]; 6262306a36Sopenharmony_ci struct faultinfo faultinfo; 6362306a36Sopenharmony_ci long syscall; 6462306a36Sopenharmony_ci int is_user; 6562306a36Sopenharmony_ci}; 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci#define EMPTY_UML_PT_REGS { } 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci#define UPT_SYSCALL_NR(r) ((r)->syscall) 7062306a36Sopenharmony_ci#define UPT_FAULTINFO(r) (&(r)->faultinfo) 7162306a36Sopenharmony_ci#define UPT_IS_USER(r) ((r)->is_user) 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ciextern int user_context(unsigned long sp); 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci#endif /* __SYSDEP_X86_PTRACE_H */ 76