RISC-V Fixes for 5.13-rc4

I have a handful of RISC-V related fixes:
 
 * A fix to avoid errors when the stack tracing code is tracing itself.
 * A fix to resurrect the memtest= kernel command line argument on
   RISC-V, which was briefly enabled during the merge window before a
   refactoring disabled it.
 * A build fix and some warning cleanups.
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCgAxFiEEKzw3R0RoQ7JKlDp6LhMZ81+7GIkFAmCybDoTHHBhbG1lckBk
 YWJiZWx0LmNvbQAKCRAuExnzX7sYiUsfD/9UVmra34L0VlTVsJJNCk8ZOZN8lbgm
 PBkTV5ynzqXnI/iNiAYqY4H9E8kDJRnCBqwCHz7ghQaVPjvgUoCbx8eDW56Y/LKS
 GqNlgf0rXpFiz0RZuRl9UfRQgmAfRDBQMpTYmxM/2v7UWQot/+tRbF8ip6ksZOjC
 GUj+bE4xr/Pdlq2++x02p5uzTEAQv6r+JSt6gFwc/yQ8CEPCFCJJzs1pyYXTxpZY
 XpcQSnzQfZFJnk6bf1qQQaaBDJZR67WFg/2XCG2es74miXSy4xDXXLgbpjNNUxFx
 InRZHjubdqY1uKfGXv6EH1pz/uIpPyM2MA91VgwRn4FHge5KUY9OtwIb/kzukqdh
 nobaiSQtiCdlD+osdl7JfjoY9XNo2+eP6EcfmHqRlWWXw3iXDUeFW/ddp5ztANfa
 WqqP8ls+Sj6Sq8W+H7QssGpy5MS4iYne3bQ8cHNkCVR459EE8M1rVw3S5565Swr7
 93GIXq9scjxpYBjTk2vAcKi/6W9Y6FgGsiKeO0uOampGZ4or0+se+IT1guuICDzG
 Lv8jAQroYrIWD5+/H7KyXo3a/uQ2bbKQ43Zsl4Qm7G5ILh8eo1xCrjdvR/V4KHLR
 3GE5Jo1XDnbfXR9g2Mv82vguia1FFipStznACgqXVd0D0nJfmfMgpB+sG2pOaqdx
 5CZIcAlnhhLPSw==
 =Pg04
 -----END PGP SIGNATURE-----

Merge tag 'riscv-for-linus-5.13-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux

Pull RISC-V fixes from Palmer Dabbelt:
 "A handful of RISC-V related fixes:

   - avoid errors when the stack tracing code is tracing itself.

   - resurrect the memtest= kernel command line argument on RISC-V,
     which was briefly enabled during the merge window before a
     refactoring disabled it.

   - build fix and some warning cleanups"

* tag 'riscv-for-linus-5.13-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  riscv: kexec: Fix W=1 build warnings
  riscv: kprobes: Fix build error when MMU=n
  riscv: Select ARCH_USE_MEMTEST
  riscv: stacktrace: fix the riscv stacktrace when CONFIG_FRAME_POINTER enabled
This commit is contained in:
Linus Torvalds 2021-05-29 18:10:10 -10:00
commit 9d68fe84f8
5 changed files with 18 additions and 14 deletions

View File

@ -34,6 +34,7 @@ config RISCV
select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
select ARCH_SUPPORTS_HUGETLBFS if MMU select ARCH_SUPPORTS_HUGETLBFS if MMU
select ARCH_USE_MEMTEST
select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
select ARCH_WANT_FRAME_POINTERS select ARCH_WANT_FRAME_POINTERS
select ARCH_WANT_HUGE_PMD_SHARE if 64BIT select ARCH_WANT_HUGE_PMD_SHARE if 64BIT

View File

@ -42,8 +42,8 @@ struct kimage_arch {
unsigned long fdt_addr; unsigned long fdt_addr;
}; };
const extern unsigned char riscv_kexec_relocate[]; extern const unsigned char riscv_kexec_relocate[];
const extern unsigned int riscv_kexec_relocate_size; extern const unsigned int riscv_kexec_relocate_size;
typedef void (*riscv_kexec_method)(unsigned long first_ind_entry, typedef void (*riscv_kexec_method)(unsigned long first_ind_entry,
unsigned long jump_addr, unsigned long jump_addr,

View File

@ -14,8 +14,9 @@
#include <asm/set_memory.h> /* For set_memory_x() */ #include <asm/set_memory.h> /* For set_memory_x() */
#include <linux/compiler.h> /* For unreachable() */ #include <linux/compiler.h> /* For unreachable() */
#include <linux/cpu.h> /* For cpu_down() */ #include <linux/cpu.h> /* For cpu_down() */
#include <linux/reboot.h>
/** /*
* kexec_image_info - Print received image details * kexec_image_info - Print received image details
*/ */
static void static void
@ -39,7 +40,7 @@ kexec_image_info(const struct kimage *image)
} }
} }
/** /*
* machine_kexec_prepare - Initialize kexec * machine_kexec_prepare - Initialize kexec
* *
* This function is called from do_kexec_load, when the user has * This function is called from do_kexec_load, when the user has
@ -100,7 +101,7 @@ machine_kexec_prepare(struct kimage *image)
} }
/** /*
* machine_kexec_cleanup - Cleanup any leftovers from * machine_kexec_cleanup - Cleanup any leftovers from
* machine_kexec_prepare * machine_kexec_prepare
* *
@ -135,7 +136,7 @@ void machine_shutdown(void)
#endif #endif
} }
/** /*
* machine_crash_shutdown - Prepare to kexec after a kernel crash * machine_crash_shutdown - Prepare to kexec after a kernel crash
* *
* This function is called by crash_kexec just before machine_kexec * This function is called by crash_kexec just before machine_kexec
@ -151,7 +152,7 @@ machine_crash_shutdown(struct pt_regs *regs)
pr_info("Starting crashdump kernel...\n"); pr_info("Starting crashdump kernel...\n");
} }
/** /*
* machine_kexec - Jump to the loaded kimage * machine_kexec - Jump to the loaded kimage
* *
* This function is called by kernel_kexec which is called by the * This function is called by kernel_kexec which is called by the

View File

@ -84,6 +84,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
return 0; return 0;
} }
#ifdef CONFIG_MMU
void *alloc_insn_page(void) void *alloc_insn_page(void)
{ {
return __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, VMALLOC_END, return __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, VMALLOC_END,
@ -91,6 +92,7 @@ void *alloc_insn_page(void)
VM_FLUSH_RESET_PERMS, NUMA_NO_NODE, VM_FLUSH_RESET_PERMS, NUMA_NO_NODE,
__builtin_return_address(0)); __builtin_return_address(0));
} }
#endif
/* install breakpoint in text */ /* install breakpoint in text */
void __kprobes arch_arm_kprobe(struct kprobe *p) void __kprobes arch_arm_kprobe(struct kprobe *p)

View File

@ -27,10 +27,10 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
fp = frame_pointer(regs); fp = frame_pointer(regs);
sp = user_stack_pointer(regs); sp = user_stack_pointer(regs);
pc = instruction_pointer(regs); pc = instruction_pointer(regs);
} else if (task == NULL || task == current) { } else if (task == current) {
fp = (unsigned long)__builtin_frame_address(0); fp = (unsigned long)__builtin_frame_address(1);
sp = sp_in_global; sp = (unsigned long)__builtin_frame_address(0);
pc = (unsigned long)walk_stackframe; pc = (unsigned long)__builtin_return_address(0);
} else { } else {
/* task blocked in __switch_to */ /* task blocked in __switch_to */
fp = task->thread.s[0]; fp = task->thread.s[0];
@ -106,15 +106,15 @@ static bool print_trace_address(void *arg, unsigned long pc)
return true; return true;
} }
void dump_backtrace(struct pt_regs *regs, struct task_struct *task, noinline void dump_backtrace(struct pt_regs *regs, struct task_struct *task,
const char *loglvl) const char *loglvl)
{ {
pr_cont("%sCall Trace:\n", loglvl);
walk_stackframe(task, regs, print_trace_address, (void *)loglvl); walk_stackframe(task, regs, print_trace_address, (void *)loglvl);
} }
void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl) void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
{ {
pr_cont("%sCall Trace:\n", loglvl);
dump_backtrace(NULL, task, loglvl); dump_backtrace(NULL, task, loglvl);
} }
@ -139,7 +139,7 @@ unsigned long get_wchan(struct task_struct *task)
#ifdef CONFIG_STACKTRACE #ifdef CONFIG_STACKTRACE
void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, noinline void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
struct task_struct *task, struct pt_regs *regs) struct task_struct *task, struct pt_regs *regs)
{ {
walk_stackframe(task, regs, consume_entry, cookie); walk_stackframe(task, regs, consume_entry, cookie);