From 3ad547fe93fbaa1bced13b220c976d525d77349a Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 10 Aug 2024 13:43:29 +0200 Subject: [PATCH] add general 2024.07 patches to nanopi-r5c u-boot (#7056) --- ...eneral-btrfs-fix-out-of-bounds-write.patch | 43 ++++++++++++++ .../general-dw-hdmi-disable.patch | 53 ++++++++++++++++++ .../general-dwc-otg-usb-fix.patch | 56 +++++++++++++++++++ .../general-fix-inno-phy-macro.patch | 45 +++++++++++++++ 4 files changed, 197 insertions(+) create mode 100644 patch/u-boot/v2024.07/board_nanopi-r5c/general-btrfs-fix-out-of-bounds-write.patch create mode 100644 patch/u-boot/v2024.07/board_nanopi-r5c/general-dw-hdmi-disable.patch create mode 100644 patch/u-boot/v2024.07/board_nanopi-r5c/general-dwc-otg-usb-fix.patch create mode 100644 patch/u-boot/v2024.07/board_nanopi-r5c/general-fix-inno-phy-macro.patch diff --git a/patch/u-boot/v2024.07/board_nanopi-r5c/general-btrfs-fix-out-of-bounds-write.patch b/patch/u-boot/v2024.07/board_nanopi-r5c/general-btrfs-fix-out-of-bounds-write.patch new file mode 100644 index 000000000000..626a53c5602d --- /dev/null +++ b/patch/u-boot/v2024.07/board_nanopi-r5c/general-btrfs-fix-out-of-bounds-write.patch @@ -0,0 +1,43 @@ +From ee1941e4fec601a8444f49c7dad04ad700d501a6 Mon Sep 17 00:00:00 2001 +From: Alex Shumsky +Date: Wed, 19 Jun 2024 00:41:38 +0300 +Subject: [PATCH] fs: btrfs: fix out of bounds write + +Fix btrfs_read/read_and_truncate_page write out of bounds of destination +buffer. Old behavior break bootstd malloc'd buffers of exact file size. +Previously this OOB write have not been noticed because distroboot usually +read files into huge static memory areas. + +Signed-off-by: Alex Shumsky +Fixes: e342718 ("fs: btrfs: Implement btrfs_file_read()") +Reviewed-by: Qu Wenruo +--- + fs/btrfs/inode.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c +index 4691612eda33..3998ffc2c819 100644 +--- a/fs/btrfs/inode.c ++++ b/fs/btrfs/inode.c +@@ -640,7 +640,11 @@ static int read_and_truncate_page(struct btrfs_path *path, + extent_type = btrfs_file_extent_type(leaf, fi); + if (extent_type == BTRFS_FILE_EXTENT_INLINE) { + ret = btrfs_read_extent_inline(path, fi, buf); +- memcpy(dest, buf + page_off, min(page_len, ret)); ++ if (ret < 0) { ++ free(buf); ++ return ret; ++ } ++ memcpy(dest, buf + page_off, min3(page_len, ret, len)); + free(buf); + return len; + } +@@ -652,7 +656,7 @@ static int read_and_truncate_page(struct btrfs_path *path, + free(buf); + return ret; + } +- memcpy(dest, buf + page_off, page_len); ++ memcpy(dest, buf + page_off, min(page_len, len)); + free(buf); + return len; + } diff --git a/patch/u-boot/v2024.07/board_nanopi-r5c/general-dw-hdmi-disable.patch b/patch/u-boot/v2024.07/board_nanopi-r5c/general-dw-hdmi-disable.patch new file mode 100644 index 000000000000..acf5cadc9465 --- /dev/null +++ b/patch/u-boot/v2024.07/board_nanopi-r5c/general-dw-hdmi-disable.patch @@ -0,0 +1,53 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Paolo Sabatino +Date: Sun, 30 Jun 2024 17:36:02 +0200 +Subject: add dw_hdmi_disable() function to DW-HDMI driver + +--- + drivers/video/dw_hdmi.c | 17 ++++++++++ + include/dw_hdmi.h | 1 + + 2 files changed, 18 insertions(+) + +diff --git a/drivers/video/dw_hdmi.c b/drivers/video/dw_hdmi.c +index 111111111111..222222222222 100644 +--- a/drivers/video/dw_hdmi.c ++++ b/drivers/video/dw_hdmi.c +@@ -1025,6 +1025,23 @@ int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct display_timing *edid) + return 0; + } + ++int dw_hdmi_disable(struct dw_hdmi *hdmi) ++{ ++ uint clkdis; ++ ++ /* disable pixel clock and tmds data path */ ++ clkdis = 0x7f; ++ hdmi_write(hdmi, clkdis, HDMI_MC_CLKDIS); ++ ++ /* disable phy */ ++ hdmi_phy_sel_interface_control(hdmi, 0); ++ hdmi_phy_enable_tmds(hdmi, 0); ++ hdmi_phy_enable_power(hdmi, 0); ++ ++ return 0; ++ ++} ++ + static const struct dw_hdmi_phy_ops dw_hdmi_synopsys_phy_ops = { + .phy_set = dw_hdmi_phy_cfg, + }; +diff --git a/include/dw_hdmi.h b/include/dw_hdmi.h +index 111111111111..222222222222 100644 +--- a/include/dw_hdmi.h ++++ b/include/dw_hdmi.h +@@ -562,6 +562,7 @@ int dw_hdmi_phy_wait_for_hpd(struct dw_hdmi *hdmi); + void dw_hdmi_phy_init(struct dw_hdmi *hdmi); + + int dw_hdmi_enable(struct dw_hdmi *hdmi, const struct display_timing *edid); ++int dw_hdmi_disable(struct dw_hdmi *hdmi); + int dw_hdmi_read_edid(struct dw_hdmi *hdmi, u8 *buf, int buf_size); + void dw_hdmi_init(struct dw_hdmi *hdmi); + int dw_hdmi_detect_hpd(struct dw_hdmi *hdmi); +-- +Armbian + diff --git a/patch/u-boot/v2024.07/board_nanopi-r5c/general-dwc-otg-usb-fix.patch b/patch/u-boot/v2024.07/board_nanopi-r5c/general-dwc-otg-usb-fix.patch new file mode 100644 index 000000000000..46b59a2ce60d --- /dev/null +++ b/patch/u-boot/v2024.07/board_nanopi-r5c/general-dwc-otg-usb-fix.patch @@ -0,0 +1,56 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Paolo Sabatino +Date: Fri, 12 Mar 2021 20:20:12 +0000 +Subject: [ARCHEOLOGY] Changes and fixes to rk322x uboot and kernel config + +> X-Git-Archeology: > recovered message: > - Enabled nfc on rk322x-dev and disable on rk322x-current (need further development) +> X-Git-Archeology: > recovered message: > - Tidied up rk322x-current device tree +> X-Git-Archeology: > recovered message: > - enabled nfc rockchip driver enabled in rk322x-dev kernel config +> X-Git-Archeology: > recovered message: > - Enabled EHCI controller in u-boot (added patch for inno-phy, device tree and config bits), better device detection for dwc2 usb otg port +> X-Git-Archeology: > recovered message: > - Removed SPL_FIT_GENERATOR from u-boot configuration, fixed .its file to use binman +> X-Git-Archeology: > recovered message: > - fixed rk322x its file (now includes dtb), reverted u-boot to v2020.10 and changed dev_* into log_debug() calls +> X-Git-Archeology: - Revision 95425c27b9d3bbb96e7936cc531638c9150538f9: https://github.com/armbian/build/commit/95425c27b9d3bbb96e7936cc531638c9150538f9 +> X-Git-Archeology: Date: Fri, 12 Mar 2021 20:20:12 +0000 +> X-Git-Archeology: From: Paolo Sabatino +> X-Git-Archeology: Subject: Changes and fixes to rk322x uboot and kernel config +> X-Git-Archeology: +> X-Git-Archeology: - Revision 5130cc32fd9b18ecf71d5d26b688859ede0ffe03: https://github.com/armbian/build/commit/5130cc32fd9b18ecf71d5d26b688859ede0ffe03 +> X-Git-Archeology: Date: Mon, 20 Jun 2022 08:35:13 +0200 +> X-Git-Archeology: From: Paolo Sabatino +> X-Git-Archeology: Subject: rockchip64: fix u-boot USB OTG patch name +> X-Git-Archeology: +> X-Git-Archeology: - Revision d4daf41404853fc13813dc4eb9f6cad76f95945c: https://github.com/armbian/build/commit/d4daf41404853fc13813dc4eb9f6cad76f95945c +> X-Git-Archeology: Date: Mon, 20 Jun 2022 08:35:13 +0200 +> X-Git-Archeology: From: Paolo Sabatino +> X-Git-Archeology: Subject: rockchip64: add sdmmc_ext node, mmc reset properties and otg usb fix to u-boot +> X-Git-Archeology: +> X-Git-Archeology: - Revision efee17f217e58a93e795c165e303bfd0a2a0a32a: https://github.com/armbian/build/commit/efee17f217e58a93e795c165e303bfd0a2a0a32a +> X-Git-Archeology: Date: Mon, 22 Apr 2024 12:39:09 +0200 +> X-Git-Archeology: From: Paolo Sabatino +> X-Git-Archeology: Subject: rockchip64: bump rk3318-box uboot to v2024.01 +> X-Git-Archeology: +> X-Git-Archeology: - Revision 7876017d0b77bbfefbb3d112045b32d9b50db928: https://github.com/armbian/build/commit/7876017d0b77bbfefbb3d112045b32d9b50db928 +> X-Git-Archeology: Date: Tue, 02 Jul 2024 23:31:50 +0000 +> X-Git-Archeology: From: Paolo +> X-Git-Archeology: Subject: Bump rk322x-box and rk3318-box to u-boot v2024.07-rc5 (#6855) +> X-Git-Archeology: +--- + drivers/usb/host/dwc2.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c +index 111111111111..222222222222 100644 +--- a/drivers/usb/host/dwc2.c ++++ b/drivers/usb/host/dwc2.c +@@ -441,6 +441,8 @@ static void dwc_otg_core_init(struct udevice *dev) + + writel(usbcfg, ®s->gusbcfg); + ++ mdelay(10); ++ + /* Program the GAHBCFG Register. */ + switch (readl(®s->ghwcfg2) & DWC2_HWCFG2_ARCHITECTURE_MASK) { + case DWC2_HWCFG2_ARCHITECTURE_SLAVE_ONLY: +-- +Armbian + diff --git a/patch/u-boot/v2024.07/board_nanopi-r5c/general-fix-inno-phy-macro.patch b/patch/u-boot/v2024.07/board_nanopi-r5c/general-fix-inno-phy-macro.patch new file mode 100644 index 000000000000..ce360c97d256 --- /dev/null +++ b/patch/u-boot/v2024.07/board_nanopi-r5c/general-fix-inno-phy-macro.patch @@ -0,0 +1,45 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Paolo Sabatino +Date: Sun, 16 Jun 2024 18:07:03 +0200 +Subject: fix inno_poll macro + +--- + drivers/phy/rockchip/phy-rockchip-inno-hdmi.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/drivers/phy/rockchip/phy-rockchip-inno-hdmi.c b/drivers/phy/rockchip/phy-rockchip-inno-hdmi.c +index 111111111111..222222222222 100644 +--- a/drivers/phy/rockchip/phy-rockchip-inno-hdmi.c ++++ b/drivers/phy/rockchip/phy-rockchip-inno-hdmi.c +@@ -432,8 +432,8 @@ static inline void inno_update_bits(struct inno_hdmi_phy *inno, u8 reg, + inno_write(inno, reg, tmp); + } + +-#define inno_poll(reg, val, cond, sleep_us, timeout_us) \ +- readl_poll_sleep_timeout((reg) * 4, val, cond, sleep_us, timeout_us) ++#define inno_poll(inno, reg, val, cond, sleep_us, timeout_us) \ ++ readl_poll_sleep_timeout(inno->regs + (reg * 4), val, cond, sleep_us, timeout_us) + + static unsigned long inno_hdmi_phy_get_tmdsclk(struct inno_hdmi_phy *inno, + unsigned long rate) +@@ -575,7 +575,7 @@ inno_hdmi_phy_rk3328_clk_set_rate(struct phy *phy, + inno_update_bits(inno, 0xa0, RK3328_PRE_PLL_POWER_DOWN, 0); + + /* Wait for Pre-PLL lock */ +- ret = inno_poll(0xa9, val, val & RK3328_PRE_PLL_LOCK_STATUS, ++ ret = inno_poll(inno, 0xa9, val, val & RK3328_PRE_PLL_LOCK_STATUS, + 1000, 10000); + if (ret) { + dev_err(phy->dev, "Pre-PLL locking failed\n"); +@@ -674,7 +674,7 @@ inno_hdmi_phy_rk3328_power_on(struct phy *phy, + RK3328_TMDS_DRIVER_ENABLE); + + /* Wait for post PLL lock */ +- ret = inno_poll(0xaf, v, v & RK3328_POST_PLL_LOCK_STATUS, ++ ret = inno_poll(inno, 0xaf, v, v & RK3328_POST_PLL_LOCK_STATUS, + 1000, 10000); + if (ret) { + dev_err(phy->dev, "Post-PLL locking failed\n"); +-- +Armbian +