master
h 114 lines 3.38 KB
Raw
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 "gdbstub/enums.h"
17 #include "qom/object.h"
18 #include "accel/accel-ops.h"
19
20 #ifdef __aarch64__
21 #include <Hypervisor/Hypervisor.h>
22 typedef hv_vcpu_t hvf_vcpuid;
23 #else
24 #include <Hypervisor/hv.h>
25 typedef hv_vcpuid_t hvf_vcpuid;
26 #endif
27
28 typedef struct hvf_vcpu_caps {
29 uint64_t vmx_cap_pinbased;
30 uint64_t vmx_cap_procbased;
31 uint64_t vmx_cap_procbased2;
32 uint64_t vmx_cap_entry;
33 uint64_t vmx_cap_exit;
34 uint64_t vmx_cap_preemption_timer;
35 } hvf_vcpu_caps;
36
37 struct HVFState {
38 AccelState parent_obj;
39
40 hvf_vcpu_caps *hvf_caps;
41 uint64_t vtimer_offset;
42 QTAILQ_HEAD(, hvf_sw_breakpoint) hvf_sw_breakpoints;
43 };
44 extern HVFState *hvf_state;
45
46 struct AccelCPUState {
47 hvf_vcpuid fd;
48 #ifdef __aarch64__
49 hv_vcpu_exit_t *exit;
50 bool vtimer_masked;
51 bool guest_debug_enabled;
52 struct QEMUTimer *wfi_timer;
53 #endif
54 };
55
56 void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
57 const char *exp);
58 #define assert_hvf_ok(EX) assert_hvf_ok_impl((EX), __FILE__, __LINE__, #EX)
59 const char *hvf_return_string(hv_return_t ret);
60 int hvf_arch_init(void);
61 hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range);
62 uint32_t hvf_arch_get_default_ipa_bit_size(void);
63 uint32_t hvf_arch_get_max_ipa_bit_size(void);
64 void hvf_kick_vcpu_thread(CPUState *cpu);
65
66 /* Must be called by the owning thread */
67 int hvf_arch_init_vcpu(CPUState *cpu);
68 /* Must be called by the owning thread */
69 void hvf_arch_vcpu_destroy(CPUState *cpu);
70 /* Must be called by the owning thread */
71 int hvf_arch_vcpu_exec(CPUState *);
72 /* Must be called by the owning thread */
73 int hvf_arch_put_registers(CPUState *);
74 /* Must be called by the owning thread */
75 int hvf_arch_get_registers(CPUState *);
76 /* Must be called by the owning thread */
77 void hvf_arch_update_guest_debug(CPUState *cpu);
78
79 void hvf_protect_clean_range(hwaddr addr, size_t size);
80 void hvf_unprotect_dirty_range(hwaddr addr, size_t size);
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_gdbstub_hw_breakpoint(vaddr addr, vaddr len,
96 GdbBreakpointType type);
97 int hvf_arch_remove_gdbstub_hw_breakpoint(vaddr addr, vaddr len,
98 GdbBreakpointType type);
99 void hvf_arch_remove_all_gdbstub_hw_breakpoints(void);
100
101 /*
102 * hvf_update_guest_debug:
103 * @cs: CPUState for the CPU to update
104 *
105 * Update guest to enable or disable debugging. Per-arch specifics will be
106 * handled by calling down to hvf_arch_update_guest_debug.
107 */
108 int hvf_update_guest_debug(CPUState *cpu);
109
110 bool hvf_arch_cpu_realize(CPUState *cpu, Error **errp);
111 uint32_t hvf_arch_get_default_ipa_bit_size(void);
112 uint32_t hvf_arch_get_max_ipa_bit_size(void);
113
114 #endif