From cf72a6dcbcde309fd838a04114b961ef11aa16b1 Mon Sep 17 00:00:00 2001 From: Noah Date: Fri, 9 Oct 2026 19:17:57 -0600 Subject: [PATCH] kernel: make KCONFIG_SHA256 independent of the host python (bfe-core1106-sdk#19) DRM_MSM_VALIDATE_XML depended on `$(PYTHON3) -c "import lxml"`, so the expanded .config gained a line on hosts where python3 could import lxml and the whole-file digest differed (the flashed image ec276f77 against e8e9ef1c from a config-only run on the same tree). Drop the unused Qualcomm symbol with a one-block Kconfig patch; the digest is now ec276f77 everywhere and equals the flashed one. Regression test: tests/required-symbols/run-config-determinism-tests.sh runs the config-only expansion with a python3 whose import lxml works and one where it fails and requires the same digest; it is proven red on a copy of the tree without the patch. The kernel-symbols CI job runs it. Fixes #19. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01Cxh2piVufTWbzKTmUafTkk --- .github/workflows/ci.yml | 6 ++ patches/90-kconfig-no-python-symbol.patch | 25 ++++++++ patches/README.md | 1 + .../run-config-determinism-tests.sh | 62 +++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 patches/90-kconfig-no-python-symbol.patch create mode 100755 tests/required-symbols/run-config-determinism-tests.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d14239b..6bfeb16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -255,6 +255,12 @@ jobs: export KERNEL_TARBALL="$HOME/linux-6.18.46.tar.xz" bash build/build-kernel.sh cmp "${{ runner.temp }}/final.config" "$CONFIG_OUT" + - name: the digest does not depend on the host python (issue #19) + env: + CROSS_COMPILE: arm-linux-gnueabihf- + run: | + export KERNEL_TARBALL="$HOME/linux-6.18.46.tar.xz" + bash tests/required-symbols/run-config-determinism-tests.sh patches-apply: # The RV1106 series must apply cleanly onto pristine linux-6.18.46. diff --git a/patches/90-kconfig-no-python-symbol.patch b/patches/90-kconfig-no-python-symbol.patch new file mode 100644 index 0000000..5fcd07c --- /dev/null +++ b/patches/90-kconfig-no-python-symbol.patch @@ -0,0 +1,25 @@ +Remove the DRM_MSM_VALIDATE_XML Kconfig symbol (rebuild M0, bfe-core1106-sdk#19). + +Its dependency $(success,$(PYTHON3) -c "import lxml") makes the expanded .config differ by host: with +python3-lxml importable the file gains '# CONFIG_DRM_MSM_VALIDATE_XML is not set', without it the line is +absent, so KCONFIG_SHA256 was not reproducible across hosts. The symbol only validates Qualcomm GPU register +XML for DRM MSM developers; the panel has no Qualcomm GPU. No binary changes. + +diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig +--- a/drivers/gpu/drm/msm/Kconfig ++++ b/drivers/gpu/drm/msm/Kconfig +@@ -50,14 +50,6 @@ + Only use this if you are a driver developer. This should *not* + be enabled for production kernels. If unsure, say N. + +-config DRM_MSM_VALIDATE_XML +- bool "Validate XML register files against schema" +- depends on DRM_MSM && EXPERT +- depends on $(success,$(PYTHON3) -c "import lxml") +- help +- Validate XML files with register definitions against rules-fd schema. +- This option is mostly targeting DRM MSM developers. If unsure, say N. +- + config DRM_MSM_KMS + def_bool n + depends on DRM_MSM diff --git a/patches/README.md b/patches/README.md index 41dcb04..632f9a0 100644 --- a/patches/README.md +++ b/patches/README.md @@ -28,6 +28,7 @@ with `../build/warden_defconfig` -> `zImage` + `rv1106-warden.dtb`). | `60-wifi-aic8800.patch` | out-of-tree AIC8800 wifi/BT (the 88.5K-line vendor blob) | | `70-audio-codec.patch` | `rv1106_codec` + I2S wiring | | `80-misc-thermal-rtc-adc.patch` | tsadc, rtc-rockchip, saradc, trng, otp, gmac, goodix touch | +| `90-kconfig-no-python-symbol.patch` | drops `DRM_MSM_VALIDATE_XML` so the expanded `.config` (and `KCONFIG_SHA256`) does not depend on the host python (#19) | ## License diff --git a/tests/required-symbols/run-config-determinism-tests.sh b/tests/required-symbols/run-config-determinism-tests.sh new file mode 100755 index 0000000..1b8e58e --- /dev/null +++ b/tests/required-symbols/run-config-determinism-tests.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# The final kernel .config, and so KCONFIG_SHA256, must not depend on the host's python (issue #19): +# DRM_MSM_VALIDATE_XML used to be visible only where python3 could import lxml, adding one line to the +# file. Runs the config-only expansion twice, once with a python3 whose `import lxml` works and once with +# one where it fails, and requires the same digest. Proven red on a copy of the tree without +# patches/90-kconfig-no-python-symbol.patch (when this host's python3 has lxml; otherwise the red case +# is skipped with a notice). Needs the pinned kernel tarball: KERNEL_TARBALL=, or skipped. +set -uo pipefail +HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO="$(cd "$HERE/../.." && pwd)" +TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT +FAIL=0 +ok() { printf '[PASS] %s\n' "$1"; } +bad() { printf '[FAIL] %s\n' "$1"; FAIL=1; } + +if [ -z "${KERNEL_TARBALL:-}" ] || [ ! -f "$KERNEL_TARBALL" ]; then + echo "[SKIP] set KERNEL_TARBALL to the pinned linux-6.18.46.tar.xz"; exit 0 +fi +command -v python >/dev/null || { echo "[SKIP] needs 'python' on PATH (SDK quirk)"; exit 0; } +REAL_PY="$(command -v python3)" + +# a python3 on which `import lxml` fails, everything else passes through +mkdir -p "$TMP/nolxml" +cat > "$TMP/nolxml/python3" < "$TMP/lxml/python3" < + local root="$1" pfx="$2" work + work="$(mktemp -d "$TMP/w.XXXXXX")" + PATH="$pfx:$PATH" KERNEL_TARBALL="$KERNEL_TARBALL" WORK="$work" WARDEN_CONFIG_ONLY=1 \ + CONFIG_OUT="$work/final.config" CROSS_COMPILE="${CROSS_COMPILE:-arm-linux-gnueabihf-}" \ + bash "$root/build/build-kernel.sh" > "$work/log" 2>&1 || { tail -5 "$work/log" >&2; echo FAILED; return; } + cat "$work/final.config.sha256" +} + +a="$(digest "$REPO" "$TMP/lxml")"; b="$(digest "$REPO" "$TMP/nolxml")" +if [ "$a" != FAILED ] && [ "$a" = "$b" ]; then ok "the config digest is the same with and without a working import lxml ($a)" +else bad "the config digest depends on the host python: with lxml $a, without $b"; fi + +# red case: a tree without the patch +mkdir -p "$TMP/old/patches" +cp -r "$REPO/build" "$TMP/old/build" +for p in "$REPO"/patches/*.patch; do [ "$(basename "$p")" = 90-kconfig-no-python-symbol.patch ] || cp "$p" "$TMP/old/patches/"; done +oa="$(digest "$TMP/old" "$TMP/lxml")"; ob="$(digest "$TMP/old" "$TMP/nolxml")" +if [ "$oa" = FAILED ] || [ "$ob" = FAILED ]; then bad "the doctored tree did not expand" +elif [ "$oa" != "$ob" ]; then ok "doctored: without the patch the digests differ ($oa vs $ob), so this test can fail" +else bad "doctored: the digests are equal even without the patch; the test proves nothing on this tarball"; fi + +if [ "$FAIL" -eq 0 ]; then echo "ALL CONFIG-DETERMINISM TESTS PASSED"; else echo "CONFIG-DETERMINISM TESTS FAILED"; fi +exit $FAIL