From patchwork Tue Jun 12 05:26:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 928091 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="ToPwDC5u"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 414dn90hQ0z9s0W for ; Tue, 12 Jun 2018 15:32:28 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id BC7F1C21D56; Tue, 12 Jun 2018 05:27:51 +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_H2, 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 09392C21E02; Tue, 12 Jun 2018 05:27:08 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D0BC1C21DF3; Tue, 12 Jun 2018 05:27:02 +0000 (UTC) Received: from mail-io0-f193.google.com (mail-io0-f193.google.com [209.85.223.193]) by lists.denx.de (Postfix) with ESMTPS id 18949C21DCA for ; Tue, 12 Jun 2018 05:26:58 +0000 (UTC) Received: by mail-io0-f193.google.com with SMTP id k3-v6so12586636iog.3 for ; Mon, 11 Jun 2018 22:26:58 -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=HUlWAW4cfn87Ozgs1VA29BWFVwdk5SyWPlrC+uwlsYg=; b=ToPwDC5uTKLpBdE8YFvjRlWjozoYsly6AbflPuMavaVjPADSO9aZr8X2Q9a/vJxN9M b4o9DOX3vO13b+iZFPdYOnvwSCp1iDIJpMplIhnUECVdqHGlPku2iU347pzrVjVLr9pe iLqsaQEOVkyT6Gx6gR8JDqdZf6nJi1bDMVxi7JkxNrZkpn6WOC/scwNF8mw5oZDF5wyF K/m0pJJmtS+2DTQIWFxGUTSnaayxhyRKpsBKq1g+j6aZIXdjT4+KmvVbsQJH54LiNLTl 2uoOfAvxpdIiPEz+tN2s9FjUXgKQ+/NBafSEa2goSUnu0TNbtIiO111BopdSb+mfMKOp a7CQ== 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=HUlWAW4cfn87Ozgs1VA29BWFVwdk5SyWPlrC+uwlsYg=; b=uNUFSWbdvHmDo0eK5dV1SqTg3kHW28+NmLnb/0jv99S4k4F0GXiU1nJeKgK8ky+p6r TWK99M4WaIpRFBWiXKPlTc5BhfSidZPiPQg856Iqqw7jHreBWepAUJ0/q69KThCrPVkg reSntnEPvfhwwMegBtGJBKNJmvKCsBZvDnzk5MkVMUgeA7JWxlR2vM9efG7jko3YCPjr JbFHgx7Uq100MzPscr89SgBgFcWD0RG73zJxzbKZSnUQ1CJ/LHwXuXdnw4hxinh9ZnvF kj37BuZ3DBkL5PZZGsZPtlfDrlO/iViwRBbKf7CC70uVFMef04Q+pPB+EyXhbgAUpvoR IKKA== X-Gm-Message-State: APt69E2q/ggUALpSk5DywYu9qDqaUFm8YkuQa1VCaY0S20WV4npvb6kB gxdDfIRMiurWlbLDZhkCKExf8A== X-Google-Smtp-Source: ADUXVKJkUS8RBSAgkB3g/WjIXRRiO9W1fQioQWMDo07PrK219S5H8YpIwm4qSi17RpY5hS8igq1M6g== X-Received: by 2002:a6b:1d4b:: with SMTP id d72-v6mr1773254iod.190.1528781216457; Mon, 11 Jun 2018 22:26:56 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([100.67.80.24]) by smtp.gmail.com with ESMTPSA id i10-v6sm136720itb.38.2018.06.11.22.26.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 22:26:55 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id 6A4F713FDBE; Mon, 11 Jun 2018 23:26:54 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 11 Jun 2018 23:26:36 -0600 Message-Id: <20180612052646.109214-4-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180612052646.109214-1-sjg@chromium.org> References: <20180612052646.109214-1-sjg@chromium.org> Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v5 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 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 */