Skip to content

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 CommandSource Module (gki_porting_sdk/tools/)Purpose
gki-abi-gateabi-gate.pyVerifies zero symbol CRC drift (__versions & Linux 6.18+ EXTENDED_MODVERSIONS) between vendor .ko trees and custom vmlinux.symvers.
gki-kcfi-ko-gatekcfi-ko-gate.pyEnforces ARM64 .ko structural invariants: zero GOT (311/312) relocations, exact .gnu.linkonce.this_module size, and optional __kcfi_typeid_* cross-check.
gki-kmi-checkkmi-check.pyAudits GKI KMI symbol list coverage (abi_gki_aarch64*) against custom kernel exports.
gki-btf-diffbtf-diff.pyCompares .BTF struct layouts and function prototypes between stock Image and custom vmlinux.
gki-module-inventorymodule-inventory.pyComputes vendor .ko dependency DAGs, topological load groups, and minimal dependency closures for specified modules.
gki-export-mod-symversexport-mod-symvers.pyExtracts standard Module.symvers tables from a directory of .ko binaries without running modpost.
gki-fdtdifffdtdiff.pyStructural node, property, and overlay __fixups__ diff engine for .dtb and .dtbo blobs.
gki-mkdtboimgmkdtboimg.pyBit-exact Android dt_table_header dtbo.img packer.
gki-dtbo-extractdtbo-extract.pyInspects and extracts individual .dtbo entries (id, rev, flags) from dtbo.img.
KoElf (Python API)_elfmod.pyPure-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.json
bash
# 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.md
bash
# 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=0

4. Running Tests ​

bash
python3 -m unittest discover -s tests -v
python3 scripts/check_hygiene.py

Independent Open-Source Community (CC-BY-4.0). Not affiliated with Huawei, HiSilicon, OpenAtom Foundation, Xiaomi, Qualcomm, MediaTek, or Arm.