Commit da06cc5b authored by Palmer Dabbelt's avatar Palmer Dabbelt

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 'f9293ad4':
  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
parents 76ad33e1 f9293ad4
...@@ -44,7 +44,7 @@ SYM_CODE_START(riscv_crash_save_regs) ...@@ -44,7 +44,7 @@ SYM_CODE_START(riscv_crash_save_regs)
REG_S t6, PT_T6(a0) /* x31 */ REG_S t6, PT_T6(a0) /* x31 */
csrr t1, CSR_STATUS csrr t1, CSR_STATUS
csrr t2, CSR_EPC auipc t2, 0x0
csrr t3, CSR_TVAL csrr t3, CSR_TVAL
csrr t4, CSR_CAUSE csrr t4, CSR_CAUSE
......
...@@ -138,19 +138,37 @@ void machine_shutdown(void) ...@@ -138,19 +138,37 @@ void machine_shutdown(void)
#endif #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 * 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
* below and its goal is similar to machine_shutdown, but in case of * and its goal is to shutdown non-crashing cpus and save registers.
* a kernel crash. Since we don't handle such cases yet, this function
* is empty.
*/ */
void void
machine_crash_shutdown(struct pt_regs *regs) 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()); crash_save_cpu(regs, smp_processor_id());
machine_shutdown();
pr_info("Starting crashdump kernel...\n"); pr_info("Starting crashdump kernel...\n");
} }
...@@ -171,7 +189,7 @@ machine_kexec(struct kimage *image) ...@@ -171,7 +189,7 @@ machine_kexec(struct kimage *image)
struct kimage_arch *internal = &image->arch; struct kimage_arch *internal = &image->arch;
unsigned long jump_addr = (unsigned long) image->start; unsigned long jump_addr = (unsigned long) image->start;
unsigned long first_ind_entry = (unsigned long) &image->head; 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 this_hart_id = cpuid_to_hartid_map(this_cpu_id);
unsigned long fdt_addr = internal->fdt_addr; unsigned long fdt_addr = internal->fdt_addr;
void *control_code_buffer = page_address(image->control_code_page); void *control_code_buffer = page_address(image->control_code_page);
......
...@@ -135,6 +135,10 @@ static void __init print_vm_layout(void) ...@@ -135,6 +135,10 @@ static void __init print_vm_layout(void)
(unsigned long)VMEMMAP_END); (unsigned long)VMEMMAP_END);
print_ml("vmalloc", (unsigned long)VMALLOC_START, print_ml("vmalloc", (unsigned long)VMALLOC_START,
(unsigned long)VMALLOC_END); (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, print_ml("lowmem", (unsigned long)PAGE_OFFSET,
(unsigned long)high_memory); (unsigned long)high_memory);
if (IS_ENABLED(CONFIG_64BIT)) { if (IS_ENABLED(CONFIG_64BIT)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment