提交 d703008e 编写于 作者: H He Chuyue 提交者: guzitao

sw64: perf: don't rely on layout of pt_regs to grab some registers

Sunway inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6ILAC

--------------------------------

The layout of struct perf_event_sw64_regs and pt_regs is inconsistent,
and some integer registers cannot get correct value.

This patch checks these registers explicitly to return the appropriate
values.
Signed-off-by: NHe Chuyue <hechuyue@wxiat.com>
Reviewed-by: NHe Sheng <hesheng@wxiat.com>
Signed-off-by: NGu Zitao <guzitao@wxiat.com>
上级 58b964b3
......@@ -8,7 +8,24 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)
if (WARN_ON_ONCE((u32)idx >= PERF_REG_SW64_MAX))
return 0;
return ((unsigned long *)regs)[idx];
switch (idx) {
case PERF_REG_SW64_R16:
return regs->r16;
case PERF_REG_SW64_R17:
return regs->r17;
case PERF_REG_SW64_R18:
return regs->r18;
case PERF_REG_SW64_R19 ... PERF_REG_SW64_R28:
return ((unsigned long *)regs)[idx - 3];
case PERF_REG_SW64_GP:
return regs->gp;
case PERF_REG_SW64_SP:
return (u64)(user_mode(regs) ? rdusp() : (regs + 1));
case PERF_REG_SW64_PC:
return regs->pc;
default:
return ((unsigned long *)regs)[idx];
}
}
#define REG_RESERVED (~((1ULL << PERF_REG_SW64_MAX) - 1))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册