Skip to content

Commit da529d4

Browse files
chleroympe
authored andcommitted
powerpc/ptrace: create ppc_gethwdinfo()
Create ippc_gethwdinfo() to handle PPC_PTRACE_GETHWDBGINFO and reduce ifdef mess Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/82fefcc1ec75b96cece792878217a5d85ecda0c2.1582848567.git.christophe.leroy@c-s.fr
1 parent e08227d commit da529d4

File tree

4 files changed

+37
-31
lines changed

4 files changed

+37
-31
lines changed

arch/powerpc/kernel/ptrace/ptrace-adv.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ void user_disable_single_step(struct task_struct *task)
5656
clear_tsk_thread_flag(task, TIF_SINGLESTEP);
5757
}
5858

59+
void ppc_gethwdinfo(struct ppc_debug_info *dbginfo)
60+
{
61+
dbginfo->version = 1;
62+
dbginfo->num_instruction_bps = CONFIG_PPC_ADV_DEBUG_IACS;
63+
dbginfo->num_data_bps = CONFIG_PPC_ADV_DEBUG_DACS;
64+
dbginfo->num_condition_regs = CONFIG_PPC_ADV_DEBUG_DVCS;
65+
dbginfo->data_bp_alignment = 4;
66+
dbginfo->sizeof_condition = 4;
67+
dbginfo->features = PPC_DEBUG_FEATURE_INSN_BP_RANGE |
68+
PPC_DEBUG_FEATURE_INSN_BP_MASK;
69+
if (IS_ENABLED(CONFIG_PPC_ADV_DEBUG_DAC_RANGE))
70+
dbginfo->features |= PPC_DEBUG_FEATURE_DATA_BP_RANGE |
71+
PPC_DEBUG_FEATURE_DATA_BP_MASK;
72+
}
73+
5974
int ptrace_get_debugreg(struct task_struct *child, unsigned long addr,
6075
unsigned long __user *datalp)
6176
{

arch/powerpc/kernel/ptrace/ptrace-decl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ int tm_cgpr32_set(struct task_struct *target, const struct user_regset *regset,
176176
extern const struct user_regset_view user_ppc_native_view;
177177

178178
/* ptrace-(no)adv */
179+
void ppc_gethwdinfo(struct ppc_debug_info *dbginfo);
179180
int ptrace_get_debugreg(struct task_struct *child, unsigned long addr,
180181
unsigned long __user *datalp);
181182
int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, unsigned long data);

arch/powerpc/kernel/ptrace/ptrace-noadv.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,26 @@ void user_disable_single_step(struct task_struct *task)
3939
clear_tsk_thread_flag(task, TIF_SINGLESTEP);
4040
}
4141

42+
void ppc_gethwdinfo(struct ppc_debug_info *dbginfo)
43+
{
44+
dbginfo->version = 1;
45+
dbginfo->num_instruction_bps = 0;
46+
if (ppc_breakpoint_available())
47+
dbginfo->num_data_bps = 1;
48+
else
49+
dbginfo->num_data_bps = 0;
50+
dbginfo->num_condition_regs = 0;
51+
dbginfo->data_bp_alignment = sizeof(long);
52+
dbginfo->sizeof_condition = 0;
53+
if (IS_ENABLED(CONFIG_HAVE_HW_BREAKPOINT)) {
54+
dbginfo->features = PPC_DEBUG_FEATURE_DATA_BP_RANGE;
55+
if (dawr_enabled())
56+
dbginfo->features |= PPC_DEBUG_FEATURE_DATA_BP_DAWR;
57+
} else {
58+
dbginfo->features = 0;
59+
}
60+
}
61+
4262
int ptrace_get_debugreg(struct task_struct *child, unsigned long addr,
4363
unsigned long __user *datalp)
4464
{

arch/powerpc/kernel/ptrace/ptrace.c

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -139,37 +139,7 @@ long arch_ptrace(struct task_struct *child, long request,
139139
case PPC_PTRACE_GETHWDBGINFO: {
140140
struct ppc_debug_info dbginfo;
141141

142-
dbginfo.version = 1;
143-
#ifdef CONFIG_PPC_ADV_DEBUG_REGS
144-
dbginfo.num_instruction_bps = CONFIG_PPC_ADV_DEBUG_IACS;
145-
dbginfo.num_data_bps = CONFIG_PPC_ADV_DEBUG_DACS;
146-
dbginfo.num_condition_regs = CONFIG_PPC_ADV_DEBUG_DVCS;
147-
dbginfo.data_bp_alignment = 4;
148-
dbginfo.sizeof_condition = 4;
149-
dbginfo.features = PPC_DEBUG_FEATURE_INSN_BP_RANGE |
150-
PPC_DEBUG_FEATURE_INSN_BP_MASK;
151-
#ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE
152-
dbginfo.features |=
153-
PPC_DEBUG_FEATURE_DATA_BP_RANGE |
154-
PPC_DEBUG_FEATURE_DATA_BP_MASK;
155-
#endif
156-
#else /* !CONFIG_PPC_ADV_DEBUG_REGS */
157-
dbginfo.num_instruction_bps = 0;
158-
if (ppc_breakpoint_available())
159-
dbginfo.num_data_bps = 1;
160-
else
161-
dbginfo.num_data_bps = 0;
162-
dbginfo.num_condition_regs = 0;
163-
dbginfo.data_bp_alignment = sizeof(long);
164-
dbginfo.sizeof_condition = 0;
165-
#ifdef CONFIG_HAVE_HW_BREAKPOINT
166-
dbginfo.features = PPC_DEBUG_FEATURE_DATA_BP_RANGE;
167-
if (dawr_enabled())
168-
dbginfo.features |= PPC_DEBUG_FEATURE_DATA_BP_DAWR;
169-
#else
170-
dbginfo.features = 0;
171-
#endif /* CONFIG_HAVE_HW_BREAKPOINT */
172-
#endif /* CONFIG_PPC_ADV_DEBUG_REGS */
142+
ppc_gethwdinfo(&dbginfo);
173143

174144
if (copy_to_user(datavp, &dbginfo,
175145
sizeof(struct ppc_debug_info)))

0 commit comments

Comments
 (0)