foxlet / macOS-Simple-KVM

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

Passthough GTX 970 - QEMU 5.0 Monitor pending #290

Open Killouis opened 4 years ago

Killouis commented 4 years ago

Hi, i've installed OSX Catalina and it works correctly. Next i tried to passthrough my GTX 970 but i can't see nothing when i start the VM. Can someone help me? There are my configurations and logs:

/etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet intel_iommu=on iommu=pt vfio-pci.ids=10de:13c2,10de:0fbb"

lspci -nnk

01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GM204 [GeForce GTX 970] [10de:13c2] (rev a1)
    Subsystem: ZOTAC International (MCO) Ltd. Device [19da:1366]
    Kernel driver in use: vfio-pci
    Kernel modules: nouveau, nvidia_drm, nvidia
01:00.1 Audio device [0403]: NVIDIA Corporation GM204 High Definition Audio Controller [10de:0fbb] (rev a1)
    Subsystem: ZOTAC International (MCO) Ltd. Device [19da:1366]
    Kernel driver in use: vfio-pci
    Kernel modules: snd_hda_intel
02:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK107 [GeForce GT 640] [10de:0fc1] (rev a1)
    Subsystem: ASUSTeK Computer Inc. Device [1043:83f3]
    Kernel driver in use: nvidia
    Kernel modules: nouveau, nvidia_drm, nvidia
02:00.1 Audio device [0403]: NVIDIA Corporation GK107 HDMI Audio Controller [10de:0e1b] (rev a1)
    Subsystem: ASUSTeK Computer Inc. Device [1043:83f3]
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel

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 10G \
    -machine q35,accel=kvm \
    -smp cores=4 \
    -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 pcie-root-port,bus=pcie.0,multifunction=on,port=1,chassis=1,id=port.1 \
    -device vfio-pci,host=01:00.0,bus=port.1,multifunction=on,romfile=$VMDIR/gtx970.rom \
    -device vfio-pci,host=01:00.1,bus=port.1 \
    -usb -device usb-kbd -device usb-mouse \
    -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,format=raw,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 \

Log

[root@archdesktop macOS-Simple-KVM]# ./basic.sh
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.fma [bit 12]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.movbe [bit 22]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.bmi1 [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.avx2 [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.bmi2 [bit 8]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX.xsavec [bit 1]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX.xgetbv1 [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.fma [bit 12]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.movbe [bit 22]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.bmi1 [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.avx2 [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.bmi2 [bit 8]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX.xsavec [bit 1]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX.xgetbv1 [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.fma [bit 12]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.movbe [bit 22]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.bmi1 [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.avx2 [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.bmi2 [bit 8]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX.xsavec [bit 1]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX.xgetbv1 [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.fma [bit 12]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.movbe [bit 22]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.bmi1 [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.avx2 [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.bmi2 [bit 8]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX.xsavec [bit 1]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX.xgetbv1 [bit 2]

image

ghost commented 4 years ago

Which CPU do you use?

Killouis commented 4 years ago

Hi @gfelipe099, thank you for your response! Intel i7 3770

ghost commented 4 years ago

QEMU is telling you that your computer is missing features it requires from the CPU, which the i7-3770 seems to not support.

Edit: you can list the flags your CPU supports and compare them by running:

lscpu | grep Flags:

Killouis commented 4 years ago

It works fine without the passthrow of GPU. Anyway this is the output:

fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts md_clear flush_l1d

Thank you!

ghost commented 4 years ago

Now please, make a backup and then replace the line with -cpu with the one below in your .sh file, which only contains flags supported by your CPU. -cpu Penryn,vendor=GenuineIntel,kvm=on,+sse3,+sse4.2,+aes,+xsave,+avx,+xsaveopt,+smep,+bmi1,+invtsc \

Edit: And try again!

Killouis commented 4 years ago

This is the output now, but QEMU still the same:

[root@archdesktop macOS-Simple-KVM]# ./basic.sh
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.bmi1 [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.bmi1 [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.bmi1 [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.bmi1 [bit 3]

Edit: i removed the bmi1 option and now i haven't warning but the issue still remain

ghost commented 4 years ago

Did you try to passthrough the GPU in another VM?

jamfor352 commented 4 years ago

Catalina doesn’t support Nvidia cards anyway so that may be another issue you’re having. Have you tried High Sierra?

Killouis commented 4 years ago

Hi @gfelipe099 and @jf352 i tried with High Sierra but the problem still remain. QEMU still black as the screenshot and the output is as follows:

[root@archdesktop macOS-Simple-KVM]# ./basic.sh qemu-system-x86_64: -device vfio-pci,host=01:00.0,bus=port.1,multifunction=on,romfile=/home/killouis/repo/high-sierra/macOS-Simple-KVM/gtx970.rom: Failed to mmap 0000:01:00.0 BAR 3. Performance may be slow

ghost commented 4 years ago

Are you using a Debian-based distro, or Debian itself?

Killouis commented 4 years ago

I'm using Arch Linux

ghost commented 4 years ago

Is the GPU plugged in on another monitor?

Killouis commented 4 years ago

I have 2 GPU:

ghost commented 4 years ago

Does -vga qxl work for you?

Killouis commented 4 years ago

It starts but from QEMU, not from the other monitor, and i receive this message from QEMU:

image

This is the configuration file now:

#!/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 10G \
    -machine q35,accel=kvm \
    -smp cores=4 \
    -cpu Penryn,vendor=GenuineIntel,kvm=on,+sse3,+sse4.2,+aes,+xsave,+avx,+xsaveopt,+smep,+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 qxl \
    -device pcie-root-port,bus=pcie.0,multifunction=on,port=1,chassis=1,id=port.1 \
    -device vfio-pci,host=01:00.0,bus=port.1,multifunction=on,romfile=$VMDIR/gtx970.rom \
    -device vfio-pci,host=01:00.1,bus=port.1 \
    -usb -device usb-kbd -device usb-mouse \
    -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,format=raw,if=none,file=BaseSystem.img \
    -device ide-hd,bus=sata.3,drive=InstallMedia \
    -drive id=SystemDisk,if=none,file=MyDiskHS.qcow2 \
    -device ide-hd,bus=sata.4,drive=SystemDisk \
ghost commented 4 years ago

Do you have virt-manager installed in your system?

Killouis commented 4 years ago

Yes, i have

ghost commented 4 years ago

Try to import it to virt-manager, it might be easier there.

rosenpin commented 3 years ago

I have the same issue but for me when using -vga qxl it works

But it's slow, does -vga qxl disable the passthrough?

janboeye commented 3 years ago

@killouis this is because passthrough mode display image to real gpu, host could not show the content of passthrough GPU. You could check it if you connect a monitor to your passthrough gpu