[DragonFlyBSD - Bug #3310] NVMM+QEMU fail to boot with UEFI: Mem Assist Failed [gpa=0xfffffff0]

bugtracker-admin at leaf.dragonflybsd.org bugtracker-admin at leaf.dragonflybsd.org
Sun Jan 9 06:41:02 PST 2022


Issue #3310 has been updated by liweitianux.


After investigation, the issue is caused by the missing memory maps of the UEFI firmware for the guest.

The UEFI firmware are mapped by QEMU as ROM devices in the ROMD mode.  And this is excluded for guest memory mappings in the QEMU NVMM code.

I figured out the following patch that makes NVMM+QEMU to boot with UEFI:

<pre><code class="diff">
diff --git target/i386/nvmm/nvmm-all.c target/i386/nvmm/nvmm-all.c
index 290077f62..e3c948b31 100644
--- target/i386/nvmm/nvmm-all.c
+++ target/i386/nvmm/nvmm-all.c
@@ -1082,7 +1082,11 @@ nvmm_process_section(MemoryRegionSection *section, int add)
     unsigned int delta;
     uintptr_t hva;
 
-    if (!memory_region_is_ram(mr)) {
+    /*
+     * Don't exclude ROMD memory; for example, it's used to map UEFI firmware
+     * (if=pflash) and should be mapped for guest.
+     */
+    if (!memory_region_is_ram(mr) && !memory_region_is_romd(mr)) {
         return;
     }
</code></pre>

However, NVMM+QEMU is *extremely slow* and uses 100% CPU. It's even much slower than TCG (i.e., without @-accel nvmm@).

For example: for QEMU to boot into the UEFI shell on my desktop, it takes ~12 seconds with TCG, but it takes *~170 seconds with NVMM* !

Test command:

<pre>
qemu-system-x86_64 -boot menu=on \
  -drive file=OVMF_CODE.fd,if=pflash,format=raw,readonly=on \
  -drive file=OVMF_VARS.fd,if=pflash,format=raw \
  -display sdl [-accel nvmm]
</pre>


----------------------------------------
Bug #3310: NVMM+QEMU fail to boot with UEFI: Mem Assist Failed [gpa=0xfffffff0]
http://bugs.dragonflybsd.org/issues/3310#change-14242

* Author: liweitianux
* Status: In Progress
* Priority: Normal
* Category: nvmm
* Target version: 6.4
* Start date: 2022-01-09
----------------------------------------
NVMM+QEMU fail to boot with UEFI, for example:

<pre>
% qemu-system-x86_64 \
      -boot menu=on -display sdl -accel nvmm \
      -drive file=OVMF_CODE.fd,if=pflash,format=raw,readonly=on \
      -drive file=OVMF_VARS.fd,if=pflash,format=raw
NetBSD Virtual Machine Monitor accelerator is operational
qemu-system-x86_64: NVMM: Mem Assist Failed [gpa=0xfffff000]
qemu-system-x86_64: NVMM: Failed to execute a VCPU.
</pre>

The UEFI firmware can be obtained by installing the @uefi-edk2-qemu-x86_64@ package
or by downloading from: https://leaf.dragonflybsd.org/~aly/uefi/

First reported by Mario Marietto and confirmed by me, see:
https://lists.dragonflybsd.org/pipermail/users/2022-January/404898.html



-- 
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account



More information about the Bugs mailing list