Skip to content

Commit

Permalink
RISC-V: fixups to work with crash tool
Browse files Browse the repository at this point in the history
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
palmer-dabbelt committed Aug 11, 2022

Verified

This commit was signed with the committer’s verified signature.
palmer-dabbelt Palmer Dabbelt
2 parents 76ad33e + f9293ad commit da06cc5
Showing 3 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion arch/riscv/kernel/crash_save_regs.S
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ SYM_CODE_START(riscv_crash_save_regs)
REG_S t6, PT_T6(a0) /* x31 */

csrr t1, CSR_STATUS
csrr t2, CSR_EPC
auipc t2, 0x0
csrr t3, CSR_TVAL
csrr t4, CSR_CAUSE

28 changes: 23 additions & 5 deletions arch/riscv/kernel/machine_kexec.c
Original file line number Diff line number Diff line change
@@ -138,19 +138,37 @@ void machine_shutdown(void)
#endif
}

/* Override the weak function in kernel/panic.c */
void crash_smp_send_stop(void)
{
static int cpus_stopped;

/*
* This function can be called twice in panic path, but obviously
* we execute this only once.
*/
if (cpus_stopped)
return;

smp_send_stop();
cpus_stopped = 1;
}

/*
* machine_crash_shutdown - Prepare to kexec after a kernel crash
*
* This function is called by crash_kexec just before machine_kexec
* below and its goal is similar to machine_shutdown, but in case of
* a kernel crash. Since we don't handle such cases yet, this function
* is empty.
* and its goal is to shutdown non-crashing cpus and save registers.
*/
void
machine_crash_shutdown(struct pt_regs *regs)
{
local_irq_disable();

/* shutdown non-crashing cpus */
crash_smp_send_stop();

crash_save_cpu(regs, smp_processor_id());
machine_shutdown();
pr_info("Starting crashdump kernel...\n");
}

@@ -171,7 +189,7 @@ machine_kexec(struct kimage *image)
struct kimage_arch *internal = &image->arch;
unsigned long jump_addr = (unsigned long) image->start;
unsigned long first_ind_entry = (unsigned long) &image->head;
unsigned long this_cpu_id = smp_processor_id();
unsigned long this_cpu_id = __smp_processor_id();
unsigned long this_hart_id = cpuid_to_hartid_map(this_cpu_id);
unsigned long fdt_addr = internal->fdt_addr;
void *control_code_buffer = page_address(image->control_code_page);
4 changes: 4 additions & 0 deletions arch/riscv/mm/init.c
Original file line number Diff line number Diff line change
@@ -135,6 +135,10 @@ static void __init print_vm_layout(void)
(unsigned long)VMEMMAP_END);
print_ml("vmalloc", (unsigned long)VMALLOC_START,
(unsigned long)VMALLOC_END);
#ifdef CONFIG_64BIT
print_ml("modules", (unsigned long)MODULES_VADDR,
(unsigned long)MODULES_END);
#endif
print_ml("lowmem", (unsigned long)PAGE_OFFSET,
(unsigned long)high_memory);
if (IS_ENABLED(CONFIG_64BIT)) {

0 comments on commit da06cc5

Please sign in to comment.