LCOV - code coverage report
Current view: top level - arch/x86/um/os-Linux - mcontext.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 11 100.0 %
Date: 2023-04-06 08:38:28 Functions: 1 1 100.0 %

          Line data    Source code
       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             : 
       7        2749 : void get_regs_from_mc(struct uml_pt_regs *regs, mcontext_t *mc)
       8             : {
       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        2749 :         COPY(R8); COPY(R9); COPY(R10); COPY(R11);
      23        2749 :         COPY(R12); COPY(R13); COPY(R14); COPY(R15);
      24        2749 :         COPY(RDI); COPY(RSI); COPY(RBP); COPY(RBX);
      25        2749 :         COPY(RDX); COPY(RAX); COPY(RCX); COPY(RSP);
      26        2749 :         COPY(RIP);
      27        2749 :         COPY2(EFLAGS, EFL);
      28        2749 :         COPY2(CS, CSGSFS);
      29        2749 :         regs->gp[CS / sizeof(unsigned long)] &= 0xffff;
      30        2749 :         regs->gp[CS / sizeof(unsigned long)] |= 3;
      31             : #endif
      32        2749 : }

Generated by: LCOV version 1.14