1c97d6d2cSSergio Andres Gomez Del Real /* 2c97d6d2cSSergio Andres Gomez Del Real * QEMU Hypervisor.framework (HVF) support 3c97d6d2cSSergio Andres Gomez Del Real * 4c97d6d2cSSergio Andres Gomez Del Real * Copyright Google Inc., 2017 5c97d6d2cSSergio Andres Gomez Del Real * 6c97d6d2cSSergio Andres Gomez Del Real * This work is licensed under the terms of the GNU GPL, version 2 or later. 7c97d6d2cSSergio Andres Gomez Del Real * See the COPYING file in the top-level directory. 8c97d6d2cSSergio Andres Gomez Del Real * 9c97d6d2cSSergio Andres Gomez Del Real */ 10c97d6d2cSSergio Andres Gomez Del Real 11c97d6d2cSSergio Andres Gomez Del Real /* header to be included in non-HVF-specific code */ 12a8b991b5SMarkus Armbruster 13a8b991b5SMarkus Armbruster #ifndef HVF_H 14a8b991b5SMarkus Armbruster #define HVF_H 15c97d6d2cSSergio Andres Gomez Del Real 16940e43aaSClaudio Fontana #include "qemu/accel.h" 170af34b1dSPhilippe Mathieu-Daudé #include "qemu/queue.h" 180af34b1dSPhilippe Mathieu-Daudé #include "exec/vaddr.h" 19db1015e9SEduardo Habkost #include "qom/object.h" 20d48ad737SEduardo Habkost 217d7a21baSPhilippe Mathieu-Daudé #ifdef COMPILING_PER_TARGET 22c97d6d2cSSergio Andres Gomez Del Real # ifdef CONFIG_HVF 23*962f9f18SPhilippe Mathieu-Daudé # define CONFIG_HVF_IS_POSSIBLE 24*962f9f18SPhilippe Mathieu-Daudé # endif /* !CONFIG_HVF */ 25*962f9f18SPhilippe Mathieu-Daudé #else 26*962f9f18SPhilippe Mathieu-Daudé # define CONFIG_HVF_IS_POSSIBLE 27*962f9f18SPhilippe Mathieu-Daudé #endif /* COMPILING_PER_TARGET */ 28*962f9f18SPhilippe Mathieu-Daudé 29*962f9f18SPhilippe Mathieu-Daudé #ifdef CONFIG_HVF_IS_POSSIBLE 30f291cf54SPhilippe Mathieu-Daudé extern bool hvf_allowed; 3192cc3aaaSRoman Bolshakov #define hvf_enabled() (hvf_allowed) 32*962f9f18SPhilippe Mathieu-Daudé #else /* !CONFIG_HVF_IS_POSSIBLE */ 33c97d6d2cSSergio Andres Gomez Del Real #define hvf_enabled() 0 34*962f9f18SPhilippe Mathieu-Daudé #endif /* !CONFIG_HVF_IS_POSSIBLE */ 3513b48fb0SThomas Huth 36c97d6d2cSSergio Andres Gomez Del Real #define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf") 37c97d6d2cSSergio Andres Gomez Del Real 383932885aSEduardo Habkost typedef struct HVFState HVFState; 398110fa1dSEduardo Habkost DECLARE_INSTANCE_CHECKER(HVFState, HVF_STATE, 408110fa1dSEduardo Habkost TYPE_HVF_ACCEL) 41c97d6d2cSSergio Andres Gomez Del Real 427d7a21baSPhilippe Mathieu-Daudé #ifdef COMPILING_PER_TARGET 43f4152040SFrancesco Cagnin struct hvf_sw_breakpoint { 44fcfe7616SAnton Johansson vaddr pc; 45fcfe7616SAnton Johansson vaddr saved_insn; 46f4152040SFrancesco Cagnin int use_count; 47f4152040SFrancesco Cagnin QTAILQ_ENTRY(hvf_sw_breakpoint) entry; 48f4152040SFrancesco Cagnin }; 49f4152040SFrancesco Cagnin 50f4152040SFrancesco Cagnin struct hvf_sw_breakpoint *hvf_find_sw_breakpoint(CPUState *cpu, 51fcfe7616SAnton Johansson vaddr pc); 52f4152040SFrancesco Cagnin int hvf_sw_breakpoints_active(CPUState *cpu); 53f4152040SFrancesco Cagnin 54f4152040SFrancesco Cagnin int hvf_arch_insert_sw_breakpoint(CPUState *cpu, struct hvf_sw_breakpoint *bp); 55f4152040SFrancesco Cagnin int hvf_arch_remove_sw_breakpoint(CPUState *cpu, struct hvf_sw_breakpoint *bp); 56d447a624SAnton Johansson int hvf_arch_insert_hw_breakpoint(vaddr addr, vaddr len, int type); 57d447a624SAnton Johansson int hvf_arch_remove_hw_breakpoint(vaddr addr, vaddr len, int type); 58f4152040SFrancesco Cagnin void hvf_arch_remove_all_hw_breakpoints(void); 59eb2edc42SFrancesco Cagnin 60eb2edc42SFrancesco Cagnin /* 61eb2edc42SFrancesco Cagnin * hvf_update_guest_debug: 62eb2edc42SFrancesco Cagnin * @cs: CPUState for the CPU to update 63eb2edc42SFrancesco Cagnin * 64eb2edc42SFrancesco Cagnin * Update guest to enable or disable debugging. Per-arch specifics will be 65eb2edc42SFrancesco Cagnin * handled by calling down to hvf_arch_update_guest_debug. 66eb2edc42SFrancesco Cagnin */ 67eb2edc42SFrancesco Cagnin int hvf_update_guest_debug(CPUState *cpu); 68eb2edc42SFrancesco Cagnin void hvf_arch_update_guest_debug(CPUState *cpu); 69eb2edc42SFrancesco Cagnin 70eb2edc42SFrancesco Cagnin /* 71eb2edc42SFrancesco Cagnin * Return whether the guest supports debugging. 72eb2edc42SFrancesco Cagnin */ 73eb2edc42SFrancesco Cagnin bool hvf_arch_supports_guest_debug(void); 747d7a21baSPhilippe Mathieu-Daudé #endif /* COMPILING_PER_TARGET */ 75f4152040SFrancesco Cagnin 76c97d6d2cSSergio Andres Gomez Del Real #endif 77