⬢ DragonFlyBSD Kernel Audit
DF-4890 / precond_probe.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-4890 precondition probe — run IN THE GUEST (root).
# Establishes whether the guest hosts the runtime preconditions of the
# AcpiOsAcquireLock idle-vs-normal race:
#   (1) SMP:                     hw.ncpu >= 2
#   (2) ACPI C-State driver:     cpu_cst* attached
#   (3) deep C-states (C2/C3):   cx_supported advertises more than C1
#                                (the idle-thread side of the race only
#                                executes on C3/BM/ARB paths:
#                                acpi_cpu_cstate.c:930-935,957-977)
echo "== uname =="; uname -a
echo "== cpus =="; sysctl hw.ncpu hw.machine
echo "== cst attach =="; sysctl -a 2>/dev/null | grep -E '^dev\.cpu\.[0-9]+\.%desc' | head -8
dmesg | grep -i 'cpu_cst' | head -8
echo "== cx states =="; sysctl -a 2>/dev/null | grep -E 'cx_supported|cx_lowest' | head -16
echo "== idle hook =="; sysctl -a 2>/dev/null | grep -E 'cpu_idlehlt|cpu_mwait' | head -6
echo "== verdict preconditions =="
NCPU=$(sysctl -n hw.ncpu)
CX=$(sysctl -n hw.acpi.cpu0.cx_supported 2>/dev/null)
echo "ncpu=$NCPU cpu0.cx_supported=${CX:-none}"
case "$CX" in
  *C2*|*C3*) echo "PRECONDITION C2/C3: PRESENT (race hostable)" ;;
  *)         echo "PRECONDITION C2/C3: ABSENT (idle-side taker never runs; race not hostable on this machine)" ;;
esac