From patchwork Tue Oct 3 21:50:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 820834 X-Patchwork-Delegate: yorksun@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3y5w1J5Rgwz9t50 for ; Tue, 3 Oct 2017 21:16:36 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 28495C21F40; Tue, 3 Oct 2017 10:16:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAD_ENC_HEADER, DATE_IN_FUTURE_06_12, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C6D81C21C46; Tue, 3 Oct 2017 10:16:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 54804C21C46; Tue, 3 Oct 2017 10:16:20 +0000 (UTC) Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0056.outbound.protection.outlook.com [104.47.37.56]) by lists.denx.de (Postfix) with ESMTPS id BDC43C21C39 for ; Tue, 3 Oct 2017 10:16:18 +0000 (UTC) Received: from BLUPR0301CA0031.namprd03.prod.outlook.com (10.162.113.169) by DM5PR03MB2697.namprd03.prod.outlook.com (10.168.197.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Tue, 3 Oct 2017 10:16:16 +0000 Received: from BN1AFFO11FD014.protection.gbl (2a01:111:f400:7c10::130) by BLUPR0301CA0031.outlook.office365.com (2a01:111:e400:5259::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.8 via Frontend Transport; Tue, 3 Oct 2017 10:16:16 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11FD014.mail.protection.outlook.com (10.58.52.74) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.77.10 via Frontend Transport; Tue, 3 Oct 2017 10:16:15 +0000 Received: from b49020-OptiPlex-790.ap.freescale.net (b49020-OptiPlex-790.ap.freescale.net [10.232.132.83]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id v93AGAlJ014389; Tue, 3 Oct 2017 03:16:12 -0700 From: Sumit Garg To: Date: Wed, 4 Oct 2017 03:20:49 +0530 Message-ID: <1507067449-13266-1-git-send-email-sumit.garg@nxp.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131514993760899982; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39380400002)(376002)(39860400002)(346002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(43544003)(5003940100001)(5660300001)(48376002)(97736004)(36756003)(85426001)(498600001)(50466002)(104016004)(86362001)(16586007)(4326008)(54906003)(50986999)(305945005)(50226002)(2906002)(316002)(6666003)(6916009)(53936002)(68736007)(81156014)(47776003)(8676002)(8936002)(81166006)(189998001)(8656003)(69596002)(77096006)(33646002)(106466001)(2351001)(356003)(105606002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2697; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD014; 1:c+Aj3YhuQT6GD47tnauwmgw4oMxDdXxlWVlL0Tuk188VLnJMINMWqJU90Zgkoq8S6Ker/Xzx3wFAnfc+uBMf4iRDwPNiC12LwncQx2J6md0IHBo+FZrYUNn6PIomUyOQ MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 220dd8f9-5aef-4942-322f-08d50a47c836 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017052603199)(201703131430075)(201703131517081); SRVR:DM5PR03MB2697; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2697; 3:dlCQcjqDqgl75hqZ3OUhow9kMRSNWk1EY1DB75EjWH/cJQAVn/gfN9HC9kUiqBPRjBX/NWUsW8N2XWXaByCaJwMzxlekR1E50LrcFfFMg8H/8J9sDBvhv7bSNB92d8cafCFTbIyB2ONXwacgBQqBsj6V5vGeZXooNQPIWYxmT56kwVTlJN0Obf8X6eZfgUSXjZSYRP3jBeGbMkbAOYTv8nPi6zyhZD7buSXXj36Md1NZbUAwTsGQHHrhwR3eWDyj9gT8XucuHSYVBagJO2US3r8j0kftjY87HtcxX/qaTn+m3/kEtwX8UfYPpLN05T8oOEtW02u7Yxg4yxiBqrIDHQ==; 25:pwbtcZO+uxBNP9g2uXY49+ccbYsxupRTKr0yOciyQURJwS9wdteySWelVLPdZHF9nOrzXCrODtxqMUVbKhgmRLD5EQ2CNLPh35Pj6TO7AeQzxUOID2bkI3krK0qrSdY+JQgtl/+MRwAo62bUXU3+nnlc0P+YONbCE5e8Acgh+MNCfdzZmtxFQMM+4kOcW20BPckaBwLDmn0awUTSbJ11O3kU9Ja8MQ6ZWxmiQMtxSHN28i6Y5mQnBbelMMJT+srjkM+0wFpE9DT3hCCpgXqBigX2CPyfawMCToC2KQRZd/epmCY/PamzKiDo6UfG+tIJJVlVq/xT9T3GfiTNuX0NsA==; 31:c/l+cFeGv0qAELHXbYQqIYLskJMB/wDBf+AL7GlVxdzxyg0H4Na+zLrouUSZgVV6NmrjdeZdZb7apwy4BG78QGxWo9YlxOohawN4Xq9SeYWPfV5HruB79VI20onpqlRMrR5eoTQ4S1r7YShmm1/MWneX8ewBXetxt4+wlfoFWkmj5aHWwuJYSWFgBFsfify07qkLpCS6IZQX6OwHxSXEscuNrozEzny1ShsEyRhxAnE= X-MS-TrafficTypeDiagnostic: DM5PR03MB2697: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6096035)(20161123561025)(20161123563025)(20161123565025)(20161123556025)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(201703151042153)(20161123559100)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM5PR03MB2697; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM5PR03MB2697; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2697; 4:5ygCPWUF4hVFVlGTgCLtGeRDUNT9QYhiyFUpSQ/IByjO2Z3jLE49f3hB5OVehk9yDDymqhyIjbjMrNZSPjs1bPkxmB2/73HJ7DCJRFkMlo7Y1t76bt6Yj1dJjJZK/G8HAJ+jLGIvf26pRgsUv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x8GpIRShuKNLLm9Xd7iFh/eevfqZwEFnjeHAGGo7euXoItFlsp/5dCrtOGyKSpWriNbT3wTiaGZ3oHMWO5NOn9/4AGKmPIiBw8/p3WDFFjD4BCYbeieaDYLJ5PRBClkfeXzq0x2a2x1Zo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2017 10:16:15.8403 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2697 Cc: sahil.malhotra@nxp.com, pankaj.gupta@nxp.com, arun.pathak@nxp.com, ruchika.gupta@nxp.com Subject: [U-Boot] [PATCH] armv8: fsl-layerscape: Allocate Secure memory from first ddr region X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" This change is required due to trusted OS (OP-TEE) not being position independent code, it requires compile time fixed base address. To take care of this it is assumed that all layerscape armv8 platforms has minimum 2G ddr in first region. So we can have fixed address space (66 MB -> (2MB for PPA + 64MB for trusted OS)) allocated from top of first 2G ddr region and compile trusted OS with this fixed base address. But one exception here is ls1012 where we have only 1G (rdb) or 512M (frdm) ddr memory. For those we can have different fixed compile time base addresses for trusted OS. Signed-off-by: Sumit Garg --- Tested on ls1012ardb, ls1043ardb, ls1046ardb, ls2088ardb, ls1088ardb. arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 59 ++++++++++----------------------- 1 file changed, 18 insertions(+), 41 deletions(-) diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c index ef3e300..09aa538 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c @@ -643,13 +643,14 @@ phys_size_t get_effective_memsize(void) /* * For ARMv8 SoCs, DDR memory is split into two or three regions. The - * first region is 2GB space at 0x8000_0000. If the memory extends to - * the second region (or the third region if applicable), the secure - * memory and Management Complex (MC) memory should be put into the - * highest region, i.e. the end of DDR memory. CONFIG_MAX_MEM_MAPPED - * is set to the size of first region so U-Boot doesn't relocate itself - * into higher address. Should DDR be configured to skip the first - * region, this function needs to be adjusted. + * first region is 2GB space at 0x8000_0000. Secure memory needs to + * allocated from first region. If the memory extends to the second + * region (or the third region if applicable), Management Complex (MC) + * memory should be put into the highest region, i.e. the end of DDR + * memory. CONFIG_MAX_MEM_MAPPED is set to the size of first region so + * U-Boot doesn't relocate itself into higher address. Should DDR be + * configured to skip the first region, this function needs to be + * adjusted. */ if (gd->ram_size > CONFIG_MAX_MEM_MAPPED) { ea_size = CONFIG_MAX_MEM_MAPPED; @@ -660,16 +661,10 @@ phys_size_t get_effective_memsize(void) #ifdef CONFIG_SYS_MEM_RESERVE_SECURE /* Check if we have enough space for secure memory */ - if (rem > CONFIG_SYS_MEM_RESERVE_SECURE) { - rem -= CONFIG_SYS_MEM_RESERVE_SECURE; - } else { - if (ea_size > CONFIG_SYS_MEM_RESERVE_SECURE) { - ea_size -= CONFIG_SYS_MEM_RESERVE_SECURE; - rem = 0; /* Presume MC requires more memory */ - } else { - printf("Error: No enough space for secure memory.\n"); - } - } + if (ea_size > CONFIG_SYS_MEM_RESERVE_SECURE) + ea_size -= CONFIG_SYS_MEM_RESERVE_SECURE; + else + printf("Error: No enough space for secure memory.\n"); #endif /* Check if we have enough memory for MC */ if (rem < board_reserve_ram_top(rem)) { @@ -714,32 +709,14 @@ int dram_init_banksize(void) gd->bd->bi_dram[0].size = gd->ram_size; } #ifdef CONFIG_SYS_MEM_RESERVE_SECURE -#ifdef CONFIG_SYS_DDR_BLOCK3_BASE - if (gd->bd->bi_dram[2].size >= CONFIG_SYS_MEM_RESERVE_SECURE) { - gd->bd->bi_dram[2].size -= CONFIG_SYS_MEM_RESERVE_SECURE; - gd->arch.secure_ram = gd->bd->bi_dram[2].start + - gd->bd->bi_dram[2].size; + if (gd->bd->bi_dram[0].size > + CONFIG_SYS_MEM_RESERVE_SECURE) { + gd->bd->bi_dram[0].size -= + CONFIG_SYS_MEM_RESERVE_SECURE; + gd->arch.secure_ram = gd->bd->bi_dram[0].start + + gd->bd->bi_dram[0].size; gd->arch.secure_ram |= MEM_RESERVE_SECURE_MAINTAINED; gd->ram_size -= CONFIG_SYS_MEM_RESERVE_SECURE; - } else -#endif - { - if (gd->bd->bi_dram[1].size >= CONFIG_SYS_MEM_RESERVE_SECURE) { - gd->bd->bi_dram[1].size -= - CONFIG_SYS_MEM_RESERVE_SECURE; - gd->arch.secure_ram = gd->bd->bi_dram[1].start + - gd->bd->bi_dram[1].size; - gd->arch.secure_ram |= MEM_RESERVE_SECURE_MAINTAINED; - gd->ram_size -= CONFIG_SYS_MEM_RESERVE_SECURE; - } else if (gd->bd->bi_dram[0].size > - CONFIG_SYS_MEM_RESERVE_SECURE) { - gd->bd->bi_dram[0].size -= - CONFIG_SYS_MEM_RESERVE_SECURE; - gd->arch.secure_ram = gd->bd->bi_dram[0].start + - gd->bd->bi_dram[0].size; - gd->arch.secure_ram |= MEM_RESERVE_SECURE_MAINTAINED; - gd->ram_size -= CONFIG_SYS_MEM_RESERVE_SECURE; - } } #endif /* CONFIG_SYS_MEM_RESERVE_SECURE */