akaros/kern/arch/x86/ros/trapframe64.h
<<
>>
Prefs
   1#pragma once
   2
   3#ifndef ROS_INC_ARCH_TRAPFRAME_H
   4#error "Do not include include ros/arch/trapframe64.h directly"
   5#endif
   6
   7struct hw_trapframe {
   8        uint64_t tf_gsbase;
   9        uint64_t tf_fsbase;
  10        uint64_t tf_rax;
  11        uint64_t tf_rbx;
  12        uint64_t tf_rcx;
  13        uint64_t tf_rdx;
  14        uint64_t tf_rbp;
  15        uint64_t tf_rsi;
  16        uint64_t tf_rdi;
  17        uint64_t tf_r8;
  18        uint64_t tf_r9;
  19        uint64_t tf_r10;
  20        uint64_t tf_r11;
  21        uint64_t tf_r12;
  22        uint64_t tf_r13;
  23        uint64_t tf_r14;
  24        uint64_t tf_r15;
  25        uint32_t tf_trapno;
  26        uint32_t tf_padding5;           /* used in trap reflection */
  27        /* below here defined by x86 hardware (error code optional) */
  28        uint32_t tf_err;
  29        uint32_t tf_padding4;           /* used in trap reflection */
  30        uint64_t tf_rip;
  31        uint16_t tf_cs;
  32        uint16_t tf_padding3;           /* used in trap reflection */
  33        uint32_t tf_padding2;
  34        uint64_t tf_rflags;
  35        /* unlike 32 bit, SS:RSP is always pushed, even when not changing rings
  36         */
  37        uint64_t tf_rsp;
  38        uint16_t tf_ss;
  39        uint16_t tf_padding1;
  40        uint32_t tf_padding0;           /* used for partial contexts */
  41};
  42
  43struct sw_trapframe {
  44        uint64_t tf_gsbase;
  45        uint64_t tf_fsbase;
  46        uint64_t tf_rbx;
  47        uint64_t tf_rbp;
  48        uint64_t tf_r12;
  49        uint64_t tf_r13;
  50        uint64_t tf_r14;
  51        uint64_t tf_r15;
  52        uint64_t tf_rip;
  53        uint64_t tf_rsp;
  54        uint32_t tf_mxcsr;
  55        uint16_t tf_fpucw;
  56        uint16_t tf_padding0;           /* used for partial contexts */
  57};
  58
  59#define MXCSR_RSVD_0    0xffff  // These 0s must be 0, mxcsr &= this
  60
  61/* The context is both what we want to run and its current state.  For VMs, that
  62 * includes status bits from the VMCS for reflected vmexits/hypercalls.  This is
  63 * not particularly different than how hardware contexts contain info on
  64 * reflected traps.
  65 *
  66 * The VM context also consists of a mountain of state in the VMCS, referenced
  67 * only in here by guest pcoreid.  Those bits are set once by Akaros to sensible
  68 * defaults and then are changed during execution of the VM.  The parts of that
  69 * state that are exposed to the user-VMM are the contents of the trapframe.
  70 *
  71 * Before adding any new flags, consider whether or not they need to be checked
  72 * in proc_secure_vmtf(). */
  73
  74#define VMCTX_FL_PARTIAL                (1 << 0)
  75#define VMCTX_FL_HAS_FAULT              (1 << 1)
  76#define VMCTX_FL_VMRESUME               (1 << 2)
  77#define VMCTX_FL_EPT_VMR_BACKED (1 << 3)
  78
  79struct vm_trapframe {
  80        /* Actual processor state */
  81        uint64_t tf_rax;
  82        uint64_t tf_rbx;
  83        uint64_t tf_rcx;
  84        uint64_t tf_rdx;
  85        uint64_t tf_rbp;
  86        uint64_t tf_rsi;
  87        uint64_t tf_rdi;
  88        uint64_t tf_r8;
  89        uint64_t tf_r9;
  90        uint64_t tf_r10;
  91        uint64_t tf_r11;
  92        uint64_t tf_r12;
  93        uint64_t tf_r13;
  94        uint64_t tf_r14;
  95        uint64_t tf_r15;
  96        uint64_t tf_rip;
  97        uint64_t tf_rflags;
  98        uint64_t tf_rsp;
  99        uint64_t tf_cr2;
 100        uint64_t tf_cr3;
 101        /* Admin bits */
 102        uint32_t tf_guest_pcoreid;
 103        uint32_t tf_flags;
 104        uint32_t tf_trap_inject;
 105        uint16_t tf_guest_intr_status;
 106        uint16_t tf_padding0;
 107        uint32_t tf_exit_reason;
 108        uint32_t tf_exit_qual;
 109        uint32_t tf_intrinfo1;
 110        uint32_t tf_intrinfo2;
 111        uint64_t tf_guest_va;
 112        uint64_t tf_guest_pa;
 113};
 114