Trying to get discrete laptop GPU running in QEMU KVM Windows


I just bought a Lenovo Legion 5 Pro with an RTX3060M. I’m running the AMDGPU driver in X windows and it works great.

I’m trying to do PCIe passthrough to a VirtMGR, KVM/QEMU virtual machine running Windows 10.

The discrete graphics are initializing with the virtual BIOS and the video does initialize with the HDMI output of the laptop, but Windows 10 does not recognize the controller as an RTX 3060. And Nvidia’s drivers do not recognize the controller as nvidia hardware.

So The hardware ends up running 800X600 with no acelleration.

I talked to the QEMU guys and they suggested a configuration change to report a serial or model number to Windows, but that did not help.

Windows 10 uses the “Microsoft Basic Display Adapter” from 2006 and cannot be convinced to use any other driver.

I have checked the hardware IDs using Device Manager and they are correct.

It feels like there is something left un-initialzed by the BIOS due to the hybrid graphics of this laptop.

I tried to install bumblebee, but that won’t initialize probably because of the vfio-pci driver being loaded.

Likewise, the nvidia binary blob won’t load either, probably for the same reason.

I’d like some help debugging this, does anyone have the time to walk me through this?

I have hybrid graphics enabled in BIOS, but there doesn’t seem to be any other setting to monkey with.

Any help would be greatly appreciated. I’m really hoping to run Windows in a VM as a slave to my linux install.

Please try extracting the vbios and attaching it in qemu.

1 Like

Thanks for the quick reply.

I don’t have windows installed anymore so I extracted the VBIOS from Lenovo’s bios update exe file (jucn38ww.exe) using this tool: GitHub - coderobe/VBiosFinder: Extract embedded VBIOS from (almost) any BIOS Update (which requires a lot of hand built additional tools)

I’m figuring out how to add vbios_1002_164d_1.rom to qemu at the moment.

I added the rom file to libvirt by editing the xml directly. It removed the rombar=“on” or what ever it said. When I was done it looked like this:

<hostdev mode="subsystem" type="pci" managed="yes">
    <address domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
  <rom bar="on" file="/home/brian/libvirt/vbios_1002_164d_1.rom"/>
  <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>

But I get no video at all now.

The vbios I got was only 44KB. A sample I downloaded for another nvidia card is 256KB.

That makes me think that the extractor missed something.

The vbios is not for the Nvidia card, which has ID=10de:2560

Well. I got the BIOS image with this: GitHub - SpaceinvaderOne/Dump_GPU_vBIOS: Script to dump the vbios from any GPU even if primary gpu on an Unraid Server

146K. It loads in qemu, but windows and the nvidia installer still don’t recognize it.

Still stuck at 800x600 with the “Microsoft Basic Display Adapter” driver.

Did you try to install the nvidia driver?

Yes. It says the same thing it has always said, Hardware not supported, compatible hardware not found.

Did you try with the driver downloaded from lenovo for your model?

The only driver available on Lenovo’s website is the audio driver. I’m not sure why.

I tried to get more information from Windows. It indicates that there is no ram on the graphics card. Clearly there is a configuration problem.

I wish I knew how to get windows to give me info about the device.

Isn’t this the driver download for your notebook model?

Thanks. That is not for my particular Legion, but I tried it anyway and it didn’t work.

Since a notebook’s dgpu differs a lot from a desktop gpu, it’s difficult to impossible to pass it through to a vm. I’d rather try with a linux vm first to check for better error messages.

That’s a great idea.

I’m working with who are experts to see if we can figure out what’s wrong.

If I can’t get it to work, i’ll create an Ubuntu VM and see what the kernel can tell me.

Can someone tell me exactly what the nvidia driver is looking for when it searches for the mobile RTX GPU?

I understand that with the 3060 Max-Q it needs a battery device. I have that installed.

What else does it need? I’m only passing the GPU, it’s sound device and the battery at the moment. I wonder if there’s something else the driver needs.

I’m running a kubuntu linux distro in a VM with the RTX 3060M passed through. The nvidia blob driver recognizes the card:

[ 1109.374329] nvidia: loading out-of-tree module taints kernel.
[ 1109.374335] nvidia: module license 'NVIDIA' taints kernel.
[ 1109.374336] Disabling lock debugging due to kernel taint
[ 1109.383654] nvidia: module verification failed: signature and/or required key missing - tainting kernel
[ 1109.392718] nvidia-nvlink: Nvlink Core is being initialized, major device number 511

[ 1109.393878] nvidia 0000:05:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=none:owns=none
[ 1109.445110] NVRM: loading NVIDIA UNIX x86_64 Kernel Module  515.48.07  Fri May 27 03:26:43 UTC 2022
[ 1109.473136] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  515.48.07  Fri May 27 03:18:00 UTC 2022
[ 1109.480285] [drm] [nvidia-drm] [GPU ID 0x00000500] Loading driver
[ 1109.515280] ACPI Warning: \_SB.PCI0.S14.S00._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20210730/nsarguments-61)
[ 1110.646083] [drm] Initialized nvidia-drm 0.0.0 20160202 for 0000:05:00.0 on minor 2
[ 1110.658309] nvidia_uvm: module uses symbols from proprietary module nvidia, inheriting taint.
[ 1110.660613] nvidia-uvm: Loaded the UVM driver, major device number 509.

When I run nvidia settings, it properly identifies the card. I haven’t put pixels on the screen because nouveau loads on bootup and doesn’t allow the card to work. Could be the same issue as windows… Not sure at the moment.

I wonder, Is this this Zen 3+ R7-6800H supported by Windows 10?

The battery is not needed. The driver doesn’t care for that.
The linux vm looks good, basic init went well. The next step would be to start an Xserver on it to check if graphics init also works.
The windows driver has an additional check on install against the pci id, to be able to install the generic driver, it has to be modified:

In general, the driver recognizes the gpu with internal checks for the gpu’s architecture.

So close.

I modified the driver I downloaded from nvidia’s website and the installer recognized the card. It attempted to install the driver, but failed.

It lists five things it can install, the middle being the graphics driver and says, “failed” after the version number.

I’ll see if I can find a log or something.

The only thing I was unsure of is the section number to use. The manufacturer code for this laptop is not listed in the inf file, making me think that something is different with it.

To be specific, the string from device manager is: PCI\VEN_10DE&DEV_2560&SUBSYS_3B0717AA

There are no 3B07s listed in the driver package. Does this mean that nvidia doesn’t yet support this laptop?

I got it!

I downloaded the latest beta driver from nvidia’s website (it happens to be a DCH studio driver) and it worked!

It’s up and running.

I’m going to create a how to this weekend and post it somewhere.

Thanks so much for your help!!!