Created
October 9, 2025 18:32
-
-
Save congwang-mk/858077cc81a63ba75bc344ee2b45fda5 to your computer and use it in GitHub Desktop.
multikernel.sh
This file contains hidden or 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
| #!/bin/bash | |
| cat /proc/iomem | |
| echo "0000:09:00.0" > /sys/bus/pci/devices/0000:09:00.0/driver/unbind | |
| shared_mem=$(grep Multikernel /proc/iomem | awk '{print $1}' | cut -d'-' -f1) | |
| memmap=$( | |
| awk '/Multikernel Shared/ { | |
| addr_range = $1; | |
| gsub(/^[ \t]+|[ \t]+$/, "", addr_range); | |
| split(addr_range, addr, "-"); | |
| start = strtonum("0x" addr[1]); | |
| end = strtonum("0x" addr[2]); | |
| size = end - start + 1; | |
| printf("0x%x@0x%x\n", size, start); | |
| }' /proc/iomem) | |
| cd /host/kexec-tools | |
| ./build/sbin/kexec -c -d --load-multikernel -l ../linux/arch/x86/boot/bzImage --initrd=../linux/core-new --mem-min=0x40000000 --mem-max=0x7ff00000 --command-line="init=/bin/sh console=ttyS0 nosmp acpi=off memmap=exactmap memmap=0x0009ec00@0x00001000 memmap=1G@0x40000000 vty_order=1 initcall_blacklist=virtio_blk_init,8042_init,psmouse_init,atkbd_init loglevel=7 nokaslr usbcore.nousb mk_shared_memory=0x$shared_mem memmap=$memmap pci_whitelist=1af4:1041@0000:09:00.0,1b36:000c@0000:00:03.0" | |
| echo 0 > /sys/devices/system/cpu/cpu1/online | |
| sleep 2 | |
| ./build/sbin/kexec --exec-multikernel 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment