From patchwork Wed Jun 13 02:37:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 928622 X-Patchwork-Delegate: sjg@chromium.org 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="rUmQAeNc"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4159v63j4Mz9s3C for ; Wed, 13 Jun 2018 12:39:30 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 3050DC21E07; Wed, 13 Jun 2018 02:38:33 +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_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 E0227C21E26; Wed, 13 Jun 2018 02:37:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DA3DDC21C8B; Wed, 13 Jun 2018 02:37:42 +0000 (UTC) Received: from mail-it0-f65.google.com (mail-it0-f65.google.com [209.85.214.65]) by lists.denx.de (Postfix) with ESMTPS id ADD01C21DA1 for ; Wed, 13 Jun 2018 02:37:37 +0000 (UTC) Received: by mail-it0-f65.google.com with SMTP id l6-v6so1956909iti.2 for ; Tue, 12 Jun 2018 19:37:37 -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=EiYcwDufTwAPJ++t+mGW5B/XX6Lfr7vGfEHbFwicfcQ=; b=rUmQAeNci0oJwxWWTKoi0tO32af7BBRlNtpFOW9Pt5E+FIqK6mwgsJ4IN1u3E2Uuh9 1I/n8TB1ZP5rGv4zOD+5oKlEovqhcrCPYoWnBHoVDeEmw53qeQl3arEb5Sywj6VVksJ+ BbjWQTekuNIzF2fSWAgE9k/PMWEDgHhzw6BrJuDXwp51TPfkkg585gmWc6HbV81t1rvA czNut8KHwakl7ZUivO69EWR8g1604Q+48VxqFqfMMYSsaNLN3knHYsHCE4L9eQ6hw1g9 2mbDyEKunMuJDgNQZKi2eivzASrZ6T5LipSigG+GE+R1pOYTx7T6aXPTPUqM1Br3VDPA calA== 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=EiYcwDufTwAPJ++t+mGW5B/XX6Lfr7vGfEHbFwicfcQ=; b=VcOULZ6A0H6BXSpeMFHeLwDjbdXQ2IuQ33Dk3mc6AjSnn6GfetAylnZVSj/Sesma2a 3YouqNQIVa6UY/W9PoId3d4vVL0uevUYmy8Uiy1BZ7VTOeK9fTdIgGa5GwNdUI7LbWEY otvAqp25UJbmsLvnF3B4oVC6CosKKC4XCYyOrzM6Q3s4jxvifogQ5ddlWdYyXM6QYuRa fh9t2q3XabZyMdLkpa1AZDBMwY/OT/iWLd+92GuFGcces1e11RqdzgUeYTaXpLPcUC9k 8HBq18j2Ldzm3YKPEE1qt/FLgt72TDzj56xs6wjbxkYQUJYdlFZ23KfUIrooISXMx1Ov iPnw== X-Gm-Message-State: APt69E2qOzEU4RHhwTMaC8qhRPXg5JpcsLdbUQyXDBTqCdIf5nS5764R 1hk6dyFyCAlBepcgxJt0UMa4ow== X-Google-Smtp-Source: ADUXVKJay8ito8mqrRM4wH2Cl0Ur8Ph2LsmhiwcXJKYLIkyQvq7089Y06PQeh2+wICjy+nepKYnUGg== X-Received: by 2002:a24:4a02:: with SMTP id k2-v6mr2969687itb.128.1528857456053; Tue, 12 Jun 2018 19:37:36 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([100.67.80.24]) by smtp.gmail.com with ESMTPSA id n4-v6sm491548ioc.76.2018.06.12.19.37.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Jun 2018 19:37:35 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id CBB9414153C; Tue, 12 Jun 2018 20:37:34 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Tue, 12 Jun 2018 20:37:18 -0600 Message-Id: <20180613023728.202173-4-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180613023728.202173-1-sjg@chromium.org> References: <20180613023728.202173-1-sjg@chromium.org> Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v6 03/13] 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 v6: None Changes in v5: None 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 ec66af98ea..210e49ee8b 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 @@ -393,7 +394,7 @@ efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void **buffer) &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; } @@ -504,18 +505,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 */