Skip to content

Commit

Permalink
LoongArch: Add pad structure members for explicit alignment
Browse files Browse the repository at this point in the history
This is done in order to easily calculate the number of breakpoints
in hw_break_get.

Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
  • Loading branch information
zhangqingmy authored and intel-lab-lkp committed Apr 18, 2023
1 parent 6a8f57a commit dace280
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion arch/loongarch/include/uapi/asm/ptrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ struct user_fp_state {
};

struct user_watch_state {
uint16_t dbg_info;
uint64_t dbg_info;
struct {
uint64_t addr;
uint64_t mask;
uint32_t ctrl;
uint32_t pad;
} dbg_regs[8];
};

Expand Down
13 changes: 9 additions & 4 deletions arch/loongarch/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,10 @@ static int ptrace_hbp_fill_attr_ctrl(unsigned int note_type,
return 0;
}

static int ptrace_hbp_get_resource_info(unsigned int note_type, u16 *info)
static int ptrace_hbp_get_resource_info(unsigned int note_type, u64 *info)
{
u8 num;
u16 reg = 0;
u64 reg = 0;

switch (note_type) {
case NT_LOONGARCH_HW_BREAK:
Expand Down Expand Up @@ -532,7 +532,7 @@ static int hw_break_get(struct task_struct *target,
const struct user_regset *regset,
struct membuf to)
{
u16 info;
u64 info;
u32 ctrl;
u64 addr, mask;
int ret, idx = 0;
Expand Down Expand Up @@ -562,6 +562,7 @@ static int hw_break_get(struct task_struct *target,
membuf_store(&to, addr);
membuf_store(&to, mask);
membuf_store(&to, ctrl);
membuf_zero(&to, sizeof(u32));
idx++;
}

Expand All @@ -578,7 +579,7 @@ static int hw_break_set(struct task_struct *target,
int ret, idx = 0, offset, limit;
unsigned int note_type = regset->core_note_type;

/* Resource info */
/* Resource info and pad */
offset = offsetof(struct user_watch_state, dbg_regs);
user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, 0, offset);

Expand Down Expand Up @@ -620,6 +621,10 @@ static int hw_break_set(struct task_struct *target,
if (ret)
return ret;
offset += PTRACE_HBP_CTRL_SZ;

user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
offset, offset + PTRACE_HBP_PAD_SZ);
offset += PTRACE_HBP_PAD_SZ;
idx++;
}

Expand Down

0 comments on commit dace280

Please sign in to comment.