From b6be9597120cc511c0ff4223693c7a9d369120c0 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 12 Oct 2024 20:05:41 +0200 Subject: [PATCH] feat: Detect nested virtualization (#94) --- src/boot.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/boot.sh b/src/boot.sh index 190ca14..879253f 100644 --- a/src/boot.sh +++ b/src/boot.sh @@ -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" ;;