diff --git a/CREDITS.md b/CREDITS.md index 87c893e..8522c3f 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -23,3 +23,5 @@ * http://www.insanelymac.com/ - Enoch bootloader * Nicholas Sherlock - UEFI, Clover, and other hacks + +* Phil Dennis-Jordan - virtio-net-osx, usb-tablet and other hacks diff --git a/boot-clover.sh b/boot-clover.sh index cdc462c..2a06c09 100755 --- a/boot-clover.sh +++ b/boot-clover.sh @@ -4,7 +4,13 @@ # # The "pc-q35-2.4" machine type was changed to "pc-q35-2.9" on 06-August-2017. -qemu-system-x86_64 -enable-kvm -m 3072 -cpu Penryn,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on \ +################################################################################## +# NOTE: Comment out the "MY_OPTIONS" line in case you are having booting problems! +################################################################################## + +MY_OPTIONS="+aes,+xsave,+avx,+xsaveopt,+xsavec,+xgetbv1,+xsaves,+avx2,+bmi2,+smep,+bmi1,+fma,+movbe" + +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 \ diff --git a/boot-macOS.sh b/boot-macOS.sh index 8145e42..208a78e 100755 --- a/boot-macOS.sh +++ b/boot-macOS.sh @@ -23,7 +23,7 @@ qemu-system-x86_64 -enable-kvm -m 3072 -cpu Penryn,kvm=off,vendor=GenuineIntel \ -smp 4,cores=2 \ -usb -device usb-kbd -device usb-mouse \ -device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" \ - -kernel ./enoch_rev2889_boot \ + -kernel ./enoch_rev2898_boot \ -smbios type=2 \ -device ich9-intel-hda -device hda-duplex \ -device ide-drive,bus=ide.2,drive=MacHDD \ diff --git a/enoch_rev2898_boot b/enoch_rev2898_boot new file mode 100644 index 0000000..92d2753 Binary files /dev/null and b/enoch_rev2898_boot differ diff --git a/kernel-debugging-notes.txt b/kernel-debugging-notes.txt new file mode 100644 index 0000000..265948d --- /dev/null +++ b/kernel-debugging-notes.txt @@ -0,0 +1,33 @@ +1. How do I symbolicate kernel panic traces? + +Just add keepsyms=1 to either the Kernel Flags setting in /Library/Preferences/SystemConfiguration/com.apple.Boot.plist, +or to the boot-args NVRAM variable. Reboot, and any subsequent panics will be automatically symbolicated. You can run +mangled C++ symbols through the c++filt command line utility to get the proper C++ function signatures. + +$ sudo nvram boot-args="-v keepsyms=1" + +Thanks for Phil Dennis-Jordan for this great tip. + +2. Debugging a AVX related crash which occurs at bootup. + +$ nm /System/Library/Extensions/corecrypto.kext/Contents/MacOS/corecrypto | grep avx +0000000000001840 T _ccsha256_vng_intel_avx1_compress +0000000000036708 T _ccsha256_vng_intel_avx2_compress +0000000000026973 T _ccsha512_vng_intel_avx1_compress +00000000000327cb T _ccsha512_vng_intel_avx2_compress +000000000001d960 T _gcmDecrypt_avx1 +000000000001c980 T _gcmEncrypt_avx1 + +$ gdb /System/Library/Extensions/corecrypto.kext/Contents/MacOS/corecrypto +(gdb) x/16i 0x0000000000001840 + 0x1840: push %rbp + 0x1841: mov %rsp,%rbp + 0x1844: push %rbx + 0x1845: push %r12 + 0x1847: push %r13 + 0x1849: push %r14 + 0x184b: push %r15 + 0x184d: sub $0x168,%rsp + 0x1854: lea 0x60(%rsp),%rax + 0x1859: and $0xffffffffffffffe0,%rax + 0x185d: vmovdqa %ymm0,(%rax) <--- the crash occurs here due to lack of "xsave" support diff --git a/kexts/Virtio-Net-Driver-0.9.4.pkg b/kexts/Virtio-Net-Driver-0.9.4.pkg new file mode 100644 index 0000000..92b1ce2 Binary files /dev/null and b/kexts/Virtio-Net-Driver-0.9.4.pkg differ diff --git a/networking-qemu-kvm-howto.txt b/networking-qemu-kvm-howto.txt index 55f8357..a6ffc4f 100644 --- a/networking-qemu-kvm-howto.txt +++ b/networking-qemu-kvm-howto.txt @@ -41,7 +41,7 @@ to your qemu-system-x86_64 command. QEMU networking tip ------------------- -# printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256)) # generates QEMU compatible mac addresses! +# printf '52:54:00:AB:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256)) # generates QEMU compatible mac addresses! ------------------ Bridged Networking diff --git a/notes.md b/notes.md index 1c6816f..3cc6629 100644 --- a/notes.md +++ b/notes.md @@ -141,6 +141,8 @@ Thanks to Zhang Tong and Kfir Ozer for finding this. See `UEFI/README.md` for GPU passthrough notes. +Note: There is no working QXL driver for macOS so far. + ### Virtual Sound Device No support is provided for this. You are on your own. The sound output is known @@ -152,6 +154,8 @@ to be choppy and distorted. * To get sound on your virtual Mac, install the VoodooHDA driver from [here](https://sourceforge.net/projects/voodoohda/files/). +Note: It seems that playback of Flash videos requires an audio device to be +present. ### Building QEMU from source @@ -211,6 +215,48 @@ openssl speed aes-128-cbc openssl speed -evp aes-128-cbc # uses AES-NI ``` +### Exposing AVX and AVX2 instructions to macOS + +Exposing AVX and AVX2 instructions to macOS requires support for these +instructions on the host CPU. + +The `boot-clover.sh` script already exposes AVX and AVX2 instructions to the +macOS guest by default. Modify or comment out the `MY_OPTIONS` line in +`boot-clover.sh` file in case you are having problems. + +To enable AVX2, do the following change, + +`Clover boot menu -> Options -> Binaries patching -> Fake CPUID -> 0x0306C0 # for Haswell` + +For details, see [this wiki](https://clover-wiki.zetam.org/Configuration/KernelAndKextPatches) page. + +Once enabled, the following commands can be used to confirm the presence of AVX +and AVX2 instructions on the macOS guest. + +``` +$ sysctl -a | grep avx +hw.optional.avx2_0: 1 +hw.optional.avx1_0: 1 + +$ sysctl -a | grep leaf7 +machdep.cpu.leaf7_features: SMEP BMI1 AVX2 BMI2 +machdep.cpu.leaf7_feature_bits: 424 +``` + +### Using virtio-net-osx with macOS + +Configuration options for macOS Sierra (thanks to virtio-net-osx project users), + +``` +-netdev user,id=hub0port0 \ +-device virtio-net,netdev=hub0port0,id=eth0 \ +-set device.eth0.vectors=0 +``` + +Adapt these to your use case. These changes need to be made in the `boot-*` +scripts. On the guest, install the included `Virtio-Net-Driver-0.9.4.pkg` +package. + ### Boot Notes Type the following after boot, diff --git a/screenshots/macOS+QEMU+AVX.png b/screenshots/macOS+QEMU+AVX.png new file mode 100644 index 0000000..4f7d246 Binary files /dev/null and b/screenshots/macOS+QEMU+AVX.png differ diff --git a/screenshots/macOS-expose-AVX2.png b/screenshots/macOS-expose-AVX2.png new file mode 100644 index 0000000..000ad35 Binary files /dev/null and b/screenshots/macOS-expose-AVX2.png differ