GKI 6.x Kernel Verification SDK (UniOHOS/gki-sdk)
UniOHOS/gki-sdk (MIT, Python >= 3.9, zero third-party dependencies) verifies Android GKI 6.6 / 6.18 kernel ABI, KMI symbol coverage, KCFI/GOT module invariants, BTF struct layouts, module load closures, and DeviceTree overlays completely offline before flashing.
1. Installation
bash
git clone https://github.com/UniOHOS/gki-sdk.git
cd gki-sdk
pip install -e .2. Tool Catalog (9 CLI Tools + _elfmod.py Library)
| CLI Command | Source Module (gki_porting_sdk/tools/) | Purpose |
|---|---|---|
gki-abi-gate | abi-gate.py | Verifies zero symbol CRC drift (__versions & Linux 6.18+ EXTENDED_MODVERSIONS) between vendor .ko trees and custom vmlinux.symvers. |
gki-kcfi-ko-gate | kcfi-ko-gate.py | Enforces ARM64 .ko structural invariants: zero GOT (311/312) relocations, exact .gnu.linkonce.this_module size, and optional __kcfi_typeid_* cross-check. |
gki-kmi-check | kmi-check.py | Audits GKI KMI symbol list coverage (abi_gki_aarch64*) against custom kernel exports. |
gki-btf-diff | btf-diff.py | Compares .BTF struct layouts and function prototypes between stock Image and custom vmlinux. |
gki-module-inventory | module-inventory.py | Computes vendor .ko dependency DAGs, topological load groups, and minimal dependency closures for specified modules. |
gki-export-mod-symvers | export-mod-symvers.py | Extracts standard Module.symvers tables from a directory of .ko binaries without running modpost. |
gki-fdtdiff | fdtdiff.py | Structural node, property, and overlay __fixups__ diff engine for .dtb and .dtbo blobs. |
gki-mkdtboimg | mkdtboimg.py | Bit-exact Android dt_table_header dtbo.img packer. |
gki-dtbo-extract | dtbo-extract.py | Inspects and extracts individual .dtbo entries (id, rev, flags) from dtbo.img. |
KoElf (Python API) | _elfmod.py | Pure-Python ELF64 .ko parser shared across all ABI/KCFI/module tools. |
3. Verified Command Examples
bash
# 1. Check zero CRC drift across vendor_boot and vendor_dlkm modules
gki-abi-gate --our-symvers out/vmlinux.symvers --moddir vendor_boot=work/vendor_boot_mods --moddir vendor_dlkm=work/vendor_dlkm_mods --json out/abi-gate.json --out out/abi-gate.md
# 2. Verify custom out-of-tree .ko modules (zero GOT 311/312, exact this_module size)
gki-kcfi-ko-gate --dir out/kmod --expect-this-module-size 0x680 --vmlinux out/vmlinux --json out/kcfi-gate.jsonbash
# Compare BTF struct layouts between stock Image and custom vmlinux
gki-btf-diff --a work/Image.stock --b out/vmlinux
# Audit KMI symbol coverage
gki-kmi-check --stock-symvers work/stock.symvers --vmlinux out/vmlinux --our-symvers out/vmlinux.symvers
# Extract standard Module.symvers directly from a directory of .ko modules
gki-export-mod-symvers --moddir vendor_boot=work/vendor_boot_mods --out out/vendor-modules.symvers
# Compute dependency closure for early-boot modules
gki-module-inventory --kernel-symvers out/Module.symvers --tree vendor_boot:work/vendor_boot_mods --closure xring_wdt.ko,xring_ufs.ko --closure-out out/early-closure.mdbash
# Inspect or extract entries from a stock dtbo.img
gki-dtbo-extract --img work/dtbo.img --info
gki-dtbo-extract --img work/dtbo.img --out work/dtbo_extracted
# Structural diff between stock and rebuilt overlay .dtbo
gki-fdtdiff work/stock.dtbo out/rebuilt.dtbo --overlay --json out/fdt-diff.json
# Pack bit-exact dtbo.img (comma-separated key=value overrides after ':')
gki-mkdtboimg --out out/dtbo.img --entry out/board.dtbo:id=0x090f0000,rev=04. Running Tests
bash
python3 -m unittest discover -s tests -v
python3 scripts/check_hygiene.py