Passthrough VGA: Code 12 error in Windows 7 guest

Discussions related to using VirtualBox on Linux hosts.
Post Reply
dsjstc
Posts: 20
Joined: 13. Sep 2010, 21:11
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: windows

Passthrough VGA: Code 12 error in Windows 7 guest

Post by dsjstc »

I have what feels like an almost-working passthrough VGA setup (VT-d capable system, secondary GPU unused by host, pciattach successful). However, now I'm stumped. Device Manager in the guest is reporting a "Code 12" error:
This device cannot find enough free resources that it can use. (Code 12)
If you want to use this device, you will need to disable one of the other devices on this system.
I don't believe it's a shared interrupt problem -- lsdev on the host does not show an interrupt associated with the PCI address of my guest VGA hardware.

Code: Select all

	# lspci -k

	05:00.0 VGA compatible controller: NVIDIA Corporation GT218 [GeForce 8400 GS Rev. 3] (rev a2)
		Subsystem: Device 196e:0879
		Kernel driver in use: pci-stub
		Kernel modules: nvidiafb, nouveau, nvidia_367, nvidia_367_drm

	# lsdev
	Device            DMA   IRQ  I/O Ports
	------------------------------------------------
	0000:00:19.0                   f040-f05f
	0000:00:1f.2                   f020-f03f   f060-f063   f070-f077   f080-f083   f090-f097
	0000:00:1f.3                   f000-f01f
	0000:01:00.0                     e000-e07f
	0000:05:00.0                         d000-d07f
	ACPI                           1800-1803   1804-1805   1808-180b   1820-182f   1850-1850
	acpi                      9 
	ahci                             f020-f03f     f060-f063     f070-f077     f080-f083     f090-f097
	ahci[0000:00:1f.2]         29 
	cascade             4       
	dma                            0080-008f
	dma1                           0000-001f
	dma2                           00c0-00df
	dmar0                    24 
	ehci_hcd:usb1            16 
	ehci_hcd:usb2            23 
	enp0s25                  28 
	fpu                            00f0-00ff
	i8042                  1 12 
	iTCO_wdt.0.auto                1830-1833   1860-187f
	keyboard                       0060-0060   0064-0064
	mei_me                   30 
	nvidia                   32 
	PCI                          0000-0cf7 0cf8-0cff 0d00-ffff   d000-dfff     d000-dfff       d000-dfff   e000-efff
	PCIe PME              25 26 
	pic1                           0020-0021
	pic2                           00a0-00a1
	pnp                            0290-029f   04d0-04d1   0800-087f   1854-1857
	PNP0C04:00                       00f0-00f0
	rtc0                      8    0070-0077
	serial                         03f8-03ff
	snd_hda_intel:card0         31 
	snd_hda_intel:card1         17 
	timer                     0 
	timer0                         0040-0043
	timer1                         0050-0053
	vboxpci               33 34 
	vga+                           03c0-03df
	xhci_hcd                 27
Disabling the virtual display device didn't help, and I'm really not sure what to try next. Thoughts and suggestions welcome!
dsjstc
Posts: 20
Joined: 13. Sep 2010, 21:11
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: windows

Re: Passthrough VGA: Code 12 error in Windows 7 guest

Post by dsjstc »

After upgrading the spare GPU to a GeForce GTX760, I managed to get a full GPU passthrough setup working in KVM/Qemu.

Unfortunately, in order to prevent data-centre use of consumer-grade hardware, NVidia has creatively introduced a bug to their Windows driver that causes it to fail with error "Code 43", when it detects that it is running in a virtualized environment. The only solution is to disguise the virtualization from the OS.

In KVM, this is accomplished by use of the <kvm> <hidden state='on'/> </kvm> feature. I have no idea whether there is an analagous features in VirtualBox.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Passthrough VGA: Code 12 error in Windows 7 guest

Post by socratis »

dsjstc wrote:in order to prevent data-centre use of consumer-grade hardware, NVidia has creatively introduced a bug to their Windows driver that causes it to fail with error "Code 43", when it detects that it is running in a virtualized environment.
Seriously now? Really? How many data centers do they envision that they'll be using PCI pass-through? So, if you downgrade your driver, does it work?
dsjstc wrote:In KVM, this is accomplished by use of the <kvm> <hidden state='on'/> </kvm> feature. I have no idea whether there is an analagous features in VirtualBox.
I don't think there is. Not one that I know of at least. There can be many ways to identify a VM, no matter how well you can try to hide it. In VirtualBox at least...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
dsjstc
Posts: 20
Joined: 13. Sep 2010, 21:11
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: windows

Re: Passthrough VGA: Code 12 error in Windows 7 guest

Post by dsjstc »

socratis wrote:
dsjstc wrote:in order to prevent data-centre use of consumer-grade hardware, NVidia has creatively introduced a bug to their Windows driver that causes it to fail with error "Code 43", when it detects that it is running in a virtualized environment.
Seriously now? Really? How many data centers do they envision that they'll be using PCI pass-through? So, if you downgrade your driver, does it work?
It makes a twisted kind of anti-user business sense. They have an enterprise product called CUDA. I'd imagine anyone operating at a scale that permitted a fault-tolerant architecture would prefer to use user-grade hardware if possible. So maybe they took action to prevent that.

I tried to confirm through Nvidia's level 1 user support, but failed utterly to reach anyone who even understood the concept of virtualization. In the end I didn't find any confirmation beyond assertions in various people's Qemu blogs.
In KVM, this is accomplished by use of the <kvm> <hidden state='on'/> </kvm> feature.
Right. About that: this flag doesn't do much. It only turns off the virtual cpu's "virtualization-present" flag. So after looking up the name of that flag, I did some more looking. It turns out that VB has an appropriate-looking flag for this:

Code: Select all

VBoxManage modifyvm "$VMNAME" --paravirtprovider none
. It didn't help, I still got the Code 43 -- however, there is also a virtualized timer that I had to turn off in KVM, and I didn't find any equivalent to that in VirtualBox.

So anyhow, that's the results of my research, and I'm done fighting it -- after a pretty nasty learning curve, KVM/Qemu actually works pretty well for me. It's quite nice to be able to run my Windows VMs while simultaneously using Android Studio's KVM features.
Post Reply