From patchwork Wed Jan 19 22:52:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Salveti X-Patchwork-Id: 1581953 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=bFzpQmXb; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JfLXR5zqzz9s9c for ; Thu, 20 Jan 2022 09:53:27 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6CCAA833A2; Wed, 19 Jan 2022 23:53:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="bFzpQmXb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A6837837C4; Wed, 19 Jan 2022 23:53:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0607683373 for ; Wed, 19 Jan 2022 23:53:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ricardo@foundries.io Received: by mail-ot1-x331.google.com with SMTP id i7-20020a9d68c7000000b0059396529af8so5234998oto.4 for ; Wed, 19 Jan 2022 14:53:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=CmBoY4GaKJsS3vyoNJBvXAilmYH6xV177Fb5okRWY8g=; b=bFzpQmXbZi3C2KjqRp6mcxmB5XwILQj0gmX7VwrQtzKN6A8d08c+WrSXGRcO4pZiSN QKX5TS7eCMk9KA0etUvas6kbp2I/t8inkAMc5ux2QQEYwA2EJ1lgu6IC8K5O3Qi7GmOG rNspBFgstpdbGKDiwnkqzHd9q101ROsK+GVX5GZUagtAr4sFFvw4zlv6C4wAPw4COa8B DMnHEu7o4LKDoa8umHgS3KLn07+TZKrqrd5rVXef2+Ya7VIeFmoGv7i1AMkNVPGS4NQD Dduegc72kLs1YLhvSBVg7HZdgNxJc9Ob2fTdWERxigKLD+EBSxTI3OalOgsbwoMUEaEI CPoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=CmBoY4GaKJsS3vyoNJBvXAilmYH6xV177Fb5okRWY8g=; b=DnKdonbNvk/ygjlwSfLjw5os/lZQTs58r274siXa96faC/r5hHjMgp/PwdxhGiYbHM e6Y1LznuDvYq00l8KY5XNmf5cGghCOuvaS6PUb5bGuMRDmz4SjjbuLPPA+kfBFW62fXf +xHTpmMVJKLvRrFvqku3eeUrjIdr7B2cIPIWeIs3ozHbORZfOeMgrurcH5t0z0+83w9m xeW5S2JPAnwOpOfgSN5bhiW992+nW8Ja83icoBCmBpIkQ0/SYnH5IQzwNVgKOfL2Y52x dB9M2trjEGQmDsKxTpDv7d84p24cIH3S6YDWxKrurypquzT2qSHIQ+rGOQZVncoWWF2q WK2Q== X-Gm-Message-State: AOAM533KTohU5cnGMrwZeNrQRP8UEzuVqHnH/7XWdGz92X8gPkMGkIBc pb03kzuPbrSAfCj60UgNsbPgoHrtFthf X-Google-Smtp-Source: ABdhPJyro0g30x+cs/F2vvq3FwDF68XSjaQzvkyw965NdEZgwnKKFW/8/fCnO55+8Hp15IPVilnCcg== X-Received: by 2002:a9d:2aa3:: with SMTP id e32mr25741153otb.6.1642632797215; Wed, 19 Jan 2022 14:53:17 -0800 (PST) Received: from localhost.localdomain ([191.251.45.228]) by smtp.gmail.com with ESMTPSA id k10sm535533oou.26.2022.01.19.14.53.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 14:53:16 -0800 (PST) From: Ricardo Salveti To: u-boot@lists.denx.de Cc: michal.simek@xilinx.com, igor.opaniuk@foundries.io Subject: [PATCH] xilinx: common: change bootm_size to not go beyond ram_top Date: Wed, 19 Jan 2022 19:52:58 -0300 Message-Id: <20220119225258.3207314-1-ricardo@foundries.io> 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.2 at phobos.denx.de X-Virus-Status: Clean The available ram can be limited by ram_top as that depends on the reserved memory nodes provided by the device-tree (via board_get_usable_ram_top), so make sure to respect ram_top when setting up bootm_size to avoid overlapping reserved memory regions (e.g. memory used by OP-TEE). The same logic is available in env_get_bootm_size when bootm_size is not defined by the default environment. Signed-off-by: Ricardo Salveti --- board/xilinx/common/board.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 78a5d0efa86..4928fab2c96 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -389,6 +389,9 @@ int board_late_init_xilinx(void) if (CONFIG_IS_ENABLED(ARCH_ZYNQ) || CONFIG_IS_ENABLED(MICROBLAZE)) bootm_size = min(bootm_size, (phys_size_t)(SZ_512M + SZ_256M)); + if (gd->ram_base + bootm_size > gd->ram_top) + bootm_size = gd->ram_top - gd->ram_base; + ret |= env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET); ret |= env_set_addr("bootm_low", (void *)gd->ram_base);