[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <db0636b3290bbc72084f170a28e4dee5a22a622d.1532714999.git.joe@perches.com>
Date: Fri, 27 Jul 2018 11:12:00 -0700
From: Joe Perches <joe@...ches.com>
To: Oleg Nesterov <oleg@...hat.com>,
Palmer Dabbelt <palmer@...ive.com>,
Albert Ou <aou@...s.berkeley.edu>
Cc: linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH] riscv: Convert uses of REG_FMT to %p
Use %p pointer output instead of REG_FMT and cast the unsigned longs to
(void *) to avoid exposing kernel addresses.
Miscellanea:
o Convert pr_cont to printk(KERN_DEFAULT as these uses are
new logging lines and not previous line continuations
o Remove the now unused REG_FMT defines
Signed-off-by: Joe Perches <joe@...ches.com>
---
arch/riscv/include/asm/ptrace.h | 6 -----
arch/riscv/kernel/process.c | 52 +++++++++++++++++++++--------------------
arch/riscv/kernel/traps.c | 4 ++--
3 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/arch/riscv/include/asm/ptrace.h b/arch/riscv/include/asm/ptrace.h
index 2c5df945d43c..b123e723f8fa 100644
--- a/arch/riscv/include/asm/ptrace.h
+++ b/arch/riscv/include/asm/ptrace.h
@@ -60,12 +60,6 @@ struct pt_regs {
unsigned long orig_a0;
};
-#ifdef CONFIG_64BIT
-#define REG_FMT "%016lx"
-#else
-#define REG_FMT "%08lx"
-#endif
-
#define user_mode(regs) (((regs)->sstatus & SR_SPP) == 0)
diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
index d7c6ca7c95ae..7223f6715ff3 100644
--- a/arch/riscv/kernel/process.c
+++ b/arch/riscv/kernel/process.c
@@ -36,7 +36,7 @@
extern asmlinkage void ret_from_fork(void);
extern asmlinkage void ret_from_kernel_thread(void);
-void arch_cpu_idle(void)
+void arch_yycpu_idle(void)
{
wait_for_interrupt();
local_irq_enable();
@@ -46,31 +46,33 @@ void show_regs(struct pt_regs *regs)
{
show_regs_print_info(KERN_DEFAULT);
- pr_cont("sepc: " REG_FMT " ra : " REG_FMT " sp : " REG_FMT "\n",
- regs->sepc, regs->ra, regs->sp);
- pr_cont(" gp : " REG_FMT " tp : " REG_FMT " t0 : " REG_FMT "\n",
- regs->gp, regs->tp, regs->t0);
- pr_cont(" t1 : " REG_FMT " t2 : " REG_FMT " s0 : " REG_FMT "\n",
- regs->t1, regs->t2, regs->s0);
- pr_cont(" s1 : " REG_FMT " a0 : " REG_FMT " a1 : " REG_FMT "\n",
- regs->s1, regs->a0, regs->a1);
- pr_cont(" a2 : " REG_FMT " a3 : " REG_FMT " a4 : " REG_FMT "\n",
- regs->a2, regs->a3, regs->a4);
- pr_cont(" a5 : " REG_FMT " a6 : " REG_FMT " a7 : " REG_FMT "\n",
- regs->a5, regs->a6, regs->a7);
- pr_cont(" s2 : " REG_FMT " s3 : " REG_FMT " s4 : " REG_FMT "\n",
- regs->s2, regs->s3, regs->s4);
- pr_cont(" s5 : " REG_FMT " s6 : " REG_FMT " s7 : " REG_FMT "\n",
- regs->s5, regs->s6, regs->s7);
- pr_cont(" s8 : " REG_FMT " s9 : " REG_FMT " s10: " REG_FMT "\n",
- regs->s8, regs->s9, regs->s10);
- pr_cont(" s11: " REG_FMT " t3 : " REG_FMT " t4 : " REG_FMT "\n",
- regs->s11, regs->t3, regs->t4);
- pr_cont(" t5 : " REG_FMT " t6 : " REG_FMT "\n",
- regs->t5, regs->t6);
+ printk(KERN_DEFAULT "sepc: %p ra : %p sp : %p\n",
+ (void *)regs->sepc, (void *)regs->ra, (void *)regs->sp);
+ printk(KERN_DEFAULT " gp : %p tp : %p t0 : %p\n",
+ (void *)regs->gp, (void *)regs->tp, (void *)regs->t0);
+ printk(KERN_DEFAULT " t1 : %p t2 : %p s0 : %p\n",
+ (void *)regs->t1, (void *)regs->t2, (void *)regs->s0);
+ printk(KERN_DEFAULT " s1 : %p a0 : %p a1 : %p\n",
+ (void *)regs->s1, (void *)regs->a0, (void *)regs->a1);
+ printk(KERN_DEFAULT " a2 : %p a3 : %p a4 : %p\n",
+ (void *)regs->a2, (void *)regs->a3, (void *)regs->a4);
+ printk(KERN_DEFAULT " a5 : %p a6 : %p a7 : %p\n",
+ (void *)regs->a5, (void *)regs->a6, (void *)regs->a7);
+ printk(KERN_DEFAULT " s2 : %p s3 : %p s4 : %p\n",
+ (void *)regs->s2, (void *)regs->s3, (void *)regs->s4);
+ printk(KERN_DEFAULT " s5 : %p s6 : %p s7 : %p\n",
+ (void *)regs->s5, (void *)regs->s6, (void *)regs->s7);
+ printk(KERN_DEFAULT " s8 : %p s9 : %p s10: %p\n",
+ (void *)regs->s8, (void *)regs->s9, (void *)regs->s10);
+ printk(KERN_DEFAULT " s11: %p t3 : %p t4 : %p\n",
+ (void *)regs->s11, (void *)regs->t3, (void *)regs->t4);
+ printk(KERN_DEFAULT " t5 : %p t6 : %p\n",
+ (void *)regs->t5, (void *)regs->t6);
- pr_cont("sstatus: " REG_FMT " sbadaddr: " REG_FMT " scause: " REG_FMT "\n",
- regs->sstatus, regs->sbadaddr, regs->scause);
+ printk(KERN_DEFAULT "sstatus: %p sbadaddr: %p scause: %p\n",
+ (void *)regs->sstatus,
+ (void *)regs->sbadaddr,
+ (void *)regs->scause);
}
void start_thread(struct pt_regs *regs, unsigned long pc,
diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
index 81a1952015a6..ba1942befa6a 100644
--- a/arch/riscv/kernel/traps.c
+++ b/arch/riscv/kernel/traps.c
@@ -68,8 +68,8 @@ void do_trap(struct pt_regs *regs, int signo, int code,
{
if (show_unhandled_signals && unhandled_signal(tsk, signo)
&& printk_ratelimit()) {
- pr_info("%s[%d]: unhandled signal %d code 0x%x at 0x" REG_FMT,
- tsk->comm, task_pid_nr(tsk), signo, code, addr);
+ pr_info("%s[%d]: unhandled signal %d code 0x%x at 0x%p",
+ tsk->comm, task_pid_nr(tsk), signo, code, (void *)addr);
print_vma_addr(KERN_CONT " in ", GET_IP(regs));
pr_cont("\n");
show_regs(regs);
--
2.15.0
Powered by blists - more mailing lists