Skip to content
Closed
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions tools/aurora-sep/air-gpu/air-gpu-collect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# the tgz has lines naming a serial number dropped and MAC addresses masked.
#
# The last line printed is the verdict, one of:
# NOT-ARMED the analysed boot did not have asahi.t8122_start=1 (no one-shot boot)
# NOT-ARMED the analysed boot did not have aurora.t8122_start=1 (or asahi.t8122_start=1) (no one-shot boot)
# ARMED-NO-LOG the last arming's boot left no kernel log (most likely a hang in the GPU
# start, before the journal was written); no older boot's result is shown
# ARMED-NOT-STARTED armed, but the driver stopped before it started the firmware
Expand Down Expand Up @@ -82,11 +82,11 @@ RE_KERNEL_ARMED='M3 G15G start: armed'
# 2. Without those lines (a kernel before them, or a test run on an M3 Pro), these extended regexes
# decide, in this order: armed? -> firmware started? -> InitData sent? -> accepted? -> job?
# The boot was armed: on its command line.
RE_ARMED='(^| )asahi\.t8122_start=1( |$)'
RE_ARMED='(^| )(asahi|aurora)\.t8122_start=1( |$)'
# The driver refused or stopped before it started the firmware (the last such line is the reason).
RE_REFUSED='M3 G15G start: (refused|not armed)|GPU startup disabled|identity or ABI rejected|startup refused|no GPU backend|invalid for parameter .asahi\.|InitData self-check failed'
RE_REFUSED='M3 G15G start: (refused|not armed)|GPU startup disabled|identity or ABI rejected|startup refused|no GPU backend|invalid for parameter .(asahi|aurora)\.|InitData self-check failed'
# The probe ended in an error (the reason when nothing more specific was logged).
RE_PROBE_FAILED='probe with driver asahi failed'
RE_PROBE_FAILED='probe with driver (asahi|aurora) failed'
# The driver probed the GPU at all (without a boot-loader handoff the GPU node is disabled).
RE_PROBED='asahi [0-9a-f]+\.gpu: Probing'
# The GPU coprocessor's firmware was started.
Expand All @@ -105,7 +105,7 @@ RE_JOB_NOT_DISPATCHED='GPU is powered down'
RE_JOB_FAILED='M3 scheduler: execution failed|M3 completion events=|GPU is powered down|M3 fault render|M3 bank [0-9]+ fault=0x[0-9a-f]*[1-9a-f]|M3 fault mapping'
#
# The GPU lines kept in gpu-log.txt, and the firmware's own log lines in firmware-log.txt.
RE_GPU_LINES='asahi|agx|G15|M3[ _:]|t8122|gpu|RTKit|devcoredump|macsmc'
RE_GPU_LINES='asahi|aurora|agx|G15|M3[ _:]|t8122|gpu|RTKit|devcoredump|macsmc'
RE_FW_LOG='\.gpu: RTKit: (syslog|crashlog|co-processor|Unknown)|firmware crashed|crashlog|M3 firmware|M3 G15G (verdict|start)'
# SMC power keys that read zero at idle on an M3 Air (J613) sample (2026-10-06): the GPU rail
# candidates. One of them should rise the first time the GPU draws power.
Expand Down Expand Up @@ -376,7 +376,7 @@ classify_core() {
last_line() { { grep -aE "$1" "$log" || true; } | tail -1 | sed -E 's/^\[[^]]*\] *//; s/^[^ ]+ kernel: //'; }
if ! [[ " $cmd " =~ $RE_ARMED ]]; then
VERDICT=NOT-ARMED VERDICT_SRC=cmdline
REASON="asahi.t8122_start=1 is not on the analysed boot's command line"
REASON="neither aurora.t8122_start=1 nor asahi.t8122_start=1 is on the analysed boot's command line"
return 0
fi
if grep -qaE "$RE_KERNEL_VERDICT" "$log"; then
Expand Down
23 changes: 13 additions & 10 deletions tools/aurora-sep/air-gpu/air-gpu-oneshot.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
# air-gpu-oneshot.sh: arm ONE boot of this M3 MacBook Air with the GPU start switch
# (asahi.t8122_start=1) and the given asahi knobs on the kernel command line.
# (aurora.t8122_start=1, and asahi.t8122_start=1 for kernels that still build asahi.ko) and the
# given knobs on the kernel command line.
#
# sudo air-gpu-oneshot.sh start arm one boot with the kernel's defaults
# sudo air-gpu-oneshot.sh <knob>=<value> ... arm one boot with these knobs as well
Expand Down Expand Up @@ -146,16 +147,17 @@ list_knobs() {
printf '%s\n' "$KNOBS" | sed '/^$/d'
}

# Fills PARAMS ("asahi.name=value" words, t8122_start first) from the arguments, or refuses.
# Fills PARAMS from the arguments, or refuses: each knob as asahi.name=value and aurora.name=value
# (aurora.ko reads aurora.*, the older asahi.ko asahi.*), t8122_start first.
PARAMS=()
parse_knobs() {
local arg name value line re seen=" "
PARAMS=("asahi.t8122_start=1")
PARAMS=("asahi.t8122_start=1" "aurora.t8122_start=1")
for arg in "$@"; do
[[ $arg == start ]] && continue
[[ $arg == *=* ]] || refuse "\"$arg\" is not a knob=value (or start)."
name=${arg%%=*} value=${arg#*=}
name=${name#asahi.}
name=${name#asahi.} name=${name#aurora.}
line=$(knob_line "$name")
[[ -n $line ]] || refuse "unknown knob \"$name\" (air-gpu-oneshot.sh --list-knobs lists them)."
re=$(awk '{ print $2 }' <<<"$line")
Expand All @@ -165,7 +167,7 @@ parse_knobs() {
[[ $seen != *" $name "* ]] || refuse "$name is given twice."
seen+="$name "
[[ $name == t8122_start ]] && continue
PARAMS+=("asahi.$name=$value")
PARAMS+=("asahi.$name=$value" "aurora.$name=$value")
done
}

Expand Down Expand Up @@ -428,9 +430,9 @@ preflight() {
refuse "the //$SOURCE_ENTRY entry has no cmdline: with root= to copy."
[[ $SRC_CMDLINE != *'"'* && $SRC_CMDLINE != *"'"* ]] ||
refuse "the //$SOURCE_ENTRY command line has quotes, which this script does not rewrite."
# The kernel reads - and _ alike in a parameter name, and a bare asahi.t8122_start means =1.
[[ ! " $SRC_CMDLINE " =~ \ asahi\.t8122[_-]start([=\ ]) ]] ||
refuse "the normal //$SOURCE_ENTRY entry already sets asahi.t8122_start, so every boot would start the GPU. Remove it from /etc/default/limine first."
# The kernel reads - and _ alike in a parameter name, and a bare aurora.t8122_start means =1.
[[ ! " $SRC_CMDLINE " =~ \ (asahi|aurora)\.t8122[_-]start([=\ ]) ]] ||
refuse "the normal //$SOURCE_ENTRY entry already sets t8122_start, so every boot would start the GPU. Remove it from /etc/default/limine first."
UKI=$(limine_file "$SRC_PATH")
[[ -f $UKI ]] || refuse "the //$SOURCE_ENTRY entry's UKI $UKI does not exist."
if [[ $SRC_PATH == *#* ]]; then
Expand All @@ -443,7 +445,8 @@ preflight() {
fi
grep -qaF "$KREL" "$UKI" || refuse "$UKI is not the kernel this boot runs ($KREL). Reboot into the installed kernel first."
for p in "${PARAMS[@]}"; do
p=${p%%=*}
[[ $p == aurora.* ]] && continue
p=${p%%=*} p=${p#asahi.}
if ! grep -qaF "$p" "$UKI"; then
if is_m3pro && ((ALLOW_M3PRO)); then
WARNINGS+=("this kernel has no $p parameter; the test boot ignores it")
Expand Down Expand Up @@ -511,7 +514,7 @@ new_cmdline() {
set +f
for w in "${words[@]}"; do
skip=0
[[ $w == asahi.t8122[_-]* || $w == "$TAG"=* || $w == panic=* ]] && skip=1
[[ $w == asahi.t8122[_-]* || $w == aurora.t8122[_-]* || $w == "$TAG"=* || $w == panic=* ]] && skip=1
for p in "${PARAMS[@]}"; do
name=${p%%=*}
[[ $w == "$name" || $w == "$name"=* ]] && skip=1
Expand Down
26 changes: 14 additions & 12 deletions tools/aurora-sep/install-aurora-sep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,8 @@ M3_PERSISTENT_TRANSACTION_ACTIVE=0
M3_PERSISTENT_MAIN_ARMED=0
M3_GPU_BIN=/usr/local/bin
M3_GPU_SCRIPTS=(
"air-gpu-oneshot.sh d0259869b8519439a4dbcdae08ef1b0e17fdcaf84ac746fca61febf6a325f8aa"
"air-gpu-collect.sh face8fac811b59c31a8e98e6ca704a2cb33eceada8bc37986397cb393b050b30"
"air-gpu-oneshot.sh 9d41005ecd45485fd573a01237e2b8e4f4a5a4f9ecaad59ec84ca7cedbad3104"
"air-gpu-collect.sh 87d26091209580abadbcf128ec04a59751a2d91830d4018b2ee8506d6420151b"
"air-gpu-job.sh 9a0eb9aab52fd099488054e4ed4846c579b19fc9f78144245242b6975a40da1d"
)
# The Mesa prefix air-gpu-job.sh runs with: mesa-m3's (12.4 on; it replaces the separate
Expand Down Expand Up @@ -1741,7 +1741,7 @@ mesa_needs_too_old() {
# the tools of an earlier one.
m3_gpu_notice() {
if ((M3_GPU_PERSISTENT)); then
say "Experimental GPU profile $M3_GPU_PROFILE is selected for subsequent boots with the matched kernel, Mesa and bootloader. The retained previous entry uses asahi.t8122_start=0 and mesa_m3=off."
say "Experimental GPU profile $M3_GPU_PROFILE is selected for subsequent boots with the matched kernel, Mesa and bootloader. The retained previous entry uses aurora.t8122_start=0 (and asahi.t8122_start=0 for kernels that still build asahi.ko) and mesa_m3=off."
say "Reboot, log into your desktop, then run: aurora-m3-gpu-check"
[[ $M3_GPU_PROFILE != j613-25g83 ]] || say "25G83 native OpenGL is experimental; Vulkan hardware support is unavailable."
if m3_25_j615; then m3_25_j615_warning; fi
Expand Down Expand Up @@ -3474,8 +3474,8 @@ EOF
subvol=$(findmnt -no FSROOT /)
cmdline=$(sed -e 's/BOOT_IMAGE=[^ ]*//' /proc/cmdline)
if ((M3_GPU_PERSISTENT)); then
cmdline=$(sed -E 's/(^| )asahi\.t8122[_-]start(=[^ ]*)?//g; s/(^| )mesa_m3=[^ ]*//g' <<<"$cmdline")
cmdline+=" asahi.t8122_start=0 mesa_m3=off"
cmdline=$(sed -E 's/(^| )(asahi|aurora)\.t8122[_-]start(=[^ ]*)?//g; s/(^| )mesa_m3=[^ ]*//g' <<<"$cmdline")
cmdline+=" asahi.t8122_start=0 aurora.t8122_start=0 mesa_m3=off"
fi
if [[ $(findmnt -no FSTYPE /boot) == vfat ]]; then
linux=/vmlinuz-aurora-sep-previous initrd=/initramfs-aurora-sep-previous.img
Expand Down Expand Up @@ -7368,7 +7368,7 @@ if text.count(begin) != text.count(end) or text.count(begin) > 1:
raise SystemExit('malformed owned M3 cmdline block')
text = re.sub(re.escape(begin) + r'\n.*?' + re.escape(end) + r'\n?', '', text, flags=re.S)
if chain == 'grub':
setting = 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} asahi.t8122_start=' + armed + '"'
setting = 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} asahi.t8122_start=' + armed + ' aurora.t8122_start=' + armed + '"'
else:
# Limine reads literal assignments; it does not expand shell variables.
values = {}
Expand Down Expand Up @@ -7407,9 +7407,9 @@ else:
if not value: value = Path(sys.argv[5]).read_text().strip()
if any(c in value for c in ('"', "'", '\n', '\r', '`', '${', '$(', '+=')) or not any(w.startswith('root=') for w in value.split()):
raise SystemExit('Limine command line must contain literal root= arguments without quotes, shell expressions or += inside arguments; fix ' + str(path) + ' before retrying')
words = [w for w in value.split() if not re.match(r'asahi\.t8122[_-]start(?:=|$)', w)
words = [w for w in value.split() if not re.match(r'(?:asahi|aurora)\.t8122[_-]start(?:=|$)', w)
and not w.startswith(('mesa_m3=', 'air_gpu.oneshot=', 'BOOT_IMAGE='))]
words += ['asahi.t8122_start=' + armed]
words += ['asahi.t8122_start=' + armed, 'aurora.t8122_start=' + armed]
if armed == '0': words += ['mesa_m3=off']
setting = 'KERNEL_CMDLINE[linux-aurora]="' + ' '.join(words) + '"'
data = text.rstrip() + '\n\n' + begin + '\n' + setting + '\n' + end + '\n'
Expand Down Expand Up @@ -7502,9 +7502,11 @@ def locks(paths, timeout=30.0):
def cmdline(line, armed):
if '"' in line or "'" in line or not any(w.startswith('root=') for w in line.split()):
raise ValueError('boot command line must contain root= and have no quotes')
words = [w for w in line.split() if not re.match(r'asahi\.t8122[_-]start(?:=|$)', w)
words = [w for w in line.split() if not re.match(r'(?:asahi|aurora)\.t8122[_-]start(?:=|$)', w)
and not w.startswith('mesa_m3=') and not w.startswith('air_gpu.oneshot=')]
return ' '.join(words + ['asahi.t8122_start=' + ('1' if armed else '0')] + ([] if armed else ['mesa_m3=off']))
# aurora.ko reads aurora.*, the older asahi.ko asahi.*; each module ignores the other's key.
value = '1' if armed else '0'
return ' '.join(words + ['asahi.t8122_start=' + value, 'aurora.t8122_start=' + value] + ([] if armed else ['mesa_m3=off']))

def without_block(text):
if text.count(BEGIN) != text.count(END) or text.count(BEGIN) > 1:
Expand Down Expand Up @@ -7756,9 +7758,9 @@ lines=text.splitlines(keepends=True)
indices=[i for i,l in enumerate(lines) if re.match(r'\s*linux\s+\S*vmlinuz-aurora-sep-previous\s',l)]
if len(indices)!=1: raise SystemExit('retained GRUB entry is missing its unique previous kernel line')
i=indices[0]
line=re.sub(r'(^| )asahi\.t8122[_-]start(?:=[^ ]*)?(?= |$)',r'\1',lines[i].rstrip())
line=re.sub(r'(^| )(?:asahi|aurora)\.t8122[_-]start(?:=[^ ]*)?(?= |$)',r'\1',lines[i].rstrip())
line=re.sub(r'(^| )mesa_m3=[^ ]*',r'\1',line)
lines[i]=line+' asahi.t8122_start=0 mesa_m3=off\n'
lines[i]=line+' asahi.t8122_start=0 aurora.t8122_start=0 mesa_m3=off\n'
path.write_text(''.join(lines))
M3_GRUB_OFF
}
Expand Down
6 changes: 4 additions & 2 deletions tools/aurora-sep/m3-boot-profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ def locks(paths, timeout=30.0):
def cmdline(line, armed):
if '"' in line or "'" in line or not any(w.startswith('root=') for w in line.split()):
raise ValueError('boot command line must contain root= and have no quotes')
words = [w for w in line.split() if not re.match(r'asahi\.t8122[_-]start(?:=|$)', w)
words = [w for w in line.split() if not re.match(r'(?:asahi|aurora)\.t8122[_-]start(?:=|$)', w)
and not w.startswith('mesa_m3=') and not w.startswith('air_gpu.oneshot=')]
return ' '.join(words + ['asahi.t8122_start=' + ('1' if armed else '0')] + ([] if armed else ['mesa_m3=off']))
# aurora.ko reads aurora.*, the older asahi.ko asahi.*; each module ignores the other's key.
value = '1' if armed else '0'
return ' '.join(words + ['asahi.t8122_start=' + value, 'aurora.t8122_start=' + value] + ([] if armed else ['mesa_m3=off']))
Comment on lines +67 to +71

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Recovery still starts the GPU

The new GPU-off switches only reach newly saved fallbacks. If an older installer already retained a 7.3 kernel, retain reloads m3-known-entry.json and preserves its old asahi.t8122_start=0 command line. That kernel ignores the old key, so “Aurora previous (GPU off)” still starts the GPU after this update. Users cannot rely on that entry to recover from a GPU startup failure.

After checking ownership, update the saved command line and its matching boot entry together. Apply the same fix to the embedded helper in install-aurora-sep.sh.


def without_block(text):
if text.count(BEGIN) != text.count(END) or text.count(BEGIN) > 1:
Expand Down
20 changes: 14 additions & 6 deletions tools/aurora-sep/tests/test_air_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ def test_arm_consume_disarm(self):
self.assertIn(" protocol: efi", lines)
self.assertIn(f" path: {self.mac.path}", lines)
cmd = next(l for l in lines if l.startswith(" cmdline: "))[len(" cmdline: "):]
self.assertTrue(cmd.startswith(CMDLINE + " asahi.t8122_start=1 asahi.t8122_pstate_cap=1 "
"asahi.t8122_clkgen=e1c panic=10 air_gpu.oneshot="), cmd)
self.assertTrue(cmd.startswith(CMDLINE + " asahi.t8122_start=1 aurora.t8122_start=1 asahi.t8122_pstate_cap=1 "
"aurora.t8122_pstate_cap=1 asahi.t8122_clkgen=e1c aurora.t8122_clkgen=e1c "
"panic=10 air_gpu.oneshot="), cmd)
# The normal entry, the default and everything else stay as they were.
text = self.mac.conf.read_text()
self.assertTrue(text.startswith(before.decode().rstrip("\n")), text)
Expand Down Expand Up @@ -342,13 +343,16 @@ def test_start_alone(self):
self.oneshot("start", check=True)
cmd = re.search(r"^ cmdline: (.*)$", self.armed_block(), re.M).group(1)
self.assertEqual([w for w in cmd.split() if w.startswith("asahi.")], ["asahi.t8122_start=1"])
self.assertEqual([w for w in cmd.split() if w.startswith("aurora.")], ["aurora.t8122_start=1"])

def test_knobs_on_the_normal_cmdline_are_replaced(self):
self.mac.conf.write_text(limine_conf(self.mac.path, CMDLINE + " asahi.t8122_pstate_cap=5 asahi.m3_expose=0"))
self.mac.conf.write_text(limine_conf(self.mac.path, CMDLINE + " asahi.t8122_pstate_cap=5 asahi.m3_expose=0 aurora.t8122_pstate_cap=4"))
self.oneshot("t8122_pstate_cap=1", "m3_expose=1", check=True)
cmd = re.search(r"^ cmdline: (.*)$", self.armed_block(), re.M).group(1).split()
self.assertEqual([w for w in cmd if w.startswith("asahi.")],
["asahi.t8122_start=1", "asahi.t8122_pstate_cap=1", "asahi.m3_expose=1"])
self.assertEqual([w for w in cmd if w.startswith("aurora.")],
["aurora.t8122_start=1", "aurora.t8122_pstate_cap=1", "aurora.m3_expose=1"])

def test_check_changes_nothing(self):
before = self.mac.snapshot()
Expand All @@ -373,7 +377,7 @@ def test_test_run_on_a_kernel_without_the_knobs(self):
# A kernel without the knobs (12.0 on an M3 Pro): the boot steps can still be tested.
self.mac = FakeMac(self, board="j516s", uki_params=[b"asahi.m3_expose"])
proc = self.oneshot("--allow-test-on-m3pro", "start", check=True)
self.assertIn("has no asahi.t8122_start parameter; the test boot ignores it", proc.stdout)
self.assertIn("has no t8122_start parameter; the test boot ignores it", proc.stdout)

# Refusals: each one changes nothing

Expand Down Expand Up @@ -429,16 +433,18 @@ def test_initdata_version_bounds(self):

def test_refuses_a_knob_the_kernel_lacks(self):
self.mac = FakeMac(self, uki_params=[p for p in PARAMS if p != b"asahi.t8122_clkgen"])
self.assert_refused("has no asahi.t8122_clkgen parameter", "t8122_clkgen=none")
self.assert_refused("has no t8122_clkgen parameter", "t8122_clkgen=none")

def test_refuses_unsafe_limine_settings(self):
cases = [
("remember_last_entry: yes", lambda: self.mac.conf.write_text(
limine_conf(self.mac.path, top="remember_last_entry: yes\n"))),
("2 //linux-aurora entries", lambda: self.mac.conf.write_text(
limine_conf(self.mac.path, extra=f" //linux-aurora\n protocol: efi\n path: {self.mac.path}\n"))),
("already sets asahi.t8122_start", lambda: self.mac.conf.write_text(
("already sets t8122_start", lambda: self.mac.conf.write_text(
limine_conf(self.mac.path, CMDLINE + " asahi.t8122_start=1"))),
("already sets t8122_start", lambda: self.mac.conf.write_text(
limine_conf(self.mac.path, CMDLINE + " aurora.t8122_start=1"))),
("measures BLAKE2b", lambda: self.mac.uki.write_bytes(self.mac.uki.read_bytes() + b"x")),
("Reboot into the installed kernel first", lambda: self.mac.conf.write_text(
limine_conf(self.mac.path, kver="7.1.12-2-12.0-sep-ARCH"))),
Expand Down Expand Up @@ -733,6 +739,8 @@ def test_without_the_kernels_verdict_lines(self):
def test_not_armed(self):
self.assertEqual(self.verdict(RUNNING, cmd=CMDLINE)[0], "NOT-ARMED")
self.assertEqual(self.verdict(RUNNING, cmd=CMDLINE + " asahi.t8122_start=0")[0], "NOT-ARMED")
self.assertEqual(self.verdict(RUNNING, cmd=CMDLINE + " aurora.t8122_start=0")[0], "NOT-ARMED")
self.assertNotEqual(self.verdict(RUNNING, cmd=CMDLINE + " aurora.t8122_start=1")[0], "NOT-ARMED")


JOURNALCTL = r"""#!/bin/bash
Expand Down
Loading
Loading