Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9B9FC4338F for ; Mon, 23 Aug 2021 02:43:39 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1B75261356 for ; Mon, 23 Aug 2021 02:43:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1B75261356 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 85C3682E2B; Mon, 23 Aug 2021 04:43:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="pKpGn8Ib"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6CF9F821F0; Mon, 23 Aug 2021 04:43:26 +0200 (CEST) Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) (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 F026C82E2B for ; Mon, 23 Aug 2021 04:43:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=grandpaul@gmail.com Received: by mail-pg1-x529.google.com with SMTP id k24so15310880pgh.8 for ; Sun, 22 Aug 2021 19:43:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=StMK7uXbq580FMG0/IdyOyi03jZbvk/jHGLK8y0J6z4=; b=pKpGn8Ib/whJyvu8bqkgoHaFY3KYyq+3hQ8Qg7cBy/GJE242tYtnldceRB/UjhOSon B2D8hnIygPw0MsauVjq2FSoTByk+1LvcAkLxDqHm8+K+Q4sa8yYTQ7iath9b1l/xFb3m 0igyYj4yj9CR2bLQtutomX7ucXJWGc57RpgZvEi3kB2hyCot5bU9KTcZUOEB+tZGkvww AvQ6voK5wSJCOwDyahBHasLVFYC/VBqw2iV1cCSlMhNiZmO4tkGicMq0CILYeboaWiAX KS9Vp6PuYvukzi6YB+VzlCn/Ef04U4xjYJ9z5hOvS2vCGIb+NVlLuzHCpBhuYTbH+PD5 eY3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=StMK7uXbq580FMG0/IdyOyi03jZbvk/jHGLK8y0J6z4=; b=Gy0pr0HuXkI+2Dm8LX0boPCsqm+OH0p35P+NNZNAy2YUZWsfuIsJCmxE3M9ReIH519 ZTSZNj4UBipRLcmqNncH3zBpKEn26tge2MwBB0P/F8O+PUqmm1CJwm0P5H4wshWOUFAP qrYmAyTy+PnJkpfuPp84smRR21E1zPRbd1wMIFmoly2zqJewmKX6Bixbp0iXQNxblTbT zwaqmeKs0hAH8QoOOmeNoHzsWU7LIreI1zO/5AyjQBAtACq3BvHyzbXlbvqE4S10vYbs QRL9ffzHe2C6PGCE+SJwd6DLaf13E5Dd7SlHEehlls/UgW6oiLk4ckGCAv1xPEEZlSGI WH4A== X-Gm-Message-State: AOAM533yZym2uhLMXmdwVkN3qp43ZbjLdDiBeruq8pjWKM7rPXBS6qQY P/v2fHr6OUsJg5Nfb5J0cTSQ/Zyfvzs= X-Google-Smtp-Source: ABdhPJwGQvIGlwS8d5Dppz6OK/6HTH2r+zB/cyG3d1MgOco3to6kxEa2/DE5YUSIKG1sHk8NEUqXjQ== X-Received: by 2002:a62:d414:0:b0:3eb:13e2:eccd with SMTP id a20-20020a62d414000000b003eb13e2eccdmr8779603pfh.68.1629686598909; Sun, 22 Aug 2021 19:43:18 -0700 (PDT) Received: from localhost (host-111-184-129-17.dynamic.kbtelecom.net. [111.184.129.17]) by smtp.gmail.com with ESMTPSA id n185sm14900418pfn.171.2021.08.22.19.43.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Aug 2021 19:43:18 -0700 (PDT) From: Ying-Chun Liu To: u-boot@lists.denx.de Cc: "Ying-Chun Liu (PaulLiu)" , Fabio Estevam , Frieder Schrempf , uboot-imx Subject: [PATCH 1/1] imx8m: Restrict usable memory based on rom_pointer[0] Date: Mon, 23 Aug 2021 10:43:06 +0800 Message-Id: <20210823024306.2046708-2-grandpaul@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210823024306.2046708-1-grandpaul@gmail.com> References: <20210823024306.2046708-1-grandpaul@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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 From: "Ying-Chun Liu (PaulLiu)" When TEE is loaded, we need to restrict the memory usage based on rom_pointer[0] Signed-off-by: Ying-Chun Liu (PaulLiu) Cc: Fabio Estevam Cc: Frieder Schrempf Cc: uboot-imx --- arch/arm/mach-imx/imx8m/soc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c index f2ddc834d4..863508776d 100644 --- a/arch/arm/mach-imx/imx8m/soc.c +++ b/arch/arm/mach-imx/imx8m/soc.c @@ -298,16 +298,26 @@ phys_size_t get_effective_memsize(void) ulong board_get_usable_ram_top(ulong total_size) { + ulong top_addr = PHYS_SDRAM + gd->ram_size; + /* * Some IPs have their accessible address space restricted by * the interconnect. Let's make sure U-Boot only ever uses the * space below the 4G address boundary (which is 3GiB big), * even when the effective available memory is bigger. */ - if (PHYS_SDRAM + gd->ram_size > 0x80000000) - return 0x80000000; + if (top_addr > 0x80000000) + top_addr = 0x80000000; + + /* + * rom_pointer[0] stores the TEE memory start address. + * rom_pointer[1] stores the size TEE uses. + * We need to reserve the memory region for TEE. + */ + if (rom_pointer[0] && rom_pointer[1] && top_addr > rom_pointer[0]) + top_addr = rom_pointer[0]; - return PHYS_SDRAM + gd->ram_size; + return top_addr; } static u32 get_cpu_variant_type(u32 type) -- 2.32.0