Last active
August 18, 2022 14:21
-
-
Save cwshu/122a2b40abe1372c7cc44ef177694635 to your computer and use it in GitHub Desktop.
QEMU breakpoint at start_kernel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For RISC-V Linux v5.18 | |
# Add Linux symbol (before MMU setup) | |
add-symbol-file vmlinux -o -0xfffffffeffe00000 | |
# OpenSBI symbol | |
add-symbol-file fw_jump.elf | |
# Linux kernel 1st line | |
br *0x80200000 | |
c | |
# Tricky routine to set breakpoint just after MMU setup ($pc at 0xffffffff80001160) | |
# refer to: https://elixir.bootlin.com/linux/v5.18/source/arch/riscv/kernel/head.S#L73 | |
# 1) goto relocate_enable_mmu() | |
br relocate_enable_mmu | |
c | |
# 2) si to instr 'csrw satp,a0' | |
si 22 | |
# 3) goto return address of relocate_enable_mmu() | |
# (remove breakpoint / symbol file before MMU setup) | |
br *$ra | |
del 1 | |
remove-symbol-file -a 0x0000000080200000 | |
c | |
# 4) Add Linux symbol (after MMU setup) | |
add-symbol-file vmlinux | |
# Normal use: (e.g. start_kernel) | |
br start_kernel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment