From d92b1063caf940534795fcf56b5be619e82e0289 Mon Sep 17 00:00:00 2001 From: Alexandro Sanchez Bach Date: Sun, 18 Nov 2018 13:51:10 +0100 Subject: [PATCH] Moved VMX-specific definitions to vmx.h - Moved vcpu_vmx_data and interruptibility_state_t from {vcpu,vcpu_state}.h to vmx.h. - Removed vcpu_state_t::interruptibility_state_t since it's not used. Signed-off-by: Alexandro Sanchez Bach --- core/include/vcpu.h | 34 ------------------------------ core/include/vmx.h | 50 ++++++++++++++++++++++++++++++++++++++++++++ include/vcpu_state.h | 15 ------------- 3 files changed, 50 insertions(+), 49 deletions(-) diff --git a/core/include/vcpu.h b/core/include/vcpu.h index dd81a272..325b6daf 100644 --- a/core/include/vcpu.h +++ b/core/include/vcpu.h @@ -68,40 +68,6 @@ struct cvtlb { struct hax_mmu; struct per_cpu_data; -struct vcpu_vmx_data { - uint32_t pin_ctls_base; - uint32_t pcpu_ctls_base; - uint32_t scpu_ctls_base; - uint32_t entry_ctls_base; - uint32_t exc_bitmap_base; - uint32_t exit_ctls_base; - - uint32_t pin_ctls; - uint32_t pcpu_ctls; - uint32_t scpu_ctls; - uint32_t entry_ctls; - uint32_t exc_bitmap; - uint32_t exit_ctls; - - uint64_t cr0_mask, cr0_shadow; - uint64_t cr4_mask, cr4_shadow; - uint32_t entry_exception_vector; - uint32_t entry_exception_error_code; - - uint32_t exit_exception_error_code; - interruption_info_t exit_intr_info; - interruption_info_t entry_intr_info; - uint32_t exit_idt_vectoring; - uint32_t exit_instr_length; - uint32_t entry_instr_length; - - exit_reason_t exit_reason; - exit_qualification_t exit_qualification; - interruptibility_state_t interruptibility_state; - - uint64_t exit_gpa; -}; - /* Information saved by instruction decoder and used by post-MMIO handler */ struct vcpu_post_mmio { enum { diff --git a/core/include/vmx.h b/core/include/vmx.h index 70e350a1..7b7170e8 100644 --- a/core/include/vmx.h +++ b/core/include/vmx.h @@ -102,6 +102,7 @@ enum { VMX_EXIT_XRSTORS = 64 }; +// Intel SDM Vol. 3D: Appendix B: Field Encoding in VMCS enum component_index_t { VMX_PIN_CONTROLS = 0x00004000, VMX_PRIMARY_PROCESSOR_CONTROLS = 0x00004002, @@ -467,6 +468,21 @@ union instruction_info_t { typedef union instruction_info_t instruction_info_t; +// Intel SDM Vol. 3C: Table 24-3. Format of Interruptibility State +union interruptibility_state_t { + uint32_t raw; + struct { + uint32_t sti_blocking : 1; + uint32_t movss_blocking : 1; + uint32_t smi_blocking : 1; + uint32_t nmi_blocking : 1; + uint32_t reserved : 28; + }; + uint64_t pad; +} PACKED; + +typedef union interruptibility_state_t interruptibility_state_t; + // 64-bit OK union interruption_info_t { uint32_t raw; @@ -636,6 +652,40 @@ struct invept_desc { struct vcpu_state_t; struct vcpu_t; +struct vcpu_vmx_data { + uint32_t pin_ctls_base; + uint32_t pcpu_ctls_base; + uint32_t scpu_ctls_base; + uint32_t entry_ctls_base; + uint32_t exc_bitmap_base; + uint32_t exit_ctls_base; + + uint32_t pin_ctls; + uint32_t pcpu_ctls; + uint32_t scpu_ctls; + uint32_t entry_ctls; + uint32_t exc_bitmap; + uint32_t exit_ctls; + + uint64_t cr0_mask, cr0_shadow; + uint64_t cr4_mask, cr4_shadow; + uint32_t entry_exception_vector; + uint32_t entry_exception_error_code; + + uint32_t exit_exception_error_code; + interruption_info_t exit_intr_info; + interruption_info_t entry_intr_info; + uint32_t exit_idt_vectoring; + uint32_t exit_instr_length; + uint32_t entry_instr_length; + + exit_reason_t exit_reason; + exit_qualification_t exit_qualification; + interruptibility_state_t interruptibility_state; + + uint64_t exit_gpa; +}; + vmx_result_t ASMCALL asm_invept(uint type, struct invept_desc *desc); vmx_result_t ASMCALL asm_vmclear(const paddr_t *addr_in); vmx_result_t ASMCALL asm_vmptrld(const paddr_t *addr_in); diff --git a/include/vcpu_state.h b/include/vcpu_state.h index e4507066..d42c862e 100644 --- a/include/vcpu_state.h +++ b/include/vcpu_state.h @@ -31,20 +31,6 @@ #ifndef HAX_VCPU_STATE_H_ #define HAX_VCPU_STATE_H_ -union interruptibility_state_t { - uint32_t raw; - struct { - uint32_t sti_blocking : 1; - uint32_t movss_blocking : 1; - uint32_t smi_blocking : 1; - uint32_t nmi_blocking : 1; - uint32_t reserved : 28; - }; - uint64_t pad; -} PACKED; - -typedef union interruptibility_state_t interruptibility_state_t; - // Segment descriptor struct segment_desc_t { uint16_t selector; @@ -187,7 +173,6 @@ struct vcpu_state_t { uint32_t _activity_state; uint32_t pad; - interruptibility_state_t _interruptibility_state; } PACKED; void dump(void);