Skip to content

Releases

saipan v1.1.0 - cgroup v2, and a container memory cap that actually binds

Choose a tag to compare

@tingao tingao released this 25 Sep 14:08

Two more kernels for the moto g(50) 5G (saipan, XT2149-1, MediaTek MT6833 / Dimensity 700), built for Droidspaces.

This release is about cgroups. The v1.0.0 pair kept the container on cgroup v1, and on this device that means the container has no cgroup isolation at all: its systemd writes /init.scope and /system.slice/* at the host hierarchy root, next to Android's own cgroups, so there is no single cgroup covering it and nothing can bound it. These images put the container on cgroup v2, where it gets a subtree of its own.

file size md5 what it is
boot-saipan-ksu-cgroupv2-mem.img 28,551,168 f5e522848d0432f7eac3f728691dc21e recommended - cgroup v2, with cgroup_no_v1=memory on the cmdline. What runs on my handset
boot-saipan-ksu-noprefix.img 28,551,168 6b1bccb22fe169b5ecee08693239f213 identical kernel, stock cmdline - memory stays on v1. The fallback

Both reuse the stock Motorola ramdisk and DTB unchanged, and both are smaller than the 41,943,040-byte boot partition. Flash with fastboot flash boot <file>; the boot partition is the only thing touched. Both also carry the mtk_cpufreq.level= DVFS override from v1.0.0, which does nothing unless the cmdline asks for it.

What changed since v1.0.0

The cgroup v2 device-controller backport. BPF_CGROUP_DEVICE plus the plumbing runc needs on a cgroup v2 host - the whole BPF_PROG_QUERY command, check_return_code() and the bpf_prog_array helpers. 342 lines across 12 files, ported from upstream 4.15. This is what makes --force-cgroupv1 unnecessary: runc attaches a device program and bpf_prog_query() reports it.

Droidspaces' 02.fix_restore cgroup file prefix handling patch. Android mounts the v1 cpuset hierarchy with noprefix, so /dev/cpuset exposed cpus and mems but not cpuset.cpus / cpuset.mems at all. Now both spellings exist, and cpuset.cpus reads 0-7 inside the container.

The container moves to cgroup v2, which is what actually buys the isolation described above.

Verified on hardware

vendor modules        17 of 17 load - Wi-Fi, Bluetooth, touch, fingerprint, GPS, FM, sensors
root                  KernelSU-Next, su -c id -> uid=0 context=u:r:ksu:s0
SELinux               Enforcing
Droidspaces           v6.5.5, Debian 13 trixie, systemd PID 1
cgroup                container on cgroup v2, force_cgroupv1=0
cgroup isolation      25 of 25 container processes under /sys/fs/cgroup/droidspaces/bagda
Docker in container   Engine 29.8.1, overlay2, systemd cgroup driver, hello-world rc=0
BPF_CGROUP_DEVICE     attached by runc: prog_cnt=1, attach_flags=0x2 (BPF_F_ALLOW_MULTI)
release string        4.14.186+ - byte-identical to the stock vermagic

The memory cap was tested live rather than assumed: with the container capped at 256 MB, a workload inside it was killed by the kernel (Memory cgroup out of memory: Kill process 16592 (python3) score 613) and the container carried on untouched.

If you use the recommended image

  • Set memory_limit= if you want a cap. Droidspaces delegates +memory to the container cgroup and writes memory.max. Note that a memory-only cap loses to zram here - measured, a 192 MB allocation was absorbed under a 64 MB memory.max because memory.swap.current reached 129 MB - so extras/container-memguard sets memory.max and memory.swap.max and keeps oom_score_adj at a killable value. It is optional.
  • If you move a container to v2, drop "cgroup-parent" from daemon.json. On v2 Docker selects the systemd cgroup driver and dockerd refuses to start entirely: cgroup-parent for systemd cgroup should be a valid slice named as "xxx.slice". It is unnecessary there anyway.
  • Still needs --privileged=noseccomp and the systemd drop-in replacing dockerd -H fd:// with -H unix:///var/run/docker.sock.

Known gap

CONFIG_ARM64_ERRATUM_1188873 and CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY are set in the stock config, but do not exist anywhere in the published Motorola source branch - zero hits across every Kconfig, Makefile, .c and .h, and olddefconfig on the untouched stock config drops both. The stock binary carries the ARM erratum 1188873 and Spectre-BHB strings; every kernel built from that branch carries neither. Restoring them means porting through arch/arm64/kernel/entry.S, which is documented in docs/KERNEL-NOTES.md §9 rather than quietly dropped.

saipan v1.0.0 - Droidspaces + KernelSU-Next kernel for the moto g(50) 5G

Choose a tag to compare

@tingao tingao released this 24 Sep 21:17

Two prebuilt kernels for the moto g(50) 5G (saipan, XT2149-1, MediaTek MT6833 / Dimensity 700), built for Droidspaces.

Both reuse the stock Motorola ramdisk unchanged and are smaller than the 41,943,040-byte boot partition. Flash with fastboot flash boot <file>; the boot partition is the only thing touched.

file size md5 what it is
boot-saipan-ksu-level.img 28,551,168 7c852300024f14f5b73e2f2fa8b23fda recommended - Droidspaces config, KernelSU-Next root, vendor-module CRC tolerance, plus a cmdline-selectable MTK DVFS segment
boot-saipan-ksu.img 28,549,120 6698b76d58dacb34669bfe29cd2646d4 the first build that was flashed and validated; the level override is not in this one

The second is a strict subset of the first: with no mtk_cpufreq.level= on the cmdline the level image behaves identically. It is published because it is the build that was validated first, and keeping it makes the history honest.

What was verified on hardware

vendor modules        17 of 17 load - Wi-Fi, Bluetooth, touch, fingerprint, GPS, FM, sensors
root                  KernelSU-Next, su -c id -> uid=0 context=u:r:ksu:s0
SELinux               Enforcing
Droidspaces           v6.5.5, container debian-moto, Debian 13 trixie, systemd PID 1
Docker in container   Engine 29.8.1, overlay2, cgroupfs, cgroup v1, hello-world rc=0
release string        4.14.186+ - byte-identical to the stock vermagic

Why this kernel exists

The handset's 17 prebuilt modules in /vendor/lib/modules were built by Motorola from branch android-12-release-s1rs32.38-20-7-16. The only branch published for that train is …-20-9, so building it - even with the completely unmodified shipped config - produces different symbol CRCs and check_version() rejects every module at once. Wi-Fi, Bluetooth, the touchscreen, the fingerprint reader and GPS all go away together, while the kernel still boots and looks healthy. This kernel keeps CONFIG_MODVERSIONS=y so the vermagic stays byte-identical, and turns that one CRC mismatch into a warning.

The container options Droidspaces needs are in place too, with one deliberate exception: SYSVIPC is off. IPC_NS only depends on (SYSVIPC || POSIX_MQUEUE), so POSIX_MQUEUE satisfies it, and SYSVIPC would insert fields into struct task_struct before fs/files/nsproxy/signal/sighand - shifting offsets the prebuilt vendor modules rely on. Silent memory corruption, not a clean failure.

Running Docker inside a container on 4.14

Three non-default settings are required, and Droidspaces' own troubleshooting covers two of them:

droidspaces --name=<container> start --net=nat --hw-access --privileged=noseccomp --force-cgroupv1
  • --privileged=noseccomp - on legacy kernels Droidspaces returns EPERM to namespace syscalls to avoid the 4.14 VFS deadlock, and containerd's shim needs them.
  • --force-cgroupv1 - on cgroup v2 runc must program device rules with BPF, and 4.14 has no BPF_CGROUP_DEVICE prog-query support.
  • A systemd drop-in inside the container replacing dockerd -H fd:// with -H unix:///var/run/docker.sock.

CPU clocks

The MT6833 driver carries three OPP tables selected by an efuse segment code. I made the choice switchable from the boot image cmdline and measured all three with a hardware frequency readback:

segment driver reports hardware PLL Vproc sysbench, pinned to cpu6
FY (stock) 2,203,000 kHz 2,202,000 793,750 µV 927.9 events/s
B20G 2,000,000 kHz 1,999,000 750,000 µV 841.2 events/s (−9.3 %)
B24G 2,400,000 kHz 2,202,000 837,500 µV 929.6 events/s (+0.2 %)

The 2.4 GHz table is not an overclock on this silicon: the PLL never leaves 2.202 GHz, throughput does not change, and the core voltage is 43.75 mV higher. The handset runs the stock segment.

Notes

  • Never relock the bootloader. On a Motorola MTK device that programs an efuse and can leave a phone that will not flash anything, including official firmware.
  • Tested against stock Android 12 S1RSS32.38-20-7-16 on an XT2149-1 (opencl). Other builds and variants are untested.
  • GPU acceleration from inside the container is untested on this device.
  • Full write-ups: kernel notes, CPU clocks, server setup.