Skip to content

Commit ff9f3d7

Browse files
zhangqingmychenhuacai
authored andcommitted
LoongArch: Adjust user_watch_state for explicit alignment
This is done in order to easily calculate the number of breakpoints in hw_break_get()/hw_break_set(). Signed-off-by: Qing Zhang <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 93eb121 commit ff9f3d7

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

arch/loongarch/include/uapi/asm/ptrace.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ struct user_fp_state {
4747
};
4848

4949
struct user_watch_state {
50-
uint16_t dbg_info;
50+
uint64_t dbg_info;
5151
struct {
5252
uint64_t addr;
5353
uint64_t mask;
5454
uint32_t ctrl;
55+
uint32_t pad;
5556
} dbg_regs[8];
5657
};
5758

arch/loongarch/kernel/ptrace.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,10 @@ static int ptrace_hbp_fill_attr_ctrl(unsigned int note_type,
391391
return 0;
392392
}
393393

394-
static int ptrace_hbp_get_resource_info(unsigned int note_type, u16 *info)
394+
static int ptrace_hbp_get_resource_info(unsigned int note_type, u64 *info)
395395
{
396396
u8 num;
397-
u16 reg = 0;
397+
u64 reg = 0;
398398

399399
switch (note_type) {
400400
case NT_LOONGARCH_HW_BREAK:
@@ -524,15 +524,16 @@ static int ptrace_hbp_set_addr(unsigned int note_type,
524524
return modify_user_hw_breakpoint(bp, &attr);
525525
}
526526

527-
#define PTRACE_HBP_CTRL_SZ sizeof(u32)
528527
#define PTRACE_HBP_ADDR_SZ sizeof(u64)
529528
#define PTRACE_HBP_MASK_SZ sizeof(u64)
529+
#define PTRACE_HBP_CTRL_SZ sizeof(u32)
530+
#define PTRACE_HBP_PAD_SZ sizeof(u32)
530531

531532
static int hw_break_get(struct task_struct *target,
532533
const struct user_regset *regset,
533534
struct membuf to)
534535
{
535-
u16 info;
536+
u64 info;
536537
u32 ctrl;
537538
u64 addr, mask;
538539
int ret, idx = 0;
@@ -562,6 +563,7 @@ static int hw_break_get(struct task_struct *target,
562563
membuf_store(&to, addr);
563564
membuf_store(&to, mask);
564565
membuf_store(&to, ctrl);
566+
membuf_zero(&to, sizeof(u32));
565567
idx++;
566568
}
567569

@@ -620,6 +622,11 @@ static int hw_break_set(struct task_struct *target,
620622
if (ret)
621623
return ret;
622624
offset += PTRACE_HBP_CTRL_SZ;
625+
626+
user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
627+
offset, offset + PTRACE_HBP_PAD_SZ);
628+
offset += PTRACE_HBP_PAD_SZ;
629+
623630
idx++;
624631
}
625632

0 commit comments

Comments
 (0)