Modernize multiple components
parent
2794e12955
commit
ab17ed4a38
@ -0,0 +1,20 @@
|
||||
Building OVMF
|
||||
-------------
|
||||
|
||||
git clone https://github.com/tianocore/edk2
|
||||
cd edk2
|
||||
make -C BaseTools
|
||||
. edksetup.sh BaseTools
|
||||
build -a X64 -t GCC5 -p OvmfPkg/OvmfPkgX64.dsc -b RELEASE
|
||||
|
||||
The included blobs were built from commit 2913ebb2b550f50a.
|
||||
|
||||
Host OS
|
||||
-------
|
||||
|
||||
OVMF blobs were built on Ubuntu 14.04.5 LTS (Trusty Tahr)
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
https://www.contrib.andrew.cmu.edu/~somlo/OSXKVM/
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,193 @@
|
||||
/*
|
||||
* prints out 4-character name of the SMC key at given index position;
|
||||
*
|
||||
* by Gabriel L. Somlo <somlo@cmu.edu>, Summer 2014
|
||||
*
|
||||
* Compile with: gcc -O2 -o SmcDumpKey SmcDumpKey.c -Wall
|
||||
*
|
||||
* You probably want to "modprobe -r applesmc" before running this...
|
||||
*
|
||||
* Code bits and pieces shamelessly ripped from the linux kernel driver
|
||||
* (drivers/hwmon/applesmc.c by N. Boichat and H. Rydberg)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License v2 as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/io.h>
|
||||
#include <linux/byteorder/little_endian.h>
|
||||
|
||||
|
||||
#define APPLESMC_START 0x300
|
||||
#define APPLESMC_RANGE 0x20
|
||||
|
||||
#define APPLESMC_DATA_PORT (APPLESMC_START + 0x00)
|
||||
#define APPLESMC_CMD_PORT (APPLESMC_START + 0x04)
|
||||
|
||||
#define APPLESMC_READ_CMD 0x10
|
||||
#define APPLESMC_GET_KEY_BY_INDEX_CMD 0x12
|
||||
#define APPLESMC_GET_KEY_TYPE_CMD 0x13
|
||||
|
||||
|
||||
/* wait up to 128 ms for a status change. */
|
||||
#define APPLESMC_MIN_WAIT 0x0010
|
||||
#define APPLESMC_RETRY_WAIT 0x0100
|
||||
#define APPLESMC_MAX_WAIT 0x20000
|
||||
|
||||
|
||||
#define APPLESMC_KEY_NAME_LEN 4
|
||||
#define APPLESMC_KEY_TYPE_LEN 4
|
||||
|
||||
typedef struct key_type {
|
||||
uint8_t data_len;
|
||||
uint8_t data_type[APPLESMC_KEY_TYPE_LEN];
|
||||
uint8_t flags;
|
||||
} __attribute__((packed)) key_type;
|
||||
|
||||
|
||||
/* wait_read - Wait for a byte to appear on SMC port. */
|
||||
static int
|
||||
wait_read(void)
|
||||
{
|
||||
uint8_t status;
|
||||
int us;
|
||||
|
||||
for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
|
||||
usleep(us);
|
||||
status = inb(APPLESMC_CMD_PORT);
|
||||
/* read: wait for smc to settle */
|
||||
if (status & 0x01)
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf(stderr, "wait_read() fail: 0x%02x\n", status);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*send_byte - Write to SMC port, retrying when necessary. */
|
||||
static int
|
||||
send_byte(uint8_t cmd, unsigned short port)
|
||||
{
|
||||
uint8_t status;
|
||||
int us;
|
||||
|
||||
outb(cmd, port);
|
||||
for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
|
||||
usleep(us);
|
||||
status = inb(APPLESMC_CMD_PORT);
|
||||
/* write: wait for smc to settle */
|
||||
if (status & 0x02)
|
||||
continue;
|
||||
/* ready: cmd accepted, return */
|
||||
if (status & 0x04)
|
||||
return 0;
|
||||
/* timeout: give up */
|
||||
if (us << 1 == APPLESMC_MAX_WAIT)
|
||||
break;
|
||||
/* busy: long wait and resend */
|
||||
usleep(APPLESMC_RETRY_WAIT);
|
||||
outb(cmd, port);
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"send_byte(0x%02x, 0x%04x) fail: 0x%02x\n", cmd, port, status);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
send_argument(const uint8_t *key)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < APPLESMC_KEY_NAME_LEN; i++)
|
||||
if (send_byte(key[i], APPLESMC_DATA_PORT))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
read_smc(uint8_t cmd, const uint8_t *key, uint8_t *buf, uint8_t len)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (send_byte(cmd, APPLESMC_CMD_PORT) || send_argument(key)) {
|
||||
fprintf(stderr, "%.4s: read arg fail\n", key);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (send_byte(len, APPLESMC_DATA_PORT)) {
|
||||
fprintf(stderr, "%.4s: read len fail\n", key);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (wait_read()) {
|
||||
fprintf(stderr, "%.4s: read data[%d] fail\n", key, i);
|
||||
return -1;
|
||||
}
|
||||
buf[i] = inb(APPLESMC_DATA_PORT);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
key_type kt;
|
||||
uint8_t data_buf[UCHAR_MAX];
|
||||
uint8_t i;
|
||||
|
||||
if (argc != 2 || strlen(argv[1]) != APPLESMC_KEY_NAME_LEN) {
|
||||
fprintf(stderr, "\nUsage: %s <4-char-key-name>\n\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ioperm(APPLESMC_START, APPLESMC_RANGE, 1) != 0) {
|
||||
perror("ioperm failed");
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (read_smc(APPLESMC_GET_KEY_TYPE_CMD,
|
||||
(uint8_t *)argv[1], (uint8_t *)&kt, sizeof(kt)) != 0) {
|
||||
fprintf(stderr, "\nread_smc get_key_type error\n\n");
|
||||
return -3;
|
||||
}
|
||||
printf(" type=\"");
|
||||
for (i = 0; i < APPLESMC_KEY_TYPE_LEN; i++)
|
||||
printf(isprint(kt.data_type[i]) ? "%c" : "\\x%02x",
|
||||
(uint8_t)kt.data_type[i]);
|
||||
printf("\" length=%d flags=%x\n", kt.data_len, kt.flags);
|
||||
|
||||
if (read_smc(APPLESMC_READ_CMD,
|
||||
(uint8_t *)argv[1], data_buf, kt.data_len) != 0) {
|
||||
fprintf(stderr, "\nread_smc get_key_data error\n\n");
|
||||
return -4;
|
||||
}
|
||||
printf(" data=\"");
|
||||
for (i = 0; i < kt.data_len; i++)
|
||||
printf(isprint(data_buf[i]) ? "%c" : "\\x%02x",
|
||||
(uint8_t)data_buf[i]);
|
||||
printf("\"\n");
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
# Run "synergys" on Linux host
|
||||
|
||||
section: screens
|
||||
uber:
|
||||
mac:
|
||||
end
|
||||
section: links
|
||||
uber:
|
||||
right = mac
|
||||
mac:
|
||||
left = uber
|
||||
end
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
MD5 (sym/Clover_v2.4k_r4152.pkg) = adf87b4a9aa182859216dee0722a4dff
|
@ -0,0 +1,152 @@
|
||||
### Setting up UEFI enabled macOS
|
||||
|
||||
**This is under development. No support is provided for OVMF and Clover based
|
||||
installations at the moment. Experiment at your own risk.**
|
||||
|
||||
* Install macOS by following the usual Enoch method.
|
||||
|
||||
* Build and use QEMU from https://github.com/kholia/qemu/. Use the "macOS"
|
||||
branch. Clover + macOS will fail to boot without this step.
|
||||
|
||||
* Install the included `Clover_v2*.pkg` on the main macOS disk.
|
||||
|
||||
* Hit the `Customize` button during Clover install.
|
||||
|
||||
* Tick 'Install for UEFI booting only', OsxAptioFix2Drv-64 and
|
||||
PartitionDxe-64 options.
|
||||
|
||||
* The Clover installer should leave the EFI partition mounted for us. Open that
|
||||
up in Finder.
|
||||
|
||||
* Replace the `EFI/CLOVER/config.plist` file with `config.plist` included in
|
||||
this folder.
|
||||
|
||||
* Put the included `q35-acpi-dsdt.aml` file into `EFI/CLOVER/ACPI/origin`
|
||||
location.
|
||||
|
||||
* You may edit `EFI/CLOVER/config.plist` to change the screen resolution from
|
||||
`800x600` to a higher **supported** value.
|
||||
|
||||
This change also requires a corresponding change in the OVMF settings. When
|
||||
using OVMF with a virtual display (without VGA passthrough), you can set the
|
||||
client resolution in the OVMF menu, which you can reach with a press of the
|
||||
ESC button during the OVMF boot logo. In the OVMF menu settings, set Device
|
||||
Manager -> OVMF Platform Configuration -> Change Preferred Resolution for Next
|
||||
Boot to a supported value. Commit changes and exit the OVMF settings.
|
||||
Relaunch the `boot-macOS` script.
|
||||
|
||||
* Finally, use `boot-clover.sh` to use OVMF/UEFI to boot macOS with Clover.
|
||||
|
||||
* You can use `Clover Configurator` to modify your Clover configuration, if
|
||||
required.
|
||||
|
||||
|
||||
### GPU passthrough notes
|
||||
|
||||
These steps will need to be adapted for your particular setup. A host machine
|
||||
with IOMMU support is required. Consult the Arch Wiki article linked to at the
|
||||
bottom of this file for exact requirements and other details.
|
||||
|
||||
I am running Ubuntu 17.04 on Intel i5-6500 + ASUS Z170-AR motherboard + NVIDIA
|
||||
1050 Ti.
|
||||
|
||||
* Enable IOMMU support on the host machine.
|
||||
|
||||
Add `iommu=pt intel_iommu=on video=efifb:off` to the `GRUB_CMDLINE_LINUX_DEFAULT` line in `/etc/default/grub` file.
|
||||
|
||||
* Uninstall NVIDIA drivers from the host machine and blacklist the required modules.
|
||||
|
||||
```
|
||||
$ cat /etc/modprobe.d/blacklist.conf
|
||||
... <existing stuff>
|
||||
|
||||
blacklist radeon
|
||||
blacklist nouveau
|
||||
blacklist nvidia
|
||||
```
|
||||
|
||||
* Enable the required kernel modules.
|
||||
|
||||
```
|
||||
# echo "vfio" >> /etc/modules
|
||||
# echo "vfio_iommu_type1" >> /etc/modules
|
||||
# echo "vfio_pci" >> /etc/modules
|
||||
# echo "vfio_virqfd" >> /etc/modules
|
||||
```
|
||||
|
||||
* Isolate the passthrough PCIe devices with vfio-pci, with the help of `lspci
|
||||
-nnk` command. Adapt these commands to suit your hardware setup.
|
||||
|
||||
```
|
||||
$ lspci -nn
|
||||
...
|
||||
01:00.0 ... NVIDIA Corporation [GeForce GTX 1050 Ti] [10de:1c82]
|
||||
01:00.1 Audio device: NVIDIA Corporation Device [10de:0fb9]
|
||||
03:00.0 USB controller: ASMedia ASM1142 USB 3.1 Host Controller [1b21:1242]
|
||||
```
|
||||
|
||||
```
|
||||
# echo "options vfio-pci ids=10de:1c82,10de:0fb9 disable_vga=1" > /etc/modprobe.d/vfio.conf
|
||||
```
|
||||
|
||||
* Update initramfs, GRUB and then reboot.
|
||||
|
||||
```
|
||||
$ sudo update-grub2
|
||||
$ sudo update-initramfs -k all -u
|
||||
```
|
||||
|
||||
* Verify that the IOMMU is enabled, and vfio_pci is working as expected.
|
||||
Consult Arch Wiki again for help on this.
|
||||
|
||||
* On the macOS VM, install a NVIDIA Web Driver version which is appropriate for
|
||||
the macOS version. Consult http://www.macvidcards.com/drivers.html for more
|
||||
information.
|
||||
|
||||
For example, macOS 10.12.5 requires version `378.05.05.15f01` whereas macOS
|
||||
10.12.6 requires version `378.05.05.25f01`.
|
||||
|
||||
* Boot the macOS VM using the `boot-passthrough.sh` script. At this point, the
|
||||
display connected to your passthrough PCIe device should turn on, and you
|
||||
should see the Clover boot screen. Using the keyboard, navigate to Options ->
|
||||
Graphics Injectord, and enable `Use NVIDIA Web Driver`, then boot macOS.
|
||||
|
||||
* Updating SMBIOS for the macOS to `iMac14,2` might be required. I did not do
|
||||
so myself.
|
||||
|
||||
* To reuse the keyboard and mouse devices from the host, setup "Automatic
|
||||
login" in System Preferences in macOS and configure Synergy software.
|
||||
|
||||
### Synergy Notes
|
||||
|
||||
* Get Synergy from https://sourceforge.net/projects/synergy-stable-builds.
|
||||
|
||||
I installed "synergy-v1.8.8-stable-MacOSX-x86_64.dmg" on the macOS guest and
|
||||
configured it as a client.
|
||||
|
||||
For automatically starting Synergy on macOS, add Synergy to "Login Items",
|
||||
System Preferences -> Users & Groups -> Select your user account -> Login Items
|
||||
-> Add a login item
|
||||
|
||||
* On the Linux host machine, install "synergy-v1.8.8-stable-Linux-x86_64.deb"
|
||||
or newer, configure `~/.synergy.conf` and run `synergys` command.
|
||||
|
||||
* The included `.synergy.conf` will need to be adapted according to your setup.
|
||||
|
||||
#### Credits
|
||||
|
||||
* Nicholas Sherlock and others - UEFI, Clover, and other hacks
|
||||
|
||||
* Kyle Dayton - UEFI, Clover, and GPU passthrough notes
|
||||
|
||||
#### References
|
||||
|
||||
* https://pve.proxmox.com/wiki/Qemu/KVM_Virtual_Machines
|
||||
|
||||
* https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF
|
||||
|
||||
* https://clover-wiki.zetam.org/configuration/smbios
|
||||
|
||||
* https://sourceforge.net/projects/synergy-stable-builds.
|
||||
|
||||
* https://wiki.archlinux.org/index.php/synergy
|
Binary file not shown.
After Width: | Height: | Size: 2.4 MiB |
@ -0,0 +1,172 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>ACPI</key>
|
||||
<dict>
|
||||
<key>DSDT</key>
|
||||
<dict>
|
||||
<key>Debug</key>
|
||||
<false/>
|
||||
<key>DropOEM_DSM</key>
|
||||
<dict>
|
||||
<key>ATI</key>
|
||||
<false/>
|
||||
<key>Firewire</key>
|
||||
<false/>
|
||||
<key>HDA</key>
|
||||
<false/>
|
||||
<key>HDMI</key>
|
||||
<false/>
|
||||
<key>IDE</key>
|
||||
<false/>
|
||||
<key>IntelGFX</key>
|
||||
<false/>
|
||||
<key>LAN</key>
|
||||
<false/>
|
||||
<key>LPC</key>
|
||||
<false/>
|
||||
<key>NVidia</key>
|
||||
<false/>
|
||||
<key>SATA</key>
|
||||
<false/>
|
||||
<key>SmBUS</key>
|
||||
<false/>
|
||||
<key>USB</key>
|
||||
<true/>
|
||||
<key>WIFI</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>Fixes</key>
|
||||
<dict>
|
||||
<key>AddPNLF_1000000</key>
|
||||
<true/>
|
||||
<key>DeleteUnused_400000</key>
|
||||
<true/>
|
||||
<key>FIX_ACST_4000000</key>
|
||||
<true/>
|
||||
<key>FIX_ADP1_800000</key>
|
||||
<true/>
|
||||
<key>FIX_RTC_20000</key>
|
||||
<true/>
|
||||
<key>FIX_S3D_2000000</key>
|
||||
<true/>
|
||||
<key>FixRegions_10000000</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>Name</key>
|
||||
<string>q35-acpi-dsdt.aml</string>
|
||||
<key>ReuseFFFF</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>SSDT</key>
|
||||
<dict>
|
||||
<key>DropOem</key>
|
||||
<false/>
|
||||
<key>Generate</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>Boot</key>
|
||||
<dict>
|
||||
<key>Debug</key>
|
||||
<false/>
|
||||
<key>DefaultLoader</key>
|
||||
<string>boot.efi</string>
|
||||
<key>DefaultVolume</key>
|
||||
<string>LastBootedVolume</string>
|
||||
<key>Legacy</key>
|
||||
<string>PBR</string>
|
||||
<key>Secure</key>
|
||||
<false/>
|
||||
<key>Timeout</key>
|
||||
<integer>5</integer>
|
||||
<key>XMPDetection</key>
|
||||
<string>Yes</string>
|
||||
</dict>
|
||||
<key>CPU</key>
|
||||
<dict>
|
||||
<key>QEMU</key>
|
||||
<true/>
|
||||
<key>UseARTFrequency</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>Devices</key>
|
||||
<dict>
|
||||
<key>USB</key>
|
||||
<dict>
|
||||
<key>FixOwnership</key>
|
||||
<false/>
|
||||
<key>Inject</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>GUI</key>
|
||||
<dict>
|
||||
<key>Mouse</key>
|
||||
<dict>
|
||||
<key>DoubleClick</key>
|
||||
<integer>500</integer>
|
||||
<key>Enabled</key>
|
||||
<false/>
|
||||
<key>Mirror</key>
|
||||
<false/>
|
||||
<key>Speed</key>
|
||||
<integer>8</integer>
|
||||
</dict>
|
||||
<key>Scan</key>
|
||||
<true/>
|
||||
<key>ScreenResolution</key>
|
||||
<string>800x600</string>
|
||||
<key>Theme</key>
|
||||
<string>embedded</string>
|
||||
</dict>
|
||||
<key>Graphics</key>
|
||||
<dict>
|
||||
<key>Inject</key>
|
||||
<false/>
|
||||
<key>NvidiaSingle</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>KernelAndKextPatches</key>
|
||||
<dict>
|
||||
<key>AppleRTC</key>
|
||||
<false/>
|
||||
<key>AsusAICPUPM</key>
|
||||
<false/>
|
||||
<key>Debug</key>
|
||||
<false/>
|
||||
<key>KernelCpu</key>
|
||||
<false/>
|
||||
<key>KernelHaswellE</key>
|
||||
<false/>
|
||||
<key>KernelLapic</key>
|
||||
<false/>
|
||||
<key>KernelPm</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>RtVariables</key>
|
||||
<dict>
|
||||
<key>BooterConfig</key>
|
||||
<string>0x28</string>
|
||||
<key>CsrActiveConfig</key>
|
||||
<string>0x67</string>
|
||||
<key>ROM</key>
|
||||
<string>UseMacAddr0</string>
|
||||
</dict>
|
||||
<key>SMBIOS</key>
|
||||
<dict>
|
||||
<key>Manufacturer</key>
|
||||
<string>Apple Inc.</string>
|
||||
<key>Trust</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>SystemParameters</key>
|
||||
<dict>
|
||||
<key>InjectKexts</key>
|
||||
<string>Detect</string>
|
||||
<key>InjectSystemID</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
OVMF_CODE-pure-efi.fd and OVMF_VARS-pure-efi.fd files are borrowed from Proxmox.
|
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# See https://www.mail-archive.com/qemu-devel@nongnu.org/msg471657.html thread.
|
||||
#
|
||||
# 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 \
|
||||
-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.fd \
|
||||
-drive if=pflash,format=raw,file=OVMF_VARS.fd \
|
||||
-smbios type=2 \
|
||||
-device ich9-intel-hda -device hda-duplex \
|
||||
-device ide-drive,bus=ide.2,drive=MacHDD \
|
||||
-drive id=MacHDD,if=none,file=./mac_hdd.img \
|
||||
-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
|
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
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 \
|
||||
-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=OVMF_CODE.fd \
|
||||
-drive if=pflash,format=raw,file=OVMF_VARS.fd \
|
||||
-smbios type=2 \
|
||||
-device ide-drive,bus=ide.2,drive=MacHDD \
|
||||
-drive id=MacHDD,if=none,file=./mac_hdd.img \
|
||||
-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
|
@ -1,35 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# qemu-img create -f qcow2 mac_hdd.img 64G
|
||||
# echo 1 > /sys/module/kvm/parameters/ignore_msrs
|
||||
#
|
||||
# Type the following after boot,
|
||||
# -v "KernelBooter_kexts"="Yes" "CsrActiveConfig"="103"
|
||||
#
|
||||
# printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256))
|
||||
#
|
||||
# no_floppy = 1 is required for OS X guests!
|
||||
#
|
||||
# Commit 473a49460db0a90bfda046b8f3662b49f94098eb (qemu) makes "no_floppy = 0"
|
||||
# for pc-q35-2.3 hardware, and OS X doesn't like this (it hangs at "Waiting for
|
||||
# DSMOS" message). Hence, we switch to pc-q35-2.4 hardware.
|
||||
#
|
||||
# Network device "-device e1000-82545em" can be replaced with "-device vmxnet3"
|
||||
# for possibly better performance.
|
||||
|
||||
qemu-system-x86_64 -enable-kvm -m 8192 -cpu core2duo,kvm=off \
|
||||
-machine pc-q35-2.4 \
|
||||
-smp 4,cores=2 \
|
||||
-usb -device usb-kbd -device usb-mouse \
|
||||
-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" \
|
||||
-kernel ./enoch_rev2839_boot \
|
||||
-smbios type=2 \
|
||||
-device ide-drive,bus=ide.2,drive=MacHDD \
|
||||
-drive id=MacHDD,if=none,file=./mac_hdd.img \
|
||||
-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 \
|
||||
-device ide-drive,bus=ide.0,drive=MacDVD \
|
||||
-drive id=MacDVD,if=none,snapshot=on,file=./Install_OS_X_10.11.6_El_Capitan.iso
|
||||
# -vnc 0.0.0.0:0 -k en-us \
|
||||
# -redir tcp:5901::5900 \
|
||||
# -netdev user,id=hub0port0 -device e1000-82545em,netdev=hub0port0,id=mac_vnet0 \
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
options kvm_intel nested=1
|
||||
options kvm_intel emulate_invalid_guest_state=0
|
||||
options kvm ignore_msrs=1
|
@ -0,0 +1,127 @@
|
||||
#!/usr/bin/env python
|
||||
# https://gist.github.com/Lekensteyn (Peter Wu)
|
||||
#
|
||||
# Extract .cpio file from a pbzx Payload file.
|
||||
#
|
||||
# Based on https://gist.github.com/pudquick/ac29c8c19432f2d200d4. This version
|
||||
# adds a command-line interface, improves efficiency (1 MiB chunks instead of a
|
||||
# full copy in memory), adds Python 3 compatibility and automatically
|
||||
# decompresses stuff (some blocks may not be compressed).
|
||||
#
|
||||
# Example usage (from Python):
|
||||
#
|
||||
# parse_pbzx(open('PayloadJava', 'rb'), open('PayloadJava.cpio', wb'))
|
||||
#
|
||||
# Example usage (from shell):
|
||||
#
|
||||
# # These are all equivalent
|
||||
# ./parse_pbzx.py < PayloadJava > PayloadJava.cpio
|
||||
# ./parse_pbzx.py PayloadJava > PayloadJava.cpio
|
||||
# ./parse_pbzx.py PayloadJava PayloadJava.cpio
|
||||
#
|
||||
# Another example, extract Payload from a .pkg file, convert it to a cpio.xz
|
||||
# archive (this script) and list contents (cpio -t):
|
||||
#
|
||||
# bsdtar -xOf some.pkg Payload | ./parse_pbzx.py Payload | cpio -t
|
||||
#
|
||||
# Kernel extraction example:
|
||||
#
|
||||
# tar -xOf Essentials.pkg Payload | ./parse_pbzx.py | cpio -idmu ./System/Library/Kernels
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import struct
|
||||
import sys
|
||||
from contextlib import contextmanager
|
||||
import subprocess
|
||||
|
||||
|
||||
def dbg_print(*args):
|
||||
# Uncomment next line for debugging
|
||||
# print(*args, file=sys.stderr)
|
||||
pass
|
||||
|
||||
|
||||
def read_f(f, count):
|
||||
"""Try to fully read data, raising EOFError on short reads."""
|
||||
data = f.read(count)
|
||||
read_bytes = len(data)
|
||||
if read_bytes != count:
|
||||
raise EOFError("Read %d, expected %d" % (read_bytes, count))
|
||||
return data
|
||||
|
||||
|
||||
def copy_data(f_in, f_out, count):
|
||||
"""Copy in chunks of a megabyte to avoid excess memory waste."""
|
||||
while count > 0:
|
||||
sz = min(count, 1024**2)
|
||||
f_out.write(read_f(f_in, sz))
|
||||
count -= sz
|
||||
|
||||
|
||||
@contextmanager
|
||||
def unxz(f_out):
|
||||
# proc = subprocess.Popen(["unxz"], stdin=subprocess.PIPE, stdout=f_out)
|
||||
proc = subprocess.Popen(["zcat"], stdin=subprocess.PIPE, stdout=f_out)
|
||||
try:
|
||||
yield proc.stdin
|
||||
finally:
|
||||
proc.stdin.close()
|
||||
ret = proc.wait()
|
||||
if ret != 0:
|
||||
raise OSError("Decompression failed with status code %d" % ret)
|
||||
|
||||
|
||||
def parse_pbzx(pbzx_file, cpio_file):
|
||||
magic = read_f(pbzx_file, 4)
|
||||
if magic != b'pbzx':
|
||||
raise RuntimeError("Error: Not a pbzx file")
|
||||
# Read 8 bytes for initial flags
|
||||
flags = read_f(pbzx_file, 8)
|
||||
# Interpret the flags as a 64-bit big-endian unsigned int
|
||||
flags = struct.unpack('>Q', flags)[0]
|
||||
out_offset, in_offset = 0, 4 + 8
|
||||
while (flags & (1 << 24)):
|
||||
# Read in more flags
|
||||
flags = read_f(pbzx_file, 8)
|
||||
flags = struct.unpack('>Q', flags)[0]
|
||||
# Read in length
|
||||
f_length = read_f(pbzx_file, 8)
|
||||
f_length = struct.unpack('>Q', f_length)[0]
|
||||
|
||||
if f_length == 0x1000000:
|
||||
# Literal copy
|
||||
copy_data(pbzx_file, cpio_file, f_length)
|
||||
else:
|
||||
xzmagic = read_f(pbzx_file, 6)
|
||||
dbg_print("Flags: %#018x Length: %r Magic: %r" % (flags, f_length, xzmagic))
|
||||
if xzmagic != b'\xfd7zXZ\x00':
|
||||
cpio_file.close()
|
||||
# raise RuntimeError("Error: Header is not xar file header: offset %d, magic %r" % (offset, xzmagic))
|
||||
raise RuntimeError("Error: Header is not xar file header: offset %d, magic %r" % (0, xzmagic))
|
||||
else:
|
||||
with unxz(cpio_file) as unxz_f:
|
||||
unxz_f.write(xzmagic)
|
||||
# Do not copy header magic again (-6)
|
||||
copy_data(pbzx_file, unxz_f, -6 + f_length)
|
||||
|
||||
in_offset += 8 + 8 + f_length
|
||||
out_offset += f_length
|
||||
dbg_print("Read %d bytes, wrote %d bytes so far" % (in_offset, out_offset))
|
||||
try:
|
||||
cpio_file.close()
|
||||
except:
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
def open_file(argno, mode, f):
|
||||
if len(sys.argv) > argno:
|
||||
return open(sys.argv[argno], mode)
|
||||
# Access binary stdin/stdout in Python 3
|
||||
if hasattr(f, "buffer"):
|
||||
return f.buffer
|
||||
else:
|
||||
return f
|
||||
in_file = open_file(1, "rb", sys.stdin)
|
||||
out_file = open_file(2, "wb", sys.stdout)
|
||||
parse_pbzx(in_file, out_file)
|
@ -1 +0,0 @@
|
||||
45ce9f06b0a417f875dbd1f23bc0f860 pbzx
|
@ -1 +0,0 @@
|
||||
b6d928432e8837defdec18d1698665f16863432cb499a60ca14d734540ab014c pbzx
|
Loading…
Reference in New Issue