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

2022-01-11 Thread bugtracker-admin
Issue #3310 has been updated by marietto.


with this : -bios /usr/pkg/share/qemu/edk2-x86_64-code.fd \

qemu: could not load PC BIOS '/usr/pkg/share/qemu/edk2-x86_64-code.fd'



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

* 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:


% 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=0xf000]
qemu-system-x86_64: NVMM: Failed to execute a VCPU.


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


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

2022-01-11 Thread bugtracker-admin
Issue #3310 has been updated by marietto.


Hello. I tried using the -bios parameter to add the efi code,like this :

qemu-system-x86_64 \
-machine type=q35,accel=nvmm \
-smp cpus=1 -m 8G \
-bios /home/marietto/Desktop/Files/Virt/OVMF/OVMF.fd \
-drive file=/mnt/dk26/bhyve/impish-cuda-11-4-nvidia-470.img,if=none,id=disk0 \
-device virtio-blk-pci,drive=disk0 \
-netdev user,id=net0,hostfwd=tcp:127.0.0.1:6022-:22 \
-device virtio-net-pci,netdev=net0 \  
-object rng-random,id=rng0,filename=/dev/urandom \
-device virtio-rng-pci,rng=rng0 \ 
-display curses \
-vga qxl \
-spice 
addr=127.0.0.1,port=5900,ipv4=on,disable-ticketing=on,seamless-migration=on

but it didn't work :

qemu-system-x86_64: NVMM: Unexpected RDMSR 0x3a, ignored
qemu-system-x86_64: NVMM: Unexpected WRMSR 0x3a [val=0x1], ignored
qemu-system-x86_64: NVMM: Unexpected RDMSR 0x140, ignored
qemu-system-x86_64: NVMM: Unexpected RDMSR 0xce, ignored
qemu-system-x86_64: NVMM: Unexpected WRMSR 0x140 [val=0x0], ignored
qemu-system-x86_64: NVMM: Unexpected RDMSR 0x64e, ignored
qemu-system-x86_64: NVMM: Unexpected RDMSR 0x34, ignored

and this :

qemu-system-x86_64 \
-machine type=q35,accel=nvmm \
-smp cpus=1 -m 8G \
-bios /home/marietto/Desktop/Files/Virt/OVMF/QEMU_UEFI_CODE-x86_64.fd \
-drive file=/mnt/dk26/bhyve/impish-cuda-11-4-nvidia-470.img,if=none,id=disk0 \
-device virtio-blk-pci,drive=disk0 \
-netdev user,id=net0,hostfwd=tcp:127.0.0.1:6022-:22 \
-device virtio-net-pci,netdev=net0 \  
-object rng-random,id=rng0,filename=/dev/urandom \
-device virtio-rng-pci,rng=rng0 \ 
-display curses \
-vga qxl \
-spice 
addr=127.0.0.1,port=5900,ipv4=on,disable-ticketing=on,seamless-migration=on

qemu: could not load PC BIOS 
'/home/marietto/Desktop/Files/Virt/OVMF/QEMU_UEFI_CODE-x86_64.fd'

with this : OVMF_CODE.fd =

qemu-system-x86_64: NVMM: Unexpected RDMSR 0x3a, ignored
qemu-system-x86_64: NVMM: Unexpected WRMSR 0x3a [val=0x1], ignored
qemu-system-x86_64: NVMM: Unexpected RDMSR 0x140, ignored
qemu-system-x86_64: NVMM: Unexpected RDMSR 0xce, ignored
qemu-system-x86_64: NVMM: Unexpected WRMSR 0x140 [val=0x0], ignored
qemu-system-x86_64: NVMM: Unexpected RDMSR 0x64e, ignored
qemu-system-x86_64: NVMM: Unexpected RDMSR 0x34, ignored

with this : 


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

* 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:


% 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=0xf000]
qemu-system-x86_64: NVMM: Failed to execute a VCPU.


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


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

2022-01-09 Thread bugtracker-admin
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:


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;
 }


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:


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]




Bug #3310: NVMM+QEMU fail to boot with UEFI: Mem Assist Failed [gpa=0xfff0]
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:


% 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=0xf000]
qemu-system-x86_64: NVMM: Failed to execute a VCPU.


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