xref: /qemu/include/system/hvf.h (revision af3ca6e7f09d8ed0e8c9a3fff55d7a68b5019033)
1 /*
2  * QEMU Hypervisor.framework (HVF) support
3  *
4  * Copyright Google Inc., 2017
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  *
9  */
10 
11 /* header to be included in non-HVF-specific code */
12 
13 #ifndef HVF_H
14 #define HVF_H
15 
16 #include "qemu/accel.h"
17 #include "qemu/queue.h"
18 #include "exec/vaddr.h"
19 #include "qom/object.h"
20 #include "exec/vaddr.h"
21 
22 #ifdef COMPILING_PER_TARGET
23 # ifdef CONFIG_HVF
24 #  define CONFIG_HVF_IS_POSSIBLE
25 # endif /* !CONFIG_HVF */
26 #else
27 # define CONFIG_HVF_IS_POSSIBLE
28 #endif /* COMPILING_PER_TARGET */
29 
30 #ifdef CONFIG_HVF_IS_POSSIBLE
31 extern bool hvf_allowed;
32 #define hvf_enabled() (hvf_allowed)
33 #else /* !CONFIG_HVF_IS_POSSIBLE */
34 #define hvf_enabled() 0
35 #endif /* !CONFIG_HVF_IS_POSSIBLE */
36 
37 #define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
38 
39 typedef struct HVFState HVFState;
40 DECLARE_INSTANCE_CHECKER(HVFState, HVF_STATE,
41                          TYPE_HVF_ACCEL)
42 
43 #ifdef COMPILING_PER_TARGET
44 struct hvf_sw_breakpoint {
45     vaddr pc;
46     vaddr saved_insn;
47     int use_count;
48     QTAILQ_ENTRY(hvf_sw_breakpoint) entry;
49 };
50 
51 struct hvf_sw_breakpoint *hvf_find_sw_breakpoint(CPUState *cpu,
52                                                  vaddr pc);
53 int hvf_sw_breakpoints_active(CPUState *cpu);
54 
55 int hvf_arch_insert_sw_breakpoint(CPUState *cpu, struct hvf_sw_breakpoint *bp);
56 int hvf_arch_remove_sw_breakpoint(CPUState *cpu, struct hvf_sw_breakpoint *bp);
57 int hvf_arch_insert_hw_breakpoint(vaddr addr, vaddr len, int type);
58 int hvf_arch_remove_hw_breakpoint(vaddr addr, vaddr len, int type);
59 void hvf_arch_remove_all_hw_breakpoints(void);
60 
61 /*
62  * hvf_update_guest_debug:
63  * @cs: CPUState for the CPU to update
64  *
65  * Update guest to enable or disable debugging. Per-arch specifics will be
66  * handled by calling down to hvf_arch_update_guest_debug.
67  */
68 int hvf_update_guest_debug(CPUState *cpu);
69 void hvf_arch_update_guest_debug(CPUState *cpu);
70 
71 /*
72  * Return whether the guest supports debugging.
73  */
74 bool hvf_arch_supports_guest_debug(void);
75 #endif /* COMPILING_PER_TARGET */
76 
77 #endif
78