arm64: ptrace: use HW_BREAKPOINT_EMPTY type for disabled breakpoints

If a debugger tries to zero a hardware debug control register, the
kernel will try to infer both the type and length of the breakpoint
in order to sanity-check against the requested regset type. This will
fail because the encoding will appear as a zero-length breakpoint.

This patch changes the control register setting so that disabled
breakpoints are treated as HW_BREAKPOINT_EMPTY and no further
sanity-checking is required.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
This commit is contained in:
Will Deacon 2012-10-18 15:17:00 +01:00 committed by Catalin Marinas
parent 7797d17c59
commit 8f34a1da35

View File

@ -234,8 +234,12 @@ static int ptrace_hbp_fill_attr_ctrl(unsigned int note_type,
struct arch_hw_breakpoint_ctrl ctrl,
struct perf_event_attr *attr)
{
int err, len, type;
int err, len, type, disabled = !ctrl.enabled;
if (disabled) {
len = 0;
type = HW_BREAKPOINT_EMPTY;
} else {
err = arch_bp_generic_fields(ctrl, &len, &type);
if (err)
return err;
@ -252,10 +256,11 @@ static int ptrace_hbp_fill_attr_ctrl(unsigned int note_type,
default:
return -EINVAL;
}
}
attr->bp_len = len;
attr->bp_type = type;
attr->disabled = !ctrl.enabled;
attr->disabled = disabled;
return 0;
}