From patchwork Wed May 16 15:42:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 914710 X-Patchwork-Delegate: agraf@suse.de 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="M17GMzw5"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40mJmm4Y63z9s2R for ; Thu, 17 May 2018 01:50:32 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 43676C21FBB; Wed, 16 May 2018 15:47:47 +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=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID 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 44EE9C21FCC; Wed, 16 May 2018 15:44:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 049B9C21FE3; Wed, 16 May 2018 15:42:59 +0000 (UTC) Received: from mail-it0-f68.google.com (mail-it0-f68.google.com [209.85.214.68]) by lists.denx.de (Postfix) with ESMTPS id 9CE7CC21FE1 for ; Wed, 16 May 2018 15:42:49 +0000 (UTC) Received: by mail-it0-f68.google.com with SMTP id j186-v6so3072663ita.5 for ; Wed, 16 May 2018 08:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=4BfyYUecsE/68U1gSIPLLTBBBu9LrdUhfKliZKL0zik=; b=M17GMzw5fDGue5TO0ofaUseFyQFKB8a8IDkf2bfdGoaXJVgQ6TChwJj7mN3uqNwgfF Z6mhbGCekL4fcrPipguRwbLzFFWfqE1aGh9Tfsa/i/9Bpjq3Uiek9HJiVh0gvjmAO8uC emAryPk0C2SCX2n3+k/jzSpqGgxx1OZWWt91bc4AeV3MPHPS2Wa7IThKKExCGj2gpu6y yn0ZKcNgkEJaG7AKb8jLUAznZ6eKKKTCIH4V5hDJ3huDe3n+HLaLnCw80p7xb6F5sRwh oxD1e8mPelyDT+TJ0tvi/HEsUuTvn+QHOTJktTo1fF/8pbSVEyVgcQ9wPSFPJNYjK9S2 dJig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=4BfyYUecsE/68U1gSIPLLTBBBu9LrdUhfKliZKL0zik=; b=S++oit2XyPJbNYKVt+Ivd+1kJliHVqaVqR07tBZUqHfBjeE2NVi6grlQdjDWpUx6Qf CTmnJ1vWiYKz9D9vjrtmf3Srnxls0U7k5wNQvGX1P/bT1QEqaCgw7ciEeJyvIbxxmjPb 1K7sRqHGJc/6WJC/uyHlvmRuEA7uOTxXR59FNcT34dfj2wqaJ/1PkIH4+pwxCeES69cB ppviWolf/IZA9CeNVVbIc9BUJhmOCNM9vuvFzXy7dVnY+5RKVjSztlsdXgzRP9bkPD91 MaVy6ajeQ5+deKckHLgRC7lWIsk9Mu94PmwEJkglol4HRASmwEnh1er9g3Tv483DpcQ+ jwpQ== X-Gm-Message-State: ALKqPwcGpHBazlWVMrq3tkg/qiIxXK6EuoFkVB6a299kt7vetFmriEd3 nDO9itWfNUQuOKP5ItKT6dNrEA== X-Google-Smtp-Source: AB8JxZqlljMDUzf0udWB8E0xAqcRJuZSNjONC/Zxnd83Z9y0IdLcvJY3AbzCLb/GHzkguDNmOrVnbg== X-Received: by 2002:a24:8b82:: with SMTP id g124-v6mr1462999ite.56.1526485368116; Wed, 16 May 2018 08:42:48 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([100.67.80.24]) by smtp.gmail.com with ESMTPSA id j200-v6sm1782961itj.9.2018.05.16.08.42.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:42:47 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id D98B2140474; Wed, 16 May 2018 09:42:46 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Wed, 16 May 2018 09:42:20 -0600 Message-Id: <20180516154233.21457-4-sjg@chromium.org> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog In-Reply-To: <20180516154233.21457-1-sjg@chromium.org> References: <20180516154233.21457-1-sjg@chromium.org> Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v4 03/16] efi: sandbox: Adjust memory usage for sandbox 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" With sandbox the U-Boot code is not mapped into the sandbox memory range so does not need to be excluded when allocating EFI memory. Update the EFI memory init code to take account of that. Also use mapmem instead of a cast to convert a memory address to a pointer. Signed-off-by: Simon Glass --- Changes in v4: None Changes in v3: None Changes in v2: - Update to use mapmem instead of a cast lib/efi_loader/efi_memory.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 664c651db56..3fbed63728b 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -388,7 +389,7 @@ efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void **buffer) r = efi_allocate_pages(0, pool_type, num_pages, &t); if (r == EFI_SUCCESS) { - struct efi_pool_allocation *alloc = (void *)(uintptr_t)t; + struct efi_pool_allocation *alloc = map_sysmem(t, size); alloc->num_pages = num_pages; *buffer = alloc->data; } @@ -499,18 +500,22 @@ int efi_memory_init(void) efi_add_known_memory(); - /* Add U-Boot */ - uboot_start = (gd->start_addr_sp - uboot_stack_size) & ~EFI_PAGE_MASK; - uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT; - efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA, false); - - /* Add Runtime Services */ - runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK; - runtime_end = (ulong)&__efi_runtime_stop; - runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK; - runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT; - efi_add_memory_map(runtime_start, runtime_pages, - EFI_RUNTIME_SERVICES_CODE, false); + if (!IS_ENABLED(CONFIG_SANDBOX)) { + /* Add U-Boot */ + uboot_start = (gd->start_addr_sp - uboot_stack_size) & + ~EFI_PAGE_MASK; + uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT; + efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA, + false); + + /* Add Runtime Services */ + runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK; + runtime_end = (ulong)&__efi_runtime_stop; + runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK; + runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT; + efi_add_memory_map(runtime_start, runtime_pages, + EFI_RUNTIME_SERVICES_CODE, false); + } #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER /* Request a 32bit 64MB bounce buffer region */