Repository navigation
Conversation
A SoC opts into the shim board hooks (shim/soc_hooks.h, next commit) with "shim_hooks": true in its soc.json. boards.py then emits `#define SOC_SHIM_HOOKS 1` into board_config.h, after the SOC_* family macros, and `--get shim_hooks` prints 1 (else 0) for shim/build.sh. The key is refused in a board.json and when it is not a JSON boolean. No SoC sets it, so every generated header is unchanged (bluejay's board_config.h compared byte for byte). Test: tools/test_boards_shim_hooks.py (trunk headers carry no macro; a copied tree without the key renders identical headers; opting gs101 in adds exactly one line; false == absent; non-bool and board.json values refused, also through the CLI). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shim/soc_hooks.h declares the points where the shared flow hands over to SoC code, with the rules for them (read-only unless audited, bounded waits, no hook on the stop path): soc_hook_entry (top of the probe, may ask for the USB live log early), soc_hook_video / soc_hook_console (around con_set_video), soc_hook_pstore_fallback (pstore_init found no zone), soc_hook_probes (after checkpoint 1), soc_hook_pre_xnu (first step of --boot-xnu), and in the loader soc_hook_payload, soc_hook_bootflags, soc_hook_before_jump. The loader ones are SOC_HOOK_* macros that expand to the replaced code without hooks and sit on existing lines, so loader.c keeps its line numbers (SHIM_ASSERT __LINE__). Every call site is under `#if SOC_SHIM_HOOKS`, a capability flag from tools/boards.py (soc.json "shim_hooks"), never a SoC name. The probe flow (bluejay_probe, try_write32, the exception skip) now builds for SHIM_PROBE = SOC_GS101 || SOC_SHIM_HOOKS, identical to SOC_GS101 on gs101; its gs101-only steps keep SOC_GS101 guards (DECON re-arm, PMU CPU prep; REBOOT_BL is an #error elsewhere) and reset()/shim_halt() take a PSCI-only branch on a hook SoC instead of sweet's Qualcomm words. build.sh compiles and links soc/<vendor>/<soc>/shim/soc_hooks.c only when `boards.py --get shim_hooks` is 1 (also in the ABS64 list), and its host-test block compiles shim.c/loader.c for a non-gs101 hook SoC into $O/hookcheck and checks every always-built hook is referenced, because no SoC on trunk sets the key. Inert on trunk: bluejay objects, shim.elf and Image are byte-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
First shared-code PR of the cheetah (Pixel 7 Pro, gs201) split agreed in #3 (step A2). It adds the points where the shared shim
flow hands over to SoC code, and nothing that uses them: no SoC on
mainopts in, so the bluejay build is unchanged(proof below).
What changed
Opt-in (
tools/boards.py): a SoC sets"shim_hooks": trueinsoc/<vendor>/<soc>/soc.json. Only then is#define SOC_SHIM_HOOKS 1emitted intoboard_config.h(after theSOC_*family macros) andboards.py BOARD --get shim_hooksprints 1 (else 0). The key is refused in aboard.jsonand when it is not a JSONboolean.
shim/soc_hooks.h: the hook API with its rules (read-only unless audited, bounded waits, no hook on the stoppath) and when each hook runs. Hooks, each derived from a gs201 call site on the reference branch:
soc_hook_entry(dtb)->SOC_ENTRY_USB_EARLYbluejay_probesoc_hook_video(&video)con_set_videosoc_hook_console(&video)FBlinesoc_hook_pstore_fallback()pstore_init(dtb)found no zonesoc_hook_probes()soc_hook_pre_xnu()--boot-xnusoc_hook_payload,soc_hook_bootflags,soc_hook_before_jumploader_boot()Call sites (
shim/shim.c): all under#if SOC_SHIM_HOOKS, a capability flag, not a SoC name. The loader hooksare
SOC_HOOK_*macros (included throughloader.h) that expand to exactly the replaced code without hooks and siton existing lines, so
loader.ckeeps its line numbers.Probe flow widened by capability: the probe section,
try_write32and the exception-handler fault skip nowbuild for
SHIM_PROBE = SOC_GS101 || SOC_SHIM_HOOKS(on gs101 that is 1, asSOC_GS101was). The gs101-only stepsinside keep
SOC_GS101guards (DECON re-arm, PMU CPU prep),REBOOT_BLis an#erroron any other SoC, andreset()/shim_halt()take a PSCI-only branch on a hook SoC instead of sweet's Qualcomm restart words.shim/build.sh: compiles and linkssoc/<vendor>/<soc>/shim/soc_hooks.conly when--get shim_hooksis 1(also in the ABS64 relocation check). Because no SoC sets the key, the host-test block also compiles shim.c and
loader.c for a non-gs101 hook SoC (this board's header with
SOC_GS101 0+SOC_SHIM_HOOKS 1, into$O/hookcheck/) and checks that every always-built hook is referenced, so the hook code cannot rot unbuilt.Not in this PR (listed per file in a classification, available on request): every gs201 body (goes to
soc/google/gs201/shim/soc_hooks.cin the board PRs), and the generic changes the reference branch carries that areuseful to all boards but change bluejay bytes (console no-framebuffer guard,
pstore_init_fixed, USB log drain beforethe jump,
SCTLR_EL1reset instart.S,WDT_ARMED,PANEL_QUIET/BOOT_LOGO, Wi-Fi header fixes). Those come asseparate PRs with their own proof. The type/style pass is dropped as asked.
Hardware evidence
Not tested on hardware: no bluejay byte changes and no SoC uses the hooks yet.
Bluejay (Pixel 6a) impact
Shared code changed; the bluejay build is unchanged (observed, build host, 2026-12-03).
Method: two worktrees at the same HEAD
b5baf08(so both embed build idb5baf08): cleanorigin/main, andorigin/main+ this PR's diff uncommitted.tools/pix build bluejayin each, thensha256sumof every object thebuild compiles,
shim.elf,Image,Image.lz4,shim-boot.img,shim-boot-lz4.img,ramdisk.bin,board_config.h,wlan_seq.h. Second pair: same with__LINE__replaced by0inSHIM_ASSERT(
shim/shim_assert.h). Script:a2-compare.sh(at the end of this description).shim.elf,Image,Image.lz4,board_config.h,wlan_seq.hidentical;ramdisk.binand the two boot images differ__LINE__= 0ramdisk.binand the two boot imagesThe
ramdisk.bindifference is not this PR:build.shpacks an empty placeholder directory withfind . \| cpio \| gzip, so the cpio header carries that directory's inode and mtime and the gzip header atimestamp; two builds of the same
maintree differ the same way. Re-packing both trees'Image/Image.lz4with onefixed ramdisk and
build.sh's exactmkbootimgarguments gives identical boot images in both pairs(
fixedrd-*rows). Because the normal pair is already identical, no object of the default build depends on ashifted
__LINE__:loader.ckeeps its line numbers, andshim.c's onlySHIM_ASSERT(line 65 -> 66, below the new#include) is compiled only with--touch-probe=dvfs, which this comparison does not build.Key hashes (normal pair; the same value in the main and the PR build; full lists for all four builds on request):
__LINE__ = 0pair, same in both:shim.elf093d50e9460f6fbe...,Image3e95b69e155fbf5a...,fixedrd-shim-boot.img98a89847f82d1571... (these differ from the normal pair, so the neutralised builds were fresh).The
__LINE__ = 0builds end withFAIL shim_assert_host_test(it checks the real line number); that is expectedand happens on
maintoo; the images are linked before the host tests run.Tests and gate
tools/test_boards_shim_hooks.py(new, 6 tests): trunk headers carry no macro and--getprints 0; a copied treewithout the key renders identical headers for every board; opting gs101 in adds exactly one line after the
SOC_*macros (other SoCs untouched) and
--getprints 1;falseequals absent; non-boolean values and aboard.jsonkeyare refused, also through the CLI.
shim/build.shhost-test block:soc_hooks call sites (shim.c, hook SoC),(loader.c, hook SoC),soc_hooks call sites reference every always-built hook: PASS.tools/lint-c --style --base origin/main:RESULT: PASS style new=0 baseline=1468..github/scripts/pr_rules.py --profile kernel origin/main HEAD:RESULT: PASS 7 files, 0 rule(s) failed(on the final head).tools/check-all.shon this head (observed, build host, 2026-12-04; run withLINT_STYLE_BASE=origin/main GATE_JOBS=2 GATE_STEP_TIMEOUT=2400 --keep-going):GATE FAIL 8751e11 unit failed: test_devd_mutants.py, test_safety_xrun.py, test_adversary_matrix.py +22 more.Every other step passes (all 12 build variants, host-tests, boot-safety, validate, rules, public-guard, shellcheck,
lint-c, xnu-build, stack-apply, mutant-needles, boot-markers, lint-silent, consumed, inputs, wlan-mutants), and
test_boards_shim_hooks.pypasses in its shard. Why the knobs: this host's localmainbranch is 346 commitsbehind
origin/main, so the style ratchet's default base counts every function changed since then(
style new=238,validatefails the same way on a cleanorigin/maincheckout); with the default 6 parallelbuilds the build steps hit the 900 s step timeout on this machine.
No
GATE PASSon this host. Per your rule in Pixel 7 Pro (cheetah, gs201) port: split plan for #2 and pixelios-userland#1 #3, here is every failure: the unit step counts 26 = 14 failingfiles + 11 skips not pinned in
tools/unit-skip-allow.txt(4 files) + 1COUNT MISMATCH(2382 collected vs 2377run: the 5 tests of
test_safety_xrun.py, whosesetUpClasserrors). Each failing file, run standalone onorigin/mainand on this head, gives the same result on both:tools/triage-settle-guardtools/wake/ wake hook heretest_usbroot_hostenvironmentgit rev-parseoutside a repo in its temp dirsunshare -r -n -mnot permittedtest_guard_refuses_a_root_image_file: this host's "standard root image" (newest line offlashed-userdata.txt) is a cheetah root without/usr/local/bin/wifid-probe; reproduced on a cleanorigin/mainworktreeNone of these files or the code they test is touched by this PR. A
GATE PASSfrom a machine with the full environmentwould still be welcome.
Hardware: none. This PR changes no bluejay byte, and no SoC uses the hooks yet; nothing was run on a phone.
Size: 7 files, +347 / -19 lines (of which 135 test, 89 the documented header).
Safety checklist
userdata; no new UFS write path in the shimtools/check-all.shprintsGATE PASS(not on this host: only the unit step fails, every failure listed above and the same onmain)xnu/patches/untouched; changes come as new numbered patches (no patch touched)tools/test-bluejay-boot.pynot edited)shim_hookscapability; bluejay proof above)a2-compare.sh
🤖 Generated with Claude Code