Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Booting ARM using EFI #44

Open
LJKingd opened this issue Nov 1, 2024 · 7 comments
Open

Booting ARM using EFI #44

LJKingd opened this issue Nov 1, 2024 · 7 comments

Comments

@LJKingd
Copy link

LJKingd commented Nov 1, 2024

Excuse me for bothering you with a question. Currently, I can't find any feasible methods online to start Xen hyper in UEFI mode on ARM. Could you please give me some guidance? The article on Wiki about this is already out of date, and I failed when following the methods it provided.
https://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions/qemu-system-aarch64
@lorc

@lorc
Copy link
Collaborator

lorc commented Nov 4, 2024

Hi @LJKingd,

well, actually we were able to start Xen using this method on QEMU not so long ago.

Also, I am quite sure that OP-TEE CI uses Xen on QEMU with UEFI boot. You can check for scripts here: https://github.com/OP-TEE/build/blob/master/qemu_v8.mk

What problem are you facing? I believe most common issue is that UEFI does not boots in EL2...

@LJKingd
Copy link
Author

LJKingd commented Nov 4, 2024

hello @lorc Thank you for your reply. I used this command, but I can't see any output.

qemu-system-aarch64
-machine virt,gic_version=3
-machine virtualization=true
-cpu cortex-a57 -machine type=virt
-smp 4 -m 4096 -display none
-serial mon:stdio
-bios /path/to/QEMU_EFI.bin
-netdev user,id=hostnet0,hostfwd=tcp::2222-:22 -device virtio-net-device,netdev=hostnet0,mac=MAC_ADDRESS
-drive if=none,file=/path/to/xenial-server-cloudimg-arm64-uefi1.img,id=hd0 -device virtio-blk-device,drive=hd0 -boot order=d

@LJKingd
Copy link
Author

LJKingd commented Nov 7, 2024

@lorc hello, I encountered the following problem when using UEFI to boot on qemu - arm.
Xen.efi can be recognized normally.
Snipaste_2024-11-07_14-22-24
image
but after init uefi , error:
image
I found that the UEFI initialization work of Xen has been completed, but it crashes at ExitBootServices at the end.

image

@lorc
Copy link
Collaborator

lorc commented Nov 8, 2024

Hmm, this is quite strange. Looks like ExitBootServices is not installed. I am running my Xen in QEMU like this:

qemu-system-aarch64 -m 4G \
	-nographic \
	-kernel /home/lorc/work/xen/xen/xen \
	-machine virt,acpi=off,secure=off,mte=off,virtualization=on,iommu=smmuv3,gic-version=max \
	-append "dom0_mem=1G loglvl=all guest_loglvl=all console=dtuart pci-passthrough=yes" \
	-cpu cortex-a57 \
	-device guest-loader,addr=0x42000000,kernel=/home/lorc/work/linux/arch/arm64/boot/Image,bootargs="console=hvc0 earlyprintk=xen nokaslr root=/dev/vda2" \
	-drive id=rootfs,file=/home/lorc/mnt/ssd/rpi5/rpi_img,if=none -device virtio-blk-pci,drive=rootfs

Could you try this way? Of course, you will need to supplement your local Xen image, Dom0 kernel image and rootfs image.

@LJKingd
Copy link
Author

LJKingd commented Nov 8, 2024

@lorc hello Thank you very much for your reply.

Let me introduce my process. I couldn't get the UEFI menu to show up using the UEFI startup method provided by Xen. So I used this method to create a basic environment with a UEFI partition:
https://cdn.kernel.org/pub/linux/kernel/people/will/docs/qemu/qemu-arm64-howto.html
Then I copied my own image to /boot/efi (debian qemu rootfs):
xen.cfg xen.efi virt-gicv3.dtb
(The file is in my attachment.)
Uploading xen_uefi_files.tar.gz…

first inter debian:
qemu-system-aarch64 -M virt
-machine virtualization=true -machine virt,gic-version=3
-cpu cortex-a57 -smp 4 -m 4096
-drive if=pflash,format=raw,file=efi.img,readonly=on
-drive if=pflash,format=raw,file=varstore.img
-drive if=virtio,format=qcow2,file=disk.img
-device virtio-scsi-pci,id=scsi0
-object rng-random,filename=/dev/urandom,id=rng0
-device virtio-rng-pci,rng=rng0
-device virtio-net-pci,netdev=net0
-netdev user,id=net0,hostfwd=tcp::8022-:22
-nographic
-virtfs local,path=/mnt/shared,mount_tag=host0,security_model=passthrough,id=host0

second:
sudo su
cd /boot/efi/
mount share dir with host:
mkdir -p /mnt/shared
sudo mount -t 9p -o trans=virtio,version=9p2000.L host0 /mnt/shared
copy files for host pc:
cp /mnt/shared/* .

Then execute it using the following command:

qemu-system-aarch64 -M virt
-machine virtualization=true -machine virt,gic-version=3
-cpu cortex-a57 -smp 4 -m 4096
-drive if=pflash,format=raw,file=efi.img,readonly=on
-drive if=pflash,format=raw,file=varstore.img
-drive if=virtio,format=qcow2,file=disk.img
-device virtio-scsi-pci,id=scsi0
-object rng-random,filename=/dev/urandom,id=rng0
-device virtio-rng-pci,rng=rng0
-device virtio-net-pci,netdev=net0
-netdev user,id=net0,hostfwd=tcp::8022-:22
-nographic
-virtfs local,path=/mnt/shared,mount_tag=host0,security_model=passthrough,id=host0

Select in the boot menu.
image
image
image
inter uefi shell:
image
input: fs0:
input:xen

image

@LJKingd
Copy link
Author

LJKingd commented Nov 8, 2024

@LJKingd
Copy link
Author

LJKingd commented Nov 8, 2024

There's one more question to consult. Excuse me. Where can I obtain reliable documents for Xen on ARM? A lot of the wiki on the official website is out - of - date. @lorc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants