arm64: ptrace: avoid using HW_BREAKPOINT_EMPTY for disabled events
authorWill Deacon <will.deacon@arm.com>
Tue, 17 Dec 2013 17:09:08 +0000 (17:09 +0000)
committerMark Brown <broonie@linaro.org>
Wed, 14 May 2014 11:16:06 +0000 (12:16 +0100)
commitff5ec2d401f7ab457cece4b1c00587e8af26d74c
tree4babf812bed6196cbf1071eb359ae7459931e698
parenta73eb27dbbbbf1b3f40a4cec380f8d9f238c26aa
arm64: ptrace: avoid using HW_BREAKPOINT_EMPTY for disabled events

commit cdc27c27843248ae7eb0df5fc261dd004eaa5670 upstream.

Commit 8f34a1da35ae ("arm64: ptrace: use HW_BREAKPOINT_EMPTY type for
disabled breakpoints") fixed an issue with GDB trying to zero breakpoint
control registers. The problem there is that the arch hw_breakpoint code
will attempt to create a (disabled), execute breakpoint of length 0.

This will fail validation and report unexpected failure to GDB. To avoid
this, we treated disabled breakpoints as HW_BREAKPOINT_EMPTY, but that
seems to have broken with recent kernels, causing watchpoints to be
treated as TYPE_INST in the core code and returning ENOSPC for any
further breakpoints.

This patch fixes the problem by prioritising the `enable' field of the
breakpoint: if it is cleared, we simply update the perf_event_attr to
indicate that the thing is disabled and don't bother changing either the
type or the length. This reinforces the behaviour that the breakpoint
control register is essentially read-only apart from the enable bit
when disabling a breakpoint.

Reported-by: Aaron Liu <liucy214@gmail.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 11b81802921618b02122855db021a63df7d9fd49)
Signed-off-by: Mark Brown <broonie@linaro.org>
arch/arm64/kernel/ptrace.c