mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 00/13] ARM32: modules: fix bitrot and add test
@ 2026-01-16 16:06 Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 01/13] kbuild: fold rmdirs into rmfiles Ahmad Fatoum
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2026-01-16 16:06 UTC (permalink / raw)
  To: barebox; +Cc: David Dgien

v1 -> v2:
  - drop <fdt.h> include in <compressed-dtb.h> in favor of
    https://lore.barebox.org/barebox/20260114120221.941836-3-a.fatoum@pengutronix.de/T/#m191aec342beb0a80468f5c18a7cdd58dedad08ad
  - patch 01/13 is new to allow deleting the .tmp_barebox_modules_env
    directory
  - renamed virt-el2@multi_v8_defconfig.yaml to dt-2nd@multi_v8_defconfig.yaml
  - added YAML configs for ARM32 as well (Sascha)
  - changed printf in lowlevel.c to pr_info (Sascha)

---

We have had experimental module support in barebox for quite a while,
but AFAIK it doesn't see much real world usage and thus bitrots over time.

One use case I see for modules though is systems, where we want to fit
barebox prebootloader + compressed barebox proper into SRAM to avoid
the need for a PBL-only eMMC driver for example.

In these cases, it would be quite useful if we could strip barebox to
the bare minimum amount of drivers and just load e.g. network driver on
demand. There's a number of things we need before that though: At least
support for W^X (CONFIG_ARM_MMU_PERMISSIONS), ARM64 support and support
for module signature verification.

But for now, let's ensure the support we already have doesn't
deteriorate further and fix some bitrot accumulated so far and add a
test to the test suite to verify module loading continues to work in
future as well. The test is also wired into CI, so it runs on every push
(and Github pull request).


Ahmad Fatoum (13):
  kbuild: fold rmdirs into rmfiles
  boards: qemu-virt: reserve BIOS device tree
  ARM: qemu-virt: add image for use as -bios
  kbuild: build *.mod.c with -std=gnu11
  ARM32: mark modules as incompatible with ARM_MMU_PERMISSIONS
  treewide: fix some missing EXPORT_SYMBOL
  pci: ecam: enable build as module
  kbuild: add support for installing and stripping modules
  ARM32: module: handle more relocations
  commands: pm_domain: make command tristate
  test: conftest: add support for describing FW_CFG environment in YAML
  defaultenv: add barebox_modules_env target
  test: arm: add simple driver/command module test

 .github/workflows/test-labgrid-pytest.yml |   4 +
 Makefile                                  |  44 ++---
 arch/arm/boards/Makefile                  |   1 +
 arch/arm/boards/qemu-virt/Makefile        |   2 +-
 arch/arm/boards/qemu-virt/lowlevel.c      |  80 ++++++++
 arch/arm/configs/modules32_defconfig      | 230 ++++++++++++++++++++++
 arch/arm/cpu/Kconfig                      |   2 +-
 arch/arm/include/asm/elf.h                |   2 +
 arch/arm/lib32/Makefile                   |   1 +
 arch/arm/lib32/module.c                   |  20 ++
 arch/arm/lib32/string.c                   |   7 +
 commands/Kconfig                          |   2 +-
 common/Kconfig                            |  14 ++
 common/bbu.c                              |   1 +
 common/block.c                            |   2 +
 common/boards/qemu-virt/board.c           |  32 +++
 common/firmware.c                         |   1 +
 common/globalvar.c                        |   1 +
 common/machine_id.c                       |   1 +
 common/memory.c                           |   1 +
 common/structio.c                         |   3 +
 conftest.py                               |  19 ++
 defaultenv/.gitignore                     |   1 +
 drivers/base/bus.c                        |   2 +
 drivers/base/class.c                      |   1 +
 drivers/base/driver.c                     |   1 +
 drivers/base/platform.c                   |   1 +
 drivers/base/power.c                      |   2 +
 drivers/clk/clk-bulk.c                    |   2 +-
 drivers/clk/clk.c                         |   1 +
 drivers/firmware/arm_scmi/driver.c        |   1 +
 drivers/gpio/gpiolib.c                    |   2 +-
 drivers/hw_random/core.c                  |   1 +
 drivers/mtd/core.c                        |   1 +
 drivers/net/dsa.c                         |   1 +
 drivers/nvmem/core.c                      |   1 +
 drivers/of/base.c                         |   3 +-
 drivers/pci/Kconfig                       |   2 +-
 drivers/pci/pci.c                         |   2 +
 drivers/pinctrl/pinctrl.c                 |   1 +
 drivers/video/fb.c                        |   1 +
 fs/pstore/platform.c                      |   1 +
 images/Makefile.vexpress                  |   5 +
 lib/parameter.c                           |   1 +
 lib/string.c                              |   2 +
 lib/stringlist.c                          |   3 +
 lib/ucs2_string.c                         |   2 +-
 net/eth.c                                 |   1 +
 net/net.c                                 |   1 +
 scripts/Makefile.modinst                  |  67 +++++++
 test/arm/dt-2nd@multi_v7_defconfig.yaml   |  22 +++
 test/arm/dt-2nd@multi_v8_defconfig.yaml   |  23 +++
 test/arm/modules32_defconfig.yaml         |  27 +++
 test/arm/virt@multi_v7_defconfig.yaml     |   4 +-
 test/arm/virt@multi_v8_defconfig.yaml     |   4 +-
 test/py/test_module.py                    |  54 +++++
 56 files changed, 679 insertions(+), 35 deletions(-)
 create mode 100644 arch/arm/boards/qemu-virt/lowlevel.c
 create mode 100644 arch/arm/configs/modules32_defconfig
 create mode 100644 arch/arm/lib32/string.c
 create mode 100644 scripts/Makefile.modinst
 create mode 100644 test/arm/dt-2nd@multi_v7_defconfig.yaml
 create mode 100644 test/arm/dt-2nd@multi_v8_defconfig.yaml
 create mode 100644 test/arm/modules32_defconfig.yaml
 create mode 100644 test/py/test_module.py

-- 
2.47.3




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 01/13] kbuild: fold rmdirs into rmfiles
  2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
@ 2026-01-16 16:06 ` Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 02/13] boards: qemu-virt: reserve BIOS device tree Ahmad Fatoum
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2026-01-16 16:06 UTC (permalink / raw)
  To: barebox; +Cc: David Dgien, Ahmad Fatoum

Linux doesn't differentiate between the two either and by adopting that,
we can have intermediary .tmp_*/ directories automatically deleted when
cleaning.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 Makefile | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index 3b31cecc22c4..e3127ed2cb37 100644
--- a/Makefile
+++ b/Makefile
@@ -1393,8 +1393,7 @@ MRPROPER_FILES += .config .config.old .security_config .version .old_version \
 
 # clean - Delete most, but leave enough to build external modules
 #
-clean: rm-dirs  := $(CLEAN_DIRS)
-clean: rm-files := $(CLEAN_FILES)
+clean: rm-files := $(CLEAN_FILES) $(CLEAN_DIRS)
 clean-dirs      := $(addprefix _clean_,$(srctree) $(barebox-alldirs))
 
 PHONY += $(clean-dirs) clean archclean
@@ -1403,7 +1402,6 @@ $(clean-dirs):
 	$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
 
 clean: archclean $(clean-dirs)
-	$(call cmd,rmdirs)
 	$(call cmd,rmfiles)
 	@find . $(RCS_FIND_IGNORE) \
 		\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
@@ -1416,8 +1414,7 @@ clean: archclean $(clean-dirs)
 
 # mrproper - Delete all generated files, including .config
 #
-mrproper: rm-dirs  := $(wildcard $(MRPROPER_DIRS))
-mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
+mrproper: rm-files := $(wildcard $(MRPROPER_DIRS)) $(wildcard $(MRPROPER_FILES))
 mrproper-dirs      := $(addprefix _mrproper_,scripts)
 
 PHONY += $(mrproper-dirs) mrproper
@@ -1425,7 +1422,6 @@ $(mrproper-dirs):
 	$(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
 
 mrproper: clean $(mrproper-dirs)
-	$(call cmd,rmdirs)
 	$(call cmd,rmfiles)
 
 # distclean
@@ -1590,11 +1586,8 @@ target-dir = $(dir $@)
 # FIXME Should go into a make.lib or something
 # ===========================================================================
 
-quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN   $(wildcard $(rm-dirs)))
-      cmd_rmdirs = rm -rf $(rm-dirs)
-
 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN   $(wildcard $(rm-files)))
-      cmd_rmfiles = rm -f $(rm-files)
+      cmd_rmfiles = rm -rf $(rm-files)
 
 
 a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \
-- 
2.47.3




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 02/13] boards: qemu-virt: reserve BIOS device tree
  2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 01/13] kbuild: fold rmdirs into rmfiles Ahmad Fatoum
@ 2026-01-16 16:06 ` Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 03/13] ARM: qemu-virt: add image for use as -bios Ahmad Fatoum
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2026-01-16 16:06 UTC (permalink / raw)
  To: barebox; +Cc: David Dgien, Ahmad Fatoum

On the ARM Virt platform, QEMU places its device tree at the start of
RAM and doesn't provide a standard FW_CFG to access it.

To be able to keep reusing it when chainloading barebox in future and
passing it to the kernel, reserve this piece of memory.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 common/boards/qemu-virt/board.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/common/boards/qemu-virt/board.c b/common/boards/qemu-virt/board.c
index 0c9cc1a75d3b..53945aefb7aa 100644
--- a/common/boards/qemu-virt/board.c
+++ b/common/boards/qemu-virt/board.c
@@ -6,6 +6,8 @@
 #include <common.h>
 #include <init.h>
 #include <of.h>
+#include <memory.h>
+#include <compressed-dtb.h>
 #include <deep-probe.h>
 #include <security/policy.h>
 #include "qemu-virt-flash.h"
@@ -47,6 +49,8 @@ static const struct of_device_id virt_of_match[] = {
 };
 BAREBOX_DEEP_PROBE_ENABLE(virt_of_match);
 
+static bool is_qemu_virt;
+
 /*
  * We don't have a dedicated qemu-virt device tree and instead rely
  * on what Qemu passes us. To be able to get fundamental changes
@@ -64,6 +68,8 @@ static int virt_board_driver_init(void)
 	if (!id)
 		return 0;
 
+	is_qemu_virt = true;
+
 	if (id->data) {
 		init = id->data;
 		init();
@@ -94,3 +100,29 @@ static int virt_board_driver_init(void)
 	return 0;
 }
 postcore_initcall(virt_board_driver_init);
+
+static __maybe_unused int virt_board_reserve_fdt(void)
+{
+	resource_size_t start = ~0, end = ~0;
+
+	if (!is_qemu_virt)
+		return 0;
+
+	memory_bank_first_find_space(&start, &end);
+	if (start != ~0) {
+		void *fdt = (void *)start;
+
+		if (!blob_is_fdt(fdt))
+			return 0;
+
+		request_sdram_region("qemu-virt-fdt", start,
+				     fdt_totalsize(fdt),
+				     MEMTYPE_BOOT_SERVICES_DATA,
+				     MEMATTRS_RO);
+	}
+
+	return 0;
+}
+#ifdef CONFIG_ARM
+postmem_initcall(virt_board_reserve_fdt);
+#endif
-- 
2.47.3




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 03/13] ARM: qemu-virt: add image for use as -bios
  2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 01/13] kbuild: fold rmdirs into rmfiles Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 02/13] boards: qemu-virt: reserve BIOS device tree Ahmad Fatoum
@ 2026-01-16 16:06 ` Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 04/13] kbuild: build *.mod.c with -std=gnu11 Ahmad Fatoum
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2026-01-16 16:06 UTC (permalink / raw)
  To: barebox; +Cc: David Dgien, Ahmad Fatoum

We previously used barebox-dt-2nd.img as image for Qemu Virt.
Adding a dedicated image however allows us to use -kernel to specify,
well, a kernel, which can make some testing scenarios more straight
forward, once we implement support for barebox to lookup -kernel and
-append QEMU options.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 arch/arm/boards/Makefile                |  1 +
 arch/arm/boards/qemu-virt/Makefile      |  2 +-
 arch/arm/boards/qemu-virt/lowlevel.c    | 80 +++++++++++++++++++++++++
 images/Makefile.vexpress                |  5 ++
 test/arm/dt-2nd@multi_v7_defconfig.yaml | 22 +++++++
 test/arm/dt-2nd@multi_v8_defconfig.yaml | 23 +++++++
 test/arm/virt@multi_v7_defconfig.yaml   |  4 +-
 test/arm/virt@multi_v8_defconfig.yaml   |  4 +-
 8 files changed, 136 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/boards/qemu-virt/lowlevel.c
 create mode 100644 test/arm/dt-2nd@multi_v7_defconfig.yaml
 create mode 100644 test/arm/dt-2nd@multi_v8_defconfig.yaml

diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index 4c586de2a985..dd2f2c324e25 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -189,6 +189,7 @@ obj-$(CONFIG_MACH_RK3568_EVB)			+= rockchip-rk3568-evb/
 obj-$(CONFIG_MACH_RK3568_BPI_R2PRO)			+= rockchip-rk3568-bpi-r2pro/
 obj-$(CONFIG_MACH_PINE64_PINETAB2)		+= pine64-pinetab2/
 obj-$(CONFIG_MACH_PINE64_QUARTZ64)		+= pine64-quartz64/
+obj-$(CONFIG_BOARD_ARM_VIRT)			+= qemu-virt/
 obj-$(CONFIG_MACH_RADXA_ROCK3)			+= radxa-rock3/
 obj-$(CONFIG_MACH_RADXA_ROCK5)			+= radxa-rock5/
 obj-$(CONFIG_MACH_VARISCITE_DT8MCUSTOMBOARD_IMX8MP)	+= variscite-dt8mcustomboard-imx8mp/
diff --git a/arch/arm/boards/qemu-virt/Makefile b/arch/arm/boards/qemu-virt/Makefile
index ad283446eaf1..458f5209008d 100644
--- a/arch/arm/boards/qemu-virt/Makefile
+++ b/arch/arm/boards/qemu-virt/Makefile
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
-obj-y += board.o
+lwl-y += lowlevel.o
diff --git a/arch/arm/boards/qemu-virt/lowlevel.c b/arch/arm/boards/qemu-virt/lowlevel.c
new file mode 100644
index 000000000000..d6c48e367d08
--- /dev/null
+++ b/arch/arm/boards/qemu-virt/lowlevel.c
@@ -0,0 +1,80 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/sizes.h>
+#include <asm/barebox-arm.h>
+#include <asm/reloc.h>
+#include <compressed-dtb.h>
+#include <debug_ll.h>
+#include <console.h>
+#include <stdio.h>
+#include <debug_ll/pl011.h>
+#include <pbl.h>
+
+#define RAM_BASE	0x40000000
+#define PL011_BASE	IOMEM(0x9000000)
+
+extern char __dtb_qemu_virt32_start[];
+extern char __dtb_qemu_virt64_start[];
+
+static void *find_fdt(void *r0)
+{
+	void *fdt, *ram = (void *)RAM_BASE;
+	const char *origin;
+
+	if (blob_is_fdt(ram)) {
+		origin = "-bios";
+		fdt = ram;
+	} else if (r0 >= ram && blob_is_fdt(r0)) {
+		origin = "-kernel";
+		fdt = r0;
+	} else if (IS_ENABLED(CONFIG_ARM32)) {
+		origin = "built-in";
+		fdt = __dtb_qemu_virt32_start;
+	} else {
+		origin = "built-in";
+		fdt = __dtb_qemu_virt64_start;
+	}
+
+	pr_info("Using %s device tree at %p\n", origin, fdt);
+	return fdt;
+}
+
+/*
+ * Entry point for QEMU virt firmware boot (-bios option).
+ *
+ * Memory layout:
+ *   0x00000000 - 0x08000000: Flash/ROM
+ *   0x08000000 - 0x40000000: Peripherals
+ *   0x40000000 - ...........: RAM
+ */
+static noinline void continue_qemu_virt_bios(ulong r0)
+{
+	ulong membase = RAM_BASE, memsize = SZ_32M - SZ_4M;
+	void *fdt;
+
+	pbl_set_putc(debug_ll_pl011_putc, PL011_BASE);
+
+	/* QEMU may put a DTB at the start of RAM */
+	fdt = find_fdt((void *)r0);
+
+	fdt_find_mem(fdt, &membase, &memsize);
+
+	barebox_arm_entry(membase, memsize, fdt);
+}
+
+ENTRY_FUNCTION_WITHSTACK(start_qemu_virt_bios, RAM_BASE + SZ_32M, r0, r1, r2)
+{
+
+	arm_cpu_lowlevel_init();
+
+	putc_ll('>');
+
+	if (get_pc() >= RAM_BASE)
+		relocate_to_current_adr();
+	else
+		relocate_to_adr_full(RAM_BASE + SZ_4M);
+
+	setup_c();
+
+	continue_qemu_virt_bios(r0);
+}
diff --git a/images/Makefile.vexpress b/images/Makefile.vexpress
index 11c49cca0cbd..81ab8caa4c24 100644
--- a/images/Makefile.vexpress
+++ b/images/Makefile.vexpress
@@ -10,3 +10,8 @@ image-$(CONFIG_MACH_VEXPRESS) += barebox-vexpress-ca9.img
 pblb-$(CONFIG_MACH_VEXPRESS) += start_vexpress_ca15
 FILE_barebox-vexpress-ca15.img = start_vexpress_ca15.pblb
 image-$(CONFIG_MACH_VEXPRESS) += barebox-vexpress-ca15.img
+
+# Firmware image for -bios option
+pblb-$(CONFIG_BOARD_ARM_VIRT) += start_qemu_virt_bios
+FILE_barebox-qemu-virt.img = start_qemu_virt_bios.pblb
+image-$(CONFIG_BOARD_ARM_VIRT) += barebox-qemu-virt.img
diff --git a/test/arm/dt-2nd@multi_v7_defconfig.yaml b/test/arm/dt-2nd@multi_v7_defconfig.yaml
new file mode 100644
index 000000000000..891581205898
--- /dev/null
+++ b/test/arm/dt-2nd@multi_v7_defconfig.yaml
@@ -0,0 +1,22 @@
+targets:
+  main:
+    drivers:
+      QEMUDriver:
+        qemu_bin: qemu-system-arm
+        machine: virt
+        cpu: cortex-a7
+        memory: 1024M
+        kernel: barebox-dt-2nd.img
+        display: qemu-default
+      BareboxDriver:
+        prompt: 'barebox@[^:]+:[^ ]+ '
+        bootstring: 'commandline:'
+      BareboxTestStrategy: {}
+    features:
+      - virtio-mmio
+      - barebox-state
+      - testfs
+images:
+  barebox-dt-2nd.img: !template "$LG_BUILDDIR/images/barebox-dt-2nd.img"
+imports:
+  -  ../strategy.py
diff --git a/test/arm/dt-2nd@multi_v8_defconfig.yaml b/test/arm/dt-2nd@multi_v8_defconfig.yaml
new file mode 100644
index 000000000000..8aa514fb4179
--- /dev/null
+++ b/test/arm/dt-2nd@multi_v8_defconfig.yaml
@@ -0,0 +1,23 @@
+targets:
+  main:
+    drivers:
+      QEMUDriver:
+        qemu_bin: qemu-system-aarch64
+        machine: virt,highmem=off
+        cpu: cortex-a57
+        memory: 1024M
+        kernel: barebox-dt-2nd.img
+        display: qemu-default
+      BareboxDriver:
+        prompt: 'barebox@[^:]+:[^ ]+ '
+        bootstring: 'commandline:'
+      BareboxTestStrategy: {}
+    features:
+      - virtio-mmio
+      - network
+      - barebox-state
+      - testfs
+images:
+  barebox-dt-2nd.img: !template "$LG_BUILDDIR/images/barebox-dt-2nd.img"
+imports:
+  -  ../strategy.py
diff --git a/test/arm/virt@multi_v7_defconfig.yaml b/test/arm/virt@multi_v7_defconfig.yaml
index 891581205898..eef08a5b345b 100644
--- a/test/arm/virt@multi_v7_defconfig.yaml
+++ b/test/arm/virt@multi_v7_defconfig.yaml
@@ -6,7 +6,7 @@ targets:
         machine: virt
         cpu: cortex-a7
         memory: 1024M
-        kernel: barebox-dt-2nd.img
+        bios: barebox-qemu-virt.img
         display: qemu-default
       BareboxDriver:
         prompt: 'barebox@[^:]+:[^ ]+ '
@@ -17,6 +17,6 @@ targets:
       - barebox-state
       - testfs
 images:
-  barebox-dt-2nd.img: !template "$LG_BUILDDIR/images/barebox-dt-2nd.img"
+  barebox-qemu-virt.img: !template "$LG_BUILDDIR/images/barebox-qemu-virt.img"
 imports:
   -  ../strategy.py
diff --git a/test/arm/virt@multi_v8_defconfig.yaml b/test/arm/virt@multi_v8_defconfig.yaml
index 8aa514fb4179..2e654359709e 100644
--- a/test/arm/virt@multi_v8_defconfig.yaml
+++ b/test/arm/virt@multi_v8_defconfig.yaml
@@ -6,7 +6,7 @@ targets:
         machine: virt,highmem=off
         cpu: cortex-a57
         memory: 1024M
-        kernel: barebox-dt-2nd.img
+        bios: barebox-qemu-virt.img
         display: qemu-default
       BareboxDriver:
         prompt: 'barebox@[^:]+:[^ ]+ '
@@ -18,6 +18,6 @@ targets:
       - barebox-state
       - testfs
 images:
-  barebox-dt-2nd.img: !template "$LG_BUILDDIR/images/barebox-dt-2nd.img"
+  barebox-qemu-virt.img: !template "$LG_BUILDDIR/images/barebox-qemu-virt.img"
 imports:
   -  ../strategy.py
-- 
2.47.3




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 04/13] kbuild: build *.mod.c with -std=gnu11
  2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
                   ` (2 preceding siblings ...)
  2026-01-16 16:06 ` [PATCH 03/13] ARM: qemu-virt: add image for use as -bios Ahmad Fatoum
@ 2026-01-16 16:06 ` Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 05/13] ARM32: mark modules as incompatible with ARM_MMU_PERMISSIONS Ahmad Fatoum
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2026-01-16 16:06 UTC (permalink / raw)
  To: barebox; +Cc: David Dgien, Ahmad Fatoum

The *.mod.c files are generated C files built as part of the module
build. They didn't have a -std= set so far, so newer toolchains, module
build failed, because true/false became keyworks in -std=c23.

Add an explicit -std=gnu11 to fix this.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index e3127ed2cb37..1a5f21b66ebb 100644
--- a/Makefile
+++ b/Makefile
@@ -468,7 +468,7 @@ PYTEST		= $(if $(shell command -v labgrid-pytest 2>/dev/null),labgrid-pytest,pyt
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF)
 CFLAGS_KERNEL	=
 AFLAGS_KERNEL	=
-CFLAGS_MODULE	= -fshort-wchar
+CFLAGS_MODULE	= -fshort-wchar -std=gnu11
 AFLAGS_MODULE	=
 
 LDFLAGS_MODULE  = -T common/module.lds
-- 
2.47.3




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 05/13] ARM32: mark modules as incompatible with ARM_MMU_PERMISSIONS
  2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
                   ` (3 preceding siblings ...)
  2026-01-16 16:06 ` [PATCH 04/13] kbuild: build *.mod.c with -std=gnu11 Ahmad Fatoum
@ 2026-01-16 16:06 ` Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 06/13] treewide: fix some missing EXPORT_SYMBOL Ahmad Fatoum
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2026-01-16 16:06 UTC (permalink / raw)
  To: barebox; +Cc: David Dgien, Ahmad Fatoum

The module code currently assumes RWX. This can be fixed if desired, but
for now just reflect it in Kconfig to avoid the runtime panic.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 arch/arm/cpu/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/cpu/Kconfig b/arch/arm/cpu/Kconfig
index fe0d1e470578..04b1585679f3 100644
--- a/arch/arm/cpu/Kconfig
+++ b/arch/arm/cpu/Kconfig
@@ -4,7 +4,7 @@ comment "Processor Type"
 
 config CPU_32
 	bool
-	select HAS_MODULES
+	select HAS_MODULES if !ARM_MMU_PERMISSIONS
 	select HAVE_MOD_ARCH_SPECIFIC
 	select HAS_DMA
 	select ARCH_HAS_ZERO_PAGE
-- 
2.47.3




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 06/13] treewide: fix some missing EXPORT_SYMBOL
  2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
                   ` (4 preceding siblings ...)
  2026-01-16 16:06 ` [PATCH 05/13] ARM32: mark modules as incompatible with ARM_MMU_PERMISSIONS Ahmad Fatoum
@ 2026-01-16 16:06 ` Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 07/13] pci: ecam: enable build as module Ahmad Fatoum
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2026-01-16 16:06 UTC (permalink / raw)
  To: barebox; +Cc: David Dgien, Claude, Ahmad Fatoum

In preparation for testing ARM32 module support in CI, fix some
EXPORT_SYMBOL around the tree, which we will rely on later.

Co-developed-by: Claude <noreply@claude.ai>
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 arch/arm/lib32/Makefile            | 1 +
 arch/arm/lib32/string.c            | 7 +++++++
 common/bbu.c                       | 1 +
 common/block.c                     | 2 ++
 common/firmware.c                  | 1 +
 common/globalvar.c                 | 1 +
 common/machine_id.c                | 1 +
 common/memory.c                    | 1 +
 common/structio.c                  | 3 +++
 drivers/base/bus.c                 | 2 ++
 drivers/base/class.c               | 1 +
 drivers/base/driver.c              | 1 +
 drivers/base/platform.c            | 1 +
 drivers/base/power.c               | 2 ++
 drivers/clk/clk-bulk.c             | 2 +-
 drivers/clk/clk.c                  | 1 +
 drivers/firmware/arm_scmi/driver.c | 1 +
 drivers/gpio/gpiolib.c             | 2 +-
 drivers/hw_random/core.c           | 1 +
 drivers/mtd/core.c                 | 1 +
 drivers/net/dsa.c                  | 1 +
 drivers/nvmem/core.c               | 1 +
 drivers/of/base.c                  | 3 ++-
 drivers/pci/pci.c                  | 2 ++
 drivers/pinctrl/pinctrl.c          | 1 +
 drivers/video/fb.c                 | 1 +
 fs/pstore/platform.c               | 1 +
 lib/parameter.c                    | 1 +
 lib/string.c                       | 2 ++
 lib/stringlist.c                   | 3 +++
 lib/ucs2_string.c                  | 2 +-
 net/eth.c                          | 1 +
 net/net.c                          | 1 +
 33 files changed, 49 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/lib32/string.c

diff --git a/arch/arm/lib32/Makefile b/arch/arm/lib32/Makefile
index cdfb992c0d5d..67c4f16f76ad 100644
--- a/arch/arm/lib32/Makefile
+++ b/arch/arm/lib32/Makefile
@@ -25,6 +25,7 @@ obj-pbl-y += reloc.o
 obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS)	+= memcpy.o
 obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS)	+= memmove.o
 obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS)	+= memset.o
+obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS)	+= string.o
 obj-$(CONFIG_ARM_UNWIND) += unwind.o
 obj-$(CONFIG_MODULES) += module.o
 obj-$(CONFIG_ARM_MODULE_PLTS) += module-plts.o
diff --git a/arch/arm/lib32/string.c b/arch/arm/lib32/string.c
new file mode 100644
index 000000000000..ad1113034be3
--- /dev/null
+++ b/arch/arm/lib32/string.c
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <linux/string.h>
+#include <linux/export.h>
+
+EXPORT_SYMBOL(memcpy);
+EXPORT_SYMBOL(memset);
diff --git a/common/bbu.c b/common/bbu.c
index 00d415bcf826..07a51c112f0e 100644
--- a/common/bbu.c
+++ b/common/bbu.c
@@ -288,6 +288,7 @@ bool bbu_handlers_available(void)
 {
 	return !list_empty(&bbu_image_handlers);
 }
+EXPORT_SYMBOL(bbu_handlers_available);
 
 /*
  * print a list of all registered update handlers
diff --git a/common/block.c b/common/block.c
index e021b1a9666f..22597124a1b3 100644
--- a/common/block.c
+++ b/common/block.c
@@ -16,6 +16,7 @@
 #include <file-list.h>
 
 LIST_HEAD(block_device_list);
+EXPORT_SYMBOL(block_device_list);
 
 /* a chunk of contiguous data */
 struct chunk {
@@ -583,6 +584,7 @@ const char *blk_type_str(enum blk_type type)
 		return "unknown";
 	}
 }
+EXPORT_SYMBOL(blk_type_str);
 
 int cdev_get_linux_root_and_opts(const struct cdev *partcdev, const char **root,
 				 const char **rootopts)
diff --git a/common/firmware.c b/common/firmware.c
index 264fc9d66dcc..31b75bd88ab5 100644
--- a/common/firmware.c
+++ b/common/firmware.c
@@ -87,6 +87,7 @@ struct firmware_mgr *firmwaremgr_find_by_node(struct device_node *np)
 
 	return NULL;
 }
+EXPORT_SYMBOL(firmwaremgr_find_by_node);
 
 /*
  * firmwaremgr_list_handlers - list registered firmware device handlers
diff --git a/common/globalvar.c b/common/globalvar.c
index 127ecd5c6075..fcaa15179f68 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -21,6 +21,7 @@ struct device global_device = {
 	.name = "global",
 	.id = DEVICE_ID_SINGLE,
 };
+EXPORT_SYMBOL(global_device);
 
 struct device nv_device = {
 	.name = "nv",
diff --git a/common/machine_id.c b/common/machine_id.c
index e670886d8538..acc7aac52cf9 100644
--- a/common/machine_id.c
+++ b/common/machine_id.c
@@ -22,6 +22,7 @@ const void *machine_id_get_hashable(size_t *len)
 	*len = __machine_id_hashable_length;
 	return __machine_id_hashable;
 }
+EXPORT_SYMBOL(machine_id_get_hashable);
 
 /**
  * machine_id_set_hashable - Provide per-board unique data
diff --git a/common/memory.c b/common/memory.c
index 49ff0ef619d5..1c18c5b38710 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -212,6 +212,7 @@ void *sbrk(ptrdiff_t increment)
 }
 
 LIST_HEAD(memory_banks);
+EXPORT_SYMBOL(memory_banks);
 
 static int barebox_grow_memory_bank(struct memory_bank *bank, const char *name,
 				    const struct resource *newres)
diff --git a/common/structio.c b/common/structio.c
index 935c4628dd77..776dc1e902ab 100644
--- a/common/structio.c
+++ b/common/structio.c
@@ -3,6 +3,7 @@
 #include <structio.h>
 #include <command.h>
 #include <device.h>
+#include <linux/export.h>
 
 static struct bobject *active_capture;
 
@@ -34,6 +35,7 @@ int structio_run_command(struct bobject **bret, const char *cmd)
 	*bret = bobj;
 	return 0;
 }
+EXPORT_SYMBOL(structio_run_command);
 
 int structio_devinfo(struct bobject **bret, struct device *dev)
 {
@@ -54,3 +56,4 @@ int structio_devinfo(struct bobject **bret, struct device *dev)
 	*bret = bobj;
 	return 0;
 }
+EXPORT_SYMBOL(structio_devinfo);
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 7ee5959e8b9f..9e5b43cd0ffa 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -10,6 +10,7 @@
 #include <of.h>
 
 DEFINE_DEV_CLASS(bus_class, "bus");
+EXPORT_SYMBOL(bus_class);
 
 struct bus_type *get_bus_by_name(const char *name)
 {
@@ -22,6 +23,7 @@ struct bus_type *get_bus_by_name(const char *name)
 
 	return NULL;
 }
+EXPORT_SYMBOL(get_bus_by_name);
 
 int bus_register(struct bus_type *bus)
 {
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 693260fe22dc..d21d679f1acc 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -4,6 +4,7 @@
 #include <linux/list.h>
 
 LIST_HEAD(class_list);
+EXPORT_SYMBOL(class_list);
 
 void class_register(struct class *class)
 {
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 782cdfdfcecb..36a1fcda48c8 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -586,6 +586,7 @@ struct resource *dev_request_mem_resource(struct device *dev, int num)
 
 	return dev_request_iomem_resource(dev, res);
 }
+EXPORT_SYMBOL(dev_request_mem_resource);
 
 void __iomem *dev_request_mem_region_err_null(struct device *dev, int num)
 {
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index ac7c473c8c7b..9e6718c6476c 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -28,6 +28,7 @@ int platform_driver_register(struct driver *drv)
 
 	return register_driver(drv);
 }
+EXPORT_SYMBOL(platform_driver_register);
 
 int platform_device_register(struct device *new_device)
 {
diff --git a/drivers/base/power.c b/drivers/base/power.c
index cffd0436278a..543c85a3d9b8 100644
--- a/drivers/base/power.c
+++ b/drivers/base/power.c
@@ -361,6 +361,7 @@ bool genpd_is_active(void)
 {
 	return have_genpd_providers && !list_empty(&gpd_list);
 }
+EXPORT_SYMBOL(genpd_is_active);
 
 static struct bus_type genpd_bus_type = {
 	.name		= "genpd",
@@ -563,3 +564,4 @@ void pm_genpd_print(void)
 		printf("%-20s %6s\n", genpd->name,
 		       genpd->status == GPD_STATE_ACTIVE ? "on" : "off");
 }
+EXPORT_SYMBOL(pm_genpd_print);
diff --git a/drivers/clk/clk-bulk.c b/drivers/clk/clk-bulk.c
index c16fed282b21..e34a1feff2a2 100644
--- a/drivers/clk/clk-bulk.c
+++ b/drivers/clk/clk-bulk.c
@@ -170,7 +170,7 @@ int __must_check clk_bulk_get_all_enabled(struct device *dev,
 
 	return num_clks;
 }
-EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all_enabled);
+EXPORT_SYMBOL_GPL(clk_bulk_get_all_enabled);
 
 /**
  * clk_bulk_disable - gate a set of clocks
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index ac5b83cf8b40..5e385380cee2 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -29,6 +29,7 @@ bool clk_have_nonfixed_providers(void)
 
 	return false;
 }
+EXPORT_SYMBOL(clk_have_nonfixed_providers);
 
 static int clk_parent_enable(struct clk *clk)
 {
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index bbb62dd5191a..5c69ea953c76 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -39,6 +39,7 @@ static DEFINE_SPINLOCK(protocol_lock);
 
 /* List of all SCMI devices active in system */
 LIST_HEAD(scmi_list);
+EXPORT_SYMBOL(scmi_list);
 /* Protection for the entire list */
 static DEFINE_MUTEX(scmi_list_mutex);
 /* Track the unique id for the transfers for debug & profiling purpose */
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index e1493ffb6640..37a98995f2e8 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -662,7 +662,7 @@ struct gpio_desc *gpiod_request_one(unsigned gpio,
 
 	return desc;
 }
-EXPORT_SYMBOL_GPL(gpio_request_one);
+EXPORT_SYMBOL_GPL(gpiod_request_one);
 
 
 /**
diff --git a/drivers/hw_random/core.c b/drivers/hw_random/core.c
index 7bc3c33319f9..9f73aa45bcec 100644
--- a/drivers/hw_random/core.c
+++ b/drivers/hw_random/core.c
@@ -102,6 +102,7 @@ struct hwrng *hwrng_get_first(void)
 	else
 		return list_first_entry(&hwrngs, struct hwrng, list);
 }
+EXPORT_SYMBOL(hwrng_get_first);
 
 int hwrng_register(struct device *dev, struct hwrng *rng)
 {
diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index bb579a8f5249..922105944d34 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -26,6 +26,7 @@
 static LIST_HEAD(mtd_register_hooks);
 
 DEFINE_DEV_CLASS(mtd_class, "mtd");
+EXPORT_SYMBOL(mtd_class);
 
 /**
  * mtd_buf_all_ff - check if buffer contains only 0xff
diff --git a/drivers/net/dsa.c b/drivers/net/dsa.c
index 667297e8fea3..8eb12522999f 100644
--- a/drivers/net/dsa.c
+++ b/drivers/net/dsa.c
@@ -7,6 +7,7 @@
 #include <param.h>
 
 LIST_HEAD(dsa_switch_list);
+EXPORT_SYMBOL(dsa_switch_list);
 
 u32 dsa_user_ports(struct dsa_switch *ds)
 {
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 8e1cf400e5d8..0047bf188dd2 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -38,6 +38,7 @@ struct nvmem_cell {
 };
 
 DEFINE_DEV_CLASS(nvmem_class, "nvmem");
+EXPORT_SYMBOL(nvmem_class);
 
 void nvmem_devices_print(void)
 {
diff --git a/drivers/of/base.c b/drivers/of/base.c
index a26c1faa41d5..54fd458bd9a1 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -294,7 +294,7 @@ int of_alias_get_free_id(const char *stem)
 
 	return id + 1;
 }
-EXPORT_SYMBOL_GPL(of_alias_get_highest_id);
+EXPORT_SYMBOL_GPL(of_alias_get_free_id);
 
 int of_alias_get_id_from(struct device_node *root, struct device_node *np,
 			 const char *stem)
@@ -2072,6 +2072,7 @@ struct device_node *of_get_root_node(void)
 {
 	return root_node;
 }
+EXPORT_SYMBOL(of_get_root_node);
 
 int of_set_root_node(struct device_node *node)
 {
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index e6370b5c7f6e..32624fe05b56 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -48,6 +48,7 @@ void pci_controller_init(struct pci_controller *hose)
 
 	of_pci_bridge_init(hose->parent, hose);
 }
+EXPORT_SYMBOL(pci_controller_init);
 
 void register_pci_controller(struct pci_controller *hose)
 {
@@ -85,6 +86,7 @@ void register_pci_controller(struct pci_controller *hose)
 
 	return;
 }
+EXPORT_SYMBOL(register_pci_controller);
 
 /*
  *  Wrappers for all PCI configuration access functions.  They just check
diff --git a/drivers/pinctrl/pinctrl.c b/drivers/pinctrl/pinctrl.c
index 2f85a0f08f08..01567aa5ae97 100644
--- a/drivers/pinctrl/pinctrl.c
+++ b/drivers/pinctrl/pinctrl.c
@@ -30,6 +30,7 @@ struct pinctrl_consumer_info {
 };
 
 LIST_HEAD(pinctrl_list);
+EXPORT_SYMBOL(pinctrl_list);
 
 static struct pinctrl_device *pin_to_pinctrl(unsigned int pin)
 {
diff --git a/drivers/video/fb.c b/drivers/video/fb.c
index 939368a0de68..bfc075039e9e 100644
--- a/drivers/video/fb.c
+++ b/drivers/video/fb.c
@@ -10,6 +10,7 @@
 #include <init.h>
 
 DEFINE_DEV_CLASS(fb_class, "fb");
+EXPORT_SYMBOL(fb_class);
 
 static int fb_ioctl(struct cdev* cdev, unsigned int req, void *data)
 {
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 3157cc90d514..b72c7346e6a8 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -50,6 +50,7 @@ bool pstore_is_ready(void)
 {
 	return pstore_ready;
 }
+EXPORT_SYMBOL(pstore_is_ready);
 
 void pstore_log(const char *str)
 {
diff --git a/lib/parameter.c b/lib/parameter.c
index bf5dbbb05e6b..1243a12e8701 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -86,6 +86,7 @@ const char *bobject_get_param(bobject_t _bobj, const char *name)
 
 	return param->get(bobj, param);
 }
+EXPORT_SYMBOL(bobject_get_param);
 
 /**
  * bobject_set_param - set a parameter of a barebox object to a new value
diff --git a/lib/string.c b/lib/string.c
index a55f98990032..302f87a60422 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -684,6 +684,7 @@ EXPORT_SYMBOL(__nokasan_default_memset);
 #ifndef __HAVE_ARCH_MEMSET
 void *memset(void *s, int c, size_t count) __alias(__default_memset);
 void *__memset(void *s, int c, size_t count) __alias(__default_memset);
+EXPORT_SYMBOL(memset);
 #endif
 
 /**
@@ -723,6 +724,7 @@ void *memcpy(void * dest, const void *src, size_t count)
 	__alias(__default_memcpy);
 void *__memcpy(void * dest, const void *src, size_t count)
 	__alias(__default_memcpy);
+EXPORT_SYMBOL(memcpy);
 #endif
 
 void *mempcpy(void *dest, const void *src, size_t count)
diff --git a/lib/stringlist.c b/lib/stringlist.c
index 908fa3683c36..96e06c288d28 100644
--- a/lib/stringlist.c
+++ b/lib/stringlist.c
@@ -27,6 +27,7 @@ int string_list_add(struct string_list *sl, const char *str)
 
 	return 0;
 }
+EXPORT_SYMBOL(string_list_add);
 
 int string_list_add_asprintf(struct string_list *sl, const char *fmt, ...)
 {
@@ -50,6 +51,7 @@ int string_list_add_asprintf(struct string_list *sl, const char *fmt, ...)
 
 	return 0;
 }
+EXPORT_SYMBOL(string_list_add_asprintf);
 
 int string_list_add_sorted(struct string_list *sl, const char *str)
 {
@@ -126,6 +128,7 @@ char *string_list_join(const struct string_list *sl, const char *joinstr)
 
 	return str;
 }
+EXPORT_SYMBOL(string_list_join);
 
 void string_list_print_by_column(struct string_list *sl)
 {
diff --git a/lib/ucs2_string.c b/lib/ucs2_string.c
index db3f34f6b70c..6f027010d3a5 100644
--- a/lib/ucs2_string.c
+++ b/lib/ucs2_string.c
@@ -113,7 +113,7 @@ ucs2_strcmp(const ucs2_char_t *a, const ucs2_char_t *b)
 {
 	return ucs2_strncmp(a, b, ~0UL);
 }
-EXPORT_SYMBOL(ucs2_strncmp);
+EXPORT_SYMBOL(ucs2_strcmp);
 
 unsigned long
 ucs2_utf8size(const ucs2_char_t *src)
diff --git a/net/eth.c b/net/eth.c
index 857bd2ee70dd..4201ed1c6b66 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -22,6 +22,7 @@
 #include <linux/stat.h>
 
 DEFINE_DEV_CLASS(eth_class, "eth");
+EXPORT_SYMBOL(eth_class);
 
 LIST_HEAD(ethaddr_list);
 
diff --git a/net/net.c b/net/net.c
index 9c5999604b67..60f325ec63de 100644
--- a/net/net.c
+++ b/net/net.c
@@ -364,6 +364,7 @@ IPaddr_t net_get_ip(struct eth_device *edev)
 {
 	return edev->ipaddr;
 }
+EXPORT_SYMBOL(net_get_ip);
 
 void net_set_netmask(struct eth_device *edev, IPaddr_t nm)
 {
-- 
2.47.3




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 07/13] pci: ecam: enable build as module
  2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
                   ` (5 preceding siblings ...)
  2026-01-16 16:06 ` [PATCH 06/13] treewide: fix some missing EXPORT_SYMBOL Ahmad Fatoum
@ 2026-01-16 16:06 ` Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 08/13] kbuild: add support for installing and stripping modules Ahmad Fatoum
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2026-01-16 16:06 UTC (permalink / raw)
  To: barebox; +Cc: David Dgien, Ahmad Fatoum

The driver would be buildable as module, if only we marked it so in the
Kconfig.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 drivers/pci/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index 8f37805d71ca..f8e60c4ea59e 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -68,7 +68,7 @@ config PCI_EFI
 	select PCI
 
 config PCI_ECAM_GENERIC
-	bool "Generic ECAM-based PCI host controller support"
+	tristate "Generic ECAM-based PCI host controller support"
 	select OF_PCI
 	select PCI
 	help
-- 
2.47.3




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 08/13] kbuild: add support for installing and stripping modules
  2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
                   ` (6 preceding siblings ...)
  2026-01-16 16:06 ` [PATCH 07/13] pci: ecam: enable build as module Ahmad Fatoum
@ 2026-01-16 16:06 ` Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 09/13] ARM32: module: handle more relocations Ahmad Fatoum
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2026-01-16 16:06 UTC (permalink / raw)
  To: barebox; +Cc: David Dgien, Claude, Ahmad Fatoum

We have a defunct modules_install target, which fails when called.
Fix it, so it actually installs stripped modules.

This is important, because we don't want barebox to attempt relocation
the .debug sections as it doesn't support all relocations that can occur
there.

Note that unlike Linux, we always strip. Linux on the other hand has a
check that skips relocation of non-alloc segments and we may want to add
that too in future, but only after switching to barebox proper being
linked in PBL as proper ELF.

Co-developed-by: Claude <noreply@claude.ai>
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 Makefile                 | 15 ++-------
 scripts/Makefile.modinst | 67 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 12 deletions(-)
 create mode 100644 scripts/Makefile.modinst

diff --git a/Makefile b/Makefile
index 1a5f21b66ebb..b6023dc4ff2c 100644
--- a/Makefile
+++ b/Makefile
@@ -448,7 +448,6 @@ LEX		= flex
 YACC		= bison
 AWK		= awk
 GENKSYMS	= scripts/genksyms/genksyms
-DEPMOD		= /sbin/depmod
 KALLSYMS	= scripts/kallsyms
 SCONFIGPOST	= scripts/sconfig/sconfigpost
 PERL		= perl
@@ -1317,18 +1316,13 @@ modules_prepare: prepare scripts
 
 # Target to install modules
 PHONY += modules_install
-modules_install: _modinst_ _modinst_post
+modules_install: _modinst_
 
 PHONY += _modinst_
 _modinst_:
-	@if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
-		echo "Warning: you may need to install module-init-tools"; \
-		echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\
-		sleep 1; \
-	fi
-	@rm -rf $(MODLIB)/kernel
+	@rm -rf $(MODLIB)/barebox
 	@rm -f $(MODLIB)/source
-	@mkdir -p $(MODLIB)/kernel
+	@mkdir -p $(MODLIB)/barebox
 	@ln -s $(srctree) $(MODLIB)/source
 	@if [ ! $(objtree) -ef  $(MODLIB)/build ]; then \
 		rm -f $(MODLIB)/build ; \
@@ -1346,9 +1340,6 @@ depmod_opts	:=
 else
 depmod_opts	:= -b $(INSTALL_MOD_PATH) -r
 endif
-PHONY += _modinst_post
-_modinst_post: _modinst_
-	if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
 
 else # CONFIG_MODULES
 
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
new file mode 100644
index 000000000000..6cb9b6ccaa1e
--- /dev/null
+++ b/scripts/Makefile.modinst
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: GPL-2.0
+# ==========================================================================
+# Installing modules
+# ==========================================================================
+
+PHONY := __modinst
+__modinst:
+
+include $(objtree)/include/config/auto.conf
+include $(srctree)/scripts/Kbuild.include
+
+install-y :=
+
+# remove the old directory
+$(shell rm -fr $(MODLIB)/barebox)
+
+dst := $(MODLIB)/barebox
+
+# Find all .ko files in the build tree
+modules := $(shell find $(objtree) -name '*.ko' -not -path '$(MODLIB)/*' 2>/dev/null)
+modules-dst := $(addprefix $(dst)/, $(patsubst $(objtree)/%,%,$(modules)))
+
+install-$(CONFIG_MODULES) += $(modules-dst)
+
+__modinst: $(install-y)
+	@:
+
+#
+# Installation
+#
+quiet_cmd_install = INSTALL $@
+      cmd_install = mkdir -p $(dir $@) && cp $< $@
+
+INSTALL_MOD_STRIP ?= 1
+
+# Strip
+#
+# INSTALL_MOD_STRIP, if defined, will cause modules to be stripped after they
+# are installed. If INSTALL_MOD_STRIP is '1', then the default option
+# --strip-debug will be used. Otherwise, INSTALL_MOD_STRIP value will be used
+# as the options to the strip command.
+ifdef INSTALL_MOD_STRIP
+
+ifeq ($(INSTALL_MOD_STRIP),1)
+strip-option := --strip-debug
+else
+strip-option := $(INSTALL_MOD_STRIP)
+endif
+
+quiet_cmd_strip = STRIP   $@
+      cmd_strip = $(STRIP) $(strip-option) $@
+
+else
+
+quiet_cmd_strip =
+      cmd_strip = :
+
+endif
+
+$(dst)/%.ko: $(objtree)/%.ko FORCE
+	$(call cmd,install)
+	$(call cmd,strip)
+
+PHONY += FORCE
+FORCE:
+
+.PHONY: $(PHONY)
-- 
2.47.3




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 09/13] ARM32: module: handle more relocations
  2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
                   ` (7 preceding siblings ...)
  2026-01-16 16:06 ` [PATCH 08/13] kbuild: add support for installing and stripping modules Ahmad Fatoum
@ 2026-01-16 16:06 ` Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 10/13] commands: pm_domain: make command tristate Ahmad Fatoum
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2026-01-16 16:06 UTC (permalink / raw)
  To: barebox; +Cc: David Dgien, Ahmad Fatoum

Compiling with arm-linux-gnueabihf-gcc (Debian 14.2.0-19) 14.2.0
generates a few more relocation types than the module loader currently
supports.

Import support for them from Linux, so we can start automatically
testing this feature.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 arch/arm/include/asm/elf.h |  2 ++
 arch/arm/lib32/module.c    | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index 0b4704a4a561..f3b6e0dd37c3 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -29,9 +29,11 @@ typedef struct user_fp elf_fpregset_t;
 
 #define R_ARM_NONE	0
 #define R_ARM_PC24	1
+#define R_ARM_REL32	3
 #define R_ARM_ABS32	2
 #define R_ARM_CALL	28
 #define R_ARM_JUMP24	29
+#define R_ARM_PREL31	42
 
 #define R_ARM_THM_CALL		10
 #define R_ARM_THM_JUMP24	30
diff --git a/arch/arm/lib32/module.c b/arch/arm/lib32/module.c
index 7214e3c73c3d..0cf04ea9faba 100644
--- a/arch/arm/lib32/module.c
+++ b/arch/arm/lib32/module.c
@@ -49,6 +49,9 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 		loc = dstsec->sh_addr + rel->r_offset;
 
 		switch (ELF32_R_TYPE(rel->r_info)) {
+		case R_ARM_NONE:
+			/* ignore */
+			break;
 		case R_ARM_ABS32:
 			*(u32 *)loc += sym->st_value;
 			break;
@@ -90,6 +93,23 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 			*(u32 *)loc |= offset & 0x00ffffff;
 			break;
 
+		case R_ARM_PREL31:
+			offset = (*(s32 *)loc << 1) >> 1; /* sign extend */
+			offset += sym->st_value - loc;
+			if (offset >= 0x40000000 || offset < -0x40000000) {
+				pr_err("%s: section %u reloc %u sym '%s': relocation %u out of range (%#lx -> %#x)\n",
+				       module->name, relindex, i, strtab + sym->st_name,
+				       ELF32_R_TYPE(rel->r_info), loc,
+				       sym->st_value);
+				return -ENOEXEC;
+			}
+			*(u32 *)loc &= 0x80000000;
+			*(u32 *)loc |= offset & 0x7fffffff;
+			break;
+
+		case R_ARM_REL32:
+			*(u32 *)loc += sym->st_value - loc;
+			break;
 		default:
 			printf("%s: unknown relocation: %u\n",
 			       module->name, ELF32_R_TYPE(rel->r_info));
-- 
2.47.3




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 10/13] commands: pm_domain: make command tristate
  2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
                   ` (8 preceding siblings ...)
  2026-01-16 16:06 ` [PATCH 09/13] ARM32: module: handle more relocations Ahmad Fatoum
@ 2026-01-16 16:06 ` Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 11/13] test: conftest: add support for describing FW_CFG environment in YAML Ahmad Fatoum
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2026-01-16 16:06 UTC (permalink / raw)
  To: barebox; +Cc: David Dgien, Ahmad Fatoum

The upcoming module test will build pm_domain as module and check that
dynamically adding commands work, so prepare for that in Kconfig.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 commands/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commands/Kconfig b/commands/Kconfig
index f94c7278e72e..297c89b4b566 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -273,7 +273,7 @@ config CMD_REGULATOR
 	  their current state.
 
 config CMD_PM_DOMAIN
-	bool
+	tristate
 	depends on PM_GENERIC_DOMAINS
 	prompt "pm_domain command"
 	help
-- 
2.47.3




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 11/13] test: conftest: add support for describing FW_CFG environment in YAML
  2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
                   ` (9 preceding siblings ...)
  2026-01-16 16:06 ` [PATCH 10/13] commands: pm_domain: make command tristate Ahmad Fatoum
@ 2026-01-16 16:06 ` Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 12/13] defaultenv: add barebox_modules_env target Ahmad Fatoum
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2026-01-16 16:06 UTC (permalink / raw)
  To: barebox; +Cc: David Dgien, Claude, Ahmad Fatoum

We can inject new environment files via FW_CFG with pytest --env.
Add support for an env: key that allows manipulating the barebox
environment with only the YAML.

Co-developed-by: Claude <noreply@claude.ai>
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 conftest.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/conftest.py b/conftest.py
index ef6ca221a5db..4241ebce7702 100644
--- a/conftest.py
+++ b/conftest.py
@@ -143,6 +143,12 @@ def strategy(request, target, pytestconfig):  # noqa: max-complexity=30
     except KeyError:
         features = []
 
+    try:
+        main = target.env.config.data["targets"]["main"]
+        yaml_env = main["env"]
+    except KeyError:
+        yaml_env = {}
+
     try:
         main = target.env.config.data["targets"]["main"]
         qemu_bin = main["drivers"]["QEMUDriver"]["qemu_bin"]
@@ -218,6 +224,19 @@ def strategy(request, target, pytestconfig):  # noqa: max-complexity=30
         else:
             pytest.exit("--env unsupported for target\n", 1)
 
+    for envpath, value in yaml_env.items():
+        if virtio:
+            if value.startswith('@'):
+                source = f"file='{value[1:]}'"
+            else:
+                source = f"string='{value}'"
+
+            strategy.append_qemu_args(
+                '-fw_cfg', f'name=opt/org.barebox.env/{envpath},{source}'
+            )
+        else:
+            pytest.exit("env unsupported for target\n", 1)
+
     if len(pytestconfig.option.bootarg) > 0:
         strategy.append_qemu_bootargs(pytestconfig.option.bootarg)
 
-- 
2.47.3




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 12/13] defaultenv: add barebox_modules_env target
  2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
                   ` (10 preceding siblings ...)
  2026-01-16 16:06 ` [PATCH 11/13] test: conftest: add support for describing FW_CFG environment in YAML Ahmad Fatoum
@ 2026-01-16 16:06 ` Ahmad Fatoum
  2026-01-16 16:06 ` [PATCH 13/13] test: arm: add simple driver/command module test Ahmad Fatoum
  2026-01-19  7:28 ` [PATCH 00/13] ARM32: modules: fix bitrot and add test Sascha Hauer
  13 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2026-01-16 16:06 UTC (permalink / raw)
  To: barebox; +Cc: David Dgien, Claude, Ahmad Fatoum

We want a single file with all modules to make it easier to load them
inside emulation. Add a very simple environment target to facilitate
this.

There may be room for improvement as enabling CONFIG_MODULES_ENVIRONMENT
triggers the rebuild every time, but for experimental feature that's
not enabled by default, it should be acceptable for now.

Co-developed-by: Claude <noreply@claude.ai>
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 Makefile              | 14 ++++++++++++++
 common/Kconfig        | 14 ++++++++++++++
 defaultenv/.gitignore |  1 +
 3 files changed, 29 insertions(+)

diff --git a/Makefile b/Makefile
index b6023dc4ff2c..9c70aa0f49a3 100644
--- a/Makefile
+++ b/Makefile
@@ -1341,6 +1341,20 @@ else
 depmod_opts	:= -b $(INSTALL_MOD_PATH) -r
 endif
 
+# Target to build modules environment
+MODULES_ENV_DIR := $(objtree)/.tmp_barebox_modules_env
+CLEAN_DIRS += $(MODULES_ENV_DIR)
+
+barebox_modules_env: modules FORCE
+	$(Q)rm -rf $(MODULES_ENV_DIR)
+	$(Q)$(MAKE) -f $(srctree)/Makefile modules_install MODLIB=$(MODULES_ENV_DIR)
+	$(Q)$(objtree)/scripts/bareboxenv -s $(MODULES_ENV_DIR)/barebox $@
+	$(Q)mv barebox_modules_env $(objtree)/defaultenv/
+
+ifdef CONFIG_MODULES_ENVIRONMENT
+all: barebox_modules_env
+endif
+
 else # CONFIG_MODULES
 
 # Modules not configured
diff --git a/common/Kconfig b/common/Kconfig
index d4d9d930a996..50c26695b2b5 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -356,6 +356,20 @@ config MODULES
 	  As modules can't be signed, loading external modules is not
 	  recommended for secure systems.
 
+config MODULES_ENVIRONMENT
+	bool "Build environment with all modules"
+	depends on MODULES
+	help
+	  This option creates a separate environment file (barebox_modules_env)
+	  containing all built modules in stripped form. This environment is
+	  not built into barebox but can be flashed separately and mounted
+	  at runtime to load modules.
+
+	  The modules are taken from the barebox/ directory inside $MODLIB
+	  after running modules_install and have been stripped.
+
+	  If unsure, say n here.
+
 config KALLSYMS
 	depends on HAS_KALLSYMS
 	bool "kallsyms"
diff --git a/defaultenv/.gitignore b/defaultenv/.gitignore
index d14aa0f494b5..7847b5ce19d6 100644
--- a/defaultenv/.gitignore
+++ b/defaultenv/.gitignore
@@ -2,4 +2,5 @@
 
 barebox_default_env*
 barebox_zero_env
+barebox_modules_env
 defaultenv-2-ikconfig/
-- 
2.47.3




^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 13/13] test: arm: add simple driver/command module test
  2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
                   ` (11 preceding siblings ...)
  2026-01-16 16:06 ` [PATCH 12/13] defaultenv: add barebox_modules_env target Ahmad Fatoum
@ 2026-01-16 16:06 ` Ahmad Fatoum
  2026-01-19  7:28 ` [PATCH 00/13] ARM32: modules: fix bitrot and add test Sascha Hauer
  13 siblings, 0 replies; 15+ messages in thread
From: Ahmad Fatoum @ 2026-01-16 16:06 UTC (permalink / raw)
  To: barebox; +Cc: David Dgien, Claude, Ahmad Fatoum

To make sure that this experimental command support doesn't bitrot, add
two tests to exercise it:

  - The ECAM PCI driver module is loaded and we verify that PCI devices
    are only detected after it was loaded

  - The pm_domain command module is loaded and we verify that the
    command only exists after it was loaded

The pm_domain command was chosen, because the resulting module has no
references to _GLOBAL_OFFSET_TABLE_ as this seems to be not yet supported.

The hope is that modules32_defconfig will be removed in future in favor
of a fragment that just enables modules on top of
multi_v7_defconfig.yaml. This is not yet possible, however, because not
all drivers have been fixed yet to be able to build with CONFIG_MODULES
(repeated EXPORT_SYMBOL are a common issue for example).

Co-developed-by: Claude <noreply@claude.ai>
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 .github/workflows/test-labgrid-pytest.yml |   4 +
 arch/arm/configs/modules32_defconfig      | 230 ++++++++++++++++++++++
 test/arm/modules32_defconfig.yaml         |  27 +++
 test/py/test_module.py                    |  54 +++++
 4 files changed, 315 insertions(+)
 create mode 100644 arch/arm/configs/modules32_defconfig
 create mode 100644 test/arm/modules32_defconfig.yaml
 create mode 100644 test/py/test_module.py

diff --git a/.github/workflows/test-labgrid-pytest.yml b/.github/workflows/test-labgrid-pytest.yml
index d387f9e3867a..c06bc5f11faa 100644
--- a/.github/workflows/test-labgrid-pytest.yml
+++ b/.github/workflows/test-labgrid-pytest.yml
@@ -23,6 +23,10 @@ jobs:
             lgenv: 'test/arm/*@multi_v7_defconfig.yaml'
             defconfig: multi_v7_defconfig
 
+          - ARCH: arm
+            lgenv: 'test/arm/modules32_defconfig.yaml'
+            defconfig: modules32_defconfig
+
           - ARCH: arm
             lgenv: test/arm/multi_v8_defconfig.yaml
             defconfig: multi_v8_defconfig
diff --git a/arch/arm/configs/modules32_defconfig b/arch/arm/configs/modules32_defconfig
new file mode 100644
index 000000000000..0e32a4dd9c3e
--- /dev/null
+++ b/arch/arm/configs/modules32_defconfig
@@ -0,0 +1,230 @@
+CONFIG_ARCH_LAYERSCAPE=y
+CONFIG_ARCH_SAMSUNG=y
+CONFIG_ARCH_VERSATILE=y
+CONFIG_ARCH_VEXPRESS=y
+CONFIG_MACH_VIRT=y
+CONFIG_AEABI=y
+CONFIG_ARM_BOARD_APPEND_ATAG=y
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+CONFIG_ARM_EXCEPTIONS_PBL=y
+CONFIG_ARM_UNWIND=y
+# CONFIG_ARM_MMU_PERMISSIONS is not set
+CONFIG_ARM_SEMIHOSTING=y
+CONFIG_BOOT_ATAGS=y
+CONFIG_ARM_BOOTM_FIP=y
+CONFIG_NAME="modules32_defconfig"
+CONFIG_MMU=y
+CONFIG_MALLOC_SIZE=0x0
+CONFIG_EXPERIMENTAL=y
+CONFIG_MODULES=y
+CONFIG_MODULES_ENVIRONMENT=y
+CONFIG_KALLSYMS=y
+CONFIG_PROMPT="barebox> "
+CONFIG_HUSH_FANCY_PROMPT=y
+CONFIG_AUTO_COMPLETE=y
+CONFIG_MENU=y
+# CONFIG_TIMESTAMP is not set
+CONFIG_BOOTM_SHOW_TYPE=y
+CONFIG_BOOTM_VERBOSE=y
+CONFIG_BOOTM_INITRD=y
+CONFIG_BOOTM_OFTREE_UIMAGE=y
+CONFIG_BOOTM_AIMAGE=y
+CONFIG_BOOTM_FITIMAGE=y
+CONFIG_BLSPEC=y
+CONFIG_CONSOLE_ALLOW_COLOR=y
+CONFIG_PBL_CONSOLE=y
+CONFIG_CONSOLE_RATP=y
+CONFIG_RATP_CMD_I2C=y
+CONFIG_RATP_CMD_GPIO=y
+CONFIG_PARTITION_DISK_EFI=y
+# CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE is not set
+# CONFIG_PARTITION_DISK_EFI_GPT_COMPARE is not set
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW_REBOOT_MODE=y
+CONFIG_TLV=y
+CONFIG_STATE=y
+CONFIG_BOOTCHOOSER=y
+CONFIG_RESET_SOURCE=y
+CONFIG_MACHINE_ID=y
+CONFIG_FASTBOOT_CMD_OEM=y
+CONFIG_CMD_CLASS=y
+CONFIG_CMD_DMESG=y
+CONFIG_LONGHELP=y
+CONFIG_CMD_IOMEM=y
+CONFIG_CMD_IMD=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_ARM_MMUINFO=y
+CONFIG_CMD_REGULATOR=y
+CONFIG_CMD_PM_DOMAIN=m
+CONFIG_CMD_BFETCH=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_MMC_EXTCSD=y
+# CONFIG_CMD_BOOTU is not set
+CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_GO=y
+CONFIG_CMD_LOADB=y
+CONFIG_CMD_RESET=y
+CONFIG_CMD_UIMAGE=y
+CONFIG_CMD_BOOTCHOOSER=y
+CONFIG_CMD_PARTITION=y
+CONFIG_CMD_FINDMNT=y
+CONFIG_CMD_UBIFORMAT=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_DEFAULTENV=y
+CONFIG_CMD_LOADENV=y
+CONFIG_CMD_PRINTENV=y
+CONFIG_CMD_MAGICVAR=y
+CONFIG_CMD_MAGICVAR_HELP=y
+CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_FILETYPE=y
+CONFIG_CMD_LN=y
+CONFIG_CMD_MD5SUM=y
+CONFIG_CMD_SHA1SUM=y
+CONFIG_CMD_SHA224SUM=y
+CONFIG_CMD_SHA256SUM=y
+CONFIG_CMD_UNCOMPRESS=y
+CONFIG_CMD_LET=y
+CONFIG_CMD_MSLEEP=y
+CONFIG_CMD_READF=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MIITOOL=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_TFTP=y
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_MENU=y
+CONFIG_CMD_MENU_MANAGEMENT=y
+CONFIG_CMD_MENUTREE=y
+CONFIG_CMD_SPLASH=y
+CONFIG_CMD_FBTEST=y
+CONFIG_CMD_READLINE=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_CRC=y
+CONFIG_CMD_CRC_CMP=y
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_MM=y
+CONFIG_CMD_CLK=y
+CONFIG_CMD_DETECT=y
+CONFIG_CMD_FLASH=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_LED=y
+CONFIG_CMD_NANDTEST=y
+CONFIG_CMD_POWEROFF=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_LED_TRIGGER=y
+CONFIG_CMD_BAREBOX_UPDATE=y
+CONFIG_CMD_LSMOD=y
+CONFIG_CMD_OF_DIFF=y
+CONFIG_CMD_OF_NODE=y
+CONFIG_CMD_OF_PROPERTY=y
+CONFIG_CMD_OF_DISPLAY_TIMINGS=y
+CONFIG_CMD_OF_FIXUP_STATUS=y
+CONFIG_CMD_OF_OVERLAY=y
+CONFIG_CMD_OFTREE=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_TLV=y
+CONFIG_NET=y
+CONFIG_NET_NETCONSOLE=y
+CONFIG_NET_FASTBOOT=y
+CONFIG_NET_9P=y
+CONFIG_NET_9P_VIRTIO=y
+CONFIG_DEEP_PROBE_DEFAULT=y
+CONFIG_OF_BAREBOX_DRIVERS=y
+CONFIG_SERIAL_AMBA_PL011=y
+CONFIG_DRIVER_SERIAL_NS16550=y
+CONFIG_VIRTIO_CONSOLE=y
+CONFIG_DRIVER_NET_SMC91111=y
+CONFIG_AT803X_PHY=y
+CONFIG_MICREL_PHY=y
+CONFIG_REALTEK_PHY=y
+CONFIG_SMSC_PHY=y
+CONFIG_MDIO_BITBANG=y
+CONFIG_MDIO_GPIO=y
+CONFIG_MDIO_BUS_MUX_GPIO=y
+CONFIG_DSA=y
+CONFIG_DRIVER_NET_KSZ8873=y
+CONFIG_DRIVER_SPI_GPIO=y
+CONFIG_I2C=y
+CONFIG_I2C_VERSATILE=y
+CONFIG_I2C_MUX=y
+CONFIG_MTD=y
+CONFIG_MTD_RAW_DEVICE=y
+CONFIG_MTD_CONCAT=y
+CONFIG_MTD_DATAFLASH=y
+CONFIG_MTD_M25P80=y
+CONFIG_DRIVER_CFI=y
+CONFIG_NAND=y
+CONFIG_NAND_ALLOW_ERASE_BAD=y
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_FASTMAP=y
+CONFIG_VIRTIO_BLK=y
+CONFIG_DISK_AHCI=y
+CONFIG_DISK_INTF_PLATFORM_IDE=y
+CONFIG_VIDEO=y
+CONFIG_DRIVER_VIDEO_FB_SSD1307=y
+CONFIG_DRIVER_VIDEO_SIMPLEFB=y
+CONFIG_DRIVER_VIDEO_EDID=y
+CONFIG_DRIVER_VIDEO_BACKLIGHT=y
+CONFIG_DRIVER_VIDEO_BACKLIGHT_PWM=y
+CONFIG_DRIVER_VIDEO_SIMPLE_PANEL=y
+CONFIG_DRIVER_VIDEO_DW_HDMI=y
+CONFIG_MCI=y
+CONFIG_MCI_STARTUP=y
+CONFIG_MCI_MMC_BOOT_PARTITIONS=y
+CONFIG_MCI_MMCI=y
+CONFIG_COMMON_CLK_SCMI=y
+CONFIG_MFD_DA9063=y
+CONFIG_MFD_STMPE=y
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
+CONFIG_LED_GPIO_OF=y
+CONFIG_LED_TRIGGERS=y
+CONFIG_EEPROM_AT25=y
+CONFIG_EEPROM_AT24=y
+CONFIG_KEYBOARD_GPIO=y
+CONFIG_INPUT_SPECIALKEYS=y
+CONFIG_PWM=y
+CONFIG_HWRNG=y
+CONFIG_HW_RANDOM_VIRTIO=y
+CONFIG_GPIO_74164=y
+CONFIG_GPIO_GENERIC_PLATFORM=y
+CONFIG_GPIO_STMPE=y
+CONFIG_PINCTRL_SINGLE=y
+CONFIG_REGULATOR=y
+CONFIG_REGULATOR_FIXED=y
+CONFIG_REGULATOR_ARM_SCMI=y
+CONFIG_RESET_CONTROLLER=y
+CONFIG_PCI_ECAM_GENERIC=m
+CONFIG_ARM_SCMI_PROTOCOL=y
+CONFIG_SYSCON_REBOOT_MODE=y
+CONFIG_POWER_RESET_SYSCON=y
+CONFIG_VIRTIO_MMIO=y
+CONFIG_TEE=y
+CONFIG_OPTEE=y
+CONFIG_OPTEE_AVB_PERSISTENT_VALUES=y
+CONFIG_FS_EXT4=y
+CONFIG_FS_TFTP=y
+CONFIG_FS_NFS=y
+CONFIG_9P_FS=y
+CONFIG_9P_FS_WRITE=y
+CONFIG_FS_FAT=y
+CONFIG_FS_FAT_WRITE=y
+CONFIG_FS_UBIFS=y
+CONFIG_FS_UBIFS_COMPRESSION_LZO=y
+CONFIG_FS_UBIFS_COMPRESSION_ZLIB=y
+CONFIG_FS_UBIFS_COMPRESSION_ZSTD=y
+CONFIG_FS_UIMAGEFS=y
+CONFIG_FS_SMHFS=y
+CONFIG_FS_PSTORE=y
+CONFIG_FS_PSTORE_CONSOLE=y
+CONFIG_FS_PSTORE_RAMOOPS=y
+CONFIG_FS_SQUASHFS=y
+CONFIG_FS_RATP=y
+CONFIG_FS_QEMU_FW_CFG=y
+CONFIG_DIGEST_SHA1_ARM=y
+CONFIG_DIGEST_SHA256_ARM=y
+CONFIG_CRC8=y
+CONFIG_PNG=y
+CONFIG_NLS=y
diff --git a/test/arm/modules32_defconfig.yaml b/test/arm/modules32_defconfig.yaml
new file mode 100644
index 000000000000..aa01881f0ecc
--- /dev/null
+++ b/test/arm/modules32_defconfig.yaml
@@ -0,0 +1,27 @@
+targets:
+  main:
+    drivers:
+      QEMUDriver:
+        qemu_bin: qemu-system-arm
+        machine: virt
+        cpu: cortex-a7
+        memory: 64M  # To avoid indirection via (unsupported) PLTs
+        bios: barebox-qemu-virt.img
+        display: qemu-default
+      BareboxDriver:
+        prompt: 'barebox@[^:]+:[^ ]+ '
+        bootstring: 'commandline:'
+      BareboxTestStrategy: {}
+    features:
+      - virtio-mmio
+      - testfs
+      - modules
+    env:
+      data/modules.env: !template "@$LG_BUILDDIR/defaultenv/barebox_modules_env"
+      init/loadenv-modules: |
+        #!/bin/sh
+        loadenv /env/data/modules.env /modules
+images:
+  barebox-qemu-virt.img: !template "$LG_BUILDDIR/images/barebox-qemu-virt.img"
+imports:
+  - ../strategy.py
diff --git a/test/py/test_module.py b/test/py/test_module.py
new file mode 100644
index 000000000000..de9112852651
--- /dev/null
+++ b/test/py/test_module.py
@@ -0,0 +1,54 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+import pytest
+from .helper import skip_disabled
+
+
+def test_insmod_driver(barebox, barebox_config, env):
+    """Test that insmod works for drivers."""
+    skip_disabled(barebox_config, "CONFIG_MODULES", "CONFIG_CMD_LSMOD")
+
+    if 'modules' not in env.get_target_features():
+        pytest.skip("modules feature not enabled for this board")
+
+    [stdout], _, ret = barebox.run("lspci")
+    assert ret != 0, "Test assumes all PCI drivers are modules"
+    assert stdout == "No PCI bus detected"
+
+    # First load the module
+    barebox.run_check("insmod /modules/drivers/pci/pci-ecam-generic.ko")
+
+    # Check lsmod output
+    stdout = barebox.run_check("lsmod")
+    output = "\n".join(stdout)
+    assert "pci_ecam_generic" in output, \
+        f"Module not found in lsmod output: {output}"
+
+    stdout, _, ret = barebox.run("lspci")
+    assert ret == 0, "Loading PCI driver should result in PCI bus detection"
+    assert len(stdout) > 1 or stdout[0] != "No PCI bus detected"
+
+
+def test_insmod_command(barebox, barebox_config, env):
+    """Test that insmod works for commands."""
+    skip_disabled(barebox_config, "CONFIG_MODULES", "CONFIG_CMD_LSMOD")
+
+    if 'modules' not in env.get_target_features():
+        pytest.skip("modules feature not enabled for this board")
+
+    [stdout], _, ret = barebox.run("pm_domain")
+    assert ret != 0, "pm_domain shouldn't yet exist"
+    assert stdout == "pm_domain: Command not found"
+
+    # First load the module
+    barebox.run_check("insmod /modules/commands/pm_domain.ko")
+
+    # Check lsmod output
+    stdout = barebox.run_check("lsmod")
+    output = "\n".join(stdout)
+    assert "pm_domain" in output, \
+        f"Module not found in lsmod output: {output}"
+
+    stdout, _, ret = barebox.run("pm_domain")
+    assert ret == 0, "pm_domain should exist now"
+    assert stdout[0] != "pm_domain: Command not found"
-- 
2.47.3




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 00/13] ARM32: modules: fix bitrot and add test
  2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
                   ` (12 preceding siblings ...)
  2026-01-16 16:06 ` [PATCH 13/13] test: arm: add simple driver/command module test Ahmad Fatoum
@ 2026-01-19  7:28 ` Sascha Hauer
  13 siblings, 0 replies; 15+ messages in thread
From: Sascha Hauer @ 2026-01-19  7:28 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum; +Cc: David Dgien


On Fri, 16 Jan 2026 17:06:23 +0100, Ahmad Fatoum wrote:
> v1 -> v2:
>   - drop <fdt.h> include in <compressed-dtb.h> in favor of
>     https://lore.barebox.org/barebox/20260114120221.941836-3-a.fatoum@pengutronix.de/T/#m191aec342beb0a80468f5c18a7cdd58dedad08ad
>   - patch 01/13 is new to allow deleting the .tmp_barebox_modules_env
>     directory
>   - renamed virt-el2@multi_v8_defconfig.yaml to dt-2nd@multi_v8_defconfig.yaml
>   - added YAML configs for ARM32 as well (Sascha)
>   - changed printf in lowlevel.c to pr_info (Sascha)
> 
> [...]

Applied, thanks!

[01/13] kbuild: fold rmdirs into rmfiles
        https://git.pengutronix.de/cgit/barebox/commit/?id=9914f8fdddac (link may not be stable)
[02/13] boards: qemu-virt: reserve BIOS device tree
        https://git.pengutronix.de/cgit/barebox/commit/?id=e6b570cd12cd (link may not be stable)
[03/13] ARM: qemu-virt: add image for use as -bios
        https://git.pengutronix.de/cgit/barebox/commit/?id=555631bf396a (link may not be stable)
[04/13] kbuild: build *.mod.c with -std=gnu11
        https://git.pengutronix.de/cgit/barebox/commit/?id=a9687a8f0af8 (link may not be stable)
[05/13] ARM32: mark modules as incompatible with ARM_MMU_PERMISSIONS
        https://git.pengutronix.de/cgit/barebox/commit/?id=8b26bb51e606 (link may not be stable)
[06/13] treewide: fix some missing EXPORT_SYMBOL
        https://git.pengutronix.de/cgit/barebox/commit/?id=20752da0f8b2 (link may not be stable)
[07/13] pci: ecam: enable build as module
        https://git.pengutronix.de/cgit/barebox/commit/?id=b317d4408c38 (link may not be stable)
[08/13] kbuild: add support for installing and stripping modules
        https://git.pengutronix.de/cgit/barebox/commit/?id=dbbd806920b3 (link may not be stable)
[09/13] ARM32: module: handle more relocations
        https://git.pengutronix.de/cgit/barebox/commit/?id=8ba9b6daf11c (link may not be stable)
[10/13] commands: pm_domain: make command tristate
        https://git.pengutronix.de/cgit/barebox/commit/?id=c49215926a57 (link may not be stable)
[11/13] test: conftest: add support for describing FW_CFG environment in YAML
        https://git.pengutronix.de/cgit/barebox/commit/?id=0590c54d58b1 (link may not be stable)
[12/13] defaultenv: add barebox_modules_env target
        https://git.pengutronix.de/cgit/barebox/commit/?id=b8d781f46605 (link may not be stable)
[13/13] test: arm: add simple driver/command module test
        https://git.pengutronix.de/cgit/barebox/commit/?id=469a1673c976 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-01-19  7:29 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-16 16:06 [PATCH 00/13] ARM32: modules: fix bitrot and add test Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 01/13] kbuild: fold rmdirs into rmfiles Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 02/13] boards: qemu-virt: reserve BIOS device tree Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 03/13] ARM: qemu-virt: add image for use as -bios Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 04/13] kbuild: build *.mod.c with -std=gnu11 Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 05/13] ARM32: mark modules as incompatible with ARM_MMU_PERMISSIONS Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 06/13] treewide: fix some missing EXPORT_SYMBOL Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 07/13] pci: ecam: enable build as module Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 08/13] kbuild: add support for installing and stripping modules Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 09/13] ARM32: module: handle more relocations Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 10/13] commands: pm_domain: make command tristate Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 11/13] test: conftest: add support for describing FW_CFG environment in YAML Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 12/13] defaultenv: add barebox_modules_env target Ahmad Fatoum
2026-01-16 16:06 ` [PATCH 13/13] test: arm: add simple driver/command module test Ahmad Fatoum
2026-01-19  7:28 ` [PATCH 00/13] ARM32: modules: fix bitrot and add test Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox