Bug 279720 - virtualization/bhyve: it does not boot from the slot where the parameter bootindex=1 is declared.
Summary: virtualization/bhyve: it does not boot from the slot where the parameter boot...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bhyve (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-virtualization (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-13 19:50 UTC by mario felicioni
Modified: 2024-06-14 06:51 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mario felicioni 2024-06-13 19:50:58 UTC
Hello to everyone.

I want to show you what it seems to be a bug in bhyve. Please evaluate the situation below :

/usr/sbin/./bhyve-win -S -c sockets=4,cores=2,threads=1 -m 8G -w -H \
-S -c sockets=4,cores=2,threads=1 -m 8G -w -H \
-s 0,hostbridge \
-s 1,ahci-hd,/mnt/$vmdisk0'p2'/bhyve/img/Windows/Windows11.img,bootindex=1 \
-s 2,ahci-hd,/dev/$vmdisk5 \
-s 8:0,passthru,2/0/0 \
-s 8:1,passthru,2/0/1 \
-s 8:2,passthru,2/0/2 \
-s 8:3,passthru,2/0/3 \
-s 13,virtio-net,tap18 \
-s 29,fbuf,tcp=0.0.0.0:5918,w=1600,h=950,wait \
-s 30,xhci,tablet \
-s 31,lpc \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI_CODE.fd \
vm0:18 < /dev/null & sleep 2 && vncviewer 0:18

as you can see I have attached all the slots of my GPU. Infact my Nvidia GPU has 4 slots :

02:00.0 VGA compatible controller: NVIDIA Corporation TU102 [GeForce RTX 2080 Ti] (rev a1)
02:00.1 Audio device: NVIDIA Corporation TU102 High Definition Audio Controller (rev a1)
02:00.2 USB controller: NVIDIA Corporation TU102 USB 3.1 Host Controller (rev a1)
02:00.3 Serial bus controller: NVIDIA Corporation TU102 USB Type-C UCSI Controller (rev a1)

As you can see my GPU has one USB controller and one USB port mini integrated with the controller. Well,I attached a pen drive on the port of the USB controller and then I tried to boot the Windows 11 vm. What's happened ? that,despite I have declared that I want boot the Windows11 vm at slot 1 by adding the parameter bootindex=1,instead,it booted from the USB stick attached to the mini USB port of the USB controller (yes because on that USB stick I have installed Windows 7,so it can boot). This seems to be a bug,because it does not do what I want. And it is easy to reproduce. Just put bootindex=1 to every OS that you want to boot and then attach a bootable USB stick to the usb port of the GPU (it should be recent,it should be a GPU with the USB controller integrated,but the latest high quality GPU models have it),and just run the bhyve VM and you will see that it will not boot the OS you want.
Comment 1 Corvin Köhne freebsd_committer freebsd_triage 2024-06-14 06:39:14 UTC
From https://man.freebsd.org/cgi/man.cgi?bhyve:

		   bootindex=index
			       Add  the	 device	 to the	bootorder at index.  A
			       fwcfg file is used to  specify  the  bootorder.
			       The  guest  firmware may	ignore or doesn't sup-
			       port this fwcfg file.  In that case, this  fea-
			       ture doesn't work as expected.

EDK2 for bhyve currently doesn't support the bootorder fwcfg file. Therefore, it's ignored and uses it's default bootorder.

I'm going to send a patch to upstream EDK2.
Comment 2 Corvin Köhne freebsd_committer freebsd_triage 2024-06-14 06:51:05 UTC
https://github.com/tianocore/edk2/pull/5774

When it's merged upstream, we can backport it to our EDK2 port.