xref: /qemu/accel/hvf/hvf-all.c (revision f9bb7e53a341d08fd4ec8d7e810ebfd4f6f936bd)
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 "system/hvf.h"
14 #include "system/hvf_int.h"
15 #include "hw/core/cpu.h"
16 
hvf_return_string(hv_return_t ret)17 const char *hvf_return_string(hv_return_t ret)
18 {
19     switch (ret) {
20     case HV_SUCCESS:      return "HV_SUCCESS";
21     case HV_ERROR:        return "HV_ERROR";
22     case HV_BUSY:         return "HV_BUSY";
23     case HV_BAD_ARGUMENT: return "HV_BAD_ARGUMENT";
24     case HV_NO_RESOURCES: return "HV_NO_RESOURCES";
25     case HV_NO_DEVICE:    return "HV_NO_DEVICE";
26     case HV_UNSUPPORTED:  return "HV_UNSUPPORTED";
27     case HV_DENIED:       return "HV_DENIED";
28     default:              return "[unknown hv_return value]";
29     }
30 }
31 
assert_hvf_ok_impl(hv_return_t ret,const char * file,unsigned int line,const char * exp)32 void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
33                         const char *exp)
34 {
35     if (ret == HV_SUCCESS) {
36         return;
37     }
38 
39     error_report("Error: %s = %s (0x%x, at %s:%u)",
40         exp, hvf_return_string(ret), ret, file, line);
41 
42     abort();
43 }
44 
hvf_find_sw_breakpoint(CPUState * cpu,vaddr pc)45 struct hvf_sw_breakpoint *hvf_find_sw_breakpoint(CPUState *cpu, vaddr pc)
46 {
47     struct hvf_sw_breakpoint *bp;
48 
49     QTAILQ_FOREACH(bp, &hvf_state->hvf_sw_breakpoints, entry) {
50         if (bp->pc == pc) {
51             return bp;
52         }
53     }
54     return NULL;
55 }
56 
hvf_sw_breakpoints_active(CPUState * cpu)57 int hvf_sw_breakpoints_active(CPUState *cpu)
58 {
59     return !QTAILQ_EMPTY(&hvf_state->hvf_sw_breakpoints);
60 }
61 
do_hvf_update_guest_debug(CPUState * cpu,run_on_cpu_data arg)62 static void do_hvf_update_guest_debug(CPUState *cpu, run_on_cpu_data arg)
63 {
64     hvf_arch_update_guest_debug(cpu);
65 }
66 
hvf_update_guest_debug(CPUState * cpu)67 int hvf_update_guest_debug(CPUState *cpu)
68 {
69     run_on_cpu(cpu, do_hvf_update_guest_debug, RUN_ON_CPU_NULL);
70     return 0;
71 }
72