Skip to content

Commit 9d68fe8

Browse files
committed
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
2 parents 75b9c72 + bab0d47 commit 9d68fe8

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

arch/riscv/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ config RISCV
3434
select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
3535
select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
3636
select ARCH_SUPPORTS_HUGETLBFS if MMU
37+
select ARCH_USE_MEMTEST
3738
select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
3839
select ARCH_WANT_FRAME_POINTERS
3940
select ARCH_WANT_HUGE_PMD_SHARE if 64BIT

arch/riscv/include/asm/kexec.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ struct kimage_arch {
4242
unsigned long fdt_addr;
4343
};
4444

45-
const extern unsigned char riscv_kexec_relocate[];
46-
const extern unsigned int riscv_kexec_relocate_size;
45+
extern const unsigned char riscv_kexec_relocate[];
46+
extern const unsigned int riscv_kexec_relocate_size;
4747

4848
typedef void (*riscv_kexec_method)(unsigned long first_ind_entry,
4949
unsigned long jump_addr,

arch/riscv/kernel/machine_kexec.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
#include <asm/set_memory.h> /* For set_memory_x() */
1515
#include <linux/compiler.h> /* For unreachable() */
1616
#include <linux/cpu.h> /* For cpu_down() */
17+
#include <linux/reboot.h>
1718

18-
/**
19+
/*
1920
* kexec_image_info - Print received image details
2021
*/
2122
static void
@@ -39,7 +40,7 @@ kexec_image_info(const struct kimage *image)
3940
}
4041
}
4142

42-
/**
43+
/*
4344
* machine_kexec_prepare - Initialize kexec
4445
*
4546
* This function is called from do_kexec_load, when the user has
@@ -100,7 +101,7 @@ machine_kexec_prepare(struct kimage *image)
100101
}
101102

102103

103-
/**
104+
/*
104105
* machine_kexec_cleanup - Cleanup any leftovers from
105106
* machine_kexec_prepare
106107
*
@@ -135,7 +136,7 @@ void machine_shutdown(void)
135136
#endif
136137
}
137138

138-
/**
139+
/*
139140
* machine_crash_shutdown - Prepare to kexec after a kernel crash
140141
*
141142
* This function is called by crash_kexec just before machine_kexec
@@ -151,7 +152,7 @@ machine_crash_shutdown(struct pt_regs *regs)
151152
pr_info("Starting crashdump kernel...\n");
152153
}
153154

154-
/**
155+
/*
155156
* machine_kexec - Jump to the loaded kimage
156157
*
157158
* This function is called by kernel_kexec which is called by the

arch/riscv/kernel/probes/kprobes.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
8484
return 0;
8585
}
8686

87+
#ifdef CONFIG_MMU
8788
void *alloc_insn_page(void)
8889
{
8990
return __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, VMALLOC_END,
9091
GFP_KERNEL, PAGE_KERNEL_READ_EXEC,
9192
VM_FLUSH_RESET_PERMS, NUMA_NO_NODE,
9293
__builtin_return_address(0));
9394
}
95+
#endif
9496

9597
/* install breakpoint in text */
9698
void __kprobes arch_arm_kprobe(struct kprobe *p)

arch/riscv/kernel/stacktrace.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
2727
fp = frame_pointer(regs);
2828
sp = user_stack_pointer(regs);
2929
pc = instruction_pointer(regs);
30-
} else if (task == NULL || task == current) {
31-
fp = (unsigned long)__builtin_frame_address(0);
32-
sp = sp_in_global;
33-
pc = (unsigned long)walk_stackframe;
30+
} else if (task == current) {
31+
fp = (unsigned long)__builtin_frame_address(1);
32+
sp = (unsigned long)__builtin_frame_address(0);
33+
pc = (unsigned long)__builtin_return_address(0);
3434
} else {
3535
/* task blocked in __switch_to */
3636
fp = task->thread.s[0];
@@ -106,15 +106,15 @@ static bool print_trace_address(void *arg, unsigned long pc)
106106
return true;
107107
}
108108

109-
void dump_backtrace(struct pt_regs *regs, struct task_struct *task,
109+
noinline void dump_backtrace(struct pt_regs *regs, struct task_struct *task,
110110
const char *loglvl)
111111
{
112-
pr_cont("%sCall Trace:\n", loglvl);
113112
walk_stackframe(task, regs, print_trace_address, (void *)loglvl);
114113
}
115114

116115
void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
117116
{
117+
pr_cont("%sCall Trace:\n", loglvl);
118118
dump_backtrace(NULL, task, loglvl);
119119
}
120120

@@ -139,7 +139,7 @@ unsigned long get_wchan(struct task_struct *task)
139139

140140
#ifdef CONFIG_STACKTRACE
141141

142-
void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
142+
noinline void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
143143
struct task_struct *task, struct pt_regs *regs)
144144
{
145145
walk_stackframe(task, regs, consume_entry, cookie);

0 commit comments

Comments
 (0)