Skip to content

feat(fc-kernels): build the android flavour on every stem - #3839

Draft
Davixk wants to merge 3 commits into
e2b-dev:mainfrom
Davixk:feat/fc-kernels-android-every-stem
Draft

Davixk wants to merge 3 commits into
e2b-dev:mainfrom
Davixk:feat/fc-kernels-android-every-stem

Conversation

@Davixk

@Davixk Davixk commented Nov 21, 2026

Copy link
Copy Markdown

Problem

The android flavour is a full config, configs/<arch>/6.1.158-android.config. The weekly bump neither seeds from it nor bumps it, so the flavour is stuck on 6.1.158 while the stems moved on to 6.1.190. Carrying it to a new stem by hand means copying a 3,600-line config and working out again which lines are Android's.

Change

  • A flavour is now defined once, as a fragment over a stem: flavours/<arch>/android.config holds only the lines the flavour changes in a stem's config (181 on x86_64, 117 on arm64), with a header saying how they were derived.
  • The flavour patch moves from patches/6.1.158-android/ to patches/android/ (a pure rename, content unchanged) and applies after the stem's patches on every <stem>-android build. If patches/<stem>-android/ holds patches, they replace the shared set for that one build, for a stem the shared patch no longer applies to.
  • build.sh: with CONFIG_ONLY=1 ./build.sh <stem>-<flavour> [arch], when configs/<arch>/<stem>-<flavour>.config does not exist yet but flavours/<arch>/<flavour>.config does, the config is seeded from configs/<arch>/<stem>.config with the fragment appended (Kconfig takes a symbol's last assignment, so the fragment wins). It is resolved with olddefconfig as for any version, and the build salt is set from the tag. It fails without writing anything if any fragment line did not survive. A symbol the resolved config leaves out counts as n, the same way Kconfig reads it. An existing flavoured config is re-settled as before and checked against the fragment again. A normal build still reads the committed resolved config, so what ships is what was reviewed.
  • scripts/flavour_fragment.py derives a fragment from a flavoured config and its seed. The same module provides the survival check the tests use.
  • scripts/test_flavours.py: every committed <stem>-<flavour>.config keeps every line of its fragment; every pin in kernel_versions.txt has a config on both arches; unit tests for the derivation and the survival rule. test_ipvs_config.py now skips pins with no config on an arch, so a missing config fails once, in test_flavours.py, instead of raising FileNotFoundError in every IPVS test.
  • 6.1.190-android is pinned, and configs/x86_64/6.1.190-android.config is produced by the new CONFIG_ONLY path.
  • README "Flavours" describes the fragment mechanism and how the bump adds <new stem>-android (pin it, seed it with CONFIG_ONLY=1 on each arch).

6.1.158-android builds exactly as before: its committed config is unchanged and still read as is, the stem patches apply first, then the same memfd patch byte for byte (100% rename), in the same order.

How the fragments were derived

A fragment is every symbol whose value differs between the config the flavour was seeded from and the flavour's resolved config, with the flavour's value. A symbol a config leaves out counts as n. Toolchain probes (CC_*, AS_*, LD_*, GCC_*, CLANG_*, LLD_*, PAHOLE_*, RUSTC_*) and BUILD_SALT are left out, because every stem's config carries its own.

  • x86_64: seed configs/x86_64/6.1.177.config at e7b859b (the parent of 1ee3def, which added the flavour; at that commit 6.1.177 and 6.1.182 differ only in BUILD_SALT), flavour configs/x86_64/6.1.158-android.config at origin/main. 181 lines: binder, binderfs, DMA-BUF heaps, PSI on by default, BPF JIT, MEMFD_ASHMEM_COMPAT, Android netfilter/xfrm/crypto options, EROFS/F2FS, RTC, modules on (signed, forced), kexec off.
  • arm64: seed configs/arm64/6.1.158.config at the same commit, flavour configs/arm64/6.1.158-android.config at origin/main. 120 lines, of which three are dead on 6.1 and were dropped (see below), leaving 117. The arm64 flavour was evidently seeded from arm64 6.1.158, not 6.1.177. A 6.1.177 seed yields 175 lines, a strict superset, and the 55 extra lines are exactly what the 6.1.177 bump changed on arm64: tracing off, DEBUG_INFO off, ARM64_ERRATUM_3194386/4118414 off, and others. Those are not Android's, and applying them to new stems would turn off CPU errata workarounds and debug info.

To reproduce: python3 scripts/flavour_fragment.py <(git show e7b859b30b60:firecracker/fc-kernels/configs/<arch>/<seed>.config) configs/<arch>/6.1.158-android.config.

What was verified

  • CONFIG_ONLY=1 ./build.sh 6.1.190-android x86_64 ran as root in buildpack-deps:noble (the toolchain the committed configs record, gcc 13.3.0 Ubuntu 24.04). It seeded from configs/x86_64/6.1.190.config plus the fragment, checked out kernel-6.1.190-237.442.amzn2023, applied the four 6.1.190 patches and then patches/android/0001-memfd-answer-ashmem-ioctls.patch cleanly, set the salt to 6.1.190-android-amzn2023.x86_64, and every one of the 181 fragment lines survived olddefconfig.
  • Resolved config configs/x86_64/6.1.190-android.config: 3622 lines, sha256 4944722c69f679c9bdca75fad74cd94b81e462557db256baeac0c45b840d9127. Compared with the 6.1.190 stem config, it differs in 179 symbols: 178 are fragment lines (3 fragment lines already match the stem, for example # CONFIG_KEXEC_FILE is not set), and one is outside the fragment, CONFIG_MODULE_SIG_ALL=y (see open items).
  • Both fragments survive on their own source configs (6.1.158-android, x86_64 and arm64), checked by the new test.
  • Resolved config configs/arm64/6.1.190-android.config, sha256 45503b167de38946931ab32c8c2d57eadf54d25e37d0f24a98335862551f23ce, resolved natively on arm64 (buildpack-deps:noble, CONFIG_ONLY=1 ./build.sh 6.1.190-android arm64). The arm64 fragment drops three lines no 6.1 tree can keep: CONFIG_IPV6_PRIVACY (removed upstream), CONFIG_MEMCG_SWAP (dropped in 6.1; swap accounting follows SWAP and MEMCG) and CONFIG_NFT_COUNTER (built into nf_tables). The arm64 6.1.158-android config carries them as dead lines; the x86_64 fragment never had them.
  • python3 -m pytest firecracker/fc-kernels/scripts -q: 69 passed.

Open items for maintainers

  • CONFIG_MODULE_SIG_ALL: it is # ... is not set in 6.1.158-android, but the seed never showed the symbol (modules were off there), so the value-difference rule does not put it in the fragment. On 6.1.190 it resolves to y, the Kconfig default once modules are on. It only makes modules_install sign modules and does not change the vmlinux. The same gap applies to 64 x86_64 and 4 arm64 symbols that only the flavour exposes, all left at their default n in 6.1.158-android. Only MODULE_SIG_ALL resolves differently on 6.1.190. If maintainers want the flavour to pin those answers too, change the rule to also count a symbol the flavour shows as not set and the seed does not show, then regenerate.
  • The weekly bump lives outside this repo. Per the README it should add <new stem>-android next to each new stem and seed it with CONFIG_ONLY=1 per arch. That automation is not part of this change.

Test evidence

OS1 built E2B's 6.1.158-android flavour lines (same fragment logic) plus the flavour patch on stem vmlinux-6.1.177_5008931 and booted it on a self-hosted E2B host. binder protocol 8; binderfs devices binder, hwbinder, vndbinder and binder-control; BINDER_CTL_ADD works; memfd with F_SEAL_FUTURE_WRITE; ASHMEM_GET_SIZE on a memfd returns the size; /proc/pressure present; bpf_jit_enable=1; /dev/dma_heap/system present. Pause and resume kept a process's binder fd and memfd. The guest uses about +9 MiB RAM vs stock.

🤖 Generated with Claude Code

Davixk and others added 3 commits November 21, 2026 18:53
flavours/<arch>/android.config holds the lines the android flavour changes in a
stem's config, and patches/android/ the patch it carries on every stem.
CONFIG_ONLY=1 seeds a missing <stem>-android config from the stem's config plus
the fragment and fails unless every fragment line survives olddefconfig. A build
still reads the committed resolved config, and 6.1.158-android resolves and
applies exactly as before.
Seeded with CONFIG_ONLY=1 ./build.sh 6.1.190-android on x86_64; every line of
flavours/x86_64/android.config survived. arm64 still needs resolving on an arm64
machine.
Resolved natively on arm64 (buildpack-deps:noble, CONFIG_ONLY=1). The arm64
fragment drops three lines no 6.1 tree can keep: CONFIG_IPV6_PRIVACY (removed
upstream), CONFIG_MEMCG_SWAP (dropped in 6.1, swap accounting follows SWAP and
MEMCG) and CONFIG_NFT_COUNTER (built into nf_tables). The x86_64 fragment never
carried them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AtipGDi8uiAr2rwfSnqLQF
@cla-bot

cla-bot Bot commented Nov 21, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @Davixk on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check'

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant