From patchwork Wed Jul 24 06:01:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 814125 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2617433wro; Tue, 23 Jul 2024 23:03:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWHjTI3Arhcdi7WnOKEMB+pTvI77NDN0PS7qCdy9ju39j29/dxN8Eo+EZQ0CArX9moMfiLGSH6sF2JJWoe4wyps X-Google-Smtp-Source: AGHT+IEE2mFYtFHahIiQ43EpyLYdqjuq0HVcDR/i9xrNMmWIIZh6VP+Tv/gUZWQR0iYUnyX/9up3 X-Received: by 2002:a05:6000:4011:b0:368:7f4f:9e95 with SMTP id ffacd0b85a97d-369f5a6e507mr716404f8f.10.1721800996259; Tue, 23 Jul 2024 23:03:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721800996; cv=none; d=google.com; s=arc-20160816; b=uOtaw7O/QbXX9gpPDhr8iMHbJjuF6cMZvqSm/c6ddiyNLol8EvN47LWSziAZ1Cb+dF XO5/bulCAJZ12pPgC25+Wf6rkw1sVnP3RMirSFhcekmRcv7wWLxRrQkliHWZuVAxAlgR pDAaMtzotOGtH1dgVacY/5B0TWHRkxXn2XLVvN97fgRC2pVRHRw88w7sv9Cer2pQjpRi 1+OmPL5K8rIM/pbcP4FmgfFqe4kA7a/DQVhR6cMGFO4lw/YjQVWSRQJEWN4yWADC6OGc 93rM2uhIJvgkcJYod1V9If5OuTJMtYhL6mjtH8BXjUDGEVV0hSYlw0+KpMS0guhqbQ9C PZ/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=aqJxDDav3qOOhodC98XAU46PXzvMTB4lmxcN2sozllo=; fh=G2Nx6qmC1+Ay1LUfC62cUoso8wjIgHRVpc+UEIULvec=; b=zVxH2VxF6sHuYCBm/u318MvQ5r7Q2F2jYWeHtEtK7bbVUVTHRH03/LbvOot9BuWFIu 1DiALtqzj6HOPL11T1mOe2B1g/t+TqtXdlvQaAtOjV6WkwPgUFdfHgGtFZnpAb+tQz2/ nJkgMGZ+eThONmLZDHTfH9Uc6+H7svuV5Qro/1wTK7bozkRlPMMHB99IyEMW0teTbQYk U8gvs/ELoMyrkynS57uT/hYOU+73Hildt+lzF2FHVXdDkfcMexoDcEmO8YQOPyeam74F Gzyb0OkRS0VEaRrxKfF961LKx3zto/NTi3fel30KhZld7t5OT4uvncqizYE2h8UqkgqC xZhw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id ffacd0b85a97d-369e365dd28si1388881f8f.207.2024.07.23.23.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 23:03:16 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E4DAD88853; Wed, 24 Jul 2024 08:02:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 3EB2788845; Wed, 24 Jul 2024 08:02:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 7BCF3887FA for ; Wed, 24 Jul 2024 08:02:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3CFE3106F; Tue, 23 Jul 2024 23:03:08 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 636683F766; Tue, 23 Jul 2024 23:02:38 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Marek Vasut , Mark Kettenis , Michal Simek , Patrick DELAUNAY , Patrice CHOTARD , Huan Wang , Angelo Dureghello , Daniel Schwierzeck , Thomas Chou , Rick Chen , Max Filippov Subject: [PATCH 00/40] Make LMB memory map global and persistent Date: Wed, 24 Jul 2024 11:31:44 +0530 Message-Id: <20240724060224.3071065-1-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This is a follow-up from an earlier RFC series [1] for making the LMB and EFI memory allocations work together. This is a non-rfc version with only the LMB part of the patches, for making the LMB memory map global and persistent. This is part one of a set of patches which aim to have the LMB and EFI memory allocations work together. This requires making the LMB memory map global and persistent, instead of having local, caller specific maps. This is being done keeping in mind the usage of LMB memory by platforms where the same memory region can be used to load multiple different images. What is not allowed is to overwrite memory that has been allocated by the other module, currently the EFI memory module. This is being achieved by introducing a new flag, LMB_NOOVERWRITE, which represents memory which cannot be re-requested once allocated. The data structures (alloced lists) required for maintaining the LMB map are initialised during board init. The LMB module is enabled by default for the main U-Boot image, while it needs to be enabled for SPL. The allocation API's have been tweaked to introduce a flag argument, which will pass any flags that might be associated with a lmb memory region. This is being done to avoid having a separate set of API's for the EFI memory module, thus saving on space. The tests have been tweaked where needed because of these changes. The second part of the patches, to be sent subsequently, would work on having the EFI allocations work with the LMB API's. [1] - https://lore.kernel.org/u-boot/20240704073544.670249-1-sughosh.ganu@linaro.org/T/#t Changes since rfc: * Squash patches 9 - 11, 13 from the rfc v2 series into a single patch to make it bisectable. * Add a function comment for lmb_add_region_flags(). * Change the wording of a comment in lmb_merge_overlap_regions() as per review comment from Simon Glass. * Replace conditional compilation of lmb code to an if (CONFIG_IS_ENABLED()) in store_block() and tftp_init_load_addr(). * Add a function for reserving common areas in SPL, lmb_reserve_common_spl() * Enable SPL config for sandbox_noinst * Change the lmb_mem_regions_init() function to have it called from the lmb tests as well. Simon Glass (4): malloc: Support testing with realloc() lib: Handle a special case with str_to_list() alist: Add support for an allocated pointer list lib: Convert str_to_list() to use alist Sughosh Ganu (36): spl: alloc: call full alloc functions if malloc pool is available alist: add a couple of helper functions lmb: ut: disable unit tests for lmb changes lmb: remove the unused lmb_is_reserved() function lmb: staticize __lmb_alloc_base() lmb: use the BIT macro for lmb flags lmb: make LMB memory map persistent and global lmb: allow for resizing lmb regions lmb: remove config symbols used for lmb region count test: lmb: remove the test for max regions lmb: config: add lmb config symbols for SPL lmb: allow lmb module to be used in SPL lmb: introduce a function to add memory to the lmb memory map lmb: remove the lmb_init_and_reserve() function lmb: reserve common areas during board init lmb: remove lmb_init_and_reserve_range() function lmb: bootm: remove superfluous lmb stub functions lmb: init: initialise the lmb data structures during board init lmb: add a flags parameter to the API's lmb: add a common implementation of arch_lmb_reserve() sandbox: move the TCG event log to the start of ram memory spl: call spl_board_init() at the end of the spl init sequence spl: sandbox: initialise the ram banksize in spl lmb: config: make lmb config symbol def_bool sandbox: spl: enable lmb config for SPL sandbox: iommu: remove lmb allocation in the driver zynq: lmb: do not add to lmb map before relocation stm32mp: do not add lmb memory before relocation test: cedit: use allocated address for reading file test: lmb: tweak the tests for the persistent lmb memory map test: lmb: run lmb tests only manually test: lmb: add a separate class of unit tests for lmb test: lmb: invoke the LMB unit tests from a separate script test: bdinfo: dump the global LMB memory map sandbox: adjust load address of couple of tests lmb: ut: re-enable unit tests arch/arc/lib/cache.c | 14 - arch/arm/lib/stack.c | 14 - arch/arm/mach-apple/board.c | 20 +- arch/arm/mach-snapdragon/board.c | 17 +- arch/arm/mach-stm32mp/dram_init.c | 13 +- arch/arm/mach-stm32mp/stm32mp1/cpu.c | 7 +- arch/m68k/lib/bootm.c | 20 +- arch/microblaze/lib/bootm.c | 14 - arch/mips/lib/bootm.c | 22 +- arch/nios2/lib/bootm.c | 13 - arch/powerpc/cpu/mpc85xx/mp.c | 4 +- arch/powerpc/include/asm/mp.h | 4 +- arch/powerpc/lib/bootm.c | 25 +- arch/riscv/lib/bootm.c | 13 - arch/sandbox/cpu/spl.c | 13 +- arch/sandbox/dts/test.dts | 2 +- arch/sh/lib/bootm.c | 13 - arch/x86/lib/bootm.c | 18 - arch/xtensa/lib/bootm.c | 13 - board/xilinx/common/board.c | 33 - boot/bootm.c | 39 +- boot/bootm_os.c | 5 +- boot/image-board.c | 47 +- boot/image-fdt.c | 37 +- cmd/bdinfo.c | 5 +- cmd/booti.c | 2 +- cmd/bootz.c | 2 +- cmd/elf.c | 2 +- cmd/load.c | 7 +- common/board_r.c | 4 + common/dlmalloc.c | 4 + common/malloc_simple.c | 13 + common/spl/spl.c | 9 +- configs/a3y17lte_defconfig | 1 - configs/a5y17lte_defconfig | 1 - configs/a7y17lte_defconfig | 1 - configs/apple_m1_defconfig | 1 - configs/mt7981_emmc_rfb_defconfig | 1 - configs/mt7981_rfb_defconfig | 1 - configs/mt7981_sd_rfb_defconfig | 1 - configs/mt7986_rfb_defconfig | 1 - configs/mt7986a_bpir3_emmc_defconfig | 1 - configs/mt7986a_bpir3_sd_defconfig | 1 - configs/mt7988_rfb_defconfig | 1 - configs/mt7988_sd_rfb_defconfig | 1 - configs/qcom_defconfig | 1 - configs/sandbox_noinst_defconfig | 1 + configs/sandbox_spl_defconfig | 1 + configs/sandbox_vpl_defconfig | 1 - configs/stm32mp13_defconfig | 3 - configs/stm32mp15_basic_defconfig | 3 - configs/stm32mp15_defconfig | 3 - configs/stm32mp15_trusted_defconfig | 3 - configs/stm32mp25_defconfig | 3 - configs/th1520_lpi4a_defconfig | 1 - drivers/iommu/apple_dart.c | 8 +- drivers/iommu/sandbox_iommu.c | 19 +- fs/fs.c | 10 +- include/alist.h | 236 ++++++ include/image.h | 28 +- include/lmb.h | 159 ++-- include/test/suites.h | 1 + lib/Kconfig | 46 +- lib/Makefile | 3 +- lib/alist.c | 147 ++++ lib/efi_loader/efi_dt_fixup.c | 2 +- lib/efi_loader/efi_helper.c | 2 +- lib/lmb.c | 672 +++++++++++----- lib/strto.c | 33 +- net/tftp.c | 39 +- net/wget.c | 9 +- test/Kconfig | 9 + test/Makefile | 1 + test/boot/cedit.c | 6 +- test/cmd/bdinfo.c | 39 +- test/cmd_ut.c | 7 + test/lib/Makefile | 2 +- test/lib/alist.c | 197 +++++ test/lib/lmb.c | 825 -------------------- test/lmb_ut.c | 813 +++++++++++++++++++ test/py/tests/test_android/test_abootimg.py | 2 +- test/py/tests/test_lmb.py | 24 + test/py/tests/test_vbe.py | 2 +- test/str_ut.c | 4 +- 84 files changed, 2192 insertions(+), 1653 deletions(-) create mode 100644 include/alist.h create mode 100644 lib/alist.c create mode 100644 test/lib/alist.c delete mode 100644 test/lib/lmb.c create mode 100644 test/lmb_ut.c create mode 100644 test/py/tests/test_lmb.py