kgdb,x86: fix regression in detach handling

The fix from ba773f7c510c0b252145933926c636c439889207
(x86,kgdb: Fix hw breakpoint regression) was not entirely complete.

The kgdb_remove_all_hw_break() function also needs to call the
hw_break_release_slot() or else a breakpoint can get activated again
after the debugger has detached.

The kgdb test suite exposes the behavior in the form of either a hang
or repetitive failure. The kernel config that exposes the problem
contains all of the following:

CONFIG_DEBUG_RODATA=y
CONFIG_KGDB_TESTS=y
CONFIG_KGDB_TESTS_ON_BOOT=y
CONFIG_KGDB_TESTS_BOOT_STRING="V1F100"

Reported-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Tested-by: Frederic Weisbecker <fweisbec@gmail.com>

+8 -4
+8 -4
arch/x86/kernel/kgdb.c
··· 315 315 if (!breakinfo[i].enabled) 316 316 continue; 317 317 bp = *per_cpu_ptr(breakinfo[i].pev, cpu); 318 - if (bp->attr.disabled == 1) 318 + if (!bp->attr.disabled) { 319 + arch_uninstall_hw_breakpoint(bp); 320 + bp->attr.disabled = 1; 319 321 continue; 322 + } 320 323 if (dbg_is_early) 321 324 early_dr7 &= ~encode_dr7(i, breakinfo[i].len, 322 325 breakinfo[i].type); 323 - else 324 - arch_uninstall_hw_breakpoint(bp); 325 - bp->attr.disabled = 1; 326 + else if (hw_break_release_slot(i)) 327 + printk(KERN_ERR "KGDB: hw bpt remove failed %lx\n", 328 + breakinfo[i].addr); 329 + breakinfo[i].enabled = 0; 326 330 } 327 331 } 328 332