foxlet / macOS-Simple-KVM

Tools to set up a quick macOS VM in QEMU, accelerated by KVM.
13.6k stars 1.14k forks source link

PCIe Passtrhough iommu notifier #13

Open LKLAW opened 5 years ago

LKLAW commented 5 years ago

macOS is installed and works fine, trying the PCIe passthrough atm. After lots of googling I gave up and decided to ask here :) I get the following error message when trying to initialize my 750ti with the basic script:

qemu-system-x86_64: -device vfio-pci,host=20:00.0,bus=port.1,multifunction=on: device 00.00.0 requires iommu notifier which is not currently supported

My basic.sh: `#!/bin/bash

OSK="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" VMDIR=$PWD OVMF=$VMDIR/firmware

export QEMU_AUDIO_DRV=pa

QEMU_AUDIO_DRV=pa

qemu-system-x86_64 \ -enable-kvm \ -m 2G \ -machine q35,accel=kvm \ -smp 4,cores=2 \ -cpu Penryn,vendor=GenuineIntel,kvm=on,+sse3,+sse4.2,+aes,+xsave,+avx,+xsaveopt,+xsavec,+xgetbv1,+avx2,+bmi2,+smep,+bmi1,+fma,+movbe,+invtsc \ -device isa-applesmc,osk="$OSK" \ -smbios type=2 \ -drive if=pflash,format=raw,readonly,file=$OVMF/OVMF_CODE.fd \ -drive if=pflash,format=raw,file=$OVMF/OVMF_VARS-1024x768.fd \ -vga none \ -device ich9-intel-hda -device hda-output \ -usb -device usb-kbd -device usb-tablet \ -netdev user,id=net0 \ -device e1000-82545em,netdev=net0,id=net0,mac=52:54:00:c9:18:27 \ -device ich9-ahci,id=sata \ -drive id=ESP,if=none,format=qcow2,file=ESP.qcow2 \ -device ide-hd,bus=sata.2,drive=ESP \ -drive id=InstallMedia,if=none,file=BaseSystem.img \ -device ide-hd,bus=sata.3,drive=InstallMedia \ -drive id=SystemDisk,if=none,file=MyDisk.qcow2 \ -device ide-hd,bus=sata.4,drive=SystemDisk \ -device ioh3420,bus=pcie.0,multifunction=on,port=1,chassis=1,id=port.1 \ -device amd-iommu \ -device vfio-pci,host=20:00.0,bus=port.1,multifunction=on \ -device vfio-pci,host=20:00.1,bus=port.1 `

foxlet commented 5 years ago

What version of QEMU are you using? That's an error arising from old versions (2.6+).

LKLAW commented 5 years ago

I'm using version 3.1.0 (Debian 1:3.1+dfsg-2ubuntu3.1)

aidengilmartin commented 5 years ago

Try removing -device amd-iommu if you haven't already. I tried it with that option and got the same error.

foxlet commented 5 years ago

You don't need an amd-iommu device, that's only for the host.

LKLAW commented 5 years ago

Ok now I get (display did react though): WARNING: Image format was not specified for 'BaseSystem.img' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. qemu-system-x86_64: vfio: Unable to power on device, stuck in D3 qemu-system-x86_64: vfio: Unable to power on device, stuck in D3 qemu-system-x86_64: vfio-pci: Cannot read device rom at 0000:20:00.0 Device option ROM contents are probably invalid (check dmesg). Skip option ROM probe with rombar=0, or load from file with romfile=

Then I added vbios.rom in the project root folder and firmware folder and now I just get a blank screen with just this in the terminal, Qemu-System-x86-64 is open on the desktop though and just says "qemy monitor 3.1.0, type help: WARNING: Image format was not specified for 'BaseSystem.img' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions.

foxlet commented 5 years ago

When dumping the ROM from your GPU, make sure to not use a tainted version (the Linux kernel applies changes that cause the ROM to be invalid).

In addition, make sure your GPU doesn't suffer from the PCI Bus Reset bug (which means the card cannot reset itself to a clean state via software, you have to manually restart the host before it will work). If it does, you will have to power cycle every time you use the VM (sometimes sleep works).

LKLAW commented 5 years ago

Can I also dump the ROM via GPU-Z in windows? Or does it have to be via linux? (I tried to follow the Arch wiki guide but failed badly so I decided just used a techpowerup rom)

foxlet commented 5 years ago

GPU-Z dumps are fine, or from nvflash/atiflash.

LKLAW commented 5 years ago

Using the GPU'z file I can see that the screen gets wiped, but it stays dark. Using Virt-Manager, I get a display on my ubuntu screen, and it doesn't see the PCIe card..

LKLAW commented 5 years ago

Ok now I got something after rebooting: qemu-system-x86_64: vfio:

qemu-system-x86_64: vfio: Unable to power on device, stuck in D3
qemu-system-x86_64: vfio: Unable to power on device, stuck in D3

How would I verify the reset bug? I can't find anything on a 750ti. Also any idea why my my system won't power down or reboot anymore after enabling this vfio stuff?