target/arm: kvm64: remove a redundant KVM_CAP_SET_GUEST_DEBUG probe
PATCH 1/1 target/arm: kvm64: remove a redundant KVM_CAP_SET_GUEST_DEBUG probe
The KVM_CAP_SET_GUEST_DEBUG is probed during kvm_init(). gdbserver will fail to start if the CAP is not supported. So no need to make another probe here, like other targets.
--- target/arm/kvm64.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-)
target/arm/kvm64.c +7 -21
@@ -31,13 +31,9 @@#include "hw/acpi/acpi.h" #include "hw/acpi/ghes.h" -static bool have_guest_debug;void kvm_arm_init_debug (KVMState *s) { - have_guest_debug =kvm_check_extension (s, -KVM_CAP_SET_GUEST_DEBUG ); - max_hw_wps =kvm_check_extension (s,KVM_CAP_GUEST_DEBUG_HW_WPS ); hw_watchpoints =g_array_sized_new (true, true,sizeof (HWWatchpoint), max_hw_wps);
@@ -1140,33 +1136,23 @@ static const uint32_t brk_insn = 0xd4200000;int kvm_arch_insert_sw_breakpoint (CPUState *cs,struct kvm_sw_breakpoint *bp) { -if (have_guest_debug) { -if (cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&bp->saved_insn,4 ,0 ) || -cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&brk_insn,4 ,1 )) { -return -EINVAL ; - } -return 0 ; - }else { -error_report ("guest debug not supported on this kernel" ); +if (cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&bp->saved_insn,4 ,0 ) || +cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&brk_insn,4 ,1 )) {return -EINVAL ; } +return 0 ; }int kvm_arch_remove_sw_breakpoint (CPUState *cs,struct kvm_sw_breakpoint *bp) {static uint32_t brk; -if (have_guest_debug) { -if (cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&brk,4 ,0 ) || - brk != brk_insn || -cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&bp->saved_insn,4 ,1 )) { -return -EINVAL ; - } -return 0 ; - }else { -error_report ("guest debug not supported on this kernel" ); +if (cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&brk,4 ,0 ) || + brk != brk_insn || +cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&bp->saved_insn,4 ,1 )) {return -EINVAL ; } +return 0 ; }/* See v8 ARM ARM D7.2.27 ESR_ELx, Exception Syndrome Register
Signature · 1 line
2.17.1
Hi,
Kindly ping. :)
Thanks,
Chao
Quoted 72 lines
-----Original Messages-----From:"Chao Du" <[email protected]>Sent Time:2023-10-25 15:07:26 (Wednesday)To:[email protected], [email protected]:Subject:[PATCH] target/arm: kvm64: remove a redundant
KVM_CAP_SET_GUEST_DEBUGprobeThe
KVM_CAP_SET_GUEST_DEBUGis probed duringkvm_init(). gdbserver will fail to start if the CAP is not supported. So no need to make another probe here, like other targets.Signed-off-by Chao Du <[email protected]>--- target/arm/kvm64.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-)target/arm/kvm64.c +7
-21@@ -31,13 +31,9 @@#include "hw/acpi/acpi.h" #include "hw/acpi/ghes.h" -static bool have_guest_debug;void kvm_arm_init_debug (KVMState *s) { - have_guest_debug =kvm_check_extension (s, -KVM_CAP_SET_GUEST_DEBUG ); - max_hw_wps =kvm_check_extension (s,KVM_CAP_GUEST_DEBUG_HW_WPS ); hw_watchpoints =g_array_sized_new (true, true,sizeof (HWWatchpoint), max_hw_wps);@@ -1140,33 +1136,23 @@ static const uint32_t brk_insn = 0xd4200000;int kvm_arch_insert_sw_breakpoint (CPUState *cs,struct kvm_sw_breakpoint *bp) { -if (have_guest_debug) { -if (cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&bp->saved_insn,4 ,0 ) || -cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&brk_insn,4 ,1 )) { -return -EINVAL ; - } -return 0 ; - }else { -error_report ("guest debug not supported on this kernel" ); +if (cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&bp->saved_insn,4 ,0 ) || +cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&brk_insn,4 ,1 )) {return -EINVAL ; } +return 0 ; }int kvm_arch_remove_sw_breakpoint (CPUState *cs,struct kvm_sw_breakpoint *bp) {static uint32_t brk; -if (have_guest_debug) { -if (cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&brk,4 ,0 ) || - brk != brk_insn || -cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&bp->saved_insn,4 ,1 )) { -return -EINVAL ; - } -return 0 ; - }else { -error_report ("guest debug not supported on this kernel" ); +if (cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&brk,4 ,0 ) || + brk != brk_insn || +cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&bp->saved_insn,4 ,1 )) {return -EINVAL ; } +return 0 ; }/* See v8 ARM ARM D7.2.27 ESR_ELx, Exception Syndrome Register Signature · 1 line
2.17.1
Richard Henderson
Reviewed-byQuoted 15 lines · Chao Du
Hi,
Kindly ping. :)
Thanks,
ChaoQuoted 7 lines
-----Original Messages-----From:"Chao Du" <[email protected]>Sent Time:2023-10-25 15:07:26 (Wednesday)To:[email protected], [email protected]:Subject:[PATCH] target/arm: kvm64: remove a redundant
KVM_CAP_SET_GUEST_DEBUGprobeThe
KVM_CAP_SET_GUEST_DEBUGis probed duringkvm_init(). gdbserver will fail to start if the CAP is not supported. So no need to make another probe here, like other targets.Signed-off-by Chao Du <[email protected]>
Correct: all handled by kvm_supports_guest_debug.
r~
Quoted 65 lines
Quoted 65 lines
--- target/arm/kvm64.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-)target/arm/kvm64.c +7
-21@@ -31,13 +31,9 @@#include "hw/acpi/acpi.h" #include "hw/acpi/ghes.h" -static bool have_guest_debug;void kvm_arm_init_debug (KVMState *s) { - have_guest_debug =kvm_check_extension (s, -KVM_CAP_SET_GUEST_DEBUG ); - max_hw_wps =kvm_check_extension (s,KVM_CAP_GUEST_DEBUG_HW_WPS ); hw_watchpoints =g_array_sized_new (true, true,sizeof (HWWatchpoint), max_hw_wps);@@ -1140,33 +1136,23 @@ static const uint32_t brk_insn = 0xd4200000;int kvm_arch_insert_sw_breakpoint (CPUState *cs,struct kvm_sw_breakpoint *bp) { -if (have_guest_debug) { -if (cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&bp->saved_insn,4 ,0 ) || -cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&brk_insn,4 ,1 )) { -return -EINVAL ; - } -return 0 ; - }else { -error_report ("guest debug not supported on this kernel" ); +if (cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&bp->saved_insn,4 ,0 ) || +cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&brk_insn,4 ,1 )) {return -EINVAL ; } +return 0 ; }int kvm_arch_remove_sw_breakpoint (CPUState *cs,struct kvm_sw_breakpoint *bp) {static uint32_t brk; -if (have_guest_debug) { -if (cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&brk,4 ,0 ) || - brk != brk_insn || -cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&bp->saved_insn,4 ,1 )) { -return -EINVAL ; - } -return 0 ; - }else { -error_report ("guest debug not supported on this kernel" ); +if (cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&brk,4 ,0 ) || + brk != brk_insn || +cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&bp->saved_insn,4 ,1 )) {return -EINVAL ; } +return 0 ; }/* See v8 ARM ARM D7.2.27 ESR_ELx, Exception Syndrome Register Signature · 1 line
2.17.1