VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/README@ 108794

Last change on this file since 108794 was 108794, checked in by vboxsync, 2 weeks ago

Devices/EFI/FirmwareNew: Merge edk2-stable202502 from the vendor branch and make it build for the important platforms, bugref:4643

  • Property svn:eol-style set to native
File size: 18.2 KB
Line 
1
2=== OVMF OVERVIEW ===
3
4The Open Virtual Machine Firmware (OVMF) project aims
5to support firmware for Virtual Machines using the edk2
6code base. More information can be found at:
7
8http://www.tianocore.org/ovmf/
9
10=== STATUS ===
11
12Current capabilities:
13* IA32 and X64 architectures
14* QEMU (version 1.7.1 or later, with 1.7 or later machine types)
15 - Video, keyboard, IDE, CD-ROM, serial
16 - Runs UEFI shell
17 - Optional NIC support.
18* UEFI Linux boots
19* UEFI Windows 8 boots
20* UEFI Windows 7 & Windows 2008 Server boot (see important notes below!)
21
22=== FUTURE PLANS ===
23
24* Test/Stabilize UEFI Self-Certification Tests (SCT) results
25
26=== BUILDING OVMF ===
27
28Pre-requisites:
29* Build environment capable of build the edk2 MdeModulePkg.
30* A properly configured ASL compiler:
31 - Intel ASL compiler: Available from
32 https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/download.html
33 - Microsoft ASL compiler: Available from
34 https://learn.microsoft.com/en-us/windows-hardware/drivers/bringup/microsoft-asl-compiler
35* NASM: https://www.nasm.us/
36
37Update Conf/target.txt ACTIVE_PLATFORM for OVMF:
38 PEI arch DXE arch UEFI interfaces
39* OvmfPkg/OvmfPkgIa32.dsc IA32 IA32 IA32
40* OvmfPkg/OvmfPkgIa32X64.dsc IA32 X64 X64
41* OvmfPkg/OvmfPkgX64.dsc X64 X64 X64
42
43Update Conf/target.txt TARGET_ARCH based on the .dsc file:
44 TARGET_ARCH
45* OvmfPkg/OvmfPkgIa32.dsc IA32
46* OvmfPkg/OvmfPkgIa32X64.dsc IA32 X64
47* OvmfPkg/OvmfPkgX64.dsc X64
48
49Following the edk2 build process, you will find the OVMF binaries
50under the $WORKSPACE/Build/*/*/FV directory. The actual path will
51depend on how your build is configured. You can expect to find
52these binary outputs:
53* OVMF.FD
54 - Please note! This filename has changed. Older releases used OVMF.Fv.
55* OvmfVideo.rom
56 - This file is not built separately any longer, starting with svn r13520.
57
58If you are new to building in edk2 or looking for the latest build
59instructions, visit https://github.com/tianocore/tianocore.github.io/wiki/Build-Instructions
60
61More OVMF-specific build information can be found at:
62
63https://github.com/tianocore/tianocore.github.io/wiki/How%20to%20build%20OVMF
64
65=== RUNNING OVMF on QEMU ===
66
67* Be sure to use qemu-system-x86_64, if you are using an X64 firmware.
68 (qemu-system-x86_64 works for the IA32 firmware as well, of course.)
69* Use OVMF for QEMU firmware (3 options available)
70 - Option 1: Use QEMU -pflash parameter
71 * QEMU/OVMF will use emulated flash, and fully support UEFI variables
72 * Run qemu with: -pflash path/to/OVMF.fd
73 * Note that this option is required for running SecureBoot-enabled builds
74 (-D SECURE_BOOT_ENABLE).
75 - Option 2: Use QEMU -bios parameter
76 * Note that UEFI variables will be partially emulated, and non-volatile
77 variables may lose their contents after a reboot
78 * Run qemu with: -bios path/to/OVMF.fd
79 - Option 3: Use QEMU -L parameter
80 * Note that UEFI variables will be partially emulated, and non-volatile
81 variables may lose their contents after a reboot
82 * Either copy, rename or symlink OVMF.fd => bios.bin
83 * Use the QEMU -L parameter to specify the directory where the bios.bin
84 file is located.
85* The EFI shell is built into OVMF builds at this time, so it should
86 run automatically if a UEFI boot application is not found on the
87 removable media.
88* On Linux, newer version of QEMU may enable KVM feature, and this might
89 cause OVMF to fail to boot. The QEMU '-no-kvm' may allow OVMF to boot.
90* Capturing OVMF debug messages on qemu:
91 - The default OVMF build writes debug messages to IO port 0x402. The
92 following qemu command line options save them in the file called
93 debug.log: '-debugcon file:debug.log -global isa-debugcon.iobase=0x402'.
94 - It is possible to revert to the original behavior, when debug messages were
95 written to the emulated serial port (potentially intermixing OVMF debug
96 output with UEFI serial console output). For this the
97 '-D DEBUG_ON_SERIAL_PORT' option has to be passed to the build command (see
98 the next section), and in order to capture the serial output qemu needs to
99 be started with eg. '-serial file:serial.log'.
100 - Debug messages fall into several categories. Logged vs. suppressed
101 categories are controlled at OVMF build time by the
102 'gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel' bitmask (an UINT32
103 value) in the selected .dsc file. Individual bits of this bitmask are
104 defined in <MdePkg/Include/Library/DebugLib.h>. One non-default bit (with
105 some performance impact) that is frequently set for debugging is 0x00400000
106 (DEBUG_VERBOSE).
107 - The RELEASE build target ('-b RELEASE' build option, see below) disables
108 all debug messages. The default build target is DEBUG.
109
110=== Build Scripts ===
111
112On systems with the bash shell you can use OvmfPkg/build.sh to simplify
113building and running OVMF.
114
115So, for example, to build + run OVMF X64:
116$ OvmfPkg/build.sh -a X64
117$ OvmfPkg/build.sh -a X64 qemu
118
119And to run a 64-bit UEFI bootable ISO image:
120$ OvmfPkg/build.sh -a X64 qemu -cdrom /path/to/disk-image.iso
121
122To build a 32-bit OVMF without debug messages using GCC 4.8:
123$ OvmfPkg/build.sh -a IA32 -b RELEASE -t GCC48
124
125=== Secure Boot ===
126
127Secure Boot is a security feature that ensures only trusted and digitally
128signed software is allowed to run during the boot process. This is achieved
129by storing Secure Boot keys in UEFI Variables, as result it can be easily
130bypassed by writing directly to the flash varstore. To avoid this situation,
131it's necessary to make the varstore with SB keys read-only and/or provide an
132isolated execution environment for flash access (such as SMM).
133
134* In order to support Secure Boot, OVMF must be built with the
135 "-D SECURE_BOOT_ENABLE" option.
136
137* By default, OVMF is not shipped with any SecureBoot keys installed. The user
138 need to install them with "Secure Boot Configuration" utility in the firmware
139 UI, or enroll the default UEFI keys using the OvmfPkg/EnrollDefaultKeys app.
140
141 For the EnrollDefaultKeys application, the hypervisor is expected to add a
142 string entry to the "OEM Strings" (Type 11) SMBIOS table. The string should
143 have the following format:
144
145 4e32566d-8e9e-4f52-81d3-5bb9715f9727:<Base64 X509 cert for PK and first KEK>
146
147 Such string can be generated with the following script, for example:
148
149 sed \
150 -e 's/^-----BEGIN CERTIFICATE-----$/4e32566d-8e9e-4f52-81d3-5bb9715f9727:/' \
151 -e '/^-----END CERTIFICATE-----$/d' \
152 PkKek1.pem \
153 | tr -d '\n' \
154 > PkKek1.oemstr
155
156 - Using QEMU 5.2 or later, the SMBIOS type 11 field can be specified from a
157 file:
158
159 -smbios type=11,path=PkKek1.oemstr \
160
161 - Using QEMU 5.1 or earlier, the string has to be passed as a value:
162
163 -smbios type=11,value="$(< PkKek1.oemstr)"
164
165=== SMM support ===
166
167Requirements:
168* SMM support requires QEMU 2.5.
169* The minimum required QEMU machine type is "pc-q35-2.5".
170* SMM with KVM requires Linux 4.4 (host).
171
172OVMF is capable of utilizing SMM if the underlying QEMU or KVM hypervisor
173emulates SMM. SMM is put to use in the S3 suspend and resume infrastructure,
174and in the UEFI variable driver stack. The purpose is (virtual) hardware
175separation between the runtime guest OS and the firmware (OVMF), with the
176intent to make Secure Boot actually secure, by preventing the runtime guest OS
177from tampering with the variable store and S3 areas.
178
179For SMM support, OVMF must be built with the "-D SMM_REQUIRE" option. The
180resultant firmware binary will check if QEMU actually provides SMM emulation;
181if it doesn't, then OVMF will log an error and trigger an assertion failure
182during boot (even in RELEASE builds). Both the naming of the flag (SMM_REQUIRE,
183instead of SMM_ENABLE), and this behavior are consistent with the goal
184described above: this is supposed to be a security feature, and fallbacks are
185not allowed. Similarly, a pflash-backed variable store is a requirement.
186
187QEMU should be started with the options listed below (in addition to any other
188guest-specific flags). The command line should be gradually composed from the
189hints below. '\' is used to extend the command line to multiple lines, and '^'
190can be used on Windows.
191
192* QEMU binary and options specific to 32-bit guests:
193
194 $ qemu-system-i386 -cpu coreduo,-nx \
195
196 or
197
198 $ qemu-system-x86_64 -cpu <MODEL>,-lm,-nx \
199
200* QEMU binary for running 64-bit guests (no particular options):
201
202 $ qemu-system-x86_64 \
203
204* Flags common to all SMM scenarios (only the Q35 machine type is supported):
205
206 -machine q35,smm=on,accel=(tcg|kvm) \
207 -m ... \
208 -smp ... \
209 -global driver=cfi.pflash01,property=secure,value=on \
210 -drive if=pflash,format=raw,unit=0,file=OVMF_CODE.fd,readonly=on \
211 -drive if=pflash,format=raw,unit=1,file=copy_of_OVMF_VARS.fd \
212
213* In order to disable S3, add:
214
215 -global ICH9-LPC.disable_s3=1 \
216
217=== Network Support ===
218
219OVMF provides a UEFI network stack by default. Its lowest level driver is the
220NIC driver, higher levels are generic. In order to make DHCP, PXE Boot, and eg.
221socket test utilities from the StdLib edk2 package work, (1) qemu has to be
222configured to emulate a NIC, (2) a matching UEFI NIC driver must be available
223when OVMF boots.
224
225(If a NIC is configured for the virtual machine, and -- dependent on boot order
226-- PXE booting is attempted, but no DHCP server responds to OVMF's DHCP
227DISCOVER message at startup, the boot process may take approx. 3 seconds
228longer.)
229
230* For each NIC emulated by qemu, a GPLv2 licensed UEFI driver is available from
231 the iPXE project. The qemu source distribution contains prebuilt binaries of
232 these drivers (and of course allows one to rebuild them from source as well).
233 This is the recommended set of drivers.
234
235* Use the qemu -netdev and -device options, or the legacy -net option, to
236 enable NIC support: <http://wiki.qemu.org/Documentation/Networking>.
237
238* The iPXE drivers are automatically available to and configured for OVMF in
239 the default qemu installation.
240
241* Independently of the iPXE NIC drivers, the default OVMF build provides a
242 basic virtio-net driver, located in OvmfPkg/VirtioNetDxe.
243
244* Also independently of the iPXE NIC drivers, Intel's proprietary E1000 NIC
245 driver (from the BootUtil distribution) can be embedded in the OVMF image at
246 build time:
247
248 - Download BootUtil:
249 - Navigate to
250 https://downloadcenter.intel.com/download/19186/Ethernet-Intel-Ethernet-Connections-Boot-Utility-Preboot-Images-and-EFI-Drivers
251 - Click the download link for "PREBOOT.EXE".
252 - Accept the Intel Software License Agreement that appears.
253 - Unzip "PREBOOT.EXE" into a separate directory (this works with the
254 "unzip" utility on platforms different from Windows as well).
255 - Copy the "APPS/EFI/EFIx64/E3522X2.EFI" driver binary to
256 "Intel3.5/EFIX64/E3522X2.EFI" in your WORKSPACE.
257 - Intel have stopped distributing an IA32 driver binary (which used to
258 match the filename pattern "E35??E2.EFI"), thus this method will only
259 work for the IA32X64 and X64 builds of OVMF.
260
261 - Include the driver in OVMF during the build:
262 - Add "-D E1000_ENABLE" to your build command (only when building
263 "OvmfPkg/OvmfPkgIa32X64.dsc" or "OvmfPkg/OvmfPkgX64.dsc").
264 - For example: "build -D E1000_ENABLE".
265
266* When a matching iPXE driver is configured for a NIC as described above, it
267 takes priority over other drivers that could possibly drive the card too:
268
269 | e1000 ne2k_pci pcnet rtl8139 virtio-net-pci
270 ---------------------+------------------------------------------------
271 iPXE | x x x x x
272 VirtioNetDxe | x
273 Intel BootUtil (X64) | x
274
275=== HTTPS Boot ===
276
277HTTPS Boot is an alternative solution to PXE. It replaces the tftp server
278with a HTTPS server so the firmware can download the images through a trusted
279and encrypted connection.
280
281* To enable HTTPS Boot, you have to build OVMF with -D NETWORK_HTTP_BOOT_ENABLE
282 and -D NETWORK_TLS_ENABLE. The former brings in the HTTP stack from
283 NetworkPkg while the latter enables TLS support in both NetworkPkg and
284 CryptoPkg.
285
286 If you want to exclude the unsecured HTTP connection completely, OVMF has to
287 be built with -D NETWORK_ALLOW_HTTP_CONNECTIONS=FALSE so that only the HTTPS
288 connections will be accepted.
289
290* By default, there is no trusted certificate. The user has to import the
291 certificates either manually with "Tls Auth Configuration" utility in the
292 firmware UI or through the fw_cfg entry, etc/edk2/https/cacerts.
293
294 -fw_cfg name=etc/edk2/https/cacerts,file=<certdb>
295
296 The blob for etc/edk2/https/cacerts has to be in the format of Signature
297 Database(*1). You can use p11-kit(*2) or efisiglit(*3) to create the
298 certificate list.
299
300 If you want to create the certificate list based on the CA certificates
301 in your local host, p11-kit will be a good choice. Here is the command to
302 create the list:
303
304 p11-kit extract --format=edk2-cacerts --filter=ca-anchors \
305 --overwrite --purpose=server-auth <certdb>
306
307 If you only want to import one certificate, efisiglist is the tool for you:
308
309 efisiglist -a <cert file> -o <certdb>
310
311 Please note that the certificate has to be in the DER format.
312
313 You can also append a certificate to the existing list with the following
314 command:
315
316 efisiglist -i <old certdb> -a <cert file> -o <new certdb>
317
318 NOTE: You may need the patch to make efisiglist generate the correct header.
319 (https://github.com/rhboot/pesign/pull/40)
320
321* Besides the trusted certificates, it's also possible to configure the trusted
322 cipher suites for HTTPS through another fw_cfg entry: etc/edk2/https/ciphers.
323
324 OVMF expects a binary UINT16 array which comprises the cipher suites HEX
325 IDs(*4). If the cipher suite list is given, OVMF will choose the cipher
326 suite from the intersection of the given list and the built-in cipher
327 suites. Otherwise, OVMF just chooses whatever proper cipher suites from the
328 built-in ones.
329
330 - Using QEMU 5.2 or later, QEMU can expose the ordered list of permitted TLS
331 cipher suites from the host side to OVMF:
332
333 -object tls-cipher-suites,id=mysuite0,priority=@SYSTEM \
334 -fw_cfg name=etc/edk2/https/ciphers,gen_id=mysuite0
335
336 (Refer to the QEMU manual and to
337 <https://gnutls.org/manual/html_node/Priority-Strings.html> for more
338 information on the "priority" property.)
339
340 - Using QEMU 5.1 or earlier, the array has to be passed from a file:
341
342 -fw_cfg name=etc/edk2/https/ciphers,file=<cipher suites>
343
344 whose contents can be generated with the following script, for example:
345
346 export LC_ALL=C
347 openssl ciphers -V \
348 | sed -r -n \
349 -e 's/^ *0x([0-9A-F]{2}),0x([0-9A-F]{2}) - .*$/\\\\x\1 \\\\x\2/p' \
350 | xargs -r -- printf -- '%b' > ciphers.bin
351
352 This script creates ciphers.bin that contains all the cipher suite IDs
353 supported by openssl according to the local host configuration.
354
355 You may want to enable only a limited set of cipher suites. Then, you
356 should check the validity of your list first:
357
358 openssl ciphers -V <cipher list>
359
360 If all the cipher suites in your list map to the proper HEX IDs, go ahead
361 to modify the script and execute it:
362
363 export LC_ALL=C
364 openssl ciphers -V <cipher list> \
365 | sed -r -n \
366 -e 's/^ *0x([0-9A-F]{2}),0x([0-9A-F]{2}) - .*$/\\\\x\1 \\\\x\2/p' \
367 | xargs -r -- printf -- '%b' > ciphers.bin
368
369(*1) See "31.4.1 Signature Database" in UEFI specification 2.7 errata A.
370(*2) p11-kit: https://github.com/p11-glue/p11-kit/
371(*3) efisiglist: https://github.com/rhboot/pesign/blob/master/src/efisiglist.c
372(*4) https://wiki.mozilla.org/Security/Server_Side_TLS#Cipher_names_correspondence_table
373
374=== OVMF Flash Layout ===
375
376Like all current IA32/X64 system designs, OVMF's firmware device (rom/flash)
377appears in QEMU's physical address space just below 4GB (0x100000000).
378
379OVMF supports building a 1MB, 2MB or 4MB flash image (see the DSC files for the
380FD_SIZE_1MB, FD_SIZE_2MB, FD_SIZE_4MB build defines). The base address for the
3811MB image in QEMU physical memory is 0xfff00000. The base address for the 2MB
382image is 0xffe00000. The base address for the 4MB image is 0xffc00000.
383
384Using the 1MB or 2MB image, the layout of the firmware device in memory looks
385like:
386
387+--------------------------------------- 4GB (0x100000000)
388| VTF0 (16-bit reset code) and OVMF SEC
389| (SECFV, 208KB/0x34000)
390+--------------------------------------- varies based on flash size
391|
392| Compressed main firmware image
393| (FVMAIN_COMPACT)
394|
395+--------------------------------------- base + 0x20000
396| Fault-tolerant write (FTW)
397| Spare blocks (64KB/0x10000)
398+--------------------------------------- base + 0x10000
399| FTW Work block (4KB/0x1000)
400+--------------------------------------- base + 0x0f000
401| Event log area (4KB/0x1000)
402+--------------------------------------- base + 0x0e000
403| Non-volatile variable storage
404| area (56KB/0xe000)
405+--------------------------------------- base address
406
407Using the 4MB image, the layout of the firmware device in memory looks like:
408
409+--------------------------------------- base + 0x400000 (4GB/0x100000000)
410| VTF0 (16-bit reset code) and OVMF SEC
411| (SECFV, 208KB/0x34000)
412+--------------------------------------- base + 0x3cc000
413|
414| Compressed main firmware image
415| (FVMAIN_COMPACT, 3360KB/0x348000)
416|
417+--------------------------------------- base + 0x84000
418| Fault-tolerant write (FTW)
419| Spare blocks (264KB/0x42000)
420+--------------------------------------- base + 0x42000
421| FTW Work block (4KB/0x1000)
422+--------------------------------------- base + 0x41000
423| Event log area (4KB/0x1000)
424+--------------------------------------- base + 0x40000
425| Non-volatile variable storage
426| area (256KB/0x40000)
427+--------------------------------------- base address (0xffc00000)
428
429The code in SECFV locates FVMAIN_COMPACT, and decompresses the
430main firmware (MAINFV) into RAM memory at address 0x800000. The
431remaining OVMF firmware then uses this decompressed firmware
432volume image.
433
434=== UEFI Windows 7 & Windows 2008 Server ===
435
436* One of the '-vga std' and '-vga qxl' QEMU options should be used.
437* Only one video mode, 1024x768x32, is supported at OS runtime.
438* The '-vga qxl' QEMU option is recommended. After booting the installed
439 guest OS, select the video card in Device Manager, and upgrade its driver
440 to the QXL XDDM one. Download location:
441 <http://www.spice-space.org/download.html>, Guest | Windows binaries.
442 This enables further resolutions at OS runtime, and provides S3
443 (suspend/resume) capability.
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette