Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 60DE0C7EE24 for ; Tue, 6 Jun 2023 08:23:38 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 78E1985D8B; Tue, 6 Jun 2023 10:23:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=reject dis=none) header.from=sifive.com 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 5D51F85DFA; Tue, 6 Jun 2023 10:23:35 +0200 (CEST) Received: from imap5.colo.codethink.co.uk (imap5.colo.codethink.co.uk [78.40.148.171]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0F5B285D8B for ; Tue, 6 Jun 2023 10:23:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=reject dis=none) header.from=sifive.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ben@codethink.co.uk Received: from [90.160.41.100] (helo=rainbowdash) by imap5.colo.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1q6RyU-003DNZ-NM; Tue, 06 Jun 2023 09:23:31 +0100 Received: from ben by rainbowdash with local (Exim 4.96) (envelope-from ) id 1q6RyU-000DyY-1r; Tue, 06 Jun 2023 09:23:30 +0100 From: Ben Dooks To: u-boot@lists.denx.de Cc: hs@denx.de, Ben Dooks , Ben Dooks Subject: [PATCHv2] ubifs: allow loading to above 4GiB Date: Tue, 6 Jun 2023 09:23:28 +0100 Message-Id: <20230606082328.53713-1-ben.dooks@sifive.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 The ubifsload command is truncating any address above 4GiB as it casts this address to an u32, instead of using an unsigned long which most of the other load commands do. Change this to an unsigned long to allow loading into high memory for boards which use these areas. Fixes the following error: => ubifsload 0x2100000000 /boot/Image.lzma Loading file '/boot/Image.lzma' to addr 0x00000000... Unhandled exception: Store/AMO access fault Signed-off-by: Ben Dooks Signed-off-by: Ben Dooks --- v2: - fixed debug print --- cmd/ubifs.c | 4 ++-- fs/ubifs/ubifs.c | 4 ++-- include/ubifs_uboot.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/ubifs.c b/cmd/ubifs.c index 6a01d0988a..2a035bc7ae 100644 --- a/cmd/ubifs.c +++ b/cmd/ubifs.c @@ -111,7 +111,7 @@ static int do_ubifs_load(struct cmd_tbl *cmdtp, int flag, int argc, char *filename; char *endp; int ret; - u32 addr; + unsigned long addr; u32 size = 0; if (!ubifs_mounted) { @@ -133,7 +133,7 @@ static int do_ubifs_load(struct cmd_tbl *cmdtp, int flag, int argc, if (endp == argv[3]) return CMD_RET_USAGE; } - debug("Loading file '%s' to address 0x%08x (size %d)\n", filename, addr, size); + debug("Loading file '%s' to address 0x%08lx (size %d)\n", filename, addr, size); ret = ubifs_load(filename, addr, size); if (ret) { diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c index d3026e3101..609bdbf603 100644 --- a/fs/ubifs/ubifs.c +++ b/fs/ubifs/ubifs.c @@ -925,12 +925,12 @@ void ubifs_close(void) } /* Compat wrappers for common/cmd_ubifs.c */ -int ubifs_load(char *filename, u32 addr, u32 size) +int ubifs_load(char *filename, unsigned long addr, u32 size) { loff_t actread; int err; - printf("Loading file '%s' to addr 0x%08x...\n", filename, addr); + printf("Loading file '%s' to addr 0x%08lx...\n", filename, addr); err = ubifs_read(filename, (void *)(uintptr_t)addr, 0, size, &actread); if (err == 0) { diff --git a/include/ubifs_uboot.h b/include/ubifs_uboot.h index b025779d59..db8a29e9bb 100644 --- a/include/ubifs_uboot.h +++ b/include/ubifs_uboot.h @@ -21,7 +21,7 @@ int ubifs_init(void); int uboot_ubifs_mount(char *vol_name); void uboot_ubifs_umount(void); int ubifs_is_mounted(void); -int ubifs_load(char *filename, u32 addr, u32 size); +int ubifs_load(char *filename, unsigned long addr, u32 size); int ubifs_set_blk_dev(struct blk_desc *rbdd, struct disk_partition *info); int ubifs_ls(const char *dir_name); -- 2.39.2