1 /* 2 * QEMU Hypervisor.framework (HVF) support 3 * 4 * This work is licensed under the terms of the GNU GPL, version 2 or later. 5 * See the COPYING file in the top-level directory. 6 * 7 */ 8 9 /* header to be included in HVF-specific code */ 10 11 #ifndef HVF_INT_H 12 #define HVF_INT_H 13 14 #include "qemu/queue.h" 15 #include "exec/vaddr.h" 16 #include "qom/object.h" 17 18 #ifdef __aarch64__ 19 #include <Hypervisor/Hypervisor.h> 20 typedef hv_vcpu_t hvf_vcpuid; 21 #else 22 #include <Hypervisor/hv.h> 23 typedef hv_vcpuid_t hvf_vcpuid; 24 #endif 25 26 /* hvf_slot flags */ 27 #define HVF_SLOT_LOG (1 << 0) 28 29 typedef struct hvf_slot { 30 uint64_t start; 31 uint64_t size; 32 uint8_t *mem; 33 int slot_id; 34 uint32_t flags; 35 MemoryRegion *region; 36 } hvf_slot; 37 38 typedef struct hvf_vcpu_caps { 39 uint64_t vmx_cap_pinbased; 40 uint64_t vmx_cap_procbased; 41 uint64_t vmx_cap_procbased2; 42 uint64_t vmx_cap_entry; 43 uint64_t vmx_cap_exit; 44 uint64_t vmx_cap_preemption_timer; 45 } hvf_vcpu_caps; 46 47 struct HVFState { 48 AccelState parent; 49 50 hvf_slot slots[32]; 51 int num_slots; 52 53 hvf_vcpu_caps *hvf_caps; 54 uint64_t vtimer_offset; 55 QTAILQ_HEAD(, hvf_sw_breakpoint) hvf_sw_breakpoints; 56 }; 57 extern HVFState *hvf_state; 58 59 struct AccelCPUState { 60 hvf_vcpuid fd; 61 void *exit; 62 bool vtimer_masked; 63 sigset_t unblock_ipi_mask; 64 bool guest_debug_enabled; 65 bool dirty; 66 }; 67 68 void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line, 69 const char *exp); 70 #define assert_hvf_ok(EX) assert_hvf_ok_impl((EX), __FILE__, __LINE__, #EX) 71 const char *hvf_return_string(hv_return_t ret); 72 int hvf_arch_init(void); 73 hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range); 74 int hvf_arch_init_vcpu(CPUState *cpu); 75 void hvf_arch_vcpu_destroy(CPUState *cpu); 76 int hvf_vcpu_exec(CPUState *); 77 hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t); 78 int hvf_put_registers(CPUState *); 79 int hvf_get_registers(CPUState *); 80 void hvf_kick_vcpu_thread(CPUState *cpu); 81 82 struct hvf_sw_breakpoint { 83 vaddr pc; 84 vaddr saved_insn; 85 int use_count; 86 QTAILQ_ENTRY(hvf_sw_breakpoint) entry; 87 }; 88 89 struct hvf_sw_breakpoint *hvf_find_sw_breakpoint(CPUState *cpu, 90 vaddr pc); 91 int hvf_sw_breakpoints_active(CPUState *cpu); 92 93 int hvf_arch_insert_sw_breakpoint(CPUState *cpu, struct hvf_sw_breakpoint *bp); 94 int hvf_arch_remove_sw_breakpoint(CPUState *cpu, struct hvf_sw_breakpoint *bp); 95 int hvf_arch_insert_hw_breakpoint(vaddr addr, vaddr len, int type); 96 int hvf_arch_remove_hw_breakpoint(vaddr addr, vaddr len, int type); 97 void hvf_arch_remove_all_hw_breakpoints(void); 98 99 /* 100 * hvf_update_guest_debug: 101 * @cs: CPUState for the CPU to update 102 * 103 * Update guest to enable or disable debugging. Per-arch specifics will be 104 * handled by calling down to hvf_arch_update_guest_debug. 105 */ 106 int hvf_update_guest_debug(CPUState *cpu); 107 void hvf_arch_update_guest_debug(CPUState *cpu); 108 109 /* 110 * Return whether the guest supports debugging. 111 */ 112 bool hvf_arch_supports_guest_debug(void); 113 114 #endif 115