From 9f0588a1a9b3dc380141d65885dd5f0cee09b940 Mon Sep 17 00:00:00 2001 From: Love Kumar Date: Wed, 8 Nov 2023 12:40:31 +0530 Subject: test/py: net: Add a TFTP put test Execute tftpput command for uploading files to a server and validate its size & CRC32. Signed-off-by: Love Kumar Reviewed-by: Tom Rini --- test/py/tests/test_net.py | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py index b2241ae6a48..2495608786d 100644 --- a/test/py/tests/test_net.py +++ b/test/py/tests/test_net.py @@ -7,6 +7,7 @@ import pytest import u_boot_utils import uuid +import datetime """ Note: This test relies on boardenv_* containing configuration values to define @@ -51,6 +52,8 @@ env__net_tftp_readable_file = { 'addr': 0x10000000, 'size': 5058624, 'crc32': 'c2244b26', + 'timeout': 50000, + 'fnu': 'ubtest-upload.bin', } # Details regarding a file that may be read from a NFS server. This variable @@ -326,3 +329,71 @@ def test_net_pxe_get(u_boot_console): assert expected_text_default in output assert "Config file 'default.boot' found" in output + +@pytest.mark.buildconfigspec("cmd_crc32") +@pytest.mark.buildconfigspec("cmd_net") +@pytest.mark.buildconfigspec("cmd_tftpput") +def test_net_tftpput(u_boot_console): + """Test the tftpput command. + + A file is downloaded from the TFTP server and then uploaded to the TFTP + server, its size and its CRC32 are validated. + + The details of the file to download are provided by the boardenv_* file; + see the comment at the beginning of this file. + """ + + if not net_set_up: + pytest.skip("Network not initialized") + + f = u_boot_console.config.env.get("env__net_tftp_readable_file", None) + if not f: + pytest.skip("No TFTP readable file to read") + + addr = f.get("addr", None) + if not addr: + addr = u_boot_utils.find_ram_base(u_boot_console) + + sz = f.get("size", None) + timeout = f.get("timeout", u_boot_console.p.timeout) + fn = f["fn"] + fnu = f.get("fnu", "_".join([datetime.datetime.now().strftime("%y%m%d%H%M%S"), fn])) + expected_text = "Bytes transferred = " + if sz: + expected_text += "%d" % sz + + with u_boot_console.temporary_timeout(timeout): + output = u_boot_console.run_command("tftpboot %x %s" % (addr, fn)) + + assert "TIMEOUT" not in output + assert expected_text in output + + expected_tftpb_crc = f.get("crc32", None) + + output = u_boot_console.run_command("crc32 $fileaddr $filesize") + assert expected_tftpb_crc in output + + with u_boot_console.temporary_timeout(timeout): + output = u_boot_console.run_command( + "tftpput $fileaddr $filesize $serverip:%s" % (fnu) + ) + + expected_text = "Bytes transferred = " + if sz: + expected_text += "%d" % sz + addr = addr + sz + assert "TIMEOUT" not in output + assert "Access violation" not in output + assert expected_text in output + + with u_boot_console.temporary_timeout(timeout): + output = u_boot_console.run_command("tftpboot %x %s" % (addr, fnu)) + + expected_text = "Bytes transferred = " + if sz: + expected_text += "%d" % sz + assert "TIMEOUT" not in output + assert expected_text in output + + output = u_boot_console.run_command("crc32 $fileaddr $filesize") + assert expected_tftpb_crc in output -- cgit v1.3.1 From 891b178c579c0084c1759cf0319e7151a7e288a5 Mon Sep 17 00:00:00 2001 From: Francois Berder Date: Sun, 12 Nov 2023 20:16:50 +0100 Subject: lib/slre: Fix memory leak if regex compilation fails Signed-off-by: Francois Berder --- lib/slre.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/slre.c b/lib/slre.c index e82a9e7635b..e1a50443e04 100644 --- a/lib/slre.c +++ b/lib/slre.c @@ -686,6 +686,7 @@ int main(int argc, char *argv[]) } if (!slre_compile(&slre, argv[1])) { + (void) fclose(fp); fprintf(stderr, "Error compiling slre: %s\n", slre.err_str); return 1; } -- cgit v1.3.1 From d6d8078cb3604b60a579eb700ef8151d2b2b25fa Mon Sep 17 00:00:00 2001 From: Alex Bee Date: Tue, 14 Nov 2023 22:11:27 +0100 Subject: timer-uclass: Always use "clock-frequency" property as fallback Currently the "clock-frequency" DT property is only being considered as an fallback if either there is no clock driver, the clock driver implements the request-op correctly or there is no clock defined for the timer at all. This patch makes "clock-frequency" also being picked as a fallback if getting the clock-rate fails, since clk_get(_by_index) will return no error, if a clock driver does not implement the request-op and does also not support getting the rate of the clock in question. timer_post_probe will take care if the property does not exist in the DT or is defined as 0. Signed-off-by: Alex Bee --- drivers/timer/timer-uclass.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c index 0c2018bfe3b..60ff65529ab 100644 --- a/drivers/timer/timer-uclass.c +++ b/drivers/timer/timer-uclass.c @@ -66,13 +66,13 @@ static int timer_pre_probe(struct udevice *dev) err = clk_get_by_index(dev, 0, &timer_clk); if (!err) { ret = clk_get_rate(&timer_clk); - if (IS_ERR_VALUE(ret)) - return ret; - uc_priv->clock_rate = ret; - } else { - uc_priv->clock_rate = - dev_read_u32_default(dev, "clock-frequency", 0); + if (!IS_ERR_VALUE(ret)) { + uc_priv->clock_rate = ret; + return 0; + } } + + uc_priv->clock_rate = dev_read_u32_default(dev, "clock-frequency", 0); } return 0; -- cgit v1.3.1 From 654580eee13bc7a0d4ed4cad2b2fead1ec88107a Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Wed, 15 Nov 2023 10:53:45 +0900 Subject: xen: pvblock: fix the maximum io size in one operation The current implementation may cause BUG_ON() in blkfront_aio() BUG_ON(n > BLKIF_MAX_SEGMENTS_PER_REQUEST); In pvblock_iop(), a read/write operation will be split into smaller chunks of data so that the size in one access (aio_nbytes) is limited to, at the maximum, BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE But this works only if when the *buffer* passed in to pvblock_io() is page-aligned. If not, the given data region may stand across (BLKIF_MAX_SEGMENTS_PER_REQUEST + 1) pages. See the logic in blkfront_aio(): start = (uintptr_t)aiocbp->aio_buf & PAGE_MASK; end = ((uintptr_t)aiocbp->aio_buf + aiocbp->aio_nbytes + PAGE_SIZE - 1) & PAGE_MASK; Then this will lead to BUG_ON() above. This can be fixed by decreasing the maximum size of aio_nbytes. Signed-off-by: AKASHI Takahiro Fixes: commit 3a739cc6c948 ("xen: pvblock: Implement front-back protocol and do IO") --- drivers/xen/pvblock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/xen/pvblock.c b/drivers/xen/pvblock.c index 4ad548d599d..1df04e239ad 100644 --- a/drivers/xen/pvblock.c +++ b/drivers/xen/pvblock.c @@ -632,7 +632,8 @@ static ulong pvblock_iop(struct udevice *udev, lbaint_t blknr, memcpy(blk_dev->bounce_buffer, buffer, desc->blksz); aiocb.aio_nbytes = unaligned ? desc->blksz : - min((size_t)(BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE), + min((size_t)((BLKIF_MAX_SEGMENTS_PER_REQUEST - 1) + * PAGE_SIZE), (size_t)(blocks_todo * desc->blksz)); blkfront_io(&aiocb, write); -- cgit v1.3.1 From 4072572b0f8aeffedcd908dc45b7e046ee0554b0 Mon Sep 17 00:00:00 2001 From: Christophe Leroy Date: Wed, 15 Nov 2023 19:36:36 +0100 Subject: Fix stack-protector for powerpc On powerpc, stack protector expects a function called __stack_chk_fail_local() instead of __stack_chk_fail() And some versions of GCC for powerpc default to TLS canary instead of global canary, so always force GCC to use global canary with -mstack-protector-guard=global Cc: Joel Peshkin Fixes: 4e9bce12432 ("Add support for stack-protector") Signed-off-by: Christophe Leroy --- Makefile | 1 + common/stackprot.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Makefile b/Makefile index ffeb722c107..1b347f4dfd8 100644 --- a/Makefile +++ b/Makefile @@ -750,6 +750,7 @@ endif ifeq ($(CONFIG_STACKPROTECTOR),y) KBUILD_CFLAGS += $(call cc-option,-fstack-protector-strong) +KBUILD_CFLAGS += $(call cc-option,-mstack-protector-guard=global) CFLAGS_EFI += $(call cc-option,-fno-stack-protector) else KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector) diff --git a/common/stackprot.c b/common/stackprot.c index d5b70616655..6495951a773 100644 --- a/common/stackprot.c +++ b/common/stackprot.c @@ -18,3 +18,8 @@ void __stack_chk_fail(void) panic("Stack smashing detected in function:\n%p relocated from %p", ra, ra - gd->reloc_off); } + +void __stack_chk_fail_local(void) +{ + __stack_chk_fail(); +} -- cgit v1.3.1 From 83ad745cb9add78f33182d02dfcb0a0a723d8907 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Fri, 17 Nov 2023 16:38:27 -0600 Subject: configs: keystone2: Remove unused SPL_MALLOC_F_SIZE and KEYSTONE_SPL_STACK_SIZE These are leftover definitions. While here cleanup some leftover comments. Signed-off-by: Andrew Davis Reviewed-by: Simon Glass --- include/configs/ti_armv7_keystone2.h | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/include/configs/ti_armv7_keystone2.h b/include/configs/ti_armv7_keystone2.h index 72c04d8a994..637e9e4369e 100644 --- a/include/configs/ti_armv7_keystone2.h +++ b/include/configs/ti_armv7_keystone2.h @@ -9,23 +9,10 @@ #ifndef __CONFIG_KS2_EVM_H #define __CONFIG_KS2_EVM_H -/* U-Boot Build Configuration */ - -/* SoC Configuration */ - /* Memory Configuration */ #define CFG_SYS_LPAE_SDRAM_BASE 0x800000000 #define CFG_MAX_RAM_BANK_SIZE (2 << 30) /* 2GB */ -#ifdef CONFIG_SYS_MALLOC_F_LEN -#define SPL_MALLOC_F_SIZE CONFIG_SYS_MALLOC_F_LEN -#else -#define SPL_MALLOC_F_SIZE 0 -#endif - -/* SPL SPI Loader Configuration */ -#define KEYSTONE_SPL_STACK_SIZE (8 * 1024) - /* SRAM scratch space entries */ #define SRAM_SCRATCH_SPACE_ADDR 0xc0c23fc @@ -53,8 +40,6 @@ #define CFG_KSNET_SERDES_SGMII2_BASE KS2_SGMII_SERDES2_BASE #define CFG_KSNET_SERDES_LANES_PER_SGMII KS2_LANES_PER_SGMII_SERDES -/* EEPROM definitions */ - /* NAND Configuration */ #define CFG_SYS_NAND_MASK_CLE 0x4000 #define CFG_SYS_NAND_MASK_ALE 0x2000 @@ -63,13 +48,6 @@ #define CFG_SYS_NAND_LARGEPAGE #define CFG_SYS_NAND_BASE_LIST { 0x30000000, } - - -/* U-Boot general configuration */ - -/* EDMA3 */ - - /* Now for the remaining common defines */ #include -- cgit v1.3.1 From cef52c9cb2d0d1bcef32ec700e37e99a592bd175 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Fri, 17 Nov 2023 16:38:28 -0600 Subject: configs: keystone2: Do not include hardware.h This is a hacky way to have this file included in all source files that include common.h, instead just include from the files that need it. Signed-off-by: Andrew Davis --- drivers/memory/ti-aemif.c | 1 + drivers/soc/ti/keystone_serdes.c | 1 + include/configs/ti_armv7_keystone2.h | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/memory/ti-aemif.c b/drivers/memory/ti-aemif.c index c4bc88c1510..41325eb0f94 100644 --- a/drivers/memory/ti-aemif.c +++ b/drivers/memory/ti-aemif.c @@ -7,6 +7,7 @@ */ #include +#include #include #define AEMIF_WAITCYCLE_CONFIG (KS2_AEMIF_CNTRL_BASE + 0x4) diff --git a/drivers/soc/ti/keystone_serdes.c b/drivers/soc/ti/keystone_serdes.c index 2ece1a8f647..0e1bf8ff39d 100644 --- a/drivers/soc/ti/keystone_serdes.c +++ b/drivers/soc/ti/keystone_serdes.c @@ -8,6 +8,7 @@ #include #include +#include #include #include diff --git a/include/configs/ti_armv7_keystone2.h b/include/configs/ti_armv7_keystone2.h index 637e9e4369e..b36207cb5d1 100644 --- a/include/configs/ti_armv7_keystone2.h +++ b/include/configs/ti_armv7_keystone2.h @@ -52,7 +52,6 @@ #include /* we may include files below only after all above definitions */ -#include #include #ifndef CONFIG_SOC_K2G #define CFG_SYS_HZ_CLOCK ks_clk_get_rate(KS2_CLK1_6) -- cgit v1.3.1 From 53a230001263e6aca89e7a1322f2c7adbee4d55e Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Fri, 17 Nov 2023 16:38:29 -0600 Subject: ARM: keystone2: Remove unneeded inclusions of common.h Signed-off-by: Andrew Davis Reviewed-by: Simon Glass --- arch/arm/mach-keystone/clock.c | 1 - arch/arm/mach-keystone/cmd_clock.c | 2 +- arch/arm/mach-keystone/cmd_mon.c | 1 - arch/arm/mach-keystone/cmd_poweroff.c | 1 - arch/arm/mach-keystone/ddr3.c | 2 +- arch/arm/mach-keystone/ddr3_spd.c | 2 +- arch/arm/mach-keystone/init.c | 1 - arch/arm/mach-keystone/keystone.c | 1 - arch/arm/mach-keystone/mon.c | 1 - arch/arm/mach-keystone/msmc.c | 1 - arch/arm/mach-keystone/psc.c | 1 - 11 files changed, 3 insertions(+), 11 deletions(-) diff --git a/arch/arm/mach-keystone/clock.c b/arch/arm/mach-keystone/clock.c index 0c59515d2eb..4f193794efb 100644 --- a/arch/arm/mach-keystone/clock.c +++ b/arch/arm/mach-keystone/clock.c @@ -6,7 +6,6 @@ * Texas Instruments Incorporated, */ -#include #include #include #include diff --git a/arch/arm/mach-keystone/cmd_clock.c b/arch/arm/mach-keystone/cmd_clock.c index 72dc394df5f..e9ecc05953a 100644 --- a/arch/arm/mach-keystone/cmd_clock.c +++ b/arch/arm/mach-keystone/cmd_clock.c @@ -6,7 +6,7 @@ * Texas Instruments Incorporated, */ -#include +#include #include #include #include diff --git a/arch/arm/mach-keystone/cmd_mon.c b/arch/arm/mach-keystone/cmd_mon.c index dc97bac8550..c6e7e2c3097 100644 --- a/arch/arm/mach-keystone/cmd_mon.c +++ b/arch/arm/mach-keystone/cmd_mon.c @@ -6,7 +6,6 @@ * Texas Instruments Incorporated, */ -#include #include #include #include diff --git a/arch/arm/mach-keystone/cmd_poweroff.c b/arch/arm/mach-keystone/cmd_poweroff.c index f0ad9173b96..0ad31ef4e28 100644 --- a/arch/arm/mach-keystone/cmd_poweroff.c +++ b/arch/arm/mach-keystone/cmd_poweroff.c @@ -6,7 +6,6 @@ * Texas Instruments Incorporated, */ -#include #include #include #include diff --git a/arch/arm/mach-keystone/ddr3.c b/arch/arm/mach-keystone/ddr3.c index ea7d0b903cf..ca0fb702d54 100644 --- a/arch/arm/mach-keystone/ddr3.c +++ b/arch/arm/mach-keystone/ddr3.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/mach-keystone/ddr3_spd.c b/arch/arm/mach-keystone/ddr3_spd.c index 6f7f8ab7b40..d4ff442175b 100644 --- a/arch/arm/mach-keystone/ddr3_spd.c +++ b/arch/arm/mach-keystone/ddr3_spd.c @@ -5,8 +5,8 @@ * (C) Copyright 2015-2016 Texas Instruments Incorporated, */ -#include #include +#include #include #include diff --git a/arch/arm/mach-keystone/init.c b/arch/arm/mach-keystone/init.c index 1954e69e9f0..39afaaa63d6 100644 --- a/arch/arm/mach-keystone/init.c +++ b/arch/arm/mach-keystone/init.c @@ -6,7 +6,6 @@ * Texas Instruments Incorporated, */ -#include #include #include #include diff --git a/arch/arm/mach-keystone/keystone.c b/arch/arm/mach-keystone/keystone.c index efaabca5a7e..8846df3af48 100644 --- a/arch/arm/mach-keystone/keystone.c +++ b/arch/arm/mach-keystone/keystone.c @@ -6,7 +6,6 @@ * Texas Instruments Incorporated, */ -#include #include #include #include diff --git a/arch/arm/mach-keystone/mon.c b/arch/arm/mach-keystone/mon.c index e91b0d68f4d..b945e19ec77 100644 --- a/arch/arm/mach-keystone/mon.c +++ b/arch/arm/mach-keystone/mon.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/arch/arm/mach-keystone/msmc.c b/arch/arm/mach-keystone/msmc.c index f5cadfbf669..a20e0c98865 100644 --- a/arch/arm/mach-keystone/msmc.c +++ b/arch/arm/mach-keystone/msmc.c @@ -6,7 +6,6 @@ * Texas Instruments Incorporated, */ -#include #include struct mpax { diff --git a/arch/arm/mach-keystone/psc.c b/arch/arm/mach-keystone/psc.c index 145aff8ac66..84d64f3bc40 100644 --- a/arch/arm/mach-keystone/psc.c +++ b/arch/arm/mach-keystone/psc.c @@ -6,7 +6,6 @@ * Texas Instruments Incorporated, */ -#include #include #include #include -- cgit v1.3.1