Commit ffe7afd1 authored by Mark Rutland's avatar Mark Rutland Committed by Will Deacon

arm64/kprobes: consistently handle MRS/MSR with XZR

Now that we have XZR-safe helpers for fiddling with registers, use these
in the arm64 kprobes code rather than open-coding the logic.
Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 521c6461
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/kprobes.h> #include <linux/kprobes.h>
#include <asm/ptrace.h>
#include "simulate-insn.h" #include "simulate-insn.h"
#define bbl_displacement(insn) \ #define bbl_displacement(insn) \
...@@ -36,30 +38,22 @@ ...@@ -36,30 +38,22 @@
static inline void set_x_reg(struct pt_regs *regs, int reg, u64 val) static inline void set_x_reg(struct pt_regs *regs, int reg, u64 val)
{ {
if (reg < 31) pt_regs_write_reg(regs, reg, val);
regs->regs[reg] = val;
} }
static inline void set_w_reg(struct pt_regs *regs, int reg, u64 val) static inline void set_w_reg(struct pt_regs *regs, int reg, u64 val)
{ {
if (reg < 31) pt_regs_write_reg(regs, reg, lower_32_bits(val));
regs->regs[reg] = lower_32_bits(val);
} }
static inline u64 get_x_reg(struct pt_regs *regs, int reg) static inline u64 get_x_reg(struct pt_regs *regs, int reg)
{ {
if (reg < 31) return pt_regs_read_reg(regs, reg);
return regs->regs[reg];
else
return 0;
} }
static inline u32 get_w_reg(struct pt_regs *regs, int reg) static inline u32 get_w_reg(struct pt_regs *regs, int reg)
{ {
if (reg < 31) return lower_32_bits(pt_regs_read_reg(regs, reg));
return lower_32_bits(regs->regs[reg]);
else
return 0;
} }
static bool __kprobes check_cbz(u32 opcode, struct pt_regs *regs) static bool __kprobes check_cbz(u32 opcode, struct pt_regs *regs)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment