From: Yuan Yao <yuan.yao@xxxxxxxxx> This interface is designed to setup the MemoryRegion::debug_ops. Also introduced 2 wrapper functions for installing/calling the KVMState::set_mr_debug_ops from different targets easily. Signed-off-by: Yuan Yao <yuan.yao@xxxxxxxxx> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index b6d5c9fd7d..1482561bd7 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -129,6 +129,8 @@ struct KVMState KVMMemoryListener *ml; AddressSpace *as; } *as; + + set_memory_region_debug_ops set_mr_debug_ops; }; KVMState *kvm_state; @@ -3157,6 +3159,21 @@ static void kvm_set_kernel_irqchip(Object *obj, Visitor *v, } } +void kvm_setup_memory_region_debug_ops(struct KVMState *s, + set_memory_region_debug_ops new_ops) +{ + if (s) + s->set_mr_debug_ops = new_ops; +} + +void kvm_set_memory_region_debug_ops(void *handle, MemoryRegion *mr) +{ + if (!kvm_state || !kvm_state->set_mr_debug_ops) + return; + + kvm_state->set_mr_debug_ops(handle, mr); +} + bool kvm_kernel_irqchip_allowed(void) { return kvm_state->kernel_irqchip_allowed; diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index 0f17acfac0..f1c57ad8d7 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -148,4 +148,15 @@ bool kvm_arm_supports_user_irq(void) { return false; } + +void kvm_setup_memory_region_debug_ops(struct KVMState *s, + set_memory_region_debug_ops new_ops) +{ + +} + +void kvm_set_memory_region_debug_ops(void *handle, MemoryRegion *mr) +{ + +} #endif diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index a1ab1ee12d..64685cad57 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -547,4 +547,9 @@ bool kvm_cpu_check_are_resettable(void); bool kvm_arch_cpu_check_are_resettable(void); +typedef void (*set_memory_region_debug_ops)(void *handle, MemoryRegion *mr); +void kvm_setup_memory_region_debug_ops(struct KVMState *s, set_memory_region_debug_ops new_ops); + +void kvm_set_memory_region_debug_ops(void *handle, MemoryRegion *mr); + #endif -- 2.20.1