Files
DroidDeck/tools/components
LunaDLandKurt Himebauch 88d44b0dc6 Feat: Improve ARMv8.0 Steam compatibility with LSE emulation (#3720)
* feat: emulate LSE atomics so the Steam client starts on ARMv8.0 CPUs

* fix: keep NZCV across patched LSE min/max stubs and catch st* aliases

* fix: fail the LSE check when objdump fails

* fix: validate the CASP pair on a mismatch in the LSE emulator

* fix: sandboxes switch on the LSE emulator when it is preloaded

* fix: keep the MaliBridge pointer from main

* Handle LSE atomics before preload constructors

* Support early LSE handling in root guest processes

* Fix LSE-Emu signal and patching review findings

* Assert CASP and min/max sites use patched stubs

* Correct patch test statistics regexes

* Validate SIGILL syscall ABI and retain active state on restore failure

* Preserve the previous SIGILL disposition during early install

* Synchronize instruction fetch on generated LSE stubs

* Address LSE-Emu follow-up review findings

* Fix missing LSE signal handler state declarations

* Honor application signal mask when forwarding SIGILL

* Preserve SA_RESETHAND mask during handler forwarding

* Fix LSE opt-out after early handler install

* Avoid recursive SIGILL forwarding during LSE emulation

* Fix LSE SIGILL handler re-entry tracking

* Honor SA_NODEFER in forwarded SIGILL mask

* Preserve nested SIGILL delivery semantics

* Preserve explicit SIGILL mask with SA_NODEFER

* Reduce LSE patch contention across threads

* Guard nested faults before acquiring patch lock

* Fix early SIGILL restore and wake patch waiters

* Preserve libc restorer when restoring application SIGILL

* Wait for concurrent LSE patch instead of skipping

* Fix LSE patch lock release and fork recovery

* Avoid reinstalling the early SIGILL handler

* chore: retrigger CI

* Avoid proc maps reads in concurrent SIGILL patching

* Prevent late IFUNC handler install when emulation is disabled

* Clarify cached mapping lookup

* Move cached map declarations before find_gap

* Default LSE instruction patching to off

* Document conservative LSE emulation default

* Keep LSE instruction patching opt-in in sandbox preload

* Document default and opt-in LSE emulation checks

* Assert LSE patching remains opt-in in sandbox tests

* Align LSE device checks with SDK 34 patching behavior

* Check expected mprotect failures in opt-in device run

* Clarify LSE emulator device validation criteria

* Specify controlled SDK mprotect validation

* fix(lse-emu): publish SIGILL actions atomically

* fix(runtime): honor LSE_EMU=0 before preload

* test(runtime): keep LSE preload disabled when opted out

* fix(runtime): fully honor LSE_EMU=0 opt-out

* test(runtime): verify LSE opt-out removes inherited preload

* fix(runtime): filter inherited LSE preload without preload file

* fix(lse-emu): use bounded signal-safe action snapshots

* fix(runtime): split inherited preloads on spaces and colons

* test(runtime): cover both LSE preload entry orders

* fix(lse-emu): recycle displaced SIGILL snapshots

* fix(preload): preserve colliding path cache entries

* test(lse-emu): report patch failure details

* fix(lse-emu): serialize action snapshot publishers

* fix(lse-emu): fall back to reachable arena mapping

* fix(lse-emu): make signal action publication nonblocking

* refactor(lse-emu): remove obsolete publisher lock

* Fix SIGILL snapshot retirement and honor session LSE opt-out

* Preserve the Java staging API and isolate the SIGILL stress test

* fix(nativeguest): filter LSE preload when disabled

* fix(lse-emu): tighten seccomp and signal setup

* fix(session): preserve active LSE override while staging

* fix(lse-emu): return atomically displaced signal actions

* fix(lse-emu): stage raw signal masks safely

* fix(lse-emu): distinguish seccomp listener success

* fix(lse-emu): publish seccomp veto atomically

* fix(lse-emu): fail closed on RX restore errors

* fix(lse-emu): keep stack-using atomic stubs on trap path

* fix(lse-emu): allow patching with inherited seccomp

* test(lse-emu): cover LDAPR patch path

* test(lse-emu): assert LDAPR-only patching

* fix(nativeguest): filter disabled LSE from preload chains

* docs(lse-emu): define inherited seccomp patch policy

* fix(lse-emu): emulate LDAPR trap fallback

* refactor(lse-emu): remove unused seccomp query

* fix(nativeguest): release filtered preload chain in scope

* test(lse-emu): allow forwarded udf diagnostic

* fix(nativeguest): avoid unsafe preload fallback when disabled

* test(lse-emu): match full zero instruction field

* test(lse-emu): match complete instruction diagnostics

* Keep nested native preloads from duplicating host libraries

* fix(nativeguest): fail exec when disabled preload cannot map

* fix(nativeguest): stop exec when preload mapping fails

* fix(nativeguest): propagate preload filter allocation failures

* Consume only the selected one-shot SIGILL action

* Reclaim abandoned SIGILL action slots after fork

* Revalidate the live file mapping before optional LSE patching

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-12-05 19:09:28 -05:00
..

Runtime component preparation

recipes.json owns component source inputs, builders, outputs, package requirements and pinned downloads. prepare.py runs those recipes, calculates cache identities, installs the union of missing tools and verifies the prepared artifact handoff. Builders live in recipes/; the workflow describes scheduling and gates.

flowchart LR
    Source[Pin source tree] --> Components[Prepare verified components]
    Source --> Xbox[Xbox ARM64 backend]
    Source --> Tests[Python and native tests]
    Components --> APK[Compile APK]
    Xbox --> APK
    APK --> Gate[Compile and test APK gate]
    Tests --> Gate
    Gate --> Publish[Main only: signing and publishing]

Kotlin unit tests run in the separate Unit tests workflow (unit-tests.yml), so a PR test build is published as soon as the APK compiles. Build validation folds both workflows into the Build APK commit status, and Release APKs requires both for the released commit.

All workers verify the same source tree. The component artifact records that tree, recipe identities and every output hash; the APK worker verifies the inventory before building. This handoff verifies consistency within the same CI run. It is not independent provenance for arbitrary artifacts. Source policy checks, tests, APK content/ABI checks and signing/publication gates remain in place.

tools/ci/toolchains.env pins the Android NDK shared by component, APK and native test workers. Linux builds use Ubuntu 24.04. Recipe and input changes invalidate the relevant component cache; ordinary caches remain performance aids.

Verified preload snapshots

preloads.lock.json pins a small immutable preload archive. It records each binary's hash, its producing main CI run, the original APK artifact identity and digest, source/header hashes, the ARM64 build recipe and x86 compiler-image inputs. It covers core ARM64 preloads and the x86 preload libraries. VR, Android native libraries, Comet and Xbox use their registered recipes and existing release pins or component caches.

Every build compares current source inputs, including transitive quoted headers, and build recipes with this manifest. Changed groups rebuild from source. A missing release also selects a rebuild. Corrupt archives, unexpected files and binary hash mismatches fail the build. Existing preload checks, runtime packaging checks and all test jobs still run.

The trust anchor is the manifest in the pinned main base. A new or changed PR manifest is independently checked against a successful push build of main: GitHub must confirm the run/source/workflow and original APK artifact digest, and every claimed binary must match that APK. The claimed source inputs and recipe must match that run's Git source. A PR cannot establish trust by changing both a binary and its claimed checksum. This is approved-build reuse, not a claim of bit-for-bit reproducible compilation or a signed SLSA attestation.

To refresh after source or compiler changes:

  1. Let a main build compile and test the new inputs.
  2. Run python tools/components/preloads.py snapshot --run RUN_ID.
  3. Publish app/build/component-snapshot/preloads.tar.gz to DroidDeck-Components as preloads-<full archive SHA-256>, without replacing an existing release. Include the manifest and producing run in the release notes.
  4. Review and commit the updated manifest. CI independently checks its origin.

The workflow dispatch rebuild_preloads option forces source compilation even when an approved snapshot matches. Use it when refreshing a compiler or system header revision. Runner image updates do not silently replace an approved binary; the producing run remains the record of its compiler environment.