/* SPDX-License-Identifier: MIT */1/*2* Copyright (c) 2015, Roger Pau Monne <[email protected]>3*/45#ifndef __XEN_PUBLIC_HVM_HVM_VCPU_H__6#define __XEN_PUBLIC_HVM_HVM_VCPU_H__78#include "../xen.h"910struct vcpu_hvm_x86_32 {11uint32_t eax;12uint32_t ecx;13uint32_t edx;14uint32_t ebx;15uint32_t esp;16uint32_t ebp;17uint32_t esi;18uint32_t edi;19uint32_t eip;20uint32_t eflags;2122uint32_t cr0;23uint32_t cr3;24uint32_t cr4;2526uint32_t pad1;2728/*29* EFER should only be used to set the NXE bit (if required)30* when starting a vCPU in 32bit mode with paging enabled or31* to set the LME/LMA bits in order to start the vCPU in32* compatibility mode.33*/34uint64_t efer;3536uint32_t cs_base;37uint32_t ds_base;38uint32_t ss_base;39uint32_t es_base;40uint32_t tr_base;41uint32_t cs_limit;42uint32_t ds_limit;43uint32_t ss_limit;44uint32_t es_limit;45uint32_t tr_limit;46uint16_t cs_ar;47uint16_t ds_ar;48uint16_t ss_ar;49uint16_t es_ar;50uint16_t tr_ar;5152uint16_t pad2[3];53};5455/*56* The layout of the _ar fields of the segment registers is the57* following:58*59* Bits [0,3]: type (bits 40-43).60* Bit 4: s (descriptor type, bit 44).61* Bit [5,6]: dpl (descriptor privilege level, bits 45-46).62* Bit 7: p (segment-present, bit 47).63* Bit 8: avl (available for system software, bit 52).64* Bit 9: l (64-bit code segment, bit 53).65* Bit 10: db (meaning depends on the segment, bit 54).66* Bit 11: g (granularity, bit 55)67* Bits [12,15]: unused, must be blank.68*69* A more complete description of the meaning of this fields can be70* obtained from the Intel SDM, Volume 3, section 3.4.5.71*/7273struct vcpu_hvm_x86_64 {74uint64_t rax;75uint64_t rcx;76uint64_t rdx;77uint64_t rbx;78uint64_t rsp;79uint64_t rbp;80uint64_t rsi;81uint64_t rdi;82uint64_t rip;83uint64_t rflags;8485uint64_t cr0;86uint64_t cr3;87uint64_t cr4;88uint64_t efer;8990/*91* Using VCPU_HVM_MODE_64B implies that the vCPU is launched92* directly in long mode, so the cached parts of the segment93* registers get set to match that environment.94*95* If the user wants to launch the vCPU in compatibility mode96* the 32-bit structure should be used instead.97*/98};99100struct vcpu_hvm_context {101#define VCPU_HVM_MODE_32B 0 /* 32bit fields of the structure will be used. */102#define VCPU_HVM_MODE_64B 1 /* 64bit fields of the structure will be used. */103uint32_t mode;104105uint32_t pad;106107/* CPU registers. */108union {109struct vcpu_hvm_x86_32 x86_32;110struct vcpu_hvm_x86_64 x86_64;111} cpu_regs;112};113typedef struct vcpu_hvm_context vcpu_hvm_context_t;114115#endif /* __XEN_PUBLIC_HVM_HVM_VCPU_H__ */116117118