1 /*
2 * QEMU Hypervisor.framework support
3 *
4 * This work is licensed under the terms of the GNU GPL, version 2. See
5 * the COPYING file in the top-level directory.
6 *
7 * Contributions after 2012-01-13 are licensed under the terms of the
8 * GNU GPL, version 2 or (at your option) any later version.
9 */
10
11 #include "qemu/osdep.h"
12 #include "qemu/error-report.h"
13 #include "sysemu/hvf.h"
14 #include "sysemu/hvf_int.h"
15
hvf_return_string(hv_return_t ret)16 const char *hvf_return_string(hv_return_t ret)
17 {
18 switch (ret) {
19 case HV_SUCCESS: return "HV_SUCCESS";
20 case HV_ERROR: return "HV_ERROR";
21 case HV_BUSY: return "HV_BUSY";
22 case HV_BAD_ARGUMENT: return "HV_BAD_ARGUMENT";
23 case HV_NO_RESOURCES: return "HV_NO_RESOURCES";
24 case HV_NO_DEVICE: return "HV_NO_DEVICE";
25 case HV_UNSUPPORTED: return "HV_UNSUPPORTED";
26 case HV_DENIED: return "HV_DENIED";
27 default: return "[unknown hv_return value]";
28 }
29 }
30
assert_hvf_ok_impl(hv_return_t ret,const char * file,unsigned int line,const char * exp)31 void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
32 const char *exp)
33 {
34 if (ret == HV_SUCCESS) {
35 return;
36 }
37
38 error_report("Error: %s = %s (0x%x, at %s:%u)",
39 exp, hvf_return_string(ret), ret, file, line);
40
41 abort();
42 }
43
hvf_find_sw_breakpoint(CPUState * cpu,vaddr pc)44 struct hvf_sw_breakpoint *hvf_find_sw_breakpoint(CPUState *cpu, vaddr pc)
45 {
46 struct hvf_sw_breakpoint *bp;
47
48 QTAILQ_FOREACH(bp, &hvf_state->hvf_sw_breakpoints, entry) {
49 if (bp->pc == pc) {
50 return bp;
51 }
52 }
53 return NULL;
54 }
55
hvf_sw_breakpoints_active(CPUState * cpu)56 int hvf_sw_breakpoints_active(CPUState *cpu)
57 {
58 return !QTAILQ_EMPTY(&hvf_state->hvf_sw_breakpoints);
59 }
60
hvf_update_guest_debug(CPUState * cpu)61 int hvf_update_guest_debug(CPUState *cpu)
62 {
63 hvf_arch_update_guest_debug(cpu);
64 return 0;
65 }
66