zoukankan      html  css  js  c++  java
  • Quick QEMU

    Cheatsheet for qemu

    Debug Kernel

    1. Preparation, make sure you have already install these tools. Here, mine as follow:
    • gdb 10.1-4
    • qemu 5.2.0-3
    • make 4.3-3
    • binutil 2.36.1-2▫
    1. compile the kernel with debug configuration, we need three files here
    • vmlinux (symbols)
    • arch/x86-64-/boot/bzImage (kenel image in compressed format)
    • scripts/gdb/vmlinux-gdb.py (gdb scripts)
    1. Lauch the emulator at src directory by excuting command▫
    qemu-system-x86_64 -enable-kvm -S -s 
        -kernel ./arch/x86_64/boot/bzImage 
        -initrd ./rootfs.cpio.gz -nographic 
        -append 'nokaslr console=ttyS0'
    
    • --nographic start without gui
    • -S will not run until connected with a gdb client
    • -gdb tcp::[port] run a gdbserver with open port at [port] by tcp

    PS: -s tells QEMU to start a GDB server on port 1234. -S can be appended to pause the VM before starting to run.

    1. GDB debuger
      1. gdb vmlinux
      2. gdb: target remote :1234
      3. lx-symbols
      4. break start_kernel or hb start_kernel
      5. continute

    BUGs FIX

    1. cannot insert breakpoints at 0xfffffffxxxxx

    use nokaslr or turn off KASLR while compile by set .config with CONFIG_RANDOMIZE_BASE = n

    1. qemu output(endless rebooting):
       Booting from ROM...
       Probing EDD (edd=off to disable)... ok
       arly console in extract_kernel
       input_data: 0x0000000002c773b4
       input_len: 0x000000000090c470
       output: 0x0000000001000000
       output_len: 0x000000000173a968
       kernel_total_size: 0x00000000025a7000
    
       Decompressing Linux... Parsing ELF...
    
    

    solution:
    https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=e3d03598e8ae7d195af5d3d049596dec336f569f
    just add serval lines at arch/x86/Makefile 223

    ifdef CONFIG_X86_64  
    LDFLAGS += $(call ld-option, -z max-page-size=0x200000)  
    endif                                                                                                                                                                                                                                  ```
  • 相关阅读:
    I2S波形解析
    F407整点原子I2C波形解码
    WAVE格式文件说明
    ADC结构体初始化成员
    这次,我是真的想吐槽MDK
    I2S源程序(正点原子F407探索者)
    强制类型转换
    嵌套结构体的初始化
    lua 元方法 __index
    lua pairs 与 ipairs
  • 原文地址:https://www.cnblogs.com/sonnet/p/14691029.html
Copyright © 2011-2022 走看看