mirror of
https://github.com/dockur/macos.git
synced 2026-10-12 02:13:08 +00:00
feat: Improve CPU compatibility and performance (#425)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "macOS 14 (Sonoma)",
|
||||
"service": "macos",
|
||||
"containerEnv": {
|
||||
"VERSION": "14"
|
||||
},
|
||||
"forwardPorts": [8006],
|
||||
"portsAttributes": {
|
||||
"8006": {
|
||||
"label": "Web",
|
||||
"onAutoForward": "notify"
|
||||
}
|
||||
},
|
||||
"otherPortsAttributes": {
|
||||
"onAutoForward": "ignore"
|
||||
},
|
||||
"dockerComposeFile": "../codespaces.yml",
|
||||
"initializeCommand": "docker system prune --all --force"
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "macOS 14 (Sonoma)",
|
||||
"name": "macOS 26 (Tahoe)",
|
||||
"service": "macos",
|
||||
"containerEnv": {
|
||||
"VERSION": "14"
|
||||
"VERSION": "26"
|
||||
},
|
||||
"forwardPorts": [8006],
|
||||
"portsAttributes": {
|
||||
|
||||
@@ -94,7 +94,7 @@ kubectl apply -f https://raw.githubusercontent.com/dockur/macos/refs/heads/maste
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
VERSION: "15"
|
||||
VERSION: "13"
|
||||
```
|
||||
|
||||
Select from the values below:
|
||||
@@ -108,7 +108,7 @@ kubectl apply -f https://raw.githubusercontent.com/dockur/macos/refs/heads/maste
|
||||
| `11` | macOS 11 | Big Sur |
|
||||
|
||||
> [!NOTE]
|
||||
> Support for macOS 15 (Sequoia) is still in its infancy, as it does not allow you to sign in to your Apple Account yet.
|
||||
> Starting with macOS 15 (Sequoia), you cannot sign in to an Apple Account unless you install [VMHide.kext](https://github.com/Carnations-Botanica/VMHide) first.
|
||||
|
||||
### How do I change the storage location?
|
||||
|
||||
|
||||
-82
@@ -175,86 +175,4 @@ BOOT_DRIVE_ID="OpenCore"
|
||||
DISK_OPTS+=" -device virtio-blk-pci,drive=${BOOT_DRIVE_ID},bus=pcie.0,addr=0x5,bootindex=$BOOT_INDEX"
|
||||
DISK_OPTS+=" -drive file=$IMG,id=$BOOT_DRIVE_ID,format=raw,cache=unsafe,readonly=on,if=none"
|
||||
|
||||
CPU_VENDOR=$(lscpu | awk '/Vendor ID/{print $3}')
|
||||
DEFAULT_FLAGS="vendor=GenuineIntel,vmx=off,vmware-cpuid-freq=on,-pdpe1gb"
|
||||
|
||||
if [[ "$CPU_VENDOR" == "AuthenticAMD" || "${KVM:-}" == [Nn]* ]]; then
|
||||
|
||||
if [ -z "${CPU_MODEL:-}" ]; then
|
||||
|
||||
case "${VERSION,,}" in
|
||||
"ventura" | "13"* )
|
||||
CPU_MODEL="Haswell-noTSX" ;;
|
||||
"monterey" | "12"* )
|
||||
CPU_MODEL="Haswell-noTSX" ;;
|
||||
"bigsur" | "big-sur" | "11"* )
|
||||
CPU_MODEL="Haswell-noTSX" ;;
|
||||
"catalina" | "10"* )
|
||||
CPU_MODEL="Haswell-noTSX" ;;
|
||||
*)
|
||||
CPU_MODEL="Skylake-Client-v4"
|
||||
DEFAULT_FLAGS+=",-spec-ctrl"
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
if [[ "${KVM:-}" == [Nn]* ]] || [[ "${ARCH,,}" != "amd64" ]] || [[ "$OSTYPE" =~ ^darwin ]]; then
|
||||
DEFAULT_FLAGS+=",-pcid,-tsc-deadline,-invpcid,-xsavec,-xsaves,+ssse3,+sse4.2,+popcnt,+avx,+avx2,+aes,+fma,+bmi1,+bmi2,+smep,+xsave,+xsaveopt,+xgetbv1,+movbe,+rdrand,check"
|
||||
else
|
||||
DEFAULT_FLAGS+=",+pcid,+ssse3,+sse4.2,+popcnt,+avx,+avx2,+aes,+fma,+bmi1,+bmi2,+smep,+xsave,+xsavec,+xsaves,+xsaveopt,+xgetbv1,+movbe,+rdrand,check"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [ -z "${CPU_FLAGS:-}" ]; then
|
||||
CPU_FLAGS="$DEFAULT_FLAGS"
|
||||
else
|
||||
CPU_FLAGS="$DEFAULT_FLAGS,$CPU_FLAGS"
|
||||
fi
|
||||
|
||||
SM_BIOS=""
|
||||
CLOCKSOURCE="tsc"
|
||||
[[ "${ARCH,,}" == "arm64" ]] && CLOCKSOURCE="arch_sys_counter"
|
||||
CLOCK="/sys/devices/system/clocksource/clocksource0/current_clocksource"
|
||||
|
||||
if [ ! -f "$CLOCK" ]; then
|
||||
warn "file \"$CLOCK\" cannot be found?"
|
||||
else
|
||||
result=$(<"$CLOCK")
|
||||
result="${result//[![:print:]]/}"
|
||||
case "${result,,}" in
|
||||
"${CLOCKSOURCE,,}" )
|
||||
if [[ "$CPU_VENDOR" == "GenuineIntel" && "$CPU_CORES" == "1" && "${KVM:-}" != [Nn]* ]]; then
|
||||
CPU_CORES="2"
|
||||
fi ;;
|
||||
"kvm-clock" ) warn "Nested KVM virtualization detected, this might cause issues running macOS!" ;;
|
||||
"hyperv_clocksource_tsc_page" ) info "Nested Hyper-V virtualization detected, this might cause issues running macOS!" ;;
|
||||
"hpet" ) warn "unsupported clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE', otherwise it will cause issues running macOS!" ;;
|
||||
*) warn "unexpected clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE', otherwise it will cause issues running macOS!" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case "$CPU_CORES" in
|
||||
"" | "0" | "3" ) CPU_CORES="2" ;;
|
||||
"5" ) CPU_CORES="4" ;;
|
||||
"9" ) CPU_CORES="8" ;;
|
||||
esac
|
||||
|
||||
case "$CPU_CORES" in
|
||||
"1" | "2" | "4" | "8" ) SMP="$CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1" ;;
|
||||
"6" | "7" ) SMP="$CPU_CORES,sockets=3,dies=1,cores=2,threads=1" ;;
|
||||
"10" | "11" ) SMP="$CPU_CORES,sockets=5,dies=1,cores=2,threads=1" ;;
|
||||
"12" | "13" ) SMP="$CPU_CORES,sockets=3,dies=1,cores=4,threads=1" ;;
|
||||
"14" | "15" ) SMP="$CPU_CORES,sockets=7,dies=1,cores=2,threads=1" ;;
|
||||
"16" | "32" | "64" ) SMP="$CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1" ;;
|
||||
*)
|
||||
error "Invalid amount of CPU_CORES, value \"${CPU_CORES}\" is not a power of 2!" && exit 35
|
||||
;;
|
||||
esac
|
||||
|
||||
USB="nec-usb-xhci,id=xhci"
|
||||
USB+=" -device usb-kbd,bus=xhci.0"
|
||||
USB+=" -global nec-usb-xhci.msi=off"
|
||||
|
||||
return 0
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
CPU_VENDOR=$(lscpu | awk '/Vendor ID/{print $3}')
|
||||
DEFAULT_FLAGS="vendor=GenuineIntel,vmx=off,vmware-cpuid-freq=on,-pdpe1gb"
|
||||
|
||||
has_flag() {
|
||||
# Match a whitespace-delimited token in /proc/cpuinfo (works for flags containing '-' and avoids substring matches)
|
||||
awk -v f="$1" '
|
||||
$1 == "flags" {
|
||||
for (i = 1; i <= NF; i++) if ($i == f) exit 0
|
||||
}
|
||||
END { exit 1 }
|
||||
' /proc/cpuinfo
|
||||
}
|
||||
|
||||
if [[ "$CPU_VENDOR" == "AuthenticAMD" || "${KVM:-}" == [Nn]* ]]; then
|
||||
|
||||
# Configuration for AMD processors
|
||||
|
||||
if [ -z "${CPU_MODEL:-}" ]; then
|
||||
|
||||
case "${VERSION,,}" in
|
||||
"10"* | "11"* | "12"* | "13"* | \
|
||||
"catalina" | "bigsur" | "big-sur" | "monterey" | "ventura" )
|
||||
CPU_MODEL="Haswell-noTSX"
|
||||
;;
|
||||
*)
|
||||
CPU_MODEL="Skylake-Client-v4"
|
||||
if has_flag "spec-ctrl" && [[ "${KVM:-}" != [Nn]* ]]; then
|
||||
DEFAULT_FLAGS+=",+spec-ctrl"
|
||||
else
|
||||
DEFAULT_FLAGS+=",-spec-ctrl"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
if [[ "${KVM:-}" == [Nn]* ]]; then
|
||||
|
||||
DEFAULT_FLAGS+=",-pcid,-invpcid,-tsc-deadline,-xsavec,-xsaves"
|
||||
|
||||
else
|
||||
|
||||
for flag in pcid invpcid tsc-deadline xsavec xsaves; do
|
||||
if has_flag "$flag"; then
|
||||
DEFAULT_FLAGS+=",+$flag"
|
||||
else
|
||||
DEFAULT_FLAGS+=",-$flag"
|
||||
fi
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
DEFAULT_FLAGS+=",+ssse3,+sse4.2,+popcnt,+avx,+avx2,+aes,+fma,+bmi1,+bmi2,+smep,+xsave,+xsaveopt,+xgetbv1,+movbe,+rdrand,check"
|
||||
|
||||
else
|
||||
|
||||
# Configuration for Intel processors
|
||||
|
||||
if [ -z "${CPU_MODEL:-}" ]; then
|
||||
|
||||
CPU_MODEL="Skylake-Client-v4"
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [ -z "${CPU_FLAGS:-}" ]; then
|
||||
CPU_FLAGS="$DEFAULT_FLAGS"
|
||||
else
|
||||
CPU_FLAGS="$DEFAULT_FLAGS,$CPU_FLAGS"
|
||||
fi
|
||||
|
||||
SM_BIOS=""
|
||||
CLOCKSOURCE="tsc"
|
||||
[[ "${ARCH,,}" == "arm64" ]] && CLOCKSOURCE="arch_sys_counter"
|
||||
CLOCK="/sys/devices/system/clocksource/clocksource0/current_clocksource"
|
||||
|
||||
if [ ! -f "$CLOCK" ]; then
|
||||
warn "file \"$CLOCK\" cannot be found?"
|
||||
else
|
||||
result=$(<"$CLOCK")
|
||||
result="${result//[![:print:]]/}"
|
||||
case "${result,,}" in
|
||||
"${CLOCKSOURCE,,}" )
|
||||
if [[ "$CPU_VENDOR" == "GenuineIntel" && "$CPU_CORES" == "1" && "${KVM:-}" != [Nn]* ]]; then
|
||||
CPU_CORES="2"
|
||||
fi ;;
|
||||
"kvm-clock" ) warn "Nested KVM virtualization detected, this might cause issues running macOS!" ;;
|
||||
"hyperv_clocksource_tsc_page" ) info "Nested Hyper-V virtualization detected, this might cause issues running macOS!" ;;
|
||||
"hpet" ) warn "unsupported clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE', otherwise it will cause issues running macOS!" ;;
|
||||
*) warn "unexpected clock source detected: '$result'. Please set host clock source to '$CLOCKSOURCE', otherwise it will cause issues running macOS!" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case "$CPU_CORES" in
|
||||
"" | "0" | "3" ) CPU_CORES="2" ;;
|
||||
"5" ) CPU_CORES="4" ;;
|
||||
"9" ) CPU_CORES="8" ;;
|
||||
esac
|
||||
|
||||
case "$CPU_CORES" in
|
||||
"1" | "2" | "4" | "8" ) SMP="$CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1" ;;
|
||||
"6" | "7" ) SMP="$CPU_CORES,sockets=3,dies=1,cores=2,threads=1" ;;
|
||||
"10" | "11" ) SMP="$CPU_CORES,sockets=5,dies=1,cores=2,threads=1" ;;
|
||||
"12" | "13" ) SMP="$CPU_CORES,sockets=3,dies=1,cores=4,threads=1" ;;
|
||||
"14" | "15" ) SMP="$CPU_CORES,sockets=7,dies=1,cores=2,threads=1" ;;
|
||||
"16" | "32" | "64" ) SMP="$CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1" ;;
|
||||
*)
|
||||
error "Invalid amount of CPU_CORES, value \"${CPU_CORES}\" is not a power of 2!" && exit 35
|
||||
;;
|
||||
esac
|
||||
|
||||
USB="nec-usb-xhci,id=xhci"
|
||||
USB+=" -device usb-kbd,bus=xhci.0"
|
||||
USB+=" -global nec-usb-xhci.msi=off"
|
||||
|
||||
return 0
|
||||
+16
-3
@@ -3,8 +3,8 @@ set -Eeuo pipefail
|
||||
|
||||
: "${APP:="macOS"}"
|
||||
: "${VGA:="vmware"}"
|
||||
: "${DISK_TYPE:="blk"}"
|
||||
: "${PLATFORM:="x64"}"
|
||||
: "${DISK_TYPE:="blk"}"
|
||||
: "${SUPPORT:="https://github.com/dockur/macos"}"
|
||||
|
||||
cd /run
|
||||
@@ -18,6 +18,7 @@ cd /run
|
||||
. display.sh # Initialize graphics
|
||||
. network.sh # Initialize network
|
||||
. boot.sh # Configure boot
|
||||
. cpu.sh # Configure CPU model
|
||||
. proc.sh # Initialize processor
|
||||
. power.sh # Configure shutdown
|
||||
. memory.sh # Check available memory
|
||||
@@ -31,11 +32,23 @@ cmd=(qemu-system-x86_64)
|
||||
version=$("${cmd[@]}" --version | awk 'NR==1 { print $4 }')
|
||||
info "Booting ${APP}${BOOT_DESC} using QEMU v$version..."
|
||||
|
||||
pipe="$QEMU_DIR/qemu.pipe"
|
||||
rm -f "$pipe" && mkfifo "$pipe"
|
||||
|
||||
sed -u \
|
||||
-e 's/\x1B\[[=0-9;]*[a-z]//gi' \
|
||||
-e 's/\x1B\x63//g' \
|
||||
-e 's/\x1B\[[=?]7l//g' \
|
||||
-e '/^$/d' \
|
||||
-e 's/\x44\x53\x73//g' \
|
||||
-e 's/failed to load Boot/skipped Boot/g' \
|
||||
<"$pipe" &
|
||||
|
||||
if [[ "$SHUTDOWN" != [Yy1]* ]]; then
|
||||
exec "${cmd[@]}" ${ARGS:+ $ARGS}
|
||||
exec "${cmd[@]}" ${ARGS:+ $ARGS} >"$pipe"
|
||||
fi
|
||||
|
||||
"${cmd[@]}" ${ARGS:+ $ARGS} &
|
||||
"${cmd[@]}" ${ARGS:+ $ARGS} >"$pipe" &
|
||||
|
||||
rc=0
|
||||
wait $! || rc=$?
|
||||
|
||||
Reference in New Issue
Block a user