From 54d40d81eed80794f5c232b4c4699bb3d5f2181f Mon Sep 17 00:00:00 2001 From: AI Dev Date: Sat, 7 Nov 2026 09:25:57 +0000 Subject: [PATCH] ambarella-osdrv-s3l: stop the build when the kernel moves iav.ko's offsets The prebuilt modules hard-code struct offsets and carry no __versions, so a kernel config that moves them builds, boots and loads them, and fails only at the first /dev/iav ioctl. CI cannot see that: #2778 passed every check while it would have broken iav.ko on every S3L image. The package now compiles a probe against the built kernel with its own Kbuild, and stops if inode->i_cdev or file->private_data is not where iav_open expects. --- .../ambarella-osdrv-s3l.mk | 21 +++++++++++++++++++ .../legacy/ambarella-osdrv-s3l/src/abi/Kbuild | 1 + .../ambarella-osdrv-s3l/src/abi/abi_probe.c | 14 +++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 general/package/legacy/ambarella-osdrv-s3l/src/abi/Kbuild create mode 100644 general/package/legacy/ambarella-osdrv-s3l/src/abi/abi_probe.c diff --git a/general/package/legacy/ambarella-osdrv-s3l/ambarella-osdrv-s3l.mk b/general/package/legacy/ambarella-osdrv-s3l/ambarella-osdrv-s3l.mk index 9b3b2e17c..8ae5608d3 100644 --- a/general/package/legacy/ambarella-osdrv-s3l/ambarella-osdrv-s3l.mk +++ b/general/package/legacy/ambarella-osdrv-s3l/ambarella-osdrv-s3l.mk @@ -11,8 +11,29 @@ AMBARELLA_OSDRV_S3L_LICENSE = MIT (load_ucode), PROPRIETARY (modules, microcode) # load_ucode puts the DSP microcode in place. files/firmware is the generic set # from Ambarella's S3L SDK release 2.5.0_20181109 (2018/10/28, 284712.282649), # not from a camera's stock firmware, which the tree does not accept (#2767). +# +# The prebuilt modules hard-code struct offsets and carry no __versions, so a +# kernel config that moves them builds, boots and loads the modules, and fails +# only at the first /dev/iav ioctl. iav_open reads inode->i_cdev at 272 and +# writes file->private_data at 112: CONFIG_LBDAF moves the first (#2763), and +# CONFIG_QUOTA on top of it moved it again (#2778). So the kernel's own Kbuild +# compiles src/abi against this kernel, and the build stops on a mismatch. +AMBARELLA_OSDRV_S3L_DEPENDENCIES = linux +AMBARELLA_OSDRV_S3L_IAV_OFFSETS = INODE_I_CDEV:272 FILE_PRIVATE_DATA:112 + define AMBARELLA_OSDRV_S3L_BUILD_CMDS $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) load_ucode + $(LINUX_MAKE_ENV) $(MAKE) -C $(LINUX_DIR) $(LINUX_MAKE_FLAGS) \ + M=$(@D)/abi abi_probe.s + for want in $(AMBARELLA_OSDRV_S3L_IAV_OFFSETS); do \ + name=$${want%%:*}; \ + got=$$(sed -n "s/^->$$name [#$$]*\([0-9]*\) .*/\1/p" $(@D)/abi/abi_probe.s); \ + if [ "$$got" != "$${want#*:}" ]; then \ + echo "ambarella-osdrv-s3l: $$name is '$$got' in this kernel," \ + "iav.ko needs $${want#*:}: check the kernel config" >&2; \ + exit 1; \ + fi; \ + done endef define AMBARELLA_OSDRV_S3L_INSTALL_TARGET_CMDS diff --git a/general/package/legacy/ambarella-osdrv-s3l/src/abi/Kbuild b/general/package/legacy/ambarella-osdrv-s3l/src/abi/Kbuild new file mode 100644 index 000000000..a0f4fa02d --- /dev/null +++ b/general/package/legacy/ambarella-osdrv-s3l/src/abi/Kbuild @@ -0,0 +1 @@ +obj-m := abi_probe.o diff --git a/general/package/legacy/ambarella-osdrv-s3l/src/abi/abi_probe.c b/general/package/legacy/ambarella-osdrv-s3l/src/abi/abi_probe.c new file mode 100644 index 000000000..12e5273da --- /dev/null +++ b/general/package/legacy/ambarella-osdrv-s3l/src/abi/abi_probe.c @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MIT +/* + * Not a module: Kbuild compiles this to assembly only, with the kernel's own + * headers and flags, so the package can read the offsets the prebuilt iav.ko + * depends on. See ambarella-osdrv-s3l.mk. + */ +#include +#include + +void abi_probe(void) +{ + DEFINE(INODE_I_CDEV, offsetof(struct inode, i_cdev)); + DEFINE(FILE_PRIVATE_DATA, offsetof(struct file, private_data)); +}