Commit Graph

15 Commits

Author SHA1 Message Date
Youling Tang
859d1c0e8a MIPS32/64: Add 'irq' command support
Add support for the 'irq' series of commands in the MIPS32/64
architecture, except for the 'irq -d' command, others can be
used.  Without the patch, the 'irq' command fails as follows:

  irq: cannot determine number of IRQs

Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2021-06-09 16:57:21 +09:00
Youling Tang
4cb2e85fec MIPS64: Add 'help -r' command support
Add support form printing out the registers from the dump file. We don't
take the registers directly from the ELF notes but instead use the version
we've saved into the machine_specific structure.  If we don't do this,
we'd get misleading output when the number of ELF notes don't match the
number of online CPUs.

E.g. Without this patch:
crash> help -r
help: -r option not supported for this dumpfile

E.g. With this patch:
crash> help -r
...
CPU 3:
     R0: 0000000000000000   R1: 0000000000000001   R2: 9800000254f3c400
     R3: 0000000000000000   R4: ffffffff8123b6b0   R5: 0000000000000000
     R6: 9800000243bcf200   R7: fffffffffffffff8   R8: fffffffffffffffd
     R9: 00180000000000ff  R10: ffffffff810e29a8  R11: ffffffff80e84190
    R12: 000000005400cce0  R13: 0000000000000000  R14: 0000000000000040
    R15: 6e69636e79732074  R16: ffffffff81200000  R17: ffffffff81240000
    R18: 0000000000000000  R19: ffffffff81430000  R20: 980000024291f938
    R21: 0000000000000001  R22: 980000024aef7320  R23: ffffffff81430000
    R24: 0000000000000002  R25: ffffffff80878b58  R26: 0000000000000000
    R27: 0000000000000000  R28: 980000024291c000  R29: 980000024291f930
    R30: 9800000243bcf200  R31: ffffffff802fff00
       LO: ffffffff81210000        HI: ffffffff81210000
      EPC: ffffffff802fff84  BADVADDR: ffffffff802bbe9c
   STATUS: ffffffff81430000     CAUSE: 9800000243bcf200

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2021-04-23 10:39:19 +09:00
Youling Tang
6ef54efe15 MIPS64: Add 'help -m/M' command support
Add mips64_dump_machdep_table() implementation, display machdep_table.

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2021-04-23 10:38:52 +09:00
Youling Tang
48409d764a MIPS64: Add the realization of verify symbol
Add mips64_verify_symbol() implementation, accept or reject a
symbol from the kernel namelist.

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2021-04-23 10:38:01 +09:00
Youling Tang
b5ce1f1904 MIPS64: Add 'bt -l' command support
Add 'bt -l' command support, get a line number associated with a
current pc address.

E.g. With this patch:
crash> bt -l
PID: 4768   TASK: 9800000243bcf200  CPU: 3   COMMAND: "bash"
 #0 [980000024291f930] __crash_kexec at ffffffff802fff84
    /home/tang/loongson-419/linux-4.19.152kexec/./arch/mips/include/asm/stacktrace.h: 43
 #1 [980000024291faa0] panic at ffffffff80248cac
    /home/tang/loongson-419/linux-4.19.152kexec/kernel/panic.c: 206
...

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2021-04-23 10:37:31 +09:00
Youling Tang
e9f7cdf4b8 MIPS64: Add 'bt -f' command support
Add 'bt -f' command support, display all stack data contained in a frame.

E.g. With this patch:
crash> bt -f
PID: 4768   TASK: 9800000243bcf200  CPU: 3   COMMAND: "bash"
 #0 [980000024291f930] __crash_kexec at ffffffff802fff84
    [PC: ffffffff802fff84 RA: ffffffff80248cac SP: 980000024291f930 SIZE: 368]
    980000024291f930: ffffffff81239060 ffffffff802a9944
    980000024291f940: 0000000000000001 9800000254f3c400
...

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2021-04-23 10:37:18 +09:00
Youling Tang
4b962a2ab8 MIPS64: Fixes for the gathering of the active task registers for the 'bt' command
dumpfiles:
 (1) If the kernel's crash_notes are not available, read them from
     ELF notes.
 (2) If an online CPUs did not save its ELF notes, then adjust
     the mapping of each ELF note to its CPU accordingly.

E.g. With this patch:
crash> bt
PID: 4768   TASK: 9800000243bcf200  CPU: 3   COMMAND: "bash"
 #0 [980000024291f930] __crash_kexec at ffffffff802fff84
 #1 [980000024291faa0] panic at ffffffff80248cac
 #2 [980000024291fb40] die at ffffffff8021b338
 #3 [980000024291fb70] do_page_fault at ffffffff802315e0
 #4 [980000024291fbd0] tlb_do_page_fault_1 at ffffffff80239388
 #5 [980000024291fd00] sysrq_handle_crash at ffffffff8085d308
 #6 [980000024291fd10] __handle_sysrq at ffffffff8085d9e0
 #7 [980000024291fd60] write_sysrq_trigger at ffffffff8085e020
 #8 [980000024291fd80] proc_reg_write at ffffffff804762f0
 #9 [980000024291fda0] __vfs_write at ffffffff803f3138

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2021-04-23 10:34:16 +09:00
Youling Tang
0a0ef33e86 MIPS64: Add basic support for the 'bt' command
Add basic support for the 'bt' command, refer to the implementation
of mips.c.

E.g. With this patch:
crash> bt
PID: 4768   TASK: 9800000243bcf200  CPU: 3   COMMAND: "bash"
bt: WARNING: cannot determine starting stack frame for task 9800000243bcf200

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2021-04-23 10:33:36 +09:00
Youling Tang
f80b478c78 MIPS64: Add 'mach' command support
The 'mach' command can only get some basic machine state information, such
as machine type, processor speed, etc.

E.g. With this patch:
crash> mach
       MACHINE TYPE: mips64
        MEMORY SIZE: 7.5 GB
               CPUS: 4
    PROCESSOR SPEED: 1800 Mhz
                 HZ: 250
          PAGE SIZE: 16384
  KERNEL STACK SIZE: 16384

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2021-04-23 10:32:58 +09:00
Youling Tang
1b13f7678c MIPS64: Add to get processor speed
Obtain the processor speed from the kernel symbol "mips_cpu_frequency" or
"cpu_clock_freq".

E.g. With this patch:
...
MACHINE: mips64  (1800 Mhz)
...

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2021-04-23 10:32:30 +09:00
Youling Tang
880ab39df7 MIPS64: Add 'dis' command support
Use generic_dis_filter() function to support dis command implementation.

E.g. With this patch:
crash> dis machine_kexec
0xffffffff8022dfd0 <machine_kexec>:     daddiu  sp,sp,-48
0xffffffff8022dfd4 <machine_kexec+4>:   sd      s2,24(sp)
0xffffffff8022dfd8 <machine_kexec+8>:   sd      s1,16(sp)
...

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2021-04-23 10:31:45 +09:00
Youling Tang
adc7788bb8 MIPS64: Add 'pte' command support
The pte command converts the pte table entry into a physical address and
displays the page flags. Also fixed the pte part in the vtop command.

E.g. With this patch:
crash> vtop ffffffffc0004000
VIRTUAL           PHYSICAL
ffffffffc0004000  2504ac000

SEGMENT: sseg
PAGE DIRECTORY: ffffffff81330000
  PGD: ffffffff81333ff8 => 9800000255828000
  PMD: 000000025582bf00 => 98000002504bc000
  PTE: 00000002504bc008 => 0000001282563e0f
 PAGE: 00000002504ac000

   PTE      PHYSICAL   FLAGS
1282563e0f  2504ac000  (PRESENT|WRITE|ACCESSED|MODIFIED|GLOBAL|VALID|DIRTY)

      PAGE       PHYSICAL      MAPPING       INDEX CNT FLAGS
9800000257f04ac0 2504ac000                0        0  1 2501fff000000
crash> pte 1282563e0f
   PTE      PHYSICAL   FLAGS
1282563e0f  2504ac000  (PRESENT|WRITE|ACCESSED|MODIFIED|GLOBAL|VALID|DIRTY)

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2021-04-23 10:31:23 +09:00
Youling Tang
9b4d67d149 MIPS64: Make the crash tool successfully enter the crash command line
1. Add mips64_init() implementation, do all necessary machine-specific setup,
which will be called multiple times during initialization.

2. Add the implementation of the vtop command, which is used to convert a
virtual address to a physical address. When entering the crash command line,
the corresponding symbols in the kernel will be read, and at the same time,
the conversion of virtual and real addresses will also be used, so the vtop
command is a prerequisite for entering the crash command line.

3. Add mips64_get_smp_cpus() implementation, get the number of online cpus.

4. Add mips64_get_page_size() implementation, get page size.

The results after applying patch 01~04 are as follows:
...
      KERNEL: /boot/vmlinux-4.19.161kexec+
    DUMPFILE: /home/tang/vmcore_4.19.161
        CPUS: 4
        DATE: Mon Jan 25 18:54:14 HKT 2021
      UPTIME: (cannot calculate: unknown HZ value)
LOAD AVERAGE: 0.24, 0.21, 0.09
       TASKS: 348
    NODENAME: bogon
     RELEASE: 4.19.161kexec+
     VERSION: #15 SMP PREEMPT Mon Jan 25 17:56:16 HKT 2021
     MACHINE: mips64  (unknown Mhz)
      MEMORY: 0
       PANIC: "CPU 3 Unable to handle kernel paging request at virtual address 0000000000000000, epc == ffffffff8085d318, ra == ffffffff8085d308"
         PID: 4768
     COMMAND: "bash"
        TASK: 9800000243bcf200  [THREAD_INFO: 980000024291c000]
         CPU: 3
       STATE: TASK_RUNNING (PANIC)

crash>

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2021-04-23 10:30:45 +09:00
Youling Tang
f90335097f MIPS64: Support getting regs from kdump dumpfiles
Add support for using the notes in MIPS kdump compressed format dumpfiles.

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2021-04-23 10:29:18 +09:00
Youling Tang
52f44631e3 Add MIPS64 framework code support
Mainly added some environment configurations, macro definitions, specific
architecture structures and some function declarations supported by the
MIPS64 architecture.

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2021-04-23 10:26:40 +09:00