lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Thu, 21 Oct 2021 09:51:42 -0700
From:   Vineet Gupta <vineetg@...osinc.com>
To:     Paul Walmsley <paul.walmsley@...ive.com>,
        Palmer Dabbelt <palmer@...belt.com>,
        Albert Ou <aou@...s.berkeley.edu>,
        Anup Patel <anup.patel@....com>,
        Kefeng Wang <wangkefeng.wang@...wei.com>,
        Atish Patra <atish.patra@....com>,
        Jisheng Zhang <jszhang@...nel.org>,
        Chen Huang <chenhuang5@...wei.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Guo Ren <guoren@...ux.alibaba.com>
Cc:     linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org,
        Vineet Gupta <vineetg@...osinc.com>
Subject: [PATCH] riscv: remove code for !CONFIG_FRAME_POINTER

while frame pointer generates horrible code it is a necessary evil on
RISC-V as the only way to unwind stack.

In fact Kconfig unconditonally selects ARCH_WANT_FRAME_POINTERS, so
any code for handling !FRAME_POINTER is essentially dead weight.

And while here remove redundant setting of -fno-omit-frame-pointer as
this is enabled by generic code for CONFIG_FRAME_POINTER

Signed-off-by: Vineet Gupta <vineetg@...osinc.com>
---
 arch/riscv/Makefile            |  3 ---
 arch/riscv/kernel/stacktrace.c | 37 ++--------------------------------
 2 files changed, 2 insertions(+), 38 deletions(-)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index a0b8259c7098..a4329035c341 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -65,9 +65,6 @@ endif
 ifeq ($(CONFIG_CMODEL_MEDANY),y)
 	KBUILD_CFLAGS += -mcmodel=medany
 endif
-ifeq ($(CONFIG_PERF_EVENTS),y)
-        KBUILD_CFLAGS += -fno-omit-frame-pointer
-endif
 
 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
 
diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
index 315db3d0229b..63f471278401 100644
--- a/arch/riscv/kernel/stacktrace.c
+++ b/arch/riscv/kernel/stacktrace.c
@@ -16,13 +16,13 @@
 
 register unsigned long sp_in_global __asm__("sp");
 
-#ifdef CONFIG_FRAME_POINTER
-
 void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
 			     bool (*fn)(void *, unsigned long), void *arg)
 {
 	unsigned long fp, sp, pc;
 
+        BUILD_BUG_ON(!IS_ENABLED(CONFIG_FRAME_POINTER));
+
 	if (regs) {
 		fp = frame_pointer(regs);
 		sp = user_stack_pointer(regs);
@@ -65,39 +65,6 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
 	}
 }
 
-#else /* !CONFIG_FRAME_POINTER */
-
-void notrace walk_stackframe(struct task_struct *task,
-	struct pt_regs *regs, bool (*fn)(void *, unsigned long), void *arg)
-{
-	unsigned long sp, pc;
-	unsigned long *ksp;
-
-	if (regs) {
-		sp = user_stack_pointer(regs);
-		pc = instruction_pointer(regs);
-	} else if (task == NULL || task == current) {
-		sp = sp_in_global;
-		pc = (unsigned long)walk_stackframe;
-	} else {
-		/* task blocked in __switch_to */
-		sp = task->thread.sp;
-		pc = task->thread.ra;
-	}
-
-	if (unlikely(sp & 0x7))
-		return;
-
-	ksp = (unsigned long *)sp;
-	while (!kstack_end(ksp)) {
-		if (__kernel_text_address(pc) && unlikely(!fn(arg, pc)))
-			break;
-		pc = (*ksp++) - 0x4;
-	}
-}
-
-#endif /* CONFIG_FRAME_POINTER */
-
 static bool print_trace_address(void *arg, unsigned long pc)
 {
 	const char *loglvl = arg;
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ