@@ -568,9 +568,7 @@ static int arch_build_bp_info(struct perf_event *bp,
hw->address = attr->bp_addr;
/* Privilege */
- hw->ctrl.privilege = ARM_BREAKPOINT_USER;
- if (arch_check_bp_in_kernelspace(hw))
- hw->ctrl.privilege |= ARM_BREAKPOINT_PRIV;
+ hw->ctrl.privilege = attr->bp_priv;
/* Enabled? */
hw->ctrl.enabled = !attr->disabled;
@@ -422,6 +422,7 @@ static struct perf_event *ptrace_hbp_create(struct task_struct *tsk, int type)
attr.bp_addr = 0;
attr.bp_len = HW_BREAKPOINT_LEN_4;
attr.bp_type = type;
+ attr.bp_priv = ARM_BREAKPOINT_USER;
attr.disabled = 1;
return register_user_hw_breakpoint(&attr, ptrace_hbptriggered, NULL,
@@ -530,6 +531,7 @@ static int ptrace_sethbpregs(struct task_struct *tsk, long num,
attr.bp_len = gen_len;
attr.bp_type = gen_type;
+ attr.bp_priv = ctrl.privilege;
attr.disabled = !ctrl.enabled;
}
In the current code, decode_ctrl_reg() saves the privilege of access control passed by the ptrace user data, but it is not used anymore, arch_build_bp_info() checks whether bp virtual address is in kernel space to construct hw->ctrl.privilege, it seems not reasonable. The value of ctrl->privilege saved in decode_ctrl_reg() can be used in arch_build_bp_info(), there is no need to check bp virtual address to assign value for hw->ctrl.privilege, just make use of "bp_priv" in the struct perf_event_attr to save the privilege of access control via ptrace for hardware breakpoint. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> --- arch/arm/kernel/hw_breakpoint.c | 4 +--- arch/arm/kernel/ptrace.c | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-)