From 7117ebab0bc681aa6657202dd44c6b562335901b Mon Sep 17 00:00:00 2001 From: Chuanhong Guo Date: Fri, 28 Jun 2024 16:31:59 +0800 Subject: [PATCH 01/16] kernel: mtdsplit: fix fit rootfs_data split fit size should be rounded up instead of rounding down first and adding a block. Otherwise the calculated size is one block more than needed when fit size is exactly multiples of one block size. Fixes: 9a863f803ec1 ("kernel: mtdsplit: add support for FIT image") Signed-off-by: Chuanhong Guo Signed-off-by: Qingfang Deng --- .../linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c index 3b71597d23..a271a676e1 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c @@ -278,7 +278,7 @@ mtdsplit_fit_parse(struct mtd_info *mtd, parts[0].name = KERNEL_PART_NAME; parts[0].offset = fit_offset; - parts[0].size = mtd_rounddown_to_eb(fit_size + offset_start, mtd) + mtd->erasesize; + parts[0].size = mtd_roundup_to_eb(fit_size + offset_start, mtd); if (type == MTDSPLIT_PART_TYPE_UBI) parts[1].name = UBI_PART_NAME; @@ -327,7 +327,7 @@ mtdsplit_fit_parse(struct mtd_info *mtd, return -ENOMEM; parts[0].name = ROOTFS_SPLIT_NAME; - parts[0].offset = fit_offset + mtd_rounddown_to_eb(max_size, mtd) + mtd->erasesize; + parts[0].offset = fit_offset + mtd_roundup_to_eb(max_size, mtd); parts[0].size = mtd->size - parts[0].offset; *pparts = parts; From 2ded54972e5acb6df8c323a173a4d8ff27f9f1a0 Mon Sep 17 00:00:00 2001 From: Qingfang Deng Date: Fri, 28 Jun 2024 17:01:00 +0800 Subject: [PATCH 02/16] mediatek: fit: fix use of uninitialized variable When building the kernel with -Wmaybe-uninitialized, GCC reports this warning: block/partitions/fit.c: In function 'parse_fit_partitions': block/partitions/fit.c:164:3: warning: 'images' may be used uninitialized in this function [-Wmaybe-uninitialized] 164 | printk(KERN_ERR "FIT: Cannot find %s node: %d\n", FIT_CONFS_PATH, images); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It appears to be a copy paste error. It's the "config" variable that is supposed to be printed. Fixes: e6aac8d98f56 ("image: add support for building FIT image with filesystem") Signed-off-by: Qingfang Deng --- target/linux/mediatek/files/block/partitions/fit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/mediatek/files/block/partitions/fit.c b/target/linux/mediatek/files/block/partitions/fit.c index 463cd4e9ab..01b0f42c7c 100644 --- a/target/linux/mediatek/files/block/partitions/fit.c +++ b/target/linux/mediatek/files/block/partitions/fit.c @@ -161,7 +161,7 @@ int parse_fit_partitions(struct parsed_partitions *state, u64 fit_start_sector, config = fdt_path_offset(fit, FIT_CONFS_PATH); if (config < 0) { - printk(KERN_ERR "FIT: Cannot find %s node: %d\n", FIT_CONFS_PATH, images); + printk(KERN_ERR "FIT: Cannot find %s node: %d\n", FIT_CONFS_PATH, config); ret = -ENOENT; goto ret_out; } From 7bffb3f72bbfa06db5c61351f074533ac2d035a4 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Sun, 7 Jul 2024 18:24:24 +0200 Subject: [PATCH 03/16] kernel: fix CopyImage function with Per Device Rootfs Some target define custom kernel images with KERNEL_INITRAMFS_NAME to reference .elf variant of vmlinux. With Per Device Rootfs, the expected format is image.suffix.extension.ROOTFS_ID, while in CopyImage we are currently generating images with image.suffix.ROOTFS_ID.extension making some target failing. Fix CopyImage function to correctly follow the expected pattern. Fixes: 97fd059e7e6a ("image: respect TARGET_PER_DEVICE_ROOTFS for initramfs") Signed-off-by: Christian Marangi --- include/kernel-defaults.mk | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/include/kernel-defaults.mk b/include/kernel-defaults.mk index 84d686cafc..46045b0ed7 100644 --- a/include/kernel-defaults.mk +++ b/include/kernel-defaults.mk @@ -136,14 +136,16 @@ ifeq ($(LINUX_KARCH),x86_64) IMAGES_DIR:=../../x86/boot endif +# $1: image suffix +# $2: Per Device Rootfs ID define Kernel/CopyImage - cmp -s $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux$(1).debug || { \ - $(KERNEL_CROSS)objcopy -O binary $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)$(1); \ - $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux$(1).elf; \ - $(CP) $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux$(1).debug; \ + cmp -s $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux$(1).debug$(2) || { \ + $(KERNEL_CROSS)objcopy -O binary $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)$(1)$(2); \ + $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux$(1).elf$(2); \ + $(CP) $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux$(1).debug$(2); \ $(foreach k, \ $(if $(KERNEL_IMAGES),$(KERNEL_IMAGES),$(filter-out vmlinux dtbs,$(KERNELNAME))), \ - $(CP) $(LINUX_DIR)/arch/$(LINUX_KARCH)/boot/$(IMAGES_DIR)/$(k) $(KERNEL_BUILD_DIR)/$(k)$(1); \ + $(CP) $(LINUX_DIR)/arch/$(LINUX_KARCH)/boot/$(IMAGES_DIR)/$(k) $(KERNEL_BUILD_DIR)/$(k)$(1)$(2); \ ) \ } endef @@ -188,7 +190,7 @@ else +$(call locked,$(if $(2),$(CP) $(LINUX_DIR)$(2)/.config* $(LINUX_DIR) && touch $(LINUX_DIR)/.config && )\ rm -rf $(LINUX_DIR)/usr/initramfs_data.cpio* $(LINUX_DIR)/.config.prev && \ $(KERNEL_MAKE) $(KERNEL_MAKEOPTS_IMAGE) $(if $(KERNELNAME),$(KERNELNAME),all) && \ - { $(call Kernel/CopyImage,-initramfs$(2)) },gen-initramfs) + { $(call Kernel/CopyImage,-initramfs,$(2)) },gen-initramfs) endif endef else From a307f8f84b9e3753b6c033525aebda2b5b852392 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 7 Jul 2024 21:25:22 +0100 Subject: [PATCH 04/16] procd: bump to git HEAD f230c11 utils: use strlcpy when appropriate a8cf548 jail: fix copy & paste error in parseOCIlinux() 1e411a5 utils: get_cmdline_val: add missing error check Signed-off-by: Daniel Golle --- package/system/procd/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile index dca6684df8..faf72a407d 100644 --- a/package/system/procd/Makefile +++ b/package/system/procd/Makefile @@ -12,9 +12,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/procd.git -PKG_MIRROR_HASH:=ad1e0d6c2549b2ebec57705c33b231e7c02042dd65c3134f62bf528cf2516efb -PKG_SOURCE_DATE:=2024-03-30 -PKG_SOURCE_VERSION:=946552a7b598a0b88db6101e864679554ec4f221 +PKG_MIRROR_HASH:=9a0f7a5dfc883e7ea2f7f779e2e68f93507477ca780945219f808b145db5e71d +PKG_SOURCE_DATE:=2024-07-07 +PKG_SOURCE_VERSION:=f230c11771875adc1f74bef013e8cea1fa1867bc CMAKE_INSTALL:=1 PKG_LICENSE:=GPL-2.0 From e7599942af8e14541166234349e9e49278455ef6 Mon Sep 17 00:00:00 2001 From: Zxl hhyccc Date: Sat, 6 Jul 2024 02:29:52 +0800 Subject: [PATCH 05/16] kernel: bump 6.1 to 6.1.97 https://cdn.kernel.org/pub/linux/kernel/v6.x/ChangeLog-6.1.97 All patches automatically rebased. Build system: Kirkwood bcm53xx Signed-off-by: Zxl hhyccc Link: https://github.com/openwrt/openwrt/pull/15883 Signed-off-by: Hauke Mehrtens --- include/kernel-6.1 | 4 ++-- ...1-net-dpaa2-eth-don-t-use-ENOTSUPP-error-code.patch | 2 +- ...a2-eth-assign-priv-mac-after-dpaa2_mac_connec.patch | 6 +++--- ...a2-eth-connect-to-MAC-before-requesting-the-e.patch | 10 +++++----- ...a2-eth-serialize-changes-to-priv-mac-with-a-m.patch | 10 +++++----- ...-dpaa2-mac-move-rtnl_lock-only-around-phylink.patch | 6 +++--- ...T-mm-multi-gen-LRU-per-node-lru_gen_folio-lis.patch | 4 ++-- ...alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch | 2 +- ...er-nf_tables-ignore-EOPNOTSUPP-on-flowtable-d.patch | 2 +- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/kernel-6.1 b/include/kernel-6.1 index e8acd5ca1f..d67049a6b3 100644 --- a/include/kernel-6.1 +++ b/include/kernel-6.1 @@ -1,2 +1,2 @@ -LINUX_VERSION-6.1 = .96 -LINUX_KERNEL_HASH-6.1.96 = 3e77c9069de5e7ab02ff9c2dcfe77dab193613fc1de21071901b4153374862a9 +LINUX_VERSION-6.1 = .97 +LINUX_KERNEL_HASH-6.1.97 = 890b845f36452328716e62dd893b634584f607cdd44b4e685392d302d3be41af diff --git a/target/linux/armsr/patches-6.1/701-v6.2-0001-net-dpaa2-eth-don-t-use-ENOTSUPP-error-code.patch b/target/linux/armsr/patches-6.1/701-v6.2-0001-net-dpaa2-eth-don-t-use-ENOTSUPP-error-code.patch index ec72f91d0f..f173cad7ef 100644 --- a/target/linux/armsr/patches-6.1/701-v6.2-0001-net-dpaa2-eth-don-t-use-ENOTSUPP-error-code.patch +++ b/target/linux/armsr/patches-6.1/701-v6.2-0001-net-dpaa2-eth-don-t-use-ENOTSUPP-error-code.patch @@ -22,7 +22,7 @@ Signed-off-by: Paolo Abeni --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c -@@ -3614,7 +3614,7 @@ static int dpaa2_eth_setup_dpni(struct f +@@ -3618,7 +3618,7 @@ static int dpaa2_eth_setup_dpni(struct f dev_err(dev, "DPNI version %u.%u not supported, need >= %u.%u\n", priv->dpni_ver_major, priv->dpni_ver_minor, DPNI_VER_MAJOR, DPNI_VER_MINOR); diff --git a/target/linux/armsr/patches-6.1/701-v6.2-0005-net-dpaa2-eth-assign-priv-mac-after-dpaa2_mac_connec.patch b/target/linux/armsr/patches-6.1/701-v6.2-0005-net-dpaa2-eth-assign-priv-mac-after-dpaa2_mac_connec.patch index c31a470182..bd27c8be20 100644 --- a/target/linux/armsr/patches-6.1/701-v6.2-0005-net-dpaa2-eth-assign-priv-mac-after-dpaa2_mac_connec.patch +++ b/target/linux/armsr/patches-6.1/701-v6.2-0005-net-dpaa2-eth-assign-priv-mac-after-dpaa2_mac_connec.patch @@ -49,7 +49,7 @@ Signed-off-by: Paolo Abeni --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c -@@ -4444,9 +4444,8 @@ static int dpaa2_eth_connect_mac(struct +@@ -4448,9 +4448,8 @@ static int dpaa2_eth_connect_mac(struct err = dpaa2_mac_open(mac); if (err) goto err_free_mac; @@ -60,7 +60,7 @@ Signed-off-by: Paolo Abeni err = dpaa2_mac_connect(mac); if (err && err != -EPROBE_DEFER) netdev_err(priv->net_dev, "Error connecting to the MAC endpoint: %pe", -@@ -4455,11 +4454,12 @@ static int dpaa2_eth_connect_mac(struct +@@ -4459,11 +4458,12 @@ static int dpaa2_eth_connect_mac(struct goto err_close_mac; } @@ -74,7 +74,7 @@ Signed-off-by: Paolo Abeni err_free_mac: kfree(mac); return err; -@@ -4467,15 +4467,18 @@ err_free_mac: +@@ -4471,15 +4471,18 @@ err_free_mac: static void dpaa2_eth_disconnect_mac(struct dpaa2_eth_priv *priv) { diff --git a/target/linux/armsr/patches-6.1/701-v6.2-0009-net-dpaa2-eth-connect-to-MAC-before-requesting-the-e.patch b/target/linux/armsr/patches-6.1/701-v6.2-0009-net-dpaa2-eth-connect-to-MAC-before-requesting-the-e.patch index 4e39e9a0ac..246cd633ba 100644 --- a/target/linux/armsr/patches-6.1/701-v6.2-0009-net-dpaa2-eth-connect-to-MAC-before-requesting-the-e.patch +++ b/target/linux/armsr/patches-6.1/701-v6.2-0009-net-dpaa2-eth-connect-to-MAC-before-requesting-the-e.patch @@ -33,7 +33,7 @@ Signed-off-by: Paolo Abeni --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c -@@ -4711,6 +4711,10 @@ static int dpaa2_eth_probe(struct fsl_mc +@@ -4715,6 +4715,10 @@ static int dpaa2_eth_probe(struct fsl_mc } #endif @@ -44,7 +44,7 @@ Signed-off-by: Paolo Abeni err = dpaa2_eth_setup_irqs(dpni_dev); if (err) { netdev_warn(net_dev, "Failed to set link interrupt, fall back to polling\n"); -@@ -4723,10 +4727,6 @@ static int dpaa2_eth_probe(struct fsl_mc +@@ -4727,10 +4731,6 @@ static int dpaa2_eth_probe(struct fsl_mc priv->do_link_poll = true; } @@ -55,7 +55,7 @@ Signed-off-by: Paolo Abeni err = dpaa2_eth_dl_alloc(priv); if (err) goto err_dl_register; -@@ -4762,13 +4762,13 @@ err_dl_port_add: +@@ -4766,13 +4766,13 @@ err_dl_port_add: err_dl_trap_register: dpaa2_eth_dl_free(priv); err_dl_register: @@ -71,7 +71,7 @@ Signed-off-by: Paolo Abeni dpaa2_eth_free_rings(priv); err_alloc_rings: err_csum: -@@ -4816,9 +4816,6 @@ static int dpaa2_eth_remove(struct fsl_m +@@ -4820,9 +4820,6 @@ static int dpaa2_eth_remove(struct fsl_m #endif unregister_netdev(net_dev); @@ -81,7 +81,7 @@ Signed-off-by: Paolo Abeni dpaa2_eth_dl_port_del(priv); dpaa2_eth_dl_traps_unregister(priv); -@@ -4829,6 +4826,9 @@ static int dpaa2_eth_remove(struct fsl_m +@@ -4833,6 +4830,9 @@ static int dpaa2_eth_remove(struct fsl_m else fsl_mc_free_irqs(ls_dev); diff --git a/target/linux/armsr/patches-6.1/701-v6.2-0010-net-dpaa2-eth-serialize-changes-to-priv-mac-with-a-m.patch b/target/linux/armsr/patches-6.1/701-v6.2-0010-net-dpaa2-eth-serialize-changes-to-priv-mac-with-a-m.patch index 9b068ce8f5..553870d8ec 100644 --- a/target/linux/armsr/patches-6.1/701-v6.2-0010-net-dpaa2-eth-serialize-changes-to-priv-mac-with-a-m.patch +++ b/target/linux/armsr/patches-6.1/701-v6.2-0010-net-dpaa2-eth-serialize-changes-to-priv-mac-with-a-m.patch @@ -121,7 +121,7 @@ Signed-off-by: Paolo Abeni return -EOPNOTSUPP; } -@@ -4454,7 +4474,9 @@ static int dpaa2_eth_connect_mac(struct +@@ -4458,7 +4478,9 @@ static int dpaa2_eth_connect_mac(struct goto err_close_mac; } @@ -131,7 +131,7 @@ Signed-off-by: Paolo Abeni return 0; -@@ -4467,9 +4489,12 @@ err_free_mac: +@@ -4471,9 +4493,12 @@ err_free_mac: static void dpaa2_eth_disconnect_mac(struct dpaa2_eth_priv *priv) { @@ -145,7 +145,7 @@ Signed-off-by: Paolo Abeni if (!mac) return; -@@ -4488,6 +4513,7 @@ static irqreturn_t dpni_irq0_handler_thr +@@ -4492,6 +4517,7 @@ static irqreturn_t dpni_irq0_handler_thr struct fsl_mc_device *dpni_dev = to_fsl_mc_device(dev); struct net_device *net_dev = dev_get_drvdata(dev); struct dpaa2_eth_priv *priv = netdev_priv(net_dev); @@ -153,7 +153,7 @@ Signed-off-by: Paolo Abeni int err; err = dpni_get_irq_status(dpni_dev->mc_io, 0, dpni_dev->mc_handle, -@@ -4505,7 +4531,12 @@ static irqreturn_t dpni_irq0_handler_thr +@@ -4509,7 +4535,12 @@ static irqreturn_t dpni_irq0_handler_thr dpaa2_eth_update_tx_fqids(priv); rtnl_lock(); @@ -167,7 +167,7 @@ Signed-off-by: Paolo Abeni dpaa2_eth_disconnect_mac(priv); else dpaa2_eth_connect_mac(priv); -@@ -4606,6 +4637,8 @@ static int dpaa2_eth_probe(struct fsl_mc +@@ -4610,6 +4641,8 @@ static int dpaa2_eth_probe(struct fsl_mc priv = netdev_priv(net_dev); priv->net_dev = net_dev; diff --git a/target/linux/armsr/patches-6.1/701-v6.2-0012-net-dpaa2-mac-move-rtnl_lock-only-around-phylink.patch b/target/linux/armsr/patches-6.1/701-v6.2-0012-net-dpaa2-mac-move-rtnl_lock-only-around-phylink.patch index 521c9d4a54..5de2137002 100644 --- a/target/linux/armsr/patches-6.1/701-v6.2-0012-net-dpaa2-mac-move-rtnl_lock-only-around-phylink.patch +++ b/target/linux/armsr/patches-6.1/701-v6.2-0012-net-dpaa2-mac-move-rtnl_lock-only-around-phylink.patch @@ -34,7 +34,7 @@ Signed-off-by: Paolo Abeni --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c -@@ -4530,7 +4530,6 @@ static irqreturn_t dpni_irq0_handler_thr +@@ -4534,7 +4534,6 @@ static irqreturn_t dpni_irq0_handler_thr dpaa2_eth_set_mac_addr(netdev_priv(net_dev)); dpaa2_eth_update_tx_fqids(priv); @@ -42,7 +42,7 @@ Signed-off-by: Paolo Abeni /* We can avoid locking because the "endpoint changed" IRQ * handler is the only one who changes priv->mac at runtime, * so we are not racing with anyone. -@@ -4540,7 +4539,6 @@ static irqreturn_t dpni_irq0_handler_thr +@@ -4544,7 +4543,6 @@ static irqreturn_t dpni_irq0_handler_thr dpaa2_eth_disconnect_mac(priv); else dpaa2_eth_connect_mac(priv); @@ -50,7 +50,7 @@ Signed-off-by: Paolo Abeni } return IRQ_HANDLED; -@@ -4859,9 +4857,7 @@ static int dpaa2_eth_remove(struct fsl_m +@@ -4863,9 +4861,7 @@ static int dpaa2_eth_remove(struct fsl_m else fsl_mc_free_irqs(ls_dev); diff --git a/target/linux/generic/backport-6.1/020-v6.3-06-BACKPORT-mm-multi-gen-LRU-per-node-lru_gen_folio-lis.patch b/target/linux/generic/backport-6.1/020-v6.3-06-BACKPORT-mm-multi-gen-LRU-per-node-lru_gen_folio-lis.patch index 69f52fa403..7756d19d9b 100644 --- a/target/linux/generic/backport-6.1/020-v6.3-06-BACKPORT-mm-multi-gen-LRU-per-node-lru_gen_folio-lis.patch +++ b/target/linux/generic/backport-6.1/020-v6.3-06-BACKPORT-mm-multi-gen-LRU-per-node-lru_gen_folio-lis.patch @@ -297,7 +297,7 @@ Signed-off-by: T.J. Mercier #endif /* CONFIG_LRU_GEN */ -@@ -1219,6 +1330,8 @@ typedef struct pglist_data { +@@ -1218,6 +1329,8 @@ typedef struct pglist_data { #ifdef CONFIG_LRU_GEN /* kswap mm walk data */ struct lru_gen_mm_walk mm_walk; @@ -361,7 +361,7 @@ Signed-off-by: T.J. Mercier static void mem_cgroup_css_free(struct cgroup_subsys_state *css) --- a/mm/page_alloc.c +++ b/mm/page_alloc.c -@@ -7945,6 +7945,7 @@ static void __init free_area_init_node(i +@@ -7949,6 +7949,7 @@ static void __init free_area_init_node(i pgdat_set_deferred_range(pgdat); free_area_init_core(pgdat); diff --git a/target/linux/generic/pending-6.1/120-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch b/target/linux/generic/pending-6.1/120-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch index a3d66c54b3..edee0e46a5 100644 --- a/target/linux/generic/pending-6.1/120-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch +++ b/target/linux/generic/pending-6.1/120-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch @@ -71,7 +71,7 @@ Signed-off-by: Tobias Wolf --- a/mm/page_alloc.c +++ b/mm/page_alloc.c -@@ -7899,7 +7899,7 @@ static void __init alloc_node_mem_map(st +@@ -7903,7 +7903,7 @@ static void __init alloc_node_mem_map(st if (pgdat == NODE_DATA(0)) { mem_map = NODE_DATA(0)->node_mem_map; if (page_to_pfn(mem_map) != pgdat->node_start_pfn) diff --git a/target/linux/generic/pending-6.1/701-netfilter-nf_tables-ignore-EOPNOTSUPP-on-flowtable-d.patch b/target/linux/generic/pending-6.1/701-netfilter-nf_tables-ignore-EOPNOTSUPP-on-flowtable-d.patch index 9f8c3d6ff5..916b6bc6a0 100644 --- a/target/linux/generic/pending-6.1/701-netfilter-nf_tables-ignore-EOPNOTSUPP-on-flowtable-d.patch +++ b/target/linux/generic/pending-6.1/701-netfilter-nf_tables-ignore-EOPNOTSUPP-on-flowtable-d.patch @@ -18,7 +18,7 @@ Signed-off-by: Felix Fietkau --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c -@@ -7959,7 +7959,7 @@ static int nft_register_flowtable_net_ho +@@ -7958,7 +7958,7 @@ static int nft_register_flowtable_net_ho err = flowtable->data.type->setup(&flowtable->data, hook->ops.dev, FLOW_BLOCK_BIND); From f9a1996367628d4e5a0849f58a2d29abb6b89bd5 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 15 May 2024 19:43:00 -0400 Subject: [PATCH 06/16] tools/elfutils: remove header symlink between subdirectories Replace the symlink in the build recipe for gnulib with an extra include path flag in CPPFLAGS to the lib subdirectory so that it is the last in the order of include paths, and use a quote escape to make the flag a literal string in order to use Make variables within it. The original reason this is necessary is because the config.h header provided by the project at the top-level build directory calls another header eu-config.h which is stored in the lib subdirectory instead of the top-level, and building the gnulib library requires the config.h header. Signed-off-by: Michael Pratt Link: https://github.com/openwrt/openwrt/pull/15853 Signed-off-by: Robert Marko --- tools/elfutils/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/elfutils/Makefile b/tools/elfutils/Makefile index 11a2ff7261..bbbb1da914 100644 --- a/tools/elfutils/Makefile +++ b/tools/elfutils/Makefile @@ -67,6 +67,8 @@ HOST_MAKE_FLAGS += \ REPLACE_FCNTL=0 REPLACE_FREE=0 REPLACE_FSTAT=0 REPLACE_OPEN=0 \ bin_PROGRAMS='$(PKG_PROGRAMS)' EXEEXT= +HOST_CPPFLAGS += "'-I$$$$(top_srcdir)/lib'" + ifeq ($(HOST_OS),Darwin) HOST_CFLAGS += -I/opt/homebrew/include endif @@ -99,7 +101,6 @@ HOST_CONFIGURE_VARS += \ Hooks/HostConfigure/Pre := Host/Gnulib $(Hooks/HostConfigure/Pre) define Host/Gnulib $(STAGING_DIR_HOST)/bin/gnulib-tool $(PKG_GNULIB_ARGS) $(PKG_GNULIB_MODS); - ln -sf ../lib/eu-config.h $(HOST_BUILD_DIR)/libgnu/; endef define Host/Compile From 3de19697fdd5baee3df9c67fdec48fe48e673894 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 20 Jun 2024 00:23:39 -0400 Subject: [PATCH 07/16] build: add support for PKG_SUBDIRS variable Add support for overriding the SUBDIRS variable while invoking Make by defining it after Make in the command line. This is useful for builds that have previously patched out the building of certain subdirectories in projects that use recursive and independent Makefiles, for example, to block the building of docs or test suites. The wildcard function is used in the case of there being subdirectories within any of the subdirectories, for example, in the building of gengetopt, in order to avoid the problem where Make will attempt to execute a Makefile in a subdirectory that does not exist within the subdirectory it is currently running from because it really exists at the top-level, or one that exists within one of the subdirectories when ran from top-level. There are also cases where the Makefiles in the subdirectories have the recursive building rules even though there are no more subdirectories beyond that point, for example, with gnulib. Signed-off-by: Michael Pratt Link: https://github.com/openwrt/openwrt/pull/15853 Signed-off-by: Robert Marko --- include/host-build.mk | 4 ++-- include/package-defaults.mk | 1 + include/package.mk | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/host-build.mk b/include/host-build.mk index 246f248e26..7e64fc16fe 100644 --- a/include/host-build.mk +++ b/include/host-build.mk @@ -110,11 +110,11 @@ define Host/Compile/Default endef define Host/Compile - $(call Host/Compile/Default) + $(call Host/Compile/Default,$(if $(PKG_SUBDIRS),SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))')) endef define Host/Install/Default - $(call Host/Compile/Default,install) + $(call Host/Compile/Default,$(if $(PKG_SUBDIRS),SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))') install) endef define Host/Install diff --git a/include/package-defaults.mk b/include/package-defaults.mk index 37de9f0ccb..6a401dde2c 100644 --- a/include/package-defaults.mk +++ b/include/package-defaults.mk @@ -151,6 +151,7 @@ define Build/Install/Default $(MAKE_VARS) \ $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \ $(MAKE_INSTALL_FLAGS) \ + $(if $(PKG_SUBDIRS),SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))') \ $(if $(1), $(1), install); endef diff --git a/include/package.mk b/include/package.mk index 8ee78415df..7fbecf98dc 100644 --- a/include/package.mk +++ b/include/package.mk @@ -343,7 +343,7 @@ endef Build/Prepare=$(call Build/Prepare/Default,) Build/Configure=$(call Build/Configure/Default,) -Build/Compile=$(call Build/Compile/Default,) +Build/Compile=$(call Build/Compile/Default,$(if $(PKG_SUBDIRS),SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))')) Build/Install=$(if $(PKG_INSTALL),$(call Build/Install/Default,)) Build/Dist=$(call Build/Dist/Default,) Build/DistCheck=$(call Build/DistCheck/Default,) From 9c833bc1c42cefc6294571d22c2f2e0ba344884c Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 20 Jun 2024 00:55:58 -0400 Subject: [PATCH 08/16] build: add default host build recipes for gnulib Add generic recipes for incorporating gnulib into a build for simplification and readability of the individual build Makefile. Recipes for configuring and installing are purposefully missing since "configuring" gnulib is done with standard autoreconf and gnulib is not a final build target meant for installing. Signed-off-by: Michael Pratt Link: https://github.com/openwrt/openwrt/pull/15853 Signed-off-by: Robert Marko --- include/host-build.mk | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/host-build.mk b/include/host-build.mk index 7e64fc16fe..8313dbfbb3 100644 --- a/include/host-build.mk +++ b/include/host-build.mk @@ -45,6 +45,15 @@ define Host/Prepare $(call Host/Prepare/Default) endef +define Host/Gnulib/Prepare + $(STAGING_DIR_HOST)/bin/gnulib-tool \ + --local-dir=$(STAGING_DIR_HOST)/share/gnulib \ + --source-base=$(PKG_GNULIB_BASE) \ + $(PKG_GNULIB_ARGS) \ + $(PKG_GNULIB_MODS) \ + ; +endef + HOST_CONFIGURE_VARS = \ CC="$(HOSTCC)" \ CFLAGS="$(HOST_CFLAGS)" \ @@ -113,6 +122,10 @@ define Host/Compile $(call Host/Compile/Default,$(if $(PKG_SUBDIRS),SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))')) endef +define Host/Gnulib/Compile + $(call Host/Compile/Default,SUBDIRS='$$$$(wildcard $(PKG_GNULIB_BASE))') +endef + define Host/Install/Default $(call Host/Compile/Default,$(if $(PKG_SUBDIRS),SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))') install) endef From b07099a6fdf05937446c486c8ef78e4cca081724 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 20 Jun 2024 01:10:21 -0400 Subject: [PATCH 09/16] build: let HOST_CXXFLAGS default to HOST_CFLAGS Usage of g++ should mimic the usage of gcc, otherwise, part of a binary or library may have optimizations and part of it may not, unbeknownst to the users or developers working on a build. This can lead to some features like, for example, FORTIFY_SOURCE, to have less of an effect or even cause a build error on some hosts. Therefore, let HOST_CXXFLAGS default to HOST_CFLAGS. Fixes: 87d489f67 ("build: add HOST_CXXFLAGS for host build") Signed-off-by: Michael Pratt Link: https://github.com/openwrt/openwrt/pull/15853 Signed-off-by: Robert Marko --- rules.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules.mk b/rules.mk index 91ed9b2085..ae20742bd7 100644 --- a/rules.mk +++ b/rules.mk @@ -245,8 +245,8 @@ export PKG_CONFIG HOSTCC:=$(STAGING_DIR_HOST)/bin/gcc HOSTCXX:=$(STAGING_DIR_HOST)/bin/g++ HOST_CPPFLAGS:=-I$(STAGING_DIR_HOST)/include $(if $(IS_PACKAGE_BUILD),-I$(STAGING_DIR_HOSTPKG)/include -I$(STAGING_DIR)/host/include) -HOST_CXXFLAGS:= HOST_CFLAGS:=-O2 $(HOST_CPPFLAGS) +HOST_CXXFLAGS:=$(HOST_CFLAGS) HOST_LDFLAGS:=-L$(STAGING_DIR_HOST)/lib $(if $(IS_PACKAGE_BUILD),-L$(STAGING_DIR_HOSTPKG)/lib -L$(STAGING_DIR)/host/lib) BUILD_KEY=$(TOPDIR)/key-build From 3b3a81f18eb8e1b46301f31dde40260bff51ce28 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 20 Jun 2024 01:28:00 -0400 Subject: [PATCH 10/16] tools/elfutils: simplify and cleanup Makefile After changes to default host build recipes and default variable definitions, several custom definitions can be removed, and the gnulib recipes replaced with hooks to common recipes. Also remove leftover PKG_INSTALL which has no effect for host builds. Signed-off-by: Michael Pratt Link: https://github.com/openwrt/openwrt/pull/15853 Signed-off-by: Robert Marko --- tools/elfutils/Makefile | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/tools/elfutils/Makefile b/tools/elfutils/Makefile index bbbb1da914..2836cadc87 100644 --- a/tools/elfutils/Makefile +++ b/tools/elfutils/Makefile @@ -15,12 +15,10 @@ PKG_LICENSE_FILES:=COPYING COPYING-GPLV2 COPYING-LGPLV3 PKG_CPE_ID:=cpe:/a:elfutils_project:elfutils PKG_FIXUP:=autoreconf -PKG_INSTALL:=1 PKG_PROGRAMS:=elflint findtextrel elfcmp unstrip stack elfcompress elfclassify srcfiles PKG_SUBDIRS := \ - libgnu \ config \ lib \ libelf \ @@ -36,8 +34,6 @@ PKG_GNULIB_BASE:=libgnu PKG_GNULIB_ARGS = \ --dir=$(HOST_BUILD_DIR) \ - --local-dir=$(STAGING_DIR_HOST)/share/gnulib \ - --source-base=$(PKG_GNULIB_BASE) \ --libtool \ --avoid=reallocarray \ --import @@ -74,7 +70,6 @@ ifeq ($(HOST_OS),Darwin) endif HOST_CFLAGS += -Wno-error -fPIC -HOST_CXXFLAGS += -O2 HOST_CONFIGURE_ARGS += \ --without-libintl-prefix \ @@ -98,18 +93,8 @@ HOST_CONFIGURE_VARS += \ ac_cv_search__obstack_free=yes \ ac_cv_buildid=yes -Hooks/HostConfigure/Pre := Host/Gnulib $(Hooks/HostConfigure/Pre) -define Host/Gnulib - $(STAGING_DIR_HOST)/bin/gnulib-tool $(PKG_GNULIB_ARGS) $(PKG_GNULIB_MODS); -endef - -define Host/Compile - $(call Host/Compile/Default,SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))') -endef - -define Host/Install - $(call Host/Compile/Default,install SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))') -endef +Hooks/HostConfigure/Pre := Host/Gnulib/Prepare $(Hooks/HostConfigure/Pre) +Hooks/HostCompile/Pre := Host/Gnulib/Compile $(Hooks/HostCompile/Pre) define Host/Uninstall -$(call Host/Compile/Default,uninstall) From 1b141cb3d10ae3bdb3b7cf0c4eb0d957629bc644 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Wed, 3 Jul 2024 17:53:36 -0700 Subject: [PATCH 11/16] ncurses: enable pc files in the host build Needed for things such as readline that depend on ncurses. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/15864 Signed-off-by: Robert Marko --- package/libs/ncurses/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/package/libs/ncurses/Makefile b/package/libs/ncurses/Makefile index 4d8e685f35..02791720c1 100644 --- a/package/libs/ncurses/Makefile +++ b/package/libs/ncurses/Makefile @@ -82,6 +82,7 @@ CONFIGURE_VARS += \ HOST_CFLAGS += $(HOST_FPIC) HOST_CONFIGURE_ARGS += \ + --enable-pc-files \ --without-cxx \ --without-cxx-binding \ --without-ada \ From d7a76fc351f7c33292202dedd4f9ab48b698212a Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 4 Jul 2024 12:12:33 -0700 Subject: [PATCH 12/16] readline: fix pkgconfig usage ncurses is built with wide support enabled, which enables libncursesw. The problem is, the ncurses build system only supplies ncursesw or ncurses.pc but not both. The other problem is, the readline build tests for libncurses before the w variant, making its pc file unusable as there is no ncurses.pc file to satisfy the Required: ncurses section. Just override the library. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/15864 Signed-off-by: Robert Marko --- package/libs/readline/Makefile | 3 ++- .../readline/patches/010-ncursesw-first.patch | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 package/libs/readline/patches/010-ncursesw-first.patch diff --git a/package/libs/readline/Makefile b/package/libs/readline/Makefile index 015a1ae2da..3ab28712af 100644 --- a/package/libs/readline/Makefile +++ b/package/libs/readline/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=readline PKG_VERSION:=8.2 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@GNU/readline @@ -51,6 +51,7 @@ CONFIGURE_ARGS += --with-curses --disable-install-examples CONFIGURE_VARS += \ bash_cv_wcwidth_broken=no \ bash_cv_func_sigsetjmp=yes \ + bash_cv_termcap_lib=libncursesw TARGET_CFLAGS += $(FPIC) HOST_CFLAGS += $(FPIC) diff --git a/package/libs/readline/patches/010-ncursesw-first.patch b/package/libs/readline/patches/010-ncursesw-first.patch new file mode 100644 index 0000000000..d66cc04622 --- /dev/null +++ b/package/libs/readline/patches/010-ncursesw-first.patch @@ -0,0 +1,20 @@ +--- a/configure ++++ b/configure +@@ -7305,6 +7305,9 @@ TERMCAP_DEP= + elif test $bash_cv_termcap_lib = libncurses; then + TERMCAP_LIB=-lncurses + TERMCAP_DEP= ++elif test $bash_cv_termcap_lib = libncursesw; then ++TERMCAP_LIB=-lncursesw ++TERMCAP_DEP= + elif test $bash_cv_termcap_lib = libc; then + TERMCAP_LIB= + TERMCAP_DEP= +@@ -7340,6 +7343,7 @@ case "$TERMCAP_LIB" in + -ltinfo) TERMCAP_PKG_CONFIG_LIB=tinfo ;; + -lcurses) TERMCAP_PKG_CONFIG_LIB=ncurses ;; + -lncurses) TERMCAP_PKG_CONFIG_LIB=ncurses ;; ++-lncursesw) TERMCAP_PKG_CONFIG_LIB=ncursesw ;; + -ltermcap) TERMCAP_PKG_CONFIG_LIB=termcap ;; + *) TERMCAP_PKG_CONFIG_LIB=termcap ;; + esac From dbb669872173237612d4f39aa2f742620da6bd57 Mon Sep 17 00:00:00 2001 From: Robert Marko Date: Mon, 8 Jul 2024 09:46:02 +0200 Subject: [PATCH 13/16] kernel: fix x86 compilation on macOS Trying to compile x86 or x86_64 on macOS will fail with: openwrt/build_dir/target-x86_64_musl/linux-x86_64/linux-6.6.36/tools/include/linux/rbtree.h:21:10: fatal error: 'linux/stddef.h' file not found After some digging, it seems that we dropped the old 212-tools_portability patch when 6.6 x86 support was added, then Felix added back some parts of it in ("kernel: fix tools build breakage on macos with x86") but trying to build x86 kernels will still fail. So, lets add more of the required changes from the 212-tools_portability patch so that x86 kernels build on macOS. Fixes: 69b145188f1a ("generic: 6.6: Removal of tools_portability.patch already included in kernel 6.6") Link: https://github.com/openwrt/openwrt/pull/15904 Signed-off-by: Robert Marko --- .../hack-6.6/200-tools_portability.patch | 162 +++++++++++++++++- 1 file changed, 161 insertions(+), 1 deletion(-) diff --git a/target/linux/generic/hack-6.6/200-tools_portability.patch b/target/linux/generic/hack-6.6/200-tools_portability.patch index 5d2b20dcb7..f016e641c6 100644 --- a/target/linux/generic/hack-6.6/200-tools_portability.patch +++ b/target/linux/generic/hack-6.6/200-tools_portability.patch @@ -40,7 +40,20 @@ Signed-off-by: Felix Fietkau # sysroots and flags or to avoid the GCC call in pure Clang builds. --- a/tools/include/linux/types.h +++ b/tools/include/linux/types.h -@@ -56,6 +56,7 @@ typedef __s8 s8; +@@ -10,8 +10,12 @@ + #define __SANE_USERSPACE_TYPES__ /* For PPC64, to get LL64 types */ + #endif + ++#ifndef __linux__ ++#include ++#else + #include + #include ++#endif + + struct page; + struct kmem_cache; +@@ -56,6 +60,7 @@ typedef __s8 s8; #define __user #endif #define __must_check @@ -95,3 +108,150 @@ Signed-off-by: Felix Fietkau /** * skip_spaces - Removes leading whitespace from @str. +--- a/tools/arch/x86/include/asm/insn.h ++++ b/tools/arch/x86/include/asm/insn.h +@@ -7,7 +7,7 @@ + * Copyright (C) IBM Corporation, 2009 + */ + +-#include ++#include + /* insn_attr_t is defined in inat.h */ + #include "inat.h" /* __ignore_sync_check__ */ + +--- a/tools/arch/x86/include/asm/orc_types.h ++++ b/tools/arch/x86/include/asm/orc_types.h +@@ -46,7 +46,6 @@ + #define ORC_TYPE_REGS_PARTIAL 4 + + #ifndef __ASSEMBLY__ +-#include + + /* + * This struct is more or less a vastly simplified version of the DWARF Call +@@ -59,12 +58,12 @@ + struct orc_entry { + s16 sp_offset; + s16 bp_offset; +-#if defined(__LITTLE_ENDIAN_BITFIELD) ++#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned sp_reg:4; + unsigned bp_reg:4; + unsigned type:3; + unsigned signal:1; +-#elif defined(__BIG_ENDIAN_BITFIELD) ++#elif __BYTE_ORDER == __BIG_ENDIAN + unsigned bp_reg:4; + unsigned sp_reg:4; + unsigned unused:4; +--- a/tools/include/linux/rbtree.h ++++ b/tools/include/linux/rbtree.h +@@ -18,7 +18,6 @@ + #define __TOOLS_LINUX_PERF_RBTREE_H + + #include +-#include + + struct rb_node { + unsigned long __rb_parent_color; +--- a/tools/include/tools/be_byteshift.h ++++ b/tools/include/tools/be_byteshift.h +@@ -2,6 +2,10 @@ + #ifndef _TOOLS_BE_BYTESHIFT_H + #define _TOOLS_BE_BYTESHIFT_H + ++#ifndef __linux__ ++#include "linux_types.h" ++#endif ++ + #include + + static inline uint16_t __get_unaligned_be16(const uint8_t *p) +--- a/tools/include/tools/le_byteshift.h ++++ b/tools/include/tools/le_byteshift.h +@@ -2,6 +2,10 @@ + #ifndef _TOOLS_LE_BYTESHIFT_H + #define _TOOLS_LE_BYTESHIFT_H + ++#ifndef __linux__ ++#include "linux_types.h" ++#endif ++ + #include + + static inline uint16_t __get_unaligned_le16(const uint8_t *p) +--- /dev/null ++++ b/tools/include/tools/linux_types.h +@@ -0,0 +1,18 @@ ++#ifndef __LINUX_TYPES_H ++#define __LINUX_TYPES_H ++ ++#include ++ ++typedef int8_t __s8; ++typedef uint8_t __u8; ++ ++typedef int16_t __s16; ++typedef uint16_t __u16; ++ ++typedef int32_t __s32; ++typedef uint32_t __u32; ++ ++typedef int64_t __s64; ++typedef uint64_t __u64; ++ ++#endif +--- a/tools/objtool/Makefile ++++ b/tools/objtool/Makefile +@@ -39,6 +39,8 @@ OBJTOOL_LDFLAGS := $(LIBELF_LIBS) $(LIBS + elfshdr := $(shell echo '$(pound)include ' | $(HOSTCC) $(OBJTOOL_CFLAGS) -x c -E - | grep elf_getshdr) + OBJTOOL_CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED) + ++OBJTOOL_CFLAGS += $(HOST_EXTRACFLAGS) ++ + # Always want host compilation. + HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" + +--- a/tools/objtool/orc_dump.c ++++ b/tools/objtool/orc_dump.c +@@ -4,10 +4,10 @@ + */ + + #include +-#include + #include + #include + #include ++#include + + static const char *reg_name(unsigned int reg) + { +--- a/tools/objtool/orc_gen.c ++++ b/tools/objtool/orc_gen.c +@@ -7,11 +7,11 @@ + #include + + #include +-#include + + #include + #include + #include ++#include + + static int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi, + struct instruction *insn) +--- a/tools/arch/x86/lib/insn.c ++++ b/tools/arch/x86/lib/insn.c +@@ -15,7 +15,11 @@ + #include "../include/asm/insn.h" /* __ignore_sync_check__ */ + #include "../include/asm-generic/unaligned.h" /* __ignore_sync_check__ */ + ++#ifdef __KERNEL__ + #include ++#else ++#include ++#endif + #include + + #include "../include/asm/emulate_prefix.h" /* __ignore_sync_check__ */ From 0122fd7929d0971e2286518b2da3d307b677c683 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Sun, 7 Jul 2024 19:28:35 +0200 Subject: [PATCH 14/16] kernel: aldo fix CopyImage for Separate Initramfs Also fix CopyImage for Separate Initramfs with Per Device Rootfs. Fixes: 7bffb3f72bbf ("kernel: fix CopyImage function with Per Device Rootfs") Signed-off-by: Christian Marangi --- include/kernel-defaults.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/kernel-defaults.mk b/include/kernel-defaults.mk index 46045b0ed7..ff6c60d5b0 100644 --- a/include/kernel-defaults.mk +++ b/include/kernel-defaults.mk @@ -185,7 +185,7 @@ endif $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZO),$(STAGING_DIR_HOST)/bin/lzop -9 -f $(if $(2),$(LINUX_DIR)$(2),$(KERNEL_BUILD_DIR))/initrd.cpio) $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_XZ),$(STAGING_DIR_HOST)/bin/xz -T$(if $(filter 1,$(NPROC)),2,0) -9 -fz --check=crc32 $(if $(2),$(LINUX_DIR)$(2),$(KERNEL_BUILD_DIR))/initrd.cpio) $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_ZSTD),$(STAGING_DIR_HOST)/bin/zstd -T0 -f -o $(if $(2),$(LINUX_DIR)$(2),$(KERNEL_BUILD_DIR))/initrd.cpio.zstd $(if $(2),$(LINUX_DIR)$(2),$(KERNEL_BUILD_DIR))/initrd.cpio) - $(call Kernel/CopyImage,-initramfs$(2)) + $(call Kernel/CopyImage,-initramfs,$(2)) else +$(call locked,$(if $(2),$(CP) $(LINUX_DIR)$(2)/.config* $(LINUX_DIR) && touch $(LINUX_DIR)/.config && )\ rm -rf $(LINUX_DIR)/usr/initramfs_data.cpio* $(LINUX_DIR)/.config.prev && \ From cc6a0abcabf718df872c0f6876d1121d3dd09953 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Mon, 8 Jul 2024 13:10:52 +0200 Subject: [PATCH 15/16] image: make images and artifacts dependent of initramfs There is currently a BIG bug in how the images dependency is handled and recent Per Device Rootfs made this more clear and less statistical. There is currently no dependency between images/artifacts build with initramfs build. This cause whatever additional image that depends on an initramfs image to fail as it might happen that image and initramfs build are called at the same time and the additional image is called before initramfs build has finished. Each image-command assume the source image to be taken from the /bin directory but that is only copied from the /tmp directory only at the end of the process. Artifacts currently depends on image with the use of the BOARD-NAME-images Makefile target, but this is not the case for initramfs that also define a -images Makefile target but that is not accounted in images (that might depend on some initramfs images) To actually fix this, introduce a new Makefile target, -initramfs-images and make image and artifacts build to depend on this. Since initramfs images are optional, this dependency is actived only when initramfs image are built. With this change we correctly enforce the build order: - Initramfs Images (optional) - Images - Artifacts Signed-off-by: Christian Marangi --- include/image.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/image.mk b/include/image.mk index be0682c44e..60bb01b9cb 100644 --- a/include/image.mk +++ b/include/image.mk @@ -538,7 +538,7 @@ define Device/Build/initramfs $(KDIR)/$$(KERNEL_INITRAMFS_NAME).$$(ROOTFS_ID/$(1)):: image_prepare target-dir-$$(ROOTFS_ID/$(1)) $(call Kernel/CompileImage/Initramfs,$(KDIR)/target-dir-$$(ROOTFS_ID/$(1)),.$$(ROOTFS_ID/$(1))) endif - $(1)-images: $$(if $$(KERNEL_INITRAMFS),$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE)) + $(1)-initramfs-images: $$(if $$(KERNEL_INITRAMFS),$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE)) $(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE) cp $$^ $$@ @@ -671,7 +671,7 @@ define Device/Build/image ifndef IB $$(ROOTFS/$(1)/$(3)): $(if $(TARGET_PER_DEVICE_ROOTFS),target-dir-$$(ROOTFS_ID/$(3))) endif - $(KDIR)/tmp/$(call DEVICE_IMG_NAME,$(1),$(2)): $$(KDIR_KERNEL_IMAGE) $$(ROOTFS/$(1)/$(3)) + $(KDIR)/tmp/$(call DEVICE_IMG_NAME,$(1),$(2)): $$(KDIR_KERNEL_IMAGE) $$(ROOTFS/$(1)/$(3)) $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(3)-initramfs-images) @rm -f $$@ [ -f $$(word 1,$$^) -a -f $$(word 2,$$^) ] $$(call concat_cmd,$(if $(IMAGE/$(2)/$(1)),$(IMAGE/$(2)/$(1)),$(IMAGE/$(2)))) @@ -730,7 +730,7 @@ define Device/Build/artifact $(BUILD_DIR)/json_info_files/$(DEVICE_IMG_PREFIX)-$(1).json, \ $(BIN_DIR)/$(DEVICE_IMG_PREFIX)-$(1)) $(eval $(call Device/Export,$(KDIR)/tmp/$(DEVICE_IMG_PREFIX)-$(1))) - $(KDIR)/tmp/$(DEVICE_IMG_PREFIX)-$(1): $$(KDIR_KERNEL_IMAGE) $(2)-images + $(KDIR)/tmp/$(DEVICE_IMG_PREFIX)-$(1): $$(KDIR_KERNEL_IMAGE) $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(2)-initramfs-images) $(2)-images @rm -f $$@ $$(call concat_cmd,$(ARTIFACT/$(1))) From 2bae9d04af2f4722fc0156632169fe2ab75fccf0 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Mon, 8 Jul 2024 13:21:13 +0200 Subject: [PATCH 16/16] qualcommax: ipq807x: fix build error with no initramfs for RAX120v2 Exclude additional initramfs image for Netgear RAX120v2 when no initramfs image are compiled to fix build error. Signed-off-by: Christian Marangi --- target/linux/qualcommax/image/ipq807x.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/linux/qualcommax/image/ipq807x.mk b/target/linux/qualcommax/image/ipq807x.mk index d75cf3dd3c..e2a6da569c 100644 --- a/target/linux/qualcommax/image/ipq807x.mk +++ b/target/linux/qualcommax/image/ipq807x.mk @@ -162,10 +162,12 @@ define Device/netgear_rax120v2 NETGEAR_HW_ID := 29765589+0+512+1024+4x4+8x8 DEVICE_PACKAGES := ipq-wifi-netgear_rax120v2 kmod-spi-gpio \ kmod-spi-bitbang kmod-gpio-nxp-74hc164 kmod-hwmon-g762 +ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) IMAGES += web-ui-factory.img IMAGE/web-ui-factory.img := append-image initramfs-uImage.itb | \ pad-offset $$$$(BLOCKSIZE) 64 | append-uImage-fakehdr filesystem | \ netgear-dni +endif IMAGE/sysupgrade.bin := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \ append-uImage-fakehdr filesystem | sysupgrade-tar kernel=$$$$@ | \ append-metadata