1 // SPDX-License-Identifier: GPL-2.0 2 #include <sys/ucontext.h> 3 #define __FRAME_OFFSETS 4 #include <asm/ptrace.h> 5 #include <sysdep/ptrace.h> 6 #include <sysdep/mcontext.h> 7 8 void get_regs_from_mc(struct uml_pt_regs *regs, mcontext_t *mc) 9 { 10 #ifdef __i386__ 11 #define COPY2(X,Y) regs->gp[X] = mc->gregs[REG_##Y] 12 #define COPY(X) regs->gp[X] = mc->gregs[REG_##X] 13 #define COPY_SEG(X) regs->gp[X] = mc->gregs[REG_##X] & 0xffff; 14 #define COPY_SEG_CPL3(X) regs->gp[X] = (mc->gregs[REG_##X] & 0xffff) | 3; 15 COPY_SEG(GS); COPY_SEG(FS); COPY_SEG(ES); COPY_SEG(DS); 16 COPY(EDI); COPY(ESI); COPY(EBP); 17 COPY2(UESP, ESP); /* sic */ 18 COPY(EBX); COPY(EDX); COPY(ECX); COPY(EAX); 19 COPY(EIP); COPY_SEG_CPL3(CS); COPY(EFL); COPY_SEG_CPL3(SS); 20 #else 21 #define COPY2(X,Y) regs->gp[X/sizeof(unsigned long)] = mc->gregs[REG_##Y] 22 #define COPY(X) regs->gp[X/sizeof(unsigned long)] = mc->gregs[REG_##X] 23 COPY(R8); COPY(R9); COPY(R10); COPY(R11); 24 COPY(R12); COPY(R13); COPY(R14); COPY(R15); 25 COPY(RDI); COPY(RSI); COPY(RBP); COPY(RBX); 26 COPY(RDX); COPY(RAX); COPY(RCX); COPY(RSP); 27 COPY(RIP); 28 COPY2(EFLAGS, EFL); 29 COPY2(CS, CSGSFS); 30 regs->gp[CS / sizeof(unsigned long)] &= 0xffff; 31 regs->gp[CS / sizeof(unsigned long)] |= 3; 32 #endif 33 } 34
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.