From c4f63f7364c572fe32fbeb48098bdcb9ca7247ed Mon Sep 17 00:00:00 2001 From: Aleksander Jan Bajkowski Date: Sat, 22 Oct 2022 16:13:32 +0200 Subject: [PATCH 01/32] mediatek: filogic: refresh config This was done by executing these command: $ time make kernel_oldconfig CONFIG_TARGET=subtarget Signed-off-by: Aleksander Jan Bajkowski --- target/linux/mediatek/filogic/config-5.15 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target/linux/mediatek/filogic/config-5.15 b/target/linux/mediatek/filogic/config-5.15 index 2e02d6a7aa..43480775b6 100644 --- a/target/linux/mediatek/filogic/config-5.15 +++ b/target/linux/mediatek/filogic/config-5.15 @@ -50,7 +50,6 @@ CONFIG_BSD_PROCESS_ACCT_V3=y CONFIG_CC_HAVE_STACKPROTECTOR_SYSREG=y CONFIG_CLKSRC_MMIO=y CONFIG_CLONE_BACKWARDS=y -# CONFIG_CMDLINE_OVERRIDE is not set CONFIG_COMMON_CLK=y CONFIG_COMMON_CLK_MEDIATEK=y # CONFIG_COMMON_CLK_MT2712 is not set @@ -86,7 +85,6 @@ CONFIG_CRYPTO_AES_ARM64=y CONFIG_CRYPTO_AES_ARM64_CE=y CONFIG_CRYPTO_AES_ARM64_CE_BLK=y CONFIG_CRYPTO_AES_ARM64_CE_CCM=y -CONFIG_CRYPTO_BLAKE2S=y CONFIG_CRYPTO_CMAC=y CONFIG_CRYPTO_CRC32=y CONFIG_CRYPTO_CRC32C=y @@ -169,7 +167,6 @@ CONFIG_GENERIC_STRNCPY_FROM_USER=y CONFIG_GENERIC_STRNLEN_USER=y CONFIG_GENERIC_TIME_VSYSCALL=y CONFIG_GLOB=y -CONFIG_GPIOLIB=y CONFIG_GPIO_CDEV=y CONFIG_GRO_CELLS=y CONFIG_HANDLE_DOMAIN_IRQ=y @@ -230,8 +227,8 @@ CONFIG_MTD_SPLIT_FIRMWARE=y CONFIG_MTD_SPLIT_FIT_FW=y CONFIG_MTD_UBI=y CONFIG_MTD_UBI_BEB_LIMIT=20 -CONFIG_MTD_UBI_FASTMAP=y CONFIG_MTD_UBI_BLOCK=y +CONFIG_MTD_UBI_FASTMAP=y CONFIG_MTD_UBI_WL_THRESHOLD=4096 # CONFIG_MTK_CMDQ is not set # CONFIG_MTK_CQDMA is not set @@ -275,6 +272,8 @@ CONFIG_OF_MDIO=y CONFIG_OF_OVERLAY=y CONFIG_OF_RESOLVE=y CONFIG_PADATA=y +CONFIG_PAGE_POOL=y +CONFIG_PAGE_POOL_STATS=y CONFIG_PARTITION_PERCPU=y CONFIG_PCI=y CONFIG_PCIEAER=y @@ -404,6 +403,7 @@ CONFIG_THREAD_INFO_IN_TASK=y CONFIG_TICK_CPU_ACCOUNTING=y CONFIG_TIMER_OF=y CONFIG_TIMER_PROBE=y +CONFIG_TRACE_IRQFLAGS_NMI_SUPPORT=y CONFIG_TREE_RCU=y CONFIG_TREE_SRCU=y CONFIG_UBIFS_FS=y From 985d59cdf0fe69530dea8ed5bb1ba2119b4586ac Mon Sep 17 00:00:00 2001 From: Aleksander Jan Bajkowski Date: Sat, 22 Oct 2022 16:16:14 +0200 Subject: [PATCH 02/32] mediatek: filogic: disable swconfig This subtarget supports 3 devices: * Bananapi BPi-R3 (added in a96382c1bb204698cd43e82193877c10e4b63027), * MediaTek MTK7986 rfba AP (added in cffc77ae55ed0e5b9e70417d6a1e1d280cea92cf), * MediaTek MTK7986 rfbb AP (added in cffc77ae55ed0e5b9e70417d6a1e1d280cea92cf). This subtarget supports DSA from the beginning. It looks like CONFIG_SWCONFIG was copied from another config when the subtarget was created. Signed-off-by: Aleksander Jan Bajkowski --- target/linux/mediatek/filogic/config-5.15 | 1 - 1 file changed, 1 deletion(-) diff --git a/target/linux/mediatek/filogic/config-5.15 b/target/linux/mediatek/filogic/config-5.15 index 43480775b6..469542e219 100644 --- a/target/linux/mediatek/filogic/config-5.15 +++ b/target/linux/mediatek/filogic/config-5.15 @@ -385,7 +385,6 @@ CONFIG_SPI_MT65XX=y CONFIG_SPI_MTK_NOR=y CONFIG_SPI_MTK_SNFI=y CONFIG_SRCU=y -CONFIG_SWCONFIG=y CONFIG_SWIOTLB=y CONFIG_SWPHY=y CONFIG_SYSCTL_EXCEPTION_TRACE=y From e4270d64930bd710fdad9a48293f7b774edaf9c4 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Thu, 3 Nov 2022 11:02:02 +0100 Subject: [PATCH 03/32] mediatek: mt7622: add tag to upstreamed patches The patches "191-arm64-dts-mt7622-specify-the-L2-cache-topology.patch" and "192-arm64-dts-mt7622-specify-the-number-of-DMA-requests.patch" are upstreamed to 5.19. Signed-off-by: Nick Hainke --- ...91-v5.19-arm64-dts-mt7622-specify-the-L2-cache-topology.patch} | 0 ....19-arm64-dts-mt7622-specify-the-number-of-DMA-requests.patch} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename target/linux/mediatek/patches-5.15/{191-arm64-dts-mt7622-specify-the-L2-cache-topology.patch => 191-v5.19-arm64-dts-mt7622-specify-the-L2-cache-topology.patch} (100%) rename target/linux/mediatek/patches-5.15/{192-arm64-dts-mt7622-specify-the-number-of-DMA-requests.patch => 192-v5.19-arm64-dts-mt7622-specify-the-number-of-DMA-requests.patch} (100%) diff --git a/target/linux/mediatek/patches-5.15/191-arm64-dts-mt7622-specify-the-L2-cache-topology.patch b/target/linux/mediatek/patches-5.15/191-v5.19-arm64-dts-mt7622-specify-the-L2-cache-topology.patch similarity index 100% rename from target/linux/mediatek/patches-5.15/191-arm64-dts-mt7622-specify-the-L2-cache-topology.patch rename to target/linux/mediatek/patches-5.15/191-v5.19-arm64-dts-mt7622-specify-the-L2-cache-topology.patch diff --git a/target/linux/mediatek/patches-5.15/192-arm64-dts-mt7622-specify-the-number-of-DMA-requests.patch b/target/linux/mediatek/patches-5.15/192-v5.19-arm64-dts-mt7622-specify-the-number-of-DMA-requests.patch similarity index 100% rename from target/linux/mediatek/patches-5.15/192-arm64-dts-mt7622-specify-the-number-of-DMA-requests.patch rename to target/linux/mediatek/patches-5.15/192-v5.19-arm64-dts-mt7622-specify-the-number-of-DMA-requests.patch From e8080ce89b8945a512e57f663e797f3c922b60e4 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Thu, 3 Nov 2022 11:18:49 +0100 Subject: [PATCH 04/32] mediatek: mt7986: add tag to upstreamed patches The patch "210-pinctrl-mediatek-add-support-for-MT7986-SoC.patch" and "212-clk-mediatek-add-mt7986-clock-support.patch" are upstreamed. Signed-off-by: Nick Hainke --- ...=> 210-v6.1-pinctrl-mediatek-add-support-for-MT7986-SoC.patch} | 0 ...atch => 212-v5.17-clk-mediatek-add-mt7986-clock-support.patch} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename target/linux/mediatek/patches-5.15/{210-pinctrl-mediatek-add-support-for-MT7986-SoC.patch => 210-v6.1-pinctrl-mediatek-add-support-for-MT7986-SoC.patch} (100%) rename target/linux/mediatek/patches-5.15/{212-clk-mediatek-add-mt7986-clock-support.patch => 212-v5.17-clk-mediatek-add-mt7986-clock-support.patch} (100%) diff --git a/target/linux/mediatek/patches-5.15/210-pinctrl-mediatek-add-support-for-MT7986-SoC.patch b/target/linux/mediatek/patches-5.15/210-v6.1-pinctrl-mediatek-add-support-for-MT7986-SoC.patch similarity index 100% rename from target/linux/mediatek/patches-5.15/210-pinctrl-mediatek-add-support-for-MT7986-SoC.patch rename to target/linux/mediatek/patches-5.15/210-v6.1-pinctrl-mediatek-add-support-for-MT7986-SoC.patch diff --git a/target/linux/mediatek/patches-5.15/212-clk-mediatek-add-mt7986-clock-support.patch b/target/linux/mediatek/patches-5.15/212-v5.17-clk-mediatek-add-mt7986-clock-support.patch similarity index 100% rename from target/linux/mediatek/patches-5.15/212-clk-mediatek-add-mt7986-clock-support.patch rename to target/linux/mediatek/patches-5.15/212-v5.17-clk-mediatek-add-mt7986-clock-support.patch From 0c8d84a642f10d117d9df5a2f275177f5715238e Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Thu, 3 Nov 2022 11:41:44 +0100 Subject: [PATCH 05/32] mediatek: add tag for upstreamed patches The patches were upstreamed. Signed-off-by: Nick Hainke --- ...1-v5.16-clk-mediatek-Add-API-for-clock-resource-recycle.patch} | 0 ...16-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-and-MT.patch} | 0 ....1-PCI-mediatek-gen3-change-driver-name-to-mtk-pcie-gen.patch} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename target/linux/mediatek/patches-5.15/{211-clk-mediatek-Add-API-for-clock-resource-recycle.patch => 211-v5.16-clk-mediatek-Add-API-for-clock-resource-recycle.patch} (100%) rename target/linux/mediatek/patches-5.15/{600-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-and-MT.patch => 600-v5.16-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-and-MT.patch} (100%) rename target/linux/mediatek/patches-5.15/{922-PCI-mediatek-gen3-change-driver-name-to-mtk-pcie-gen.patch => 922-v6.1-PCI-mediatek-gen3-change-driver-name-to-mtk-pcie-gen.patch} (100%) diff --git a/target/linux/mediatek/patches-5.15/211-clk-mediatek-Add-API-for-clock-resource-recycle.patch b/target/linux/mediatek/patches-5.15/211-v5.16-clk-mediatek-Add-API-for-clock-resource-recycle.patch similarity index 100% rename from target/linux/mediatek/patches-5.15/211-clk-mediatek-Add-API-for-clock-resource-recycle.patch rename to target/linux/mediatek/patches-5.15/211-v5.16-clk-mediatek-Add-API-for-clock-resource-recycle.patch diff --git a/target/linux/mediatek/patches-5.15/600-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-and-MT.patch b/target/linux/mediatek/patches-5.15/600-v5.16-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-and-MT.patch similarity index 100% rename from target/linux/mediatek/patches-5.15/600-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-and-MT.patch rename to target/linux/mediatek/patches-5.15/600-v5.16-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-and-MT.patch diff --git a/target/linux/mediatek/patches-5.15/922-PCI-mediatek-gen3-change-driver-name-to-mtk-pcie-gen.patch b/target/linux/mediatek/patches-5.15/922-v6.1-PCI-mediatek-gen3-change-driver-name-to-mtk-pcie-gen.patch similarity index 100% rename from target/linux/mediatek/patches-5.15/922-PCI-mediatek-gen3-change-driver-name-to-mtk-pcie-gen.patch rename to target/linux/mediatek/patches-5.15/922-v6.1-PCI-mediatek-gen3-change-driver-name-to-mtk-pcie-gen.patch From 61a9367b8606d40de1639f2538dc73dccc4717ce Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Thu, 3 Nov 2022 13:00:17 +0100 Subject: [PATCH 06/32] mediatek: mt7629: add tag to upstreamed patches The patches were upstreamed. Signed-off-by: Nick Hainke --- ...h => 603-v5.16-ARM-dts-mediatek-Update-mt7629-PCIe-node.patch} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename target/linux/mediatek/patches-5.15/{603-ARM-dts-mediatek-Update-mt7629-PCIe-node.patch => 603-v5.16-ARM-dts-mediatek-Update-mt7629-PCIe-node.patch} (100%) diff --git a/target/linux/mediatek/patches-5.15/603-ARM-dts-mediatek-Update-mt7629-PCIe-node.patch b/target/linux/mediatek/patches-5.15/603-v5.16-ARM-dts-mediatek-Update-mt7629-PCIe-node.patch similarity index 100% rename from target/linux/mediatek/patches-5.15/603-ARM-dts-mediatek-Update-mt7629-PCIe-node.patch rename to target/linux/mediatek/patches-5.15/603-v5.16-ARM-dts-mediatek-Update-mt7629-PCIe-node.patch From 29d987fc89d0abaea4f6cec1510325cfe8b498a4 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Thu, 3 Nov 2022 13:48:25 +0100 Subject: [PATCH 07/32] mediatek: replace mt7986 watchdog assert patch with upstream Replace "920-watchdog-add-mt7986-assert.patch" with upstreamed - 920-v5.16-watchdog-mtk-add-disable_wdt_extrst-support.patch - 921-v5.19-watchdog-mtk_wdt-mt7986-Add-toprgu-reset-controller.patch Signed-off-by: Nick Hainke --- ...g-mtk-add-disable_wdt_extrst-support.patch | 50 ++++++++++++++++ .../920-watchdog-add-mt7986-assert.patch | 57 ------------------- ...t-mt7986-Add-toprgu-reset-controller.patch | 49 ++++++++++++++++ 3 files changed, 99 insertions(+), 57 deletions(-) create mode 100644 target/linux/mediatek/patches-5.15/920-v5.16-watchdog-mtk-add-disable_wdt_extrst-support.patch delete mode 100644 target/linux/mediatek/patches-5.15/920-watchdog-add-mt7986-assert.patch create mode 100644 target/linux/mediatek/patches-5.15/921-v5.19-watchdog-mtk_wdt-mt7986-Add-toprgu-reset-controller.patch diff --git a/target/linux/mediatek/patches-5.15/920-v5.16-watchdog-mtk-add-disable_wdt_extrst-support.patch b/target/linux/mediatek/patches-5.15/920-v5.16-watchdog-mtk-add-disable_wdt_extrst-support.patch new file mode 100644 index 0000000000..d9379721fb --- /dev/null +++ b/target/linux/mediatek/patches-5.15/920-v5.16-watchdog-mtk-add-disable_wdt_extrst-support.patch @@ -0,0 +1,50 @@ +From 59b0f51335644ee603260faaa4298c0115fb7187 Mon Sep 17 00:00:00 2001 +From: Fengquan Chen +Date: Tue, 14 Sep 2021 20:34:54 +0800 +Subject: [PATCH] watchdog: mtk: add disable_wdt_extrst support + +In some cases, we may need watchdog just to trigger an +internal soc reset without sending any output signal. + +Provide a disable_wdt_extrst parameter for configuration. +We can disable or enable it just by configuring dts. + +Signed-off-by: Fengquan Chen +Reviewed-by: Guenter Roeck +Link: https://lore.kernel.org/r/20210914123454.32603-3-Fengquan.Chen@mediatek.com +Signed-off-by: Guenter Roeck +Signed-off-by: Wim Van Sebroeck +--- + drivers/watchdog/mtk_wdt.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +--- a/drivers/watchdog/mtk_wdt.c ++++ b/drivers/watchdog/mtk_wdt.c +@@ -65,6 +65,7 @@ struct mtk_wdt_dev { + void __iomem *wdt_base; + spinlock_t lock; /* protects WDT_SWSYSRST reg */ + struct reset_controller_dev rcdev; ++ bool disable_wdt_extrst; + }; + + struct mtk_wdt_data { +@@ -256,6 +257,8 @@ static int mtk_wdt_start(struct watchdog + reg |= (WDT_MODE_IRQ_EN | WDT_MODE_DUAL_EN); + else + reg &= ~(WDT_MODE_IRQ_EN | WDT_MODE_DUAL_EN); ++ if (mtk_wdt->disable_wdt_extrst) ++ reg &= ~WDT_MODE_EXRST_EN; + reg |= (WDT_MODE_EN | WDT_MODE_KEY); + iowrite32(reg, wdt_base + WDT_MODE); + +@@ -381,6 +384,10 @@ static int mtk_wdt_probe(struct platform + if (err) + return err; + } ++ ++ mtk_wdt->disable_wdt_extrst = ++ of_property_read_bool(dev->of_node, "mediatek,disable-extrst"); ++ + return 0; + } + diff --git a/target/linux/mediatek/patches-5.15/920-watchdog-add-mt7986-assert.patch b/target/linux/mediatek/patches-5.15/920-watchdog-add-mt7986-assert.patch deleted file mode 100644 index 699161458c..0000000000 --- a/target/linux/mediatek/patches-5.15/920-watchdog-add-mt7986-assert.patch +++ /dev/null @@ -1,57 +0,0 @@ ---- a/drivers/watchdog/mtk_wdt.c -+++ b/drivers/watchdog/mtk_wdt.c -@@ -9,6 +9,7 @@ - * Based on sunxi_wdt.c - */ - -+#include - #include - #include - #include -@@ -65,6 +66,7 @@ struct mtk_wdt_dev { - void __iomem *wdt_base; - spinlock_t lock; /* protects WDT_SWSYSRST reg */ - struct reset_controller_dev rcdev; -+ bool disable_wdt_extrst; - }; - - struct mtk_wdt_data { -@@ -87,6 +89,10 @@ static const struct mtk_wdt_data mt8195_ - .toprgu_sw_rst_num = MT8195_TOPRGU_SW_RST_NUM, - }; - -+static const struct mtk_wdt_data mt7986_data = { -+ .toprgu_sw_rst_num = MT7986_TOPRGU_SW_RST_NUM, -+}; -+ - static int toprgu_reset_update(struct reset_controller_dev *rcdev, - unsigned long id, bool assert) - { -@@ -256,6 +262,8 @@ static int mtk_wdt_start(struct watchdog - reg |= (WDT_MODE_IRQ_EN | WDT_MODE_DUAL_EN); - else - reg &= ~(WDT_MODE_IRQ_EN | WDT_MODE_DUAL_EN); -+ if (mtk_wdt->disable_wdt_extrst) -+ reg &= ~WDT_MODE_EXRST_EN; - reg |= (WDT_MODE_EN | WDT_MODE_KEY); - iowrite32(reg, wdt_base + WDT_MODE); - -@@ -381,6 +389,10 @@ static int mtk_wdt_probe(struct platform - if (err) - return err; - } -+ -+ mtk_wdt->disable_wdt_extrst = -+ of_property_read_bool(dev->of_node, "mediatek,disable-extrst"); -+ - return 0; - } - -@@ -414,6 +426,7 @@ static const struct of_device_id mtk_wdt - { .compatible = "mediatek,mt8183-wdt", .data = &mt8183_data }, - { .compatible = "mediatek,mt8192-wdt", .data = &mt8192_data }, - { .compatible = "mediatek,mt8195-wdt", .data = &mt8195_data }, -+ { .compatible = "mediatek,mt7986-wdt", .data = &mt7986_data }, - { /* sentinel */ } - }; - MODULE_DEVICE_TABLE(of, mtk_wdt_dt_ids); diff --git a/target/linux/mediatek/patches-5.15/921-v5.19-watchdog-mtk_wdt-mt7986-Add-toprgu-reset-controller.patch b/target/linux/mediatek/patches-5.15/921-v5.19-watchdog-mtk_wdt-mt7986-Add-toprgu-reset-controller.patch new file mode 100644 index 0000000000..96fb215f76 --- /dev/null +++ b/target/linux/mediatek/patches-5.15/921-v5.19-watchdog-mtk_wdt-mt7986-Add-toprgu-reset-controller.patch @@ -0,0 +1,49 @@ +From 711a5b25bac95dcd1111521ed71693330e74a926 Mon Sep 17 00:00:00 2001 +From: Sam Shih +Date: Wed, 5 Jan 2022 18:04:56 +0800 +Subject: [PATCH] watchdog: mtk_wdt: mt7986: Add toprgu reset controller + support + +Besides watchdog, the mt7986 toprgu module also provides software reset +functionality for various peripheral subsystems +(eg, ethernet, pcie, and connectivity) + +Signed-off-by: Sam Shih +Reviewed-by: Matthias Brugger +Reviewed-by: Guenter Roeck +Link: https://lore.kernel.org/r/20220105100456.7126-3-sam.shih@mediatek.com +Signed-off-by: Guenter Roeck +Signed-off-by: Wim Van Sebroeck +--- + drivers/watchdog/mtk_wdt.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/watchdog/mtk_wdt.c ++++ b/drivers/watchdog/mtk_wdt.c +@@ -10,6 +10,7 @@ + */ + + #include ++#include + #include + #include + #include +@@ -76,6 +77,10 @@ static const struct mtk_wdt_data mt2712_ + .toprgu_sw_rst_num = MT2712_TOPRGU_SW_RST_NUM, + }; + ++static const struct mtk_wdt_data mt7986_data = { ++ .toprgu_sw_rst_num = MT7986_TOPRGU_SW_RST_NUM, ++}; ++ + static const struct mtk_wdt_data mt8183_data = { + .toprgu_sw_rst_num = MT8183_TOPRGU_SW_RST_NUM, + }; +@@ -418,6 +423,7 @@ static int mtk_wdt_resume(struct device + static const struct of_device_id mtk_wdt_dt_ids[] = { + { .compatible = "mediatek,mt2712-wdt", .data = &mt2712_data }, + { .compatible = "mediatek,mt6589-wdt" }, ++ { .compatible = "mediatek,mt7986-wdt", .data = &mt7986_data }, + { .compatible = "mediatek,mt8183-wdt", .data = &mt8183_data }, + { .compatible = "mediatek,mt8192-wdt", .data = &mt8192_data }, + { .compatible = "mediatek,mt8195-wdt", .data = &mt8195_data }, From f06e995c13c750a8bf396310a13a79ae290f4570 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Wed, 2 Nov 2022 15:13:53 +0100 Subject: [PATCH 08/32] tools/mtools: update to 4.0.42 Release Notes: https://lists.gnu.org/archive/html/info-mtools/2022-10/msg00000.html Signed-off-by: Nick Hainke --- tools/mtools/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/mtools/Makefile b/tools/mtools/Makefile index 964ef9db33..c0c36a9d02 100644 --- a/tools/mtools/Makefile +++ b/tools/mtools/Makefile @@ -7,11 +7,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mtools -PKG_VERSION:=4.0.41 +PKG_VERSION:=4.0.42 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=@GNU/$(PKG_NAME) -PKG_HASH:=2542152264fb3eff7ed70662abf4f4eef8133bc37d0b7a686c240df2b5f80a13 +PKG_HASH:=64bfdfde4d82af6b22f3c1c72c3e231cbb618f4c2309cc46f54d16d5502ccf15 HOST_BUILD_PARALLEL:=1 From 17dd18d993341ab927bce0281a76ff3065c70e70 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Wed, 2 Nov 2022 15:25:36 +0100 Subject: [PATCH 09/32] tools/mtd-utils: update to 2.1.5 Release Notes: https://lore.kernel.org/buildroot/c0992bbb-9487-9a51-ea9f-39cf074b61ec@sigma-star.at/ Refresh patches: - 130-lzma_jffs2.patch - 320-mkfs.jffs2-SOURCE_DATE_EPOCH.patch Signed-off-by: Nick Hainke --- tools/mtd-utils/Makefile | 4 ++-- tools/mtd-utils/patches/130-lzma_jffs2.patch | 2 +- .../patches/320-mkfs.jffs2-SOURCE_DATE_EPOCH.patch | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/mtd-utils/Makefile b/tools/mtd-utils/Makefile index e4b951acfb..14f11acaf5 100644 --- a/tools/mtd-utils/Makefile +++ b/tools/mtd-utils/Makefile @@ -7,12 +7,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mtd-utils -PKG_VERSION:=2.1.4 +PKG_VERSION:=2.1.5 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://infraroot.at/pub/mtd/ -PKG_HASH:=2c6711d15d282c47cb3867b6857340597e26d332c238465134c602e5eef71b99 +PKG_HASH:=386e27fd121699b6b729bc2e8e04dda987b31cca6b16e12fb6cc6dcf26449f46 PKG_FIXUP:=autoreconf diff --git a/tools/mtd-utils/patches/130-lzma_jffs2.patch b/tools/mtd-utils/patches/130-lzma_jffs2.patch index 55930ddc86..db683063d5 100644 --- a/tools/mtd-utils/patches/130-lzma_jffs2.patch +++ b/tools/mtd-utils/patches/130-lzma_jffs2.patch @@ -5020,7 +5020,7 @@ +} --- a/jffsX-utils/mkfs.jffs2.c +++ b/jffsX-utils/mkfs.jffs2.c -@@ -1667,11 +1667,11 @@ int main(int argc, char **argv) +@@ -1668,11 +1668,11 @@ int main(int argc, char **argv) } erase_block_size *= units; diff --git a/tools/mtd-utils/patches/320-mkfs.jffs2-SOURCE_DATE_EPOCH.patch b/tools/mtd-utils/patches/320-mkfs.jffs2-SOURCE_DATE_EPOCH.patch index f3ba4d3276..a1703eb64f 100644 --- a/tools/mtd-utils/patches/320-mkfs.jffs2-SOURCE_DATE_EPOCH.patch +++ b/tools/mtd-utils/patches/320-mkfs.jffs2-SOURCE_DATE_EPOCH.patch @@ -20,7 +20,7 @@ } entry = xcalloc(1, sizeof(struct filesystem_entry)); -@@ -1558,6 +1558,20 @@ static void parse_image(void){ +@@ -1559,6 +1559,20 @@ static void parse_image(void){ close(in_fd); } @@ -41,7 +41,7 @@ int main(int argc, char **argv) { int c, opt; -@@ -1576,6 +1590,7 @@ int main(int argc, char **argv) +@@ -1577,6 +1591,7 @@ int main(int argc, char **argv) warn_page_size = 1; /* warn user if page size not 4096 */ jffs2_compressors_init(); @@ -49,7 +49,7 @@ while ((opt = getopt_long(argc, argv, "D:d:r:s:o:qUPfh?vVe:lbp::nc:m:x:X:Lty:i:", long_options, &c)) >= 0) -@@ -1626,7 +1641,7 @@ int main(int argc, char **argv) +@@ -1627,7 +1642,7 @@ int main(int argc, char **argv) break; case 'f': From 6dd14bab3f93af5fd5f206fdd2fcc12ebe6f0449 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Wed, 2 Nov 2022 16:04:52 +0100 Subject: [PATCH 10/32] strace: update to 6.0 Release Notes: https://github.com/strace/strace/releases/tag/v6.0 Signed-off-by: Nick Hainke --- package/devel/strace/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/devel/strace/Makefile b/package/devel/strace/Makefile index 71d7945003..7500c37316 100644 --- a/package/devel/strace/Makefile +++ b/package/devel/strace/Makefile @@ -9,12 +9,12 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=strace -PKG_VERSION:=5.19 +PKG_VERSION:=6.0 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=https://strace.io/files/$(PKG_VERSION) -PKG_HASH:=aa3dc1c8e60e4f6ff3d396514aa247f3c7bf719d8a8dc4dd4fa793be786beca3 +PKG_HASH:=92d720a666855e9f1c6a11512fd6e99674a82bbfe1442557815f2ce8e1293338 PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=LGPL-2.1-or-later From e0e7e349fa93c8f147e32395d2d20936badf3d5a Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Wed, 2 Nov 2022 16:14:22 +0100 Subject: [PATCH 11/32] tools/elfutils: update to 1.88 Release Notes: https://sourceware.org/pipermail/elfutils-devel/2022q4/005561.html Signed-off-by: Nick Hainke --- tools/elfutils/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/elfutils/Makefile b/tools/elfutils/Makefile index 37e0d545f8..4461e45b68 100644 --- a/tools/elfutils/Makefile +++ b/tools/elfutils/Makefile @@ -3,12 +3,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=elfutils -PKG_VERSION:=0.187 +PKG_VERSION:=0.188 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://sourceware.org/$(PKG_NAME)/ftp/$(PKG_VERSION) -PKG_HASH:=e70b0dfbe610f90c4d1fe0d71af142a4e25c3c4ef9ebab8d2d72b65159d454c8 +PKG_HASH:=fb8b0e8d0802005b9a309c60c1d8de32dd2951b56f0c3a3cb56d21ce01595dff PKG_LICENSE:=GPL-3.0-or-later PKG_LICENSE_FILES:=COPYING COPYING-GPLV2 COPYING-LGPLV3 From bef3699ad5f6a5d41570b9c45b702ceb2c03f129 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Wed, 2 Nov 2022 16:18:34 +0100 Subject: [PATCH 12/32] elfutils: update to 1.88 Release Notes: https://sourceware.org/pipermail/elfutils-devel/2022q4/005561.html Refresh patches: - 003-libintl-compatibility.patch - 100-musl-compat.patch - 101-no-fts.patch Signed-off-by: Nick Hainke --- package/libs/elfutils/Makefile | 4 ++-- .../libs/elfutils/patches/003-libintl-compatibility.patch | 2 +- package/libs/elfutils/patches/100-musl-compat.patch | 4 ++-- package/libs/elfutils/patches/101-no-fts.patch | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package/libs/elfutils/Makefile b/package/libs/elfutils/Makefile index 4ca37d3b06..d4e5d994e8 100644 --- a/package/libs/elfutils/Makefile +++ b/package/libs/elfutils/Makefile @@ -7,12 +7,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=elfutils -PKG_VERSION:=0.187 +PKG_VERSION:=0.188 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://sourceware.org/$(PKG_NAME)/ftp/$(PKG_VERSION) -PKG_HASH:=e70b0dfbe610f90c4d1fe0d71af142a4e25c3c4ef9ebab8d2d72b65159d454c8 +PKG_HASH:=fb8b0e8d0802005b9a309c60c1d8de32dd2951b56f0c3a3cb56d21ce01595dff PKG_MAINTAINER:=Luiz Angelo Daros de Luca PKG_LICENSE:=GPL-3.0-or-later diff --git a/package/libs/elfutils/patches/003-libintl-compatibility.patch b/package/libs/elfutils/patches/003-libintl-compatibility.patch index 3254dcffb2..ce71602d77 100644 --- a/package/libs/elfutils/patches/003-libintl-compatibility.patch +++ b/package/libs/elfutils/patches/003-libintl-compatibility.patch @@ -11,7 +11,7 @@ Requires.private: zlib --- a/configure.ac +++ b/configure.ac -@@ -610,6 +610,9 @@ dnl AM_GNU_GETTEXT_REQUIRE_VERSION suppo +@@ -652,6 +652,9 @@ dnl AM_GNU_GETTEXT_REQUIRE_VERSION suppo AM_GNU_GETTEXT_VERSION([0.19.6]) AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.6]) diff --git a/package/libs/elfutils/patches/100-musl-compat.patch b/package/libs/elfutils/patches/100-musl-compat.patch index 52b9f2c43b..3fa095bd74 100644 --- a/package/libs/elfutils/patches/100-musl-compat.patch +++ b/package/libs/elfutils/patches/100-musl-compat.patch @@ -9,7 +9,7 @@ } --- a/libdwfl/dwfl_error.c +++ b/libdwfl/dwfl_error.c -@@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error) +@@ -139,6 +139,7 @@ __libdwfl_seterrno (Dwfl_Error error) static const char * errnomsg(int error) { @@ -17,7 +17,7 @@ /* Won't be changed by strerror_r, but not const so compiler doesn't throw warning */ static char unknown[] = "unknown error"; -@@ -150,6 +151,9 @@ errnomsg(int error) +@@ -149,6 +150,9 @@ errnomsg(int error) static __thread char msg[128]; return strerror_r (error, msg, sizeof (msg)) ? unknown : msg; #endif diff --git a/package/libs/elfutils/patches/101-no-fts.patch b/package/libs/elfutils/patches/101-no-fts.patch index c4f0b88233..29a6c4b36c 100644 --- a/package/libs/elfutils/patches/101-no-fts.patch +++ b/package/libs/elfutils/patches/101-no-fts.patch @@ -1,6 +1,6 @@ --- a/libdwfl/argp-std.c +++ b/libdwfl/argp-std.c -@@ -53,9 +53,6 @@ static const struct argp_option options[ +@@ -51,9 +51,6 @@ static const struct argp_option options[ { "linux-process-map", 'M', "FILE", 0, N_("Find addresses in files mapped as read from FILE" " in Linux /proc/PID/maps format"), 0 }, @@ -10,7 +10,7 @@ { "debuginfo-path", OPT_DEBUGINFO, "PATH", 0, N_("Search path for separate debuginfo files"), 0 }, { NULL, 0, NULL, 0, NULL, 0 } -@@ -82,15 +79,6 @@ static const Dwfl_Callbacks proc_callbac +@@ -80,15 +77,6 @@ static const Dwfl_Callbacks proc_callbac .find_elf = INTUSE(dwfl_linux_proc_find_elf), }; @@ -26,7 +26,7 @@ /* Structure held at state->HOOK. */ struct parse_opt { -@@ -223,43 +211,6 @@ parse_opt (int key, char *arg, struct ar +@@ -221,43 +209,6 @@ parse_opt (int key, char *arg, struct ar } break; From a0814f04ed955eb10b25df0ce6666ed91f11ca1b Mon Sep 17 00:00:00 2001 From: John Audia Date: Thu, 3 Nov 2022 09:27:49 -0400 Subject: [PATCH 13/32] openssl: bump to 1.1.1s Changes between 1.1.1r and 1.1.1s [1 Nov 2022] *) Fixed a regression introduced in 1.1.1r version not refreshing the certificate data to be signed before signing the certificate. [Gibeom Gwon] Changes between 1.1.1q and 1.1.1r [11 Oct 2022] *) Fixed the linux-mips64 Configure target which was missing the SIXTY_FOUR_BIT bn_ops flag. This was causing heap corruption on that platform. [Adam Joseph] *) Fixed a strict aliasing problem in bn_nist. Clang-14 optimisation was causing incorrect results in some cases as a result. [Paul Dale] *) Fixed SSL_pending() and SSL_has_pending() with DTLS which were failing to report correct results in some cases [Matt Caswell] *) Fixed a regression introduced in 1.1.1o for re-signing certificates with different key sizes [Todd Short] *) Added the loongarch64 target [Shi Pujin] *) Fixed a DRBG seed propagation thread safety issue [Bernd Edlinger] *) Fixed a memory leak in tls13_generate_secret [Bernd Edlinger] *) Fixed reported performance degradation on aarch64. Restored the implementation prior to commit 2621751 ("aes/asm/aesv8-armx.pl: avoid 32-bit lane assignment in CTR mode") for 64bit targets only, since it is reportedly 2-17% slower and the silicon errata only affects 32bit targets. The new algorithm is still used for 32 bit targets. [Bernd Edlinger] *) Added a missing header for memcmp that caused compilation failure on some platforms [Gregor Jasny] Build system: x86_64 Build-tested: bcm2711/RPi4B Run-tested: bcm2711/RPi4B Signed-off-by: John Audia --- package/libs/openssl/Makefile | 4 +- ...m-ppc-xlate.pl-add-linux64v2-flavour.patch | 1 - .../patches/100-Configure-afalg-support.patch | 3 +- .../openssl/patches/110-openwrt_targets.patch | 2 - .../120-strip-cflags-from-binary.patch | 3 +- .../patches/130-dont-build-tests-fuzz.patch | 3 +- .../patches/140-allow-prefer-chacha20.patch | 6 +- .../150-openssl.cnf-add-engines-conf.patch | 1 - ...o-save-ioctl-if-EVP_MD_.FLAG_ONESHOT.patch | 5 +- ..._devcrypto-add-configuration-options.patch | 20 +- ...ypto-add-command-to-dump-driver-info.patch | 15 +- ...o-make-the-dev-crypto-engine-dynamic.patch | 2626 ++++++++++++++++- ...default-to-not-use-digests-in-engine.patch | 3 +- ...to-ignore-error-when-closing-session.patch | 3 +- 14 files changed, 2527 insertions(+), 168 deletions(-) diff --git a/package/libs/openssl/Makefile b/package/libs/openssl/Makefile index bf2d6ae64d..d9b082979b 100644 --- a/package/libs/openssl/Makefile +++ b/package/libs/openssl/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=openssl PKG_BASE:=1.1.1 -PKG_BUGFIX:=q +PKG_BUGFIX:=s PKG_VERSION:=$(PKG_BASE)$(PKG_BUGFIX) PKG_RELEASE:=$(AUTORELEASE) PKG_USE_MIPS16:=0 @@ -25,7 +25,7 @@ PKG_SOURCE_URL:= \ ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/ \ ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/old/$(PKG_BASE)/ -PKG_HASH:=d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca +PKG_HASH:=c5ac01e760ee6ff0dab61d6b2bbd30146724d063eb322180c6f18a6f74e4b6aa PKG_LICENSE:=OpenSSL PKG_LICENSE_FILES:=LICENSE diff --git a/package/libs/openssl/patches/001-crypto-perlasm-ppc-xlate.pl-add-linux64v2-flavour.patch b/package/libs/openssl/patches/001-crypto-perlasm-ppc-xlate.pl-add-linux64v2-flavour.patch index e52a3d52ea..3da67e25fc 100644 --- a/package/libs/openssl/patches/001-crypto-perlasm-ppc-xlate.pl-add-linux64v2-flavour.patch +++ b/package/libs/openssl/patches/001-crypto-perlasm-ppc-xlate.pl-add-linux64v2-flavour.patch @@ -15,7 +15,6 @@ Reviewed-by: Paul Dale Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/8883) -diff --git a/crypto/perlasm/ppc-xlate.pl b/crypto/perlasm/ppc-xlate.pl --- a/crypto/perlasm/ppc-xlate.pl +++ b/crypto/perlasm/ppc-xlate.pl @@ -49,7 +49,7 @@ my $globl = sub { diff --git a/package/libs/openssl/patches/100-Configure-afalg-support.patch b/package/libs/openssl/patches/100-Configure-afalg-support.patch index 3125e37a94..746c50621f 100644 --- a/package/libs/openssl/patches/100-Configure-afalg-support.patch +++ b/package/libs/openssl/patches/100-Configure-afalg-support.patch @@ -8,10 +8,9 @@ version to disable building the AFALG engine on openwrt targets. Signed-off-by: Eneas U de Queiroz -diff --git a/Configure b/Configure --- a/Configure +++ b/Configure -@@ -1548,7 +1548,9 @@ unless ($disabled{"crypto-mdebug-backtrace"}) +@@ -1548,7 +1548,9 @@ unless ($disabled{"crypto-mdebug-backtra unless ($disabled{afalgeng}) { $config{afalgeng}=""; diff --git a/package/libs/openssl/patches/110-openwrt_targets.patch b/package/libs/openssl/patches/110-openwrt_targets.patch index 9d5db6cfd1..6b4fbad0a7 100644 --- a/package/libs/openssl/patches/110-openwrt_targets.patch +++ b/package/libs/openssl/patches/110-openwrt_targets.patch @@ -7,8 +7,6 @@ Targets are named: linux-$(CONFIG_ARCH)-openwrt Signed-off-by: Eneas U de Queiroz -diff --git a/Configurations/25-openwrt.conf b/Configurations/25-openwrt.conf -new file mode 100644 --- /dev/null +++ b/Configurations/25-openwrt.conf @@ -0,0 +1,52 @@ diff --git a/package/libs/openssl/patches/120-strip-cflags-from-binary.patch b/package/libs/openssl/patches/120-strip-cflags-from-binary.patch index 20fe21f2ac..90282706d1 100644 --- a/package/libs/openssl/patches/120-strip-cflags-from-binary.patch +++ b/package/libs/openssl/patches/120-strip-cflags-from-binary.patch @@ -8,10 +8,9 @@ OpenSSL_version(OPENSSL_CFLAGS), or running openssl version -a Signed-off-by: Eneas U de Queiroz -diff --git a/crypto/build.info b/crypto/build.info --- a/crypto/build.info +++ b/crypto/build.info -@@ -10,7 +10,7 @@ EXTRA= ../ms/uplink-x86.pl ../ms/uplink.c ../ms/applink.c \ +@@ -10,7 +10,7 @@ EXTRA= ../ms/uplink-x86.pl ../ms/uplink ppccpuid.pl pariscid.pl alphacpuid.pl arm64cpuid.pl armv4cpuid.pl DEPEND[cversion.o]=buildinf.h diff --git a/package/libs/openssl/patches/130-dont-build-tests-fuzz.patch b/package/libs/openssl/patches/130-dont-build-tests-fuzz.patch index 4707554d2d..baf8bca9e1 100644 --- a/package/libs/openssl/patches/130-dont-build-tests-fuzz.patch +++ b/package/libs/openssl/patches/130-dont-build-tests-fuzz.patch @@ -7,10 +7,9 @@ This shortens build time. Signed-off-by: Eneas U de Queiroz -diff --git a/Configure b/Configure --- a/Configure +++ b/Configure -@@ -318,7 +318,7 @@ my $auto_threads=1; # enable threads automatically? true by default +@@ -318,7 +318,7 @@ my $auto_threads=1; # enable threads my $default_ranlib; # Top level directories to build diff --git a/package/libs/openssl/patches/140-allow-prefer-chacha20.patch b/package/libs/openssl/patches/140-allow-prefer-chacha20.patch index b2418006a9..99afd9acf8 100644 --- a/package/libs/openssl/patches/140-allow-prefer-chacha20.patch +++ b/package/libs/openssl/patches/140-allow-prefer-chacha20.patch @@ -14,7 +14,6 @@ when the client has it on top of its ciphersuite preference. Signed-off-by: Eneas U de Queiroz -diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h --- a/include/openssl/ssl.h +++ b/include/openssl/ssl.h @@ -173,9 +173,15 @@ extern "C" { @@ -36,10 +35,9 @@ diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h # else # define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \ "TLS_AES_128_GCM_SHA256" -diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c --- a/ssl/ssl_ciph.c +++ b/ssl/ssl_ciph.c -@@ -1467,11 +1467,29 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, +@@ -1465,11 +1465,29 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_ ssl_cipher_apply_rule(0, SSL_kECDHE, 0, 0, 0, 0, 0, CIPHER_DEL, -1, &head, &tail); @@ -69,7 +67,7 @@ diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c /* * ...and generally, our preferred cipher is AES. -@@ -1527,7 +1545,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, +@@ -1525,7 +1543,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_ * Within each group, ciphers remain sorted by strength and previous * preference, i.e., * 1) ECDHE > DHE diff --git a/package/libs/openssl/patches/150-openssl.cnf-add-engines-conf.patch b/package/libs/openssl/patches/150-openssl.cnf-add-engines-conf.patch index 8851116347..fa92fbe2ab 100644 --- a/package/libs/openssl/patches/150-openssl.cnf-add-engines-conf.patch +++ b/package/libs/openssl/patches/150-openssl.cnf-add-engines-conf.patch @@ -8,7 +8,6 @@ This adds configuration options for engines, loading all cnf files under Signed-off-by: Eneas U de Queiroz -diff --git a/apps/openssl.cnf b/apps/openssl.cnf --- a/apps/openssl.cnf +++ b/apps/openssl.cnf @@ -22,6 +22,16 @@ oid_section = new_oids diff --git a/package/libs/openssl/patches/400-eng_devcrypto-save-ioctl-if-EVP_MD_.FLAG_ONESHOT.patch b/package/libs/openssl/patches/400-eng_devcrypto-save-ioctl-if-EVP_MD_.FLAG_ONESHOT.patch index 71c9fdd438..ed8204c339 100644 --- a/package/libs/openssl/patches/400-eng_devcrypto-save-ioctl-if-EVP_MD_.FLAG_ONESHOT.patch +++ b/package/libs/openssl/patches/400-eng_devcrypto-save-ioctl-if-EVP_MD_.FLAG_ONESHOT.patch @@ -14,7 +14,6 @@ Reviewed-by: Matthias St. Pierre Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/7585) -diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c --- a/crypto/engine/eng_devcrypto.c +++ b/crypto/engine/eng_devcrypto.c @@ -461,6 +461,7 @@ struct digest_ctx { @@ -25,7 +24,7 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c }; static const struct digest_data_st { -@@ -564,12 +565,15 @@ static int digest_update(EVP_MD_CTX *ctx, const void *data, size_t count) +@@ -564,12 +565,15 @@ static int digest_update(EVP_MD_CTX *ctx if (digest_ctx == NULL) return 0; @@ -45,7 +44,7 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c } static int digest_final(EVP_MD_CTX *ctx, unsigned char *md) -@@ -579,7 +583,10 @@ static int digest_final(EVP_MD_CTX *ctx, unsigned char *md) +@@ -579,7 +583,10 @@ static int digest_final(EVP_MD_CTX *ctx, if (md == NULL || digest_ctx == NULL) return 0; diff --git a/package/libs/openssl/patches/410-eng_devcrypto-add-configuration-options.patch b/package/libs/openssl/patches/410-eng_devcrypto-add-configuration-options.patch index 6d0fbfc982..bad7a37256 100644 --- a/package/libs/openssl/patches/410-eng_devcrypto-add-configuration-options.patch +++ b/package/libs/openssl/patches/410-eng_devcrypto-add-configuration-options.patch @@ -13,7 +13,6 @@ Reviewed-by: Matthias St. Pierre Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/7585) -diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c --- a/crypto/engine/eng_devcrypto.c +++ b/crypto/engine/eng_devcrypto.c @@ -16,6 +16,7 @@ @@ -79,7 +78,7 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c /* * Code further down must make sure that only NIDs in the table above -@@ -333,19 +367,40 @@ static int cipher_cleanup(EVP_CIPHER_CTX *ctx) +@@ -333,19 +367,40 @@ static int cipher_cleanup(EVP_CIPHER_CTX } /* @@ -185,7 +184,7 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c static const EVP_CIPHER *get_cipher_method(int nid) { size_t i = get_cipher_data_index(nid); -@@ -438,6 +520,36 @@ static int devcrypto_ciphers(ENGINE *e, const EVP_CIPHER **cipher, +@@ -438,6 +520,36 @@ static int devcrypto_ciphers(ENGINE *e, return *cipher != NULL; } @@ -246,7 +245,7 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c /* * Code further down must make sure that only NIDs in the table above -@@ -516,8 +637,8 @@ static const struct digest_data_st *get_digest_data(int nid) +@@ -516,8 +637,8 @@ static const struct digest_data_st *get_ } /* @@ -257,7 +256,7 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c */ static int digest_init(EVP_MD_CTX *ctx) -@@ -630,52 +751,94 @@ static int digest_cleanup(EVP_MD_CTX *ctx) +@@ -630,52 +751,94 @@ static int digest_cleanup(EVP_MD_CTX *ct return clean_devcrypto_session(&digest_ctx->sess); } @@ -402,7 +401,7 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c } } -@@ -739,8 +909,154 @@ static int devcrypto_digests(ENGINE *e, const EVP_MD **digest, +@@ -739,7 +909,153 @@ static int devcrypto_digests(ENGINE *e, return *digest != NULL; } @@ -478,8 +477,8 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c + "DIGESTS", + "either ALL, NONE, or a comma-separated list of digests to enable [default=ALL]", + ENGINE_CMD_FLAG_STRING}, - #endif - ++#endif ++ + {0, NULL, NULL, 0} +}; + @@ -503,7 +502,7 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c + use_softdrivers = i; +#ifdef IMPLEMENT_DIGEST + rebuild_known_digest_nids(e); -+#endif + #endif + rebuild_known_cipher_nids(e); + return 1; +#endif /* CIOCGSESSINFO */ @@ -553,10 +552,9 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c + } + return 0; +} -+ + /****************************************************************************** * - * LOAD / UNLOAD @@ -806,6 +1122,8 @@ void engine_load_devcrypto_int() if (!ENGINE_set_id(e, "devcrypto") diff --git a/package/libs/openssl/patches/420-eng_devcrypto-add-command-to-dump-driver-info.patch b/package/libs/openssl/patches/420-eng_devcrypto-add-command-to-dump-driver-info.patch index 83989a3625..eee71c6c62 100644 --- a/package/libs/openssl/patches/420-eng_devcrypto-add-command-to-dump-driver-info.patch +++ b/package/libs/openssl/patches/420-eng_devcrypto-add-command-to-dump-driver-info.patch @@ -11,10 +11,9 @@ Reviewed-by: Matthias St. Pierre Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/7585) -diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c --- a/crypto/engine/eng_devcrypto.c +++ b/crypto/engine/eng_devcrypto.c -@@ -50,16 +50,20 @@ static int use_softdrivers = DEVCRYPTO_DEFAULT_USE_SOFDTRIVERS; +@@ -50,16 +50,20 @@ static int use_softdrivers = DEVCRYPTO_D */ struct driver_info_st { enum devcrypto_status_t { @@ -81,7 +80,7 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c #endif /* CIOCGSESSINFO */ } ioctl(cfd, CIOCFSESSION, &sess.ses); -@@ -505,8 +514,11 @@ static void destroy_all_cipher_methods(void) +@@ -505,8 +514,11 @@ static void destroy_all_cipher_methods(v { size_t i; @@ -94,7 +93,7 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c } static int devcrypto_ciphers(ENGINE *e, const EVP_CIPHER **cipher, -@@ -550,6 +562,40 @@ static int cryptodev_select_cipher_cb(const char *str, int len, void *usr) +@@ -550,6 +562,40 @@ static int cryptodev_select_cipher_cb(co return 1; } @@ -189,7 +188,7 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c EVP_MD_meth_free(known_digest_methods[i]); known_digest_methods[i] = NULL; goto finish; -@@ -894,8 +945,11 @@ static void destroy_all_digest_methods(void) +@@ -894,8 +945,11 @@ static void destroy_all_digest_methods(v { size_t i; @@ -202,7 +201,7 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c } static int devcrypto_digests(ENGINE *e, const EVP_MD **digest, -@@ -939,6 +993,43 @@ static int cryptodev_select_digest_cb(const char *str, int len, void *usr) +@@ -939,6 +993,43 @@ static int cryptodev_select_digest_cb(co return 1; } @@ -246,7 +245,7 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c #endif /****************************************************************************** -@@ -983,6 +1074,11 @@ static const ENGINE_CMD_DEFN devcrypto_cmds[] = { +@@ -983,6 +1074,11 @@ static const ENGINE_CMD_DEFN devcrypto_c ENGINE_CMD_FLAG_STRING}, #endif @@ -258,7 +257,7 @@ diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c {0, NULL, NULL, 0} }; -@@ -1051,6 +1147,13 @@ static int devcrypto_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void)) +@@ -1051,6 +1147,13 @@ static int devcrypto_ctrl(ENGINE *e, int return 1; #endif /* IMPLEMENT_DIGEST */ diff --git a/package/libs/openssl/patches/430-e_devcrypto-make-the-dev-crypto-engine-dynamic.patch b/package/libs/openssl/patches/430-e_devcrypto-make-the-dev-crypto-engine-dynamic.patch index da9b704501..00c74972ab 100644 --- a/package/libs/openssl/patches/430-e_devcrypto-make-the-dev-crypto-engine-dynamic.patch +++ b/package/libs/openssl/patches/430-e_devcrypto-make-the-dev-crypto-engine-dynamic.patch @@ -8,7 +8,6 @@ engines/e_devcrypto.c. Signed-off-by: Eneas U de Queiroz -diff --git a/crypto/engine/build.info b/crypto/engine/build.info --- a/crypto/engine/build.info +++ b/crypto/engine/build.info @@ -6,6 +6,3 @@ SOURCE[../../libcrypto]=\ @@ -18,10 +17,9 @@ diff --git a/crypto/engine/build.info b/crypto/engine/build.info -IF[{- !$disabled{devcryptoeng} -}] - SOURCE[../../libcrypto]=eng_devcrypto.c -ENDIF -diff --git a/crypto/init.c b/crypto/init.c --- a/crypto/init.c +++ b/crypto/init.c -@@ -328,18 +328,6 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_engine_openssl) +@@ -328,18 +328,6 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_engine_ engine_load_openssl_int(); return 1; } @@ -40,7 +38,7 @@ diff --git a/crypto/init.c b/crypto/init.c # ifndef OPENSSL_NO_RDRAND static CRYPTO_ONCE engine_rdrand = CRYPTO_ONCE_STATIC_INIT; -@@ -364,6 +352,18 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_engine_dynamic) +@@ -364,6 +352,18 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_engine_ return 1; } # ifndef OPENSSL_NO_STATIC_ENGINE @@ -59,7 +57,7 @@ diff --git a/crypto/init.c b/crypto/init.c # if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_PADLOCK) static CRYPTO_ONCE engine_padlock = CRYPTO_ONCE_STATIC_INIT; DEFINE_RUN_ONCE_STATIC(ossl_init_engine_padlock) -@@ -704,11 +704,6 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) +@@ -704,11 +704,6 @@ int OPENSSL_init_crypto(uint64_t opts, c if ((opts & OPENSSL_INIT_ENGINE_OPENSSL) && !RUN_ONCE(&engine_openssl, ossl_init_engine_openssl)) return 0; @@ -71,7 +69,7 @@ diff --git a/crypto/init.c b/crypto/init.c # ifndef OPENSSL_NO_RDRAND if ((opts & OPENSSL_INIT_ENGINE_RDRAND) && !RUN_ONCE(&engine_rdrand, ossl_init_engine_rdrand)) -@@ -718,6 +713,11 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) +@@ -718,6 +713,11 @@ int OPENSSL_init_crypto(uint64_t opts, c && !RUN_ONCE(&engine_dynamic, ossl_init_engine_dynamic)) return 0; # ifndef OPENSSL_NO_STATIC_ENGINE @@ -83,7 +81,6 @@ diff --git a/crypto/init.c b/crypto/init.c # if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_PADLOCK) if ((opts & OPENSSL_INIT_ENGINE_PADLOCK) && !RUN_ONCE(&engine_padlock, ossl_init_engine_padlock)) -diff --git a/engines/build.info b/engines/build.info --- a/engines/build.info +++ b/engines/build.info @@ -11,6 +11,9 @@ IF[{- !$disabled{"engine"} -}] @@ -109,58 +106,1177 @@ diff --git a/engines/build.info b/engines/build.info ENGINES_NO_INST=ossltest dasync SOURCE[dasync]=e_dasync.c -diff --git a/crypto/engine/eng_devcrypto.c b/engines/e_devcrypto.c -similarity index 95% -rename from crypto/engine/eng_devcrypto.c -rename to engines/e_devcrypto.c --- a/crypto/engine/eng_devcrypto.c -+++ b/engines/e_devcrypto.c -@@ -7,7 +7,7 @@ - * https://www.openssl.org/source/license.html - */ - ++++ /dev/null +@@ -1,1277 +0,0 @@ +-/* +- * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved. +- * +- * Licensed under the OpenSSL license (the "License"). You may not use +- * this file except in compliance with the License. You can obtain a copy +- * in the file LICENSE in the source distribution or at +- * https://www.openssl.org/source/license.html +- */ +- -#include "e_os.h" -+#include "../e_os.h" - #include - #include - #include -@@ -31,18 +31,20 @@ - # define CHECK_BSD_STYLE_MACROS - #endif - -+#define engine_devcrypto_id "devcrypto" -+ - /* - * ONE global file descriptor for all sessions. This allows operations - * such as digest session data copying (see digest_copy()), but is also - * saner... why re-open /dev/crypto for every session? - */ +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-#include +-#include +-#include +-#include +-#include +-#include +- +-#include "crypto/engine.h" +- +-/* #define ENGINE_DEVCRYPTO_DEBUG */ +- +-#if CRYPTO_ALGORITHM_MIN < CRYPTO_ALGORITHM_MAX +-# define CHECK_BSD_STYLE_MACROS +-#endif +- +-/* +- * ONE global file descriptor for all sessions. This allows operations +- * such as digest session data copying (see digest_copy()), but is also +- * saner... why re-open /dev/crypto for every session? +- */ -static int cfd; -+static int cfd = -1; - #define DEVCRYPTO_REQUIRE_ACCELERATED 0 /* require confirmation of acceleration */ - #define DEVCRYPTO_USE_SOFTWARE 1 /* allow software drivers */ - #define DEVCRYPTO_REJECT_SOFTWARE 2 /* only disallow confirmed software drivers */ - +-#define DEVCRYPTO_REQUIRE_ACCELERATED 0 /* require confirmation of acceleration */ +-#define DEVCRYPTO_USE_SOFTWARE 1 /* allow software drivers */ +-#define DEVCRYPTO_REJECT_SOFTWARE 2 /* only disallow confirmed software drivers */ +- -#define DEVCRYPTO_DEFAULT_USE_SOFDTRIVERS DEVCRYPTO_REJECT_SOFTWARE -static int use_softdrivers = DEVCRYPTO_DEFAULT_USE_SOFDTRIVERS; -+#define DEVCRYPTO_DEFAULT_USE_SOFTDRIVERS DEVCRYPTO_REJECT_SOFTWARE -+static int use_softdrivers = DEVCRYPTO_DEFAULT_USE_SOFTDRIVERS; - - /* - * cipher/digest status & acceleration definitions -@@ -1058,7 +1060,7 @@ static const ENGINE_CMD_DEFN devcrypto_cmds[] = { - OPENSSL_MSTR(DEVCRYPTO_USE_SOFTWARE) "=allow all drivers, " - OPENSSL_MSTR(DEVCRYPTO_REJECT_SOFTWARE) - "=use if acceleration can't be determined) [default=" +- +-/* +- * cipher/digest status & acceleration definitions +- * Make sure the defaults are set to 0 +- */ +-struct driver_info_st { +- enum devcrypto_status_t { +- DEVCRYPTO_STATUS_FAILURE = -3, /* unusable for other reason */ +- DEVCRYPTO_STATUS_NO_CIOCCPHASH = -2, /* hash state copy not supported */ +- DEVCRYPTO_STATUS_NO_CIOCGSESSION = -1, /* session open failed */ +- DEVCRYPTO_STATUS_UNKNOWN = 0, /* not tested yet */ +- DEVCRYPTO_STATUS_USABLE = 1 /* algo can be used */ +- } status; +- +- enum devcrypto_accelerated_t { +- DEVCRYPTO_NOT_ACCELERATED = -1, /* software implemented */ +- DEVCRYPTO_ACCELERATION_UNKNOWN = 0, /* acceleration support unkown */ +- DEVCRYPTO_ACCELERATED = 1 /* hardware accelerated */ +- } accelerated; +- +- char *driver_name; +-}; +- +-static int clean_devcrypto_session(struct session_op *sess) { +- if (ioctl(cfd, CIOCFSESSION, &sess->ses) < 0) { +- SYSerr(SYS_F_IOCTL, errno); +- return 0; +- } +- memset(sess, 0, sizeof(struct session_op)); +- return 1; +-} +- +-/****************************************************************************** +- * +- * Ciphers +- * +- * Because they all do the same basic operation, we have only one set of +- * method functions for them all to share, and a mapping table between +- * NIDs and cryptodev IDs, with all the necessary size data. +- * +- *****/ +- +-struct cipher_ctx { +- struct session_op sess; +- int op; /* COP_ENCRYPT or COP_DECRYPT */ +- unsigned long mode; /* EVP_CIPH_*_MODE */ +- +- /* to handle ctr mode being a stream cipher */ +- unsigned char partial[EVP_MAX_BLOCK_LENGTH]; +- unsigned int blocksize, num; +-}; +- +-static const struct cipher_data_st { +- int nid; +- int blocksize; +- int keylen; +- int ivlen; +- int flags; +- int devcryptoid; +-} cipher_data[] = { +-#ifndef OPENSSL_NO_DES +- { NID_des_cbc, 8, 8, 8, EVP_CIPH_CBC_MODE, CRYPTO_DES_CBC }, +- { NID_des_ede3_cbc, 8, 24, 8, EVP_CIPH_CBC_MODE, CRYPTO_3DES_CBC }, +-#endif +-#ifndef OPENSSL_NO_BF +- { NID_bf_cbc, 8, 16, 8, EVP_CIPH_CBC_MODE, CRYPTO_BLF_CBC }, +-#endif +-#ifndef OPENSSL_NO_CAST +- { NID_cast5_cbc, 8, 16, 8, EVP_CIPH_CBC_MODE, CRYPTO_CAST_CBC }, +-#endif +- { NID_aes_128_cbc, 16, 128 / 8, 16, EVP_CIPH_CBC_MODE, CRYPTO_AES_CBC }, +- { NID_aes_192_cbc, 16, 192 / 8, 16, EVP_CIPH_CBC_MODE, CRYPTO_AES_CBC }, +- { NID_aes_256_cbc, 16, 256 / 8, 16, EVP_CIPH_CBC_MODE, CRYPTO_AES_CBC }, +-#ifndef OPENSSL_NO_RC4 +- { NID_rc4, 1, 16, 0, EVP_CIPH_STREAM_CIPHER, CRYPTO_ARC4 }, +-#endif +-#if !defined(CHECK_BSD_STYLE_MACROS) || defined(CRYPTO_AES_CTR) +- { NID_aes_128_ctr, 16, 128 / 8, 16, EVP_CIPH_CTR_MODE, CRYPTO_AES_CTR }, +- { NID_aes_192_ctr, 16, 192 / 8, 16, EVP_CIPH_CTR_MODE, CRYPTO_AES_CTR }, +- { NID_aes_256_ctr, 16, 256 / 8, 16, EVP_CIPH_CTR_MODE, CRYPTO_AES_CTR }, +-#endif +-#if 0 /* Not yet supported */ +- { NID_aes_128_xts, 16, 128 / 8 * 2, 16, EVP_CIPH_XTS_MODE, CRYPTO_AES_XTS }, +- { NID_aes_256_xts, 16, 256 / 8 * 2, 16, EVP_CIPH_XTS_MODE, CRYPTO_AES_XTS }, +-#endif +-#if !defined(CHECK_BSD_STYLE_MACROS) || defined(CRYPTO_AES_ECB) +- { NID_aes_128_ecb, 16, 128 / 8, 0, EVP_CIPH_ECB_MODE, CRYPTO_AES_ECB }, +- { NID_aes_192_ecb, 16, 192 / 8, 0, EVP_CIPH_ECB_MODE, CRYPTO_AES_ECB }, +- { NID_aes_256_ecb, 16, 256 / 8, 0, EVP_CIPH_ECB_MODE, CRYPTO_AES_ECB }, +-#endif +-#if 0 /* Not yet supported */ +- { NID_aes_128_gcm, 16, 128 / 8, 16, EVP_CIPH_GCM_MODE, CRYPTO_AES_GCM }, +- { NID_aes_192_gcm, 16, 192 / 8, 16, EVP_CIPH_GCM_MODE, CRYPTO_AES_GCM }, +- { NID_aes_256_gcm, 16, 256 / 8, 16, EVP_CIPH_GCM_MODE, CRYPTO_AES_GCM }, +-#endif +-#ifndef OPENSSL_NO_CAMELLIA +- { NID_camellia_128_cbc, 16, 128 / 8, 16, EVP_CIPH_CBC_MODE, +- CRYPTO_CAMELLIA_CBC }, +- { NID_camellia_192_cbc, 16, 192 / 8, 16, EVP_CIPH_CBC_MODE, +- CRYPTO_CAMELLIA_CBC }, +- { NID_camellia_256_cbc, 16, 256 / 8, 16, EVP_CIPH_CBC_MODE, +- CRYPTO_CAMELLIA_CBC }, +-#endif +-}; +- +-static size_t find_cipher_data_index(int nid) +-{ +- size_t i; +- +- for (i = 0; i < OSSL_NELEM(cipher_data); i++) +- if (nid == cipher_data[i].nid) +- return i; +- return (size_t)-1; +-} +- +-static size_t get_cipher_data_index(int nid) +-{ +- size_t i = find_cipher_data_index(nid); +- +- if (i != (size_t)-1) +- return i; +- +- /* +- * Code further down must make sure that only NIDs in the table above +- * are used. If any other NID reaches this function, there's a grave +- * coding error further down. +- */ +- assert("Code that never should be reached" == NULL); +- return -1; +-} +- +-static const struct cipher_data_st *get_cipher_data(int nid) +-{ +- return &cipher_data[get_cipher_data_index(nid)]; +-} +- +-/* +- * Following are the three necessary functions to map OpenSSL functionality +- * with cryptodev. +- */ +- +-static int cipher_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, +- const unsigned char *iv, int enc) +-{ +- struct cipher_ctx *cipher_ctx = +- (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx); +- const struct cipher_data_st *cipher_d = +- get_cipher_data(EVP_CIPHER_CTX_nid(ctx)); +- +- /* cleanup a previous session */ +- if (cipher_ctx->sess.ses != 0 && +- clean_devcrypto_session(&cipher_ctx->sess) == 0) +- return 0; +- +- cipher_ctx->sess.cipher = cipher_d->devcryptoid; +- cipher_ctx->sess.keylen = cipher_d->keylen; +- cipher_ctx->sess.key = (void *)key; +- cipher_ctx->op = enc ? COP_ENCRYPT : COP_DECRYPT; +- cipher_ctx->mode = cipher_d->flags & EVP_CIPH_MODE; +- cipher_ctx->blocksize = cipher_d->blocksize; +- if (ioctl(cfd, CIOCGSESSION, &cipher_ctx->sess) < 0) { +- SYSerr(SYS_F_IOCTL, errno); +- return 0; +- } +- +- return 1; +-} +- +-static int cipher_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, +- const unsigned char *in, size_t inl) +-{ +- struct cipher_ctx *cipher_ctx = +- (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx); +- struct crypt_op cryp; +- unsigned char *iv = EVP_CIPHER_CTX_iv_noconst(ctx); +-#if !defined(COP_FLAG_WRITE_IV) +- unsigned char saved_iv[EVP_MAX_IV_LENGTH]; +- const unsigned char *ivptr; +- size_t nblocks, ivlen; +-#endif +- +- memset(&cryp, 0, sizeof(cryp)); +- cryp.ses = cipher_ctx->sess.ses; +- cryp.len = inl; +- cryp.src = (void *)in; +- cryp.dst = (void *)out; +- cryp.iv = (void *)iv; +- cryp.op = cipher_ctx->op; +-#if !defined(COP_FLAG_WRITE_IV) +- cryp.flags = 0; +- +- ivlen = EVP_CIPHER_CTX_iv_length(ctx); +- if (ivlen > 0) +- switch (cipher_ctx->mode) { +- case EVP_CIPH_CBC_MODE: +- assert(inl >= ivlen); +- if (!EVP_CIPHER_CTX_encrypting(ctx)) { +- ivptr = in + inl - ivlen; +- memcpy(saved_iv, ivptr, ivlen); +- } +- break; +- +- case EVP_CIPH_CTR_MODE: +- break; +- +- default: /* should not happen */ +- return 0; +- } +-#else +- cryp.flags = COP_FLAG_WRITE_IV; +-#endif +- +- if (ioctl(cfd, CIOCCRYPT, &cryp) < 0) { +- SYSerr(SYS_F_IOCTL, errno); +- return 0; +- } +- +-#if !defined(COP_FLAG_WRITE_IV) +- if (ivlen > 0) +- switch (cipher_ctx->mode) { +- case EVP_CIPH_CBC_MODE: +- assert(inl >= ivlen); +- if (EVP_CIPHER_CTX_encrypting(ctx)) +- ivptr = out + inl - ivlen; +- else +- ivptr = saved_iv; +- +- memcpy(iv, ivptr, ivlen); +- break; +- +- case EVP_CIPH_CTR_MODE: +- nblocks = (inl + cipher_ctx->blocksize - 1) +- / cipher_ctx->blocksize; +- do { +- ivlen--; +- nblocks += iv[ivlen]; +- iv[ivlen] = (uint8_t) nblocks; +- nblocks >>= 8; +- } while (ivlen); +- break; +- +- default: /* should not happen */ +- return 0; +- } +-#endif +- +- return 1; +-} +- +-static int ctr_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, +- const unsigned char *in, size_t inl) +-{ +- struct cipher_ctx *cipher_ctx = +- (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx); +- size_t nblocks, len; +- +- /* initial partial block */ +- while (cipher_ctx->num && inl) { +- (*out++) = *(in++) ^ cipher_ctx->partial[cipher_ctx->num]; +- --inl; +- cipher_ctx->num = (cipher_ctx->num + 1) % cipher_ctx->blocksize; +- } +- +- /* full blocks */ +- if (inl > (unsigned int) cipher_ctx->blocksize) { +- nblocks = inl/cipher_ctx->blocksize; +- len = nblocks * cipher_ctx->blocksize; +- if (cipher_do_cipher(ctx, out, in, len) < 1) +- return 0; +- inl -= len; +- out += len; +- in += len; +- } +- +- /* final partial block */ +- if (inl) { +- memset(cipher_ctx->partial, 0, cipher_ctx->blocksize); +- if (cipher_do_cipher(ctx, cipher_ctx->partial, cipher_ctx->partial, +- cipher_ctx->blocksize) < 1) +- return 0; +- while (inl--) { +- out[cipher_ctx->num] = in[cipher_ctx->num] +- ^ cipher_ctx->partial[cipher_ctx->num]; +- cipher_ctx->num++; +- } +- } +- +- return 1; +-} +- +-static int cipher_ctrl(EVP_CIPHER_CTX *ctx, int type, int p1, void* p2) +-{ +- struct cipher_ctx *cipher_ctx = +- (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx); +- EVP_CIPHER_CTX *to_ctx = (EVP_CIPHER_CTX *)p2; +- struct cipher_ctx *to_cipher_ctx; +- +- switch (type) { +- case EVP_CTRL_COPY: +- if (cipher_ctx == NULL) +- return 1; +- /* when copying the context, a new session needs to be initialized */ +- to_cipher_ctx = +- (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(to_ctx); +- memset(&to_cipher_ctx->sess, 0, sizeof(to_cipher_ctx->sess)); +- return cipher_init(to_ctx, cipher_ctx->sess.key, EVP_CIPHER_CTX_iv(ctx), +- (cipher_ctx->op == COP_ENCRYPT)); +- +- case EVP_CTRL_INIT: +- memset(&cipher_ctx->sess, 0, sizeof(cipher_ctx->sess)); +- return 1; +- +- default: +- break; +- } +- +- return -1; +-} +- +-static int cipher_cleanup(EVP_CIPHER_CTX *ctx) +-{ +- struct cipher_ctx *cipher_ctx = +- (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx); +- +- return clean_devcrypto_session(&cipher_ctx->sess); +-} +- +-/* +- * Keep tables of known nids, associated methods, selected ciphers, and driver +- * info. +- * Note that known_cipher_nids[] isn't necessarily indexed the same way as +- * cipher_data[] above, which the other tables are. +- */ +-static int known_cipher_nids[OSSL_NELEM(cipher_data)]; +-static int known_cipher_nids_amount = -1; /* -1 indicates not yet initialised */ +-static EVP_CIPHER *known_cipher_methods[OSSL_NELEM(cipher_data)] = { NULL, }; +-static int selected_ciphers[OSSL_NELEM(cipher_data)]; +-static struct driver_info_st cipher_driver_info[OSSL_NELEM(cipher_data)]; +- +- +-static int devcrypto_test_cipher(size_t cipher_data_index) +-{ +- return (cipher_driver_info[cipher_data_index].status == DEVCRYPTO_STATUS_USABLE +- && selected_ciphers[cipher_data_index] == 1 +- && (cipher_driver_info[cipher_data_index].accelerated +- == DEVCRYPTO_ACCELERATED +- || use_softdrivers == DEVCRYPTO_USE_SOFTWARE +- || (cipher_driver_info[cipher_data_index].accelerated +- != DEVCRYPTO_NOT_ACCELERATED +- && use_softdrivers == DEVCRYPTO_REJECT_SOFTWARE))); +-} +- +-static void prepare_cipher_methods(void) +-{ +- size_t i; +- struct session_op sess; +- unsigned long cipher_mode; +-#ifdef CIOCGSESSINFO +- struct session_info_op siop; +-#endif +- +- memset(&cipher_driver_info, 0, sizeof(cipher_driver_info)); +- +- memset(&sess, 0, sizeof(sess)); +- sess.key = (void *)"01234567890123456789012345678901234567890123456789"; +- +- for (i = 0, known_cipher_nids_amount = 0; +- i < OSSL_NELEM(cipher_data); i++) { +- +- selected_ciphers[i] = 1; +- /* +- * Check that the cipher is usable +- */ +- sess.cipher = cipher_data[i].devcryptoid; +- sess.keylen = cipher_data[i].keylen; +- if (ioctl(cfd, CIOCGSESSION, &sess) < 0) { +- cipher_driver_info[i].status = DEVCRYPTO_STATUS_NO_CIOCGSESSION; +- continue; +- } +- +- cipher_mode = cipher_data[i].flags & EVP_CIPH_MODE; +- +- if ((known_cipher_methods[i] = +- EVP_CIPHER_meth_new(cipher_data[i].nid, +- cipher_mode == EVP_CIPH_CTR_MODE ? 1 : +- cipher_data[i].blocksize, +- cipher_data[i].keylen)) == NULL +- || !EVP_CIPHER_meth_set_iv_length(known_cipher_methods[i], +- cipher_data[i].ivlen) +- || !EVP_CIPHER_meth_set_flags(known_cipher_methods[i], +- cipher_data[i].flags +- | EVP_CIPH_CUSTOM_COPY +- | EVP_CIPH_CTRL_INIT +- | EVP_CIPH_FLAG_DEFAULT_ASN1) +- || !EVP_CIPHER_meth_set_init(known_cipher_methods[i], cipher_init) +- || !EVP_CIPHER_meth_set_do_cipher(known_cipher_methods[i], +- cipher_mode == EVP_CIPH_CTR_MODE ? +- ctr_do_cipher : +- cipher_do_cipher) +- || !EVP_CIPHER_meth_set_ctrl(known_cipher_methods[i], cipher_ctrl) +- || !EVP_CIPHER_meth_set_cleanup(known_cipher_methods[i], +- cipher_cleanup) +- || !EVP_CIPHER_meth_set_impl_ctx_size(known_cipher_methods[i], +- sizeof(struct cipher_ctx))) { +- cipher_driver_info[i].status = DEVCRYPTO_STATUS_FAILURE; +- EVP_CIPHER_meth_free(known_cipher_methods[i]); +- known_cipher_methods[i] = NULL; +- } else { +- cipher_driver_info[i].status = DEVCRYPTO_STATUS_USABLE; +-#ifdef CIOCGSESSINFO +- siop.ses = sess.ses; +- if (ioctl(cfd, CIOCGSESSINFO, &siop) < 0) { +- cipher_driver_info[i].accelerated = DEVCRYPTO_ACCELERATION_UNKNOWN; +- } else { +- cipher_driver_info[i].driver_name = +- OPENSSL_strndup(siop.cipher_info.cra_driver_name, +- CRYPTODEV_MAX_ALG_NAME); +- if (!(siop.flags & SIOP_FLAG_KERNEL_DRIVER_ONLY)) +- cipher_driver_info[i].accelerated = DEVCRYPTO_NOT_ACCELERATED; +- else +- cipher_driver_info[i].accelerated = DEVCRYPTO_ACCELERATED; +- } +-#endif /* CIOCGSESSINFO */ +- } +- ioctl(cfd, CIOCFSESSION, &sess.ses); +- if (devcrypto_test_cipher(i)) { +- known_cipher_nids[known_cipher_nids_amount++] = +- cipher_data[i].nid; +- } +- } +-} +- +-static void rebuild_known_cipher_nids(ENGINE *e) +-{ +- size_t i; +- +- for (i = 0, known_cipher_nids_amount = 0; i < OSSL_NELEM(cipher_data); i++) { +- if (devcrypto_test_cipher(i)) +- known_cipher_nids[known_cipher_nids_amount++] = cipher_data[i].nid; +- } +- ENGINE_unregister_ciphers(e); +- ENGINE_register_ciphers(e); +-} +- +-static const EVP_CIPHER *get_cipher_method(int nid) +-{ +- size_t i = get_cipher_data_index(nid); +- +- if (i == (size_t)-1) +- return NULL; +- return known_cipher_methods[i]; +-} +- +-static int get_cipher_nids(const int **nids) +-{ +- *nids = known_cipher_nids; +- return known_cipher_nids_amount; +-} +- +-static void destroy_cipher_method(int nid) +-{ +- size_t i = get_cipher_data_index(nid); +- +- EVP_CIPHER_meth_free(known_cipher_methods[i]); +- known_cipher_methods[i] = NULL; +-} +- +-static void destroy_all_cipher_methods(void) +-{ +- size_t i; +- +- for (i = 0; i < OSSL_NELEM(cipher_data); i++) { +- destroy_cipher_method(cipher_data[i].nid); +- OPENSSL_free(cipher_driver_info[i].driver_name); +- cipher_driver_info[i].driver_name = NULL; +- } +-} +- +-static int devcrypto_ciphers(ENGINE *e, const EVP_CIPHER **cipher, +- const int **nids, int nid) +-{ +- if (cipher == NULL) +- return get_cipher_nids(nids); +- +- *cipher = get_cipher_method(nid); +- +- return *cipher != NULL; +-} +- +-static void devcrypto_select_all_ciphers(int *cipher_list) +-{ +- size_t i; +- +- for (i = 0; i < OSSL_NELEM(cipher_data); i++) +- cipher_list[i] = 1; +-} +- +-static int cryptodev_select_cipher_cb(const char *str, int len, void *usr) +-{ +- int *cipher_list = (int *)usr; +- char *name; +- const EVP_CIPHER *EVP; +- size_t i; +- +- if (len == 0) +- return 1; +- if (usr == NULL || (name = OPENSSL_strndup(str, len)) == NULL) +- return 0; +- EVP = EVP_get_cipherbyname(name); +- if (EVP == NULL) +- fprintf(stderr, "devcrypto: unknown cipher %s\n", name); +- else if ((i = find_cipher_data_index(EVP_CIPHER_nid(EVP))) != (size_t)-1) +- cipher_list[i] = 1; +- else +- fprintf(stderr, "devcrypto: cipher %s not available\n", name); +- OPENSSL_free(name); +- return 1; +-} +- +-static void dump_cipher_info(void) +-{ +- size_t i; +- const char *name; +- +- fprintf (stderr, "Information about ciphers supported by the /dev/crypto" +- " engine:\n"); +-#ifndef CIOCGSESSINFO +- fprintf(stderr, "CIOCGSESSINFO (session info call) unavailable\n"); +-#endif +- for (i = 0; i < OSSL_NELEM(cipher_data); i++) { +- name = OBJ_nid2sn(cipher_data[i].nid); +- fprintf (stderr, "Cipher %s, NID=%d, /dev/crypto info: id=%d, ", +- name ? name : "unknown", cipher_data[i].nid, +- cipher_data[i].devcryptoid); +- if (cipher_driver_info[i].status == DEVCRYPTO_STATUS_NO_CIOCGSESSION ) { +- fprintf (stderr, "CIOCGSESSION (session open call) failed\n"); +- continue; +- } +- fprintf (stderr, "driver=%s ", cipher_driver_info[i].driver_name ? +- cipher_driver_info[i].driver_name : "unknown"); +- if (cipher_driver_info[i].accelerated == DEVCRYPTO_ACCELERATED) +- fprintf(stderr, "(hw accelerated)"); +- else if (cipher_driver_info[i].accelerated == DEVCRYPTO_NOT_ACCELERATED) +- fprintf(stderr, "(software)"); +- else +- fprintf(stderr, "(acceleration status unknown)"); +- if (cipher_driver_info[i].status == DEVCRYPTO_STATUS_FAILURE) +- fprintf (stderr, ". Cipher setup failed"); +- fprintf(stderr, "\n"); +- } +- fprintf(stderr, "\n"); +-} +- +-/* +- * We only support digests if the cryptodev implementation supports multiple +- * data updates and session copying. Otherwise, we would be forced to maintain +- * a cache, which is perilous if there's a lot of data coming in (if someone +- * wants to checksum an OpenSSL tarball, for example). +- */ +-#if defined(CIOCCPHASH) && defined(COP_FLAG_UPDATE) && defined(COP_FLAG_FINAL) +-#define IMPLEMENT_DIGEST +- +-/****************************************************************************** +- * +- * Digests +- * +- * Because they all do the same basic operation, we have only one set of +- * method functions for them all to share, and a mapping table between +- * NIDs and cryptodev IDs, with all the necessary size data. +- * +- *****/ +- +-struct digest_ctx { +- struct session_op sess; +- /* This signals that the init function was called, not that it succeeded. */ +- int init_called; +- unsigned char digest_res[HASH_MAX_LEN]; +-}; +- +-static const struct digest_data_st { +- int nid; +- int blocksize; +- int digestlen; +- int devcryptoid; +-} digest_data[] = { +-#ifndef OPENSSL_NO_MD5 +- { NID_md5, /* MD5_CBLOCK */ 64, 16, CRYPTO_MD5 }, +-#endif +- { NID_sha1, SHA_CBLOCK, 20, CRYPTO_SHA1 }, +-#ifndef OPENSSL_NO_RMD160 +-# if !defined(CHECK_BSD_STYLE_MACROS) || defined(CRYPTO_RIPEMD160) +- { NID_ripemd160, /* RIPEMD160_CBLOCK */ 64, 20, CRYPTO_RIPEMD160 }, +-# endif +-#endif +-#if !defined(CHECK_BSD_STYLE_MACROS) || defined(CRYPTO_SHA2_224) +- { NID_sha224, SHA256_CBLOCK, 224 / 8, CRYPTO_SHA2_224 }, +-#endif +-#if !defined(CHECK_BSD_STYLE_MACROS) || defined(CRYPTO_SHA2_256) +- { NID_sha256, SHA256_CBLOCK, 256 / 8, CRYPTO_SHA2_256 }, +-#endif +-#if !defined(CHECK_BSD_STYLE_MACROS) || defined(CRYPTO_SHA2_384) +- { NID_sha384, SHA512_CBLOCK, 384 / 8, CRYPTO_SHA2_384 }, +-#endif +-#if !defined(CHECK_BSD_STYLE_MACROS) || defined(CRYPTO_SHA2_512) +- { NID_sha512, SHA512_CBLOCK, 512 / 8, CRYPTO_SHA2_512 }, +-#endif +-}; +- +-static size_t find_digest_data_index(int nid) +-{ +- size_t i; +- +- for (i = 0; i < OSSL_NELEM(digest_data); i++) +- if (nid == digest_data[i].nid) +- return i; +- return (size_t)-1; +-} +- +-static size_t get_digest_data_index(int nid) +-{ +- size_t i = find_digest_data_index(nid); +- +- if (i != (size_t)-1) +- return i; +- +- /* +- * Code further down must make sure that only NIDs in the table above +- * are used. If any other NID reaches this function, there's a grave +- * coding error further down. +- */ +- assert("Code that never should be reached" == NULL); +- return -1; +-} +- +-static const struct digest_data_st *get_digest_data(int nid) +-{ +- return &digest_data[get_digest_data_index(nid)]; +-} +- +-/* +- * Following are the five necessary functions to map OpenSSL functionality +- * with cryptodev: init, update, final, cleanup, and copy. +- */ +- +-static int digest_init(EVP_MD_CTX *ctx) +-{ +- struct digest_ctx *digest_ctx = +- (struct digest_ctx *)EVP_MD_CTX_md_data(ctx); +- const struct digest_data_st *digest_d = +- get_digest_data(EVP_MD_CTX_type(ctx)); +- +- digest_ctx->init_called = 1; +- +- memset(&digest_ctx->sess, 0, sizeof(digest_ctx->sess)); +- digest_ctx->sess.mac = digest_d->devcryptoid; +- if (ioctl(cfd, CIOCGSESSION, &digest_ctx->sess) < 0) { +- SYSerr(SYS_F_IOCTL, errno); +- return 0; +- } +- +- return 1; +-} +- +-static int digest_op(struct digest_ctx *ctx, const void *src, size_t srclen, +- void *res, unsigned int flags) +-{ +- struct crypt_op cryp; +- +- memset(&cryp, 0, sizeof(cryp)); +- cryp.ses = ctx->sess.ses; +- cryp.len = srclen; +- cryp.src = (void *)src; +- cryp.dst = NULL; +- cryp.mac = res; +- cryp.flags = flags; +- return ioctl(cfd, CIOCCRYPT, &cryp); +-} +- +-static int digest_update(EVP_MD_CTX *ctx, const void *data, size_t count) +-{ +- struct digest_ctx *digest_ctx = +- (struct digest_ctx *)EVP_MD_CTX_md_data(ctx); +- +- if (count == 0) +- return 1; +- +- if (digest_ctx == NULL) +- return 0; +- +- if (EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_ONESHOT)) { +- if (digest_op(digest_ctx, data, count, digest_ctx->digest_res, 0) >= 0) +- return 1; +- } else if (digest_op(digest_ctx, data, count, NULL, COP_FLAG_UPDATE) >= 0) { +- return 1; +- } +- +- SYSerr(SYS_F_IOCTL, errno); +- return 0; +-} +- +-static int digest_final(EVP_MD_CTX *ctx, unsigned char *md) +-{ +- struct digest_ctx *digest_ctx = +- (struct digest_ctx *)EVP_MD_CTX_md_data(ctx); +- +- if (md == NULL || digest_ctx == NULL) +- return 0; +- +- if (EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_ONESHOT)) { +- memcpy(md, digest_ctx->digest_res, EVP_MD_CTX_size(ctx)); +- } else if (digest_op(digest_ctx, NULL, 0, md, COP_FLAG_FINAL) < 0) { +- SYSerr(SYS_F_IOCTL, errno); +- return 0; +- } +- +- return 1; +-} +- +-static int digest_copy(EVP_MD_CTX *to, const EVP_MD_CTX *from) +-{ +- struct digest_ctx *digest_from = +- (struct digest_ctx *)EVP_MD_CTX_md_data(from); +- struct digest_ctx *digest_to = +- (struct digest_ctx *)EVP_MD_CTX_md_data(to); +- struct cphash_op cphash; +- +- if (digest_from == NULL || digest_from->init_called != 1) +- return 1; +- +- if (!digest_init(to)) { +- SYSerr(SYS_F_IOCTL, errno); +- return 0; +- } +- +- cphash.src_ses = digest_from->sess.ses; +- cphash.dst_ses = digest_to->sess.ses; +- if (ioctl(cfd, CIOCCPHASH, &cphash) < 0) { +- SYSerr(SYS_F_IOCTL, errno); +- return 0; +- } +- return 1; +-} +- +-static int digest_cleanup(EVP_MD_CTX *ctx) +-{ +- struct digest_ctx *digest_ctx = +- (struct digest_ctx *)EVP_MD_CTX_md_data(ctx); +- +- if (digest_ctx == NULL) +- return 1; +- +- return clean_devcrypto_session(&digest_ctx->sess); +-} +- +-/* +- * Keep tables of known nids, associated methods, selected digests, and +- * driver info. +- * Note that known_digest_nids[] isn't necessarily indexed the same way as +- * digest_data[] above, which the other tables are. +- */ +-static int known_digest_nids[OSSL_NELEM(digest_data)]; +-static int known_digest_nids_amount = -1; /* -1 indicates not yet initialised */ +-static EVP_MD *known_digest_methods[OSSL_NELEM(digest_data)] = { NULL, }; +-static int selected_digests[OSSL_NELEM(digest_data)]; +-static struct driver_info_st digest_driver_info[OSSL_NELEM(digest_data)]; +- +-static int devcrypto_test_digest(size_t digest_data_index) +-{ +- return (digest_driver_info[digest_data_index].status == DEVCRYPTO_STATUS_USABLE +- && selected_digests[digest_data_index] == 1 +- && (digest_driver_info[digest_data_index].accelerated +- == DEVCRYPTO_ACCELERATED +- || use_softdrivers == DEVCRYPTO_USE_SOFTWARE +- || (digest_driver_info[digest_data_index].accelerated +- != DEVCRYPTO_NOT_ACCELERATED +- && use_softdrivers == DEVCRYPTO_REJECT_SOFTWARE))); +-} +- +-static void rebuild_known_digest_nids(ENGINE *e) +-{ +- size_t i; +- +- for (i = 0, known_digest_nids_amount = 0; i < OSSL_NELEM(digest_data); i++) { +- if (devcrypto_test_digest(i)) +- known_digest_nids[known_digest_nids_amount++] = digest_data[i].nid; +- } +- ENGINE_unregister_digests(e); +- ENGINE_register_digests(e); +-} +- +-static void prepare_digest_methods(void) +-{ +- size_t i; +- struct session_op sess1, sess2; +-#ifdef CIOCGSESSINFO +- struct session_info_op siop; +-#endif +- struct cphash_op cphash; +- +- memset(&digest_driver_info, 0, sizeof(digest_driver_info)); +- +- memset(&sess1, 0, sizeof(sess1)); +- memset(&sess2, 0, sizeof(sess2)); +- +- for (i = 0, known_digest_nids_amount = 0; i < OSSL_NELEM(digest_data); +- i++) { +- +- selected_digests[i] = 1; +- +- /* +- * Check that the digest is usable +- */ +- sess1.mac = digest_data[i].devcryptoid; +- sess2.ses = 0; +- if (ioctl(cfd, CIOCGSESSION, &sess1) < 0) { +- digest_driver_info[i].status = DEVCRYPTO_STATUS_NO_CIOCGSESSION; +- goto finish; +- } +- +-#ifdef CIOCGSESSINFO +- /* gather hardware acceleration info from the driver */ +- siop.ses = sess1.ses; +- if (ioctl(cfd, CIOCGSESSINFO, &siop) < 0) { +- digest_driver_info[i].accelerated = DEVCRYPTO_ACCELERATION_UNKNOWN; +- } else { +- digest_driver_info[i].driver_name = +- OPENSSL_strndup(siop.hash_info.cra_driver_name, +- CRYPTODEV_MAX_ALG_NAME); +- if (siop.flags & SIOP_FLAG_KERNEL_DRIVER_ONLY) +- digest_driver_info[i].accelerated = DEVCRYPTO_ACCELERATED; +- else +- digest_driver_info[i].accelerated = DEVCRYPTO_NOT_ACCELERATED; +- } +-#endif +- +- /* digest must be capable of hash state copy */ +- sess2.mac = sess1.mac; +- if (ioctl(cfd, CIOCGSESSION, &sess2) < 0) { +- digest_driver_info[i].status = DEVCRYPTO_STATUS_FAILURE; +- goto finish; +- } +- cphash.src_ses = sess1.ses; +- cphash.dst_ses = sess2.ses; +- if (ioctl(cfd, CIOCCPHASH, &cphash) < 0) { +- digest_driver_info[i].status = DEVCRYPTO_STATUS_NO_CIOCCPHASH; +- goto finish; +- } +- if ((known_digest_methods[i] = EVP_MD_meth_new(digest_data[i].nid, +- NID_undef)) == NULL +- || !EVP_MD_meth_set_input_blocksize(known_digest_methods[i], +- digest_data[i].blocksize) +- || !EVP_MD_meth_set_result_size(known_digest_methods[i], +- digest_data[i].digestlen) +- || !EVP_MD_meth_set_init(known_digest_methods[i], digest_init) +- || !EVP_MD_meth_set_update(known_digest_methods[i], digest_update) +- || !EVP_MD_meth_set_final(known_digest_methods[i], digest_final) +- || !EVP_MD_meth_set_copy(known_digest_methods[i], digest_copy) +- || !EVP_MD_meth_set_cleanup(known_digest_methods[i], digest_cleanup) +- || !EVP_MD_meth_set_app_datasize(known_digest_methods[i], +- sizeof(struct digest_ctx))) { +- digest_driver_info[i].status = DEVCRYPTO_STATUS_FAILURE; +- EVP_MD_meth_free(known_digest_methods[i]); +- known_digest_methods[i] = NULL; +- goto finish; +- } +- digest_driver_info[i].status = DEVCRYPTO_STATUS_USABLE; +-finish: +- ioctl(cfd, CIOCFSESSION, &sess1.ses); +- if (sess2.ses != 0) +- ioctl(cfd, CIOCFSESSION, &sess2.ses); +- if (devcrypto_test_digest(i)) +- known_digest_nids[known_digest_nids_amount++] = digest_data[i].nid; +- } +-} +- +-static const EVP_MD *get_digest_method(int nid) +-{ +- size_t i = get_digest_data_index(nid); +- +- if (i == (size_t)-1) +- return NULL; +- return known_digest_methods[i]; +-} +- +-static int get_digest_nids(const int **nids) +-{ +- *nids = known_digest_nids; +- return known_digest_nids_amount; +-} +- +-static void destroy_digest_method(int nid) +-{ +- size_t i = get_digest_data_index(nid); +- +- EVP_MD_meth_free(known_digest_methods[i]); +- known_digest_methods[i] = NULL; +-} +- +-static void destroy_all_digest_methods(void) +-{ +- size_t i; +- +- for (i = 0; i < OSSL_NELEM(digest_data); i++) { +- destroy_digest_method(digest_data[i].nid); +- OPENSSL_free(digest_driver_info[i].driver_name); +- digest_driver_info[i].driver_name = NULL; +- } +-} +- +-static int devcrypto_digests(ENGINE *e, const EVP_MD **digest, +- const int **nids, int nid) +-{ +- if (digest == NULL) +- return get_digest_nids(nids); +- +- *digest = get_digest_method(nid); +- +- return *digest != NULL; +-} +- +-static void devcrypto_select_all_digests(int *digest_list) +-{ +- size_t i; +- +- for (i = 0; i < OSSL_NELEM(digest_data); i++) +- digest_list[i] = 1; +-} +- +-static int cryptodev_select_digest_cb(const char *str, int len, void *usr) +-{ +- int *digest_list = (int *)usr; +- char *name; +- const EVP_MD *EVP; +- size_t i; +- +- if (len == 0) +- return 1; +- if (usr == NULL || (name = OPENSSL_strndup(str, len)) == NULL) +- return 0; +- EVP = EVP_get_digestbyname(name); +- if (EVP == NULL) +- fprintf(stderr, "devcrypto: unknown digest %s\n", name); +- else if ((i = find_digest_data_index(EVP_MD_type(EVP))) != (size_t)-1) +- digest_list[i] = 1; +- else +- fprintf(stderr, "devcrypto: digest %s not available\n", name); +- OPENSSL_free(name); +- return 1; +-} +- +-static void dump_digest_info(void) +-{ +- size_t i; +- const char *name; +- +- fprintf (stderr, "Information about digests supported by the /dev/crypto" +- " engine:\n"); +-#ifndef CIOCGSESSINFO +- fprintf(stderr, "CIOCGSESSINFO (session info call) unavailable\n"); +-#endif +- +- for (i = 0; i < OSSL_NELEM(digest_data); i++) { +- name = OBJ_nid2sn(digest_data[i].nid); +- fprintf (stderr, "Digest %s, NID=%d, /dev/crypto info: id=%d, driver=%s", +- name ? name : "unknown", digest_data[i].nid, +- digest_data[i].devcryptoid, +- digest_driver_info[i].driver_name ? digest_driver_info[i].driver_name : "unknown"); +- if (digest_driver_info[i].status == DEVCRYPTO_STATUS_NO_CIOCGSESSION) { +- fprintf (stderr, ". CIOCGSESSION (session open) failed\n"); +- continue; +- } +- if (digest_driver_info[i].accelerated == DEVCRYPTO_ACCELERATED) +- fprintf(stderr, " (hw accelerated)"); +- else if (digest_driver_info[i].accelerated == DEVCRYPTO_NOT_ACCELERATED) +- fprintf(stderr, " (software)"); +- else +- fprintf(stderr, " (acceleration status unknown)"); +- if (cipher_driver_info[i].status == DEVCRYPTO_STATUS_FAILURE) +- fprintf (stderr, ". Cipher setup failed\n"); +- else if (digest_driver_info[i].status == DEVCRYPTO_STATUS_NO_CIOCCPHASH) +- fprintf(stderr, ", CIOCCPHASH failed\n"); +- else +- fprintf(stderr, ", CIOCCPHASH capable\n"); +- } +- fprintf(stderr, "\n"); +-} +- +-#endif +- +-/****************************************************************************** +- * +- * CONTROL COMMANDS +- * +- *****/ +- +-#define DEVCRYPTO_CMD_USE_SOFTDRIVERS ENGINE_CMD_BASE +-#define DEVCRYPTO_CMD_CIPHERS (ENGINE_CMD_BASE + 1) +-#define DEVCRYPTO_CMD_DIGESTS (ENGINE_CMD_BASE + 2) +-#define DEVCRYPTO_CMD_DUMP_INFO (ENGINE_CMD_BASE + 3) +- +-/* Helper macros for CPP string composition */ +-#ifndef OPENSSL_MSTR +-# define OPENSSL_MSTR_HELPER(x) #x +-# define OPENSSL_MSTR(x) OPENSSL_MSTR_HELPER(x) +-#endif +- +-static const ENGINE_CMD_DEFN devcrypto_cmds[] = { +-#ifdef CIOCGSESSINFO +- {DEVCRYPTO_CMD_USE_SOFTDRIVERS, +- "USE_SOFTDRIVERS", +- "specifies whether to use software (not accelerated) drivers (" +- OPENSSL_MSTR(DEVCRYPTO_REQUIRE_ACCELERATED) "=use only accelerated drivers, " +- OPENSSL_MSTR(DEVCRYPTO_USE_SOFTWARE) "=allow all drivers, " +- OPENSSL_MSTR(DEVCRYPTO_REJECT_SOFTWARE) +- "=use if acceleration can't be determined) [default=" - OPENSSL_MSTR(DEVCRYPTO_DEFAULT_USE_SOFDTRIVERS) "]", -+ OPENSSL_MSTR(DEVCRYPTO_DEFAULT_USE_SOFTDRIVERS) "]", - ENGINE_CMD_FLAG_NUMERIC}, - #endif - -@@ -1166,32 +1168,22 @@ static int devcrypto_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void)) - * - *****/ - +- ENGINE_CMD_FLAG_NUMERIC}, +-#endif +- +- {DEVCRYPTO_CMD_CIPHERS, +- "CIPHERS", +- "either ALL, NONE, or a comma-separated list of ciphers to enable [default=ALL]", +- ENGINE_CMD_FLAG_STRING}, +- +-#ifdef IMPLEMENT_DIGEST +- {DEVCRYPTO_CMD_DIGESTS, +- "DIGESTS", +- "either ALL, NONE, or a comma-separated list of digests to enable [default=ALL]", +- ENGINE_CMD_FLAG_STRING}, +-#endif +- +- {DEVCRYPTO_CMD_DUMP_INFO, +- "DUMP_INFO", +- "dump info about each algorithm to stderr; use 'openssl engine -pre DUMP_INFO devcrypto'", +- ENGINE_CMD_FLAG_NO_INPUT}, +- +- {0, NULL, NULL, 0} +-}; +- +-static int devcrypto_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void)) +-{ +- int *new_list; +- switch (cmd) { +-#ifdef CIOCGSESSINFO +- case DEVCRYPTO_CMD_USE_SOFTDRIVERS: +- switch (i) { +- case DEVCRYPTO_REQUIRE_ACCELERATED: +- case DEVCRYPTO_USE_SOFTWARE: +- case DEVCRYPTO_REJECT_SOFTWARE: +- break; +- default: +- fprintf(stderr, "devcrypto: invalid value (%ld) for USE_SOFTDRIVERS\n", i); +- return 0; +- } +- if (use_softdrivers == i) +- return 1; +- use_softdrivers = i; +-#ifdef IMPLEMENT_DIGEST +- rebuild_known_digest_nids(e); +-#endif +- rebuild_known_cipher_nids(e); +- return 1; +-#endif /* CIOCGSESSINFO */ +- +- case DEVCRYPTO_CMD_CIPHERS: +- if (p == NULL) +- return 1; +- if (strcasecmp((const char *)p, "ALL") == 0) { +- devcrypto_select_all_ciphers(selected_ciphers); +- } else if (strcasecmp((const char*)p, "NONE") == 0) { +- memset(selected_ciphers, 0, sizeof(selected_ciphers)); +- } else { +- new_list=OPENSSL_zalloc(sizeof(selected_ciphers)); +- if (!CONF_parse_list(p, ',', 1, cryptodev_select_cipher_cb, new_list)) { +- OPENSSL_free(new_list); +- return 0; +- } +- memcpy(selected_ciphers, new_list, sizeof(selected_ciphers)); +- OPENSSL_free(new_list); +- } +- rebuild_known_cipher_nids(e); +- return 1; +- +-#ifdef IMPLEMENT_DIGEST +- case DEVCRYPTO_CMD_DIGESTS: +- if (p == NULL) +- return 1; +- if (strcasecmp((const char *)p, "ALL") == 0) { +- devcrypto_select_all_digests(selected_digests); +- } else if (strcasecmp((const char*)p, "NONE") == 0) { +- memset(selected_digests, 0, sizeof(selected_digests)); +- } else { +- new_list=OPENSSL_zalloc(sizeof(selected_digests)); +- if (!CONF_parse_list(p, ',', 1, cryptodev_select_digest_cb, new_list)) { +- OPENSSL_free(new_list); +- return 0; +- } +- memcpy(selected_digests, new_list, sizeof(selected_digests)); +- OPENSSL_free(new_list); +- } +- rebuild_known_digest_nids(e); +- return 1; +-#endif /* IMPLEMENT_DIGEST */ +- +- case DEVCRYPTO_CMD_DUMP_INFO: +- dump_cipher_info(); +-#ifdef IMPLEMENT_DIGEST +- dump_digest_info(); +-#endif +- return 1; +- +- default: +- break; +- } +- return 0; +-} +- +-/****************************************************************************** +- * +- * LOAD / UNLOAD +- * +- *****/ +- -static int devcrypto_unload(ENGINE *e) -{ - destroy_all_cipher_methods(); @@ -172,42 +1288,35 @@ rename to engines/e_devcrypto.c - - return 1; -} - /* +-/* - * This engine is always built into libcrypto, so it doesn't offer any - * ability to be dynamically loadable. -+ * Opens /dev/crypto - */ +- */ -void engine_load_devcrypto_int() -+static int open_devcrypto(void) - { +-{ - ENGINE *e = NULL; - int fd; - -+ if (cfd >= 0) -+ return 1; -+ - if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0) { - #ifndef ENGINE_DEVCRYPTO_DEBUG - if (errno != ENOENT) - #endif - fprintf(stderr, "Could not open /dev/crypto: %s\n", strerror(errno)); +- int fd; +- +- if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0) { +-#ifndef ENGINE_DEVCRYPTO_DEBUG +- if (errno != ENOENT) +-#endif +- fprintf(stderr, "Could not open /dev/crypto: %s\n", strerror(errno)); - return; -+ return 0; - } - - #ifdef CRIOGET -@@ -1199,35 +1191,61 @@ void engine_load_devcrypto_int() - fprintf(stderr, "Could not create crypto fd: %s\n", strerror(errno)); - close(fd); - cfd = -1; +- } +- +-#ifdef CRIOGET +- if (ioctl(fd, CRIOGET, &cfd) < 0) { +- fprintf(stderr, "Could not create crypto fd: %s\n", strerror(errno)); +- close(fd); +- cfd = -1; - return; -+ return 0; - } - close(fd); - #else - cfd = fd; - #endif - +- } +- close(fd); +-#else +- cfd = fd; +-#endif +- - if ((e = ENGINE_new()) == NULL - || !ENGINE_set_destroy_function(e, devcrypto_unload)) { - ENGINE_free(e); @@ -218,6 +1327,1268 @@ rename to engines/e_devcrypto.c - */ - close(cfd); - return; +- } +- +- prepare_cipher_methods(); +-#ifdef IMPLEMENT_DIGEST +- prepare_digest_methods(); +-#endif +- +- if (!ENGINE_set_id(e, "devcrypto") +- || !ENGINE_set_name(e, "/dev/crypto engine") +- || !ENGINE_set_cmd_defns(e, devcrypto_cmds) +- || !ENGINE_set_ctrl_function(e, devcrypto_ctrl) +- +-/* +- * Asymmetric ciphers aren't well supported with /dev/crypto. Among the BSD +- * implementations, it seems to only exist in FreeBSD, and regarding the +- * parameters in its crypt_kop, the manual crypto(4) has this to say: +- * +- * The semantics of these arguments are currently undocumented. +- * +- * Reading through the FreeBSD source code doesn't give much more than +- * their CRK_MOD_EXP implementation for ubsec. +- * +- * It doesn't look much better with cryptodev-linux. They have the crypt_kop +- * structure as well as the command (CRK_*) in cryptodev.h, but no support +- * seems to be implemented at all for the moment. +- * +- * At the time of writing, it seems impossible to write proper support for +- * FreeBSD's asym features without some very deep knowledge and access to +- * specific kernel modules. +- * +- * /Richard Levitte, 2017-05-11 +- */ +-#if 0 +-# ifndef OPENSSL_NO_RSA +- || !ENGINE_set_RSA(e, devcrypto_rsa) +-# endif +-# ifndef OPENSSL_NO_DSA +- || !ENGINE_set_DSA(e, devcrypto_dsa) +-# endif +-# ifndef OPENSSL_NO_DH +- || !ENGINE_set_DH(e, devcrypto_dh) +-# endif +-# ifndef OPENSSL_NO_EC +- || !ENGINE_set_EC(e, devcrypto_ec) +-# endif +-#endif +- || !ENGINE_set_ciphers(e, devcrypto_ciphers) +-#ifdef IMPLEMENT_DIGEST +- || !ENGINE_set_digests(e, devcrypto_digests) +-#endif +- ) { +- ENGINE_free(e); +- return; +- } +- +- ENGINE_add(e); +- ENGINE_free(e); /* Loose our local reference */ +- ERR_clear_error(); +-} +--- /dev/null ++++ b/engines/e_devcrypto.c +@@ -0,0 +1,1327 @@ ++/* ++ * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved. ++ * ++ * Licensed under the OpenSSL license (the "License"). You may not use ++ * this file except in compliance with the License. You can obtain a copy ++ * in the file LICENSE in the source distribution or at ++ * https://www.openssl.org/source/license.html ++ */ ++ ++#include "../e_os.h" ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "crypto/engine.h" ++ ++/* #define ENGINE_DEVCRYPTO_DEBUG */ ++ ++#if CRYPTO_ALGORITHM_MIN < CRYPTO_ALGORITHM_MAX ++# define CHECK_BSD_STYLE_MACROS ++#endif ++ ++#define engine_devcrypto_id "devcrypto" ++ ++/* ++ * ONE global file descriptor for all sessions. This allows operations ++ * such as digest session data copying (see digest_copy()), but is also ++ * saner... why re-open /dev/crypto for every session? ++ */ ++static int cfd = -1; ++#define DEVCRYPTO_REQUIRE_ACCELERATED 0 /* require confirmation of acceleration */ ++#define DEVCRYPTO_USE_SOFTWARE 1 /* allow software drivers */ ++#define DEVCRYPTO_REJECT_SOFTWARE 2 /* only disallow confirmed software drivers */ ++ ++#define DEVCRYPTO_DEFAULT_USE_SOFTDRIVERS DEVCRYPTO_REJECT_SOFTWARE ++static int use_softdrivers = DEVCRYPTO_DEFAULT_USE_SOFTDRIVERS; ++ ++/* ++ * cipher/digest status & acceleration definitions ++ * Make sure the defaults are set to 0 ++ */ ++struct driver_info_st { ++ enum devcrypto_status_t { ++ DEVCRYPTO_STATUS_FAILURE = -3, /* unusable for other reason */ ++ DEVCRYPTO_STATUS_NO_CIOCCPHASH = -2, /* hash state copy not supported */ ++ DEVCRYPTO_STATUS_NO_CIOCGSESSION = -1, /* session open failed */ ++ DEVCRYPTO_STATUS_UNKNOWN = 0, /* not tested yet */ ++ DEVCRYPTO_STATUS_USABLE = 1 /* algo can be used */ ++ } status; ++ ++ enum devcrypto_accelerated_t { ++ DEVCRYPTO_NOT_ACCELERATED = -1, /* software implemented */ ++ DEVCRYPTO_ACCELERATION_UNKNOWN = 0, /* acceleration support unkown */ ++ DEVCRYPTO_ACCELERATED = 1 /* hardware accelerated */ ++ } accelerated; ++ ++ char *driver_name; ++}; ++ ++static int clean_devcrypto_session(struct session_op *sess) { ++ if (ioctl(cfd, CIOCFSESSION, &sess->ses) < 0) { ++ SYSerr(SYS_F_IOCTL, errno); ++ return 0; ++ } ++ memset(sess, 0, sizeof(struct session_op)); ++ return 1; ++} ++ ++/****************************************************************************** ++ * ++ * Ciphers ++ * ++ * Because they all do the same basic operation, we have only one set of ++ * method functions for them all to share, and a mapping table between ++ * NIDs and cryptodev IDs, with all the necessary size data. ++ * ++ *****/ ++ ++struct cipher_ctx { ++ struct session_op sess; ++ int op; /* COP_ENCRYPT or COP_DECRYPT */ ++ unsigned long mode; /* EVP_CIPH_*_MODE */ ++ ++ /* to handle ctr mode being a stream cipher */ ++ unsigned char partial[EVP_MAX_BLOCK_LENGTH]; ++ unsigned int blocksize, num; ++}; ++ ++static const struct cipher_data_st { ++ int nid; ++ int blocksize; ++ int keylen; ++ int ivlen; ++ int flags; ++ int devcryptoid; ++} cipher_data[] = { ++#ifndef OPENSSL_NO_DES ++ { NID_des_cbc, 8, 8, 8, EVP_CIPH_CBC_MODE, CRYPTO_DES_CBC }, ++ { NID_des_ede3_cbc, 8, 24, 8, EVP_CIPH_CBC_MODE, CRYPTO_3DES_CBC }, ++#endif ++#ifndef OPENSSL_NO_BF ++ { NID_bf_cbc, 8, 16, 8, EVP_CIPH_CBC_MODE, CRYPTO_BLF_CBC }, ++#endif ++#ifndef OPENSSL_NO_CAST ++ { NID_cast5_cbc, 8, 16, 8, EVP_CIPH_CBC_MODE, CRYPTO_CAST_CBC }, ++#endif ++ { NID_aes_128_cbc, 16, 128 / 8, 16, EVP_CIPH_CBC_MODE, CRYPTO_AES_CBC }, ++ { NID_aes_192_cbc, 16, 192 / 8, 16, EVP_CIPH_CBC_MODE, CRYPTO_AES_CBC }, ++ { NID_aes_256_cbc, 16, 256 / 8, 16, EVP_CIPH_CBC_MODE, CRYPTO_AES_CBC }, ++#ifndef OPENSSL_NO_RC4 ++ { NID_rc4, 1, 16, 0, EVP_CIPH_STREAM_CIPHER, CRYPTO_ARC4 }, ++#endif ++#if !defined(CHECK_BSD_STYLE_MACROS) || defined(CRYPTO_AES_CTR) ++ { NID_aes_128_ctr, 16, 128 / 8, 16, EVP_CIPH_CTR_MODE, CRYPTO_AES_CTR }, ++ { NID_aes_192_ctr, 16, 192 / 8, 16, EVP_CIPH_CTR_MODE, CRYPTO_AES_CTR }, ++ { NID_aes_256_ctr, 16, 256 / 8, 16, EVP_CIPH_CTR_MODE, CRYPTO_AES_CTR }, ++#endif ++#if 0 /* Not yet supported */ ++ { NID_aes_128_xts, 16, 128 / 8 * 2, 16, EVP_CIPH_XTS_MODE, CRYPTO_AES_XTS }, ++ { NID_aes_256_xts, 16, 256 / 8 * 2, 16, EVP_CIPH_XTS_MODE, CRYPTO_AES_XTS }, ++#endif ++#if !defined(CHECK_BSD_STYLE_MACROS) || defined(CRYPTO_AES_ECB) ++ { NID_aes_128_ecb, 16, 128 / 8, 0, EVP_CIPH_ECB_MODE, CRYPTO_AES_ECB }, ++ { NID_aes_192_ecb, 16, 192 / 8, 0, EVP_CIPH_ECB_MODE, CRYPTO_AES_ECB }, ++ { NID_aes_256_ecb, 16, 256 / 8, 0, EVP_CIPH_ECB_MODE, CRYPTO_AES_ECB }, ++#endif ++#if 0 /* Not yet supported */ ++ { NID_aes_128_gcm, 16, 128 / 8, 16, EVP_CIPH_GCM_MODE, CRYPTO_AES_GCM }, ++ { NID_aes_192_gcm, 16, 192 / 8, 16, EVP_CIPH_GCM_MODE, CRYPTO_AES_GCM }, ++ { NID_aes_256_gcm, 16, 256 / 8, 16, EVP_CIPH_GCM_MODE, CRYPTO_AES_GCM }, ++#endif ++#ifndef OPENSSL_NO_CAMELLIA ++ { NID_camellia_128_cbc, 16, 128 / 8, 16, EVP_CIPH_CBC_MODE, ++ CRYPTO_CAMELLIA_CBC }, ++ { NID_camellia_192_cbc, 16, 192 / 8, 16, EVP_CIPH_CBC_MODE, ++ CRYPTO_CAMELLIA_CBC }, ++ { NID_camellia_256_cbc, 16, 256 / 8, 16, EVP_CIPH_CBC_MODE, ++ CRYPTO_CAMELLIA_CBC }, ++#endif ++}; ++ ++static size_t find_cipher_data_index(int nid) ++{ ++ size_t i; ++ ++ for (i = 0; i < OSSL_NELEM(cipher_data); i++) ++ if (nid == cipher_data[i].nid) ++ return i; ++ return (size_t)-1; ++} ++ ++static size_t get_cipher_data_index(int nid) ++{ ++ size_t i = find_cipher_data_index(nid); ++ ++ if (i != (size_t)-1) ++ return i; ++ ++ /* ++ * Code further down must make sure that only NIDs in the table above ++ * are used. If any other NID reaches this function, there's a grave ++ * coding error further down. ++ */ ++ assert("Code that never should be reached" == NULL); ++ return -1; ++} ++ ++static const struct cipher_data_st *get_cipher_data(int nid) ++{ ++ return &cipher_data[get_cipher_data_index(nid)]; ++} ++ ++/* ++ * Following are the three necessary functions to map OpenSSL functionality ++ * with cryptodev. ++ */ ++ ++static int cipher_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, ++ const unsigned char *iv, int enc) ++{ ++ struct cipher_ctx *cipher_ctx = ++ (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx); ++ const struct cipher_data_st *cipher_d = ++ get_cipher_data(EVP_CIPHER_CTX_nid(ctx)); ++ ++ /* cleanup a previous session */ ++ if (cipher_ctx->sess.ses != 0 && ++ clean_devcrypto_session(&cipher_ctx->sess) == 0) ++ return 0; ++ ++ cipher_ctx->sess.cipher = cipher_d->devcryptoid; ++ cipher_ctx->sess.keylen = cipher_d->keylen; ++ cipher_ctx->sess.key = (void *)key; ++ cipher_ctx->op = enc ? COP_ENCRYPT : COP_DECRYPT; ++ cipher_ctx->mode = cipher_d->flags & EVP_CIPH_MODE; ++ cipher_ctx->blocksize = cipher_d->blocksize; ++ if (ioctl(cfd, CIOCGSESSION, &cipher_ctx->sess) < 0) { ++ SYSerr(SYS_F_IOCTL, errno); ++ return 0; ++ } ++ ++ return 1; ++} ++ ++static int cipher_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, ++ const unsigned char *in, size_t inl) ++{ ++ struct cipher_ctx *cipher_ctx = ++ (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx); ++ struct crypt_op cryp; ++ unsigned char *iv = EVP_CIPHER_CTX_iv_noconst(ctx); ++#if !defined(COP_FLAG_WRITE_IV) ++ unsigned char saved_iv[EVP_MAX_IV_LENGTH]; ++ const unsigned char *ivptr; ++ size_t nblocks, ivlen; ++#endif ++ ++ memset(&cryp, 0, sizeof(cryp)); ++ cryp.ses = cipher_ctx->sess.ses; ++ cryp.len = inl; ++ cryp.src = (void *)in; ++ cryp.dst = (void *)out; ++ cryp.iv = (void *)iv; ++ cryp.op = cipher_ctx->op; ++#if !defined(COP_FLAG_WRITE_IV) ++ cryp.flags = 0; ++ ++ ivlen = EVP_CIPHER_CTX_iv_length(ctx); ++ if (ivlen > 0) ++ switch (cipher_ctx->mode) { ++ case EVP_CIPH_CBC_MODE: ++ assert(inl >= ivlen); ++ if (!EVP_CIPHER_CTX_encrypting(ctx)) { ++ ivptr = in + inl - ivlen; ++ memcpy(saved_iv, ivptr, ivlen); ++ } ++ break; ++ ++ case EVP_CIPH_CTR_MODE: ++ break; ++ ++ default: /* should not happen */ ++ return 0; ++ } ++#else ++ cryp.flags = COP_FLAG_WRITE_IV; ++#endif ++ ++ if (ioctl(cfd, CIOCCRYPT, &cryp) < 0) { ++ SYSerr(SYS_F_IOCTL, errno); ++ return 0; ++ } ++ ++#if !defined(COP_FLAG_WRITE_IV) ++ if (ivlen > 0) ++ switch (cipher_ctx->mode) { ++ case EVP_CIPH_CBC_MODE: ++ assert(inl >= ivlen); ++ if (EVP_CIPHER_CTX_encrypting(ctx)) ++ ivptr = out + inl - ivlen; ++ else ++ ivptr = saved_iv; ++ ++ memcpy(iv, ivptr, ivlen); ++ break; ++ ++ case EVP_CIPH_CTR_MODE: ++ nblocks = (inl + cipher_ctx->blocksize - 1) ++ / cipher_ctx->blocksize; ++ do { ++ ivlen--; ++ nblocks += iv[ivlen]; ++ iv[ivlen] = (uint8_t) nblocks; ++ nblocks >>= 8; ++ } while (ivlen); ++ break; ++ ++ default: /* should not happen */ ++ return 0; ++ } ++#endif ++ ++ return 1; ++} ++ ++static int ctr_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, ++ const unsigned char *in, size_t inl) ++{ ++ struct cipher_ctx *cipher_ctx = ++ (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx); ++ size_t nblocks, len; ++ ++ /* initial partial block */ ++ while (cipher_ctx->num && inl) { ++ (*out++) = *(in++) ^ cipher_ctx->partial[cipher_ctx->num]; ++ --inl; ++ cipher_ctx->num = (cipher_ctx->num + 1) % cipher_ctx->blocksize; ++ } ++ ++ /* full blocks */ ++ if (inl > (unsigned int) cipher_ctx->blocksize) { ++ nblocks = inl/cipher_ctx->blocksize; ++ len = nblocks * cipher_ctx->blocksize; ++ if (cipher_do_cipher(ctx, out, in, len) < 1) ++ return 0; ++ inl -= len; ++ out += len; ++ in += len; ++ } ++ ++ /* final partial block */ ++ if (inl) { ++ memset(cipher_ctx->partial, 0, cipher_ctx->blocksize); ++ if (cipher_do_cipher(ctx, cipher_ctx->partial, cipher_ctx->partial, ++ cipher_ctx->blocksize) < 1) ++ return 0; ++ while (inl--) { ++ out[cipher_ctx->num] = in[cipher_ctx->num] ++ ^ cipher_ctx->partial[cipher_ctx->num]; ++ cipher_ctx->num++; ++ } ++ } ++ ++ return 1; ++} ++ ++static int cipher_ctrl(EVP_CIPHER_CTX *ctx, int type, int p1, void* p2) ++{ ++ struct cipher_ctx *cipher_ctx = ++ (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx); ++ EVP_CIPHER_CTX *to_ctx = (EVP_CIPHER_CTX *)p2; ++ struct cipher_ctx *to_cipher_ctx; ++ ++ switch (type) { ++ case EVP_CTRL_COPY: ++ if (cipher_ctx == NULL) ++ return 1; ++ /* when copying the context, a new session needs to be initialized */ ++ to_cipher_ctx = ++ (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(to_ctx); ++ memset(&to_cipher_ctx->sess, 0, sizeof(to_cipher_ctx->sess)); ++ return cipher_init(to_ctx, cipher_ctx->sess.key, EVP_CIPHER_CTX_iv(ctx), ++ (cipher_ctx->op == COP_ENCRYPT)); ++ ++ case EVP_CTRL_INIT: ++ memset(&cipher_ctx->sess, 0, sizeof(cipher_ctx->sess)); ++ return 1; ++ ++ default: ++ break; ++ } ++ ++ return -1; ++} ++ ++static int cipher_cleanup(EVP_CIPHER_CTX *ctx) ++{ ++ struct cipher_ctx *cipher_ctx = ++ (struct cipher_ctx *)EVP_CIPHER_CTX_get_cipher_data(ctx); ++ ++ return clean_devcrypto_session(&cipher_ctx->sess); ++} ++ ++/* ++ * Keep tables of known nids, associated methods, selected ciphers, and driver ++ * info. ++ * Note that known_cipher_nids[] isn't necessarily indexed the same way as ++ * cipher_data[] above, which the other tables are. ++ */ ++static int known_cipher_nids[OSSL_NELEM(cipher_data)]; ++static int known_cipher_nids_amount = -1; /* -1 indicates not yet initialised */ ++static EVP_CIPHER *known_cipher_methods[OSSL_NELEM(cipher_data)] = { NULL, }; ++static int selected_ciphers[OSSL_NELEM(cipher_data)]; ++static struct driver_info_st cipher_driver_info[OSSL_NELEM(cipher_data)]; ++ ++ ++static int devcrypto_test_cipher(size_t cipher_data_index) ++{ ++ return (cipher_driver_info[cipher_data_index].status == DEVCRYPTO_STATUS_USABLE ++ && selected_ciphers[cipher_data_index] == 1 ++ && (cipher_driver_info[cipher_data_index].accelerated ++ == DEVCRYPTO_ACCELERATED ++ || use_softdrivers == DEVCRYPTO_USE_SOFTWARE ++ || (cipher_driver_info[cipher_data_index].accelerated ++ != DEVCRYPTO_NOT_ACCELERATED ++ && use_softdrivers == DEVCRYPTO_REJECT_SOFTWARE))); ++} ++ ++static void prepare_cipher_methods(void) ++{ ++ size_t i; ++ struct session_op sess; ++ unsigned long cipher_mode; ++#ifdef CIOCGSESSINFO ++ struct session_info_op siop; ++#endif ++ ++ memset(&cipher_driver_info, 0, sizeof(cipher_driver_info)); ++ ++ memset(&sess, 0, sizeof(sess)); ++ sess.key = (void *)"01234567890123456789012345678901234567890123456789"; ++ ++ for (i = 0, known_cipher_nids_amount = 0; ++ i < OSSL_NELEM(cipher_data); i++) { ++ ++ selected_ciphers[i] = 1; ++ /* ++ * Check that the cipher is usable ++ */ ++ sess.cipher = cipher_data[i].devcryptoid; ++ sess.keylen = cipher_data[i].keylen; ++ if (ioctl(cfd, CIOCGSESSION, &sess) < 0) { ++ cipher_driver_info[i].status = DEVCRYPTO_STATUS_NO_CIOCGSESSION; ++ continue; ++ } ++ ++ cipher_mode = cipher_data[i].flags & EVP_CIPH_MODE; ++ ++ if ((known_cipher_methods[i] = ++ EVP_CIPHER_meth_new(cipher_data[i].nid, ++ cipher_mode == EVP_CIPH_CTR_MODE ? 1 : ++ cipher_data[i].blocksize, ++ cipher_data[i].keylen)) == NULL ++ || !EVP_CIPHER_meth_set_iv_length(known_cipher_methods[i], ++ cipher_data[i].ivlen) ++ || !EVP_CIPHER_meth_set_flags(known_cipher_methods[i], ++ cipher_data[i].flags ++ | EVP_CIPH_CUSTOM_COPY ++ | EVP_CIPH_CTRL_INIT ++ | EVP_CIPH_FLAG_DEFAULT_ASN1) ++ || !EVP_CIPHER_meth_set_init(known_cipher_methods[i], cipher_init) ++ || !EVP_CIPHER_meth_set_do_cipher(known_cipher_methods[i], ++ cipher_mode == EVP_CIPH_CTR_MODE ? ++ ctr_do_cipher : ++ cipher_do_cipher) ++ || !EVP_CIPHER_meth_set_ctrl(known_cipher_methods[i], cipher_ctrl) ++ || !EVP_CIPHER_meth_set_cleanup(known_cipher_methods[i], ++ cipher_cleanup) ++ || !EVP_CIPHER_meth_set_impl_ctx_size(known_cipher_methods[i], ++ sizeof(struct cipher_ctx))) { ++ cipher_driver_info[i].status = DEVCRYPTO_STATUS_FAILURE; ++ EVP_CIPHER_meth_free(known_cipher_methods[i]); ++ known_cipher_methods[i] = NULL; ++ } else { ++ cipher_driver_info[i].status = DEVCRYPTO_STATUS_USABLE; ++#ifdef CIOCGSESSINFO ++ siop.ses = sess.ses; ++ if (ioctl(cfd, CIOCGSESSINFO, &siop) < 0) { ++ cipher_driver_info[i].accelerated = DEVCRYPTO_ACCELERATION_UNKNOWN; ++ } else { ++ cipher_driver_info[i].driver_name = ++ OPENSSL_strndup(siop.cipher_info.cra_driver_name, ++ CRYPTODEV_MAX_ALG_NAME); ++ if (!(siop.flags & SIOP_FLAG_KERNEL_DRIVER_ONLY)) ++ cipher_driver_info[i].accelerated = DEVCRYPTO_NOT_ACCELERATED; ++ else ++ cipher_driver_info[i].accelerated = DEVCRYPTO_ACCELERATED; ++ } ++#endif /* CIOCGSESSINFO */ ++ } ++ ioctl(cfd, CIOCFSESSION, &sess.ses); ++ if (devcrypto_test_cipher(i)) { ++ known_cipher_nids[known_cipher_nids_amount++] = ++ cipher_data[i].nid; ++ } ++ } ++} ++ ++static void rebuild_known_cipher_nids(ENGINE *e) ++{ ++ size_t i; ++ ++ for (i = 0, known_cipher_nids_amount = 0; i < OSSL_NELEM(cipher_data); i++) { ++ if (devcrypto_test_cipher(i)) ++ known_cipher_nids[known_cipher_nids_amount++] = cipher_data[i].nid; ++ } ++ ENGINE_unregister_ciphers(e); ++ ENGINE_register_ciphers(e); ++} ++ ++static const EVP_CIPHER *get_cipher_method(int nid) ++{ ++ size_t i = get_cipher_data_index(nid); ++ ++ if (i == (size_t)-1) ++ return NULL; ++ return known_cipher_methods[i]; ++} ++ ++static int get_cipher_nids(const int **nids) ++{ ++ *nids = known_cipher_nids; ++ return known_cipher_nids_amount; ++} ++ ++static void destroy_cipher_method(int nid) ++{ ++ size_t i = get_cipher_data_index(nid); ++ ++ EVP_CIPHER_meth_free(known_cipher_methods[i]); ++ known_cipher_methods[i] = NULL; ++} ++ ++static void destroy_all_cipher_methods(void) ++{ ++ size_t i; ++ ++ for (i = 0; i < OSSL_NELEM(cipher_data); i++) { ++ destroy_cipher_method(cipher_data[i].nid); ++ OPENSSL_free(cipher_driver_info[i].driver_name); ++ cipher_driver_info[i].driver_name = NULL; ++ } ++} ++ ++static int devcrypto_ciphers(ENGINE *e, const EVP_CIPHER **cipher, ++ const int **nids, int nid) ++{ ++ if (cipher == NULL) ++ return get_cipher_nids(nids); ++ ++ *cipher = get_cipher_method(nid); ++ ++ return *cipher != NULL; ++} ++ ++static void devcrypto_select_all_ciphers(int *cipher_list) ++{ ++ size_t i; ++ ++ for (i = 0; i < OSSL_NELEM(cipher_data); i++) ++ cipher_list[i] = 1; ++} ++ ++static int cryptodev_select_cipher_cb(const char *str, int len, void *usr) ++{ ++ int *cipher_list = (int *)usr; ++ char *name; ++ const EVP_CIPHER *EVP; ++ size_t i; ++ ++ if (len == 0) ++ return 1; ++ if (usr == NULL || (name = OPENSSL_strndup(str, len)) == NULL) ++ return 0; ++ EVP = EVP_get_cipherbyname(name); ++ if (EVP == NULL) ++ fprintf(stderr, "devcrypto: unknown cipher %s\n", name); ++ else if ((i = find_cipher_data_index(EVP_CIPHER_nid(EVP))) != (size_t)-1) ++ cipher_list[i] = 1; ++ else ++ fprintf(stderr, "devcrypto: cipher %s not available\n", name); ++ OPENSSL_free(name); ++ return 1; ++} ++ ++static void dump_cipher_info(void) ++{ ++ size_t i; ++ const char *name; ++ ++ fprintf (stderr, "Information about ciphers supported by the /dev/crypto" ++ " engine:\n"); ++#ifndef CIOCGSESSINFO ++ fprintf(stderr, "CIOCGSESSINFO (session info call) unavailable\n"); ++#endif ++ for (i = 0; i < OSSL_NELEM(cipher_data); i++) { ++ name = OBJ_nid2sn(cipher_data[i].nid); ++ fprintf (stderr, "Cipher %s, NID=%d, /dev/crypto info: id=%d, ", ++ name ? name : "unknown", cipher_data[i].nid, ++ cipher_data[i].devcryptoid); ++ if (cipher_driver_info[i].status == DEVCRYPTO_STATUS_NO_CIOCGSESSION ) { ++ fprintf (stderr, "CIOCGSESSION (session open call) failed\n"); ++ continue; ++ } ++ fprintf (stderr, "driver=%s ", cipher_driver_info[i].driver_name ? ++ cipher_driver_info[i].driver_name : "unknown"); ++ if (cipher_driver_info[i].accelerated == DEVCRYPTO_ACCELERATED) ++ fprintf(stderr, "(hw accelerated)"); ++ else if (cipher_driver_info[i].accelerated == DEVCRYPTO_NOT_ACCELERATED) ++ fprintf(stderr, "(software)"); ++ else ++ fprintf(stderr, "(acceleration status unknown)"); ++ if (cipher_driver_info[i].status == DEVCRYPTO_STATUS_FAILURE) ++ fprintf (stderr, ". Cipher setup failed"); ++ fprintf(stderr, "\n"); ++ } ++ fprintf(stderr, "\n"); ++} ++ ++/* ++ * We only support digests if the cryptodev implementation supports multiple ++ * data updates and session copying. Otherwise, we would be forced to maintain ++ * a cache, which is perilous if there's a lot of data coming in (if someone ++ * wants to checksum an OpenSSL tarball, for example). ++ */ ++#if defined(CIOCCPHASH) && defined(COP_FLAG_UPDATE) && defined(COP_FLAG_FINAL) ++#define IMPLEMENT_DIGEST ++ ++/****************************************************************************** ++ * ++ * Digests ++ * ++ * Because they all do the same basic operation, we have only one set of ++ * method functions for them all to share, and a mapping table between ++ * NIDs and cryptodev IDs, with all the necessary size data. ++ * ++ *****/ ++ ++struct digest_ctx { ++ struct session_op sess; ++ /* This signals that the init function was called, not that it succeeded. */ ++ int init_called; ++ unsigned char digest_res[HASH_MAX_LEN]; ++}; ++ ++static const struct digest_data_st { ++ int nid; ++ int blocksize; ++ int digestlen; ++ int devcryptoid; ++} digest_data[] = { ++#ifndef OPENSSL_NO_MD5 ++ { NID_md5, /* MD5_CBLOCK */ 64, 16, CRYPTO_MD5 }, ++#endif ++ { NID_sha1, SHA_CBLOCK, 20, CRYPTO_SHA1 }, ++#ifndef OPENSSL_NO_RMD160 ++# if !defined(CHECK_BSD_STYLE_MACROS) || defined(CRYPTO_RIPEMD160) ++ { NID_ripemd160, /* RIPEMD160_CBLOCK */ 64, 20, CRYPTO_RIPEMD160 }, ++# endif ++#endif ++#if !defined(CHECK_BSD_STYLE_MACROS) || defined(CRYPTO_SHA2_224) ++ { NID_sha224, SHA256_CBLOCK, 224 / 8, CRYPTO_SHA2_224 }, ++#endif ++#if !defined(CHECK_BSD_STYLE_MACROS) || defined(CRYPTO_SHA2_256) ++ { NID_sha256, SHA256_CBLOCK, 256 / 8, CRYPTO_SHA2_256 }, ++#endif ++#if !defined(CHECK_BSD_STYLE_MACROS) || defined(CRYPTO_SHA2_384) ++ { NID_sha384, SHA512_CBLOCK, 384 / 8, CRYPTO_SHA2_384 }, ++#endif ++#if !defined(CHECK_BSD_STYLE_MACROS) || defined(CRYPTO_SHA2_512) ++ { NID_sha512, SHA512_CBLOCK, 512 / 8, CRYPTO_SHA2_512 }, ++#endif ++}; ++ ++static size_t find_digest_data_index(int nid) ++{ ++ size_t i; ++ ++ for (i = 0; i < OSSL_NELEM(digest_data); i++) ++ if (nid == digest_data[i].nid) ++ return i; ++ return (size_t)-1; ++} ++ ++static size_t get_digest_data_index(int nid) ++{ ++ size_t i = find_digest_data_index(nid); ++ ++ if (i != (size_t)-1) ++ return i; ++ ++ /* ++ * Code further down must make sure that only NIDs in the table above ++ * are used. If any other NID reaches this function, there's a grave ++ * coding error further down. ++ */ ++ assert("Code that never should be reached" == NULL); ++ return -1; ++} ++ ++static const struct digest_data_st *get_digest_data(int nid) ++{ ++ return &digest_data[get_digest_data_index(nid)]; ++} ++ ++/* ++ * Following are the five necessary functions to map OpenSSL functionality ++ * with cryptodev: init, update, final, cleanup, and copy. ++ */ ++ ++static int digest_init(EVP_MD_CTX *ctx) ++{ ++ struct digest_ctx *digest_ctx = ++ (struct digest_ctx *)EVP_MD_CTX_md_data(ctx); ++ const struct digest_data_st *digest_d = ++ get_digest_data(EVP_MD_CTX_type(ctx)); ++ ++ digest_ctx->init_called = 1; ++ ++ memset(&digest_ctx->sess, 0, sizeof(digest_ctx->sess)); ++ digest_ctx->sess.mac = digest_d->devcryptoid; ++ if (ioctl(cfd, CIOCGSESSION, &digest_ctx->sess) < 0) { ++ SYSerr(SYS_F_IOCTL, errno); ++ return 0; ++ } ++ ++ return 1; ++} ++ ++static int digest_op(struct digest_ctx *ctx, const void *src, size_t srclen, ++ void *res, unsigned int flags) ++{ ++ struct crypt_op cryp; ++ ++ memset(&cryp, 0, sizeof(cryp)); ++ cryp.ses = ctx->sess.ses; ++ cryp.len = srclen; ++ cryp.src = (void *)src; ++ cryp.dst = NULL; ++ cryp.mac = res; ++ cryp.flags = flags; ++ return ioctl(cfd, CIOCCRYPT, &cryp); ++} ++ ++static int digest_update(EVP_MD_CTX *ctx, const void *data, size_t count) ++{ ++ struct digest_ctx *digest_ctx = ++ (struct digest_ctx *)EVP_MD_CTX_md_data(ctx); ++ ++ if (count == 0) ++ return 1; ++ ++ if (digest_ctx == NULL) ++ return 0; ++ ++ if (EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_ONESHOT)) { ++ if (digest_op(digest_ctx, data, count, digest_ctx->digest_res, 0) >= 0) ++ return 1; ++ } else if (digest_op(digest_ctx, data, count, NULL, COP_FLAG_UPDATE) >= 0) { ++ return 1; ++ } ++ ++ SYSerr(SYS_F_IOCTL, errno); ++ return 0; ++} ++ ++static int digest_final(EVP_MD_CTX *ctx, unsigned char *md) ++{ ++ struct digest_ctx *digest_ctx = ++ (struct digest_ctx *)EVP_MD_CTX_md_data(ctx); ++ ++ if (md == NULL || digest_ctx == NULL) ++ return 0; ++ ++ if (EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_ONESHOT)) { ++ memcpy(md, digest_ctx->digest_res, EVP_MD_CTX_size(ctx)); ++ } else if (digest_op(digest_ctx, NULL, 0, md, COP_FLAG_FINAL) < 0) { ++ SYSerr(SYS_F_IOCTL, errno); ++ return 0; ++ } ++ ++ return 1; ++} ++ ++static int digest_copy(EVP_MD_CTX *to, const EVP_MD_CTX *from) ++{ ++ struct digest_ctx *digest_from = ++ (struct digest_ctx *)EVP_MD_CTX_md_data(from); ++ struct digest_ctx *digest_to = ++ (struct digest_ctx *)EVP_MD_CTX_md_data(to); ++ struct cphash_op cphash; ++ ++ if (digest_from == NULL || digest_from->init_called != 1) ++ return 1; ++ ++ if (!digest_init(to)) { ++ SYSerr(SYS_F_IOCTL, errno); ++ return 0; ++ } ++ ++ cphash.src_ses = digest_from->sess.ses; ++ cphash.dst_ses = digest_to->sess.ses; ++ if (ioctl(cfd, CIOCCPHASH, &cphash) < 0) { ++ SYSerr(SYS_F_IOCTL, errno); ++ return 0; ++ } ++ return 1; ++} ++ ++static int digest_cleanup(EVP_MD_CTX *ctx) ++{ ++ struct digest_ctx *digest_ctx = ++ (struct digest_ctx *)EVP_MD_CTX_md_data(ctx); ++ ++ if (digest_ctx == NULL) ++ return 1; ++ ++ return clean_devcrypto_session(&digest_ctx->sess); ++} ++ ++/* ++ * Keep tables of known nids, associated methods, selected digests, and ++ * driver info. ++ * Note that known_digest_nids[] isn't necessarily indexed the same way as ++ * digest_data[] above, which the other tables are. ++ */ ++static int known_digest_nids[OSSL_NELEM(digest_data)]; ++static int known_digest_nids_amount = -1; /* -1 indicates not yet initialised */ ++static EVP_MD *known_digest_methods[OSSL_NELEM(digest_data)] = { NULL, }; ++static int selected_digests[OSSL_NELEM(digest_data)]; ++static struct driver_info_st digest_driver_info[OSSL_NELEM(digest_data)]; ++ ++static int devcrypto_test_digest(size_t digest_data_index) ++{ ++ return (digest_driver_info[digest_data_index].status == DEVCRYPTO_STATUS_USABLE ++ && selected_digests[digest_data_index] == 1 ++ && (digest_driver_info[digest_data_index].accelerated ++ == DEVCRYPTO_ACCELERATED ++ || use_softdrivers == DEVCRYPTO_USE_SOFTWARE ++ || (digest_driver_info[digest_data_index].accelerated ++ != DEVCRYPTO_NOT_ACCELERATED ++ && use_softdrivers == DEVCRYPTO_REJECT_SOFTWARE))); ++} ++ ++static void rebuild_known_digest_nids(ENGINE *e) ++{ ++ size_t i; ++ ++ for (i = 0, known_digest_nids_amount = 0; i < OSSL_NELEM(digest_data); i++) { ++ if (devcrypto_test_digest(i)) ++ known_digest_nids[known_digest_nids_amount++] = digest_data[i].nid; ++ } ++ ENGINE_unregister_digests(e); ++ ENGINE_register_digests(e); ++} ++ ++static void prepare_digest_methods(void) ++{ ++ size_t i; ++ struct session_op sess1, sess2; ++#ifdef CIOCGSESSINFO ++ struct session_info_op siop; ++#endif ++ struct cphash_op cphash; ++ ++ memset(&digest_driver_info, 0, sizeof(digest_driver_info)); ++ ++ memset(&sess1, 0, sizeof(sess1)); ++ memset(&sess2, 0, sizeof(sess2)); ++ ++ for (i = 0, known_digest_nids_amount = 0; i < OSSL_NELEM(digest_data); ++ i++) { ++ ++ selected_digests[i] = 1; ++ ++ /* ++ * Check that the digest is usable ++ */ ++ sess1.mac = digest_data[i].devcryptoid; ++ sess2.ses = 0; ++ if (ioctl(cfd, CIOCGSESSION, &sess1) < 0) { ++ digest_driver_info[i].status = DEVCRYPTO_STATUS_NO_CIOCGSESSION; ++ goto finish; ++ } ++ ++#ifdef CIOCGSESSINFO ++ /* gather hardware acceleration info from the driver */ ++ siop.ses = sess1.ses; ++ if (ioctl(cfd, CIOCGSESSINFO, &siop) < 0) { ++ digest_driver_info[i].accelerated = DEVCRYPTO_ACCELERATION_UNKNOWN; ++ } else { ++ digest_driver_info[i].driver_name = ++ OPENSSL_strndup(siop.hash_info.cra_driver_name, ++ CRYPTODEV_MAX_ALG_NAME); ++ if (siop.flags & SIOP_FLAG_KERNEL_DRIVER_ONLY) ++ digest_driver_info[i].accelerated = DEVCRYPTO_ACCELERATED; ++ else ++ digest_driver_info[i].accelerated = DEVCRYPTO_NOT_ACCELERATED; ++ } ++#endif ++ ++ /* digest must be capable of hash state copy */ ++ sess2.mac = sess1.mac; ++ if (ioctl(cfd, CIOCGSESSION, &sess2) < 0) { ++ digest_driver_info[i].status = DEVCRYPTO_STATUS_FAILURE; ++ goto finish; ++ } ++ cphash.src_ses = sess1.ses; ++ cphash.dst_ses = sess2.ses; ++ if (ioctl(cfd, CIOCCPHASH, &cphash) < 0) { ++ digest_driver_info[i].status = DEVCRYPTO_STATUS_NO_CIOCCPHASH; ++ goto finish; ++ } ++ if ((known_digest_methods[i] = EVP_MD_meth_new(digest_data[i].nid, ++ NID_undef)) == NULL ++ || !EVP_MD_meth_set_input_blocksize(known_digest_methods[i], ++ digest_data[i].blocksize) ++ || !EVP_MD_meth_set_result_size(known_digest_methods[i], ++ digest_data[i].digestlen) ++ || !EVP_MD_meth_set_init(known_digest_methods[i], digest_init) ++ || !EVP_MD_meth_set_update(known_digest_methods[i], digest_update) ++ || !EVP_MD_meth_set_final(known_digest_methods[i], digest_final) ++ || !EVP_MD_meth_set_copy(known_digest_methods[i], digest_copy) ++ || !EVP_MD_meth_set_cleanup(known_digest_methods[i], digest_cleanup) ++ || !EVP_MD_meth_set_app_datasize(known_digest_methods[i], ++ sizeof(struct digest_ctx))) { ++ digest_driver_info[i].status = DEVCRYPTO_STATUS_FAILURE; ++ EVP_MD_meth_free(known_digest_methods[i]); ++ known_digest_methods[i] = NULL; ++ goto finish; ++ } ++ digest_driver_info[i].status = DEVCRYPTO_STATUS_USABLE; ++finish: ++ ioctl(cfd, CIOCFSESSION, &sess1.ses); ++ if (sess2.ses != 0) ++ ioctl(cfd, CIOCFSESSION, &sess2.ses); ++ if (devcrypto_test_digest(i)) ++ known_digest_nids[known_digest_nids_amount++] = digest_data[i].nid; ++ } ++} ++ ++static const EVP_MD *get_digest_method(int nid) ++{ ++ size_t i = get_digest_data_index(nid); ++ ++ if (i == (size_t)-1) ++ return NULL; ++ return known_digest_methods[i]; ++} ++ ++static int get_digest_nids(const int **nids) ++{ ++ *nids = known_digest_nids; ++ return known_digest_nids_amount; ++} ++ ++static void destroy_digest_method(int nid) ++{ ++ size_t i = get_digest_data_index(nid); ++ ++ EVP_MD_meth_free(known_digest_methods[i]); ++ known_digest_methods[i] = NULL; ++} ++ ++static void destroy_all_digest_methods(void) ++{ ++ size_t i; ++ ++ for (i = 0; i < OSSL_NELEM(digest_data); i++) { ++ destroy_digest_method(digest_data[i].nid); ++ OPENSSL_free(digest_driver_info[i].driver_name); ++ digest_driver_info[i].driver_name = NULL; ++ } ++} ++ ++static int devcrypto_digests(ENGINE *e, const EVP_MD **digest, ++ const int **nids, int nid) ++{ ++ if (digest == NULL) ++ return get_digest_nids(nids); ++ ++ *digest = get_digest_method(nid); ++ ++ return *digest != NULL; ++} ++ ++static void devcrypto_select_all_digests(int *digest_list) ++{ ++ size_t i; ++ ++ for (i = 0; i < OSSL_NELEM(digest_data); i++) ++ digest_list[i] = 1; ++} ++ ++static int cryptodev_select_digest_cb(const char *str, int len, void *usr) ++{ ++ int *digest_list = (int *)usr; ++ char *name; ++ const EVP_MD *EVP; ++ size_t i; ++ ++ if (len == 0) ++ return 1; ++ if (usr == NULL || (name = OPENSSL_strndup(str, len)) == NULL) ++ return 0; ++ EVP = EVP_get_digestbyname(name); ++ if (EVP == NULL) ++ fprintf(stderr, "devcrypto: unknown digest %s\n", name); ++ else if ((i = find_digest_data_index(EVP_MD_type(EVP))) != (size_t)-1) ++ digest_list[i] = 1; ++ else ++ fprintf(stderr, "devcrypto: digest %s not available\n", name); ++ OPENSSL_free(name); ++ return 1; ++} ++ ++static void dump_digest_info(void) ++{ ++ size_t i; ++ const char *name; ++ ++ fprintf (stderr, "Information about digests supported by the /dev/crypto" ++ " engine:\n"); ++#ifndef CIOCGSESSINFO ++ fprintf(stderr, "CIOCGSESSINFO (session info call) unavailable\n"); ++#endif ++ ++ for (i = 0; i < OSSL_NELEM(digest_data); i++) { ++ name = OBJ_nid2sn(digest_data[i].nid); ++ fprintf (stderr, "Digest %s, NID=%d, /dev/crypto info: id=%d, driver=%s", ++ name ? name : "unknown", digest_data[i].nid, ++ digest_data[i].devcryptoid, ++ digest_driver_info[i].driver_name ? digest_driver_info[i].driver_name : "unknown"); ++ if (digest_driver_info[i].status == DEVCRYPTO_STATUS_NO_CIOCGSESSION) { ++ fprintf (stderr, ". CIOCGSESSION (session open) failed\n"); ++ continue; ++ } ++ if (digest_driver_info[i].accelerated == DEVCRYPTO_ACCELERATED) ++ fprintf(stderr, " (hw accelerated)"); ++ else if (digest_driver_info[i].accelerated == DEVCRYPTO_NOT_ACCELERATED) ++ fprintf(stderr, " (software)"); ++ else ++ fprintf(stderr, " (acceleration status unknown)"); ++ if (cipher_driver_info[i].status == DEVCRYPTO_STATUS_FAILURE) ++ fprintf (stderr, ". Cipher setup failed\n"); ++ else if (digest_driver_info[i].status == DEVCRYPTO_STATUS_NO_CIOCCPHASH) ++ fprintf(stderr, ", CIOCCPHASH failed\n"); ++ else ++ fprintf(stderr, ", CIOCCPHASH capable\n"); ++ } ++ fprintf(stderr, "\n"); ++} ++ ++#endif ++ ++/****************************************************************************** ++ * ++ * CONTROL COMMANDS ++ * ++ *****/ ++ ++#define DEVCRYPTO_CMD_USE_SOFTDRIVERS ENGINE_CMD_BASE ++#define DEVCRYPTO_CMD_CIPHERS (ENGINE_CMD_BASE + 1) ++#define DEVCRYPTO_CMD_DIGESTS (ENGINE_CMD_BASE + 2) ++#define DEVCRYPTO_CMD_DUMP_INFO (ENGINE_CMD_BASE + 3) ++ ++/* Helper macros for CPP string composition */ ++#ifndef OPENSSL_MSTR ++# define OPENSSL_MSTR_HELPER(x) #x ++# define OPENSSL_MSTR(x) OPENSSL_MSTR_HELPER(x) ++#endif ++ ++static const ENGINE_CMD_DEFN devcrypto_cmds[] = { ++#ifdef CIOCGSESSINFO ++ {DEVCRYPTO_CMD_USE_SOFTDRIVERS, ++ "USE_SOFTDRIVERS", ++ "specifies whether to use software (not accelerated) drivers (" ++ OPENSSL_MSTR(DEVCRYPTO_REQUIRE_ACCELERATED) "=use only accelerated drivers, " ++ OPENSSL_MSTR(DEVCRYPTO_USE_SOFTWARE) "=allow all drivers, " ++ OPENSSL_MSTR(DEVCRYPTO_REJECT_SOFTWARE) ++ "=use if acceleration can't be determined) [default=" ++ OPENSSL_MSTR(DEVCRYPTO_DEFAULT_USE_SOFTDRIVERS) "]", ++ ENGINE_CMD_FLAG_NUMERIC}, ++#endif ++ ++ {DEVCRYPTO_CMD_CIPHERS, ++ "CIPHERS", ++ "either ALL, NONE, or a comma-separated list of ciphers to enable [default=ALL]", ++ ENGINE_CMD_FLAG_STRING}, ++ ++#ifdef IMPLEMENT_DIGEST ++ {DEVCRYPTO_CMD_DIGESTS, ++ "DIGESTS", ++ "either ALL, NONE, or a comma-separated list of digests to enable [default=ALL]", ++ ENGINE_CMD_FLAG_STRING}, ++#endif ++ ++ {DEVCRYPTO_CMD_DUMP_INFO, ++ "DUMP_INFO", ++ "dump info about each algorithm to stderr; use 'openssl engine -pre DUMP_INFO devcrypto'", ++ ENGINE_CMD_FLAG_NO_INPUT}, ++ ++ {0, NULL, NULL, 0} ++}; ++ ++static int devcrypto_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void)) ++{ ++ int *new_list; ++ switch (cmd) { ++#ifdef CIOCGSESSINFO ++ case DEVCRYPTO_CMD_USE_SOFTDRIVERS: ++ switch (i) { ++ case DEVCRYPTO_REQUIRE_ACCELERATED: ++ case DEVCRYPTO_USE_SOFTWARE: ++ case DEVCRYPTO_REJECT_SOFTWARE: ++ break; ++ default: ++ fprintf(stderr, "devcrypto: invalid value (%ld) for USE_SOFTDRIVERS\n", i); ++ return 0; ++ } ++ if (use_softdrivers == i) ++ return 1; ++ use_softdrivers = i; ++#ifdef IMPLEMENT_DIGEST ++ rebuild_known_digest_nids(e); ++#endif ++ rebuild_known_cipher_nids(e); ++ return 1; ++#endif /* CIOCGSESSINFO */ ++ ++ case DEVCRYPTO_CMD_CIPHERS: ++ if (p == NULL) ++ return 1; ++ if (strcasecmp((const char *)p, "ALL") == 0) { ++ devcrypto_select_all_ciphers(selected_ciphers); ++ } else if (strcasecmp((const char*)p, "NONE") == 0) { ++ memset(selected_ciphers, 0, sizeof(selected_ciphers)); ++ } else { ++ new_list=OPENSSL_zalloc(sizeof(selected_ciphers)); ++ if (!CONF_parse_list(p, ',', 1, cryptodev_select_cipher_cb, new_list)) { ++ OPENSSL_free(new_list); ++ return 0; ++ } ++ memcpy(selected_ciphers, new_list, sizeof(selected_ciphers)); ++ OPENSSL_free(new_list); ++ } ++ rebuild_known_cipher_nids(e); ++ return 1; ++ ++#ifdef IMPLEMENT_DIGEST ++ case DEVCRYPTO_CMD_DIGESTS: ++ if (p == NULL) ++ return 1; ++ if (strcasecmp((const char *)p, "ALL") == 0) { ++ devcrypto_select_all_digests(selected_digests); ++ } else if (strcasecmp((const char*)p, "NONE") == 0) { ++ memset(selected_digests, 0, sizeof(selected_digests)); ++ } else { ++ new_list=OPENSSL_zalloc(sizeof(selected_digests)); ++ if (!CONF_parse_list(p, ',', 1, cryptodev_select_digest_cb, new_list)) { ++ OPENSSL_free(new_list); ++ return 0; ++ } ++ memcpy(selected_digests, new_list, sizeof(selected_digests)); ++ OPENSSL_free(new_list); ++ } ++ rebuild_known_digest_nids(e); ++ return 1; ++#endif /* IMPLEMENT_DIGEST */ ++ ++ case DEVCRYPTO_CMD_DUMP_INFO: ++ dump_cipher_info(); ++#ifdef IMPLEMENT_DIGEST ++ dump_digest_info(); ++#endif ++ return 1; ++ ++ default: ++ break; ++ } ++ return 0; ++} ++ ++/****************************************************************************** ++ * ++ * LOAD / UNLOAD ++ * ++ *****/ ++ ++/* ++ * Opens /dev/crypto ++ */ ++static int open_devcrypto(void) ++{ ++ int fd; ++ ++ if (cfd >= 0) ++ return 1; ++ ++ if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0) { ++#ifndef ENGINE_DEVCRYPTO_DEBUG ++ if (errno != ENOENT) ++#endif ++ fprintf(stderr, "Could not open /dev/crypto: %s\n", strerror(errno)); ++ return 0; ++ } ++ ++#ifdef CRIOGET ++ if (ioctl(fd, CRIOGET, &cfd) < 0) { ++ fprintf(stderr, "Could not create crypto fd: %s\n", strerror(errno)); ++ close(fd); ++ cfd = -1; ++ return 0; ++ } ++ close(fd); ++#else ++ cfd = fd; ++#endif ++ + return 1; +} + @@ -232,20 +2603,17 @@ rename to engines/e_devcrypto.c + if (ret != 0) { + fprintf(stderr, "Error closing /dev/crypto: %s\n", strerror(errno)); + return 0; - } ++ } + return 1; +} - -- prepare_cipher_methods(); ++ +static int devcrypto_unload(ENGINE *e) +{ + destroy_all_cipher_methods(); - #ifdef IMPLEMENT_DIGEST -- prepare_digest_methods(); ++#ifdef IMPLEMENT_DIGEST + destroy_all_digest_methods(); - #endif - -- if (!ENGINE_set_id(e, "devcrypto") ++#endif ++ + close_devcrypto(); + + return 1; @@ -254,13 +2622,12 @@ rename to engines/e_devcrypto.c +static int bind_devcrypto(ENGINE *e) { + + if (!ENGINE_set_id(e, engine_devcrypto_id) - || !ENGINE_set_name(e, "/dev/crypto engine") ++ || !ENGINE_set_name(e, "/dev/crypto engine") + || !ENGINE_set_destroy_function(e, devcrypto_unload) - || !ENGINE_set_cmd_defns(e, devcrypto_cmds) -- || !ENGINE_set_ctrl_function(e, devcrypto_ctrl) ++ || !ENGINE_set_cmd_defns(e, devcrypto_cmds) + || !ENGINE_set_ctrl_function(e, devcrypto_ctrl)) + return 0; - ++ + prepare_cipher_methods(); +#ifdef IMPLEMENT_DIGEST + prepare_digest_methods(); @@ -270,34 +2637,40 @@ rename to engines/e_devcrypto.c +#ifdef IMPLEMENT_DIGEST + && ENGINE_set_digests(e, devcrypto_digests) +#endif - /* - * Asymmetric ciphers aren't well supported with /dev/crypto. Among the BSD - * implementations, it seems to only exist in FreeBSD, and regarding the -@@ -1250,23 +1268,36 @@ void engine_load_devcrypto_int() - */ - #if 0 - # ifndef OPENSSL_NO_RSA -- || !ENGINE_set_RSA(e, devcrypto_rsa) ++/* ++ * Asymmetric ciphers aren't well supported with /dev/crypto. Among the BSD ++ * implementations, it seems to only exist in FreeBSD, and regarding the ++ * parameters in its crypt_kop, the manual crypto(4) has this to say: ++ * ++ * The semantics of these arguments are currently undocumented. ++ * ++ * Reading through the FreeBSD source code doesn't give much more than ++ * their CRK_MOD_EXP implementation for ubsec. ++ * ++ * It doesn't look much better with cryptodev-linux. They have the crypt_kop ++ * structure as well as the command (CRK_*) in cryptodev.h, but no support ++ * seems to be implemented at all for the moment. ++ * ++ * At the time of writing, it seems impossible to write proper support for ++ * FreeBSD's asym features without some very deep knowledge and access to ++ * specific kernel modules. ++ * ++ * /Richard Levitte, 2017-05-11 ++ */ ++#if 0 ++# ifndef OPENSSL_NO_RSA + && ENGINE_set_RSA(e, devcrypto_rsa) - # endif - # ifndef OPENSSL_NO_DSA -- || !ENGINE_set_DSA(e, devcrypto_dsa) ++# endif ++# ifndef OPENSSL_NO_DSA + && ENGINE_set_DSA(e, devcrypto_dsa) - # endif - # ifndef OPENSSL_NO_DH -- || !ENGINE_set_DH(e, devcrypto_dh) ++# endif ++# ifndef OPENSSL_NO_DH + && ENGINE_set_DH(e, devcrypto_dh) - # endif - # ifndef OPENSSL_NO_EC -- || !ENGINE_set_EC(e, devcrypto_ec) ++# endif ++# ifndef OPENSSL_NO_EC + && ENGINE_set_EC(e, devcrypto_ec) - # endif - #endif -- || !ENGINE_set_ciphers(e, devcrypto_ciphers) --#ifdef IMPLEMENT_DIGEST -- || !ENGINE_set_digests(e, devcrypto_digests) --#endif -- ) { ++# endif ++#endif + ); +} + @@ -316,13 +2689,14 @@ rename to engines/e_devcrypto.c + if ((e = ENGINE_new()) == NULL + || !bind_devcrypto(e)) { + close_devcrypto(); - ENGINE_free(e); - return; - } -@@ -1275,3 +1306,22 @@ void engine_load_devcrypto_int() - ENGINE_free(e); /* Loose our local reference */ - ERR_clear_error(); - } ++ ENGINE_free(e); ++ return; ++ } ++ ++ ENGINE_add(e); ++ ENGINE_free(e); /* Loose our local reference */ ++ ERR_clear_error(); ++} + +#else + diff --git a/package/libs/openssl/patches/500-e_devcrypto-default-to-not-use-digests-in-engine.patch b/package/libs/openssl/patches/500-e_devcrypto-default-to-not-use-digests-in-engine.patch index fd4701307e..df5c16d8d2 100644 --- a/package/libs/openssl/patches/500-e_devcrypto-default-to-not-use-digests-in-engine.patch +++ b/package/libs/openssl/patches/500-e_devcrypto-default-to-not-use-digests-in-engine.patch @@ -19,7 +19,6 @@ turn them on if it is safe and fast enough. Signed-off-by: Eneas U de Queiroz -diff --git a/engines/e_devcrypto.c b/engines/e_devcrypto.c --- a/engines/e_devcrypto.c +++ b/engines/e_devcrypto.c @@ -852,7 +852,7 @@ static void prepare_digest_methods(void) @@ -31,7 +30,7 @@ diff --git a/engines/e_devcrypto.c b/engines/e_devcrypto.c /* * Check that the digest is usable -@@ -1072,7 +1072,7 @@ static const ENGINE_CMD_DEFN devcrypto_cmds[] = { +@@ -1072,7 +1072,7 @@ static const ENGINE_CMD_DEFN devcrypto_c #ifdef IMPLEMENT_DIGEST {DEVCRYPTO_CMD_DIGESTS, "DIGESTS", diff --git a/package/libs/openssl/patches/510-e_devcrypto-ignore-error-when-closing-session.patch b/package/libs/openssl/patches/510-e_devcrypto-ignore-error-when-closing-session.patch index bf1c98b104..87792cf9d0 100644 --- a/package/libs/openssl/patches/510-e_devcrypto-ignore-error-when-closing-session.patch +++ b/package/libs/openssl/patches/510-e_devcrypto-ignore-error-when-closing-session.patch @@ -8,10 +8,9 @@ session. It may have been closed by another process after a fork. Signed-off-by: Eneas U de Queiroz -diff --git a/engines/e_devcrypto.c b/engines/e_devcrypto.c --- a/engines/e_devcrypto.c +++ b/engines/e_devcrypto.c -@@ -195,9 +195,8 @@ static int cipher_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, +@@ -195,9 +195,8 @@ static int cipher_init(EVP_CIPHER_CTX *c get_cipher_data(EVP_CIPHER_CTX_nid(ctx)); /* cleanup a previous session */ From 52167feff8ae3fbd02be22dfe6021e7e9c79c599 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Fri, 4 Nov 2022 23:34:02 +0100 Subject: [PATCH 14/32] tools/fakeroot: update to 1.30.1 Release Notes: https://tracker.debian.org/news/1381350/accepted-fakeroot-1301-1-source-into-unstable/ Refresh patches: - 600-macOS.patch Signed-off-by: Nick Hainke --- tools/fakeroot/Makefile | 4 ++-- tools/fakeroot/patches/600-macOS.patch | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/fakeroot/Makefile b/tools/fakeroot/Makefile index efd9227d1a..66ccbcb50d 100644 --- a/tools/fakeroot/Makefile +++ b/tools/fakeroot/Makefile @@ -5,12 +5,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=fakeroot -PKG_VERSION:=1.29 +PKG_VERSION:=1.30.1 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz PKG_SOURCE_URL:=@DEBIAN/pool/main/f/fakeroot -PKG_HASH:=8fbbafb780c9173e3ace4a04afbc1d900f337f3216883939f5c7db3431be7c20 +PKG_HASH:=32ebb1f421aca0db7141c32a8c104eb95d2b45c393058b9435fbf903dd2b6a75 PKG_LICENSE:=GPL-3.0-or-later PKG_LICENSE_FILES:=COPYING PKG_FIXUP:=autoreconf diff --git a/tools/fakeroot/patches/600-macOS.patch b/tools/fakeroot/patches/600-macOS.patch index 730367f07c..5cfcc81284 100644 --- a/tools/fakeroot/patches/600-macOS.patch +++ b/tools/fakeroot/patches/600-macOS.patch @@ -24,7 +24,7 @@ #include --- a/wrapfunc.inp +++ b/wrapfunc.inp -@@ -48,9 +48,11 @@ getattrlist$UNIX2003;int;(const char *pa +@@ -50,9 +50,11 @@ getattrlist$UNIX2003;int;(const char *pa #endif #endif #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 @@ -36,7 +36,7 @@ posix_spawn;int;(pid_t * __restrict pid, const char * __restrict path, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t * __restrict attrp, char *const argv[ __restrict], char *const envp[ __restrict]);(pid, path, file_actions, attrp, argv, envp) posix_spawnp;int;(pid_t * __restrict pid, const char * __restrict path, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t * __restrict attrp, char *const argv[ __restrict], char *const envp[ __restrict]);(pid, path, file_actions, attrp, argv, envp) #endif -@@ -229,7 +231,7 @@ facl;int;(int fd, int cmd, int cnt, void +@@ -231,7 +233,7 @@ facl;int;(int fd, int cmd, int cnt, void #ifdef HAVE_FTS_READ fts_read;FTSENT *;(FTS *ftsp);(ftsp) #ifdef __APPLE__ @@ -45,7 +45,7 @@ fts_read$INODE64;FTSENT *;(FTS *ftsp);(ftsp) #endif #endif /* ifdef __APPLE__ */ -@@ -237,7 +239,7 @@ fts_read$INODE64;FTSENT *;(FTS *ftsp);(f +@@ -239,7 +241,7 @@ fts_read$INODE64;FTSENT *;(FTS *ftsp);(f #ifdef HAVE_FTS_CHILDREN fts_children;FTSENT *;(FTS *ftsp, int options);(ftsp, options) #ifdef __APPLE__ From 87edb650c74a73d854bc01c0aed46d38dafb09a0 Mon Sep 17 00:00:00 2001 From: John Audia Date: Thu, 3 Nov 2022 12:54:01 -0400 Subject: [PATCH 15/32] kernel: bump 5.10 to 5.10.153 Manually rebased: bcm53xx/patches-5.10/180-usb-xhci-add-support-for-performing-fake-doorbell.patch lantiq/patches-5.10/0028-NET-lantiq-various-etop-fixes.patch All patches automatically rebased. Signed-off-by: John Audia --- include/kernel-5.10 | 4 ++-- .../802-usb-xhci-force-msi-renesas-xhci.patch | 4 ++-- .../910-unaligned_access_hacks.patch | 2 +- ...support-for-performing-fake-doorbell.patch | 6 +++--- ...Add-support-for-MAP-E-FMRs-mesh-mode.patch | 18 ++++++++-------- .../0028-NET-lantiq-various-etop-fixes.patch | 21 +++++++++---------- ...IPS-ralink-add-sdhci-for-mt7620a-SoC.patch | 2 +- 7 files changed, 28 insertions(+), 29 deletions(-) diff --git a/include/kernel-5.10 b/include/kernel-5.10 index f4cdfe5faa..9b74446f8e 100644 --- a/include/kernel-5.10 +++ b/include/kernel-5.10 @@ -1,2 +1,2 @@ -LINUX_VERSION-5.10 = .152 -LINUX_KERNEL_HASH-5.10.152 = fa0b5c83a4ebfda9f0a52cc693646eb6c24dbade6c37ee2d18b66ee2df15d8a6 +LINUX_VERSION-5.10 = .153 +LINUX_KERNEL_HASH-5.10.153 = 3cf2e4519fe451caef0ee0a8beac694612267325f7055fc38d6a990a762f1662 diff --git a/target/linux/apm821xx/patches-5.10/802-usb-xhci-force-msi-renesas-xhci.patch b/target/linux/apm821xx/patches-5.10/802-usb-xhci-force-msi-renesas-xhci.patch index 288276cca6..ced9b6a158 100644 --- a/target/linux/apm821xx/patches-5.10/802-usb-xhci-force-msi-renesas-xhci.patch +++ b/target/linux/apm821xx/patches-5.10/802-usb-xhci-force-msi-renesas-xhci.patch @@ -13,7 +13,7 @@ produce a noisy warning. --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c -@@ -287,6 +287,7 @@ static void xhci_pci_quirks(struct devic +@@ -291,6 +291,7 @@ static void xhci_pci_quirks(struct devic pdev->device == 0x0015) { xhci->quirks |= XHCI_RESET_ON_RESUME; xhci->quirks |= XHCI_ZERO_64B_REGS; @@ -43,7 +43,7 @@ produce a noisy warning. hcd->msi_enabled = 1; --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h -@@ -1896,6 +1896,7 @@ struct xhci_hcd { +@@ -1897,6 +1897,7 @@ struct xhci_hcd { struct xhci_hub usb2_rhub; struct xhci_hub usb3_rhub; /* support xHCI 1.0 spec USB2 hardware LPM */ diff --git a/target/linux/ath79/patches-5.10/910-unaligned_access_hacks.patch b/target/linux/ath79/patches-5.10/910-unaligned_access_hacks.patch index 977f394a62..3b0eff9419 100644 --- a/target/linux/ath79/patches-5.10/910-unaligned_access_hacks.patch +++ b/target/linux/ath79/patches-5.10/910-unaligned_access_hacks.patch @@ -740,7 +740,7 @@ SVN-Revision: 35130 EXPORT_SYMBOL(xfrm_parse_spi); --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c -@@ -4127,14 +4127,16 @@ static bool tcp_parse_aligned_timestamp( +@@ -4128,14 +4128,16 @@ static bool tcp_parse_aligned_timestamp( { const __be32 *ptr = (const __be32 *)(th + 1); diff --git a/target/linux/bcm53xx/patches-5.10/180-usb-xhci-add-support-for-performing-fake-doorbell.patch b/target/linux/bcm53xx/patches-5.10/180-usb-xhci-add-support-for-performing-fake-doorbell.patch index bce4ea6740..022b2945ad 100644 --- a/target/linux/bcm53xx/patches-5.10/180-usb-xhci-add-support-for-performing-fake-doorbell.patch +++ b/target/linux/bcm53xx/patches-5.10/180-usb-xhci-add-support-for-performing-fake-doorbell.patch @@ -127,11 +127,11 @@ it on BCM4708 family. /* --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h -@@ -1889,6 +1889,7 @@ struct xhci_hcd { - #define XHCI_NO_SOFT_RETRY BIT_ULL(40) +@@ -1890,6 +1890,7 @@ struct xhci_hcd { #define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42) #define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43) -+#define XHCI_FAKE_DOORBELL BIT_ULL(44) + #define XHCI_RESET_TO_DEFAULT BIT_ULL(44) ++#define XHCI_FAKE_DOORBELL BIT_ULL(45) unsigned int num_active_eps; unsigned int limit_active_eps; diff --git a/target/linux/generic/pending-5.10/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch b/target/linux/generic/pending-5.10/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch index 89eb7d61b3..59f202c4c5 100644 --- a/target/linux/generic/pending-5.10/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch +++ b/target/linux/generic/pending-5.10/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch @@ -338,7 +338,7 @@ Signed-off-by: Steven Barth if (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6)) return -1; -@@ -1555,6 +1716,14 @@ ip6_tnl_change(struct ip6_tnl *t, const +@@ -1556,6 +1717,14 @@ ip6_tnl_change(struct ip6_tnl *t, const t->parms.link = p->link; t->parms.proto = p->proto; t->parms.fwmark = p->fwmark; @@ -353,7 +353,7 @@ Signed-off-by: Steven Barth dst_cache_reset(&t->dst_cache); ip6_tnl_link_config(t); return 0; -@@ -1593,6 +1762,7 @@ ip6_tnl_parm_from_user(struct __ip6_tnl_ +@@ -1594,6 +1763,7 @@ ip6_tnl_parm_from_user(struct __ip6_tnl_ p->flowinfo = u->flowinfo; p->link = u->link; p->proto = u->proto; @@ -361,7 +361,7 @@ Signed-off-by: Steven Barth memcpy(p->name, u->name, sizeof(u->name)); } -@@ -1978,6 +2148,15 @@ static int ip6_tnl_validate(struct nlatt +@@ -1979,6 +2149,15 @@ static int ip6_tnl_validate(struct nlatt return 0; } @@ -377,7 +377,7 @@ Signed-off-by: Steven Barth static void ip6_tnl_netlink_parms(struct nlattr *data[], struct __ip6_tnl_parm *parms) { -@@ -2015,6 +2194,46 @@ static void ip6_tnl_netlink_parms(struct +@@ -2016,6 +2195,46 @@ static void ip6_tnl_netlink_parms(struct if (data[IFLA_IPTUN_FWMARK]) parms->fwmark = nla_get_u32(data[IFLA_IPTUN_FWMARK]); @@ -424,7 +424,7 @@ Signed-off-by: Steven Barth } static bool ip6_tnl_netlink_encap_parms(struct nlattr *data[], -@@ -2130,6 +2349,12 @@ static void ip6_tnl_dellink(struct net_d +@@ -2131,6 +2350,12 @@ static void ip6_tnl_dellink(struct net_d static size_t ip6_tnl_get_size(const struct net_device *dev) { @@ -437,7 +437,7 @@ Signed-off-by: Steven Barth return /* IFLA_IPTUN_LINK */ nla_total_size(4) + -@@ -2159,6 +2384,24 @@ static size_t ip6_tnl_get_size(const str +@@ -2160,6 +2385,24 @@ static size_t ip6_tnl_get_size(const str nla_total_size(0) + /* IFLA_IPTUN_FWMARK */ nla_total_size(4) + @@ -462,7 +462,7 @@ Signed-off-by: Steven Barth 0; } -@@ -2166,6 +2409,9 @@ static int ip6_tnl_fill_info(struct sk_b +@@ -2167,6 +2410,9 @@ static int ip6_tnl_fill_info(struct sk_b { struct ip6_tnl *tunnel = netdev_priv(dev); struct __ip6_tnl_parm *parm = &tunnel->parms; @@ -472,7 +472,7 @@ Signed-off-by: Steven Barth if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) || nla_put_in6_addr(skb, IFLA_IPTUN_LOCAL, &parm->laddr) || -@@ -2175,9 +2421,27 @@ static int ip6_tnl_fill_info(struct sk_b +@@ -2176,9 +2422,27 @@ static int ip6_tnl_fill_info(struct sk_b nla_put_be32(skb, IFLA_IPTUN_FLOWINFO, parm->flowinfo) || nla_put_u32(skb, IFLA_IPTUN_FLAGS, parm->flags) || nla_put_u8(skb, IFLA_IPTUN_PROTO, parm->proto) || @@ -501,7 +501,7 @@ Signed-off-by: Steven Barth if (nla_put_u16(skb, IFLA_IPTUN_ENCAP_TYPE, tunnel->encap.type) || nla_put_be16(skb, IFLA_IPTUN_ENCAP_SPORT, tunnel->encap.sport) || nla_put_be16(skb, IFLA_IPTUN_ENCAP_DPORT, tunnel->encap.dport) || -@@ -2217,6 +2481,7 @@ static const struct nla_policy ip6_tnl_p +@@ -2218,6 +2482,7 @@ static const struct nla_policy ip6_tnl_p [IFLA_IPTUN_ENCAP_DPORT] = { .type = NLA_U16 }, [IFLA_IPTUN_COLLECT_METADATA] = { .type = NLA_FLAG }, [IFLA_IPTUN_FWMARK] = { .type = NLA_U32 }, diff --git a/target/linux/lantiq/patches-5.10/0028-NET-lantiq-various-etop-fixes.patch b/target/linux/lantiq/patches-5.10/0028-NET-lantiq-various-etop-fixes.patch index eb47010fa0..e9f3ee473b 100644 --- a/target/linux/lantiq/patches-5.10/0028-NET-lantiq-various-etop-fixes.patch +++ b/target/linux/lantiq/patches-5.10/0028-NET-lantiq-various-etop-fixes.patch @@ -625,7 +625,7 @@ Signed-off-by: John Crispin return 0; } -@@ -457,16 +651,16 @@ ltq_etop_tx(struct sk_buff *skb, struct +@@ -457,15 +651,16 @@ ltq_etop_tx(struct sk_buff *skb, struct int queue = skb_get_queue_mapping(skb); struct netdev_queue *txq = netdev_get_tx_queue(dev, queue); struct ltq_etop_priv *priv = netdev_priv(dev); @@ -641,13 +641,12 @@ Signed-off-by: John Crispin len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len; - if ((desc->ctl & (LTQ_DMA_OWN | LTQ_DMA_C)) || ch->skb[ch->dma.desc]) { -- dev_kfree_skb_any(skb); + if ((desc->ctl & (LTQ_DMA_OWN | LTQ_DMA_C)) || + priv->txch.skb[priv->txch.dma.desc]) { netdev_err(dev, "tx ring full\n"); netif_tx_stop_queue(txq); return NETDEV_TX_BUSY; -@@ -474,7 +668,7 @@ ltq_etop_tx(struct sk_buff *skb, struct +@@ -473,7 +668,7 @@ ltq_etop_tx(struct sk_buff *skb, struct /* dma needs to start on a 16 byte aligned address */ byte_offset = CPHYSADDR(skb->data) % 16; @@ -656,7 +655,7 @@ Signed-off-by: John Crispin netif_trans_update(dev); -@@ -484,11 +678,11 @@ ltq_etop_tx(struct sk_buff *skb, struct +@@ -483,11 +678,11 @@ ltq_etop_tx(struct sk_buff *skb, struct wmb(); desc->ctl = LTQ_DMA_OWN | LTQ_DMA_SOP | LTQ_DMA_EOP | LTQ_DMA_TX_OFFSET(byte_offset) | (len & LTQ_DMA_SIZE_MASK); @@ -671,7 +670,7 @@ Signed-off-by: John Crispin netif_tx_stop_queue(txq); return NETDEV_TX_OK; -@@ -499,11 +693,14 @@ ltq_etop_change_mtu(struct net_device *d +@@ -498,11 +693,14 @@ ltq_etop_change_mtu(struct net_device *d { struct ltq_etop_priv *priv = netdev_priv(dev); unsigned long flags; @@ -687,7 +686,7 @@ Signed-off-by: John Crispin spin_unlock_irqrestore(&priv->lock, flags); return 0; -@@ -556,6 +753,9 @@ ltq_etop_init(struct net_device *dev) +@@ -555,6 +753,9 @@ ltq_etop_init(struct net_device *dev) if (err) goto err_hw; ltq_etop_change_mtu(dev, 1500); @@ -697,7 +696,7 @@ Signed-off-by: John Crispin memcpy(&mac, &priv->pldata->mac, sizeof(struct sockaddr)); if (!is_valid_ether_addr(mac.sa_data)) { -@@ -573,9 +773,10 @@ ltq_etop_init(struct net_device *dev) +@@ -572,9 +773,10 @@ ltq_etop_init(struct net_device *dev) dev->addr_assign_type = NET_ADDR_RANDOM; ltq_etop_set_multicast_list(dev); @@ -711,7 +710,7 @@ Signed-off-by: John Crispin return 0; err_netdev: -@@ -595,6 +796,9 @@ ltq_etop_tx_timeout(struct net_device *d +@@ -594,6 +796,9 @@ ltq_etop_tx_timeout(struct net_device *d err = ltq_etop_hw_init(dev); if (err) goto err_hw; @@ -721,7 +720,7 @@ Signed-off-by: John Crispin netif_trans_update(dev); netif_wake_queue(dev); return; -@@ -618,14 +822,18 @@ static const struct net_device_ops ltq_e +@@ -617,14 +822,18 @@ static const struct net_device_ops ltq_e .ndo_tx_timeout = ltq_etop_tx_timeout, }; @@ -744,7 +743,7 @@ Signed-off-by: John Crispin res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { -@@ -651,31 +859,62 @@ ltq_etop_probe(struct platform_device *p +@@ -650,31 +859,62 @@ ltq_etop_probe(struct platform_device *p goto err_out; } @@ -822,7 +821,7 @@ Signed-off-by: John Crispin err = register_netdev(dev); if (err) -@@ -704,31 +943,22 @@ ltq_etop_remove(struct platform_device * +@@ -703,31 +943,22 @@ ltq_etop_remove(struct platform_device * return 0; } diff --git a/target/linux/ramips/patches-5.10/830-mmc-MIPS-ralink-add-sdhci-for-mt7620a-SoC.patch b/target/linux/ramips/patches-5.10/830-mmc-MIPS-ralink-add-sdhci-for-mt7620a-SoC.patch index 77311c36de..544b1d267e 100644 --- a/target/linux/ramips/patches-5.10/830-mmc-MIPS-ralink-add-sdhci-for-mt7620a-SoC.patch +++ b/target/linux/ramips/patches-5.10/830-mmc-MIPS-ralink-add-sdhci-for-mt7620a-SoC.patch @@ -25,7 +25,7 @@ Signed-off-by: John Crispin --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig -@@ -1101,3 +1101,5 @@ config MMC_OWL +@@ -1102,3 +1102,5 @@ config MMC_OWL config MMC_SDHCI_EXTERNAL_DMA bool From 1eebe72a80a5c2f1ca7d0e027a82ff67d9271a8b Mon Sep 17 00:00:00 2001 From: John Audia Date: Thu, 3 Nov 2022 12:07:30 -0400 Subject: [PATCH 16/32] kernel: bump 5.15 to 5.15.77 Manually rebased: bcm27xx/patches-5.15/950-0600-xhci-quirks-add-link-TRB-quirk-for-VL805.patch bcm27xx/patches-5.15/950-0606-usb-xhci-add-VLI_TRB_CACHE_BUG-quirk.patch bcm27xx/patches-5.15/950-0717-usb-xhci-add-a-quirk-for-Superspeed-bulk-OUT-transfe.patch bcm53xx/patches-5.15/180-usb-xhci-add-support-for-performing-fake-doorbell.patch lantiq/patches-5.15/0028-NET-lantiq-various-etop-fixes.patch All other patches automatically rebased Build system: x86_64 Build-tested: bcm2711/RPi4B, mt7622/RT3200 Run-tested: bcm2711/RPi4B, mt7622/RT3200 Signed-off-by: John Audia --- include/kernel-5.15 | 4 ++-- .../910-unaligned_access_hacks.patch | 2 +- ...070-MMC-added-alternative-MMC-driver.patch | 8 +++---- ...hci_fixup_endpoint-for-interval-adju.patch | 4 ++-- ...ore-event-ring-segment-table-entries.patch | 4 ++-- ...2.h-add-V4L2_CTRL_FLAG_DYNAMIC_ARRAY.patch | 2 +- ...-quirks-add-link-TRB-quirk-for-VL805.patch | 8 +++---- ...t-TRBS_PER_SEGMENT-define-in-runtime.patch | 6 +++--- ...usb-xhci-add-VLI_TRB_CACHE_BUG-quirk.patch | 10 ++++----- ...uirk-for-Superspeed-bulk-OUT-transfe.patch | 12 +++++------ ...do-single-sector-reads-during-recove.patch | 2 +- ...support-for-performing-fake-doorbell.patch | 6 +++--- ...Add-support-for-MAP-E-FMRs-mesh-mode.patch | 18 ++++++++-------- .../0028-NET-lantiq-various-etop-fixes.patch | 21 +++++++++---------- .../patches-5.15/410-bt-mtk-serial-fix.patch | 2 +- ...IPS-ralink-add-sdhci-for-mt7620a-SoC.patch | 2 +- 16 files changed, 55 insertions(+), 56 deletions(-) diff --git a/include/kernel-5.15 b/include/kernel-5.15 index dc199a6566..d5dcb11347 100644 --- a/include/kernel-5.15 +++ b/include/kernel-5.15 @@ -1,2 +1,2 @@ -LINUX_VERSION-5.15 = .76 -LINUX_KERNEL_HASH-5.15.76 = 9007a020c419e3625b980e361be09f70ebd99e156ccb66129a981483d065d57f +LINUX_VERSION-5.15 = .77 +LINUX_KERNEL_HASH-5.15.77 = 142f841f33796a84c62fae2f2b96d2120bd8bbf9e0aac4ce157692cdb0afe9f9 diff --git a/target/linux/ath79/patches-5.15/910-unaligned_access_hacks.patch b/target/linux/ath79/patches-5.15/910-unaligned_access_hacks.patch index 84ee47a115..d284ceeaa7 100644 --- a/target/linux/ath79/patches-5.15/910-unaligned_access_hacks.patch +++ b/target/linux/ath79/patches-5.15/910-unaligned_access_hacks.patch @@ -750,7 +750,7 @@ SVN-Revision: 35130 EXPORT_SYMBOL(xfrm_parse_spi); --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c -@@ -4151,14 +4151,16 @@ static bool tcp_parse_aligned_timestamp( +@@ -4152,14 +4152,16 @@ static bool tcp_parse_aligned_timestamp( { const __be32 *ptr = (const __be32 *)(th + 1); diff --git a/target/linux/bcm27xx/patches-5.15/950-0070-MMC-added-alternative-MMC-driver.patch b/target/linux/bcm27xx/patches-5.15/950-0070-MMC-added-alternative-MMC-driver.patch index 754b633967..4548083000 100644 --- a/target/linux/bcm27xx/patches-5.15/950-0070-MMC-added-alternative-MMC-driver.patch +++ b/target/linux/bcm27xx/patches-5.15/950-0070-MMC-added-alternative-MMC-driver.patch @@ -230,7 +230,7 @@ bcm2835-mmc: uninitialized_var is no more --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c -@@ -171,6 +171,13 @@ static DEFINE_MUTEX(open_lock); +@@ -172,6 +172,13 @@ static DEFINE_MUTEX(open_lock); module_param(perdev_minors, int, 0444); MODULE_PARM_DESC(perdev_minors, "Minors numbers to allocate per device"); @@ -244,7 +244,7 @@ bcm2835-mmc: uninitialized_var is no more static inline int mmc_blk_part_switch(struct mmc_card *card, unsigned int part_type); static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, -@@ -2928,6 +2935,8 @@ static int mmc_blk_probe(struct mmc_card +@@ -2936,6 +2943,8 @@ static int mmc_blk_probe(struct mmc_card { struct mmc_blk_data *md; int ret = 0; @@ -253,7 +253,7 @@ bcm2835-mmc: uninitialized_var is no more /* * Check that the card supports the command class(es) we need. -@@ -2935,7 +2944,16 @@ static int mmc_blk_probe(struct mmc_card +@@ -2943,7 +2952,16 @@ static int mmc_blk_probe(struct mmc_card if (!(card->csd.cmdclass & CCC_BLOCK_READ)) return -ENODEV; @@ -271,7 +271,7 @@ bcm2835-mmc: uninitialized_var is no more card->complete_wq = alloc_workqueue("mmc_complete", WQ_MEM_RECLAIM | WQ_HIGHPRI, 0); -@@ -2950,6 +2968,17 @@ static int mmc_blk_probe(struct mmc_card +@@ -2958,6 +2976,17 @@ static int mmc_blk_probe(struct mmc_card goto out_free; } diff --git a/target/linux/bcm27xx/patches-5.15/950-0152-xhci-implement-xhci_fixup_endpoint-for-interval-adju.patch b/target/linux/bcm27xx/patches-5.15/950-0152-xhci-implement-xhci_fixup_endpoint-for-interval-adju.patch index 85f3e610ad..aa12dae1fc 100644 --- a/target/linux/bcm27xx/patches-5.15/950-0152-xhci-implement-xhci_fixup_endpoint-for-interval-adju.patch +++ b/target/linux/bcm27xx/patches-5.15/950-0152-xhci-implement-xhci_fixup_endpoint-for-interval-adju.patch @@ -15,7 +15,7 @@ Signed-off-by: Jonathan Bell --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c -@@ -1612,6 +1612,109 @@ command_cleanup: +@@ -1618,6 +1618,109 @@ command_cleanup: } /* @@ -125,7 +125,7 @@ Signed-off-by: Jonathan Bell * non-error returns are a promise to giveback() the urb later * we drop ownership so next owner (or urb unlink) can get it */ -@@ -5437,6 +5540,7 @@ static const struct hc_driver xhci_hc_dr +@@ -5443,6 +5546,7 @@ static const struct hc_driver xhci_hc_dr .endpoint_reset = xhci_endpoint_reset, .check_bandwidth = xhci_check_bandwidth, .reset_bandwidth = xhci_reset_bandwidth, diff --git a/target/linux/bcm27xx/patches-5.15/950-0166-xhci-Use-more-event-ring-segment-table-entries.patch b/target/linux/bcm27xx/patches-5.15/950-0166-xhci-Use-more-event-ring-segment-table-entries.patch index b3f8240db2..b3ad567226 100644 --- a/target/linux/bcm27xx/patches-5.15/950-0166-xhci-Use-more-event-ring-segment-table-entries.patch +++ b/target/linux/bcm27xx/patches-5.15/950-0166-xhci-Use-more-event-ring-segment-table-entries.patch @@ -22,7 +22,7 @@ Signed-off-by: Jonathan Bell --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c -@@ -2516,9 +2516,11 @@ int xhci_mem_init(struct xhci_hcd *xhci, +@@ -2520,9 +2520,11 @@ int xhci_mem_init(struct xhci_hcd *xhci, * Event ring setup: Allocate a normal ring, but also setup * the event ring segment table (ERST). Section 4.9.3. */ @@ -36,7 +36,7 @@ Signed-off-by: Jonathan Bell if (!xhci->event_ring) goto fail; if (xhci_check_trb_in_td_math(xhci) < 0) -@@ -2531,7 +2533,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, +@@ -2535,7 +2537,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, /* set ERST count with the number of entries in the segment table */ val = readl(&xhci->ir_set->erst_size); val &= ERST_SIZE_MASK; diff --git a/target/linux/bcm27xx/patches-5.15/950-0464-videodev2.h-add-V4L2_CTRL_FLAG_DYNAMIC_ARRAY.patch b/target/linux/bcm27xx/patches-5.15/950-0464-videodev2.h-add-V4L2_CTRL_FLAG_DYNAMIC_ARRAY.patch index 58e32d9930..67137dd695 100644 --- a/target/linux/bcm27xx/patches-5.15/950-0464-videodev2.h-add-V4L2_CTRL_FLAG_DYNAMIC_ARRAY.patch +++ b/target/linux/bcm27xx/patches-5.15/950-0464-videodev2.h-add-V4L2_CTRL_FLAG_DYNAMIC_ARRAY.patch @@ -42,7 +42,7 @@ Signed-off-by: Hans Verkuil ============ --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h -@@ -1882,6 +1882,7 @@ struct v4l2_querymenu { +@@ -1883,6 +1883,7 @@ struct v4l2_querymenu { #define V4L2_CTRL_FLAG_HAS_PAYLOAD 0x0100 #define V4L2_CTRL_FLAG_EXECUTE_ON_WRITE 0x0200 #define V4L2_CTRL_FLAG_MODIFY_LAYOUT 0x0400 diff --git a/target/linux/bcm27xx/patches-5.15/950-0600-xhci-quirks-add-link-TRB-quirk-for-VL805.patch b/target/linux/bcm27xx/patches-5.15/950-0600-xhci-quirks-add-link-TRB-quirk-for-VL805.patch index 6c2840d633..dc946b1c63 100644 --- a/target/linux/bcm27xx/patches-5.15/950-0600-xhci-quirks-add-link-TRB-quirk-for-VL805.patch +++ b/target/linux/bcm27xx/patches-5.15/950-0600-xhci-quirks-add-link-TRB-quirk-for-VL805.patch @@ -22,7 +22,7 @@ Signed-off-by: Jonathan Bell --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c -@@ -304,6 +304,7 @@ static void xhci_pci_quirks(struct devic +@@ -291,6 +291,7 @@ static void xhci_pci_quirks(struct devic if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == 0x3483) { xhci->quirks |= XHCI_LPM_SUPPORT; xhci->quirks |= XHCI_EP_CTX_BROKEN_DCS; @@ -50,11 +50,11 @@ Signed-off-by: Jonathan Bell addr = xhci_trb_virt_to_dma(new_seg, new_deq); --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h -@@ -1904,6 +1904,7 @@ struct xhci_hcd { - #define XHCI_BROKEN_D3COLD BIT_ULL(41) +@@ -1905,6 +1905,7 @@ struct xhci_hcd { #define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42) #define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43) -+#define XHCI_AVOID_DQ_ON_LINK BIT_ULL(44) + #define XHCI_RESET_TO_DEFAULT BIT_ULL(44) ++#define XHCI_AVOID_DQ_ON_LINK BIT_ULL(45) unsigned int num_active_eps; unsigned int limit_active_eps; diff --git a/target/linux/bcm27xx/patches-5.15/950-0605-xhci-refactor-out-TRBS_PER_SEGMENT-define-in-runtime.patch b/target/linux/bcm27xx/patches-5.15/950-0605-xhci-refactor-out-TRBS_PER_SEGMENT-define-in-runtime.patch index 2b7435368a..f9907cc82a 100644 --- a/target/linux/bcm27xx/patches-5.15/950-0605-xhci-refactor-out-TRBS_PER_SEGMENT-define-in-runtime.patch +++ b/target/linux/bcm27xx/patches-5.15/950-0605-xhci-refactor-out-TRBS_PER_SEGMENT-define-in-runtime.patch @@ -145,7 +145,7 @@ Signed-off-by: Jonathan Bell if (ret) return -ENOMEM; -@@ -1816,7 +1820,7 @@ int xhci_alloc_erst(struct xhci_hcd *xhc +@@ -1820,7 +1824,7 @@ int xhci_alloc_erst(struct xhci_hcd *xhc for (val = 0; val < evt_ring->num_segs; val++) { entry = &erst->entries[val]; entry->seg_addr = cpu_to_le64(seg->dma); @@ -226,7 +226,7 @@ Signed-off-by: Jonathan Bell } --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c -@@ -870,8 +870,8 @@ static void xhci_clear_command_ring(stru +@@ -876,8 +876,8 @@ static void xhci_clear_command_ring(stru seg = ring->deq_seg; do { memset(seg->trbs, 0, @@ -237,7 +237,7 @@ Signed-off-by: Jonathan Bell cpu_to_le32(~TRB_CYCLE); seg = seg->next; } while (seg != ring->deq_seg); -@@ -882,7 +882,7 @@ static void xhci_clear_command_ring(stru +@@ -888,7 +888,7 @@ static void xhci_clear_command_ring(stru ring->enq_seg = ring->deq_seg; ring->enqueue = ring->dequeue; diff --git a/target/linux/bcm27xx/patches-5.15/950-0606-usb-xhci-add-VLI_TRB_CACHE_BUG-quirk.patch b/target/linux/bcm27xx/patches-5.15/950-0606-usb-xhci-add-VLI_TRB_CACHE_BUG-quirk.patch index 39ddab76e8..4d477eb4e1 100644 --- a/target/linux/bcm27xx/patches-5.15/950-0606-usb-xhci-add-VLI_TRB_CACHE_BUG-quirk.patch +++ b/target/linux/bcm27xx/patches-5.15/950-0606-usb-xhci-add-VLI_TRB_CACHE_BUG-quirk.patch @@ -53,7 +53,7 @@ Signed-off-by: Jonathan Bell cycle_state, type, max_packet, flags); --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c -@@ -305,6 +305,7 @@ static void xhci_pci_quirks(struct devic +@@ -292,6 +292,7 @@ static void xhci_pci_quirks(struct devic xhci->quirks |= XHCI_LPM_SUPPORT; xhci->quirks |= XHCI_EP_CTX_BROKEN_DCS; xhci->quirks |= XHCI_AVOID_DQ_ON_LINK; @@ -63,11 +63,11 @@ Signed-off-by: Jonathan Bell if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h -@@ -1906,6 +1906,7 @@ struct xhci_hcd { - #define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42) +@@ -1907,6 +1907,7 @@ struct xhci_hcd { #define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43) - #define XHCI_AVOID_DQ_ON_LINK BIT_ULL(44) -+#define XHCI_VLI_TRB_CACHE_BUG BIT_ULL(45) + #define XHCI_RESET_TO_DEFAULT BIT_ULL(44) + #define XHCI_AVOID_DQ_ON_LINK BIT_ULL(45) ++#define XHCI_VLI_TRB_CACHE_BUG BIT_ULL(46) unsigned int num_active_eps; unsigned int limit_active_eps; diff --git a/target/linux/bcm27xx/patches-5.15/950-0717-usb-xhci-add-a-quirk-for-Superspeed-bulk-OUT-transfe.patch b/target/linux/bcm27xx/patches-5.15/950-0717-usb-xhci-add-a-quirk-for-Superspeed-bulk-OUT-transfe.patch index ab68debd2f..372ec6f8e7 100644 --- a/target/linux/bcm27xx/patches-5.15/950-0717-usb-xhci-add-a-quirk-for-Superspeed-bulk-OUT-transfe.patch +++ b/target/linux/bcm27xx/patches-5.15/950-0717-usb-xhci-add-a-quirk-for-Superspeed-bulk-OUT-transfe.patch @@ -26,7 +26,7 @@ Signed-off-by: Jonathan Bell --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c -@@ -306,6 +306,7 @@ static void xhci_pci_quirks(struct devic +@@ -293,6 +293,7 @@ static void xhci_pci_quirks(struct devic xhci->quirks |= XHCI_EP_CTX_BROKEN_DCS; xhci->quirks |= XHCI_AVOID_DQ_ON_LINK; xhci->quirks |= XHCI_VLI_TRB_CACHE_BUG; @@ -86,11 +86,11 @@ Signed-off-by: Jonathan Bell first_trb = false; --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h -@@ -1907,6 +1907,7 @@ struct xhci_hcd { - #define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43) - #define XHCI_AVOID_DQ_ON_LINK BIT_ULL(44) - #define XHCI_VLI_TRB_CACHE_BUG BIT_ULL(45) -+#define XHCI_VLI_SS_BULK_OUT_BUG BIT_ULL(46) +@@ -1908,6 +1908,7 @@ struct xhci_hcd { + #define XHCI_RESET_TO_DEFAULT BIT_ULL(44) + #define XHCI_AVOID_DQ_ON_LINK BIT_ULL(45) + #define XHCI_VLI_TRB_CACHE_BUG BIT_ULL(46) ++#define XHCI_VLI_SS_BULK_OUT_BUG BIT_ULL(47) unsigned int num_active_eps; unsigned int limit_active_eps; diff --git a/target/linux/bcm27xx/patches-5.15/950-0914-mmc-block-Don-t-do-single-sector-reads-during-recove.patch b/target/linux/bcm27xx/patches-5.15/950-0914-mmc-block-Don-t-do-single-sector-reads-during-recove.patch index 7390813f30..5e491a6f5a 100644 --- a/target/linux/bcm27xx/patches-5.15/950-0914-mmc-block-Don-t-do-single-sector-reads-during-recove.patch +++ b/target/linux/bcm27xx/patches-5.15/950-0914-mmc-block-Don-t-do-single-sector-reads-during-recove.patch @@ -23,7 +23,7 @@ Signed-off-by: Jonathan Bell --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c -@@ -1875,7 +1875,11 @@ static void mmc_blk_mq_rw_recovery(struc +@@ -1883,7 +1883,11 @@ static void mmc_blk_mq_rw_recovery(struc return; } diff --git a/target/linux/bcm53xx/patches-5.15/180-usb-xhci-add-support-for-performing-fake-doorbell.patch b/target/linux/bcm53xx/patches-5.15/180-usb-xhci-add-support-for-performing-fake-doorbell.patch index 239c140c9b..69d70aefaf 100644 --- a/target/linux/bcm53xx/patches-5.15/180-usb-xhci-add-support-for-performing-fake-doorbell.patch +++ b/target/linux/bcm53xx/patches-5.15/180-usb-xhci-add-support-for-performing-fake-doorbell.patch @@ -127,11 +127,11 @@ it on BCM4708 family. /* --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h -@@ -1904,6 +1904,7 @@ struct xhci_hcd { - #define XHCI_BROKEN_D3COLD BIT_ULL(41) +@@ -1905,6 +1905,7 @@ struct xhci_hcd { #define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42) #define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43) -+#define XHCI_FAKE_DOORBELL BIT_ULL(44) + #define XHCI_RESET_TO_DEFAULT BIT_ULL(44) ++#define XHCI_FAKE_DOORBELL BIT_ULL(45) unsigned int num_active_eps; unsigned int limit_active_eps; diff --git a/target/linux/generic/pending-5.15/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch b/target/linux/generic/pending-5.15/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch index 09efa1e72f..2f6fbd59e4 100644 --- a/target/linux/generic/pending-5.15/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch +++ b/target/linux/generic/pending-5.15/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch @@ -338,7 +338,7 @@ Signed-off-by: Steven Barth if (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6)) return -1; -@@ -1525,6 +1686,14 @@ ip6_tnl_change(struct ip6_tnl *t, const +@@ -1526,6 +1687,14 @@ ip6_tnl_change(struct ip6_tnl *t, const t->parms.link = p->link; t->parms.proto = p->proto; t->parms.fwmark = p->fwmark; @@ -353,7 +353,7 @@ Signed-off-by: Steven Barth dst_cache_reset(&t->dst_cache); ip6_tnl_link_config(t); return 0; -@@ -1563,6 +1732,7 @@ ip6_tnl_parm_from_user(struct __ip6_tnl_ +@@ -1564,6 +1733,7 @@ ip6_tnl_parm_from_user(struct __ip6_tnl_ p->flowinfo = u->flowinfo; p->link = u->link; p->proto = u->proto; @@ -361,7 +361,7 @@ Signed-off-by: Steven Barth memcpy(p->name, u->name, sizeof(u->name)); } -@@ -1949,6 +2119,15 @@ static int ip6_tnl_validate(struct nlatt +@@ -1950,6 +2120,15 @@ static int ip6_tnl_validate(struct nlatt return 0; } @@ -377,7 +377,7 @@ Signed-off-by: Steven Barth static void ip6_tnl_netlink_parms(struct nlattr *data[], struct __ip6_tnl_parm *parms) { -@@ -1986,6 +2165,46 @@ static void ip6_tnl_netlink_parms(struct +@@ -1987,6 +2166,46 @@ static void ip6_tnl_netlink_parms(struct if (data[IFLA_IPTUN_FWMARK]) parms->fwmark = nla_get_u32(data[IFLA_IPTUN_FWMARK]); @@ -424,7 +424,7 @@ Signed-off-by: Steven Barth } static bool ip6_tnl_netlink_encap_parms(struct nlattr *data[], -@@ -2101,6 +2320,12 @@ static void ip6_tnl_dellink(struct net_d +@@ -2102,6 +2321,12 @@ static void ip6_tnl_dellink(struct net_d static size_t ip6_tnl_get_size(const struct net_device *dev) { @@ -437,7 +437,7 @@ Signed-off-by: Steven Barth return /* IFLA_IPTUN_LINK */ nla_total_size(4) + -@@ -2130,6 +2355,24 @@ static size_t ip6_tnl_get_size(const str +@@ -2131,6 +2356,24 @@ static size_t ip6_tnl_get_size(const str nla_total_size(0) + /* IFLA_IPTUN_FWMARK */ nla_total_size(4) + @@ -462,7 +462,7 @@ Signed-off-by: Steven Barth 0; } -@@ -2137,6 +2380,9 @@ static int ip6_tnl_fill_info(struct sk_b +@@ -2138,6 +2381,9 @@ static int ip6_tnl_fill_info(struct sk_b { struct ip6_tnl *tunnel = netdev_priv(dev); struct __ip6_tnl_parm *parm = &tunnel->parms; @@ -472,7 +472,7 @@ Signed-off-by: Steven Barth if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) || nla_put_in6_addr(skb, IFLA_IPTUN_LOCAL, &parm->laddr) || -@@ -2146,9 +2392,27 @@ static int ip6_tnl_fill_info(struct sk_b +@@ -2147,9 +2393,27 @@ static int ip6_tnl_fill_info(struct sk_b nla_put_be32(skb, IFLA_IPTUN_FLOWINFO, parm->flowinfo) || nla_put_u32(skb, IFLA_IPTUN_FLAGS, parm->flags) || nla_put_u8(skb, IFLA_IPTUN_PROTO, parm->proto) || @@ -501,7 +501,7 @@ Signed-off-by: Steven Barth if (nla_put_u16(skb, IFLA_IPTUN_ENCAP_TYPE, tunnel->encap.type) || nla_put_be16(skb, IFLA_IPTUN_ENCAP_SPORT, tunnel->encap.sport) || nla_put_be16(skb, IFLA_IPTUN_ENCAP_DPORT, tunnel->encap.dport) || -@@ -2188,6 +2452,7 @@ static const struct nla_policy ip6_tnl_p +@@ -2189,6 +2453,7 @@ static const struct nla_policy ip6_tnl_p [IFLA_IPTUN_ENCAP_DPORT] = { .type = NLA_U16 }, [IFLA_IPTUN_COLLECT_METADATA] = { .type = NLA_FLAG }, [IFLA_IPTUN_FWMARK] = { .type = NLA_U32 }, diff --git a/target/linux/lantiq/patches-5.15/0028-NET-lantiq-various-etop-fixes.patch b/target/linux/lantiq/patches-5.15/0028-NET-lantiq-various-etop-fixes.patch index eb47010fa0..e9f3ee473b 100644 --- a/target/linux/lantiq/patches-5.15/0028-NET-lantiq-various-etop-fixes.patch +++ b/target/linux/lantiq/patches-5.15/0028-NET-lantiq-various-etop-fixes.patch @@ -625,7 +625,7 @@ Signed-off-by: John Crispin return 0; } -@@ -457,16 +651,16 @@ ltq_etop_tx(struct sk_buff *skb, struct +@@ -457,15 +651,16 @@ ltq_etop_tx(struct sk_buff *skb, struct int queue = skb_get_queue_mapping(skb); struct netdev_queue *txq = netdev_get_tx_queue(dev, queue); struct ltq_etop_priv *priv = netdev_priv(dev); @@ -641,13 +641,12 @@ Signed-off-by: John Crispin len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len; - if ((desc->ctl & (LTQ_DMA_OWN | LTQ_DMA_C)) || ch->skb[ch->dma.desc]) { -- dev_kfree_skb_any(skb); + if ((desc->ctl & (LTQ_DMA_OWN | LTQ_DMA_C)) || + priv->txch.skb[priv->txch.dma.desc]) { netdev_err(dev, "tx ring full\n"); netif_tx_stop_queue(txq); return NETDEV_TX_BUSY; -@@ -474,7 +668,7 @@ ltq_etop_tx(struct sk_buff *skb, struct +@@ -473,7 +668,7 @@ ltq_etop_tx(struct sk_buff *skb, struct /* dma needs to start on a 16 byte aligned address */ byte_offset = CPHYSADDR(skb->data) % 16; @@ -656,7 +655,7 @@ Signed-off-by: John Crispin netif_trans_update(dev); -@@ -484,11 +678,11 @@ ltq_etop_tx(struct sk_buff *skb, struct +@@ -483,11 +678,11 @@ ltq_etop_tx(struct sk_buff *skb, struct wmb(); desc->ctl = LTQ_DMA_OWN | LTQ_DMA_SOP | LTQ_DMA_EOP | LTQ_DMA_TX_OFFSET(byte_offset) | (len & LTQ_DMA_SIZE_MASK); @@ -671,7 +670,7 @@ Signed-off-by: John Crispin netif_tx_stop_queue(txq); return NETDEV_TX_OK; -@@ -499,11 +693,14 @@ ltq_etop_change_mtu(struct net_device *d +@@ -498,11 +693,14 @@ ltq_etop_change_mtu(struct net_device *d { struct ltq_etop_priv *priv = netdev_priv(dev); unsigned long flags; @@ -687,7 +686,7 @@ Signed-off-by: John Crispin spin_unlock_irqrestore(&priv->lock, flags); return 0; -@@ -556,6 +753,9 @@ ltq_etop_init(struct net_device *dev) +@@ -555,6 +753,9 @@ ltq_etop_init(struct net_device *dev) if (err) goto err_hw; ltq_etop_change_mtu(dev, 1500); @@ -697,7 +696,7 @@ Signed-off-by: John Crispin memcpy(&mac, &priv->pldata->mac, sizeof(struct sockaddr)); if (!is_valid_ether_addr(mac.sa_data)) { -@@ -573,9 +773,10 @@ ltq_etop_init(struct net_device *dev) +@@ -572,9 +773,10 @@ ltq_etop_init(struct net_device *dev) dev->addr_assign_type = NET_ADDR_RANDOM; ltq_etop_set_multicast_list(dev); @@ -711,7 +710,7 @@ Signed-off-by: John Crispin return 0; err_netdev: -@@ -595,6 +796,9 @@ ltq_etop_tx_timeout(struct net_device *d +@@ -594,6 +796,9 @@ ltq_etop_tx_timeout(struct net_device *d err = ltq_etop_hw_init(dev); if (err) goto err_hw; @@ -721,7 +720,7 @@ Signed-off-by: John Crispin netif_trans_update(dev); netif_wake_queue(dev); return; -@@ -618,14 +822,18 @@ static const struct net_device_ops ltq_e +@@ -617,14 +822,18 @@ static const struct net_device_ops ltq_e .ndo_tx_timeout = ltq_etop_tx_timeout, }; @@ -744,7 +743,7 @@ Signed-off-by: John Crispin res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { -@@ -651,31 +859,62 @@ ltq_etop_probe(struct platform_device *p +@@ -650,31 +859,62 @@ ltq_etop_probe(struct platform_device *p goto err_out; } @@ -822,7 +821,7 @@ Signed-off-by: John Crispin err = register_netdev(dev); if (err) -@@ -704,31 +943,22 @@ ltq_etop_remove(struct platform_device * +@@ -703,31 +943,22 @@ ltq_etop_remove(struct platform_device * return 0; } diff --git a/target/linux/mediatek/patches-5.15/410-bt-mtk-serial-fix.patch b/target/linux/mediatek/patches-5.15/410-bt-mtk-serial-fix.patch index e61b3dd94c..69647e075a 100644 --- a/target/linux/mediatek/patches-5.15/410-bt-mtk-serial-fix.patch +++ b/target/linux/mediatek/patches-5.15/410-bt-mtk-serial-fix.patch @@ -19,7 +19,7 @@ }, [PORT_NPCM] = { .name = "Nuvoton 16550", -@@ -2748,6 +2748,11 @@ serial8250_do_set_termios(struct uart_po +@@ -2753,6 +2753,11 @@ serial8250_do_set_termios(struct uart_po unsigned long flags; unsigned int baud, quot, frac = 0; diff --git a/target/linux/ramips/patches-5.15/830-mmc-MIPS-ralink-add-sdhci-for-mt7620a-SoC.patch b/target/linux/ramips/patches-5.15/830-mmc-MIPS-ralink-add-sdhci-for-mt7620a-SoC.patch index 1992850d81..21538859a5 100644 --- a/target/linux/ramips/patches-5.15/830-mmc-MIPS-ralink-add-sdhci-for-mt7620a-SoC.patch +++ b/target/linux/ramips/patches-5.15/830-mmc-MIPS-ralink-add-sdhci-for-mt7620a-SoC.patch @@ -25,7 +25,7 @@ Signed-off-by: John Crispin --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig -@@ -1091,3 +1091,5 @@ config MMC_OWL +@@ -1092,3 +1092,5 @@ config MMC_OWL config MMC_SDHCI_EXTERNAL_DMA bool From 1ee635c561ec54db7d856aa1c9a25e31112fbac4 Mon Sep 17 00:00:00 2001 From: Luiz Angelo Daros de Luca Date: Thu, 3 Nov 2022 13:34:22 -0300 Subject: [PATCH 17/32] realtek: fix typo in debug message vid_end was mentioned twice. Signed-off-by: Luiz Angelo Daros de Luca --- target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index 6ef255db4b..239b02b6ee 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -1446,7 +1446,7 @@ static void rtl83xx_vlan_add(struct dsa_switch *ds, int port, struct rtl838x_switch_priv *priv = ds->priv; int v; - pr_debug("%s port %d, vid_end %d, vid_end %d, flags %x\n", __func__, + pr_debug("%s port %d, vid_begin %d, vid_end %d, flags %x\n", __func__, port, vlan->vid_begin, vlan->vid_end, vlan->flags); if (vlan->vid_begin > 4095 || vlan->vid_end > 4095) { @@ -1511,7 +1511,7 @@ static int rtl83xx_vlan_del(struct dsa_switch *ds, int port, int v; u16 pvid; - pr_debug("%s: port %d, vid_end %d, vid_end %d, flags %x\n", __func__, + pr_debug("%s: port %d, vid_begin %d, vid_end %d, flags %x\n", __func__, port, vlan->vid_begin, vlan->vid_end, vlan->flags); if (vlan->vid_begin > 4095 || vlan->vid_end > 4095) { From 1e028ac51e4d033cc1a8a06850ca8c6469206761 Mon Sep 17 00:00:00 2001 From: Martin Schiller Date: Wed, 2 Nov 2022 07:41:04 +0100 Subject: [PATCH 18/32] kernel: further cleanup of xfrm[4|6]_mode* In my commit da5c45f4d886 ("kernel: remove handling of xfrm[4|6]_mode_* modules") I missed a few default config options and description entries. Those should be gone as well. Fixes: da5c45f4d886 ("kernel: remove handling of xfrm[4|6]_mode_* modules") Signed-off-by: Martin Schiller --- package/kernel/linux/modules/netsupport.mk | 6 ------ target/linux/generic/config-5.10 | 4 ---- target/linux/generic/config-5.15 | 4 ---- 3 files changed, 14 deletions(-) diff --git a/package/kernel/linux/modules/netsupport.mk b/package/kernel/linux/modules/netsupport.mk index 0fc3b5cce3..a8c343f44b 100644 --- a/package/kernel/linux/modules/netsupport.mk +++ b/package/kernel/linux/modules/netsupport.mk @@ -238,9 +238,6 @@ define KernelPackage/ipsec4/description - ah4 - esp4 - ipcomp4 - - xfrm4_mode_beet - - xfrm4_mode_transport - - xfrm4_mode_tunnel - xfrm4_tunnel endef @@ -273,9 +270,6 @@ define KernelPackage/ipsec6/description - ah6 - esp6 - ipcomp6 - - xfrm6_mode_beet - - xfrm6_mode_transport - - xfrm6_mode_tunnel - xfrm6_tunnel endef diff --git a/target/linux/generic/config-5.10 b/target/linux/generic/config-5.10 index 4b2837de05..103fe6de15 100644 --- a/target/linux/generic/config-5.10 +++ b/target/linux/generic/config-5.10 @@ -2540,10 +2540,6 @@ CONFIG_INET=y # CONFIG_INET6_ESPINTCP is not set # CONFIG_INET6_IPCOMP is not set # CONFIG_INET6_TUNNEL is not set -# CONFIG_INET6_XFRM_MODE_BEET is not set -# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set -# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set -# CONFIG_INET6_XFRM_MODE_TUNNEL is not set # CONFIG_INET6_XFRM_TUNNEL is not set # CONFIG_INET_AH is not set # CONFIG_INET_DIAG is not set diff --git a/target/linux/generic/config-5.15 b/target/linux/generic/config-5.15 index 1e49471ae2..c36cba7053 100644 --- a/target/linux/generic/config-5.15 +++ b/target/linux/generic/config-5.15 @@ -2641,10 +2641,6 @@ CONFIG_INET=y # CONFIG_INET6_ESPINTCP is not set # CONFIG_INET6_IPCOMP is not set # CONFIG_INET6_TUNNEL is not set -# CONFIG_INET6_XFRM_MODE_BEET is not set -# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set -# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set -# CONFIG_INET6_XFRM_MODE_TUNNEL is not set # CONFIG_INET6_XFRM_TUNNEL is not set # CONFIG_INET_AH is not set # CONFIG_INET_DIAG is not set From 8623a449c2d9617cd802ca892d443f4efc116794 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Tue, 1 Nov 2022 00:36:37 +0100 Subject: [PATCH 19/32] valgrind: update to 3.20.0 Release Notes: https://valgrind.org/docs/manual/dist.news.html Signed-off-by: Nick Hainke --- package/devel/valgrind/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/devel/valgrind/Makefile b/package/devel/valgrind/Makefile index c179f2b39c..bbd01ce37d 100644 --- a/package/devel/valgrind/Makefile +++ b/package/devel/valgrind/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=valgrind -PKG_VERSION:=3.19.0 +PKG_VERSION:=3.20.0 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://sourceware.org/pub/valgrind/ -PKG_HASH:=dd5e34486f1a483ff7be7300cc16b4d6b24690987877c3278d797534d6738f02 +PKG_HASH:=8536c031dbe078d342f121fa881a9ecd205cb5a78e639005ad570011bdb9f3c6 PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=GPL-2.0+ From d75ed3726d994fd050730e9ab5923d6232913054 Mon Sep 17 00:00:00 2001 From: Pawel Dembicki Date: Mon, 24 Oct 2022 15:11:07 +0200 Subject: [PATCH 20/32] uboot-layerscape: adjust LS1012A-IOT config and env In a254279a6c30 LS1012A-IOT kernel image was switched to FIT. But u-boot config is lack of FIT and ext4 support. This patch enables it. It also fix envs, because for some reason this board need to use "loadaddr" variable in brackets. Fixes: #9894 Fixes: a254279a6c30 ("layerscape: Change to combined rootfs on sd images") Signed-off-by: Pawel Dembicki --- .../files/fsl_ls1021a-iot-sdboot-uEnv.txt | 2 +- ...djust-LS1021A-IOT-config-for-OpenWrt.patch | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 package/boot/uboot-layerscape/patches/0900-layerscape-adjust-LS1021A-IOT-config-for-OpenWrt.patch diff --git a/package/boot/uboot-layerscape/files/fsl_ls1021a-iot-sdboot-uEnv.txt b/package/boot/uboot-layerscape/files/fsl_ls1021a-iot-sdboot-uEnv.txt index 55620d6725..ae0d6a6f96 100644 --- a/package/boot/uboot-layerscape/files/fsl_ls1021a-iot-sdboot-uEnv.txt +++ b/package/boot/uboot-layerscape/files/fsl_ls1021a-iot-sdboot-uEnv.txt @@ -2,7 +2,7 @@ fdtaddr=0x8f000000 loadaddr=0x81000000 fdt_high=0x8fffffff initrd_high=0xffffffff -sd_boot=ext4load mmc 0:1 $loadaddr fitImage;bootm $loadaddr +sd_boot=ext4load mmc 0:1 ${loadaddr} fitImage;bootm ${loadaddr} bootargs=root=/dev/mmcblk0p2 rw rootwait rootfstype=squashfs,f2fs noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200 bootcmd=echo starting openwrt ...;run sd_boot bootdelay=3 diff --git a/package/boot/uboot-layerscape/patches/0900-layerscape-adjust-LS1021A-IOT-config-for-OpenWrt.patch b/package/boot/uboot-layerscape/patches/0900-layerscape-adjust-LS1021A-IOT-config-for-OpenWrt.patch new file mode 100644 index 0000000000..414f2541ac --- /dev/null +++ b/package/boot/uboot-layerscape/patches/0900-layerscape-adjust-LS1021A-IOT-config-for-OpenWrt.patch @@ -0,0 +1,45 @@ +From b382eeafe01df21da3518b2f1dd7d22ee114efb0 Mon Sep 17 00:00:00 2001 +From: Pawel Dembicki +Date: Mon, 24 Oct 2022 14:19:38 +0200 +Subject: [PATCH] layerscape: adjust LS1021A-IOT config for OpenWrt + +Two configs are required: + - FIT + - Ext4load + +Let's enable it. U-boot is now bigger than 512K. Let's enlarge it to +768K. Envs start at 1M, so it will fit. + +Signed-off-by: Pawel Dembicki +--- + configs/ls1021aiot_sdcard_defconfig | 3 +++ + include/configs/ls1021aiot.h | 4 ++-- + 2 files changed, 5 insertions(+), 2 deletions(-) + +--- a/configs/ls1021aiot_sdcard_defconfig ++++ b/configs/ls1021aiot_sdcard_defconfig +@@ -27,8 +27,11 @@ CONFIG_CMD_MII=y + # CONFIG_CMD_MDIO is not set + CONFIG_CMD_PING=y + CONFIG_CMD_EXT2=y ++CONFIG_CMD_EXT4=y + CONFIG_CMD_FAT=y + # CONFIG_SPL_EFI_PARTITION is not set ++CONFIG_FIT=y ++CONFIG_FIT_VERBOSE=y + CONFIG_OF_CONTROL=y + CONFIG_ENV_OVERWRITE=y + CONFIG_ENV_IS_IN_MMC=y +--- a/include/configs/ls1021aiot.h ++++ b/include/configs/ls1021aiot.h +@@ -78,8 +78,8 @@ + CONFIG_SYS_MONITOR_LEN) + #define CONFIG_SYS_SPL_MALLOC_SIZE 0x100000 + #define CONFIG_SPL_BSS_START_ADDR 0x80100000 +-#define CONFIG_SPL_BSS_MAX_SIZE 0x80000 +-#define CONFIG_SYS_MONITOR_LEN 0x80000 ++#define CONFIG_SPL_BSS_MAX_SIZE 0xc0000 ++#define CONFIG_SYS_MONITOR_LEN 0xc0000 + #endif + + #define CONFIG_SYS_DDR_SDRAM_BASE 0x80000000UL From eba0a8deb65de70b0d913f9ec8910640a79d0191 Mon Sep 17 00:00:00 2001 From: Shiji Yang Date: Sat, 5 Nov 2022 19:52:08 +0800 Subject: [PATCH 21/32] ramips: improve compatibility for Youku YK-L2 and YK-L1 series Add UIMAGE_NAME and UIMAGE_MAGIC to allow users to directly install initramfs-kernel.bin from the stock firmware Web UI. At the same time, this change makes it possible to boot OpenWrt with the official u-boot. Notice: Since the stock firmware is based on OpenWrt and the configuration will be retained by default during the upgrade process, so we must use initramfs-kernel.bin to do a initial installation. After the system restarts, install sysupgrade.bin and do not retain any configuration. Signed-off-by: Shiji Yang --- target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi | 3 ++- target/linux/ramips/dts/mt7621_youku_yk-l2.dts | 3 ++- target/linux/ramips/image/mt7620.mk | 4 ++++ target/linux/ramips/image/mt7621.mk | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi b/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi index d15d2c0f4b..210b0d7d19 100644 --- a/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi +++ b/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi @@ -86,8 +86,9 @@ }; firmware: partition@50000 { - compatible = "denx,uimage"; + compatible = "openwrt,uimage", "denx,uimage"; label = "firmware"; + openwrt,ih-magic = <0x12291000>; /* reg property is set based on flash size in DTS files */ }; }; diff --git a/target/linux/ramips/dts/mt7621_youku_yk-l2.dts b/target/linux/ramips/dts/mt7621_youku_yk-l2.dts index e588e047eb..5342b40507 100644 --- a/target/linux/ramips/dts/mt7621_youku_yk-l2.dts +++ b/target/linux/ramips/dts/mt7621_youku_yk-l2.dts @@ -95,8 +95,9 @@ }; partition@50000 { - compatible = "denx,uimage"; + compatible = "openwrt,uimage", "denx,uimage"; label = "firmware"; + openwrt,ih-magic = <0x12291000>; reg = <0x50000 0xfb0000>; }; }; diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk index f6ad162779..db6ac93b2a 100644 --- a/target/linux/ramips/image/mt7620.mk +++ b/target/linux/ramips/image/mt7620.mk @@ -1281,6 +1281,8 @@ define Device/youku_yk-l1 DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-sdhci-mt7620 \ kmod-usb-ledtrig-usbport SUPPORTED_DEVICES += youku-yk1 youku,yk1 + UIMAGE_MAGIC := 0x12291000 + UIMAGE_NAME := 400000000000000000000000 endef TARGET_DEVICES += youku_yk-l1 @@ -1291,6 +1293,8 @@ define Device/youku_yk-l1c DEVICE_MODEL := YK-L1c DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-sdhci-mt7620 \ kmod-usb-ledtrig-usbport + UIMAGE_MAGIC := 0x12291000 + UIMAGE_NAME := 400000000000000000000000 endef TARGET_DEVICES += youku_yk-l1c diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 3ef4cf4efb..360513115f 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -2251,6 +2251,8 @@ define Device/youku_yk-l2 DEVICE_MODEL := YK-L2 DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \ kmod-usb-ledtrig-usbport + UIMAGE_MAGIC := 0x12291000 + UIMAGE_NAME := 400000000000000000003000 endef TARGET_DEVICES += youku_yk-l2 From 7a504c151d26210addc66f029dacda13fb662bdd Mon Sep 17 00:00:00 2001 From: Shiji Yang Date: Sat, 5 Nov 2022 19:52:08 +0800 Subject: [PATCH 22/32] ramips: add support for Youku X2 Specifications: SOC: MT7620AN + MT7612EN RAM: 128 MiB DDR2 Flash: 16 MiB (Winbond W25Q28FVFG) WLAN: 2.4G + 5G LAN: LAN ports *2 WAN: WAN port *1 USB: USB2.0 *1 SD Card: MicroSD *1 Buttons: Reset *1 LEDs: ethernet *3, system, usb, wlan2g, wlan5g MAC Address: use address source label 54:36:9b:xx:xx:ac lan lan 54:36:9b:xx:xx:ac factory.0x0028 wan 54:36:9b:xx:xx:ad factory.0x002e wlan2g 54:36:9b:xx:xx:ae factory.0x0004 wlan5g 54:36:9b:xx:xx:af factory.0x8004 Installation: 1. Apply initramfs-kernel.bin in stock firmware Web UI. 2. Install sysupgrade.bin on OpenWrt and do not retain any configuration. Signed-off-by: Shiji Yang --- target/linux/ramips/dts/mt7620a_youku_x2.dts | 38 +++++++++++++++++++ .../linux/ramips/dts/mt7620a_youku_yk-l1.dtsi | 2 +- target/linux/ramips/image/mt7620.mk | 12 ++++++ .../mt7620/base-files/etc/board.d/02_network | 5 +++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 target/linux/ramips/dts/mt7620a_youku_x2.dts diff --git a/target/linux/ramips/dts/mt7620a_youku_x2.dts b/target/linux/ramips/dts/mt7620a_youku_x2.dts new file mode 100644 index 0000000000..ad9e252f65 --- /dev/null +++ b/target/linux/ramips/dts/mt7620a_youku_x2.dts @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7620a_youku_yk-l1.dtsi" + +/ { + compatible = "youku,x2", "ralink,mt7620a-soc"; + model = "Youku X2"; +}; + +ðernet { + mediatek,portmap = "wllll"; +}; + +&firmware { + reg = <0x50000 0xfb0000>; +}; + +&led_wlan { + linux,default-trigger = "phy1tpt"; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + + led { + led-sources = <2>; + led-active-low; + }; + }; +}; diff --git a/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi b/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi index 210b0d7d19..5af7b343d9 100644 --- a/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi +++ b/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi @@ -15,7 +15,7 @@ leds { compatible = "gpio-leds"; - wlan { + led_wlan: wlan { label = "blue:wlan"; gpios = <&gpio3 0 GPIO_ACTIVE_LOW>; linux,default-trigger = "phy0tpt"; diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk index db6ac93b2a..231f6ad47d 100644 --- a/target/linux/ramips/image/mt7620.mk +++ b/target/linux/ramips/image/mt7620.mk @@ -1273,6 +1273,18 @@ define Device/xiaomi_miwifi-mini endef TARGET_DEVICES += xiaomi_miwifi-mini +define Device/youku_x2 + SOC := mt7620a + IMAGE_SIZE := 16064k + DEVICE_VENDOR := Youku + DEVICE_MODEL := X2 + DEVICE_PACKAGES := kmod-mt76x2 kmod-usb2 kmod-usb-ohci \ + kmod-sdhci-mt7620 kmod-usb-ledtrig-usbport + UIMAGE_MAGIC := 0x12291000 + UIMAGE_NAME := 400000000000000000001000 +endef +TARGET_DEVICES += youku_x2 + define Device/youku_yk-l1 SOC := mt7620a IMAGE_SIZE := 32448k diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network index 79df102056..ac1cf5e62a 100644 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network @@ -237,6 +237,10 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "5:lan" "4:wan" "6@eth0" ;; + youku,x2) + ucidef_add_switch "switch0" \ + "1:lan:2" "4:lan:1" "0:wan" "6@eth0" + ;; youku,yk-l1|\ youku,yk-l1c) ucidef_add_switch "switch0" \ @@ -368,6 +372,7 @@ ramips_setup_macs() ohyeah,oy-0001|\ wavlink,wl-wn530hg4|\ wevo,air-duo|\ + youku,x2|\ youku,yk-l1|\ youku,yk-l1c) wan_mac=$(mtd_get_mac_binary factory 0x2e) From 53f2e438cb58a8f7b8d0d01f941aca9682be1e82 Mon Sep 17 00:00:00 2001 From: Alexander Horner Date: Mon, 26 Sep 2022 20:17:40 +0100 Subject: [PATCH 23/32] ramips: add support for Zbtlink ZBT-WG1602-V04 Description heavily based on commit 7e89421a7c3855d66a20350a5bf9ca4cc7a2caf9 by Sergey Ryazanov Details I cannot confirm have been removed Completed with great help from \x on IRC. Thanks, \x! Zbtlink ZBT-WG1602-V04 is a Wi-Fi router intendend for use with WWAN (UMTS/LTE/3G/4G) modems. The router board offers a couple of miniPCIe slots with USB and SIM only and another one which is a pure miniPCIe slot as well as five Gigabit Ethernet ports (4xLAN + WAN). Specification: * SoC: MT7621A * RAM: 256/512 MiB * Flash: 16/32 MiB * Eth: 10/100/1000 Mbps Ethernet x5 ports (4xLAN + WAN) * WLAN 2GHz: MT7603E (.11bgn, MIMO 2x2) * WLAN 5GHz: MT7662E (.11nac, MIMO 2x2) * WLAN Ants: detachable x2, shared by 2GHz & 5GHz radios * miniPCIe: 2x slots with USB&SIM + 1x slot with regular PCIe bus * WWAN Ants: detachable x4 * External storage: microSD (SDXC) slot * USB: 3.0 Type-A port * LED: 11 (5 per Eth phy, 3 SoC controlled, 2 WLAN 2/5 controlled, 1 power indicator) * Button: 1 (reset) * UART: console (115200 baud) * Power: DC jack (12 V / 2.5 A) Additional HW information: * SoC USB port 1 is shared by internal miniPCIe slot and external Type-A USB port, USB D+/D- lines are toggled between ports using a GPIO controlled DPDT switch. Installation: The kernel image can be installed directly onto the device via a browser to 192.168.1.1 using the built in firmware recovery Web UI available. It can be accessed by pushing the reset button in, applying power and holding the reset button for approximately 10 seconds. When the kernel image has been flashed, you can access LuCI and upload the sysupgrade as normal. Signed-off-by: Alexander Horner --- .../dts/mt7621_zbtlink_zbt-wg1602-v04-16m.dts | 10 + .../dts/mt7621_zbtlink_zbt-wg1602-v04-32m.dts | 10 + .../dts/mt7621_zbtlink_zbt-wg1602-v04.dtsi | 215 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 24 ++ 4 files changed, 259 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_zbtlink_zbt-wg1602-v04-16m.dts create mode 100644 target/linux/ramips/dts/mt7621_zbtlink_zbt-wg1602-v04-32m.dts create mode 100644 target/linux/ramips/dts/mt7621_zbtlink_zbt-wg1602-v04.dtsi diff --git a/target/linux/ramips/dts/mt7621_zbtlink_zbt-wg1602-v04-16m.dts b/target/linux/ramips/dts/mt7621_zbtlink_zbt-wg1602-v04-16m.dts new file mode 100644 index 0000000000..61bac03742 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_zbtlink_zbt-wg1602-v04-16m.dts @@ -0,0 +1,10 @@ +#include "mt7621_zbtlink_zbt-wg1602-v04.dtsi" + +/ { + compatible = "zbtlink,zbt-wg1602-v04-16m", "zbtlink,zbt-wg1602-v04", "mediatek,mt7621-soc"; + model = "Zbtlink ZBT-WG1602-V04 (16M)"; +}; + +&firmware { + reg = <0x50000 0xfb0000>; +}; diff --git a/target/linux/ramips/dts/mt7621_zbtlink_zbt-wg1602-v04-32m.dts b/target/linux/ramips/dts/mt7621_zbtlink_zbt-wg1602-v04-32m.dts new file mode 100644 index 0000000000..a3072c116b --- /dev/null +++ b/target/linux/ramips/dts/mt7621_zbtlink_zbt-wg1602-v04-32m.dts @@ -0,0 +1,10 @@ +#include "mt7621_zbtlink_zbt-wg1602-v04.dtsi" + +/ { + compatible = "zbtlink,zbt-wg1602-v04-32m", "zbtlink,zbt-wg1602-v04", "mediatek,mt7621-soc"; + model = "Zbtlink ZBT-WG1602-V04 (32M)"; +}; + +&firmware { + reg = <0x50000 0x1fb0000>; +}; diff --git a/target/linux/ramips/dts/mt7621_zbtlink_zbt-wg1602-v04.dtsi b/target/linux/ramips/dts/mt7621_zbtlink_zbt-wg1602-v04.dtsi new file mode 100644 index 0000000000..64492af4d8 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_zbtlink_zbt-wg1602-v04.dtsi @@ -0,0 +1,215 @@ +#include "mt7621.dtsi" + +#include +#include +#include + +/ { + compatible = "zbtlink,zbt-wg1602", "mediatek,mt7621-soc"; + + aliases { + led-boot = &led_sm; + led-failsafe = &led_sm; + led-running = &led_sm; + led-upgrade = &led_sm; + label-mac-device = &gmac0; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_sm: sm { + label = "green:sm"; + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + }; + + 4g1 { + label = "green:4g1"; + gpios = <&gpio 10 GPIO_ACTIVE_LOW>; + }; + + 4g2 { + label = "green:4g2"; + gpios = <&gpio 12 GPIO_ACTIVE_LOW>; + }; + }; + + watchdog { + compatible = "linux,wdt-gpio"; + gpios = <&gpio 3 GPIO_ACTIVE_HIGH>; + hw_algo = "toggle"; + /* hw_margin_ms is actually ~120s but driver limits it to 60s */ + hw_margin_ms = <60000>; + always-running; + }; + + gpio-export { + compatible = "gpio-export"; + #size-cells = <0>; + + 4g1-pwr { + gpio-export,name = "4g1-pwr"; + gpio-export,output = <1>; + gpios = <&gpio 8 GPIO_ACTIVE_HIGH>; + }; + + 4g2-pwr { + gpio-export,name = "4g2-pwr"; + gpio-export,output = <1>; + gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + }; + + ext-usb { + gpio-export,name = "ext-usb"; + gpio-export,output = <1>; + gpios = <&gpio 6 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&sdhci { + status = "okay"; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <10000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "u-boot-env"; + reg = <0x30000 0x10000>; + read-only; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + read-only; + }; + + firmware: partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + }; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi0: wifi@0,0 { + compatible = "pci14c3,7603"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0000>; + }; +}; + +&pcie1 { + wifi1: wifi@0,0 { + compatible = "pci14c3,7662"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + + led { + led-sources = <2>; + }; + }; +}; + +&gmac0 { + nvmem-cells = <&macaddr_factory_e000>; + nvmem-cell-names = "mac-address"; +}; + +&gmac1 { + status = "okay"; + label = "wan"; + phy-handle = <ðphy4>; + + nvmem-cells = <&macaddr_factory_e006>; + nvmem-cell-names = "mac-address"; +}; + +&mdio { + ethphy4: ethernet-phy@4 { + reg = <4>; + }; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "lan1"; + }; + + port@1 { + status = "okay"; + label = "lan2"; + }; + + port@2 { + status = "okay"; + label = "lan3"; + }; + + port@3 { + status = "okay"; + label = "lan4"; + }; + }; +}; + +&state_default { + gpio { + groups = "i2c", "uart2", "wdt"; + function = "gpio"; + }; +}; + +&factory { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_factory_e000: macaddr@e000 { + reg = <0xe000 0x6>; + }; + + macaddr_factory_e006: macaddr@e006 { + reg = <0xe006 0x6>; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 360513115f..a819abd968 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -2319,6 +2319,30 @@ define Device/zbtlink_zbt-wg1602-16m endef TARGET_DEVICES += zbtlink_zbt-wg1602-16m +define Device/zbtlink_zbt-wg1602-v04-16m + $(Device/dsa-migration) + $(Device/uimage-lzma-loader) + IMAGE_SIZE := 16064k + DEVICE_VENDOR := Zbtlink + DEVICE_MODEL := ZBT-WG1602-V04 + DEVICE_VARIANT := 16M + DEVICE_PACKAGES := kmod-sdhci-mt7620 kmod-mt7603 kmod-mt76x2 kmod-usb3 \ + kmod-usb-ledtrig-usbport +endef +TARGET_DEVICES += zbtlink_zbt-wg1602-v04-16m + +define Device/zbtlink_zbt-wg1602-v04-32m + $(Device/dsa-migration) + $(Device/uimage-lzma-loader) + IMAGE_SIZE := 32128k + DEVICE_VENDOR := Zbtlink + DEVICE_MODEL := ZBT-WG1602-V04 + DEVICE_VARIANT := 32M + DEVICE_PACKAGES := kmod-sdhci-mt7620 kmod-mt7603 kmod-mt76x2 kmod-usb3 \ + kmod-usb-ledtrig-usbport +endef +TARGET_DEVICES += zbtlink_zbt-wg1602-v04-32m + define Device/zbtlink_zbt-wg1608-16m $(Device/dsa-migration) $(Device/uimage-lzma-loader) From 002a99eccd75fb653163bae0a1132bd4f494e7ad Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 1 Nov 2022 15:17:03 +0100 Subject: [PATCH 24/32] dnsmasq: Backport DHCPv6 server fix (CVE-2022-0934) This backports a commit from upstream dnsmasq to fix CVE-2022-0934. CVE-2022-0934 description: A single-byte, non-arbitrary write/use-after-free flaw was found in dnsmasq. This flaw allows an attacker who sends a crafted packet processed by dnsmasq, potentially causing a denial of service. Signed-off-by: Hauke Mehrtens --- ...rite-after-free-error-in-DHCPv6-code.patch | 179 ++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 package/network/services/dnsmasq/patches/001-CVE-2022-0934-Fix-write-after-free-error-in-DHCPv6-code.patch diff --git a/package/network/services/dnsmasq/patches/001-CVE-2022-0934-Fix-write-after-free-error-in-DHCPv6-code.patch b/package/network/services/dnsmasq/patches/001-CVE-2022-0934-Fix-write-after-free-error-in-DHCPv6-code.patch new file mode 100644 index 0000000000..4113be99aa --- /dev/null +++ b/package/network/services/dnsmasq/patches/001-CVE-2022-0934-Fix-write-after-free-error-in-DHCPv6-code.patch @@ -0,0 +1,179 @@ +From 03345ecefeb0d82e3c3a4c28f27c3554f0611b39 Mon Sep 17 00:00:00 2001 +From: Simon Kelley +Date: Thu, 31 Mar 2022 21:35:20 +0100 +Subject: Fix write-after-free error in DHCPv6 code. CVE-2022-0934 refers. + +--- + CHANGELOG | 3 +++ + src/rfc3315.c | 48 +++++++++++++++++++++++++++--------------------- + 2 files changed, 30 insertions(+), 21 deletions(-) + +--- a/CHANGELOG ++++ b/CHANGELOG +@@ -92,6 +92,9 @@ version 2.86 + of filename). Thanks to Ed Wildgoose for the initial patch + and motivation for this. + ++ Fix write-after-free error in DHCPv6 server code. ++ CVE-2022-0934 refers. ++ + + version 2.85 + Fix problem with DNS retries in 2.83/2.84. +--- a/src/rfc3315.c ++++ b/src/rfc3315.c +@@ -33,9 +33,9 @@ struct state { + unsigned int mac_len, mac_type; + }; + +-static int dhcp6_maybe_relay(struct state *state, void *inbuff, size_t sz, ++static int dhcp6_maybe_relay(struct state *state, unsigned char *inbuff, size_t sz, + struct in6_addr *client_addr, int is_unicast, time_t now); +-static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_t sz, int is_unicast, time_t now); ++static int dhcp6_no_relay(struct state *state, int msg_type, unsigned char *inbuff, size_t sz, int is_unicast, time_t now); + static void log6_opts(int nest, unsigned int xid, void *start_opts, void *end_opts); + static void log6_packet(struct state *state, char *type, struct in6_addr *addr, char *string); + static void log6_quiet(struct state *state, char *type, struct in6_addr *addr, char *string); +@@ -104,12 +104,12 @@ unsigned short dhcp6_reply(struct dhcp_c + } + + /* This cost me blood to write, it will probably cost you blood to understand - srk. */ +-static int dhcp6_maybe_relay(struct state *state, void *inbuff, size_t sz, ++static int dhcp6_maybe_relay(struct state *state, unsigned char *inbuff, size_t sz, + struct in6_addr *client_addr, int is_unicast, time_t now) + { + void *end = inbuff + sz; + void *opts = inbuff + 34; +- int msg_type = *((unsigned char *)inbuff); ++ int msg_type = *inbuff; + unsigned char *outmsgtypep; + void *opt; + struct dhcp_vendor *vendor; +@@ -259,15 +259,15 @@ static int dhcp6_maybe_relay(struct stat + return 1; + } + +-static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_t sz, int is_unicast, time_t now) ++static int dhcp6_no_relay(struct state *state, int msg_type, unsigned char *inbuff, size_t sz, int is_unicast, time_t now) + { + void *opt; +- int i, o, o1, start_opts; ++ int i, o, o1, start_opts, start_msg; + struct dhcp_opt *opt_cfg; + struct dhcp_netid *tagif; + struct dhcp_config *config = NULL; + struct dhcp_netid known_id, iface_id, v6_id; +- unsigned char *outmsgtypep; ++ unsigned char outmsgtype; + struct dhcp_vendor *vendor; + struct dhcp_context *context_tmp; + struct dhcp_mac *mac_opt; +@@ -296,12 +296,13 @@ static int dhcp6_no_relay(struct state * + v6_id.next = state->tags; + state->tags = &v6_id; + +- /* copy over transaction-id, and save pointer to message type */ +- if (!(outmsgtypep = put_opt6(inbuff, 4))) ++ start_msg = save_counter(-1); ++ /* copy over transaction-id */ ++ if (!put_opt6(inbuff, 4)) + return 0; + start_opts = save_counter(-1); +- state->xid = outmsgtypep[3] | outmsgtypep[2] << 8 | outmsgtypep[1] << 16; +- ++ state->xid = inbuff[3] | inbuff[2] << 8 | inbuff[1] << 16; ++ + /* We're going to be linking tags from all context we use. + mark them as unused so we don't link one twice and break the list */ + for (context_tmp = state->context; context_tmp; context_tmp = context_tmp->current) +@@ -347,7 +348,7 @@ static int dhcp6_no_relay(struct state * + (msg_type == DHCP6REQUEST || msg_type == DHCP6RENEW || msg_type == DHCP6RELEASE || msg_type == DHCP6DECLINE)) + + { +- *outmsgtypep = DHCP6REPLY; ++ outmsgtype = DHCP6REPLY; + o1 = new_opt6(OPTION6_STATUS_CODE); + put_opt6_short(DHCP6USEMULTI); + put_opt6_string("Use multicast"); +@@ -619,11 +620,11 @@ static int dhcp6_no_relay(struct state * + struct dhcp_netid *solicit_tags; + struct dhcp_context *c; + +- *outmsgtypep = DHCP6ADVERTISE; ++ outmsgtype = DHCP6ADVERTISE; + + if (opt6_find(state->packet_options, state->end, OPTION6_RAPID_COMMIT, 0)) + { +- *outmsgtypep = DHCP6REPLY; ++ outmsgtype = DHCP6REPLY; + state->lease_allocate = 1; + o = new_opt6(OPTION6_RAPID_COMMIT); + end_opt6(o); +@@ -809,7 +810,7 @@ static int dhcp6_no_relay(struct state * + int start = save_counter(-1); + + /* set reply message type */ +- *outmsgtypep = DHCP6REPLY; ++ outmsgtype = DHCP6REPLY; + state->lease_allocate = 1; + + log6_quiet(state, "DHCPREQUEST", NULL, ignore ? _("ignored") : NULL); +@@ -924,7 +925,7 @@ static int dhcp6_no_relay(struct state * + int address_assigned = 0; + + /* set reply message type */ +- *outmsgtypep = DHCP6REPLY; ++ outmsgtype = DHCP6REPLY; + + log6_quiet(state, msg_type == DHCP6RENEW ? "DHCPRENEW" : "DHCPREBIND", NULL, NULL); + +@@ -1057,7 +1058,7 @@ static int dhcp6_no_relay(struct state * + int good_addr = 0; + + /* set reply message type */ +- *outmsgtypep = DHCP6REPLY; ++ outmsgtype = DHCP6REPLY; + + log6_quiet(state, "DHCPCONFIRM", NULL, NULL); + +@@ -1121,7 +1122,7 @@ static int dhcp6_no_relay(struct state * + log6_quiet(state, "DHCPINFORMATION-REQUEST", NULL, ignore ? _("ignored") : state->hostname); + if (ignore) + return 0; +- *outmsgtypep = DHCP6REPLY; ++ outmsgtype = DHCP6REPLY; + tagif = add_options(state, 1); + break; + } +@@ -1130,7 +1131,7 @@ static int dhcp6_no_relay(struct state * + case DHCP6RELEASE: + { + /* set reply message type */ +- *outmsgtypep = DHCP6REPLY; ++ outmsgtype = DHCP6REPLY; + + log6_quiet(state, "DHCPRELEASE", NULL, NULL); + +@@ -1195,7 +1196,7 @@ static int dhcp6_no_relay(struct state * + case DHCP6DECLINE: + { + /* set reply message type */ +- *outmsgtypep = DHCP6REPLY; ++ outmsgtype = DHCP6REPLY; + + log6_quiet(state, "DHCPDECLINE", NULL, NULL); + +@@ -1275,7 +1276,12 @@ static int dhcp6_no_relay(struct state * + } + + } +- ++ ++ /* Fill in the message type. Note that we store the offset, ++ not a direct pointer, since the packet memory may have been ++ reallocated. */ ++ ((unsigned char *)(daemon->outpacket.iov_base))[start_msg] = outmsgtype; ++ + log_tags(tagif, state->xid); + log6_opts(0, state->xid, daemon->outpacket.iov_base + start_opts, daemon->outpacket.iov_base + save_counter(-1)); + From 8b383ee2a0d21144258346ad39006fc499d04b4f Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 1 Nov 2022 15:23:17 +0100 Subject: [PATCH 25/32] busybox: awk: fix use after free (CVE-2022-30065) This backports a commit which fixes a use after free bug in awk. CVE-2022-30065 description: A use-after-free in Busybox 1.35-x's awk applet leads to denial of service and possibly code execution when processing a crafted awk pattern in the copyvar function. Signed-off-by: Hauke Mehrtens --- ...VE-2022-30065-awk-fix-use-after-free.patch | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 package/utils/busybox/patches/001-CVE-2022-30065-awk-fix-use-after-free.patch diff --git a/package/utils/busybox/patches/001-CVE-2022-30065-awk-fix-use-after-free.patch b/package/utils/busybox/patches/001-CVE-2022-30065-awk-fix-use-after-free.patch new file mode 100644 index 0000000000..7dcb9dff3f --- /dev/null +++ b/package/utils/busybox/patches/001-CVE-2022-30065-awk-fix-use-after-free.patch @@ -0,0 +1,42 @@ +From e63d7cdfdac78c6fd27e9e63150335767592b85e Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Fri, 17 Jun 2022 17:45:34 +0200 +Subject: awk: fix use after free (CVE-2022-30065) + +fixes https://bugs.busybox.net/show_bug.cgi?id=14781 + +function old new delta +evaluate 3343 3357 +14 + +Signed-off-by: Natanael Copa +Signed-off-by: Denys Vlasenko +--- + editors/awk.c | 3 +++ + testsuite/awk.tests | 6 ++++++ + 2 files changed, 9 insertions(+) + +--- a/editors/awk.c ++++ b/editors/awk.c +@@ -3114,6 +3114,9 @@ static var *evaluate(node *op, var *res) + + case XC( OC_MOVE ): + debug_printf_eval("MOVE\n"); ++ /* make sure that we never return a temp var */ ++ if (L.v == TMPVAR0) ++ L.v = res; + /* if source is a temporary string, jusk relink it to dest */ + if (R.v == TMPVAR1 + && !(R.v->type & VF_NUMBER) +--- a/testsuite/awk.tests ++++ b/testsuite/awk.tests +@@ -469,4 +469,10 @@ testing 'awk printf %% prints one %' \ + "%\n" \ + '' '' + ++testing 'awk assign while test' \ ++ "awk '\$1==\$1=\"foo\" {print \$1}'" \ ++ "foo\n" \ ++ "" \ ++ "foo" ++ + exit $FAILCOUNT From b3aa998f6c1a3297b6f2a2330c97c30b1ccf00d8 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 1 Nov 2022 23:14:58 +0100 Subject: [PATCH 26/32] ltq-ifxos: Fix compile with ltq-tapi Do not include asm/irq.h directly, but include linux/interrupt.h instead. This fixes the build of ltq-tapi with lantiq/xway. Signed-off-by: Hauke Mehrtens --- .../lantiq/ltq-ifxos/patches/002-fix-compile.patch | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/package/kernel/lantiq/ltq-ifxos/patches/002-fix-compile.patch b/package/kernel/lantiq/ltq-ifxos/patches/002-fix-compile.patch index 7d78c12685..be518698e0 100644 --- a/package/kernel/lantiq/ltq-ifxos/patches/002-fix-compile.patch +++ b/package/kernel/lantiq/ltq-ifxos/patches/002-fix-compile.patch @@ -20,3 +20,14 @@ #include "ifx_types.h" #include "ifxos_rt_if_check.h" +--- a/src/include/linux/ifxos_linux_interrupt.h ++++ b/src/include/linux/ifxos_linux_interrupt.h +@@ -31,7 +31,7 @@ + IFX Linux adaptation - Includes + ========================================================================= */ + #include "ifx_types.h" +-#include ++#include + + /* ============================================================================ + IFX Linux adaptation - supported features From 898b4104b3ddc6c5e327ffa00f2783ae407583a0 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 1 Nov 2022 23:18:08 +0100 Subject: [PATCH 27/32] ltq-tapi: Fix compile with kernel 5.15 Do not use find_vpid(), but get_task_pid() to get the pid from pThrCntrl->tid. This is now a ponter to struct task_struct instead of an integer. This fixes the build of ltq-tapi with lantiq/xway. Signed-off-by: Hauke Mehrtens --- .../lantiq/ltq-tapi/patches/510-linux-515.patch | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 package/kernel/lantiq/ltq-tapi/patches/510-linux-515.patch diff --git a/package/kernel/lantiq/ltq-tapi/patches/510-linux-515.patch b/package/kernel/lantiq/ltq-tapi/patches/510-linux-515.patch new file mode 100644 index 0000000000..ee20c6caf7 --- /dev/null +++ b/package/kernel/lantiq/ltq-tapi/patches/510-linux-515.patch @@ -0,0 +1,14 @@ +--- a/src/drv_tapi_linux.c ++++ b/src/drv_tapi_linux.c +@@ -3779,8 +3779,10 @@ IFX_void_t TAPI_OS_ThreadKill(IFXOS_Thre + mb(); + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) + kill_proc(pThrCntrl->tid, SIGKILL, 1); +-#else ++#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) + kill_pid(find_vpid(pThrCntrl->tid), SIGKILL, 1); ++#else ++ kill_pid(get_task_pid(pThrCntrl->tid, PIDTYPE_PID), SIGKILL, 1); + #endif + /* release the big kernel lock */ + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) From f7f9203854c7173a91655683aa7ad2a0af43f518 Mon Sep 17 00:00:00 2001 From: Shiji Yang Date: Fri, 16 Sep 2022 01:10:52 +0800 Subject: [PATCH 28/32] ramips: add support for SIM SIMAX1800T and Haier HAR-20S2U1 SIM AX18T and Haier HAR-20S2U1 Wi-Fi6 AX1800 routers are designed based on Tenbay WR1800K. They have the same hardware circuits and u-boot. SIM AX18T has three carrier customized models: SIMAX1800M (China Mobile), SIMAX1800T (China Telecom) and SIMAX1800U (China Unicom). All of these models run the same firmware. Specifications: SOC: MT7621 + MT7905 + MT7975 ROM: 128 MiB RAM: 256 MiB LED: status *3 R/G/B Button: reset *1 + wps/mesh *1 Ethernet: lan *3 + wan *1 (10/100/1000Mbps) TTL Baudrate: 115200 TFTP Server: 192.168.1.254 TFTP IP: 192.168.1.28 or 192.168.1.160 (when envs is broken) MAC Address: use address source label 30:xx:xx:xx:xx:62 wan lan 30:xx:xx:xx:xx:65 factory.0x8004 wan 30:xx:xx:xx:xx:62 factory.0x8004 -3 wlan2g 30:xx:xx:xx:xx:64 factory.0x0004 wlan5g 32:xx:xx:xx:xx:64 factory.0x0004 set 7th bit TFTP Installation (initramfs image only & recommend): 1. Set local tftp server IP: 192.168.1.254 and NetMask: 255.255.255.0 2. Rename initramfs-kernel.bin to "factory.bin" and put it in the root directory of the tftp server. (tftpd64 is a good choice for Windows) 3. Start the TFTP server, plug in the power supply, and wait for the system to boot. 4. Backup "firmware" partition and rename it to "firmware.bin", we need it to back to stock firmware. 5. Use "fw_printenv" command to list envs. If "firmware_select=2" is observed then set u-boot enviroment: /# fw_setenv firmware_select 1 6. Apply sysupgrade.bin in OpenWrt LuCI. Web UI Installation: 1. Apply update by uploading initramfs-factory.bin to the web UI. 2. Use "fw_printenv" command to list envs. If "firmware_select=2" is observed then set u-boot enviroment: /# fw_setenv firmware_select 1 3. Apply squashfs-sysupgrade.bin in OpenWrt LuCI. Recovery to stock firmware: a. Upload "firmware.bin" to OpenWrt /tmp, then execute: /# mtd -r write /tmp/firmware.bin firmware b. We can also write factory image "UploadBrush-bin.img" to firmware partition to recovery. Upload image file to /tmp, then execute: /# mtd erase firmware /# mtd -r write /tmp/UploadBrush-bin.img firmware How to extract stock firmware image: Download stock firmware, then use openssl: openssl aes-256-cbc -d -salt -in [Downloaded_Firmware] \ -out "firmware.tar.tgz" -k QiLunSmartWL Signed-off-by: Chen Minqiang Signed-off-by: Shiji Yang --- package/boot/uboot-envtools/files/ramips | 5 + .../ramips/dts/mt7621_haier-sim_wr1800k.dtsi | 186 ++++++++++++++++++ .../ramips/dts/mt7621_haier_har-20s2u1.dts | 8 + .../ramips/dts/mt7621_sim_simax1800t.dts | 8 + target/linux/ramips/image/mt7621.mk | 42 ++++ .../mt7621/base-files/etc/board.d/02_network | 2 + .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 10 +- .../mt7621/base-files/lib/upgrade/platform.sh | 2 + 8 files changed, 259 insertions(+), 4 deletions(-) create mode 100644 target/linux/ramips/dts/mt7621_haier-sim_wr1800k.dtsi create mode 100644 target/linux/ramips/dts/mt7621_haier_har-20s2u1.dts create mode 100644 target/linux/ramips/dts/mt7621_sim_simax1800t.dts diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index 194f6561d4..70d70dfed0 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -56,6 +56,11 @@ linksys,e7350|\ netgear,wax202) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" ;; +haier,har-20s2u1|\ +sim,simax1800t) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" + ubootenv_add_uci_sys_config "/dev/mtd1" "0x40000" "0x40000" "0x20000" + ;; hootoo,ht-tm05|\ ravpower,rp-wd03) idx="$(find_mtd_index u-boot-env)" diff --git a/target/linux/ramips/dts/mt7621_haier-sim_wr1800k.dtsi b/target/linux/ramips/dts/mt7621_haier-sim_wr1800k.dtsi new file mode 100644 index 0000000000..32d42fe813 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_haier-sim_wr1800k.dtsi @@ -0,0 +1,186 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include +#include + +/ { + aliases { + label-mac-device = &gmac1; + led-boot = &led_status_red; + led-failsafe = &led_status_blue; + led-running = &led_status_green; + led-upgrade = &led_status_blue; + }; + + chosen { + bootargs-override = "console=ttyS0,115200"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_status_blue: led-0 { + label = "blue:status"; + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&gpio 6 GPIO_ACTIVE_LOW>; + }; + + led_status_green: led-1 { + label = "green:status"; + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + }; + + led_status_red: led-2 { + label = "red:status"; + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&gpio 7 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&gmac0 { + nvmem-cells = <&macaddr_factory_8004>; + nvmem-cell-names = "mac-address"; +}; + +&gmac1 { + status = "okay"; + label = "wan"; + phy-handle = <ðphy4>; + + nvmem-cells = <&macaddr_factory_8004>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <(-3)>; +}; + +&mdio { + ethphy4: ethernet-phy@4 { + reg = <4>; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0000000 0x0080000>; + read-only; + }; + + partition@80000 { + label = "u-boot-env"; + reg = <0x0080000 0x0080000>; + }; + + factory: partition@100000 { + label = "factory"; + reg = <0x0100000 0x0080000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_factory_8004: macaddr@8004 { + reg = <0x8004 0x6>; + }; + }; + + partition@180000 { + label = "firmware"; + reg = <0x0180000 0x7a80000>; + + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "kernel"; + reg = <0x0000000 0x0400000>; + }; + + partition@400000 { + label = "ubi"; + reg = <0x0400000 0x7680000>; + }; + }; + + /* last 128KiB *32 is reserved for bad blocks management */ + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + mediatek,disable-radar-background; + }; +}; + +&pcie2 { + status = "disabled"; +}; + +&state_default { + gpio { + groups = "i2c", "uart3", "wdt"; + function = "gpio"; + }; +}; + +&switch0 { + ports { + port@1 { + status = "okay"; + label = "lan3"; + }; + + port@2 { + status = "okay"; + label = "lan2"; + }; + + port@3 { + status = "okay"; + label = "lan1"; + }; + }; +}; + +&xhci { + status = "disabled"; +}; diff --git a/target/linux/ramips/dts/mt7621_haier_har-20s2u1.dts b/target/linux/ramips/dts/mt7621_haier_har-20s2u1.dts new file mode 100644 index 0000000000..dede7dbb20 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_haier_har-20s2u1.dts @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_haier-sim_wr1800k.dtsi" + +/ { + compatible = "haier,har-20s2u1", "mediatek,mt7621-soc"; + model = "Haier HAR-20S2U1"; +}; diff --git a/target/linux/ramips/dts/mt7621_sim_simax1800t.dts b/target/linux/ramips/dts/mt7621_sim_simax1800t.dts new file mode 100644 index 0000000000..3c5c9179d2 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_sim_simax1800t.dts @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_haier-sim_wr1800k.dtsi" + +/ { + compatible = "sim,simax1800t", "mediatek,mt7621-soc"; + model = "SIM SIMAX1800T"; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index a819abd968..60f927eeed 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -37,6 +37,18 @@ define Build/h3c-blank-header mv $@.blank $@ endef +define Build/haier-sim_wr1800k-factory + -[ -e $(KDIR)/tmp/$(KERNEL_INITRAMFS_IMAGE) ] && \ + mkdir -p "$(1).tmp" && \ + $(CP) $(KDIR)/tmp/$(KERNEL_INITRAMFS_IMAGE) "$(1).tmp/UploadBrush-bin.img" && \ + $(MKHASH) md5 "$(1).tmp/UploadBrush-bin.img" | head -c32 > "$(1).tmp/check_MD5.txt" && \ + $(TAR) -czf $(1).tmp.tgz -C "$(1).tmp" UploadBrush-bin.img check_MD5.txt && \ + $(STAGING_DIR_HOST)/bin/openssl aes-256-cbc -e -salt -in $(1).tmp.tgz -out "$(1)" -k QiLunSmartWL && \ + printf %32s "$(DEVICE_MODEL)" >> "$(1)" && \ + rm -rf "$(1).tmp" $(1).tmp.tgz && \ + $(CP) $(1) $(BIN_DIR)/ +endef + define Build/iodata-factory $(eval fw_size=$(word 1,$(1))) $(eval fw_type=$(word 2,$(1))) @@ -869,6 +881,29 @@ define Device/h3c_tx1806 endef TARGET_DEVICES += h3c_tx1806 +define Device/haier-sim_wr1800k + $(Device/dsa-migration) + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL_SIZE := 4096k + IMAGE_SIZE := 125440k + UBINIZE_OPTS := -E 5 + KERNEL_LOADADDR := 0x82000000 + KERNEL := kernel-bin | relocate-kernel 0x80001000 | lzma | \ + fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb + KERNEL_INITRAMFS := $$(KERNEL) | \ + haier-sim_wr1800k-factory $(KDIR)/tmp/$$(KERNEL_INITRAMFS_PREFIX)-factory.bin + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + DEVICE_PACKAGES := kmod-mt7915e uboot-envtools +endef + +define Device/haier_har-20s2u1 + $(Device/haier-sim_wr1800k) + DEVICE_VENDOR := Haier + DEVICE_MODEL := HAR-20S2U1 +endef +TARGET_DEVICES += haier_har-20s2u1 + define Device/hilink_hlk-7621a-evb $(Device/dsa-migration) $(Device/uimage-lzma-loader) @@ -1729,6 +1764,13 @@ define Device/sercomm_na502s endef TARGET_DEVICES += sercomm_na502s +define Device/sim_simax1800t + $(Device/haier-sim_wr1800k) + DEVICE_VENDOR := SIM + DEVICE_MODEL := SIMAX1800T +endef +TARGET_DEVICES += sim_simax1800t + define Device/snr_snr-cpe-me2-lite $(Device/dsa-migration) $(Device/uimage-lzma-loader) diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index 39af3af219..14250aa150 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -35,8 +35,10 @@ ramips_setup_interfaces() h3c,tx1800-plus|\ h3c,tx1801-plus|\ h3c,tx1806|\ + haier,har-20s2u1|\ hiwifi,hc5962|\ netgear,wax202|\ + sim,simax1800t|\ xiaomi,mi-router-3-pro|\ xiaomi,mi-router-ac2100|\ xiaomi,mi-router-cr6606|\ diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index ff3ee281b2..69ecaefd27 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -45,6 +45,12 @@ case "$board" in [ "$PHYNBR" = "0" ] && echo -n ${addr:0:9}'1'${addr:10:7} > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "1" ] && echo -n ${addr:0:9}'7'${addr:10:7} > /sys${DEVPATH}/macaddress ;; + haier,har-20s2u1|\ + jcg,y2|\ + sim,simax1800t) + [ "$PHYNBR" = "1" ] && \ + macaddr_setbit_la "$(mtd_get_mac_binary factory 0x4)" > /sys${DEVPATH}/macaddress + ;; hiwifi,hc5962) label_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ") [ "$PHYNBR" = "0" ] && [ -n "$label_mac" ] && \ @@ -69,10 +75,6 @@ case "$board" in [ "$PHYNBR" = "1" ] && \ macaddr_setbit_la "$(mtd_get_mac_binary Factory 0x4)" > /sys${DEVPATH}/macaddress ;; - jcg,y2) - [ "$PHYNBR" = "1" ] && \ - macaddr_setbit_la "$(mtd_get_mac_binary factory 0x4)" > /sys${DEVPATH}/macaddress - ;; linksys,e5600|\ linksys,ea6350-v4|\ linksys,ea7300-v1|\ diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index 05907536fe..ebe4c638be 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -65,6 +65,7 @@ platform_do_upgrade() { h3c,tx1800-plus|\ h3c,tx1801-plus|\ h3c,tx1806|\ + haier,har-20s2u1|\ hiwifi,hc5962|\ iptime,a3004t|\ iptime,ax2004m|\ @@ -95,6 +96,7 @@ platform_do_upgrade() { raisecom,msg1500-x-00|\ sercomm,na502|\ sercomm,na502s|\ + sim,simax1800t|\ xiaomi,mi-router-3g|\ xiaomi,mi-router-3-pro|\ xiaomi,mi-router-4|\ From 78110c3b5fce119d13cd45dadd33ca396c8ce197 Mon Sep 17 00:00:00 2001 From: Linos Giannopoulos Date: Mon, 3 Oct 2022 01:30:28 +0300 Subject: [PATCH 29/32] ramips: add support for TP-Link MR600 V2(EU) MR600 V2(EU) is an LTE router that also supports 4G+ band aggregation etc. and can reportedly achieve higher bandwidth with it. - Specifications: * SoC: Mediatek MT7621DAT 880MHz * RAM: 128MB DDR3 * Flash: 16MB SPI NOR flash (GD25Q128C) * LTE Modem: Qualcomm MDM9240 * WiFi 5GHz: Mediatek MT7613BEN * WiFi 2.4GHz: Mediatek MT7603EN * Ethernet: MT7530, 4x 1000Base-T. * UART: Serial console (115200 8n1), J1(GND:3) * Buttons: Reset, WPS. * LED: Power, WAN, LTE, WiFi 2GHz and 5GHz, LAN, Signal1, Signal2, Signal3 - MAC Addresses: OEM firmware configuration: 54:af:97:xx:xx:7b : 2.4G 54:af:97:xx:xx:7a : 5G 54:af:97:xx:xx:7c : LTE 54:af:97:xx:xx:7b : LAN (label) 54:af:97:xx:xx:7c : WAN - Installation: 1. Download the OpenWrt initramfs-image. Place it into a TFTP server root directory and rename it to openwrt.img Configure the TFTP server to listen at 192.168.0.5/24. 3. Connect to the serial console. Attach power and interrupt the boot procedure when prompted (type `tpl`). Credentials are admin / 1234 4. Configure U-Boot for booting OpenWrt from ram $ tftpboot $ bootm 5. Transfer the OpenWrt sysupgrade image to the device. - LTE: In order to setup the wwan0 interface: 1. Add a `qmi` proto interface under `/etc/config/network`, e.g.: ``` config interface 'wwan0' option device '/dev/cdc-wdm0' option proto 'qmi' option pincode 'XXXX' option apn 'your_isp_apn' ``` 2. Add `wwan0` interface to the `wan` firewall zone 3. `/etc/init.d/network restart` Signed-off-by: Linos Giannopoulos --- .../ramips/dts/mt7621_tplink_mr600-v2-eu.dts | 207 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 15 ++ .../mt7621/base-files/etc/board.d/01_leds | 5 + .../mt7621/base-files/etc/board.d/02_network | 8 + 4 files changed, 235 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_tplink_mr600-v2-eu.dts diff --git a/target/linux/ramips/dts/mt7621_tplink_mr600-v2-eu.dts b/target/linux/ramips/dts/mt7621_tplink_mr600-v2-eu.dts new file mode 100644 index 0000000000..b7475ec15b --- /dev/null +++ b/target/linux/ramips/dts/mt7621_tplink_mr600-v2-eu.dts @@ -0,0 +1,207 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "mt7621.dtsi" + +#include +#include +#include + +/ { + compatible = "tplink,mr600-v2-eu", "mediatek,mt7621-soc"; + model = "TP-Link MR600 v2 (EU)"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + label-mac-device = &gmac0; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + }; + + keys { + compatible = "gpio-keys"; + + wlan { + label = "wlan"; + gpios = <&gpio 3 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset { + label = "reset"; + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_power: power { + label = "white:power"; + gpios = <&gpio 6 GPIO_ACTIVE_LOW>; + }; + wlan { + label = "white:wlan"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; + }; + wan { + label = "white:wan"; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + }; + + signal1 { + label = "white:signal1"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; + + signal2 { + label = "white:signal2"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + }; + + signal3 { + label = "white:signal3"; + gpios = <&gpio 10 GPIO_ACTIVE_LOW>; + }; + + 4g { + label = "white:4g"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + }; + lan { + label = "white:lan"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + }; + +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <80000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "uboot"; + reg = <0x00000 0x20000>; + read-only; + }; + + partition@20000 { + compatible = "openwrt,uimage"; + openwrt,offset = <512>; /* account for the 512-byte long header */ + label = "firmware"; + reg = <0x20000 0xfa0000>; + }; + + romfile: partition@fc0000 { + label = "romfile"; + reg = <0xfc0000 0x10000>; + read-only; + }; + + partition@fd0000 { + label = "config"; + reg = <0xfd0000 0x10000>; + read-only; + }; + + radio: partition@fe0000 { + label = "radio"; + reg = <0xfe0000 0x10000>; + read-only; + }; + }; + }; +}; + +&pcie { + status = "okay"; +}; + + +&pcie0 { + mt76@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + nvmem-cells = <&macaddr_romfile_f100>; + nvmem-cell-names = "mac-address"; + mediatek,mtd-eeprom = <&radio 0x0>; + mtd-mac-address = <&romfile 0xf100>; + ieee80211-freq-limit = <2400000 2500000>; + }; +}; + +&pcie1 { + mt76@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&radio 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + nvmem-cells = <&macaddr_romfile_f100>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <(-1)>; + }; +}; + +&gmac0 { + nvmem-cells = <&macaddr_romfile_f100>; + nvmem-cell-names = "mac-address"; +}; + +&gmac1 { + status = "okay"; + label = "wan"; + phy-handle = <ðphy4>; + + nvmem-cells = <&macaddr_romfile_f100>; + nvmem-cell-names = "mac-address"; +}; + +&mdio { + ethphy4: ethernet-phy@4 { + reg = <4>; + }; +}; + + +&switch0 { + ports { + port@1 { + status = "okay"; + label = "lan1"; + }; + port@2 { + status = "okay"; + label = "lan2"; + }; + port@3 { + status = "okay"; + label = "lan3"; + }; + }; +}; + +&romfile { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_romfile_f100: romfile@f100 { + reg = <0xf100 0x6>; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 60f927eeed..35817d0317 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -1910,6 +1910,21 @@ define Device/tplink_eap615-wall-v1 endef TARGET_DEVICES += tplink_eap615-wall-v1 +define Device/tplink_mr600-v2-eu + $(Device/dsa-migration) + $(Device/tplink-v2) + DEVICE_MODEL := MR600 + DEVICE_VARIANT := v2 (EU) + TPLINK_FLASHLAYOUT := 16Mltq + DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7663-firmware-ap \ + kmod-usb-net-qmi-wwan uqmi kmod-usb3 + KERNEL := $(KERNEL_DTB) | uImage lzma + KERNEL_INITRAMFS := $$(KERNEL) | tplink-v2-header + TPLINK_BOARD_ID := MR600-V2-EU + IMAGE_SIZE := 16384k +endef +TARGET_DEVICES += tplink_mr600-v2-eu + define Device/tplink_re350-v1 $(Device/dsa-migration) $(Device/tplink-safeloader) diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds index c2bc9c3774..9cf83c357c 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -147,6 +147,11 @@ tplink,re350-v1) ucidef_set_led_netdev "eth_act" "LAN act" "green:eth_act" "lan" "tx rx" ucidef_set_led_netdev "eth_link" "LAN link" "green:eth_link" "lan" "link" ;; +tplink,mr600-v2-eu) + ucidef_set_led_netdev "lan" "LAN" "white:lan" "br-lan" + ucidef_set_led_netdev "wan" "WAN" "white:wan" "wan" + ucidef_set_led_netdev "4g" "4G" "white:4g" "wwan0" + ;; tplink,re500-v1|\ tplink,re650-v1|\ tplink,re650-v2) diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index 14250aa150..bfc654a23a 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -100,6 +100,9 @@ ramips_setup_interfaces() tplink,tl-wpa8631p-v3) ucidef_set_interface_lan "lan1 lan2 lan3 plc0" ;; + tplink,mr600-v2-eu) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan" + ;; ubnt,edgerouter-x) ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4" "eth0" ;; @@ -216,6 +219,11 @@ ramips_setup_macs() wan_mac=$(mtd_get_mac_ascii Config wan_hwaddr) label_mac=$lan_mac ;; + tplink,mr600-v2-eu) + label_mac=$(cat "/sys/class/net/eth0/address") + wwan_mac=$(macaddr_add $label_mac 1) + ucidef_set_interface "wwan0" device "/dev/cdc-wdm0" protocol "qmi" macaddr "$wwan_mac" + ;; mikrotik,routerboard-750gr3|\ mikrotik,routerboard-760igs|\ mikrotik,routerboard-m11g|\ From 6645a019f88e2e6930fe63d1a51046a8e72445a0 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 2 Nov 2022 22:17:51 +0100 Subject: [PATCH 30/32] CI: packages.yml: Fix usage of pre-build tools Activate CONFIG_AUTOREMOVE to match the settings used to build the pre-build tools. This has to match the pre-build tools to not rebuild them. This prevents the tools being rebuild in packages.yml. Signed-off-by: Hauke Mehrtens --- .github/workflows/packages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index bf918fe562..49d795c122 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -112,6 +112,8 @@ jobs: echo CONFIG_ALL=y >> .config echo CONFIG_ALL_KMODS=y >> .config echo CONFIG_ALL_NONSHARED=y >> .config + echo CONFIG_DEVEL=y >> .config + echo CONFIG_AUTOREMOVE=y >> .config ./scripts/ext-toolchain.sh \ --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \ From 12cee869890853716ff1ee2dbd0a89c87a0ee544 Mon Sep 17 00:00:00 2001 From: Korey Caro Date: Sat, 12 Mar 2022 23:36:30 -0500 Subject: [PATCH 31/32] ath79: add support to TrendNet TEW-673GRU MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for the TrendNet TEW-673GRU to ath79. This device was supported in 19.07.9 but was deprecated with ar71xx. This is mostly a copy of D-Link DIR-825 B1. Updates have been completed to enable factory.bin and sysupgrade.bin both. Code improvements to DTS file and makefile. Architecture | MIPS Vendor | Qualcomm Atheros bootloader | U-Boot System-On-Chip | AR7161 rev 2 (MIPS 24Kc V7.4) CPU/Speed | 24Kc V7.4 680 MHz Flash-Chip | Macronix MX25L6405D Flash size | 8192 KiB RAM Chip: | ProMOS V58C2256164SCI5 × 2 RAM size | 64 MiB Wireless | 2 x Atheros AR922X 2.4GHz/5.0GHz 802.11abgn Ethernet | RealTek RTL8366S Gigabit w/ port based vlan support USB | Yes 2 x 2.0 Initial Flashing Process: 1) Download 22.03 tew-673gru factory bin 2) Flash 22.03 using TrendNet GUI OpenWRT Upgrade Process 3) Download 22.03 tew-673gru sysupgrade.bin 4) Flash 22.03 using OpenWRT GUI Signed-off-by: Korey Caro --- .../ath79/dts/ar7161_trendnet_tew-673gru.dts | 180 ++++++++++++++++++ .../generic/base-files/etc/board.d/02_network | 6 +- .../etc/hotplug.d/firmware/10-ath9k-eeprom | 6 +- target/linux/ath79/image/generic.mk | 16 ++ 4 files changed, 204 insertions(+), 4 deletions(-) create mode 100644 target/linux/ath79/dts/ar7161_trendnet_tew-673gru.dts diff --git a/target/linux/ath79/dts/ar7161_trendnet_tew-673gru.dts b/target/linux/ath79/dts/ar7161_trendnet_tew-673gru.dts new file mode 100644 index 0000000000..8657e291bd --- /dev/null +++ b/target/linux/ath79/dts/ar7161_trendnet_tew-673gru.dts @@ -0,0 +1,180 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "ar7100.dtsi" + +#include +#include + +/ { + compatible = "trendnet,tew-673gru", "qca,ar7161"; + model = "TRENDNET TEW-673GRU"; + + aliases { + led-boot = &led_wps; + led-failsafe = &led_wps; + led-running = &led_wps; + led-upgrade = &led_wps; + }; + + extosc: ref { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-output-names = "ref"; + clock-frequency = <40000000>; + }; + + leds { + compatible = "gpio-leds"; + + led_wps: wps { + label = "blue:wps"; + gpios = <&gpio 9 GPIO_ACTIVE_LOW>; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&gpio 3 GPIO_ACTIVE_LOW>; + }; + + wps { + label = "wps"; + linux,code = ; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + }; + }; + + rtl8366s { + compatible = "realtek,rtl8366s"; + gpio-sda = <&gpio 5 GPIO_ACTIVE_HIGH>; + gpio-sck = <&gpio 7 GPIO_ACTIVE_HIGH>; + realtek,initvals = <0x06 0x0108>; + + mdio-bus { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + phy4: ethernet-phy@4 { + reg = <4>; + phy-mode = "rgmii"; + }; + }; + }; + + virtual_flash { + compatible = "mtd-concat"; + devices = <&fwconcat0 &fwconcat1>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x0 0x0>; + }; + }; + }; +}; + +&usb1 { + status = "okay"; +}; + +&usb2 { + status = "okay"; +}; + +&usb_phy { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + + wifi@0,11 { + compatible = "pci168c,0029"; + reg = <0x8800 0 0 0 0>; + qca,no-eeprom; + }; + + wifi@0,12 { + compatible = "pci168c,0029"; + reg = <0x9000 0 0 0 0>; + qca,no-eeprom; + }; +}; + +&pll { + clocks = <&extosc>; +}; + +&spi { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <25000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x000000 0x040000>; + read-only; + }; + + partition@40000 { + label = "config"; + reg = <0x040000 0x010000>; + read-only; + }; + + fwconcat0: partition@50000 { + label = "fwconcat0"; + reg = <0x050000 0x610000>; + }; + + partition@660000 { + label = "caldata"; + reg = <0x660000 0x010000>; + read-only; + }; + + fwconcat1: partition@670000 { + label = "fwconcat1"; + reg = <0x670000 0x190000>; + }; + }; + }; +}; + +ð0 { + status = "okay"; + + pll-data = <0x11110000 0x00001099 0x00991099>; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +ð1 { + status = "okay"; + + pll-data = <0x11110000 0x00001099 0x00991099>; + + phy-handle = <&phy4>; +}; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network index 1d8beaaa25..e47f66c2f2 100644 --- a/target/linux/ath79/generic/base-files/etc/board.d/02_network +++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network @@ -195,7 +195,8 @@ ath79_setup_interfaces() ;; buffalo,wzr-hp-g300nh-rb|\ buffalo,wzr-hp-g300nh-s|\ - dlink,dir-825-b1) + dlink,dir-825-b1|\ + trendnet,tew-673gru) ucidef_set_interface_wan "eth1" ucidef_add_switch "switch0" \ "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0" @@ -605,7 +606,8 @@ ath79_setup_macs() dlink,dap-3662-a1) label_mac=$(mtd_get_mac_ascii bdcfg "wlanmac") ;; - dlink,dir-825-b1) + dlink,dir-825-b1|\ + trendnet,tew-673gru) lan_mac=$(mtd_get_mac_text "caldata" 0xffa0) wan_mac=$(mtd_get_mac_text "caldata" 0xffb4) label_mac=$wan_mac diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 04705aadf8..6dd237e1fa 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -160,7 +160,8 @@ case "$FIRMWARE" in netgear,wndap360) caldata_extract "art" 0x1000 0xeb8 ;; - dlink,dir-825-b1) + dlink,dir-825-b1|\ + trendnet,tew-673gru) caldata_extract "caldata" 0x1000 0xeb8 ath9k_patch_mac_crc $(mtd_get_mac_text "caldata" 0xffa0) 0x20c ;; @@ -179,7 +180,8 @@ case "$FIRMWARE" in netgear,wndap360) caldata_extract "art" 0x5000 0xeb8 ;; - dlink,dir-825-b1) + dlink,dir-825-b1|\ + trendnet,tew-673gru) caldata_extract "caldata" 0x5000 0xeb8 ath9k_patch_mac_crc $(macaddr_add $(mtd_get_mac_text "caldata" 0xffb4) 1) 0x20c ;; diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index 7b760abc3e..11c5669fe4 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -2554,6 +2554,22 @@ define Device/teltonika_rut955-h7v3c0 endef TARGET_DEVICES += teltonika_rut955-h7v3c0 +define Device/trendnet_tew-673gru + SOC := ar7161 + DEVICE_VENDOR := Trendnet + DEVICE_MODEL := TEW-673GRU + DEVICE_VARIANT := v1.0R + DEVICE_PACKAGES := -uboot-envtools kmod-usb-ohci kmod-usb2 \ + kmod-owl-loader kmod-switch-rtl8366s + IMAGE_SIZE := 7808k + FACTORY_SIZE := 6144k + IMAGES += factory.bin + IMAGE/factory.bin = append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | \ + pad-rootfs | check-size $$$$(FACTORY_SIZE) | pad-to $$$$(FACTORY_SIZE) | \ + append-string AP94-AR7161-RT-080619-01 +endef +TARGET_DEVICES += trendnet_tew-673gru + define Device/trendnet_tew-823dru SOC := qca9558 DEVICE_VENDOR := Trendnet From aca8bb5cc332f0ffdf4249e76b0a56716f98bef0 Mon Sep 17 00:00:00 2001 From: Alan Luck Date: Fri, 14 Oct 2022 17:26:27 +1100 Subject: [PATCH 32/32] ath79: expand rootfs for DIR-825-B1 with unused space Expand currently unused flash space to roofs for DIR-825-B1 by using the same flash space as the old ar71xx big image without moving the caldata. With some testing this partition is use by the OEM firmware but if changed is regenerated which allows reverting to OEM firmware Signed-off-by: Alan Luck --- .../ath79/dts/ar7161_dlink_dir-825-b1.dts | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/target/linux/ath79/dts/ar7161_dlink_dir-825-b1.dts b/target/linux/ath79/dts/ar7161_dlink_dir-825-b1.dts index 8188027c4c..b701f15421 100644 --- a/target/linux/ath79/dts/ar7161_dlink_dir-825-b1.dts +++ b/target/linux/ath79/dts/ar7161_dlink_dir-825-b1.dts @@ -109,6 +109,23 @@ }; }; }; + + virtual_flash { + compatible = "mtd-concat"; + devices = <&fwconcat0 &fwconcat1>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x0 0x0>; + }; + }; + }; }; &usb1 { @@ -186,9 +203,8 @@ read-only; }; - partition@50000 { - compatible = "denx,uimage"; - label = "firmware"; + fwconcat0: partition@50000 { + label = "fwconcat0"; reg = <0x050000 0x610000>; }; @@ -198,10 +214,9 @@ read-only; }; - partition@670000 { - label = "unknown"; + fwconcat1: partition@670000 { + label = "fwconcat1"; reg = <0x670000 0x190000>; - read-only; }; }; };