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" 20*af3ca6e7SPierrick Bouvier #include "exec/vaddr.h" 21d48ad737SEduardo Habkost 227d7a21baSPhilippe Mathieu-Daudé #ifdef COMPILING_PER_TARGET 23c97d6d2cSSergio Andres Gomez Del Real # ifdef CONFIG_HVF 24962f9f18SPhilippe Mathieu-Daudé # define CONFIG_HVF_IS_POSSIBLE 25962f9f18SPhilippe Mathieu-Daudé # endif /* !CONFIG_HVF */ 26962f9f18SPhilippe Mathieu-Daudé #else 27962f9f18SPhilippe Mathieu-Daudé # define CONFIG_HVF_IS_POSSIBLE 28962f9f18SPhilippe Mathieu-Daudé #endif /* COMPILING_PER_TARGET */ 29962f9f18SPhilippe Mathieu-Daudé 30962f9f18SPhilippe Mathieu-Daudé #ifdef CONFIG_HVF_IS_POSSIBLE 31f291cf54SPhilippe Mathieu-Daudé extern bool hvf_allowed; 3292cc3aaaSRoman Bolshakov #define hvf_enabled() (hvf_allowed) 33962f9f18SPhilippe Mathieu-Daudé #else /* !CONFIG_HVF_IS_POSSIBLE */ 34c97d6d2cSSergio Andres Gomez Del Real #define hvf_enabled() 0 35962f9f18SPhilippe Mathieu-Daudé #endif /* !CONFIG_HVF_IS_POSSIBLE */ 3613b48fb0SThomas Huth 37c97d6d2cSSergio Andres Gomez Del Real #define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf") 38c97d6d2cSSergio Andres Gomez Del Real 393932885aSEduardo Habkost typedef struct HVFState HVFState; 408110fa1dSEduardo Habkost DECLARE_INSTANCE_CHECKER(HVFState, HVF_STATE, 418110fa1dSEduardo Habkost TYPE_HVF_ACCEL) 42c97d6d2cSSergio Andres Gomez Del Real 437d7a21baSPhilippe Mathieu-Daudé #ifdef COMPILING_PER_TARGET 44f4152040SFrancesco Cagnin struct hvf_sw_breakpoint { 45fcfe7616SAnton Johansson vaddr pc; 46fcfe7616SAnton Johansson vaddr saved_insn; 47f4152040SFrancesco Cagnin int use_count; 48f4152040SFrancesco Cagnin QTAILQ_ENTRY(hvf_sw_breakpoint) entry; 49f4152040SFrancesco Cagnin }; 50f4152040SFrancesco Cagnin 51f4152040SFrancesco Cagnin struct hvf_sw_breakpoint *hvf_find_sw_breakpoint(CPUState *cpu, 52fcfe7616SAnton Johansson vaddr pc); 53f4152040SFrancesco Cagnin int hvf_sw_breakpoints_active(CPUState *cpu); 54f4152040SFrancesco Cagnin 55f4152040SFrancesco Cagnin int hvf_arch_insert_sw_breakpoint(CPUState *cpu, struct hvf_sw_breakpoint *bp); 56f4152040SFrancesco Cagnin int hvf_arch_remove_sw_breakpoint(CPUState *cpu, struct hvf_sw_breakpoint *bp); 57d447a624SAnton Johansson int hvf_arch_insert_hw_breakpoint(vaddr addr, vaddr len, int type); 58d447a624SAnton Johansson int hvf_arch_remove_hw_breakpoint(vaddr addr, vaddr len, int type); 59f4152040SFrancesco Cagnin void hvf_arch_remove_all_hw_breakpoints(void); 60eb2edc42SFrancesco Cagnin 61eb2edc42SFrancesco Cagnin /* 62eb2edc42SFrancesco Cagnin * hvf_update_guest_debug: 63eb2edc42SFrancesco Cagnin * @cs: CPUState for the CPU to update 64eb2edc42SFrancesco Cagnin * 65eb2edc42SFrancesco Cagnin * Update guest to enable or disable debugging. Per-arch specifics will be 66eb2edc42SFrancesco Cagnin * handled by calling down to hvf_arch_update_guest_debug. 67eb2edc42SFrancesco Cagnin */ 68eb2edc42SFrancesco Cagnin int hvf_update_guest_debug(CPUState *cpu); 69eb2edc42SFrancesco Cagnin void hvf_arch_update_guest_debug(CPUState *cpu); 70eb2edc42SFrancesco Cagnin 71eb2edc42SFrancesco Cagnin /* 72eb2edc42SFrancesco Cagnin * Return whether the guest supports debugging. 73eb2edc42SFrancesco Cagnin */ 74eb2edc42SFrancesco Cagnin bool hvf_arch_supports_guest_debug(void); 757d7a21baSPhilippe Mathieu-Daudé #endif /* COMPILING_PER_TARGET */ 76f4152040SFrancesco Cagnin 77c97d6d2cSSergio Andres Gomez Del Real #endif 78