xref: /openbmc/qemu/include/sysemu/hvf.h (revision bad5cfcd)
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 "qom/object.h"
18 
19 #ifdef NEED_CPU_H
20 #include "cpu.h"
21 
22 #ifdef CONFIG_HVF
23 uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
24                                  int reg);
25 extern bool hvf_allowed;
26 #define hvf_enabled() (hvf_allowed)
27 #else /* !CONFIG_HVF */
28 #define hvf_enabled() 0
29 #define hvf_get_supported_cpuid(func, idx, reg) 0
30 #endif /* !CONFIG_HVF */
31 
32 #endif /* NEED_CPU_H */
33 
34 #define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
35 
36 typedef struct HVFState HVFState;
37 DECLARE_INSTANCE_CHECKER(HVFState, HVF_STATE,
38                          TYPE_HVF_ACCEL)
39 
40 #ifdef NEED_CPU_H
41 struct hvf_sw_breakpoint {
42     vaddr pc;
43     vaddr saved_insn;
44     int use_count;
45     QTAILQ_ENTRY(hvf_sw_breakpoint) entry;
46 };
47 
48 struct hvf_sw_breakpoint *hvf_find_sw_breakpoint(CPUState *cpu,
49                                                  vaddr pc);
50 int hvf_sw_breakpoints_active(CPUState *cpu);
51 
52 int hvf_arch_insert_sw_breakpoint(CPUState *cpu, struct hvf_sw_breakpoint *bp);
53 int hvf_arch_remove_sw_breakpoint(CPUState *cpu, struct hvf_sw_breakpoint *bp);
54 int hvf_arch_insert_hw_breakpoint(vaddr addr, vaddr len, int type);
55 int hvf_arch_remove_hw_breakpoint(vaddr addr, vaddr len, int type);
56 void hvf_arch_remove_all_hw_breakpoints(void);
57 
58 /*
59  * hvf_update_guest_debug:
60  * @cs: CPUState for the CPU to update
61  *
62  * Update guest to enable or disable debugging. Per-arch specifics will be
63  * handled by calling down to hvf_arch_update_guest_debug.
64  */
65 int hvf_update_guest_debug(CPUState *cpu);
66 void hvf_arch_update_guest_debug(CPUState *cpu);
67 
68 /*
69  * Return whether the guest supports debugging.
70  */
71 bool hvf_arch_supports_guest_debug(void);
72 #endif /* NEED_CPU_H */
73 
74 #endif
75