From mboxrd@z Thu Jan 1 00:00:00 1970 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 8008BC4708D for ; Fri, 6 Jan 2023 16:45:56 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D730E85423; Fri, 6 Jan 2023 17:45:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="ot09v7ym"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 97875854C2; Fri, 6 Jan 2023 17:45:51 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DDD0B853FD for ; Fri, 6 Jan 2023 17:45:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8CA3AB81E05; Fri, 6 Jan 2023 16:45:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 213C1C433EF; Fri, 6 Jan 2023 16:45:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673023547; bh=2vvHsxpu+sKBlQUaH/4KclI2DWCdUijU4ZdfJ2ivLZU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ot09v7ymYyx7BvN+T8ARnA62lHINTFIe31bH51xBaod4J48ttn3XsfKUzUvzEw0Gv rzlo7t20hreUNIZl96KCUa1jHSacy32FJzPg3F4107jcvocUiZIAIBHGGSf3PC02Cq FgozNYcl4KRY1hhpEelMPh7TT7rwOKY4bIcP5/CM/g9fmErfIgQNX5b2VkDGkhHg3X wbrDwNwKXoXaSYDN5/mPC3UrgpK28aUi8zVLQP7ZhFHWztdoOD146gWjoGCvlQPU4/ Be2qygZ2kUMiE9IrIGTY4Epf+l1FF4vlBdqgSGNRGNijV76FLJkkpRtL7LCxmsW9qD 6Krrc9jMtb1cw== Received: by pali.im (Postfix) id 0E879A3A; Fri, 6 Jan 2023 17:45:44 +0100 (CET) Date: Fri, 6 Jan 2023 17:45:43 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: Tom Rini Cc: u-boot@lists.denx.de, Marek Vasut , Patrick Delaunay Subject: Re: [PATCH] Revert "common/memsize.c: Fix get_effective_memsize() to check for overflow" Message-ID: <20230106164543.3gtq73flpoocg7mc@pali> References: <20230106155143.4025812-1-trini@konsulko.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230106155143.4025812-1-trini@konsulko.com> User-Agent: NeoMutt/20180716 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.6 at phobos.denx.de X-Virus-Status: Clean On Friday 06 January 2023 10:51:43 Tom Rini wrote: > This reverts commit 777aaaa706bcfe08c284aed06886db7d482af3f8. > > The changes to this generic function, which is intended to help with > 32bit platforms with large amounts of memory has unintended side effects > (which in turn lead to boot failures) on other platforms which were > previously functional. As mentioned previously, unfortunately this revert breaks 32-bit u-boot on 36-bit mpc85xx boards with 32-bit e500v2 cores and 4GB DDR module. Which platforms currently have broken u-boot without this revert? The only one which was reported is stm32mp but for it there different workaround patch waiting in the queue. > Reported-by: Marek Vasut > Cc: Patrick Delaunay > Cc: Pali Rohár > Signed-off-by: Tom Rini > --- > common/memsize.c | 18 +++--------------- > 1 file changed, 3 insertions(+), 15 deletions(-) > > diff --git a/common/memsize.c b/common/memsize.c > index 3c80ad2c8346..31884acca0df 100644 > --- a/common/memsize.c > +++ b/common/memsize.c > @@ -94,23 +94,11 @@ long get_ram_size(long *base, long maxsize) > > phys_size_t __weak get_effective_memsize(void) > { > - phys_size_t ram_size = gd->ram_size; > - > - /* > - * Check for overflow and limit ram size to some representable value. > - * It is required that ram_base + ram_size must be representable by > - * phys_size_t type and must be aligned by direct access, therefore > - * calculate it from last 4kB sector which should work as alignment > - * on any platform. > - */ > - if (gd->ram_base + ram_size < gd->ram_base) > - ram_size = ((phys_size_t)~0xfffULL) - gd->ram_base; > - > #ifndef CONFIG_MAX_MEM_MAPPED > - return ram_size; > + return gd->ram_size; > #else > /* limit stack to what we can reasonable map */ > - return ((ram_size > CONFIG_MAX_MEM_MAPPED) ? > - CONFIG_MAX_MEM_MAPPED : ram_size); > + return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ? > + CONFIG_MAX_MEM_MAPPED : gd->ram_size); > #endif > } > -- > 2.25.1 >