On 12/04/2024 13:58, Kevin Brodsky wrote:
As per the register merging principle set out in the Morello documentation [1], the kernel does not normally zero out the C register when writing to the corresponding X register. However, pt_regs_write_ptr_reg() is used in contexts such as instruction emulation, where the kernel emulates the effect of an instruction writing to an X register.
Instructions writing to X registers are architecturally guaranteed to clear the C register (that is the upper 64 bits and tag); it is therefore preferable for pt_regs_write_reg() to behave in the same way.
[1] Documentation/arch/arm64/morello.rst
Signed-off-by: Kevin Brodsky kevin.brodsky@arm.com
arch/arm64/include/asm/ptrace.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Applied on next.
Kevin
diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h index 5d682f0ccd3f..c7fa869f9191 100644 --- a/arch/arm64/include/asm/ptrace.h +++ b/arch/arm64/include/asm/ptrace.h @@ -316,8 +316,12 @@ static inline unsigned long pt_regs_read_reg(const struct pt_regs *regs, int r) static inline void pt_regs_write_reg(struct pt_regs *regs, int r, unsigned long val) {
- if (r != 31)
- if (r != 31) { regs->regs[r] = val;
+#ifdef CONFIG_ARM64_MORELLO
regs->cregs[r] = 0;
+#endif
- }
} /* Valid only for Kernel mode traps. */