quic / gunyah-hypervisor

Gunyah is a Type-1 hypervisor designed for strong security, performance and modularity.
Other
313 stars 58 forks source link

How to Set a Breakpoint at pvm start_kernel #26

Closed eismog closed 6 months ago

eismog commented 6 months ago
  1. While debugging, I found that pvm KASLR is enabled: [ 0.000000] KASLR enabled

  2. PVM HLOS mem info [RM]HLOS Mem Base : 40000000 [RM]HLOS Mem Size : 40000000 [RM]HLOS IPA base : 40000000 [RM]HLOS DT Ofst : f00000 [RM]RAM FS offset : 800000

  3. start_kernel addr root@qemuarm64:~# cat /proc/kallsyms |grep start_kernel ffffde1763e27d0c T secondary_start_kernel ffffde1764fb03c0 T start_kernel root@qemuarm64:~# cat /proc/kallsyms |more ffffde1763e00000 T _text

I tried to set a breakpoint, but it didn't work: add-symbol-file ./../core-utils/build/vmlinux 0xFFFFDE1763E00000 b start_kernel

eismog commented 6 months ago

Try to Add nokaslr to cmdline bootargs = "root=/dev/vda nokaslr ";

got qemu-system-aarch64 core dumped [RM]Init completed, disabling UART qemu-system-aarch64: ../target/arm/ptw.c:301: S1_ptw_translate: Assertion `fi->type != ARMFault_None' failed. ./run-qemu.sh: line 150: 11289 Aborted (core dumped) qemu-system-aarch64 -machine virt,virtualization=on,gic-version=3,highmem=off -cpu max,sve128=on -m size=$PLATFORM_DDR_SIZE -smp cpus=8 -nographic -accel tcg,thread=multi -kernel $HYP_IMG_FOLDER/hypvm.elf -device loader,file=$IMGS_FOLDER/virt.dtb,addr=$DT_BASE -device loader,file=$IMGS_FOLDER/Image,addr=$LINUX_BASE -device loader,file=$IMGS_FOLDER/initrd.img,addr=$INITRD_BASE -append "rw root=/dev/ram rdinit=/sbin/init earlyprintk=serial,ttyAMA0 console=ttyAMA0 nokaslr " ${VIRTIO_BLK_DEVMAP} $ARGS (gunyah-venv) ligf@hyp-dev-env:~/mnt/workspace$

eismog commented 6 months ago

I can break at arch/arm64/kernel/head.S,
add-symbol-file ./../core-utils/build/vmlinux 0x41010000

But I still can't break at start_kernel, qemu-system-aarch64 core dumped with Assertion `fi->type != ARMFault_None' failed.

image

eismog commented 6 months ago

rebuild qemu-9.0.0 and I can break at pvm start_kernel

=== sudo apt install libusb-1.0-0-dev

wget https://download.qemu.org/qemu-9.0.0.tar.xz tar xvJf qemu-9.0.0.tar.xz cd qemu-9.0.0 ./configure --target-list=aarch64-softmmu --enable-libusb --enable-debug make sudo make install

=== For early debug add-symbol-file ./../core-utils/build/vmlinux 0x41010000

For normal debug add-symbol-file ./../core-utils/build/vmlinux

image