Jump to content

Insanely fast virtual Mac (QEMU, OVMF, Clover and native graphics)


514 posts in this topic

Recommended Posts

I am having a heck of a time getting my USB Controllers to work in my VM. I see others are having success. Can someone help?
 

I have successfully passed the controllers into the VM, both show up in DCPIManager.

 

1) Integrated USB controller 82801JI (ICH10 Family) EHCI Controller #2

 

DCPIManager says it is loading AppleUSBEHCIPCI.kext
But OS X sees nothing attached. No power to devices.

 

2) VIA Technology USB 3.0 (native support)

 

DCPIManager says it is loading AppleUSBXHCIPCI.kext

A USB flash drive works fine. The drive is mounted and ejects fine.

An apple mouse does not. I plug in the mouse and it blinks red a couple times and then stops blinking.

A Microsoft webcam (native support) appears attached but continually disconnects and I am seeing, when attempting to use the video/audio, on my host logs:

Nov 19 00:42:06 pve kernel: DMAR: DRHD: handling fault status reg 2
Nov 19 00:42:06 pve kernel: DMAR: [INTR-REMAP] Request device [04:00.0] fault index 1f [fault reason 34] Present field in the IRTE entry is clear
Nov 19 00:42:06 pve kernel: DMAR: DRHD: handling fault status reg 102

None of these problems are present on my windows VM with nearly identical config. Both USB controllers work flawlessly. Every device attached to them work flawlessly. And I know these devices work when attaching them to my physical hack.

 

My video and audio (also ICH10) are working via passthrough into Sierra.

 

I believe its a DSDT issue because I am also having problems when passing USB devices/ports individually without PCI passthrough. No devices appear under the standard USB IO names EHCI/UHCI/XHCI in ioreg.

 

Also the devices do appear to be powered up in Clover. The problems happen when loading Sierra.

 

I don't know what else to try. Please let me know if you can think of anything I can try. Thanks!

 

 

 

 

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

I believe it is a DSDT issue because I am also having problems when passing USB devices/ports individually without PCI passthrough.

 

Only USB 1.1 devices can be passed to a macOS guest without the PCI passthrough of a corresponding USB controller. For USB 2 and 3 devices, PCI passthrough of the corresponding (and supported) USB controller must be done.

Link to comment
Share on other sites

  • 1 month later...

Hi,

 

I got my macOS Yosemite VM working with GPU passthrough like 2 years ago by reading this thread.

 

I don't use this VM much, only when photo editing in Lightroom.

 

So I just tried to start it but it stops at this message in the QEMU window:

AppleCredentialManager::start called
AppleKeyStore starting (BUILT: ...)

Except of updating my Ubuntu machine from 17.04 to 17.10, I don't think I changed anything in the launch script.

 

Interesting thing, if I remove the two lines for VFIO gpu passthrough and add a qxl device, then I get a working macOS Yosemite in a QEMU window with 800x600 resolution only.

 

What's wrong and what can I do?

 

Thanks.

 

Here is my script:

sudo sh -c 'echo 1 > /sys/module/kvm/parameters/ignore_msrs'

sudo qemu-system-x86_64 \
-m 8G \
-enable-kvm \
-cpu Penryn \
-M q35 \
-bios OVMF.fd \
-smp 8,sockets=1,cores=4,threads=2 \
-device isa-applesmc,osk="blahblahblah" \
-device ahci,id=hdbus,bus=pcie.0 \
-device ide-drive,bus=hdbus.0,drive=Clover \
-drive id=Clover,if=none,file=/home/me/VM/Disques/macOS/clover_dreadkopp-penryn.dd,format=raw \
-device ide-drive,bus=hdbus.1,drive=MacOSX \
-drive id=MacOSX,if=none,file=/home/me/VM/Disques/macOS/Yosemite.qcow2,media=disk,format=qcow2 \
-device virtio-net,netdev=Mac,vectors=0,mac=52:54:00:00:61:4c -netdev tap,id=Mac \
-device piix4-usb-uhci,id=usbbus \
-device usb-mouse \
-device usb-kbd \
-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vgamem_mb=16 \
-serial stdio
Link to comment
Share on other sites

I try to run macOS High Sierra with QEMU and NVIDIA passthrough but getting black screen on boot. I can see the Apple boot logo going to about 75%, then turning off all 3 monitors (2x DVI, 1x HDMI). I cannot access remote display but ssh shell (see below).

Same config works with Win10/7 passthrough.

 

Installed latest Nvidia Web Drivers for 10.13.3. Latest Clover 4380.

CPU Core I5, GPU GTX 970

 

QEMU line is:

qemu-system-x86_64 -enable-kvm -m 3072 -cpu Penryn,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on \
          -machine pc-q35-2.9 \
          -smp 4,cores=2 \
          -vga none \
          -device vfio-pci,host=01:00.0,bus=pcie.0,multifunction=on,romfile=/var/lib/libvirt/images/roms/nvbios.rom \
          -device vfio-pci,host=01:00.1,bus=pcie.0 \
          -usb -device usb-kbd -device usb-tablet \
          -device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" \
          -drive if=pflash,format=raw,readonly,file=/home/docmax/Sources/OSX-KVM/OVMF_CODE-pure-efi.fd \
          -drive if=pflash,format=raw,file=/home/docmax/Sources/OSX-KVM/OVMF_VARS-pure-efi.fd \
          -smbios type=2 \
          -device ide-drive,bus=ide.2,drive=MacHDD \
          -drive id=MacHDD,if=none,file=/mnt/htpc/data-ssd/VM/disks/qcow2/macos.qcow2 \
          -netdev tap,id=net0,ifname=tap0,script=no,downscript=no -device e1000-82545em,netdev=net0,id=net0,mac=52:54:00:c9:18:27 \
          -monitor stdio

macos dmesg:

Longterm timer threshold: 1000 ms
Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64
vm_page_bootstrap: 897437 free pages and 142947 wired pages
kext submap [0x<ptr> - 0x<ptr>], kernel text [0x<ptr> - 0x<ptr>]
zone leak detection enabled
zalloc: allocating memory for zone names buffer
"vm_compressor_mode" is 4
multiq scheduler config: deep-drain 0, ceiling 47, depth limit 4, band limit 127, sanity check 0
standard timeslicing quantum is 10000 us
standard background quantum is 2500 us
WQ[wql_init]: init linktable with max:262144 elements (8388608 bytes)
WQ[wqp_init]: init prepost table with max:262144 elements (8388608 bytes)
mig_table_max_displ = 1
Timeouts adjusted for virtualization (<<6)
kdp_core zlib memory 0x7000
ACPI: ACPI: RSDP 0x000000007FE97014 000024 (v02 BOCHS )RSDP 0x000000007FE97014 000024 (v02 BOCHS )

ACPI: ACPI: XSDT 0x000000007E3CE000 00004C (v01 BOCHS  BXPCFACP 00000001      01000013)XSDT 0x000000007E3CE000 00004C (v01 BOCHS  BXPCFACP 00000001      01000013)

ACPI: ACPI: FACP 0x000000007E3CD000 0000F4 (v04 Apple  BXPCFACP 00000001 BXPC 00000001)FACP 0x000000007E3CD000 0000F4 (v04 Apple  BXPCFACP 00000001 BXPC 00000001)

ACPI: ACPI: DSDT 0x000000007E3C9000 001F3D (v01 BOCHS  BXPCDSDT 00000001 BXPC 00000001)DSDT 0x000000007E3C9000 001F3D (v01 BOCHS  BXPCDSDT 00000001 BXPC 00000001)

ACPI: ACPI: FACS 0x000000007FE9A000 000040FACS 0x000000007FE9A000 000040

ACPI: ACPI: FACS 0x000000007FE9A000 000040FACS 0x000000007FE9A000 000040

ACPI: ACPI: APIC 0x000000007FE92000 000080 (v01 BOCHS  BXPCAPIC 00000001 BXPC 00000001)APIC 0x000000007FE92000 000080 (v01 BOCHS  BXPCAPIC 00000001 BXPC 00000001)

ACPI: ACPI: HPET 0x000000007FE91000 000038 (v01 BOCHS  BXPCHPET 00000001 BXPC 00000001)HPET 0x000000007FE91000 000038 (v01 BOCHS  BXPCHPET 00000001 BXPC 00000001)

ACPI: ACPI: MCFG 0x000000007FE90000 00003C (v01 BOCHS  BXPCMCFG 00000001 BXPC 00000001)MCFG 0x000000007FE90000 00003C (v01 BOCHS  BXPCMCFG 00000001 BXPC 00000001)

ACPI: ACPI: BGRT 0x000000007E6BF000 000038 (v01 INTEL  EDK2     00000002      01000013)BGRT 0x000000007E6BF000 000038 (v01 INTEL  EDK2     00000002      01000013)

ACPI: ACPI: 1 ACPI AML tables successfully acquired and loaded1 ACPI AML tables successfully acquired and loaded

IOTimeSyncClockManager::init created and initing
AppleCredentialManager: init: called, instance = <ptr>.
AssertMacros: value (value: 0x0),  file: /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleCredentialManager/AppleCredentialManager-195.30.6/AppleCredentialManager/AppleCredentialManager.cpp:54
AppleCredentialManager: init: EOS device type: 0.
ACM: InitCredentialEngine: Global credential set created, CS[10].
AppleCredentialManager: init: returning, result = true, instance = <ptr>.
IOTimeSyncClockManager::start starting
Did not find a usable MAC Address for Entity ID. Please file a bug report at https://bugreporter.apple.com with the model identifier.AppleACPICPU: ProcessorId=0 LocalApicId=0 Enabled
AppleACPICPU: ProcessorId=1 LocalApicId=1 Enabled
cpu_data_alloc(1) <ptr> desc_table: <ptr> ldt: <ptr> int_stack: 0x<ptr>-0x<ptr>
calling mpo_policy_init for TMSafetyNet
Security policy loaded: Safety net for Time Machine (TMSafetyNet)
calling mpo_policy_init for AMFI
Security policy loaded: Apple Mobile File Integrity (AMFI)
calling mpo_policy_init for Sandbox
Security policy loaded: Seatbelt sandbox policy (Sandbox)
calling mpo_policy_init for Quarantine
Security policy loaded: Quarantine policy (Quarantine)
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California. All rights reserved.

MAC Framework successfully initialized
ulock_initialize>thread_max=10240, ull_hash_buckets=4096
using 16384 buffer headers and 10240 cluster IO buffer headers
AppleCredentialManager: start: called, instance = <ptr>.
AppleCredentialManager: start: started, instance = <ptr>.
AppleCredentialManager: start: returning, result = true, instance = <ptr>.
AppleKeyStore starting (BUILT: Jan  8 2018 16:20:47)
AppleKeyStore::start: _kernel_relay_enable = 0
AppleKeyStore::start: _sep_enabled = 0
IOGetBootKeyStoreData: data at address 0 size 0
Started cpu 1 (lapic id 00000001)
IOAPIC: Version 0x11 Vectors 64:87
ACPI: sleep states S3 S4 S5
pci (build 09:27:03 Dec 17 2017), flags 0xe3080
pci (build 09:27:03 Dec 17 2017), flags 0xe3080
[ PCI configuration begin ]
kPEDisableScreen -1
RTC: Only single RAM bank (128 bytes)
RTC: Only single RAM bank (128 bytes)
Previous shutdown cause: 0
HID: Legacy shim 2
Matched against SMC (started)
No Generation from SMC.
initialize_screen: b=A0000000, w=00000780, h=00000438, r=00002000, d=00000001
kPEEnableScreen 1
console relocated to 0xa0000000
[ PCI configuration end, bridges 7, devices 11 ]
LINK: [GSIA] no interrupt
LINK: [GSIA] enable failed
LINK: [GSIB] no interrupt
LINK: [GSIB] enable failed
LINK: [GSIA] enable failed
LINK: [GSIA] enable failed
[AHCI][PML][00000000]+IOAHCIPortMultiplierGlobals::IOAHCIPortMultiplierGlobals
[AHCI][PML][00000000]-IOAHCIPortMultiplierGlobals::IOAHCIPortMultiplierGlobals
SATA WARNING: IDENTIFY DEVICE checksum not implemented
RTC: getGMTTimeOfDay 1516825117
clock_initialize_calendar system does not have monotonic clock.
000000.635018 AppleUSBLegacyRoot@: AppleUSBLegacyRoot::init: enabling legacy matching
mcache: 2 CPU(s), 64 bytes CPU cache line size
mbinit: done [64 MB total pool size, (42/21) split]
SK: netagent is disabled by default for this platform
bsd_autoconf: calling kminit
com.apple.AppleFSCompressionTypeZlib kmod start
com.apple.AppleFSCompressionTypeDataless kmod start
com.apple.AppleFSCompressionTypeZlib load succeeded
com.apple.AppleFSCompressionTypeDataless load succeeded
rooting via boot-uuid from /chosen: 4B8459CB-4292-3D56-A1DE-B042340BE97A
Waiting on <dict ID="0"><key>IOProviderClass</key><string ID="1">IOResources</string><key>IOResourceMatch</key><string ID="2">boot-uuid-media</string></dict>
Got boot device = IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/pci8086,2922@1F,2/AppleAHCI/PRT0@0/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice/IOBlockStorageDriver/QEMU HARDDISK Media/IOGUIDPartitionScheme/Untitled 2@2
BSD root: disk0s2, major 1, minor 2
jnl: b(1, 2): replay_journal: from: 14378496 to: 1175040 (joffset 0x400000)
000000.913815 AppleUSBHostResources@: AppleUSBHostResources::allocateDownstreamBusCurrentGated: assuming successful wakeUnits 100 sleepUnits 0
000000.913830 AppleUSBHostResources@: AppleUSBHostResources::allocateDownstreamBusCurrentGated: assuming successful wakeUnits 100 sleepUnits 0
000000.913839 AppleUSBHostResources@: AppleUSBHostResources::allocateDownstreamBusCurrentGated: assuming successful wakeUnits 100 sleepUnits 0
000000.913854 AppleUSBHostResources@: AppleUSBHostResources::allocateDownstreamBusCurrentGated: assuming successful wakeUnits 100 sleepUnits 0
000000.913862 AppleUSBHostResources@: AppleUSBHostResources::allocateDownstreamBusCurrentGated: assuming successful wakeUnits 100 sleepUnits 0
000000.913875 AppleUSBHostResources@: AppleUSBHostResources::allocateDownstreamBusCurrentGated: assuming successful wakeUnits 100 sleepUnits 0
IOTimeSyncClockManager::interfaceMatched registered service
jnl: b(1, 2): journal replay done.
hfs: mounted macOS on device b(1, 2)
load_init_program: attempting to load /sbin/launchd
VM Swap Subsystem is ON
000001.445779 AppleUSBHostResources@: AppleUSBHostResources::allocateDownstreamBusCurrentGated: assuming successful wakeUnits 100 sleepUnits 0
000001.446475 AppleUSBHostResources@: AppleUSBHostResources::allocateDownstreamBusCurrentGated: assuming successful wakeUnits 100 sleepUnits 0
000001.446594 AppleUSBHostResources@: AppleUSBHostResources::allocateDownstreamBusCurrentGated: assuming successful wakeUnits 100 sleepUnits 0
000001.446628 AppleUSBHostResources@: AppleUSBHostResources::allocateDownstreamBusCurrentGated: assuming successful wakeUnits 100 sleepUnits 0
000001.446651 AppleUSBHostResources@: AppleUSBHostResources::allocateDownstreamBusCurrentGated: assuming successful wakeUnits 100 sleepUnits 0
000001.446674 AppleUSBHostResources@: AppleUSBHostResources::allocateDownstreamBusCurrentGated: assuming successful wakeUnits 100 sleepUnits 0
hfs: Removed 0 orphaned / unlinked files and 4 directories
000001.962624 AppleUSBHostResources@: AppleUSBHostResources::allocateDownstreamBusCurrentGated: assuming successful wakeUnits 100 sleepUnits 0
000002.198590 AppleUSBHostResources@: AppleUSBHostResources::allocateDownstreamBusCurrentGated: assuming successful wakeUnits 100 sleepUnits 0
Report bytes: input:8 output:1 feature:0Collections : 2Buttons     : input:2 output:1 feature:0Values      : input:0 output:0 feature:0Element value capacity 5840Report count: 1Report ID: 0 input:64 output:8 feature:0HID: Legacy shim 2
Waiting for DSMOS...
Sandbox: coreservicesd(133) deny(1) nvram-get BSD Name
unexpected session: 100000 uid: -1 requested by: 46
AppleKeyStore: operation failed (pid: 46 sel: 7 ret: e00002c2 '-536870206', -1, 100000)
Notice - new kext com.apple.driver.KextExcludeList, v13.2.1 matches prelinked kext but can't determine if executables are the same (no UUIDs).
Matching service count = 12
Matching service count = 13
IOGraphics flags 0x43 (0x51)
NVDAStartupWeb: Web
DSMOS has arrived
[IOBluetoothFamily][start] -- completed
IOSurface allowing global lookups (with warnings)
Unsupported CPU for reporter
** AppleSMBusPCI::start failed to get acpi path for provider
** AppleSMBusPCI::start failed to get acpi path for provider
NVDAGM100HAL loaded and registered
nvAccelerator::attach provider NVDAgl parent display
nvAccelerator::probe enter provider: NVDAgl [score 130]
nvAccelerator::probe parent: display
nvAccelerator::probe return success <ptr>
nvAccelerator::probe remove "unmatched" property
nvAccelerator::detach provider NVDAgl parent display
nvAccelerator::attach provider NVDAgl parent display
nvAccelerator: ENTER ::start with provider: NVDAgl
nvAccelerator::start switch to parent: display
NVSPI::start starting!
Report bytes: input:2 output:0 feature:0Collections : 2Buttons     : input:1 output:0 feature:0Values      : input:0 output:0 feature:0Element value capacity 13800Report count: 1Report ID: 0 input:16 output:0 feature:0HID: Legacy shim 2
Report bytes: input:5 output:0 feature:0Collections : 3Buttons     : input:1 output:0 feature:0Values      : input:4 output:0 feature:0Element value capacity 316Report count: 1Report ID: 0 input:40 output:0 feature:0HID: Legacy shim 2
ACPI_SMC_PlatformPlugin::start - waitForService(resourceMatching(AppleIntelCPUPowerManagement) timed out
ACPI_SMC_PlatformPlugin::start - waitForService(resourceMatching(AppleIntelCPUPowerManagement) timed out
IOConsoleUsers: time(0) 0->0, lin 0, llk 1,
IOConsoleUsers: gIOScreenLockState 3, hs 0, bs 0, now 0, sm 0x0
Sandbox: com.apple.Ambien(195) deny(1) mach-lookup com.apple.windowserver
Sandbox: com.apple.Ambien(195) deny(1) mach-lookup com.apple.windowserver
kPEDisableScreen 1
Ethernet [Intel8254x]: Link up on en0, 10-Megabit, Half-duplex, No flow-control, Debug [796d,ac00,0de1,0e00,41e0,3c00]
en0: starting optimistic DAD immediately for fe80:8::800:d052:cbb1:16ee
en0: DAD complete for fe80:8::800:d052:cbb1:16ee - no duplicates found.
Sandbox: sshd(202) deny(1) mach-lookup com.apple.logd

Thx,

DocMAX

 

!!!Solved!!!

Link to comment
Share on other sites

  • 2 weeks later...

I have created a 10.13.3 install image, and installed to a 128GiB qcow2 image, using the Kholia/OSX-KVM boot-macOS-HS.sh script, doctored to use a bridge network interface, but I can't boot with a passthrough, and the libvirt image doesn't want to boot, either.

 

The script I used:

#!/bin/bash

MY_OPTIONS="+aes,+xsave,+avx,+xsaveopt,+smep"

qemu-system-x86_64 -enable-kvm -m 3072 -cpu Penryn,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,$MY_OPTIONS\
          -machine pc-q35-2.9 \
          -smp 4,cores=2 \
          -usb -device usb-kbd -device usb-tablet \
          -device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" \
          -drive if=pflash,format=raw,readonly,file=OVMF_CODE-pure-efi.fd \
          -drive if=pflash,format=raw,file=OVMF_VARS-pure-efi-1024x768.fd \
          -smbios type=2 \
          -device ich9-intel-hda -device hda-duplex \
          -device ide-drive,bus=ide.2,drive=Clover \
          -drive id=Clover,if=none,snapshot=on,format=qcow2,file=./'Clover.qcow2' \
          -device ide-drive,bus=ide.1,drive=MacHDD \
          -drive id=MacHDD,if=none,file=./mac_hdd.img,format=qcow2 \
          -device ide-drive,bus=ide.0,drive=MacDVD \
          -drive id=MacDVD,if=none,snapshot=on,media=cdrom,file=./'HighSierra-10.13.3.iso' \
          -netdev bridge,id=net0,br=br0,"helper=/usr/lib/qemu/qemu-bridge-helper" -device e1000-82545em,netdev=net0,id=net0,mac=52:54:00:c9:18:27 \
          -monitor stdio

The boot-passthrough.sh script, doctored to pass in my AMD RX 480, 01:00.0 and 01:00.1, and my USB interfaces, 00:14.0 00:1a.0 and 00:1d.0, using separate device lines, fails:

qemu-system-x86_64: -device vfio-pci,host=01:00.0: vfio: error opening /dev/vfio/1: No such file or directory

The non-working boot-passthrough.sh script I produced:

#!/bin/bash


qemu-system-x86_64 -enable-kvm -m 16384 -mem-prealloc -mem-path /dev/hugepages/macos -cpu Penryn,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on \
          -machine pc-q35-2.9 \
          -smp 8,cores=4 \
          -vga none \
          -device vfio-pci,host=01:00.0,id=hostdev0,bus=pcie.0,multifunction=on \
          -device vfio-pci,host=01:00.1,id=hostdev1,bus=pcie.0 \
          -device vfio-pci,host=00:14.0,id=hostdev2,bus=pcie.0 \
          -device vfio-pci,host=00:1d.0,id=hostdev3,bus=pcie.0 \
          -device vfio-pci,host=00:1a.0,id=hostdev4,bus=pcie.0 \
          -usb -device usb-kbd -device usb-tablet \
          -device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" \
          -drive if=pflash,format=raw,readonly,file=OVMF_CODE-pure-efi.fd \
          -drive if=pflash,format=raw,file=OVMF_VARS-pure-efi-1024x768.fd \
          -smbios type=2 \
          -device ide-drive,bus=ide.2,drive=MacHDD \
          -drive id=MacHDD,if=none,file=./mac_hdd.img \
          -netdev bridge,id=net0,br=br0,"helper=/usr/lib/qemu/qemu-bridge-helper" -device e1000-82545em,netdev=net0,id=net0,mac=52:54:00:c9:18:27 \
          -monitor stdio

And the libvirt script fails to boot it. I modified it to use 4 core, 8 thread, host CPU (i7 3770), no virtual graphics, passing through all of the devices mentioned above, and it simply boots to the Tianocore logo, spinning all 8 threads, then eventually getting stuck spinning only one core, without actually hitting Clover.

 

I notice the libvirt scripts have been updated, but the boot-passthrough.sh script hasn't been updated in a few months.

 

I would prefer to get this working with the libvirt method, as that's what I use to maintain my other virtual machines, including automatic startup on system boot, and automatic shutdown on host reboot or shutdown.

Link to comment
Share on other sites

And the libvirt script fails to boot it. I modified it to use 4 core, 8 thread, host CPU (i7 3770), no virtual graphics, passing through all of the devices mentioned above, and it simply boots to the Tianocore logo, spinning all 8 threads, then eventually getting stuck spinning only one core, without actually hitting Clover.

 

I notice the libvirt scripts have been updated, but the boot-passthrough.sh script hasn't been updated in a few months.

 

I would prefer to get this working with the libvirt method, as that's what I use to maintain my other virtual machines, including automatic startup on system boot, and automatic shutdown on host reboot or shutdown.

 

You must always set the CPU to Penryn; otherwise, Clover won't work. Also, make sure you are using the premade Clover image and OVMF_CODE file from the OSX-KVM place.

 

There are issues with the recent version of Clover and OVMF that prevent you from booting a Hackintosh install on qemu.

 

 

The boot-passthrough.sh script, doctored to pass in my AMD RX 480, 01:00.0 and 01:00.1, and my USB interfaces, 00:14.0 00:1a.0 and 00:1d.0, using separate device lines, fails:

qemu-system-x86_64: -device vfio-pci,host=01:00.0: vfio: error opening /dev/vfio/1: No such file or directory

 

You probably need to using modprobe to load the vfio-pci driver and manually bind the GPU to VFIO:

 

echo "1002 6719" > /sys/bus/pci/drivers/vfio-pci/new_id

echo "0000:01:00.0" > /sys/bus/pci/devices/0000:01:00.0/driver/unbind

echo "0000:01:00.0" > /sys/bus/pci/drivers/vfio-pci/bind

echo "1002 6719" > /sys/bus/pci/drivers/vfio-pci/remove_id

 

echo "1002 aa80" > /sys/bus/pci/drivers/vfio-pci/new_id

echo "0000:01:00.1" > /sys/bus/pci/devices/0000:01:00.1/driver/unbind

echo "0000:01:00.1" > /sys/bus/pci/drivers/vfio-pci/bind

echo "1002 aa80" > /sys/bus/pci/drivers/vfio-pci/remove_id

Source: https://arseniyshestakov.com/2016/03/31/how-to-pass-gpu-to-vm-and-back-without-x-restart/

Link to comment
Share on other sites

I managed to get it working, both with the distribution stock OVMF and the repository supplied OVMF. The issue with that was replacing the VARS image with the one matching the correct CODE image, or else it wouldn't boot at all.

 

My XML:

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
  <name>macOS High Sierra</name>
  <uuid>420e255f-cd8c-4938-a9a5-6d0d423c0d57</uuid>
  <memory unit='KiB'>16777216</memory>
  <currentMemory unit='KiB'>16777216</currentMemory>
  <memoryBacking>
    <hugepages/>
  </memoryBacking>
  <vcpu placement='static'>8</vcpu>
  <os>
    <type arch='x86_64' machine='pc-q35-2.10'>hvm</type>
    <loader readonly='yes' type='pflash'>/var/lib/libvirt/images/OVMF_CODE-pure-efi.fd</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/macOS_VARS.fd</nvram>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
  </features>
  <cpu mode='custom' match='exact' check='partial'>
    <model fallback='allow'>Penryn</model>
    <topology sockets='1' cores='4' threads='2'/>
    <feature policy='require' name='invtsc'/>
    <feature policy='require' name='aes'/>
    <feature policy='require' name='xsave'/>
    <feature policy='require' name='avx'/>
    <feature policy='require' name='xsaveopt'/>
    <feature policy='require' name='smep'/>
  </cpu>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/clover.qcow2'/>
      <target dev='hda' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/mac_hdd.qcow2'/>
      <target dev='hdb' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <controller type='usb' index='0' model='piix3-uhci'>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
    </controller>
    <controller type='sata' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pcie-root'/>
    <controller type='pci' index='1' model='dmi-to-pci-bridge'>
      <model name='i82801b11-bridge'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/>
    </controller>
    <controller type='pci' index='2' model='pci-bridge'>
      <model name='pci-bridge'/>
      <target chassisNr='2'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </controller>
    <controller type='pci' index='3' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='3' port='0x10'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/>
    </controller>
    <controller type='pci' index='4' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='4' port='0x11'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/>
    </controller>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x14' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x1a' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x03' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x1d' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x04' function='0x0'/>
    </hostdev>
    <memballoon model='none'/>
  </devices>
  <qemu:commandline>
    <qemu:arg value='-device'/>
    <qemu:arg value='isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc'/>
    <qemu:arg value='-smbios'/>
    <qemu:arg value='type=2'/>
    <qemu:arg value='-cpu'/>
    <qemu:arg value='Penryn,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+aes,+xsave,+avx,+xsaveopt,+smep'/>
  </qemu:commandline>
</domain>

Note the overriding CPU flags. I also had to leave out AVX2, since my CPU doesn't support that.

 

It boots, it gets past hardware enumeration if I set Clover to boot in verbose mode, but when it gets to loading the hardware drivers, it fails to attach either my display or my USB interfaces, leaving them in a seemingly detached state. The displays shut off, the USB mouse disconnects, but my USB keyboard appears to recognize caps lock and toggles its state LED. There doesn't appear to be much I can do with the machine at that point.

 

E: I managed to get it to boot, by configuring Clover with Graphics > RadeonDeInit, but now I have stuttering audio that I did not experience under my Windows VM. I assume that this stupid thing is too sensitive and needs CPU core isolation, which is total bullpucky.

Link to comment
Share on other sites

  • 3 weeks later...

As I don't get gpu passtrough anymore on Ubuntu 17.10 I'm trying to update my setup by following instructions there: https://github.com/kholia/OSX-KVM

 

The problem I have is that it's getting confusing over there as instructions for Enoch bootloader, UEFI/Clover bootlaoder and High Sierra are multiplying and getting mixed in cross-references.

 

With this post I'm trying to eliminate unknown variables from the equation.

 

First, I'm trying to figure out if the patched QEMU is still needed.

This step is not optional and is required. QEMU 2.10.1 shipped with Fedora 27 works fine too

Ubuntu 17.10, which was not yet released when most of these instructions were written in August 2017, now also ships with QEMU 2.10 as Fedora 27.

 

Anybody on Ubuntu 17.10 can tell me?

Put the included q35-acpi-dsdt.aml file into EFI/CLOVER/ACPI/origin location

This is in UEFI instructions but not in High Sierra with Clover instructions. Is that still necessary?

 

 

Thanks all

 

Link to comment
Share on other sites

  • 4 months later...

Just to bump this thread, I was able to get Mojave up and running but it took quite some work. I had to do the following:

 

1. Fix my broken Arch install (glibc fail with Pacman)

2. Compile a custom version of qemu (checked out tag v2.12.0)

3. Compiled a custom OVMF with EPT Read Only tables disabled. I had to reach out for a patch on this code. Patch worked.

4. Install Mojave as usual.

 

I am not redirecting graphics as I intend to do some kernel debugging work and it is not needed. However, redirecting should work fine as usual. Latest clover works.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

Hey,

 

So I am trying to do something different.

 

So I have a working VM High Sierra with passthrough running on the GTX 660. Problem is there is a horrendous tearing/glitching issue with the 660 and I haven't found a solution for it. The 660 is not a bad card and can push my 4k monitor just fine. 

 

Since I have this plus the intel gpu (Intel UHD 630) .I decided to try and pass the integrated GPU into the VM. (It is in its own IOMMU group)

 

So the VM keeps rebooting (When passing in the iGPU. Any idea where to start debugging? I was trying to follow this tutorial. Am I missing drivers? 

https://forum.proxmox.com/threads/guide-intel-intergrated-graphic-passthrough.30451/

 

As for the kernel output when booting with -v, There are a bunch of plus plus signs and then it reboots. on a normal working boot it is the same as well.

 

 

 

 

Edited by Maclarentosh
Link to comment
Share on other sites

  • 1 month later...

Has anyone tried KVM with Optimus?

https://gist.github.com/Misairu-G/616f7b2756c488148b7309addc940b28

This would be a nice way to get around the lack of Optimus drivers in OS X. 

 

My 17" MacBook is dying on multiple fronts and I'm looking into purchasing a PC laptop to replace it (NONE of Apple's current offerings are the least bit interesting to me). 

Link to comment
Share on other sites

  • 2 weeks later...
On 7/25/2018 at 5:18 PM, DaGr8Gatzby said:

Just to bump this thread, I was able to get Mojave up and running but it took quite some work. I had to do the following:

 

1. Fix my broken Arch install (glibc fail with Pacman)

2. Compile a custom version of qemu (checked out tag v2.12.0)

3. Compiled a custom OVMF with EPT Read Only tables disabled. I had to reach out for a patch on this code. Patch worked.

4. Install Mojave as usual.

 

I am not redirecting graphics as I intend to do some kernel debugging work and it is not needed. However, redirecting should work fine as usual. Latest clover works.

care to share the ovmf files ? :)

Link to comment
Share on other sites

  • 9 months later...
On 7/19/2017 at 6:36 AM, sll1001 said:

I can confirm the above qemu options works well with an unmodified clover and minimal config.plist

 

After some experimentation, I could switch to use IvyBridge as the guest cpu model by disabling the tsc-deadline feature.

 

 

The cpu option line becomes:

 

-cpu ivyBridge,vendor=GeniuneIntel,kvm=on,+invtsc,vmware-cpuid-freq=on,-tsc-deadline

 

The host is a Haswell-E 5960X

 

Hi sll1001,

 

Did you try you VM with IviBridge? Do you have better performances than using Penrin?

 

If I use IviBridge with your params, I have a KP. Any idea?

 

Thanks.

 

Link to comment
Share on other sites

  • 7 months later...
Spoiler

1037381592_Screenshot2020-05-07at1_58_37.png.98b7979bce9a56b2c0ae815451a3d5ff.png

 

I got the nvme emulation working with macos :shock:

 

 

Here's a patch against the latest qemu from git.

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 9b453423cf..832294e571 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -783,6 +783,15 @@ static uint16_t nvme_get_feature_timestamp(NvmeCtrl *n, NvmeCmd *cmd)
                                  sizeof(timestamp), prp1, prp2);
 }
 
+static uint16_t nvme_get_log_page(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
+{
+    uint32_t result=0;
+
+    req->cqe.result = result;
+    return NVME_SUCCESS;
+}
+
+
 static uint16_t nvme_get_feature(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
 {
     uint32_t dw10 = le32_to_cpu(cmd->cdw10);
@@ -872,6 +881,8 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
         return nvme_set_feature(n, cmd, req);
     case NVME_ADM_CMD_GET_FEATURES:
         return nvme_get_feature(n, cmd, req);
+    case NVME_ADM_CMD_GET_LOG_PAGE:
+        return nvme_get_log_page(n, cmd, req);
     default:
         trace_nvme_err_invalid_admin_opc(cmd->opcode);
         return NVME_INVALID_OPCODE | NVME_DNR;

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...