xref: /openbmc/qemu/accel/hvf/hvf-all.c (revision ce7325c1)
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 
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 #if defined(MAC_OS_VERSION_11_0) && \
27     MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
28     case HV_DENIED:       return "HV_DENIED";
29 #endif
30     default:              return "[unknown hv_return value]";
31     }
32 }
33 
34 void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
35                         const char *exp)
36 {
37     if (ret == HV_SUCCESS) {
38         return;
39     }
40 
41     error_report("Error: %s = %s (0x%x, at %s:%u)",
42         exp, hvf_return_string(ret), ret, file, line);
43 
44     abort();
45 }
46 
47 struct hvf_sw_breakpoint *hvf_find_sw_breakpoint(CPUState *cpu, vaddr pc)
48 {
49     struct hvf_sw_breakpoint *bp;
50 
51     QTAILQ_FOREACH(bp, &hvf_state->hvf_sw_breakpoints, entry) {
52         if (bp->pc == pc) {
53             return bp;
54         }
55     }
56     return NULL;
57 }
58 
59 int hvf_sw_breakpoints_active(CPUState *cpu)
60 {
61     return !QTAILQ_EMPTY(&hvf_state->hvf_sw_breakpoints);
62 }
63 
64 int hvf_update_guest_debug(CPUState *cpu)
65 {
66     hvf_arch_update_guest_debug(cpu);
67     return 0;
68 }
69