Skip to content

Commit c6986f1

Browse files
committed
KVM: x86: do not fail if software breakpoint has already been removed
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>
1 parent e586edc commit c6986f1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

target/i386/kvm/kvm.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4352,8 +4352,13 @@ int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
43524352
{
43534353
uint8_t int3;
43544354

4355-
if (cpu_memory_rw_debug(cs, bp->pc, &int3, 1, 0) || int3 != 0xcc ||
4356-
cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 1, 1)) {
4355+
if (cpu_memory_rw_debug(cs, bp->pc, &int3, 1, 0)) {
4356+
return -EINVAL;
4357+
}
4358+
if (int3 != 0xcc) {
4359+
return 0;
4360+
}
4361+
if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 1, 1)) {
43574362
return -EINVAL;
43584363
}
43594364
return 0;

0 commit comments

Comments
 (0)