Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / x86 / um / os-Linux / mcontext.c
blob49c3744cac371bb8a3a64154fc63e2607f679841
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>
7 void get_regs_from_mc(struct uml_pt_regs *regs, mcontext_t *mc)
9 #ifdef __i386__
10 #define COPY2(X,Y) regs->gp[X] = mc->gregs[REG_##Y]
11 #define COPY(X) regs->gp[X] = mc->gregs[REG_##X]
12 #define COPY_SEG(X) regs->gp[X] = mc->gregs[REG_##X] & 0xffff;
13 #define COPY_SEG_CPL3(X) regs->gp[X] = (mc->gregs[REG_##X] & 0xffff) | 3;
14 COPY_SEG(GS); COPY_SEG(FS); COPY_SEG(ES); COPY_SEG(DS);
15 COPY(EDI); COPY(ESI); COPY(EBP);
16 COPY2(UESP, ESP); /* sic */
17 COPY(EBX); COPY(EDX); COPY(ECX); COPY(EAX);
18 COPY(EIP); COPY_SEG_CPL3(CS); COPY(EFL); COPY_SEG_CPL3(SS);
19 #else
20 #define COPY2(X,Y) regs->gp[X/sizeof(unsigned long)] = mc->gregs[REG_##Y]
21 #define COPY(X) regs->gp[X/sizeof(unsigned long)] = mc->gregs[REG_##X]
22 COPY(R8); COPY(R9); COPY(R10); COPY(R11);
23 COPY(R12); COPY(R13); COPY(R14); COPY(R15);
24 COPY(RDI); COPY(RSI); COPY(RBP); COPY(RBX);
25 COPY(RDX); COPY(RAX); COPY(RCX); COPY(RSP);
26 COPY(RIP);
27 COPY2(EFLAGS, EFL);
28 COPY2(CS, CSGSFS);
29 regs->gp[CS / sizeof(unsigned long)] &= 0xffff;
30 regs->gp[CS / sizeof(unsigned long)] |= 3;
31 #endif