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-07-19 18:55:55 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        2938 : 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        2938 :         COPY(R8); COPY(R9); COPY(R10); COPY(R11);
      23        2938 :         COPY(R12); COPY(R13); COPY(R14); COPY(R15);
      24        2938 :         COPY(RDI); COPY(RSI); COPY(RBP); COPY(RBX);
      25        2938 :         COPY(RDX); COPY(RAX); COPY(RCX); COPY(RSP);
      26        2938 :         COPY(RIP);
      27        2938 :         COPY2(EFLAGS, EFL);
      28        2938 :         COPY2(CS, CSGSFS);
      29        2938 :         regs->gp[CS / sizeof(unsigned long)] &= 0xffff;
      30        2938 :         regs->gp[CS / sizeof(unsigned long)] |= 3;
      31             : #endif
      32        2938 : }

Generated by: LCOV version 1.14