how to use UEFI?

121 views
Skip to first unread message

Chuck Tuffli

unread,
Aug 15, 2023, 6:49:48 PM8/15/23
to crosvm-dev
I gather from a post to the edk2 mailing list [1] that it is possible to use OVMF to boot a UEFI image, but I haven't been able to figure out how to do this. What I have so far
 - a crosvm image that is able to boot a Linux image as described in the book
 - OVMF built from sys-firmware/edk2-ovmf-crosvm [2] with the Google patches

How do I pass the various CROSVM*.fd files to crosvm? What other options/configuration/parameters will I need to tweak to be able to boot a disk image with a UEFI partition? TIA!


--chuck

Mike Gerow

unread,
Aug 15, 2023, 7:18:11 PM8/15/23
to Chuck Tuffli, crosvm-dev
On Tue, Aug 15, 2023 at 3:49 PM Chuck Tuffli <ctu...@gmail.com> wrote:
>
> I gather from a post to the edk2 mailing list [1] that it is possible to use OVMF to boot a UEFI image, but I haven't been able to figure out how to do this. What I have so far
> - a crosvm image that is able to boot a Linux image as described in the book
> - OVMF built from sys-firmware/edk2-ovmf-crosvm [2] with the Google patches
>
> How do I pass the various CROSVM*.fd files to crosvm? What other options/configuration/parameters will I need to tweak to be able to boot a disk image with a UEFI partition? TIA!
$ crosvm run --bios CROSVM_CODE.fd --pflash CROSVM_VARS.fd --rwdisk
path/to/uefi-bootable-disk

Is probably where you'd start.

--
Mike Gerow
ge...@google.com

Chuck Tuffli

unread,
Aug 15, 2023, 8:15:14 PM8/15/23
to crosvm-dev, Mike Gerow, crosvm-dev, Chuck Tuffli
Thanks, Mike. This seems to work using Linux as a host (i.e., using kvm), but on Windows this hits an exception (below). Is this a limitation of the Whpx hypervisor or a missing piece of Windows-specific functionality in crosvm? Note that passing the kernel and initrd for this disk image using Windows as a host boots correctly.

PS C:\crosvm> cargo run --features all-msvc64,whpx -- run --bios .\CROSVM_CODE.fd --rwdisk .\debian-12-nocloud-amd64-20230802-1460.raw,sparse=false,root --mem size=1024
    Finished dev [unoptimized + debuginfo] target(s) in 0.83s
     Running `target\debug\crosvm.exe run --bios .\CROSVM_CODE.fd --rwdisk .\debian-12-nocloud-amd64-20230802-1460.raw,sparse=false,root --mem size=1024`
[2023-08-15T23:31:11.368136500+00:00 INFO  crosvm] crosvm started.
[2023-08-15T23:31:11.369502300+00:00 INFO  crosvm] CLI arguments parsed.
[2023-08-15T23:31:11.506935700+00:00 INFO  base::sys::windows::platform_timer_resolution] Successfully set timer res to 0.5ms with NtSetTimerResolution. Measured 1526us.
[2023-08-15T23:31:11.511760500+00:00 INFO  crosvm::sys::windows::main] DLL loaded: "ntmarta.dll"
[2023-08-15T23:31:11.514635600+00:00 INFO  crosvm::sys::windows] Creating Whpx
[2023-08-15T23:31:11.646815900+00:00 INFO  crosvm::sys::windows] Creating WHPX split irqchip
[2023-08-15T23:31:11.648689800+00:00 INFO  disk] disk size 2147483648,
[2023-08-15T23:31:11.648988000+00:00 INFO  disk] Disk image file is hosted on file system type 0
[2023-08-15T23:31:11.660589400+00:00 INFO  crosvm::sys::windows] TSC offset standard deviation is: 0
!!!! X64 Exception Type - 0D(#GP - General Protection)  CPU Apic ID - 00000000 !!!!
ExceptionData - 0000000000000000
RIP  - 000000003FF634A7, CS  - 0000000000000018, RFLAGS - 0000000000000006
RAX  - 0000000000000000, RCX - 0000000000000017, RDX - 0000000049656E69
RBX  - 0000000000000000, RSP - 000000003C01C488, RBP - 000000003FF58400
RSI  - 0000000000000000, RDI - 000000003FF58400
R8   - 000000003C01C47C, R9  - 000000003C01C478, R10 - 0000000000000000
R11  - 000000003FF74D40, R12 - 000000003FF5BE98, R13 - 0000000000000000
R14  - 000000003FD60000, R15 - 000000003C01C5E0
DS   - 0000000000000008, ES  - 0000000000000008, FS  - 0000000000000008
GS   - 0000000000000008, SS  - 0000000000000008
CR0  - 0000000080000033, CR2 - 0000000000000000, CR3 - 0000000000800000
CR4  - 0000000000000668, CR8 - 0000000000000000
DR0  - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
DR3  - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400
GDTR - 00000000FFFFFEE0 0000000000000027, LDTR - 0000000000000000
IDTR - 000000003C01DD70 000000000000021F,   TR - 0000000000000000
FXSAVE_STATE - 000000003C01C0E0
!!!! Find image based on IP(0x3FF634A7) (No PDB)  (ImageBase=000000003FF63000, EntryPoint=000000003FF6A12C) !!!!

Fangjian Zhong

unread,
Aug 15, 2023, 8:28:59 PM8/15/23
to crosvm-dev, Chuck Tuffli, Mike Gerow, crosvm-dev
According to trace log, there is an GP exception triggered inside OVMF.
You can try to add following build options to generate OVMF binary for more debug message, these options worked for me:
"-b DEBG -D DEBUG_ON_SERIAL_PORT"
Reply all
Reply to author
Forward
0 new messages