]> git.proxmox.com Git - mirror_qemu.git/commitdiff
KVM: x86: do not fail if software breakpoint has already been removed
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 1 Mar 2021 11:02:44 +0000 (12:02 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 6 Mar 2021 10:41:54 +0000 (11:41 +0100)
If kvm_arch_remove_sw_breakpoint finds that a software breakpoint does not
have an INT3 instruction, it fails.  This can happen if one sets a
software breakpoint in a kernel module and then reloads it.  gdb then
thinks the breakpoint cannot be deleted and there is no way to add it
back.

Suggested-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/kvm/kvm.c

index 0b5755e42b871123acfbe8e78fc70fea13d5ba2f..c8d61daf68b545e48c7471cb201dede9bb00ae7d 100644 (file)
@@ -4352,8 +4352,13 @@ int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
 {
     uint8_t int3;
 
-    if (cpu_memory_rw_debug(cs, bp->pc, &int3, 1, 0) || int3 != 0xcc ||
-        cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 1, 1)) {
+    if (cpu_memory_rw_debug(cs, bp->pc, &int3, 1, 0)) {
+        return -EINVAL;
+    }
+    if (int3 != 0xcc) {
+        return 0;
+    }
+    if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 1, 1)) {
         return -EINVAL;
     }
     return 0;