From patchwork Mon Jun 18 14:08:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930883 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418Xyl565tz9s2t for ; Tue, 19 Jun 2018 00:09:19 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 5A4BBC21DDC; Mon, 18 Jun 2018 14:09:03 +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 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 9BD52C21E7D; Mon, 18 Jun 2018 14:08:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 68A9DC21E2C; Mon, 18 Jun 2018 14:08:47 +0000 (UTC) Received: from mail-qk0-f201.google.com (mail-qk0-f201.google.com [209.85.220.201]) by lists.denx.de (Postfix) with ESMTPS id 9D32BC21E36 for ; Mon, 18 Jun 2018 14:08:43 +0000 (UTC) Received: by mail-qk0-f201.google.com with SMTP id y184-v6so14467835qka.18 for ; Mon, 18 Jun 2018 07:08:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=8XWQGl4Vz2zr/Zb6RMJTLdPSS8Vtjxw1MIEoIHKIJGM=; b=siiFpkhH5OjQd7MCz0WrfHggj8/LrIfg43TUdFbwNKYltWzUrHXCJgnZnmHJ0qrkyL h+3PZUMTGOr2EKcE/QNx++ZDn0zsbEYu9tGbohymdRPp0kFFotl1yxT3bCuap42kzltk 5INnDwvoaqncDmONgz6WV/NVLVaqIUP/1eLJdFZIKsHSvBvG1brG9hsM5nxD2hzBr0QO 4rmBlMrGOfpaLGjB+0Rq6qcFX1snSJId+6rfiHrZsZPrZQ7xmZV794P8yc+CXn8w0E/K U3EH7vq5dGgEHKMgP1V14ZQQ1Bvh8VkxfSCUb4VKuhh0H0SMk65MJq6mZrNgD1KUqicw eEUA== X-Gm-Message-State: APt69E1Mp340hQ0pF4LNp3H3EpzM/WW38am/xIDZnRszhEdvcrMvg6Ml Txf1+lEcLNRZTqlgq5vdiuDVSY4= X-Google-Smtp-Source: ADUXVKJznvM58oNOHJXBB2GWXao0AaXCk9aotsb7AjSICJwGhRu4zO/n7daTRzByl4+Z3cGNeFX1pi8= MIME-Version: 1.0 X-Received: by 2002:a0c:8764:: with SMTP id 33-v6mr6825111qvi.15.1529330922385; Mon, 18 Jun 2018 07:08:42 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:06 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-2-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 01/30] efi: Don't allow CMD_BOOTEFI_SELFTEST on 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This does not work at present and gives the following error: output: 'ld.bfd: read in flex scanner failed scripts/Makefile.lib:390: recipe for target 'lib/efi_selftest/efi_selftest_miniapp_return_efi.so' failed It may be possible to figure this out with suitable linker magic but it does not seem to be easy. Also, we will be able to run the tests on sandbox without using the miniapp. So for now at least, disable this option. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: - Add new patch to disallow CMD_BOOTEFI_SELFTEST on sandbox Changes in v4: None Changes in v3: None Changes in v2: None lib/efi_selftest/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_selftest/Kconfig b/lib/efi_selftest/Kconfig index 59f9f36801..b52696778d 100644 --- a/lib/efi_selftest/Kconfig +++ b/lib/efi_selftest/Kconfig @@ -1,6 +1,6 @@ config CMD_BOOTEFI_SELFTEST bool "Allow booting an EFI efi_selftest" - depends on CMD_BOOTEFI + depends on CMD_BOOTEFI && !SANDBOX imply FAT imply FAT_WRITE help From patchwork Mon Jun 18 14:08:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930887 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418Y140SfHz9ryk for ; Tue, 19 Jun 2018 00:11:19 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id A57B8C21E6A; Mon, 18 Jun 2018 14:09:20 +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 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 60E59C21E8A; Mon, 18 Jun 2018 14:08:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2E5F0C21E73; Mon, 18 Jun 2018 14:08:50 +0000 (UTC) Received: from mail-yw0-f202.google.com (mail-yw0-f202.google.com [209.85.161.202]) by lists.denx.de (Postfix) with ESMTPS id CB0E1C21DFD for ; Mon, 18 Jun 2018 14:08:46 +0000 (UTC) Received: by mail-yw0-f202.google.com with SMTP id t132-v6so12760786ywa.6 for ; Mon, 18 Jun 2018 07:08:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=ND4aX4F4Fdpo4bEE/RyGZqiA5NP3by/G2iUTLwBHLjA=; b=TeBonQyoNYxA6GyEmaoO7fZo4BvvuhUQkIKIbcrlp2iHJHtSXW+DCiiSIyT5RicRsO yLjZoISUA1lD+mrSWTVRSmWImghvCDLkBeEzAc5R6leLMkz3QWFN/JeJos3nShoLnSFp 9XI2b+9k3lAV6Ayy/ZJNeaejLl4ez+7VeFVdScmeEH6ZkrY9OdpS9H0wi24LTR8+KSZE M5eJVJLIIydNIcqY7hM+ZvN2/1e+TwnPF8de40wmDyMoNG2SxMIQMUuaPyaeSKeIZ2PH 70Zi7ttAALhFYBQeCm4Tm8e/NsdNRkyPsQ0FW4AHQoeKVwP6n7veFbtFlRrnN/tSP2P8 wqLg== X-Gm-Message-State: APt69E1jcjlCG4clkhXQ+Ei4AN2xHOduQd/CbKbS9plJnDT42tczbo7n 8fk4Bc61Vx3dVCYyRPQ8zXpqv5I= X-Google-Smtp-Source: ADUXVKJCpgdIlJSp2Ytfaypy4+KXXR/tjLKhpGVP9j5ZaDILNXWJSFgu9ZHRrvJefZfIpIHpD4sExcg= MIME-Version: 1.0 X-Received: by 2002:a25:84d2:: with SMTP id x18-v6mr3504346ybm.30.1529330925651; Mon, 18 Jun 2018 07:08:45 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:07 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-3-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 02/30] 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: , 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 v8: None Changes in v7: - Move some of the code from efi_memory_init() into a separate function 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 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index ec66af98ea..c6410613c7 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; } @@ -496,14 +497,13 @@ __weak void efi_add_known_memory(void) } } -int efi_memory_init(void) +/* Add memory regions for U-Boot's memory and for the runtime services code */ +static void add_u_boot_and_runtime(void) { unsigned long runtime_start, runtime_end, runtime_pages; unsigned long uboot_start, uboot_pages; unsigned long uboot_stack_size = 16 * 1024 * 1024; - 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; @@ -516,6 +516,14 @@ int efi_memory_init(void) runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT; efi_add_memory_map(runtime_start, runtime_pages, EFI_RUNTIME_SERVICES_CODE, false); +} + +int efi_memory_init(void) +{ + efi_add_known_memory(); + + if (!IS_ENABLED(CONFIG_SANDBOX)) + add_u_boot_and_runtime(); #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER /* Request a 32bit 64MB bounce buffer region */ From patchwork Mon Jun 18 14:08:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930891 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418Y2Q4dGKz9ryk for ; Tue, 19 Jun 2018 00:12:30 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 48072C21E7F; Mon, 18 Jun 2018 14:10:27 +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=none 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 ACAF1C21EA2; Mon, 18 Jun 2018 14:09:39 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9F936C21E36; Mon, 18 Jun 2018 14:08:54 +0000 (UTC) Received: from mail-oi0-f74.google.com (mail-oi0-f74.google.com [209.85.218.74]) by lists.denx.de (Postfix) with ESMTPS id 79211C21E63 for ; Mon, 18 Jun 2018 14:08:49 +0000 (UTC) Received: by mail-oi0-f74.google.com with SMTP id l20-v6so7218213oii.1 for ; Mon, 18 Jun 2018 07:08:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=kpznMlr+gZBdAh9pbUrEnBF9Nt/gfbJa9oF9PG+HvN4=; b=j1FnLEAL/xeIUV3cK940ZYAPMlDb9sqI1re07ii4Ihk/GNH+ExMyikhToWcT4VVV3d QCoOylzpozsow8le0avKnqrDN8POZjNTvLaPhBfUyg6zHWOrXyLoDG5OBEJBEWDj45rz TjDYvHf/xmyJSbeJbiV1kFwAVm29Rvi4nDq8PHqXs+nAYp/jLmPU9kX2M9c6h2PMFL0O NbEiM8X+Y3y3Dtw6go7OTGZYNzaC8o/FAbEGLau3zk9weK2XG4s/6c/vpDkeZyQA8aJR keKkk1/N2bWOReLuOUYvuk3tXK/MuC0it8Hwt8FIl9hQ5P2ODClapQ4l4hO6PM3k2mvH qQbw== X-Gm-Message-State: APt69E0Gj9LKfgeR8OOuj9oZhTaQPown+Tw0hVZdtlDOZ2xP0d8ygi3F ZMmc0vosTJF3YqR9+nBT8Ft/F3M= X-Google-Smtp-Source: ADUXVKI0UU/dEN5ZIPa78L0Y1M66880CCvE8U0PyV/wLVqGMLyYbskO+U75iW1J0kWo1gYs4GUJ34dg= MIME-Version: 1.0 X-Received: by 2002:aca:d004:: with SMTP id h4-v6mr5341271oig.19.1529330928430; Mon, 18 Jun 2018 07:08:48 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:08 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-4-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 03/30] sandbox: smbios: Update to support 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" At present this code casts addresses to pointers so cannot be used with sandbox. Update it to use mapmem instead. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: - Drop incorrect map_sysmem() in write_smbios_table() Changes in v2: None lib/smbios.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/smbios.c b/lib/smbios.c index df3d26b071..fc3dabcbc1 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -72,9 +73,10 @@ static int smbios_string_table_len(char *start) static int smbios_write_type0(ulong *current, int handle) { - struct smbios_type0 *t = (struct smbios_type0 *)*current; + struct smbios_type0 *t; int len = sizeof(struct smbios_type0); + t = map_sysmem(*current, len); memset(t, 0, sizeof(struct smbios_type0)); fill_smbios_header(t, SMBIOS_BIOS_INFORMATION, len, handle); t->vendor = smbios_add_string(t->eos, "U-Boot"); @@ -101,16 +103,18 @@ static int smbios_write_type0(ulong *current, int handle) len = t->length + smbios_string_table_len(t->eos); *current += len; + unmap_sysmem(t); return len; } static int smbios_write_type1(ulong *current, int handle) { - struct smbios_type1 *t = (struct smbios_type1 *)*current; + struct smbios_type1 *t; int len = sizeof(struct smbios_type1); char *serial_str = env_get("serial#"); + t = map_sysmem(*current, len); memset(t, 0, sizeof(struct smbios_type1)); fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle); t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER); @@ -122,15 +126,17 @@ static int smbios_write_type1(ulong *current, int handle) len = t->length + smbios_string_table_len(t->eos); *current += len; + unmap_sysmem(t); return len; } static int smbios_write_type2(ulong *current, int handle) { - struct smbios_type2 *t = (struct smbios_type2 *)*current; + struct smbios_type2 *t; int len = sizeof(struct smbios_type2); + t = map_sysmem(*current, len); memset(t, 0, sizeof(struct smbios_type2)); fill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, handle); t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER); @@ -140,15 +146,17 @@ static int smbios_write_type2(ulong *current, int handle) len = t->length + smbios_string_table_len(t->eos); *current += len; + unmap_sysmem(t); return len; } static int smbios_write_type3(ulong *current, int handle) { - struct smbios_type3 *t = (struct smbios_type3 *)*current; + struct smbios_type3 *t; int len = sizeof(struct smbios_type3); + t = map_sysmem(*current, len); memset(t, 0, sizeof(struct smbios_type3)); fill_smbios_header(t, SMBIOS_SYSTEM_ENCLOSURE, len, handle); t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER); @@ -160,6 +168,7 @@ static int smbios_write_type3(ulong *current, int handle) len = t->length + smbios_string_table_len(t->eos); *current += len; + unmap_sysmem(t); return len; } @@ -198,9 +207,10 @@ static void smbios_write_type4_dm(struct smbios_type4 *t) static int smbios_write_type4(ulong *current, int handle) { - struct smbios_type4 *t = (struct smbios_type4 *)*current; + struct smbios_type4 *t; int len = sizeof(struct smbios_type4); + t = map_sysmem(*current, len); memset(t, 0, sizeof(struct smbios_type4)); fill_smbios_header(t, SMBIOS_PROCESSOR_INFORMATION, len, handle); t->processor_type = SMBIOS_PROCESSOR_TYPE_CENTRAL; @@ -214,32 +224,37 @@ static int smbios_write_type4(ulong *current, int handle) len = t->length + smbios_string_table_len(t->eos); *current += len; + unmap_sysmem(t); return len; } static int smbios_write_type32(ulong *current, int handle) { - struct smbios_type32 *t = (struct smbios_type32 *)*current; + struct smbios_type32 *t; int len = sizeof(struct smbios_type32); + t = map_sysmem(*current, len); memset(t, 0, sizeof(struct smbios_type32)); fill_smbios_header(t, SMBIOS_SYSTEM_BOOT_INFORMATION, len, handle); *current += len; + unmap_sysmem(t); return len; } static int smbios_write_type127(ulong *current, int handle) { - struct smbios_type127 *t = (struct smbios_type127 *)*current; + struct smbios_type127 *t; int len = sizeof(struct smbios_type127); + t = map_sysmem(*current, len); memset(t, 0, sizeof(struct smbios_type127)); fill_smbios_header(t, SMBIOS_END_OF_TABLE, len, handle); *current += len; + unmap_sysmem(t); return len; } @@ -268,7 +283,7 @@ ulong write_smbios_table(ulong addr) /* 16 byte align the table address */ addr = ALIGN(addr, 16); - se = (struct smbios_entry *)(uintptr_t)addr; + se = map_sysmem(addr, sizeof(struct smbios_entry)); memset(se, 0, sizeof(struct smbios_entry)); addr += sizeof(struct smbios_entry); @@ -297,6 +312,7 @@ ulong write_smbios_table(ulong addr) isize = sizeof(struct smbios_entry) - SMBIOS_INTERMEDIATE_OFFSET; se->intermediate_checksum = table_compute_checksum(istart, isize); se->checksum = table_compute_checksum(se, sizeof(struct smbios_entry)); + unmap_sysmem(se); return addr; } From patchwork Mon Jun 18 14:08:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930889 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418Y200G4Cz9ryk for ; Tue, 19 Jun 2018 00:12:07 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id A1932C21E70; Mon, 18 Jun 2018 14:10:10 +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 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 99544C21DFD; Mon, 18 Jun 2018 14:09:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C80CFC21EBF; Mon, 18 Jun 2018 14:08:56 +0000 (UTC) Received: from mail-ua0-f201.google.com (mail-ua0-f201.google.com [209.85.217.201]) by lists.denx.de (Postfix) with ESMTPS id D74E4C21E52 for ; Mon, 18 Jun 2018 14:08:52 +0000 (UTC) Received: by mail-ua0-f201.google.com with SMTP id c26-v6so5717666uam.19 for ; Mon, 18 Jun 2018 07:08:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=uA1CP1CeoMdpbrXL1ZcuHoGpPYlhoDu98VONhEqvSNA=; b=J8MBD7U7ZeYk8SZcFP2tbkKa2jCz0O8YuppuyPdvoqMNbYITZa97dHickOChxYRj7G Gibar9vjriu/nWQHGEaHYJuM0BEgwXFxYrFMf7smejeixxj/l58utR0K6jgI2VD7qZky SDt4v4wXI5IS9rJKmEnqFbswLJwIIt3XQXz61FMPJxQCb6UwGItke9Y/R6SJ192WxENZ TRoNyon/ZNMH5JREVXnbxGlfN+TBg43NlmDIpk5CAaDD7jEr+7XoAYv+nZ8XQI/f7tJq VTwLuZAujU3C8RdvFIbW3utbn8b5zr2e3ZsZWBY/aNTC4jrU7sMqvpWgpBWE0CA1JpcE 10HQ== X-Gm-Message-State: APt69E37YpS0O9484w3r0BqVFLpaFzPYzjvkhwMCfGtMV+77WDaxrWwQ BC8/mjp6YerBIQAFMNLjlTrqN4w= X-Google-Smtp-Source: ADUXVKJ5Sk48UU05Az+pWA/DKI2PqmjpUz+eJuKoBaRXnZJSWV/EzUV/utvtz2/Yun7QfyyDbTDGMMY= MIME-Version: 1.0 X-Received: by 2002:ab0:500a:: with SMTP id b10-v6mr5557970uaa.112.1529330931606; Mon, 18 Jun 2018 07:08:51 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:09 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-5-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 04/30] efi: sandbox: Add distroboot support 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" With sandbox these values depend on the host system. Let's assume that it is x86_64 for now. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: - Drop an unnecessary comment Changes in v6: - Warn about building sandbox EFI support on something other than __x86_64__ Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None include/config_distro_bootcmd.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index d672e8ebe6..75866f2abf 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -261,6 +261,17 @@ #elif defined(CONFIG_CPU_RISCV_64) #define BOOTENV_EFI_PXE_ARCH "0x1b" #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00027:UNDI:003000" +#elif defined(CONFIG_SANDBOX) +/* + * TODO(sjg@chromium.org): Consider providing a way to enable sandbox features + * based on the host architecture + */ +# ifndef __x86_64__ +# warning "sandbox EFI support is only tested on 64-bit x86" +# endif +/* To support other *host* architectures this should be changed */ +#define BOOTENV_EFI_PXE_ARCH "0x7" +#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00007:UNDI:003000" #else #error Please specify an EFI client identifier #endif From patchwork Mon Jun 18 14:08:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930886 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418Xzx5X95z9ryk for ; Tue, 19 Jun 2018 00:10:21 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 53731C21E70; Mon, 18 Jun 2018 14:09:37 +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=none 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 6BA0AC21D65; Mon, 18 Jun 2018 14:09:16 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D27D2C21E70; Mon, 18 Jun 2018 14:08:59 +0000 (UTC) Received: from mail-io0-f201.google.com (mail-io0-f201.google.com [209.85.223.201]) by lists.denx.de (Postfix) with ESMTPS id 8F379C21E42 for ; Mon, 18 Jun 2018 14:08:55 +0000 (UTC) Received: by mail-io0-f201.google.com with SMTP id g22-v6so13525453ioh.5 for ; Mon, 18 Jun 2018 07:08:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=zlzB1tN1en5wawnn0gGLdiT2a1k4+hPppfrpvZi7Sc8=; b=I0jT5wCSoFt9ZKPF8mAeWw/eZ8a/9CvfDeNbbkOtxiEMJ9IZLeb3LL4IvyQTKql3cV rokiHI8oovR1X+icCzgUbSsexGqJ/dlGlI0NfccVv+IxV9pVPNgNG35Ut/jVR+uxsWoc sRx52LJ1ChbaT5LHsvp1k8EcaX0kqmb7A6LrhWjnABN1/HxREdxbyAlBTU9IRNt1caz7 M/ULw0SnbgKveGjEWlAZGGjUEWg5bmpwBPVOZ6TRmUc/jXnBIBOqmmdbh0n5g79X1xPv 8UeiQMMVc6hgIsT8bUh0fSyCsu2y0ztC9lNf+Tcp8HallTSCkgFFN201kOUHp+ELHkql x7lQ== X-Gm-Message-State: APt69E30MveyqbVS3KKXZyV0/6C50J1LGkQqNA3WSNxWIxHrX7t1cojz NhmwukGXlW6xZNgHhnD8lpYQBAE= X-Google-Smtp-Source: ADUXVKJDSRD0EEW0E295nHqSizV0c9hBBPT256qRl1eeDM+eQYK/cRaEgd/dq0Gb7m1lBduKyaWxKjY= MIME-Version: 1.0 X-Received: by 2002:a24:5b02:: with SMTP id g2-v6mr4996880itb.44.1529330934598; Mon, 18 Jun 2018 07:08:54 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:10 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-6-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 05/30] efi: sandbox: Add relocation constants 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" Add these so that we can build the EFI loader for sandbox. The values are for x86_64 so potentially bogus. But we don't support relocation within sandbox anyway. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: - Drop an unnecessary comment Changes in v6: - Warn about building sandbox EFI support on something other than __x86_64__ Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None lib/efi_loader/efi_runtime.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 4874eb602f..10a7878a1c 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -62,6 +62,17 @@ struct dyn_sym { #define R_ABSOLUTE R_RISCV_64 #define SYM_INDEX 32 #endif + +#elif defined(CONFIG_SANDBOX) +/* + * TODO(sjg@chromium.org): Consider providing a way to enable sandbox features + * based on the host architecture + */ +# ifndef __x86_64__ +# warning "sandbox EFI support is only tested on 64-bit x86" +# endif +#define R_RELATIVE 8 +#define R_MASK 0xffffffffULL #else #error Need to add relocation awareness #endif From patchwork Mon Jun 18 14:08:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930917 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YGT6k1Gz9ryk for ; Tue, 19 Jun 2018 00:22:57 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 7FB84C21DDC; Mon, 18 Jun 2018 14:09:53 +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 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 A489FC21E13; Mon, 18 Jun 2018 14:09:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B9108C21E15; Mon, 18 Jun 2018 14:09:01 +0000 (UTC) Received: from mail-qt0-f202.google.com (mail-qt0-f202.google.com [209.85.216.202]) by lists.denx.de (Postfix) with ESMTPS id 82502C21E50 for ; Mon, 18 Jun 2018 14:08:58 +0000 (UTC) Received: by mail-qt0-f202.google.com with SMTP id i7-v6so14116565qtp.4 for ; Mon, 18 Jun 2018 07:08:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=WP+CP3rQg0/NJPVC7CGlDTM4iGQkd7YJohVPxWyW4xY=; b=IrY5mgcIQe6jBWngsbd4zLJmyrvmru7NmibLaD6+6dmoZiVqrH11S5YtT5T0UHWtIF T+T0Yi/DlILo984awH2S8jUGTOIXwBJZQ6fz2eEIxVkER1HRJhPBsrGkW5i4jA8E3J52 3k1F/6knjALFGGl+MdCePp961jAHTcADARbxvaSdkJXi2797D+lhUkkwuUp9ta8+JwA+ YEBkkbIL0sr9gTFTDNUjfrQ6oUFXPbAvosdyqi1a/B53N4TXX50h1MglNz69hgoIlsgz NFjHiUtJXah8iSlylkCDg3qe5KNl3chl+QsUkJPl971Nt7Z9cp6XLMj7g/YS2mUayxeZ jhHg== X-Gm-Message-State: APt69E0TJijOJAy/d8LHEY5Ij9qiMk4YutyAGf8w7cW1xteZJaFuhi5V 1tRNkE+jVbBuMcg/oG5j0vY1DAc= X-Google-Smtp-Source: ADUXVKIGxOu0ulQ6hnup8bm/iXsZLeXnNVoHR4yvtFAbp0yBMGvJwazDisAHcR+zw4gez/0kSSUhOLM= MIME-Version: 1.0 X-Received: by 2002:aed:3c72:: with SMTP id u47-v6mr6944965qte.45.1529330937526; Mon, 18 Jun 2018 07:08:57 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:11 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-7-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 06/30] efi: sandbox: Enable EFI loader build 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This allows this feature to build within sandbox. This is for testing purposes only since it is not possible for sandbox to load native code. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: - Update patch subject s/builder/build/ Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: - Init the 'rows' and 'cols' vars to avoid a compiler error (gcc 4.8.4) Changes in v2: None lib/efi_loader/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index df58e633d1..d471e6f4a4 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -1,6 +1,6 @@ config EFI_LOADER bool "Support running EFI Applications in U-Boot" - depends on (ARM || X86 || RISCV) && OF_LIBFDT + depends on (ARM || X86 || RISCV || SANDBOX) && OF_LIBFDT # We do not support bootefi booting ARMv7 in non-secure mode depends on !ARMV7_NONSEC # We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB From patchwork Mon Jun 18 14:08:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930909 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418Y9D3M8zz9s2t for ; Tue, 19 Jun 2018 00:18:24 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 3260FC21E42; Mon, 18 Jun 2018 14:13:15 +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 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 1E655C21E38; Mon, 18 Jun 2018 14:11:24 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2F530C21DFD; Mon, 18 Jun 2018 14:09:04 +0000 (UTC) Received: from mail-qk0-f202.google.com (mail-qk0-f202.google.com [209.85.220.202]) by lists.denx.de (Postfix) with ESMTPS id 64E54C21DFF for ; Mon, 18 Jun 2018 14:09:01 +0000 (UTC) Received: by mail-qk0-f202.google.com with SMTP id 5-v6so14835641qke.19 for ; Mon, 18 Jun 2018 07:09:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=M6LyKf13vM/WpjGew+OlM6ILV1d9Wj2HIgaL6gXLZZo=; b=IFDHTewKC/8N9IlVWuQwwlsOu2vYlGVbUw9tiQxJfFtuIe5SpkaiDmIwNx+HpgVlAH /Wbmr4n18jpCtIAwH/eR+9pC5ER2kWdVJ81p9dhQWKjhWtxD6nLehfX9eDKcfuUpcisa 03TKK6/FQmpMDUZ07QFezVRC1rANEPMJyv32+KDWTOMfzAYP/7H5tgWQj2ol1qWkeoPy kJmZMfjQ88xkAODElbVNkt5ZyCP7niKZ9aJIEs5Zj895ipwD8jHgy3M8xKAi/c5nVIRw 7vXj+5xMl8TNd/FXio6nJObGSc3sQgiliJLk9mTffPSqINRRtY/7RaKMfvSudMO4T9Ew /Vgw== X-Gm-Message-State: APt69E2g6hWT1eVAfzpSMLYHy6d1Be/fHh/MG2QP/EYf/ZpmCZO12CIr nsdyjK3O5sWfEg0wJwfkxLl5g08= X-Google-Smtp-Source: ADUXVKL4bVcqJ7LxDmVYDnpvyitKESCDiJ/PMIi+fVronJwRA8B0MKHcBCNT5Ec2FfD93rhxwI8xKkg= MIME-Version: 1.0 X-Received: by 2002:a0c:868a:: with SMTP id 10-v6mr6924917qvf.56.1529330940550; Mon, 18 Jun 2018 07:09:00 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:12 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-8-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 07/30] efi: Split out test init/uninit into functions 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" We plan to run more than one EFI test. In order to avoid duplicating code, create functions which handle preparing for running the test and cleaning up afterwards. Also shorten the awfully long variable names here. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: - Drop call to efi_init_obj_list() which is now done in do_bootefi() Changes in v4: None Changes in v3: - Add new patch to split out test init/uninit into functions Changes in v2: None cmd/bootefi.c | 87 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 63 insertions(+), 24 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index f55a40dc84..2dfd297e78 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -356,6 +356,60 @@ exit: return ret; } +#ifdef CONFIG_CMD_BOOTEFI_SELFTEST +/** + * bootefi_test_prepare() - prepare to run an EFI test + * + * This sets things up so we can call EFI functions. This involves preparing + * the 'gd' pointer and setting up the load ed image data structures. + * + * @image: Pointer to a struct which will hold the loaded image info + * @obj: Pointer to a struct which will hold the loaded image object + * @path: File path to the test being run (often just the test name with a + * backslash before it + * @test_func: Address of the test function that is being run + * @return 0 if OK, -ve on error + */ +static efi_status_t bootefi_test_prepare(struct efi_loaded_image *image, + struct efi_object *obj, + const char *path, ulong test_func) +{ + memset(image, '\0', sizeof(*image)); + memset(obj, '\0', sizeof(*obj)); + /* Construct a dummy device path */ + bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, + (uintptr_t)test_func, + (uintptr_t)test_func); + bootefi_image_path = efi_dp_from_file(NULL, 0, path); + efi_setup_loaded_image(image, obj, bootefi_device_path, + bootefi_image_path); + /* + * gd lives in a fixed register which may get clobbered while we execute + * the payload. So save it here and restore it on every callback entry + */ + efi_save_gd(); + + /* Transfer environment variable efi_selftest as load options */ + set_load_options(image, "efi_selftest"); + + return 0; +} + +/** + * bootefi_test_finish() - finish up after running an EFI test + * + * @image: Pointer to a struct which holds the loaded image info + * @obj: Pointer to a struct which holds the loaded image object + */ +static void bootefi_test_finish(struct efi_loaded_image *image, + struct efi_object *obj) +{ + efi_restore_gd(); + free(image->load_options); + list_del(&obj->link); +} +#endif /* CONFIG_CMD_BOOTEFI_SELFTEST */ + static int do_bootefi_bootmgr_exec(void) { struct efi_device_path *device_path, *file_path; @@ -434,31 +488,16 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #endif #ifdef CONFIG_CMD_BOOTEFI_SELFTEST if (!strcmp(argv[1], "selftest")) { - struct efi_loaded_image loaded_image_info = {}; - struct efi_object loaded_image_info_obj = {}; - - /* Construct a dummy device path. */ - bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, - (uintptr_t)&efi_selftest, - (uintptr_t)&efi_selftest); - bootefi_image_path = efi_dp_from_file(NULL, 0, "\\selftest"); - - efi_setup_loaded_image(&loaded_image_info, - &loaded_image_info_obj, - bootefi_device_path, bootefi_image_path); - /* - * gd lives in a fixed register which may get clobbered while we - * execute the payload. So save it here and restore it on every - * callback entry - */ - efi_save_gd(); - /* Transfer environment variable efi_selftest as load options */ - set_load_options(&loaded_image_info, "efi_selftest"); + struct efi_loaded_image image; + struct efi_object obj; + + if (bootefi_test_prepare(&image, &obj, "\\selftest", + (uintptr_t)&efi_selftest)) + return CMD_RET_FAILURE; + /* Execute the test */ - r = efi_selftest(loaded_image_info_obj.handle, &systab); - efi_restore_gd(); - free(loaded_image_info.load_options); - list_del(&loaded_image_info_obj.link); + r = efi_selftest(obj.handle, &systab); + bootefi_test_finish(&image, &obj); return r != EFI_SUCCESS; } else #endif From patchwork Mon Jun 18 14:08:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930901 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418Y6Y3D5Dz9s3M for ; Tue, 19 Jun 2018 00:16:05 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 238E7C21E88; Mon, 18 Jun 2018 14:13: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 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 F1259C21EF0; Mon, 18 Jun 2018 14:11:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D6531C21E68; Mon, 18 Jun 2018 14:09:07 +0000 (UTC) Received: from mail-qk0-f202.google.com (mail-qk0-f202.google.com [209.85.220.202]) by lists.denx.de (Postfix) with ESMTPS id 1D7FCC21E79 for ; Mon, 18 Jun 2018 14:09:04 +0000 (UTC) Received: by mail-qk0-f202.google.com with SMTP id i64-v6so14860416qkh.14 for ; Mon, 18 Jun 2018 07:09:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=RWAA8txax5WYoPt0L4WvyTD86YUFg3+GT7YVMZXJSik=; b=DfK0ZG3q/IZRXy0S5syOvQ+yj1OV0Xz4DX0kp6iK5iT0x8jnjaFGVy45og8IOiMXOA dgnz7DuJNUXtqSMH+ifP3U4plAdVx6a+EODy+x+J9Ai2fysV7mjjKIoyT9mwgw1FVK9Q J42TPTFMwd/RvxrodyMVkzbetsmq/kurrXjnR6NnJW/j/rUUtnSYfYcHwL60g7R9PsDH g+3SIovFOm4APNeZqyQvGHl0iSpch7neCqrob1iMUHJnYVjiDBYwDy9oqsCf/BVC7E12 yroMUZNBKu53kMBA91M6cZiQ3dQSGrPR55w56rOuft8cRzVnqJz9KPDg1J0k0c+1gk/P T0hQ== X-Gm-Message-State: APt69E1K+e/tnMVHk4UiKy+3MLcFnXZhmtIlH7icm/5Wm8HMgWEXm4nG 7T+5XrHwAAsm2oI4i4z6/CewJ0w= X-Google-Smtp-Source: ADUXVKIqfMAl7Z6N4eLOEypEZNRw5SCBdxgcyS7qVf8daI5/n8WtVbg4as14HZ1mOsrdsG+hxBidG+I= MIME-Version: 1.0 X-Received: by 2002:a0c:9628:: with SMTP id 37-v6mr6896472qvx.38.1529330943258; Mon, 18 Jun 2018 07:09:03 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:13 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-9-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 08/30] efi: sandbox: Add a simple 'bootefi test' command 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 jumps to test code which can call directly into the EFI support. It does not need a separate image so it is easy to write tests with it. This test can be executed without causing problems to the run-time environemnt (e.g. U-Boot does not need to reboot afterwards). For now the test just outputs a message. To try it: ./sandbox/u-boot -c "bootefi test" U-Boot 2017.09-00204-g696c9855fe (Sep 17 2017 - 16:43:53 -0600) DRAM: 128 MiB MMC: Using default environment In: serial Out: serial Err: serial SCSI: Net: No ethernet found. IDE: Bus 0: not available Found 0 disks WARNING: booting without device tree Hello, world! Test passed Signed-off-by: Simon Glass --- Changes in v8: - Expand series substantially to support bootefi selftest - Rebase to master Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: - Rebase to master - Update SPDX tags Changes in v3: - Rebase to master Changes in v2: - Rebase to master cmd/bootefi.c | 26 ++++++++++++++++++++------ include/efi_loader.h | 3 +++ lib/efi_loader/Kconfig | 10 ++++++++++ lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_test.c | 16 ++++++++++++++++ 5 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 lib/efi_loader/efi_test.c diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 2dfd297e78..7faa3ea245 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -356,7 +356,6 @@ exit: return ret; } -#ifdef CONFIG_CMD_BOOTEFI_SELFTEST /** * bootefi_test_prepare() - prepare to run an EFI test * @@ -408,7 +407,6 @@ static void bootefi_test_finish(struct efi_loaded_image *image, free(image->load_options); list_del(&obj->link); } -#endif /* CONFIG_CMD_BOOTEFI_SELFTEST */ static int do_bootefi_bootmgr_exec(void) { @@ -440,8 +438,10 @@ static int do_bootefi_bootmgr_exec(void) /* Interpreter command to boot an arbitrary EFI image from memory */ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - unsigned long addr; + struct efi_loaded_image image; + struct efi_object obj; char *saddr; + unsigned long addr; efi_status_t r; void *fdt_addr; @@ -486,11 +486,25 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) memcpy((char *)addr, __efi_helloworld_begin, size); } else #endif + if (IS_ENABLED(CONFIG_BOOTEFI_TEST) && !strcmp(argv[1], "test")) { + int ret; + + if (bootefi_test_prepare(&image, &obj, "\\test", + (ulong)&efi_test)) + return CMD_RET_FAILURE; + + ret = efi_test(&image, &systab); + bootefi_test_finish(&image, &obj); + if (ret) { + printf("Test failed: err=%d\n", ret); + return CMD_RET_FAILURE; + } + printf("Test passed\n"); + + return 0; + } #ifdef CONFIG_CMD_BOOTEFI_SELFTEST if (!strcmp(argv[1], "selftest")) { - struct efi_loaded_image image; - struct efi_object obj; - if (bootefi_test_prepare(&image, &obj, "\\selftest", (uintptr_t)&efi_selftest)) return CMD_RET_FAILURE; diff --git a/include/efi_loader.h b/include/efi_loader.h index c66252a7dd..0615cfac85 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -442,6 +442,9 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, efi_guid_t *vendor, void *efi_bootmgr_load(struct efi_device_path **device_path, struct efi_device_path **file_path); +/* Perform EFI tests */ +int efi_test(efi_handle_t image_handle, struct efi_system_table *systab); + #else /* defined(EFI_LOADER) && !defined(CONFIG_SPL_BUILD) */ /* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */ diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index d471e6f4a4..110dcb23c9 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -25,3 +25,13 @@ config EFI_LOADER_BOUNCE_BUFFER Some hardware does not support DMA to full 64bit addresses. For this hardware we can create a bounce buffer so that payloads don't have to worry about platform details. + +config BOOTEFI_TEST + bool "Provide a test for the EFI loader" + depends on EFI_LOADER && SANDBOX + default y + help + Provides a test of the EFI loader functionality accessed via the + command line ('bootefi test'). This runs within U-Boot so does not + need a separate EFI application to work. It aims to include coverage + of all EFI code which can be accessed within sandbox. diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index c6046e36d2..2da28f9c90 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -23,3 +23,4 @@ obj-$(CONFIG_DM_VIDEO) += efi_gop.o obj-$(CONFIG_PARTITIONS) += efi_disk.o obj-$(CONFIG_NET) += efi_net.o obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o +obj-$(CONFIG_BOOTEFI_TEST) += efi_test.o diff --git a/lib/efi_loader/efi_test.c b/lib/efi_loader/efi_test.c new file mode 100644 index 0000000000..4b8d49f324 --- /dev/null +++ b/lib/efi_loader/efi_test.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2017, Google Inc. + */ + +#include +#include + +int efi_test(efi_handle_t image_handle, struct efi_system_table *systable) +{ + struct efi_simple_text_output_protocol *con_out = systable->con_out; + + con_out->output_string(con_out, L"Hello, world!\n"); + + return 0; +} From patchwork Mon Jun 18 14:08:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930904 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418Y7n3Lnhz9ryk for ; Tue, 19 Jun 2018 00:17:09 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 3903DC21E38; Mon, 18 Jun 2018 14:11:19 +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 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 3C3F4C21DFA; Mon, 18 Jun 2018 14:10:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3F050C21DFA; Mon, 18 Jun 2018 14:09:10 +0000 (UTC) Received: from mail-yb0-f201.google.com (mail-yb0-f201.google.com [209.85.213.201]) by lists.denx.de (Postfix) with ESMTPS id EE2EBC21E2C for ; Mon, 18 Jun 2018 14:09:06 +0000 (UTC) Received: by mail-yb0-f201.google.com with SMTP id r2-v6so12216180ybg.3 for ; Mon, 18 Jun 2018 07:09:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=T5WWvLWVMPhk/ZeOVL0YxxX9UU9FmH1LnvXHzll9HkI=; b=OMRwAFbJwkej6J2fYr9uMer00qdJTyemdUHafwr8Fdteza8t2qM71pKr60xZkrQJxf 0NRvZnh27ZemXL01ZLAsxxOXxSVP0ZZHZnMsiyc49QFQgSeD3p8ymIKhczyhj0P+G/js 6jrY2OX08Kg2DMBwSxkOn5kXWpOo5Zd2uGUc/6q6IJwmwbQ5v+hJvqeP9lOyNBT9BvOi 1kBW+VADYuICkcomGe1jxFpbM06BfC5YkQp5CGvIlFAkHvo+4oH7F5lYBAE4i03soWYW y/+HmIx/Yju6dfHLD/xvATw+t5/RPU19US/JtICDEc4ulTB5Ysc527bWRCOiImfOTBxD /ezg== X-Gm-Message-State: APt69E0oeO2Ueon8i5nEZ6M7j/BWTcWV1uIauqIuzazqIJwz5+cB3TyC 3nA9oWPVvE2E66Xsy0gmYDTJvoQ= X-Google-Smtp-Source: ADUXVKISKKuVLMsnZTwM5ZrQbTyXXuJsMdhUB7WMcVdQu799la2ocAvh0TMlo0HDlxGC5cz+JmJGEuY= MIME-Version: 1.0 X-Received: by 2002:a25:808e:: with SMTP id n14-v6mr3459817ybk.34.1529330946011; Mon, 18 Jun 2018 07:09:06 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:14 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-10-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 09/30] efi: Create a function to set up for running EFI code 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" Add a new bootefi_run_prepare() function which holds common code used to set up U-Boot to run EFI code. Make use of this from the existing bootefi_test_prepare() function, as well as do_bootefi_exec(). Also shorten a few variable names. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: - Drop call to efi_init_obj_list() which is now done in do_bootefi() - Introduce load_options_path to specifyc U-Boot env var for load_options_path Changes in v4: - Rebase to master Changes in v3: - Add patch to create a function to set up for running EFI code Changes in v2: None cmd/bootefi.c | 79 ++++++++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 7faa3ea245..c174e5e8fc 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -253,6 +253,26 @@ static efi_status_t efi_install_fdt(void *fdt) return ret; } +static efi_status_t bootefi_run_prepare(struct efi_loaded_image *image, + struct efi_object *obj, + const char *load_options_path, + struct efi_device_path *device_path, + struct efi_device_path *image_path) +{ + efi_setup_loaded_image(image, obj, device_path, image_path); + + /* + * gd lives in a fixed register which may get clobbered while we execute + * the payload. So save it here and restore it on every callback entry + */ + efi_save_gd(); + + /* Transfer environment variable as load options */ + set_load_options(image, load_options_path); + + return 0; +} + /* * Load an EFI payload into a newly allocated piece of memory, register all * EFI objects it would want to access and jump to it. @@ -261,8 +281,8 @@ static efi_status_t do_bootefi_exec(void *efi, struct efi_device_path *device_path, struct efi_device_path *image_path) { - struct efi_loaded_image loaded_image_info = {}; - struct efi_object loaded_image_info_obj = {}; + struct efi_loaded_image image; + struct efi_object obj; struct efi_object mem_obj = {}; struct efi_device_path *memdp = NULL; efi_status_t ret; @@ -290,19 +310,13 @@ static efi_status_t do_bootefi_exec(void *efi, assert(device_path && image_path); } - efi_setup_loaded_image(&loaded_image_info, &loaded_image_info_obj, - device_path, image_path); + ret = bootefi_run_prepare(&image, &obj, "bootargs", device_path, + image_path); + if (ret) + return ret; - /* - * gd lives in a fixed register which may get clobbered while we execute - * the payload. So save it here and restore it on every callback entry - */ - efi_save_gd(); - - /* Transfer environment variable bootargs as load options */ - set_load_options(&loaded_image_info, "bootargs"); /* Load the EFI payload */ - entry = efi_load_pe(efi, &loaded_image_info); + entry = efi_load_pe(efi, &image); if (!entry) { ret = EFI_LOAD_ERROR; goto exit; @@ -310,10 +324,10 @@ static efi_status_t do_bootefi_exec(void *efi, if (memdp) { struct efi_device_path_memory *mdp = (void *)memdp; - mdp->memory_type = loaded_image_info.image_code_type; - mdp->start_address = (uintptr_t)loaded_image_info.image_base; + mdp->memory_type = image.image_code_type; + mdp->start_address = (uintptr_t)image.image_base; mdp->end_address = mdp->start_address + - loaded_image_info.image_size; + image.image_size; } /* we don't support much: */ @@ -323,8 +337,8 @@ static efi_status_t do_bootefi_exec(void *efi, /* Call our payload! */ debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry); - if (setjmp(&loaded_image_info.exit_jmp)) { - ret = loaded_image_info.exit_status; + if (setjmp(&image.exit_jmp)) { + ret = image.exit_status; goto exit; } @@ -336,7 +350,7 @@ static efi_status_t do_bootefi_exec(void *efi, /* Move into EL2 and keep running there */ armv8_switch_to_el2((ulong)entry, - (ulong)&loaded_image_info_obj.handle, + (ulong)&obj.handle, (ulong)&systab, 0, (ulong)efi_run_in_el2, ES_TO_AARCH64); @@ -345,11 +359,11 @@ static efi_status_t do_bootefi_exec(void *efi, } #endif - ret = efi_do_enter(loaded_image_info_obj.handle, &systab, entry); + ret = efi_do_enter(obj.handle, &systab, entry); exit: /* image has returned, loaded-image obj goes *poof*: */ - list_del(&loaded_image_info_obj.link); + list_del(&obj.link); if (mem_obj.handle) list_del(&mem_obj.link); @@ -367,11 +381,13 @@ exit: * @path: File path to the test being run (often just the test name with a * backslash before it * @test_func: Address of the test function that is being run + * @load_options_path: U-Boot environment variable to use as load options * @return 0 if OK, -ve on error */ static efi_status_t bootefi_test_prepare(struct efi_loaded_image *image, struct efi_object *obj, - const char *path, ulong test_func) + const char *path, ulong test_func, + const char *load_options_path) { memset(image, '\0', sizeof(*image)); memset(obj, '\0', sizeof(*obj)); @@ -380,18 +396,8 @@ static efi_status_t bootefi_test_prepare(struct efi_loaded_image *image, (uintptr_t)test_func, (uintptr_t)test_func); bootefi_image_path = efi_dp_from_file(NULL, 0, path); - efi_setup_loaded_image(image, obj, bootefi_device_path, - bootefi_image_path); - /* - * gd lives in a fixed register which may get clobbered while we execute - * the payload. So save it here and restore it on every callback entry - */ - efi_save_gd(); - - /* Transfer environment variable efi_selftest as load options */ - set_load_options(image, "efi_selftest"); - - return 0; + return bootefi_run_prepare(image, obj, load_options_path, + bootefi_device_path, bootefi_image_path); } /** @@ -490,7 +496,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int ret; if (bootefi_test_prepare(&image, &obj, "\\test", - (ulong)&efi_test)) + (ulong)&efi_test, "efi_test")) return CMD_RET_FAILURE; ret = efi_test(&image, &systab); @@ -506,7 +512,8 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #ifdef CONFIG_CMD_BOOTEFI_SELFTEST if (!strcmp(argv[1], "selftest")) { if (bootefi_test_prepare(&image, &obj, "\\selftest", - (uintptr_t)&efi_selftest)) + (uintptr_t)&efi_selftest, + "efi_selftest")) return CMD_RET_FAILURE; /* Execute the test */ From patchwork Mon Jun 18 14:08:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930919 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YJ55VpMz9ryk for ; Tue, 19 Jun 2018 00:24:21 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 56A96C21ED6; Mon, 18 Jun 2018 14:14:07 +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=none 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 1FB93C21E6A; Mon, 18 Jun 2018 14:11:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B7981C21D65; Mon, 18 Jun 2018 14:09:13 +0000 (UTC) Received: from mail-oi0-f73.google.com (mail-oi0-f73.google.com [209.85.218.73]) by lists.denx.de (Postfix) with ESMTPS id D2ACBC21E36 for ; Mon, 18 Jun 2018 14:09:09 +0000 (UTC) Received: by mail-oi0-f73.google.com with SMTP id j7-v6so9963423oib.19 for ; Mon, 18 Jun 2018 07:09:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=1AW3IAe/55mWFoO/zqKpgpokfdQeDmaMyQNje6HLEe4=; b=Y7w7jGChv+SyvU0K61DVEfQCi6Ebo8MQwW0BlBOJlEWkzrSUb9fg60+rHXIHeHOGbm efgzQX7TxOefBxMQWyrhz7mG6cgc3BworrNf1Td4iEZ6zRdS/1IqOOYgx8M9Zuhtvi47 Pzyb/XAFPyzJPZyN7ysZ24daaz8NxrY0bF7DtmbBCI0t6YYHMob2gLkx5U3Kg+aEjwdj awdXTOEeTy93/Yt7fCAVWwLmzb76Vh672sI7T6ehhHkKlvIEFLiBOF/kbgDi6i1zpIM6 t9sx4Zht5sRGBBL+GuJUaq/KHeLz/cm/2dHLwg0gRrAQrxXtyM+R3SVotsQxQExnLnol SVAA== X-Gm-Message-State: APt69E0/fIPRfGW8EDWci585WNcerdV0VoF6S6rLbBhVDNPNd9C957zF ehNrWwf9X1L+5kn1Ubr5RMtYKY0= X-Google-Smtp-Source: ADUXVKLEoMGbai4FHn2BHiqqdulqGPRgufoDxMmg2BpN8GRTC42hhs1+VaBAktbgeC6eV3RC5Nye1cE= MIME-Version: 1.0 X-Received: by 2002:a9d:3ce2:: with SMTP id t31-v6mr6575879otf.12.1529330948655; Mon, 18 Jun 2018 07:09:08 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:15 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-11-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 10/30] efi: Rename bootefi_test_finish() to bootefi_run_finish() 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 function can be used from do_bootefi_exec() so that we use mostly the same code for a normal EFI application and an EFI test. Rename the function and use it in both places. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: - Drop patch "efi: Init the 'rows' and 'cols' variables" - Drop patches previous applied Changes in v6: None Changes in v5: - Rebase to master Changes in v4: - Rebase to master Changes in v3: - Add new patch to rename bootefi_test_finish() to bootefi_run_finish() Changes in v2: None cmd/bootefi.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index c174e5e8fc..3fa4f181ba 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -273,6 +273,20 @@ static efi_status_t bootefi_run_prepare(struct efi_loaded_image *image, return 0; } +/** + * bootefi_run_finish() - finish up after running an EFI test + * + * @image: Pointer to a struct which holds the loaded image info + * @obj: Pointer to a struct which holds the loaded image object + */ +static void bootefi_run_finish(struct efi_loaded_image *image, + struct efi_object *obj) +{ + efi_restore_gd(); + free(image->load_options); + list_del(&obj->link); +} + /* * Load an EFI payload into a newly allocated piece of memory, register all * EFI objects it would want to access and jump to it. @@ -362,8 +376,7 @@ static efi_status_t do_bootefi_exec(void *efi, ret = efi_do_enter(obj.handle, &systab, entry); exit: - /* image has returned, loaded-image obj goes *poof*: */ - list_del(&obj.link); + bootefi_run_finish(&image, &obj); if (mem_obj.handle) list_del(&mem_obj.link); @@ -400,20 +413,6 @@ static efi_status_t bootefi_test_prepare(struct efi_loaded_image *image, bootefi_device_path, bootefi_image_path); } -/** - * bootefi_test_finish() - finish up after running an EFI test - * - * @image: Pointer to a struct which holds the loaded image info - * @obj: Pointer to a struct which holds the loaded image object - */ -static void bootefi_test_finish(struct efi_loaded_image *image, - struct efi_object *obj) -{ - efi_restore_gd(); - free(image->load_options); - list_del(&obj->link); -} - static int do_bootefi_bootmgr_exec(void) { struct efi_device_path *device_path, *file_path; @@ -500,7 +499,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return CMD_RET_FAILURE; ret = efi_test(&image, &systab); - bootefi_test_finish(&image, &obj); + bootefi_run_finish(&image, &obj); if (ret) { printf("Test failed: err=%d\n", ret); return CMD_RET_FAILURE; @@ -518,7 +517,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /* Execute the test */ r = efi_selftest(obj.handle, &systab); - bootefi_test_finish(&image, &obj); + bootefi_run_finish(&image, &obj); return r != EFI_SUCCESS; } else #endif From patchwork Mon Jun 18 14:08:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930903 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418Y6s6y4Mz9ryk for ; Tue, 19 Jun 2018 00:16:21 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 7550AC21E85; Mon, 18 Jun 2018 14:10:46 +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 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 02633C21E36; Mon, 18 Jun 2018 14:09:52 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C7B35C21D65; Mon, 18 Jun 2018 14:09:17 +0000 (UTC) Received: from mail-qt0-f201.google.com (mail-qt0-f201.google.com [209.85.216.201]) by lists.denx.de (Postfix) with ESMTPS id 6AB69C21E50 for ; Mon, 18 Jun 2018 14:09:12 +0000 (UTC) Received: by mail-qt0-f201.google.com with SMTP id p12-v6so14078024qtg.5 for ; Mon, 18 Jun 2018 07:09:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=xM8bbJktdT8zZ2RwxSfC1Y5ytvm5lFPsdErzTrfyZL4=; b=OsIjSutwPHJr9yWJGstuxrePXEx8U+xoGOC2xBDWJgBFgE/WU6uJt8R7G+MtvsLusU hWCRyo7qFNi27B+NiO/0ooq1sQjRPETxOrIZ0fwIOhd9WThEjNwFJcb63gpo03Y89hs7 V1TfhRTOG2/vdAhCGgIs3CNwT0qlrT2WEu3U+WOD/vLRO+whF3fBAhsOFsMy3wJlKgMk NPn5rsSDHHJwPUfmZPs21moS1mhNEpAsQklojRlG4HD9Hi1ikGkJdMydfqh0MzE5QnTf 69TXxx93kL6wPYQgXGWxMwNrEKhfkOACKeuDxsa9HoQMz57oIvvYTl4xswxlfYt4F/vo hwTw== X-Gm-Message-State: APt69E0JnkHRfUsMB16PT8d7tVssd2N/FXbigoFnUw31ybjdKB3NATLg 5GynWfc0Q3FOFVqg3i3AGoIeIwM= X-Google-Smtp-Source: ADUXVKKB5JRSXQs99GwzCBrSoT4FiMjd7Xvcyza1P1r1DiXf9GGbAEKgWvQzcDfI/jNYXqj+iLqWrek= MIME-Version: 1.0 X-Received: by 2002:a0c:8b4a:: with SMTP id d10-v6mr7027967qvc.14.1529330951528; Mon, 18 Jun 2018 07:09:11 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:16 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-12-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 11/30] sandbox: Align RAM buffer to the machine page size 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" At present the sandbox RAM buffer is not aligned to any particular address boundary. This makes the internal pointers somewhat random with respect to the associated RAM buffer addresses. Align the buffer to the page size of the machine to help with this. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None arch/sandbox/cpu/os.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 5839932b00..a1a982af2d 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -143,14 +143,15 @@ void os_tty_raw(int fd, bool allow_sigs) void *os_malloc(size_t length) { struct os_mem_hdr *hdr; + int page_size = getpagesize(); - hdr = mmap(NULL, length + sizeof(*hdr), PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + hdr = mmap(NULL, length + page_size, + PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (hdr == MAP_FAILED) return NULL; hdr->length = length; - return hdr + 1; + return (void *)hdr + page_size; } void os_free(void *ptr) From patchwork Mon Jun 18 14:08:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930920 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YJc5yjCz9ryk for ; Tue, 19 Jun 2018 00:24:48 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 777B0C21E63; Mon, 18 Jun 2018 14:12:31 +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=none 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 690FCC21E7E; Mon, 18 Jun 2018 14:10:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 914FBC21EC2; Mon, 18 Jun 2018 14:09:19 +0000 (UTC) Received: from mail-oi0-f74.google.com (mail-oi0-f74.google.com [209.85.218.74]) by lists.denx.de (Postfix) with ESMTPS id 61DE6C21DFD for ; Mon, 18 Jun 2018 14:09:15 +0000 (UTC) Received: by mail-oi0-f74.google.com with SMTP id q129-v6so9974893oic.9 for ; Mon, 18 Jun 2018 07:09:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=948EO8JPrNRB2wD5qrsS3WycCqDc7INMLainQ2WKOFE=; b=N1l694jvlK7u8NWU8QeFkdlNV9ZP+UnTEojS6VMekgBwlUWwbeE/3KWgY1RGaC9gN6 NN873q0aTUrpz4cd47m5Um2QcAI8bw9Upjjwuux71QJzFbP0bQcRVigm7ZNtMBgO6cAs V4V1sOWjvE4DZJIy1lN99OpvuvI6h6EN5aeAx0w1rV3wLL7+6J6PgwzSE/gllMMCw9iB T8U7ZgS4b/zMDjsRNOdLx9Fp9HjwZ8sXIXkHw8IAPF6p08CYdQeiwgaeXkO0ghesHYcr YEqVf1ENkV3BpUknyWh4kWF8EWcetjHsLQxrzDe+mGVea+8U+cw+4Z54LCymyyeNVjkP VkUg== X-Gm-Message-State: APt69E12DAIVKj4XyMOXU8HNbYFClduzmmGVuNqKNIUI8+G7mJxs2pA5 CCvZjW8p84cKkRJkPrQJziCbSg0= X-Google-Smtp-Source: ADUXVKKgjN2LpSUhwpVHJTcAQkhp5z1QvANUiVLBD4qCZWi3Nk1+lXGJwMY2CXv+RGK/xX2SdhlPK7s= MIME-Version: 1.0 X-Received: by 2002:aca:e18a:: with SMTP id y132-v6mr5283073oig.96.1529330954387; Mon, 18 Jun 2018 07:09:14 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:17 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-13-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 12/30] sandbox: Try to start the RAM buffer at a particular address 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" Use a starting address of 256MB which should be available. This helps to make sandbox RAM buffers pointers more recognisable. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None arch/sandbox/cpu/os.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index a1a982af2d..1553aa687d 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -145,7 +145,12 @@ void *os_malloc(size_t length) struct os_mem_hdr *hdr; int page_size = getpagesize(); - hdr = mmap(NULL, length + page_size, + /* + * Use an address that is hopefully available to us so that pointers + * to this memory are fairly obvious. If we end up with a different + * address, that's fine too. + */ + hdr = mmap((void *)0x10000000, length + page_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (hdr == MAP_FAILED) return NULL; From patchwork Mon Jun 18 14:08: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: 930905 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418Y7y3Nf8z9ryk for ; Tue, 19 Jun 2018 00:17:18 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 29A1DC21ED5; Mon, 18 Jun 2018 14:13: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_H3, RCVD_IN_MSPIKE_WL 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 22AABC21E6C; Mon, 18 Jun 2018 14:11:31 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 60061C21D65; Mon, 18 Jun 2018 14:09:21 +0000 (UTC) Received: from mail-qk0-f202.google.com (mail-qk0-f202.google.com [209.85.220.202]) by lists.denx.de (Postfix) with ESMTPS id 23A6DC21E38 for ; Mon, 18 Jun 2018 14:09:18 +0000 (UTC) Received: by mail-qk0-f202.google.com with SMTP id 5-v6so14836309qke.19 for ; Mon, 18 Jun 2018 07:09:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=U7ggntSFb58YGyrH8KuNit1PvqsnIRc1DR/Nck8bLrk=; b=LgLuYpflLev7d7QcQbWZxWbv5eQUnITihD7iTOxtepAm9kSm0FLB54lQ1IuKxWijdI e6DV/KWYP4aVSM1lPdp6xwMlfHKcsuVFY3J2EoU0JGBWzeMS3yzDi/pH4ZFQEGoyXhW/ LwLByQD9ITOiIdJNHnexuRzRlhKtn1W3OJnWus7+4O6gd2kOHSO/MBoVHkq3ZYk2Iipm TuJvQLVKM9vSWKzZeggmnVTicOppQWr+Nvn/2DoG7BED7jt/lBTcqUFDEO4a8UQkmYuj 8mQrA00GpgtEWedN+I1EYI0C9MNEAfO6ucG+SoebAflY7hojC79YJDpyjAyodTAZAVcf DUew== X-Gm-Message-State: APt69E3UU8Zdtao1CAm1/OkixDZISIjDHMeHyowS/O8Eb0+ZNsb3zp4Y hLVtrSTRB/5QQwIT51GHsRrEzdo= X-Google-Smtp-Source: ADUXVKLk9yKzpYUYimXlLD+mPG0uXLIYgzNqOyc0y/YJPsFNBpyE260sLTS/Yrp6JOafe7d0px3tKoU= MIME-Version: 1.0 X-Received: by 2002:a0c:9373:: with SMTP id e48-v6mr6780399qve.6.1529330957284; Mon, 18 Jun 2018 07:09:17 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:18 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-14-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 13/30] sandbox: Add support for calling abort() 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 function is useful to signal that the application needs to exit immediate. It can be caught with a debugger (e.g. gdb). Add a stub for it so that it can be called from within sandbox when an internal error occurs. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None arch/sandbox/cpu/os.c | 5 +++++ include/os.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 1553aa687d..f8d87df7b6 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -657,3 +657,8 @@ void os_longjmp(ulong *jmp, int ret) { longjmp((struct __jmp_buf_tag *)jmp, ret); } + +void os_abort(void) +{ + abort(); +} diff --git a/include/os.h b/include/os.h index c8e0f52d30..e850f879ec 100644 --- a/include/os.h +++ b/include/os.h @@ -351,4 +351,8 @@ int os_setjmp(ulong *jmp, int size); */ void os_longjmp(ulong *jmp, int ret); +/** + * os_abort() - Raise SIGABRT to exit sandbox (e.g. to debugger) + */ +void os_abort(void); #endif From patchwork Mon Jun 18 14:08:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930896 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418Y5D3X28z9s3M for ; Tue, 19 Jun 2018 00:14:56 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 063E7C21EE3; Mon, 18 Jun 2018 14:11:02 +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=none 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 E3F11C21E88; Mon, 18 Jun 2018 14:10:05 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 381ACC21EC5; Mon, 18 Jun 2018 14:09:24 +0000 (UTC) Received: from mail-io0-f202.google.com (mail-io0-f202.google.com [209.85.223.202]) by lists.denx.de (Postfix) with ESMTPS id 3443AC21E9F for ; Mon, 18 Jun 2018 14:09:21 +0000 (UTC) Received: by mail-io0-f202.google.com with SMTP id i18-v6so13370832iog.12 for ; Mon, 18 Jun 2018 07:09:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=uR2UM+1XiZE28Fw4TD6sqfQfmZ8qjcNvrpiYkIwUFt0=; b=tNktH9upgaqKpoGj8GuGOfzO5EUnkz2p1V+9Q24/TbSGG3jkzo5ot3eChzWtP7Hb5G RNMZxNYV+QorA5YWTd1BHNF1G0HhBGJ8gnlRYcVgzi+R4uZbEpnAeq+y3jS4GLAT9IcG 04CSev7RMUYlPsyTlfN5CoAS25iZ65hYBz7gXFCh9ydchqc0mYSeuWN6quHn9UGzyDmn EiupThyG4aacbrXCEs6pgJGDX8C9t0b+H9vtriLyH4J6GZIEtKzz3H4asuLLZPjiBzAi GY6ZVZtqgEdzEwxv01uSC1W3B4ekNSKdcMQEDY7cB1TXEjC23zLpydF/fuKA/dMdXYpG JjKw== X-Gm-Message-State: APt69E1jkJpjyHIF4bpPkPEH1bkQGIEzqvaEXzlRVY3ohfeBdg0ua/FS 6EQH2bIS7VV05e3XlEgwdkYTl1Y= X-Google-Smtp-Source: ADUXVKJzvJFqCvWxB8ZkBMweqs3q+Nk+9GRNNsYBoPXIEIXXCi+PC3g7yl6CKwJHDaOr40xLO40vHOM= MIME-Version: 1.0 X-Received: by 2002:a24:424e:: with SMTP id i75-v6mr4944593itb.29.1529330960202; Mon, 18 Jun 2018 07:09:20 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:19 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-15-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 14/30] efi: Don't build sandbox with __attribute__((ms_abi)) 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" There appears to be a bug [1] in gcc when using varargs with this attribute. Disable it for sandbox so that functions which use that can work correctly, such as install_multiple_protocol_interfaces(). [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70955 Signed-off-by: Simon Glass Reviewed-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None include/efi.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/include/efi.h b/include/efi.h index e30a3c51c6..930ea74abe 100644 --- a/include/efi.h +++ b/include/efi.h @@ -19,11 +19,22 @@ #include #include -#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB) && defined(__x86_64__)) -/* EFI uses the Microsoft ABI which is not the default for GCC */ -#define EFIAPI __attribute__((ms_abi)) +#ifdef CONFIG_SANDBOX +/* + * Avoid using EFIAPI due to this bug: + * + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70955 + * + * This affects efi_install_multiple_protocol_interfaces(). + */ +# define EFIAPI #else -#define EFIAPI asmlinkage +# if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB) && defined(__x86_64__)) +/* EFI uses the Microsoft ABI which is not the default for GCC */ +# define EFIAPI __attribute__((ms_abi)) +# else +# define EFIAPI asmlinkage +# endif #endif struct efi_device_path; From patchwork Mon Jun 18 14:08: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: 930924 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YLG0lkmz9s3M for ; Tue, 19 Jun 2018 00:26:14 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id C1079C21EBA; Mon, 18 Jun 2018 14:12:15 +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 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 3EEFEC21EB9; Mon, 18 Jun 2018 14:10:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E0176C21E26; Mon, 18 Jun 2018 14:09:27 +0000 (UTC) Received: from mail-ua0-f201.google.com (mail-ua0-f201.google.com [209.85.217.201]) by lists.denx.de (Postfix) with ESMTPS id 11E2CC21E6C for ; Mon, 18 Jun 2018 14:09:24 +0000 (UTC) Received: by mail-ua0-f201.google.com with SMTP id v37-v6so5711606uag.6 for ; Mon, 18 Jun 2018 07:09:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=yoZi0LpTLiBdtANvXBIMIhCXuV00dRUVblypge7JS+4=; b=j3Brahrrb1U+2CfqVtn8dT0zNXbajGF+xbqt0sKFnvGDn1+xuDW3qNQX6Y5bnvDQy3 n3BUj1eStCy5hvBQFe2FZwDZgZ9AeEbXcKkz5Jy+QsOyX1iIxDy8dtHc3Vg8GCh1Z7h3 IyLRvUbbQAhJOmxzWpz0SinGyF/4JIM9KrWa9lL7HSsGNL3ITZKmRmrDM2h1Kp6QDjB9 WiA24ge9CwQQ+u3rVuwRfT7Fo6j6QPnHZ0L7pI2GPTBGVhWyvV5JNhwabmfayNFPNr+T i2usW4v7dJNrXw0Tl4PdsiJDPs8gi77DI9WZnIMH7ANJ5LYZExMmL8r1SIEtENgArsOU 6qQw== X-Gm-Message-State: APt69E2Dw/hZ8tfFWspROGo733zOjJZUXaPn9Rnij9MPLSh7eFSjVZt0 TO3EF8CwUj2Cd/a7OoVW+83uiJk= X-Google-Smtp-Source: ADUXVKL2rKcRLM4UxRyFJozVs3JKnPrOQt/ayhNDp52qg3nGQVlG3DRY/lL7KN1LPPGuhIay2FobAwM= MIME-Version: 1.0 X-Received: by 2002:ab0:49ef:: with SMTP id f44-v6mr5356323uad.10.1529330963187; Mon, 18 Jun 2018 07:09:23 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:20 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-16-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 15/30] vsprintf: Handle NULL with %pU 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" At present a NULL pointer passed to printf for a %pU argument will cause U-Boot to access memory at 0. Fix this by adding a check, and print "(null)" instead. Signed-off-by: Simon Glass Reviewed-by: Alexander Graf --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None lib/vsprintf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 8b1b29fb5a..2da7f88b18 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -407,7 +407,10 @@ static char *uuid_string(char *buf, char *end, u8 *addr, int field_width, break; } - uuid_bin_to_str(addr, uuid, str_format); + if (addr) + uuid_bin_to_str(addr, uuid, str_format); + else + strcpy(uuid, "(null)"); return string(buf, end, uuid, field_width, precision, flags); } From patchwork Mon Jun 18 14:08:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930913 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YCJ5bKXz9s2t for ; Tue, 19 Jun 2018 00:20:12 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 5AE61C21E38; Mon, 18 Jun 2018 14:11:42 +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 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 691C1C21EA2; Mon, 18 Jun 2018 14:10:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B2C82C21EA1; Mon, 18 Jun 2018 14:09:30 +0000 (UTC) Received: from mail-qk0-f202.google.com (mail-qk0-f202.google.com [209.85.220.202]) by lists.denx.de (Postfix) with ESMTPS id 34A44C21E36 for ; Mon, 18 Jun 2018 14:09:27 +0000 (UTC) Received: by mail-qk0-f202.google.com with SMTP id f207-v6so14455335qke.22 for ; Mon, 18 Jun 2018 07:09:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=IH+zjquYJBgCbyZDnHrYdNY8NjteiU261yR8eOXkx1g=; b=CDCxaoR/rE/QvzM6J6bVb+Zky642Jfltj0bkFBNP+HwtmgGh2bQLP/zGoW+hpxEHvD /zJSsUmkG6eZW3trS4QXSQinaxQUphp/fGUv/fCD05i6/7rRoAr79hWWrb+jXunnAj4j RwDokTQdAxeRY9TCS5H6oBnnT4srWhi17r9GEVfEjdjEWNve1s/RfKNfp7Ob4DY/V+Sv fvoP2AXNz58BnkZNIwZLnI98TYORllbM+JX7ZQFuEDNZsjFIctRZQRqhWtFWJ7JrIqAy XuB37pDGxOybCBaWN1jGIIl6p9EgoMdCpoTMVkM9qga7Bdl0O4u+w3ZC1l5+YD2iCS5x 9KFw== X-Gm-Message-State: APt69E0VtPyfNgHnjbSBKLfptNmXx9kXRt57/7UdVgzMl5DFrZ4Y5Kal 40CoOZSWB02oc1NWz+015k62y0g= X-Google-Smtp-Source: ADUXVKLjtUO0nU505dxM6d/efGX5R3P1i8oVejsZjvrwknHKmTkx7CgN5xuIdi6kN5q3FON9Vi9EXDU= MIME-Version: 1.0 X-Received: by 2002:a0c:d2a2:: with SMTP id q31-v6mr6807704qvh.45.1529330966349; Mon, 18 Jun 2018 07:09:26 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:21 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-17-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 16/30] efi_selftest: Clean up a few comments and messages 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" Fix the 'amp' typo, expand on what 'steps' is and fix a few other minor things. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None lib/efi_selftest/efi_selftest.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/efi_selftest/efi_selftest.c b/lib/efi_selftest/efi_selftest.c index 13eb2cd604..dd338db687 100644 --- a/lib/efi_selftest/efi_selftest.c +++ b/lib/efi_selftest/efi_selftest.c @@ -8,9 +8,7 @@ #include #include -/* - * Constants for test step bitmap - */ +/* Constants for test step bitmap */ #define EFI_ST_SETUP 1 #define EFI_ST_EXECUTE 2 #define EFI_ST_TEARDOWN 4 @@ -26,7 +24,7 @@ static u16 reset_message[] = L"Selftest completed"; * * The size of the memory map is determined. * Pool memory is allocated to copy the memory map. - * The memory amp is copied and the map key is obtained. + * The memory map is copied and the map key is obtained. * The map key is used to exit the boot services. */ void efi_st_exit_boot_services(void) @@ -146,7 +144,7 @@ static int teardown(struct efi_unit_test *test, unsigned int *failures) * Check that a test exists. * * @testname: name of the test - * @return: test + * @return: test, or NULL if not found */ static struct efi_unit_test *find_test(const u16 *testname) { @@ -182,7 +180,7 @@ static void list_all_tests(void) * * @testname name of a single selected test or NULL * @phase test phase - * @steps steps to execute + * @steps steps to execute (mask with bits from EFI_ST_...) * failures returns EFI_ST_SUCCESS if all test steps succeeded */ void efi_st_do_tests(const u16 *testname, unsigned int phase, @@ -296,12 +294,12 @@ efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle, efi_st_printc(EFI_WHITE, "\nSummary: %u failures\n\n", failures); /* Reset system */ - efi_st_printf("Preparing for reset. Press any key.\n"); + efi_st_printf("Preparing for reset. Press any key...\n"); efi_st_get_key(); runtime->reset_system(EFI_RESET_WARM, EFI_NOT_READY, sizeof(reset_message), reset_message); efi_st_printf("\n"); - efi_st_error("Reset failed.\n"); + efi_st_error("Reset failed\n"); return EFI_UNSUPPORTED; } From patchwork Mon Jun 18 14:08:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930911 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YBB6RJcz9ryk for ; Tue, 19 Jun 2018 00:19:14 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 920C5C21EC2; Mon, 18 Jun 2018 14:12:52 +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 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 C1ACCC21E79; Mon, 18 Jun 2018 14:11:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EF152C21E6A; Mon, 18 Jun 2018 14:09:33 +0000 (UTC) Received: from mail-qk0-f202.google.com (mail-qk0-f202.google.com [209.85.220.202]) by lists.denx.de (Postfix) with ESMTPS id 171E8C21EBE for ; Mon, 18 Jun 2018 14:09:30 +0000 (UTC) Received: by mail-qk0-f202.google.com with SMTP id w203-v6so14712195qkb.16 for ; Mon, 18 Jun 2018 07:09:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=mOMfINfT9/MLgaX8GWwlhFyA+yTgfX7q/xG/oDyebW0=; b=ibY1vIzCz7ccKB67KEWD6OJ8DWhy9okvY2NmpDi1rgc+ehRtPpb+zw7GTUeT1W3s1r FISLINOdH36rqMcJH52Ugsqqs5d2GMRFlf7FewvbnNGnvzBhkGrgLKzexrICbvXkE2Tv gtPvsCrkCVA0MyqlGVKqxAHUV7+33NjpjS/Ur+5EBPfMpvcdlVnCpZjct1eg4IfVsoaj gjWzMIpps4p65f7coFtIdUh+KcXJ70MV6ZwutaZ44WIY+I9O273QI1/uaeKuZtgLj0WS /31ggGn1eSrDjEkBlsoqJ/xWQwD2wNMeJqxdsW08ejFjHHgSyH/1pq1mkNqQ1nrKJybg WSYA== X-Gm-Message-State: APt69E2zaVgKWZ8wNbo7WnNlV9irRPkR7y8dot9b5OGVdZLAjmajRq8X w7/LrhGxIy6E8Cq9idyRTW/1zcM= X-Google-Smtp-Source: ADUXVKI2y/ZqvqjqhEdPcZ8ThOC4miPGFxJpK/9E4HhIMGcbOX7pcjEtDzGl7D4vNU8tbh2MSPc2bAE= MIME-Version: 1.0 X-Received: by 2002:a0c:c245:: with SMTP id w5-v6mr7012170qvh.33.1529330969214; Mon, 18 Jun 2018 07:09:29 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:22 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-18-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 17/30] sandbox: Enhance map_to_sysmem() to handle foreign pointers 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" At present map_sysmem() maps an address into the sandbox RAM buffer, return a pointer, while map_to_sysmem() goes the other way. The mapping is currently just 1:1 since a case was not found where a more flexible mapping was needed. PCI does have a separate and more complex mapping, but uses its own mechanism. However this arrange cannot handle one important case, which is where a test declares a stack variable and passes a pointer to it into a U-Boot function which uses map_to_sysmem() to turn it into a address. Since the pointer is not inside emulated DRAM, this will fail. Add a mapping feature which can handle any such pointer, mapping it to a simple tag value which can be passed around in U-Boot as an address. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None arch/sandbox/cpu/cpu.c | 141 +++++++++++++++++++++++++++++-- arch/sandbox/cpu/state.c | 8 ++ arch/sandbox/include/asm/state.h | 21 +++++ 3 files changed, 161 insertions(+), 9 deletions(-) diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index cde0b055a6..fd77603ebf 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -57,14 +57,104 @@ int cleanup_before_linux_select(int flags) return 0; } +/** + * is_in_sandbox_mem() - Checks if a pointer is within sandbox's emulated DRAM + * + * This provides a way to check if a pointer is owned by sandbox (and is within + * its RAM) or not. Sometimes pointers come from a test which conceptually runs + * output sandbox, potentially with direct access to the C-library malloc() + * function, or the sandbox stack (which is not actually within the emulated + * DRAM. + * + * Such pointers obviously cannot be mapped into sandbox's DRAM, so we must + * detect them an process them separately, by recording a mapping to a tag, + * which we can use to map back to the pointer later. + * + * @ptr: Pointer to check + * @return true if this is within sandbox emulated DRAM, false if not + */ +static bool is_in_sandbox_mem(const void *ptr) +{ + return (const uint8_t *)ptr >= gd->arch.ram_buf && + (const uint8_t *)ptr < gd->arch.ram_buf + gd->ram_size; +} + +/** + * phys_to_virt() - Converts a sandbox RAM address to a pointer + * + * Sandbox uses U-Boot addresses from 0 to the size of DRAM. These index into + * the emulated DRAM buffer used by sandbox. This function converts such an + * address to a pointer into thi sbuffer, which can be used to access the + * memory. + * + * If the address is outside this range, it is assumed to be a tag + */ void *phys_to_virt(phys_addr_t paddr) { - return (void *)(gd->arch.ram_buf + paddr); + struct sandbox_mapmem_entry *mentry; + struct sandbox_state *state; + + /* If the address is within emulated DRAM, calculate the value */ + if (paddr < gd->ram_size) + return (void *)(gd->arch.ram_buf + paddr); + + /* + * Otherwise search out list of tags for the correct pointer previously + * created by map_to_sysmem() + */ + state = state_get_current(); + list_for_each_entry(mentry, &state->mapmem_head, sibling_node) { + if (mentry->tag == paddr) { + printf("%s: Used map from %lx to %p\n", __func__, + (ulong)paddr, mentry->ptr); + return mentry->ptr; + } + } + + printf("%s: Cannot map sandbox address %lx (SDRAM from 0 to %lx)\n", + __func__, (ulong)paddr, (ulong)gd->ram_size); + os_abort(); + + /* Not reached */ + return NULL; +} + +struct sandbox_mapmem_entry *find_tag(const void *ptr) +{ + struct sandbox_mapmem_entry *mentry; + struct sandbox_state *state = state_get_current(); + + list_for_each_entry(mentry, &state->mapmem_head, sibling_node) { + if (mentry->ptr == ptr) { + debug("%s: Used map from %p to %lx\n", __func__, ptr, + mentry->tag); + return mentry; + } + } + return NULL; } -phys_addr_t virt_to_phys(void *vaddr) +phys_addr_t virt_to_phys(void *ptr) { - return (phys_addr_t)((uint8_t *)vaddr - gd->arch.ram_buf); + struct sandbox_mapmem_entry *mentry; + + /* + * If it is in emulated RAM, don't bother looking for a tag. Just + * calculate the pointer using the provides offset into the RAM buffer. + */ + if (is_in_sandbox_mem(ptr)) + return (phys_addr_t)((uint8_t *)ptr - gd->arch.ram_buf); + + mentry = find_tag(ptr); + if (!mentry) { + /* Abort so that gdb can be used here */ + printf("%s: Cannot map sandbox address %p (SDRAM from 0 to %lx)\n", + __func__, ptr, (ulong)gd->ram_size); + os_abort(); + } + printf("%s: Used map from %p to %lx\n", __func__, ptr, mentry->tag); + + return mentry->tag; } void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags) @@ -87,24 +177,57 @@ void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags) return phys_to_virt(paddr); } -void unmap_physmem(const void *vaddr, unsigned long flags) +void unmap_physmem(const void *ptr, unsigned long flags) { #ifdef CONFIG_PCI if (map_dev) { - pci_unmap_physmem(vaddr, map_len, map_dev); + pci_unmap_physmem(ptr, map_len, map_dev); map_dev = NULL; } #endif } -void sandbox_set_enable_pci_map(int enable) +phys_addr_t map_to_sysmem(const void *ptr) { - enable_pci_map = enable; + struct sandbox_mapmem_entry *mentry; + + /* + * If it is in emulated RAM, don't bother creating a tag. Just return + * the offset into the RAM buffer. + */ + if (is_in_sandbox_mem(ptr)) + return (u8 *)ptr - gd->arch.ram_buf; + + /* + * See if there is an existing tag with this pointer. If not, set up a + * new one. + */ + mentry = find_tag(ptr); + if (!mentry) { + struct sandbox_state *state = state_get_current(); + + mentry = malloc(sizeof(*mentry)); + if (!mentry) { + printf("%s: Error: Out of memory\n", __func__); + os_exit(ENOMEM); + } + mentry->tag = state->next_tag++; + mentry->ptr = (void *)ptr; + list_add_tail(&mentry->sibling_node, &state->mapmem_head); + debug("%s: Added map from %p to %lx\n", __func__, ptr, + (ulong)mentry->tag); + } + + /* + * Return the tag as the address to use. A later call to map_sysmem() + * will return ptr + */ + return mentry->tag; } -phys_addr_t map_to_sysmem(const void *ptr) +void sandbox_set_enable_pci_map(int enable) { - return (u8 *)ptr - gd->arch.ram_buf; + enable_pci_map = enable; } void flush_dcache_range(unsigned long start, unsigned long stop) diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index cc50819ab9..04a11fed55 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -359,6 +359,14 @@ void state_reset_for_test(struct sandbox_state *state) memset(&state->wdt, '\0', sizeof(state->wdt)); memset(state->spi, '\0', sizeof(state->spi)); + + /* + * Set up the memory tag list. Use the top of emulated SDRAM for the + * first tag number, since that address offset is outside the legal + * range, and can be assumed to be a tag. + */ + INIT_LIST_HEAD(&state->mapmem_head); + state->next_tag = state->ram_size; } int state_init(void) diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index 7ed4b512d2..a612ce8944 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -9,6 +9,7 @@ #include #include #include +#include #include /** @@ -45,6 +46,23 @@ struct sandbox_wdt_info { bool running; }; +/** + * struct sandbox_mapmem_entry - maps pointers to/from U-Boot addresses + * + * When map_to_sysmem() is called with an address outside sandbox's emulated + * RAM, a record is created with a tag that can be used to reference that + * pointer. When map_sysmem() is called later with that tag, the pointer will + * be returned, just as it would for a normal sandbox address. + * + * @tag: Address tag (a value which U-Boot uses to refer to the address) + * @ptr: Associated pointer for that tag + */ +struct sandbox_mapmem_entry { + ulong tag; + void *ptr; + struct list_head sibling_node; +}; + /* The complete state of the test system */ struct sandbox_state { const char *cmd; /* Command to execute */ @@ -78,6 +96,9 @@ struct sandbox_state { /* Information about Watchdog */ struct sandbox_wdt_info wdt; + + ulong next_tag; /* Next address tag to allocate */ + struct list_head mapmem_head; /* struct sandbox_mapmem_entry */ }; /* Minimum space we guarantee in the state FDT when calling read/write*/ From patchwork Mon Jun 18 14:08:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930910 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418Y9Z3yQ6z9ryk for ; Tue, 19 Jun 2018 00:18:42 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 3938FC21EBA; Mon, 18 Jun 2018 14:11:58 +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=none 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 33361C21E89; Mon, 18 Jun 2018 14:10:31 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 68F05C21E13; Mon, 18 Jun 2018 14:09:36 +0000 (UTC) Received: from mail-oi0-f73.google.com (mail-oi0-f73.google.com [209.85.218.73]) by lists.denx.de (Postfix) with ESMTPS id 06218C21E1E for ; Mon, 18 Jun 2018 14:09:33 +0000 (UTC) Received: by mail-oi0-f73.google.com with SMTP id v134-v6so9956014oia.15 for ; Mon, 18 Jun 2018 07:09:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=A8tsciY4KzdFJ6a0o6LykEji8lXB16ly35M2MEFE8U4=; b=P7HLUcV263D6vBezYbHOfpLwEsfqvFQgllgupjrHgZzYJpf/9DIS2zrxFwrcvhXZSf Cduyn5nUIGheMTWzMiwMMnHI6oEORr34lRkFDIM3ta9LB7sfNUOoSxHvY7as0kXWS+B0 suygRooAfa7WGiRSvHDlAdKt+nxuwlObrk3Sjx+Fk1F8Nq/JufdgOmc1K3q9tATvk3gK mUrxxp2EW4NgJJs/Is9InNbm11SVcwoFxcEDioxqS0k9M7qBGmoJ5BCb4RrIFB0/P2NI TNLzS9g3V9VeuLm5S3DnJcjszq4gND7ColAUEIHrBuKnUMWWv5NC+B8QWGi6KPhaeyHn WXRA== X-Gm-Message-State: APt69E2vFk2Uck4e+s4X7mTiuUAwbccmITy/e125efUOOpG0+GmQea+W +Jj8ag8UlEBEM0+nHFp534Yy4Gw= X-Google-Smtp-Source: ADUXVKIds/Lff3Z/k4w4TyWUQvbmb+/bs0OiH1nyeaIFT1XTSb3IJulWomub43vSr5OVVZlwqqevxO4= MIME-Version: 1.0 X-Received: by 2002:aca:d095:: with SMTP id j21-v6mr5727187oiy.6.1529330972012; Mon, 18 Jun 2018 07:09:32 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:23 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-19-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 18/30] efi: Add a call to exit() along with why we can't use it 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" The test should exit like any other EFI application, by calling exit() in the boot services API. But this crashes at present on sandbox. For now, add in the placeholder code. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None lib/efi_loader/efi_test.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_test.c b/lib/efi_loader/efi_test.c index 4b8d49f324..5401a0f471 100644 --- a/lib/efi_loader/efi_test.c +++ b/lib/efi_loader/efi_test.c @@ -9,8 +9,18 @@ int efi_test(efi_handle_t image_handle, struct efi_system_table *systable) { struct efi_simple_text_output_protocol *con_out = systable->con_out; + struct efi_boot_services *boottime = systable->boottime; + int ret; - con_out->output_string(con_out, L"Hello, world!\n"); + ret = con_out->output_string(con_out, L"Hello, world!\n"); + + /* + * We should really call EFI's exit() here but this crashes at present + * on sandbox due to the incorrect use of setjmp() and longjmp(). Once + * we can figure out how to make that work, this can be enabled. + */ + if (0) + boottime->exit(image_handle, ret, 0, NULL); return 0; } From patchwork Mon Jun 18 14:08:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930923 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YLC5Dffz9s2t for ; Tue, 19 Jun 2018 00:26:10 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id A99E9C21E88; Mon, 18 Jun 2018 14:14:40 +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=none 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 40EECC21E88; Mon, 18 Jun 2018 14:12:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 026AFC21EB1; Mon, 18 Jun 2018 14:09:39 +0000 (UTC) Received: from mail-it0-f74.google.com (mail-it0-f74.google.com [209.85.214.74]) by lists.denx.de (Postfix) with ESMTPS id CE15BC21EA2 for ; Mon, 18 Jun 2018 14:09:35 +0000 (UTC) Received: by mail-it0-f74.google.com with SMTP id c7-v6so8386594itd.7 for ; Mon, 18 Jun 2018 07:09:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=nVf/LsxRf6c05spAtcbI3SECSy0Cg9Q8gFunIaAlS60=; b=Y/vX2EPxT5uWJwakJFCQjy66fuTwQZfVoATFCgaFwY8I+YJUkPD6GbftU6fqHNmkeC 80lr2ZE46OYSYP2BdCvjQGGFUZ1FPgFOzfNDEIa6n8NxKMcOLm/3mDSJTPjISrLflwkY sEd9dvah8BugZbADZYLDSLxI7fqoRl5oCDt7T2u60BNTZU8S4UbGCY1PxryfWhHghQ4U /jIqor9C6+KW/H3SLCYVspJxKTXaB5IPvq1XlcVgH7VJe4QclPG68yN99InmlPyW5SX5 0o8kl6wEMAgznhNHolNmDwoAQzvubXkNLujBRGpWSKSVS0mkRDtRI0YAPdnn8SWBPxqI Ucjw== X-Gm-Message-State: APt69E3vTakMouSk6+vkEeSClLi7Nuw0Hc0FzAg8MjkseZWNPrBPVR7F UB7JLyluZj1ARzCOPwu4qdydUFc= X-Google-Smtp-Source: ADUXVKII7KcsdSP5r5nsLkXr0KowUg1WhUI3EAObsgGgXiAcHJi/Bv1Ag5D+OV1IZAQWl+S8Vqq/3g0= MIME-Version: 1.0 X-Received: by 2002:a24:6b15:: with SMTP id v21-v6mr4997571itc.1.1529330974839; Mon, 18 Jun 2018 07:09:34 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:24 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-20-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 19/30] efi: Relocate FDT to 127MB instead of 128MB 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" Sandbox only has 128MB of memory so we cannot relocate the device tree up to start at 128MB. Use 127MB instead, which should be safe. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None cmd/bootefi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 3fa4f181ba..d2458e2397 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -141,8 +141,8 @@ static void *copy_fdt(void *fdt) fdt_size = ALIGN(fdt_size + 4096, EFI_PAGE_SIZE); fdt_pages = fdt_size >> EFI_PAGE_SHIFT; - /* Safe fdt location is at 128MB */ - new_fdt_addr = fdt_ram_start + (128 * 1024 * 1024) + fdt_size; + /* Safe fdt location is at 127MB */ + new_fdt_addr = fdt_ram_start + (127 * 1024 * 1024) + fdt_size; if (efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, EFI_RUNTIME_SERVICES_DATA, fdt_pages, &new_fdt_addr) != EFI_SUCCESS) { From patchwork Mon Jun 18 14:08:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930922 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YKW0mK9z9ryk for ; Tue, 19 Jun 2018 00:25:34 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id B11E3C21EEB; Mon, 18 Jun 2018 14:14:56 +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 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 1B14CC21EC8; Mon, 18 Jun 2018 14:13:14 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 16EC3C21E26; Mon, 18 Jun 2018 14:09:42 +0000 (UTC) Received: from mail-ua0-f202.google.com (mail-ua0-f202.google.com [209.85.217.202]) by lists.denx.de (Postfix) with ESMTPS id 8DA23C21E6C for ; Mon, 18 Jun 2018 14:09:38 +0000 (UTC) Received: by mail-ua0-f202.google.com with SMTP id j9-v6so5680430uan.8 for ; Mon, 18 Jun 2018 07:09:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=a6mkSx2NYQxAtUc7RExzOSlwr3rnSy6EdaMSwZFle98=; b=rxBFDylx9nTvtZwQQryAPPUsQM9wiVYAsN3D+wzpuREzRi7GpZI9WmX5DkcTp13B9O VrxPllFtT81w5bhh5V/OyLZEU1DKMjUmbU+6AxGE7E+2poxSgM5rdFXZZS69exDfOmnX OBYilPPZQa2DCFdglMwzCtafQkQxbgQxGSZDYojHD/NJ4Fjwb3yZ3elO1H8Xr56DXs5g Yrzmuqfq3x00HJ287jPObIo7WecxK+fudVtaQ7JxlbVfZyq9mDphxzH3fvLIbn3Tx845 bgpafmXKDjYst1CY18/DWtoxprKwFwsHlOaRjUWrJjPnD2hiVxItO9ZW6v1A3oSDzWEy L6Aw== X-Gm-Message-State: APt69E2U4sXzeOM54dTqGdr7PuqXTDB3WfJGtWvvD9i3DmQR77SCIMyB Nmhmr5w6moe/akU+5qlHZ736Lok= X-Google-Smtp-Source: ADUXVKJwoZuSNGNCjh6M0zbhP5yDqhbFYZT88GRHro2knEWN/AEGpnqyYd1jGgIIjRuX/WOKi9J48NI= MIME-Version: 1.0 X-Received: by 2002:ab0:71c6:: with SMTP id n6-v6mr5280607uao.97.1529330977627; Mon, 18 Jun 2018 07:09:37 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:25 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-21-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 20/30] efi: Tidy up device-tree-size calculation in copy_fdt() 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 is a bit confusing at present since it adds 4KB to the pointer, then rounds it up. It looks like a bug, but is not. Move the 4KB addition into a separate statement and expand the comment. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None cmd/bootefi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index d2458e2397..c89f83fb33 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -137,8 +137,12 @@ static void *copy_fdt(void *fdt) fdt_ram_start = ram_start; } - /* Give us at least 4kb breathing room */ - fdt_size = ALIGN(fdt_size + 4096, EFI_PAGE_SIZE); + /* + * Give us at least 4KB of breathing room in case the device tree needs + * to be expanded later. Round up to the nearest EFI page boundary. + */ + fdt_size += 4096; + fdt_size = ALIGN(fdt_size + EFI_PAGE_SIZE - 1, EFI_PAGE_SIZE); fdt_pages = fdt_size >> EFI_PAGE_SHIFT; /* Safe fdt location is at 127MB */ From patchwork Mon Jun 18 14:08:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930931 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YMF6dRvz9ryk for ; Tue, 19 Jun 2018 00:27:05 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 7B4F7C21ECC; Mon, 18 Jun 2018 14:19:22 +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 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 A78A7C21EE7; Mon, 18 Jun 2018 14:19:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id F343AC21DFD; Mon, 18 Jun 2018 14:09:45 +0000 (UTC) Received: from mail-vk0-f74.google.com (mail-vk0-f74.google.com [209.85.213.74]) by lists.denx.de (Postfix) with ESMTPS id 95D0DC21EB4 for ; Mon, 18 Jun 2018 14:09:41 +0000 (UTC) Received: by mail-vk0-f74.google.com with SMTP id p83-v6so7073822vkf.9 for ; Mon, 18 Jun 2018 07:09:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=hLKBwvNKsCn70e1WHmIcCO6AWcJeqg59aFNzpeOdJkM=; b=Z8N0zwZntyMvEY5fMtuWloKr6gtISBYu4YCVYdqDUPu1j8a/mMhKz2lCdgCinEWsYc y9qLTk7PnMIDdJpl7Vc7N9uvb72TI3/5xiXmKJI5oxNAsYqa7yrrAN/mFXo2Q+mfGciG HyNmmAginjWlevsZMrCiorliCjTxs64hKgzQ32Zj6ZMi8d+AQd/GWH42IvQtxUire6p9 nWXgGqhIC63HViGS9Kg9JHoGrA8IeTVEoQldneag5XenPHPO2VOvIqyKd2fsTy9exolD QuqFD69HqF7+BrxYCqC0iHPckSL8/xgRy0gVHCf67bttjw/JBlWomNdJD5pTznVoinFM j+5w== X-Gm-Message-State: APt69E3RzzB884ddF8v0fg/+Bt9WCI5Zgw9V1JYKQwOmQCoyXVnfXtz1 OQ2L7tPBtmPH1gmMLQ0qM62A6sI= X-Google-Smtp-Source: ADUXVKLc6ictQaOSFtS0CB7+PkdlZ1UY6xQNejSJjXOVv086LOkPim2cLrnkP9wMradNjS1jGGfSMEY= MIME-Version: 1.0 X-Received: by 2002:ab0:52dd:: with SMTP id w29-v6mr5663223uaw.84.1529330980576; Mon, 18 Jun 2018 07:09:40 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:26 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-22-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 21/30] efi_loader: Use map_sysmem() in bootefi command 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" From: Alexander Graf The bootefi command gets a few addresses as values passed in. In sandbox, these values are in U-Boot address space, so we need to make sure we explicitly call map_sysmem() on them to be able to access them. Signed-off-by: Alexander Graf Reviewed-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None cmd/bootefi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index c89f83fb33..b62635f448 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -452,7 +453,8 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) char *saddr; unsigned long addr; efi_status_t r; - void *fdt_addr; + unsigned long fdt_addr; + void *fdt; /* Allow unaligned memory access */ allow_unaligned(); @@ -469,11 +471,12 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return CMD_RET_USAGE; if (argc > 2) { - fdt_addr = (void *)simple_strtoul(argv[2], NULL, 16); + fdt_addr = simple_strtoul(argv[2], NULL, 16); if (!fdt_addr && *argv[2] != '0') return CMD_RET_USAGE; /* Install device tree */ - r = efi_install_fdt(fdt_addr); + fdt = map_sysmem(fdt_addr, 0); + r = efi_install_fdt(fdt); if (r != EFI_SUCCESS) { printf("ERROR: failed to install device tree\n"); return CMD_RET_FAILURE; @@ -492,7 +495,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) addr = simple_strtoul(saddr, NULL, 16); else addr = CONFIG_SYS_LOAD_ADDR; - memcpy((char *)addr, __efi_helloworld_begin, size); + memcpy(map_sysmem(addr, size), __efi_helloworld_begin, size); } else #endif if (IS_ENABLED(CONFIG_BOOTEFI_TEST) && !strcmp(argv[1], "test")) { @@ -538,7 +541,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } printf("## Starting EFI application at %08lx ...\n", addr); - r = do_bootefi_exec((void *)addr, bootefi_device_path, + r = do_bootefi_exec(map_sysmem(addr, 0), bootefi_device_path, bootefi_image_path); printf("## Application terminated, r = %lu\n", r & ~EFI_ERROR_MASK); From patchwork Mon Jun 18 14:08:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930927 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YLb4XRmz9s3Z for ; Tue, 19 Jun 2018 00:26:31 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 40CB2C21F06; Mon, 18 Jun 2018 14:15:46 +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=none 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 12FDEC21E52; Mon, 18 Jun 2018 14:14:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7FDEBC21E68; Mon, 18 Jun 2018 14:09:50 +0000 (UTC) Received: from mail-oi0-f74.google.com (mail-oi0-f74.google.com [209.85.218.74]) by lists.denx.de (Postfix) with ESMTPS id A14B1C21EBF for ; Mon, 18 Jun 2018 14:09:44 +0000 (UTC) Received: by mail-oi0-f74.google.com with SMTP id e10-v6so9921187oig.16 for ; Mon, 18 Jun 2018 07:09:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=OQ8t5sjPBSjLzt80b2Mq5DbvLL0qFHfv9SG5jB4Kdg8=; b=qf1bsoL4Qjwca6JeftEHYrfxpqEerhOYGzhOU+o7HglwJAAqLbfKHuYk+O/7EcRvME AvyTzI3xF05d9AkKwIF4gEDOCJaqrmgJRBzqNFdXA76D9G+YDEOD5yGXDUXyLmtbIKvU YfKlFLJRycWZidbX1tkcQPIv1DNamPwBo0GuRT9v4VEAdeJWgHVgIehwvytlnDetyN9B L875qrPK479vzcbSp/IuzreHxFCjZH9LpJRGMpIVuGQbNAvo2zQuad0JP2YQkYUo4/3t Yp0Qrn1lkW5yrw7mOt9IF1B3NIK040K/BA4/empj6erPwPeKuqQDotO5MdeKsx+PQLIN 8ftA== X-Gm-Message-State: APt69E1Dy7r9oqQ1YtKYex4eHQr9QJOo8ptnNMwv0HiCNxt6LGwbASoG /jMRDwDwl1F2kHOxR8Rgff0IDXg= X-Google-Smtp-Source: ADUXVKLl/zNDmVB3qV/EfOUZUDwIszIdvtc8S3m4CXKujQxhXDjKiT3cKOFoD7eDUteDEodROngllxo= MIME-Version: 1.0 X-Received: by 2002:a9d:4781:: with SMTP id b1-v6mr6383805otf.43.1529330983632; Mon, 18 Jun 2018 07:09:43 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:27 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-23-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 22/30] efi: sandbox: Tidy up copy_fdt() to work with 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" At present this function takes a pointer as its argument, then passes this to efi_allocate_pages(), which actually takes an address. It uses casts, which are not supported on sandbox. Also the function calculates the FDT size rounded up to the neared EFI page size, then its caller recalculates the size and adds a bit more to it. This function is much better written as something that works with addresses only, and returns both the address and the size of the relocated FDT. Also, copy_fdt() returns NULL on error, but really should propagate the error from efi_allocate_pages(). To do this it needs to return an efi_status_t, not a void *. Update the code in this way, so that it is easier to follow, and also supports sandbox. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None cmd/bootefi.c | 78 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 28 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index b62635f448..5ef2d8499c 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -119,17 +119,30 @@ static void set_load_options(struct efi_loaded_image *loaded_image_info, loaded_image_info->load_options_size = size * 2; } -static void *copy_fdt(void *fdt) +/** + * copy_fdt() - Copy the device tree to a new location available to EFI + * + * The FDT is relocated into a suitable location within the EFI memory map. + * An additional 12KB is added to the space in case the device tree needs to be + * expanded later with fdt_open_into(). + * + * @fdt_addr: On entry, address of start of FDT. On exit, address of relocated + * FDT start + * @fdt_sizep: Returns new size of FDT, including + * @return new relocated address of FDT + */ +static efi_status_t copy_fdt(ulong *fdt_addrp, ulong *fdt_sizep) { - u64 fdt_size = fdt_totalsize(fdt); unsigned long fdt_ram_start = -1L, fdt_pages; + efi_status_t ret = 0; + void *fdt, *new_fdt; u64 new_fdt_addr; - void *new_fdt; + uint fdt_size; int i; - for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { - u64 ram_start = gd->bd->bi_dram[i].start; - u64 ram_size = gd->bd->bi_dram[i].size; + for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { + u64 ram_start = gd->bd->bi_dram[i].start; + u64 ram_size = gd->bd->bi_dram[i].size; if (!ram_size) continue; @@ -142,30 +155,37 @@ static void *copy_fdt(void *fdt) * Give us at least 4KB of breathing room in case the device tree needs * to be expanded later. Round up to the nearest EFI page boundary. */ - fdt_size += 4096; + fdt = map_sysmem(*fdt_addrp, 0); + fdt_size = fdt_totalsize(fdt); + fdt_size += 4096 * 3; fdt_size = ALIGN(fdt_size + EFI_PAGE_SIZE - 1, EFI_PAGE_SIZE); fdt_pages = fdt_size >> EFI_PAGE_SHIFT; /* Safe fdt location is at 127MB */ new_fdt_addr = fdt_ram_start + (127 * 1024 * 1024) + fdt_size; - if (efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, - EFI_RUNTIME_SERVICES_DATA, fdt_pages, - &new_fdt_addr) != EFI_SUCCESS) { + ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, + EFI_RUNTIME_SERVICES_DATA, fdt_pages, + &new_fdt_addr); + if (ret != EFI_SUCCESS) { /* If we can't put it there, put it somewhere */ new_fdt_addr = (ulong)memalign(EFI_PAGE_SIZE, fdt_size); - if (efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, - EFI_RUNTIME_SERVICES_DATA, fdt_pages, - &new_fdt_addr) != EFI_SUCCESS) { + ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, + EFI_RUNTIME_SERVICES_DATA, fdt_pages, + &new_fdt_addr); + if (ret != EFI_SUCCESS) { printf("ERROR: Failed to reserve space for FDT\n"); - return NULL; + goto done; } } - new_fdt = (void*)(ulong)new_fdt_addr; + new_fdt = map_sysmem(new_fdt_addr, fdt_size); memcpy(new_fdt, fdt, fdt_totalsize(fdt)); fdt_set_totalsize(new_fdt, fdt_size); - return new_fdt; + *fdt_addrp = new_fdt_addr; + *fdt_sizep = fdt_size; +done: + return ret; } static efi_status_t efi_do_enter( @@ -215,22 +235,27 @@ static efi_status_t efi_carve_out_dt_rsv(void *fdt) return EFI_SUCCESS; } -static efi_status_t efi_install_fdt(void *fdt) +static efi_status_t efi_install_fdt(ulong fdt_addr) { bootm_headers_t img = { 0 }; ulong fdt_pages, fdt_size, fdt_start, fdt_end; efi_status_t ret; + void *fdt; + fdt = map_sysmem(fdt_addr, 0); if (fdt_check_header(fdt)) { printf("ERROR: invalid device tree\n"); return EFI_INVALID_PARAMETER; } /* Prepare fdt for payload */ - fdt = copy_fdt(fdt); - if (!fdt) - return EFI_OUT_OF_RESOURCES; + ret = copy_fdt(&fdt_addr, &fdt_size); + if (ret) + return ret; + unmap_sysmem(fdt); + fdt = map_sysmem(fdt_addr, 0); + fdt_size = fdt_totalsize(fdt); if (image_setup_libfdt(&img, fdt, 0, NULL)) { printf("ERROR: failed to process device tree\n"); return EFI_LOAD_ERROR; @@ -247,14 +272,13 @@ static efi_status_t efi_install_fdt(void *fdt) return EFI_OUT_OF_RESOURCES; /* And reserve the space in the memory map */ - fdt_start = ((ulong)fdt) & ~EFI_PAGE_MASK; - fdt_end = ((ulong)fdt) + fdt_totalsize(fdt); - fdt_size = (fdt_end - fdt_start) + EFI_PAGE_MASK; + fdt_start = fdt_addr; + fdt_end = fdt_addr + fdt_size; fdt_pages = fdt_size >> EFI_PAGE_SHIFT; - /* Give a bootloader the chance to modify the device tree */ - fdt_pages += 2; + ret = efi_add_memory_map(fdt_start, fdt_pages, EFI_BOOT_SERVICES_DATA, true); + return ret; } @@ -454,7 +478,6 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) unsigned long addr; efi_status_t r; unsigned long fdt_addr; - void *fdt; /* Allow unaligned memory access */ allow_unaligned(); @@ -475,8 +498,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (!fdt_addr && *argv[2] != '0') return CMD_RET_USAGE; /* Install device tree */ - fdt = map_sysmem(fdt_addr, 0); - r = efi_install_fdt(fdt); + r = efi_install_fdt(fdt_addr); if (r != EFI_SUCCESS) { printf("ERROR: failed to install device tree\n"); return CMD_RET_FAILURE; From patchwork Mon Jun 18 14:08:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930908 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418Y960FdZz9ryk for ; Tue, 19 Jun 2018 00:18:17 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id BB96FC21E52; Mon, 18 Jun 2018 14:15:29 +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 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 BC0C5C21E6A; Mon, 18 Jun 2018 14:14:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B9CCAC21E1E; Mon, 18 Jun 2018 14:09:51 +0000 (UTC) Received: from mail-yw0-f201.google.com (mail-yw0-f201.google.com [209.85.161.201]) by lists.denx.de (Postfix) with ESMTPS id 627BEC21DFA for ; Mon, 18 Jun 2018 14:09:48 +0000 (UTC) Received: by mail-yw0-f201.google.com with SMTP id q66-v6so12366530ywc.18 for ; Mon, 18 Jun 2018 07:09:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=0DKJxRFcspdax7bW+FslM6mdu/9KYqw8H9AfugU9IxU=; b=oWIDNZWy4yl8HZnwVOXlNdPplU7pqUIQSrCDsZeaEa8ZXHTkOceqCjdEgqKxmkLUiI UHnpVpP0lVeLlOpS2Z+tGvpTE8nUQ47Y/n+ici7TpIUp3a25fL/nQXgsCeEmT7+pHyU6 3kagSNg9kbJ18bsa3IHEnIbFzpK+dqFWz8p7o2jlyluMdHH8PSJbkI2mFXfTAtMdZHeR lMrZGj9s7DRuoTka3T7EEzbZDzkVDpAxGksue04GACc8mqXSaNXp4egKXfcA+v+Umbxn gQ7DtaU5LWTnabdpv+FgfxCqaB9ld4Wp+QFwl98NOMXLVn8gubkJnhhvnj5PwWcpii77 0+Vg== X-Gm-Message-State: APt69E2SEeYJhTLYl6pTJVekf7WDyHA6e5CgSePuZS5bUTF0ShEesUTo p39EPDeQGWoEWucLmZDoOFsPy6c= X-Google-Smtp-Source: ADUXVKLGlHHNI+3oojQ2gsF+p7I6rAG1RD1lOqTGixrh4PodUJMUP9BczFFIx3Ood8XPDn+XrhULzb0= MIME-Version: 1.0 X-Received: by 2002:a25:a4e6:: with SMTP id g93-v6mr3498545ybi.11.1529330987467; Mon, 18 Jun 2018 07:09:47 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:28 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-24-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 23/30] efi: Drop error return in efi_carve_out_dt_rsv() 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 function currently returns an error code, but never uses it. There is no function comment so it is not obvious why. Presuambly the error is not important. Update the function to explain its purpose and why it ignores the error. Drop the useful error return value. Signed-off-by: Simon Glass Reviewed-by: Alexander Graf --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None cmd/bootefi.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 5ef2d8499c..7c41b641f6 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -214,8 +214,16 @@ static efi_status_t efi_run_in_el2(EFIAPI efi_status_t (*entry)( } #endif -/* Carve out DT reserved memory ranges */ -static efi_status_t efi_carve_out_dt_rsv(void *fdt) +/* + * efi_carve_out_dt_rsv() - Carve out DT reserved memory ranges + * + * The mem_rsv entries of the FDT are added to the memory map. Any failures are + * ignored because this is not critical and we would rather continue to try to + * boot. + * + * @fdt: Pointer to device tree + */ +static void efi_carve_out_dt_rsv(void *fdt) { int nr_rsv, i; uint64_t addr, size, pages; @@ -228,11 +236,10 @@ static efi_status_t efi_carve_out_dt_rsv(void *fdt) continue; pages = ALIGN(size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT; - efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE, - false); + if (!efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE, + false)) + printf("FDT memrsv map %d: Failed to add to map\n", i); } - - return EFI_SUCCESS; } static efi_status_t efi_install_fdt(ulong fdt_addr) @@ -261,10 +268,7 @@ static efi_status_t efi_install_fdt(ulong fdt_addr) return EFI_LOAD_ERROR; } - if (efi_carve_out_dt_rsv(fdt) != EFI_SUCCESS) { - printf("ERROR: failed to carve out memory\n"); - return EFI_LOAD_ERROR; - } + efi_carve_out_dt_rsv(fdt); /* Link to it in the efi tables */ ret = efi_install_configuration_table(&efi_guid_fdt, fdt); From patchwork Mon Jun 18 14:08:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930918 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YGp5phKz9ryk for ; Tue, 19 Jun 2018 00:23:13 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 0FBD0C21EE7; Mon, 18 Jun 2018 14:16:39 +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 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 6AEA8C21E79; Mon, 18 Jun 2018 14:15:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 05391C21E15; Mon, 18 Jun 2018 14:09:54 +0000 (UTC) Received: from mail-vk0-f73.google.com (mail-vk0-f73.google.com [209.85.213.73]) by lists.denx.de (Postfix) with ESMTPS id 4BE44C21DFF for ; Mon, 18 Jun 2018 14:09:51 +0000 (UTC) Received: by mail-vk0-f73.google.com with SMTP id d204-v6so7025965vka.23 for ; Mon, 18 Jun 2018 07:09:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=idE97fmVOLJaLGfL/GB43zllAGkh87McF1M1YKoQFgo=; b=qeVUpiXNl03qbtkjy2MHGigo+hHAUFfZgvLEotfZXgorHaGtshrxmRUlzVWDvzFXRP 2ALkARsugZG2Yla8t7z880abeoVpwz0Hx4QGDR/Rhc1JjfUr7M1y6y90PQp+pPA4WUyB w/s9qxZofFgV4BRe11ITIIsBmD0Qn7jiKHZQZuVJsXREF8Hv64wQKQoaQoJgUmU01d1D BQQCRFH0lXduPWRhQDFCQsiK8xxj2wBJIXvYjc38/w6VL0ooXm2UCaGgRiTn12PDM8r3 FhmQZmWDsxvryfvR5OH9xZa0a3fDa68YEOX6jdIkf9PKsHH5mfr+JJtElSDcBgO/IjZa p3dA== X-Gm-Message-State: APt69E3DTzzOnSwsFXxr5l6yJekmI5dY/1abzMRoHGhYDEOph5JaI6gV elmfiEINMg4v7nVfo6B4rRCZgqk= X-Google-Smtp-Source: ADUXVKK6rzvAHj8wOLL7VaSMO+Wv2Jh6Bu7HqWyMSTJTe7TX7frZbfRxQNQnk5E3OpTve6XoFTKOhOE= MIME-Version: 1.0 X-Received: by 2002:ab0:1268:: with SMTP id s40-v6mr5285032uac.41.1529330990364; Mon, 18 Jun 2018 07:09:50 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:29 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-25-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 24/30] efi: Adjust memory handling to support 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Sandbox does not support direct casts between addresses and pointers, since it uses an emulated RAM buffer rather than directly using host RAM. The current EFI code uses an integer type for addresses, but treats them like pointers. Update the code to maintain a (reasonably) clear separation between the two, so that sandbox can work. Unfortunately there remains an inconsistency between the arguments of allocate_pages() and allocate_pool(). One takes an address and one takes a pointer. Partly this seems to be defined by the boot services API itself but it would be fairly easy to update the functions in efi_memory.c to be consistent. However, this is a larger change and needs discussion. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None lib/efi_loader/efi_boottime.c | 13 +++++++++++-- lib/efi_loader/efi_image_loader.c | 3 ++- lib/efi_loader/efi_memory.c | 17 +++++++++++++---- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 50d311548e..aefafc3fba 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -14,6 +14,7 @@ #include #include #include +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -305,9 +306,17 @@ static efi_status_t EFIAPI efi_allocate_pages_ext(int type, int memory_type, uint64_t *memory) { efi_status_t r; + uint64_t addr; EFI_ENTRY("%d, %d, 0x%zx, %p", type, memory_type, pages, memory); - r = efi_allocate_pages(type, memory_type, pages, memory); + if (memory_type == EFI_ALLOCATE_MAX_ADDRESS || + memory_type == EFI_ALLOCATE_ADDRESS) + addr = *memory == -1ULL ? *memory : + map_to_sysmem((void *)(uintptr_t)*memory); + else + addr = 0; + r = efi_allocate_pages(type, memory_type, pages, &addr); + *memory = (uintptr_t)map_sysmem(addr, pages << EFI_PAGE_SHIFT); return EFI_EXIT(r); } @@ -328,7 +337,7 @@ static efi_status_t EFIAPI efi_free_pages_ext(uint64_t memory, efi_status_t r; EFI_ENTRY("%" PRIx64 ", 0x%zx", memory, pages); - r = efi_free_pages(memory, pages); + r = efi_free_pages(map_to_sysmem((void *)memory), pages); return EFI_EXIT(r); } diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index ecdb77e5b6..d5dd8864d7 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -9,6 +9,7 @@ #include #include +#include #include const efi_guid_t efi_global_variable_guid = EFI_GLOBAL_VARIABLE_GUID; @@ -301,7 +302,7 @@ void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info) /* Run through relocations */ if (efi_loader_relocate(rel, rel_size, efi_reloc, (unsigned long)image_base) != EFI_SUCCESS) { - efi_free_pages((uintptr_t) efi_reloc, + efi_free_pages(map_to_sysmem(efi_reloc), (virt_size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT); return NULL; } diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index c6410613c7..ad61b723e6 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -345,7 +345,7 @@ void *efi_alloc(uint64_t len, int memory_type) r = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, memory_type, pages, &ret); if (r == EFI_SUCCESS) - return (void*)(uintptr_t)ret; + return map_sysmem(ret, len); return NULL; } @@ -412,15 +412,17 @@ efi_status_t efi_free_pool(void *buffer) { efi_status_t r; struct efi_pool_allocation *alloc; + uintptr_t addr; if (buffer == NULL) return EFI_INVALID_PARAMETER; alloc = container_of(buffer, struct efi_pool_allocation, data); /* Sanity check, was the supplied address returned by allocate_pool */ - assert(((uintptr_t)alloc & EFI_PAGE_MASK) == 0); + addr = map_to_sysmem(alloc); + assert((addr & EFI_PAGE_MASK) == 0); - r = efi_free_pages((uintptr_t)alloc, alloc->num_pages); + r = efi_free_pages(addr, alloc->num_pages); return r; } @@ -471,7 +473,14 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, struct efi_mem_list *lmem; lmem = list_entry(lhandle, struct efi_mem_list, link); - *memory_map = lmem->desc; + memory_map->type = lmem->desc.type; + memory_map->reserved = 0; + memory_map->physical_start = (uintptr_t)map_sysmem( + lmem->desc.physical_start, + memory_map->num_pages << EFI_PAGE_SHIFT); + memory_map->virtual_start = memory_map->physical_start; + memory_map->num_pages = lmem->desc.num_pages; + memory_map->attribute = lmem->desc.attribute; memory_map--; } } From patchwork Mon Jun 18 14:08:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930933 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YNB0nkzz9s2t for ; Tue, 19 Jun 2018 00:27:53 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 9FBFCC21EE8; Mon, 18 Jun 2018 14:21:27 +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=none 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 A7BBFC21EFF; Mon, 18 Jun 2018 14:21:24 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4CD78C21EFF; Mon, 18 Jun 2018 14:09:57 +0000 (UTC) Received: from mail-ot0-f201.google.com (mail-ot0-f201.google.com [74.125.82.201]) by lists.denx.de (Postfix) with ESMTPS id 30DA4C21EC2 for ; Mon, 18 Jun 2018 14:09:54 +0000 (UTC) Received: by mail-ot0-f201.google.com with SMTP id p12-v6so10163473oti.6 for ; Mon, 18 Jun 2018 07:09:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=4aKriWbdjkssW15Q/i87EyWwepJhqjjF4/OyKD7krh4=; b=hhNTPttyep+csD7f3Yy++c8++vpFVUFSdoGFAEf0p0fq9fRTaePQABM4qhIDnbi7Pf MErp2bZuiTbv3GWOy4MrCHzfrEpw0eGVC6Ug6cxYACr6Z3oTfOVzG13EghnKcHGbueMG ujZsmdWqqp7tU6MQq6LQ7Mlcy3iO696SvcpU9Sq2DToVWncYCxT1k7nFUQEn6ckj3AZN 1mGSdBfJCzCgFxoNoc8wxzwnnVzEOSVwbJ2Fg8FRbO+Q8RYYDpur1jfK3gMRwCrmVda+ wSzoF4oPnAFZo9OqYWniYwgpWRhlG83+F/Xclk2Kcgxqj1ZXrG8p7lq8ciLDxTJPFuzU amvQ== X-Gm-Message-State: APt69E1OFLkGkuFm6iYWr6ghep6aTHqIb9vT/PAT8FUoaCC0Wx1pQOPe 9LRuCOrs+rBk6tYrIBzU8+vDiUk= X-Google-Smtp-Source: ADUXVKLgXKVLvg2pbRCgck/Xbe4GZrCsqJmNzWRkmveP4buM6B6g/lp5nEN4ppCirhAq4h1TVDkNASU= MIME-Version: 1.0 X-Received: by 2002:aca:d682:: with SMTP id n124-v6mr5918004oig.64.1529330993138; Mon, 18 Jun 2018 07:09:53 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:30 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-26-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 25/30] efi: Add more debugging for memory allocations 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" Add some more verbose debugging when doing memory allocations. This might help to find bugs later. Signed-off-by: Simon Glass Reviewed-by: Alexander Graf --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None lib/efi_loader/efi_boottime.c | 18 ++++++++++++++++++ lib/efi_loader/efi_memory.c | 22 +++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index aefafc3fba..2a41eb13aa 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -315,8 +315,12 @@ static efi_status_t EFIAPI efi_allocate_pages_ext(int type, int memory_type, map_to_sysmem((void *)(uintptr_t)*memory); else addr = 0; + debug(" input ptr %lx, addr %lx\n", (unsigned long)*memory, + (unsigned long)addr); r = efi_allocate_pages(type, memory_type, pages, &addr); *memory = (uintptr_t)map_sysmem(addr, pages << EFI_PAGE_SHIFT); + debug("* output addr %lx, ptr %lx\n", (unsigned long)addr, + (unsigned long)*memory); return EFI_EXIT(r); } @@ -364,11 +368,25 @@ static efi_status_t EFIAPI efi_get_memory_map_ext( uint32_t *descriptor_version) { efi_status_t r; + int i, entries; EFI_ENTRY("%p, %p, %p, %p, %p", memory_map_size, memory_map, map_key, descriptor_size, descriptor_version); r = efi_get_memory_map(memory_map_size, memory_map, map_key, descriptor_size, descriptor_version); + entries = *memory_map_size / sizeof(struct efi_mem_desc); + debug(" memory_map_size=%zx (%lx entries)\n", *memory_map_size, + (ulong)(*memory_map_size / sizeof(struct efi_mem_desc))); + if (memory_map) { + for (i = 0; i < entries; i++) { + struct efi_mem_desc *desc = &memory_map[i]; + + debug(" type %d, phys %lx, virt %lx, num_pages %lx, attribute %lx\n", + desc->type, (ulong)desc->physical_start, + (ulong)desc->virtual_start, + (ulong)desc->num_pages, (ulong)desc->attribute); + } + } return EFI_EXIT(r); } diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index ad61b723e6..856caa4a40 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -149,6 +149,24 @@ static s64 efi_mem_carve_out(struct efi_mem_list *map, return EFI_CARVE_LOOP_AGAIN; } +static void efi_mem_print(const char *name) +{ + struct list_head *lhandle; + + debug(" %s: memory map\n", name); + list_for_each(lhandle, &efi_mem) { + struct efi_mem_list *lmem = list_entry(lhandle, + struct efi_mem_list, link); + struct efi_mem_desc *desc = &lmem->desc; + + debug(" type %d, phys %lx, virt %lx, num_pages %lx, attribute %lx\n", + desc->type, (ulong)desc->physical_start, + (ulong)desc->virtual_start, (ulong)desc->num_pages, + (ulong)desc->attribute); + } + debug("\n"); +} + uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, bool overlap_only_ram) { @@ -237,6 +255,7 @@ uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, /* And make sure memory is listed in descending order */ efi_mem_sort(); + efi_mem_print(__func__); return start; } @@ -453,7 +472,8 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, map_entries++; map_size = map_entries * sizeof(struct efi_mem_desc); - + debug("%s: map_size %lx, provided_map_size %lx\n", __func__, + (ulong)map_size, (ulong)provided_map_size); *memory_map_size = map_size; if (provided_map_size < map_size) From patchwork Mon Jun 18 14:08:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930906 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418Y8V02Nhz9ryk for ; Tue, 19 Jun 2018 00:17:45 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 8E0E9C21E52; Mon, 18 Jun 2018 14:14: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=none 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 0D1D5C21ECA; Mon, 18 Jun 2018 14:12:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0999FC21E9F; Mon, 18 Jun 2018 14:10:00 +0000 (UTC) Received: from mail-io0-f202.google.com (mail-io0-f202.google.com [209.85.223.202]) by lists.denx.de (Postfix) with ESMTPS id 5505DC21E50 for ; Mon, 18 Jun 2018 14:09:57 +0000 (UTC) Received: by mail-io0-f202.google.com with SMTP id x14-v6so13416710ioa.6 for ; Mon, 18 Jun 2018 07:09:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=jOFGPF/4TSWjjtTuvhV9hgb8AqMpfxHCZGO7dHZPWJ4=; b=JJlKS2YxZ/YVrQdW5y6hFmp8Wg9sQ/73flK5Vr/eEwR2yOGWa/FU+Xj67xm3Yor0ns 5Hycrlj8mbLn91C8lZgOqC0MThsD8JsNQfrfSkHROfCMudd/nipmT8e3UltlNcx6GOiu LYptAM5xwPhTX0ZtyqcSG2unndmNHENMAfaiA1ezf9DAAYUM2VXN8NCYFUDDWl41K4Xo Vkh5zU60xQMATgVsE2B+/qrMc7am9TBXe+w+hc05JcOzqYkJbhQMHBLWbW906sJWIui7 u3I0wV9WbfNZ1UXdMtcgy9ohx7Dn0mNZ1Gnx8Otpb5VkgO3wjBWIAOKS+ME6WN0V4fqN Y4uw== X-Gm-Message-State: APt69E3D2Lr/MZBUWPjCPDX914t+0quqIYFSH1++sNVdSYwS1wY7w7oA c5T+jVSH+6DHmciHEKsFvpArttk= X-Google-Smtp-Source: ADUXVKKDMEU/IM1uKvJqbVjqhiJ+f0nh/F2Um63N00mvP/JSiuXzuWr2gmFAPchjWjBgce7LmFbJvqw= MIME-Version: 1.0 X-Received: by 2002:a24:2815:: with SMTP id h21-v6mr5071319ith.53.1529330996352; Mon, 18 Jun 2018 07:09:56 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:31 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-27-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 26/30] efi_loader: Use compiler constants for image loader 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" From: Alexander Graf The EFI image loader tries to determine which target architecture we're working with to only load PE binaries that match. So far this has worked based on CONFIG defines, because the target CPU was always indicated by a config define. With sandbox however, this is not longer true as all sandbox targets only encompass a single CONFIG option and so we need to use compiler defines to determine the CPU architecture. Signed-off-by: Alexander Graf Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None lib/efi_loader/efi_image_loader.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index d5dd8864d7..7e281f55e4 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -20,25 +20,25 @@ const efi_guid_t efi_simple_file_system_protocol_guid = const efi_guid_t efi_file_info_guid = EFI_FILE_INFO_GUID; static int machines[] = { -#if defined(CONFIG_ARM64) +#if defined(__aarch64__) IMAGE_FILE_MACHINE_ARM64, -#elif defined(CONFIG_ARM) +#elif defined(__arm__) IMAGE_FILE_MACHINE_ARM, IMAGE_FILE_MACHINE_THUMB, IMAGE_FILE_MACHINE_ARMNT, #endif -#if defined(CONFIG_X86_64) +#if defined(__x86_64__) IMAGE_FILE_MACHINE_AMD64, -#elif defined(CONFIG_X86) +#elif defined(__i386__) IMAGE_FILE_MACHINE_I386, #endif -#if defined(CONFIG_CPU_RISCV_32) +#if defined(__riscv) && (__riscv_xlen == 32) IMAGE_FILE_MACHINE_RISCV32, #endif -#if defined(CONFIG_CPU_RISCV_64) +#if defined(__riscv) && (__riscv_xlen == 64) IMAGE_FILE_MACHINE_RISCV64, #endif 0 }; From patchwork Mon Jun 18 14:08:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930934 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YNf3k6Fz9s2t for ; Tue, 19 Jun 2018 00:28:18 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id F334CC21E85; Mon, 18 Jun 2018 14:16:22 +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=none 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 93EDEC21EA2; Mon, 18 Jun 2018 14:15:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9380AC21E38; Mon, 18 Jun 2018 14:10:03 +0000 (UTC) Received: from mail-oi0-f74.google.com (mail-oi0-f74.google.com [209.85.218.74]) by lists.denx.de (Postfix) with ESMTPS id 16E21C21E88 for ; Mon, 18 Jun 2018 14:10:00 +0000 (UTC) Received: by mail-oi0-f74.google.com with SMTP id 9-v6so9703215oin.12 for ; Mon, 18 Jun 2018 07:10:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=79kIsDzYq/Mm5KubILaXuPoLDzbN4m5DsA//9ugDs5c=; b=X9R26DeFsBtw5EPdKcIgANtDWVxi5UwSXAHAJYawHFcs1dBWyVjExl8G7LT65+MqSO i47oW0A/j2XK8Fy2aYpEU/8+XtyqsoeJgQm2ap2jhj9C6ujpiCQwKt+GCWIPv0FzxiCF 0JRI2uTymTAgAwHWz3FT4HZxaen2wJnawtFTqkWza/rjV9P7AyeHpcx5ZHNsgHwAQ/8E 4AlMUkmwsUdLlqPyrFgXijEspKndBfyjnXwuouiIS5e1we933u20rl1ljjoW9ldGzDjw qcfkJ8byBpaF9cjcwnD5OqYLrQdFQet15bCx/byVy9PY1++T7xbWRuJ8pNqYtx0Rh33L C2ag== X-Gm-Message-State: APt69E0Vc/BkFp3q4BbGE1QtJ7GQ902e+ZOWaoXqqLTlxrvRYLtWzOm+ Xckm9mYvfCt+p0yGegqEro2sC/0= X-Google-Smtp-Source: ADUXVKIPD4XhINpIyopvXFlcx3fbS8+svZf7Ci6IozULIbuQ+ZZy+8PrzhfuoQLkLjpAES5sXwdasyc= MIME-Version: 1.0 X-Received: by 2002:aca:fd45:: with SMTP id b66-v6mr5703999oii.125.1529330999089; Mon, 18 Jun 2018 07:09:59 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:32 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-28-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 27/30] efi_loader: efi_allocate_pages is too restrictive 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" From: Heinrich Schuchardt When running on the sandbox the stack is not necessarily at a higher memory address than the highest free memory. There is no reason why the checking of the highest memory address should be more restrictive for EFI_ALLOCATE_ANY_PAGES than for EFI_ALLOCATE_MAX_ADDRESS. Signed-off-by: Heinrich Schuchardt [agraf: use -1ULL instead] Signed-off-by: Alexander Graf Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None lib/efi_loader/efi_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 856caa4a40..7804adacd2 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -315,7 +315,7 @@ efi_status_t efi_allocate_pages(int type, int memory_type, switch (type) { case EFI_ALLOCATE_ANY_PAGES: /* Any page */ - addr = efi_find_free_memory(len, gd->start_addr_sp); + addr = efi_find_free_memory(len, -1ULL); if (!addr) { r = EFI_NOT_FOUND; break; From patchwork Mon Jun 18 14:08:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930928 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YLY1sTHz9s2t for ; Tue, 19 Jun 2018 00:26:28 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id A9914C21E88; Mon, 18 Jun 2018 14:22:19 +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=none 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 CE7AAC21EE4; Mon, 18 Jun 2018 14:22:16 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A9313C21DDC; Mon, 18 Jun 2018 14:10:07 +0000 (UTC) Received: from mail-io0-f201.google.com (mail-io0-f201.google.com [209.85.223.201]) by lists.denx.de (Postfix) with ESMTPS id BC983C21DFF for ; Mon, 18 Jun 2018 14:10:02 +0000 (UTC) Received: by mail-io0-f201.google.com with SMTP id r10-v6so13375166ioh.7 for ; Mon, 18 Jun 2018 07:10:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=hhrntG6epDs9xIWTX83i0oxjemnGPxrY8b940jIkTfk=; b=RZQ3yTizsmg/4zVEU0pQdE6D46QF1R8FJvSgyETf85QnX0aY2yQYKhwJqLwKK83TQX 0NkO5f3Jn8NavAFC48BiEYFZCRnhW6ryJeT8AIH5u16kf+W7aTmZABfGDW+OBqw0K9Fp fKZJfi9Xj8hT2fdvOEKtbU+1HshnZTRHRwuLEywQpsd/jlMEnGswQBL/mF0hJlYm+hK8 J92xqpkf+pejEL37xpq+stLAds7lMMwYDtlld3h4hqmFIvoFLmcSMCVS3pSYq0ei0hY7 cIsJLGmuBR7A9T4fwGD4tFXVyV1jAiVJmQDJPSmeHLI4EzKeVxLLt5jeyY3P4i/wtSMf 0Frw== X-Gm-Message-State: APt69E0QcfQGw4H4cGa4l68/wo1GYRD5EnkDMTNDVmqNSTYR6aOB0vwP +0YIviGgJxXUuvH8YtdkVg5FRsg= X-Google-Smtp-Source: ADUXVKJMebcnm2quPN7dgLD01zM2qvXjvi8NqG+TCuSZ4kZZPXochdz767p4lyMftpYJlXX0f50O6ic= MIME-Version: 1.0 X-Received: by 2002:a24:455c:: with SMTP id y89-v6mr4953414ita.0.1529331001804; Mon, 18 Jun 2018 07:10:01 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:33 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-29-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 28/30] efi_loader: Disable miniapps on 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Alexander Graf In the sandbox environment we can not easily build efi stub binaries right now, so let's disable the respective test cases for the efi selftest suite. Signed-off-by: Alexander Graf Reviewed-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None lib/efi_selftest/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index 4fe404d88d..bf5c8199cb 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -41,7 +41,7 @@ endif # TODO: As of v2018.01 the relocation code for the EFI application cannot # be built on x86_64. -ifeq ($(CONFIG_X86_64),) +ifeq ($(CONFIG_X86_64)$(CONFIG_SANDBOX),) ifneq ($(CONFIG_CMD_BOOTEFI_SELFTEST),) From patchwork Mon Jun 18 14:08:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930921 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YJk3Ygrz9ryk for ; Tue, 19 Jun 2018 00:24:54 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id EB1B8C21E7E; Mon, 18 Jun 2018 14:15:13 +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 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 74AE1C21EB9; Mon, 18 Jun 2018 14:13:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B0490C21E7F; Mon, 18 Jun 2018 14:10:09 +0000 (UTC) Received: from mail-yw0-f202.google.com (mail-yw0-f202.google.com [209.85.161.202]) by lists.denx.de (Postfix) with ESMTPS id 808E3C21DFA for ; Mon, 18 Jun 2018 14:10:05 +0000 (UTC) Received: by mail-yw0-f202.google.com with SMTP id d129-v6so12859457ywe.4 for ; Mon, 18 Jun 2018 07:10:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=Di4jzXE3MzyExxj/o92QaW3wxf6sRY1AvQ8YVijoQUw=; b=mLq193m4WgJn8RCtXmsm++Y1BDgpJTrZgQFDB9m9/ShsWnsBY6HlbEzbHjyKMXEJrU WgWEgA5W6ynQS2QTg1GokGj+WQpoa5ursvCsTEeyrFiYBSJeDhPZSxBI0A0xmxX/UmQG vNrNbsW3DaEcQRgrdennEo9nL3wFv08voHpYr7xwo3ks2yJUkrz043Rup1mWcbj5bQjA gsDZQYHqat0FQXl2qjHSPbxVDqm01qWFKZIDQkoCAOA31Rj6D9PkohYKgqpnBH/UvgjX FLm+I2wU5x9iAY6CpxNW+JmS+3LDBzzV2DC/Dt4Ki8VtpRROwyRXvZTRLnZ7ktMkAUft 1LTw== X-Gm-Message-State: APt69E3XKx5rmKzU0QxKvDSq02YmpMO/gYOxfeeyKN3YHHGgVdP7R4cE uG0RuOrRokjvAVhUgZL+QX+PYzA= X-Google-Smtp-Source: ADUXVKIxOCmuqIZZ7JaeegrJHDd1yV00LKr2GopZ9+z+CzKpiepN84zZ91iuvyi+Sm1iNm2N0hXnkE4= MIME-Version: 1.0 X-Received: by 2002:a0d:e6d7:: with SMTP id p206-v6mr3454069ywe.37.1529331004606; Mon, 18 Jun 2018 07:10:04 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:34 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-30-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 29/30] efi_loader: Pass address to fs_read() 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" From: Alexander Graf The fs_read() function wants to get an address rather than the pointer to a buffer. So let's convert the passed buffer from pointer back a the address to make efi_loader on sandbox happier. Signed-off-by: Alexander Graf Reviewed-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None lib/efi_loader/efi_file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c index e6a15bcb52..2107730ba5 100644 --- a/lib/efi_loader/efi_file.c +++ b/lib/efi_loader/efi_file.c @@ -9,6 +9,7 @@ #include #include #include +#include #include /* GUID for file system information */ @@ -232,8 +233,10 @@ static efi_status_t file_read(struct file_handle *fh, u64 *buffer_size, void *buffer) { loff_t actread; + /* fs_read expects buffer address, not pointer */ + uintptr_t buffer_addr = (uintptr_t)map_to_sysmem(buffer); - if (fs_read(fh->path, (ulong)buffer, fh->offset, + if (fs_read(fh->path, buffer_addr, fh->offset, *buffer_size, &actread)) return EFI_DEVICE_ERROR; From patchwork Mon Jun 18 14:08:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930935 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YNt25SYz9s2t for ; Tue, 19 Jun 2018 00:28:30 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 066B0C21EB4; Mon, 18 Jun 2018 14:16:06 +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=none 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 2F7B9C21E70; Mon, 18 Jun 2018 14:14:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 02499C21E13; Mon, 18 Jun 2018 14:10:12 +0000 (UTC) Received: from mail-ot0-f202.google.com (mail-ot0-f202.google.com [74.125.82.202]) by lists.denx.de (Postfix) with ESMTPS id 69606C21EBA for ; Mon, 18 Jun 2018 14:10:08 +0000 (UTC) Received: by mail-ot0-f202.google.com with SMTP id a1-v6so9922757oti.8 for ; Mon, 18 Jun 2018 07:10:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=ZLbUApmZ3L3c+ZpYRUmRPSg2zjpC7yciU29iwT3ygAc=; b=LBn37RC6Qpks18Ohad2LCUR2e94Bhsz9v20EdC/1flq1QsWPHFNHcPXevtShLO6Ckt BiCbeyfRJszRDJ4oRxDAFyEA7t0SVGwv6wJyycDI3RlJdRVSlSFsa1Lx+9B7MxFMJFFp uX/4dobMoULEPVer6WRkqa/sVApVB5ZUWDiXfTN+AjEJLkvWvnEt89WvvfMYC97oizPF KWYCf/4fhveu14VclwPL99aPeQwl1JD+18i39aWZiAxII7Wtt14XvI+hjaiPnJxLD6vn qnLjqn3zthQzBYyQbMgN+YVfC9ph1Pg9GJFg0z2gi8BEwXHawbEhLLEb5fyy6EbIYKs8 U1kA== X-Gm-Message-State: APt69E1m5utCoNptt4+BFzv/dyzkAPxX6f2riTx+kPkq/2P9OAzoa7Vj q5ZwEnQkQKznYacq7HHkdWoMjdA= X-Google-Smtp-Source: ADUXVKI3mlRG1Fu9IUzC/gnuichxu6+Syyy5PDzSknl4pl6nPuPsSSKK9Nafb7iFMdujZ4i9ecERpWY= MIME-Version: 1.0 X-Received: by 2002:a9d:25b6:: with SMTP id q51-v6mr6177489ota.34.1529331007405; Mon, 18 Jun 2018 07:10:07 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:35 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-31-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 30/30] efi: sandbox: Enable selftest command 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" Enable this for sandbox since it passes now. Signed-off-by: Simon Glass --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None configs/sandbox_defconfig | 1 + lib/efi_selftest/Kconfig | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 2fc84a16c9..aa15d4acb9 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -200,3 +200,4 @@ CONFIG_UT_TIME=y CONFIG_UT_DM=y CONFIG_UT_ENV=y CONFIG_UT_OVERLAY=y +CONFIG_CMD_BOOTEFI_SELFTEST=y diff --git a/lib/efi_selftest/Kconfig b/lib/efi_selftest/Kconfig index b52696778d..59f9f36801 100644 --- a/lib/efi_selftest/Kconfig +++ b/lib/efi_selftest/Kconfig @@ -1,6 +1,6 @@ config CMD_BOOTEFI_SELFTEST bool "Allow booting an EFI efi_selftest" - depends on CMD_BOOTEFI && !SANDBOX + depends on CMD_BOOTEFI imply FAT imply FAT_WRITE help