Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Detect nested virtualization #94

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ else
CPU_FLAGS="$DEFAULT_FLAGS,$CPU_FLAGS"
fi

CLOCK="/sys/devices/system/clocksource/clocksource0/current_clocksource"
[ -f "$CLOCK" ] && CLOCK=$(<"$CLOCK")

if [[ "${CLOCK,,}" == "kvm-clock" ]]; then
if [[ "$CPU_VENDOR" != "GenuineIntel" ]] && [[ "${CPU_CORES,,}" == "2" ]]; then
warn "Restricted processor to a single core because nested virtualization was detected!"
CPU_CORES="1"
else
warn "Nested virtualization was detected, this might cause issues running macOS!"
fi
fi

if [[ "${CLOCK,,}" == "hpet" ]]; then
warn "Your clocksource is HPET instead of TSC, this will cause issues running macOS!"
fi

case "$CPU_CORES" in
"" | "0" | "3" ) CPU_CORES="2" ;;
"5" ) CPU_CORES="4" ;;
Expand Down