Skip to content

Commit da06cc5

Browse files
RISC-V: fixups to work with crash tool
A handful of fixes to our kexec/crash kernel support that allow crash tool to function. Link: https://lore.kernel.org/r/mhng-f5fdaa37-e99a-4214-a297-ec81f0fed0c1@palmer-mbp2014 * commit 'f9293ad46d8ba9909187a37b7215324420ad4596': RISC-V: Add modules to virtual kernel memory layout dump RISC-V: Fixup schedule out issue in machine_crash_shutdown() RISC-V: Fixup get incorrect user mode PC for kernel mode regs RISC-V: kexec: Fixup use of smp_processor_id() in preemptible context
2 parents 76ad33e + f9293ad commit da06cc5

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

arch/riscv/kernel/crash_save_regs.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ SYM_CODE_START(riscv_crash_save_regs)
4444
REG_S t6, PT_T6(a0) /* x31 */
4545

4646
csrr t1, CSR_STATUS
47-
csrr t2, CSR_EPC
47+
auipc t2, 0x0
4848
csrr t3, CSR_TVAL
4949
csrr t4, CSR_CAUSE
5050

arch/riscv/kernel/machine_kexec.c

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,37 @@ void machine_shutdown(void)
138138
#endif
139139
}
140140

141+
/* Override the weak function in kernel/panic.c */
142+
void crash_smp_send_stop(void)
143+
{
144+
static int cpus_stopped;
145+
146+
/*
147+
* This function can be called twice in panic path, but obviously
148+
* we execute this only once.
149+
*/
150+
if (cpus_stopped)
151+
return;
152+
153+
smp_send_stop();
154+
cpus_stopped = 1;
155+
}
156+
141157
/*
142158
* machine_crash_shutdown - Prepare to kexec after a kernel crash
143159
*
144160
* This function is called by crash_kexec just before machine_kexec
145-
* below and its goal is similar to machine_shutdown, but in case of
146-
* a kernel crash. Since we don't handle such cases yet, this function
147-
* is empty.
161+
* and its goal is to shutdown non-crashing cpus and save registers.
148162
*/
149163
void
150164
machine_crash_shutdown(struct pt_regs *regs)
151165
{
166+
local_irq_disable();
167+
168+
/* shutdown non-crashing cpus */
169+
crash_smp_send_stop();
170+
152171
crash_save_cpu(regs, smp_processor_id());
153-
machine_shutdown();
154172
pr_info("Starting crashdump kernel...\n");
155173
}
156174

@@ -171,7 +189,7 @@ machine_kexec(struct kimage *image)
171189
struct kimage_arch *internal = &image->arch;
172190
unsigned long jump_addr = (unsigned long) image->start;
173191
unsigned long first_ind_entry = (unsigned long) &image->head;
174-
unsigned long this_cpu_id = smp_processor_id();
192+
unsigned long this_cpu_id = __smp_processor_id();
175193
unsigned long this_hart_id = cpuid_to_hartid_map(this_cpu_id);
176194
unsigned long fdt_addr = internal->fdt_addr;
177195
void *control_code_buffer = page_address(image->control_code_page);

arch/riscv/mm/init.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ static void __init print_vm_layout(void)
135135
(unsigned long)VMEMMAP_END);
136136
print_ml("vmalloc", (unsigned long)VMALLOC_START,
137137
(unsigned long)VMALLOC_END);
138+
#ifdef CONFIG_64BIT
139+
print_ml("modules", (unsigned long)MODULES_VADDR,
140+
(unsigned long)MODULES_END);
141+
#endif
138142
print_ml("lowmem", (unsigned long)PAGE_OFFSET,
139143
(unsigned long)high_memory);
140144
if (IS_ENABLED(CONFIG_64BIT)) {

0 commit comments

Comments
 (0)