18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __SYSDEP_X86_PTRACE_H 38c2ecf20Sopenharmony_ci#define __SYSDEP_X86_PTRACE_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <generated/user_constants.h> 68c2ecf20Sopenharmony_ci#include <sysdep/faultinfo.h> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#define MAX_REG_OFFSET (UM_FRAME_SIZE) 98c2ecf20Sopenharmony_ci#define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long)) 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#define REGS_IP(r) ((r)[HOST_IP]) 128c2ecf20Sopenharmony_ci#define REGS_SP(r) ((r)[HOST_SP]) 138c2ecf20Sopenharmony_ci#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS]) 148c2ecf20Sopenharmony_ci#define REGS_AX(r) ((r)[HOST_AX]) 158c2ecf20Sopenharmony_ci#define REGS_BX(r) ((r)[HOST_BX]) 168c2ecf20Sopenharmony_ci#define REGS_CX(r) ((r)[HOST_CX]) 178c2ecf20Sopenharmony_ci#define REGS_DX(r) ((r)[HOST_DX]) 188c2ecf20Sopenharmony_ci#define REGS_SI(r) ((r)[HOST_SI]) 198c2ecf20Sopenharmony_ci#define REGS_DI(r) ((r)[HOST_DI]) 208c2ecf20Sopenharmony_ci#define REGS_BP(r) ((r)[HOST_BP]) 218c2ecf20Sopenharmony_ci#define REGS_CS(r) ((r)[HOST_CS]) 228c2ecf20Sopenharmony_ci#define REGS_SS(r) ((r)[HOST_SS]) 238c2ecf20Sopenharmony_ci#define REGS_DS(r) ((r)[HOST_DS]) 248c2ecf20Sopenharmony_ci#define REGS_ES(r) ((r)[HOST_ES]) 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define UPT_IP(r) REGS_IP((r)->gp) 278c2ecf20Sopenharmony_ci#define UPT_SP(r) REGS_SP((r)->gp) 288c2ecf20Sopenharmony_ci#define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp) 298c2ecf20Sopenharmony_ci#define UPT_AX(r) REGS_AX((r)->gp) 308c2ecf20Sopenharmony_ci#define UPT_BX(r) REGS_BX((r)->gp) 318c2ecf20Sopenharmony_ci#define UPT_CX(r) REGS_CX((r)->gp) 328c2ecf20Sopenharmony_ci#define UPT_DX(r) REGS_DX((r)->gp) 338c2ecf20Sopenharmony_ci#define UPT_SI(r) REGS_SI((r)->gp) 348c2ecf20Sopenharmony_ci#define UPT_DI(r) REGS_DI((r)->gp) 358c2ecf20Sopenharmony_ci#define UPT_BP(r) REGS_BP((r)->gp) 368c2ecf20Sopenharmony_ci#define UPT_CS(r) REGS_CS((r)->gp) 378c2ecf20Sopenharmony_ci#define UPT_SS(r) REGS_SS((r)->gp) 388c2ecf20Sopenharmony_ci#define UPT_DS(r) REGS_DS((r)->gp) 398c2ecf20Sopenharmony_ci#define UPT_ES(r) REGS_ES((r)->gp) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#ifdef __i386__ 428c2ecf20Sopenharmony_ci#include "ptrace_32.h" 438c2ecf20Sopenharmony_ci#else 448c2ecf20Sopenharmony_ci#include "ptrace_64.h" 458c2ecf20Sopenharmony_ci#endif 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cistruct syscall_args { 488c2ecf20Sopenharmony_ci unsigned long args[6]; 498c2ecf20Sopenharmony_ci}; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#define SYSCALL_ARGS(r) ((struct syscall_args) \ 528c2ecf20Sopenharmony_ci { .args = { UPT_SYSCALL_ARG1(r), \ 538c2ecf20Sopenharmony_ci UPT_SYSCALL_ARG2(r), \ 548c2ecf20Sopenharmony_ci UPT_SYSCALL_ARG3(r), \ 558c2ecf20Sopenharmony_ci UPT_SYSCALL_ARG4(r), \ 568c2ecf20Sopenharmony_ci UPT_SYSCALL_ARG5(r), \ 578c2ecf20Sopenharmony_ci UPT_SYSCALL_ARG6(r) } } ) 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistruct uml_pt_regs { 608c2ecf20Sopenharmony_ci unsigned long gp[MAX_REG_NR]; 618c2ecf20Sopenharmony_ci unsigned long fp[MAX_FP_NR]; 628c2ecf20Sopenharmony_ci struct faultinfo faultinfo; 638c2ecf20Sopenharmony_ci long syscall; 648c2ecf20Sopenharmony_ci int is_user; 658c2ecf20Sopenharmony_ci}; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#define EMPTY_UML_PT_REGS { } 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#define UPT_SYSCALL_NR(r) ((r)->syscall) 708c2ecf20Sopenharmony_ci#define UPT_FAULTINFO(r) (&(r)->faultinfo) 718c2ecf20Sopenharmony_ci#define UPT_IS_USER(r) ((r)->is_user) 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ciextern int user_context(unsigned long sp); 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#endif /* __SYSDEP_X86_PTRACE_H */ 76