From patchwork Thu Jun 14 16:55: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: 929583 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="ftFhz7qt"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4168sJ0VsXz9ryk for ; Fri, 15 Jun 2018 02:56:20 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id BC181C21E42; Thu, 14 Jun 2018 16:55:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id BBC78C21BE5; Thu, 14 Jun 2018 16:55:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 32873C21C27; Thu, 14 Jun 2018 16:55:32 +0000 (UTC) Received: from mail-io0-f196.google.com (mail-io0-f196.google.com [209.85.223.196]) by lists.denx.de (Postfix) with ESMTPS id 9BA95C21C27 for ; Thu, 14 Jun 2018 16:55:31 +0000 (UTC) Received: by mail-io0-f196.google.com with SMTP id t5-v6so7816704ioa.8 for ; Thu, 14 Jun 2018 09:55:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ly1dV12GSJXYKzqPvB/G1xZDViYsjU2C1bRAeneXF+U=; b=ftFhz7qtrEP4O5z4hC8/xbb351Pq0Y2r7pppn98SEzoEJnNgOKtzSIxL8NVjUcyF0N 1KSHKANwnO9Yo/FxkajhkyXpQ693t32UTz4eH68mNFb2I1NwQT63j72Xu+f7kD17lxdj hi04cT/9GBUHF2oveZLcid+BlQODlvHN+AgyKLvP+AvAYBjK6vJSEaxgwfzdeTHPVfn8 BY8CbNHYJWkRyjXTZY4UyK1E1rlWFU0zuVXVzHjlDBVRYQmFZgDAxQbT6ztZx5KlLiSl PdcFwEuiUmTC0edQa/orZXUekaS8yekECvnc/Eg1uxPKCSB/TSx9vqfAFdMgfFDfD0yG mkeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Ly1dV12GSJXYKzqPvB/G1xZDViYsjU2C1bRAeneXF+U=; b=DD/43qdeJ0WYbxBg5NwmVioGLxf+X/Uk+ZMXRXjMsUS2jiOghil2phT1DHA0aLt7Pi /1FFvgs1gJjJtJ0hs5ijOFdpY1fLUE2cZmK8XQYfCH76OpocZaNw+TuxuRc8N47qNJwc sTajjKakAzuY4SkFi93gcnNr5Ve17VzVWQ4m6Et9fFwdwf8huFBtt1gcdQawFCGjkj9r zva1VrtWtYaPJmmYdpmj1iP/iFg2Fasvs6NyffGptsin6EtocihrOAtYp7M8/YQuW+HB nI3w1srJa1/biX+rh8vsm1WSCrYzhU4boe0GBDE0zZSwjnlDlbZSBf/e3BdYe01siB/o X9Ww== X-Gm-Message-State: APt69E3Jk/Bctw0GNjHoN0i/3rgP6uyy53eqBbKSDin+sDptZYt6PhwQ tidcupFtt181u3iENkzGL1Ta1w== X-Google-Smtp-Source: ADUXVKKmtrZ2P5zLIJAiLasRKzpW9EUx4g96SrAmE+tcph5ESoIfLYb++giwKNvVGf+hmhjKLId2zw== X-Received: by 2002:a6b:9082:: with SMTP id s124-v6mr2997660iod.35.1528995330108; Thu, 14 Jun 2018 09:55:30 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id k16-v6sm2041833iog.45.2018.06.14.09.55.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jun 2018 09:55:29 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id 432B7140498; Thu, 14 Jun 2018 10:55:28 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 14 Jun 2018 10:55:16 -0600 Message-Id: <20180614165526.183597-2-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180614165526.183597-1-sjg@chromium.org> References: <20180614165526.183597-1-sjg@chromium.org> Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v7 01/10] 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: , MIME-Version: 1.0 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 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 Thu Jun 14 16:55: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: 929585 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="e8eQpEAw"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4168vV6X6Mz9ryk for ; Fri, 15 Jun 2018 02:58:14 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 8E259C21DE8; Thu, 14 Jun 2018 16:56: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_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A1971C21DCA; Thu, 14 Jun 2018 16:55:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BACCBC21C27; Thu, 14 Jun 2018 16:55:32 +0000 (UTC) Received: from mail-io0-f194.google.com (mail-io0-f194.google.com [209.85.223.194]) by lists.denx.de (Postfix) with ESMTPS id 2FC6DC21BE5 for ; Thu, 14 Jun 2018 16:55:32 +0000 (UTC) Received: by mail-io0-f194.google.com with SMTP id e15-v6so7857629iog.1 for ; Thu, 14 Jun 2018 09:55:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ddsiMcRjxx/2Xyyd5WkTNZFylGjBMIJ1aGBNtsE6Flw=; b=e8eQpEAwlocoHrleOrVboDRrOWXaKlrvO5BFtApCRoYSTnsM5Nqoe2/zJHMUHiIIc+ yI3rFpFRGPYspShFFlHfvLZNlXxkqaC8+onQDH37zVTABv01prR2/r/01QAVL/UV2X5Y +8Hluw7Mr0Hmouoa4ICfKo09Z5jMll7axso+NsUoh/hzYnBvksmM3B0wsQl4/dmQUb8o kLtVP6uggxl0277EMo5EXpzK97YwxWfxEu7zVP2MXm9QgQtLHf6V50tOyCmen82stWue v1Fpvhkb2cK84LzFyy8dT9s30ZCHwcWAVjOGu/IMEe7VDA2WURqf0V8/YNULCaP3FUq2 PFaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ddsiMcRjxx/2Xyyd5WkTNZFylGjBMIJ1aGBNtsE6Flw=; b=LqBOoL24b4nEpncWB9W0eQT3D4iLSCBznyqMH/D/RSQSo/QvD42VUJnSnoONGd6rgQ pAHktcNsZofyq4gToUZmvsHm5k+hgXKqx9xYEmoMDu7EbRa6Dk89Ts5j2EJMBvoZSHcl SsBbzWMXldZERqAkuIT6yQbCGR63eQ91PcW+G4l3qkcjCwTiVv65arPhNjO0WBlgdjfO MO+4OBs9/mJbtGU0Yd/bNabMRLFY2lZSEeGo7s5Fd2zUHoPbzFbk7JC94gt2xwn/qFYV pfeQyU7Ki+YLgz2fWqfQKMXYINbOlHJzPyUkPM8DGYHkMdZ8bt6bUCBHvew3k2VobUFD Qldw== X-Gm-Message-State: APt69E2B6fzC9HTMdwMWEPCZTDcseb6HoUHfPRRRr3tZMpzCQdncql44 Ax5BEV/nJqRstQTIh9MQQIGlDg== X-Google-Smtp-Source: ADUXVKJKxPDcWRgPX+IPpQMeFFwJdS1Rhy3r10GcNuWDHtYKvQRa89mvgy7XqiCjo9Gklgq819F0pQ== X-Received: by 2002:a6b:b3d6:: with SMTP id c205-v6mr3170270iof.93.1528995330649; Thu, 14 Jun 2018 09:55:30 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id y13-v6sm1957326iob.53.2018.06.14.09.55.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jun 2018 09:55:29 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id C651D1406CE; Thu, 14 Jun 2018 10:55:28 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 14 Jun 2018 10:55:17 -0600 Message-Id: <20180614165526.183597-3-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180614165526.183597-1-sjg@chromium.org> References: <20180614165526.183597-1-sjg@chromium.org> Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v7 02/10] efi: sandbox: Adjust memory usage for sandbox X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" With sandbox the U-Boot code is not mapped into the sandbox memory range so does not need to be excluded when allocating EFI memory. Update the EFI memory init code to take account of that. Also use mapmem instead of a cast to convert a memory address to a pointer. Signed-off-by: Simon Glass --- Changes in 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 Thu Jun 14 16:55: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: 929584 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="gZKMA9FG"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4168v623zQz9ryk for ; Fri, 15 Jun 2018 02:57:53 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id BA117C21DA2; Thu, 14 Jun 2018 16:56: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=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7B840C21CB6; Thu, 14 Jun 2018 16:55:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 02EC8C21C29; Thu, 14 Jun 2018 16:55:33 +0000 (UTC) Received: from mail-it0-f67.google.com (mail-it0-f67.google.com [209.85.214.67]) by lists.denx.de (Postfix) with ESMTPS id 52755C21BE5 for ; Thu, 14 Jun 2018 16:55:33 +0000 (UTC) Received: by mail-it0-f67.google.com with SMTP id l6-v6so9640855iti.2 for ; Thu, 14 Jun 2018 09:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=sTGeFyDliKX4Oa5ZA99ANYgQg1U292uXPVRIOCyj4X8=; b=gZKMA9FGeZoUSZ3JBYAFOq4BsaK7bc/TGzeQfUDAfnS6i0U6auVYxj15XnrLYwcK8e r81U8pepZiz21g5Nh9Yyua7uDd9d9T12m9fFPT81UoHC5oi4QsCA1cDJT0FSx3o5OXlb Ux8xTrh+vIaHDWPbuOscKAOxO1RPvE3d5en0gVselisdC6vlWWyY70HXrSaSbotBEZL8 WbdM1ZMui34j18lqgvNFZl4zNvuQSfc8YbpcZiiBjW9qiPh8rD9KCm4GunpX/kCXBrUp kn1C7qMbkLQI6R8oBE4yySuApztrZl6zhAIKhFncECf0KH9xfmWsLyVf2lGTPMdF1nxo ErXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=sTGeFyDliKX4Oa5ZA99ANYgQg1U292uXPVRIOCyj4X8=; b=lQaQy56KaZulklGABd9V2SOHnPblkOyA94pfBwgOmi+YBOJE5Fzd7p17TWWtmLsL2w 4fwBQGPceEMN26Mi4VWtAdawjgAvLy2OBWWDa9qcL+59rYdjimJjBB7Ji2NKQuRaLtx/ kWQXppAnFq6UD0wOpsv+0G9UAP8Dd1AKVzhECkgIx1PKPqG5MVycY5afOvAp6c6y55/N wkpeqUeqnlw3kn1ydVFJ6We7Ehg757j9yYJ+8Np4RVMUHwyulcNxn454qRBw0MBt12A+ PsR9YOT3xRuDswWps9a9kfAcAGhXNqalk92kB0kBI1+ewXCR2SyoGNUI5uGKxvV9LE5O Zzdg== X-Gm-Message-State: APt69E2VFA5xi1iBxVeWnmWvpHkgZ2KHYTdfuiUg89o3W6PmcwSZq3T6 qA2Wtca1xZgq1OBhPgczy5+iRA== X-Google-Smtp-Source: ADUXVKIN6Pgpu6+YtQ296yVyh4Q16gjeMK7C0dzUEcoE9AIjLfqBDnJTKAaYeRkPnr9TS/3fTZ8RNQ== X-Received: by 2002:a24:491f:: with SMTP id z31-v6mr2852279ita.49.1528995331662; Thu, 14 Jun 2018 09:55:31 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id z68-v6sm2785498ioz.79.2018.06.14.09.55.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jun 2018 09:55:30 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id 45929140984; Thu, 14 Jun 2018 10:55:29 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 14 Jun 2018 10:55:18 -0600 Message-Id: <20180614165526.183597-4-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180614165526.183597-1-sjg@chromium.org> References: <20180614165526.183597-1-sjg@chromium.org> Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v7 03/10] 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: , MIME-Version: 1.0 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 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 Thu Jun 14 16:55: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: 929589 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="d9gibGor"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41690B3lr5z9s01 for ; Fri, 15 Jun 2018 03:02:18 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 379E6C21E13; Thu, 14 Jun 2018 16:56:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 55704C21E26; Thu, 14 Jun 2018 16:55:39 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1B376C21DD4; Thu, 14 Jun 2018 16:55:34 +0000 (UTC) Received: from mail-io0-f193.google.com (mail-io0-f193.google.com [209.85.223.193]) by lists.denx.de (Postfix) with ESMTPS id C9DE6C21C27 for ; Thu, 14 Jun 2018 16:55:33 +0000 (UTC) Received: by mail-io0-f193.google.com with SMTP id l25-v6so7789003ioh.12 for ; Thu, 14 Jun 2018 09:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ASnz7pn7W60nAFa1YJt6sutf3TyvCfLi333qIAKkYHg=; b=d9gibGorTCssr6VB3G8i6WlpRaQ5Jr7FB53S0o4iFnv5m2/e5tBEh7omOHKpFVPTjY uzdw7jNL58AbdOOAiv9517B1k8y9GNKDqUB+hvOAf+Wuy0xwVl87+YeG4aWl9Tq/FUhG zT04xCOxePTUyS4aIHA4zB84COu03HSvqFbRS/CRFKd7DZh7jAuMWvu9Wdi/4vKfrhw4 pCaiYfK5iJViB1n+aVBJA17nsOD2FgwUDc7HgE3Z6VLEYhodNUdwBkkZYnWSKtB93lEe yNBz1kNmMy3YpfpbX1QtuYYI8st/Kqp2rX5suHoPuPfKmbTdeoabMig6lDXtgWaoFDeC OuYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ASnz7pn7W60nAFa1YJt6sutf3TyvCfLi333qIAKkYHg=; b=ARiK4S9OuDzj0IzqeuSRGWazQ8kXvzhzcM3LyeuIWgwcNLnZs0nEQO8biPY9IkS8Lv QwsOnVF1opK8q/GZQWDibvvBSfoHO71i7b1TJbEcTrJwGnWTqrk9QAY+5Bj6M04RDbtn BSknRJoG/rEn1J4mHC5gZbCFcWxOrRCoAwYICZjdTB3DQ5LiVzP5YbbW/S8W5k2vrXQj Xq2soIZUkiJ1KfP6YMzt8prvCzlwryOw9BxVOJytzv2l7YSPrvMiBZ+yEPBkOL7bmleS +O7P4Ka/bREWRI/uDduSecIg/ONtSd/YYSX5MlFtGaxZNzfcK0Teq/N8NR1UXdWRRE14 S8NA== X-Gm-Message-State: APt69E2OJZt2TokwFtmixQ+xvTaT9zBUaAfT0HUiqsPmW/Z9E+8Sc/EP ruHNV3lXSCdayZ2Z5SR1vWCtoA== X-Google-Smtp-Source: ADUXVKKffh7qVyjvNLSb1e8krtmUKDfpJY7IHNusMDfbdpeCzYq9FLZoLANa3s23QKUlSFpjmuSREA== X-Received: by 2002:a6b:588:: with SMTP id 130-v6mr2772502iof.282.1528995332237; Thu, 14 Jun 2018 09:55:32 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([100.67.80.24]) by smtp.gmail.com with ESMTPSA id r6-v6sm1953124ioj.74.2018.06.14.09.55.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jun 2018 09:55:30 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id C0844140484; Thu, 14 Jun 2018 10:55:29 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 14 Jun 2018 10:55:19 -0600 Message-Id: <20180614165526.183597-5-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180614165526.183597-1-sjg@chromium.org> References: <20180614165526.183597-1-sjg@chromium.org> Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v7 04/10] 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: , MIME-Version: 1.0 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 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 Thu Jun 14 16:55: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: 929588 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="RE8HvhDc"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4168zT2pd8z9s01 for ; Fri, 15 Jun 2018 03:01:41 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1B801C21DD4; Thu, 14 Jun 2018 16:57: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_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 1BC76C21DFD; Thu, 14 Jun 2018 16:55:51 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2C68CC21E2F; Thu, 14 Jun 2018 16:55:40 +0000 (UTC) Received: from mail-io0-f195.google.com (mail-io0-f195.google.com [209.85.223.195]) by lists.denx.de (Postfix) with ESMTPS id 637EAC21DEC for ; Thu, 14 Jun 2018 16:55:35 +0000 (UTC) Received: by mail-io0-f195.google.com with SMTP id g7-v6so7807343ioh.11 for ; Thu, 14 Jun 2018 09:55:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=5bbVRmuujN42cRcg/s84Ws95rhDSGQvfFLIY2N3hyKY=; b=RE8HvhDcQ1FWs+T9haJlgksGbrF/dqmxox784bGNPBMG5Hv9QdziDuP1a+RCfKIUYg E79FaFnB1gEO1TBcjebmBFMH5+HkwTENUR0Eve0+FWZJsoRMYEx5EdXCNte00cjfc0m1 zeZNjtWCgrHpsycmloSLAv9pCPdCZEXOYRAj8NxzDcapuMD+b7NJB8jro5iHO6gPCmSe rOCYD+6iHYN7krWSGV0A3wTnGQnVyWXIayMCG5knRAHKGbhO8g9iPQRyQBpGPhWSgK3w OxjMTuS+Yse6jM+87Xb/TkIzUdMSetQsq1NFDuBo29B6IK5U+jbRjzwFnfzX8HqDyIYM LKiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=5bbVRmuujN42cRcg/s84Ws95rhDSGQvfFLIY2N3hyKY=; b=oxP5vZd83kuopJRDpUvI+vJfHEKqURDAptAao6sqMyAZHygA7uPQxQk9c0px7jBBt5 FSlRMmxR9+8LUvMGA3jqlqf5wjw0uf8qVxdWYue0Ekjjcy39rf3JC3UyUlXr+kbNb60y AGU0K2zSpp6i6jSoQ3/1FdzILiEvSA7IusrI5GH0VaI2GslxCM8IuQ/wbX4SCHWK0+OL F+nrispizCvLtVCVsyxIiYITsj+YBf9vIQsWbkJsdaOaCeuxbVqvVWn3MN+nCylDQy1l qtZlKjIDUnXZaGTxYlXddv8I0JFtNyUQbCUpJRemMEndUTr6XISiAtY4c29pl+3jbZUx RVQw== X-Gm-Message-State: APt69E3rrQI8ZiEk6cQYSi690HR3ZcyQ7AFIpdF2whLv8tg0U/f641rQ 91Y6uONlXsq6LFMwCvn3SbPqRg== X-Google-Smtp-Source: ADUXVKJOmU19i9IE4DsE2Xv+fH+eTFqjLYd8/5OSnIFGKdr5OZacSj2FMh258Bcf+0Q/m/jNGEM2pQ== X-Received: by 2002:a6b:b8d5:: with SMTP id i204-v6mr2968402iof.284.1528995333706; Thu, 14 Jun 2018 09:55:33 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([100.67.80.24]) by smtp.gmail.com with ESMTPSA id f72-v6sm2212873iof.14.2018.06.14.09.55.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jun 2018 09:55:32 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id 3D866140498; Thu, 14 Jun 2018 10:55:30 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 14 Jun 2018 10:55:20 -0600 Message-Id: <20180614165526.183597-6-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180614165526.183597-1-sjg@chromium.org> References: <20180614165526.183597-1-sjg@chromium.org> Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v7 05/10] 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: , MIME-Version: 1.0 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 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 65f2bcf140..f439223abc 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -58,6 +58,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 Thu Jun 14 16:55: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: 929590 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="f1GVQ2mT"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41690H06W8z9s01 for ; Fri, 15 Jun 2018 03:02:22 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id A37FBC21E35; Thu, 14 Jun 2018 16:57:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 36A60C21E1A; Thu, 14 Jun 2018 16:55:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0B2AAC21E3E; Thu, 14 Jun 2018 16:55:40 +0000 (UTC) Received: from mail-it0-f67.google.com (mail-it0-f67.google.com [209.85.214.67]) by lists.denx.de (Postfix) with ESMTPS id C691EC21DFB for ; Thu, 14 Jun 2018 16:55:35 +0000 (UTC) Received: by mail-it0-f67.google.com with SMTP id 188-v6so9610588ita.5 for ; Thu, 14 Jun 2018 09:55:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=aYInXOzQD2MbVlrTa+xBi3oMuMZ6gCQfLm/LJ++rTGo=; b=f1GVQ2mTM+h39CChvPpgG8XeKxRCXi7VxqxLQkSQmvogwOySmDSAqVlBW9ap/VtDbY QC4ytGHQA42Dsy3uo1FUdmKp22qOxWaE1ch31Wg5+PEaAoG3RXSI7qNMw97gqpTekcJf RA9rwMszcj47/s4eENvcB++CeSW3PMzOmbf/EiT1COqFCTvqNrcNq6t3nUXvp1FIYaCi z3Px5CLBiI/W4sWqicoXN5NRRDoTWSz2MtopjnZu37XP3N6/2et+Na+i0C/w08ayyxT3 Okfm3neaoTHELaNGvN0AE5HQP+5V/mWoQqRp/L+OCLwOE4S1H2W6MIRDOBRur3MKK2zD bXKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=aYInXOzQD2MbVlrTa+xBi3oMuMZ6gCQfLm/LJ++rTGo=; b=NCTP9noWT57fj3yYc+QVvFmWvTIJY5EAU3xwCN5AloihL1ZgWYJsZebgNIQLTeQZJ3 HJqGDjjpAZb5hG5JC26Azi6ueiQmA4AcxQwQBObuLB5/gTndj3/1JCX4HxJs/zKot/e6 y4BWbKzec655sVDm+HHQZslAHpWh6N7aesEbOmWT4RU2UNIHgNOqxwYreSQk0a3Oabf/ 7Z6OZiJOHTKLx5qLDyC9R3G1ufhdbFV/HxSfwZKaDM+RNkkq08i0Ov7HL3EOob2XzYwb K92r1q5mzqB6jGCA5geOY7IHZ9q/GtyLbzj4dvEsEv5vXBInsiIKKghUoVOe5UnC2eW/ YiWg== X-Gm-Message-State: APt69E1MzN/2uWJJrp63M4Q2xuvEXnHUAEiOMGs3vjRy/5SKftqLGO/s o2gCF9sCQ7nPt6seAsamzmaogA== X-Google-Smtp-Source: ADUXVKK7I9y4LmlteM/1c9PFjZ9y/oSljj628Cq22bP/hG+KztrG+beYhJs90nY1umrNzNQB8L3BhA== X-Received: by 2002:a24:1d8f:: with SMTP id 137-v6mr3090487itj.41.1528995334232; Thu, 14 Jun 2018 09:55:34 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([100.67.80.24]) by smtp.gmail.com with ESMTPSA id o80-v6sm2162290ito.44.2018.06.14.09.55.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jun 2018 09:55:32 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id B8D551406CE; Thu, 14 Jun 2018 10:55:30 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 14 Jun 2018 10:55:21 -0600 Message-Id: <20180614165526.183597-7-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180614165526.183597-1-sjg@chromium.org> References: <20180614165526.183597-1-sjg@chromium.org> Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v7 06/10] 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: , MIME-Version: 1.0 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 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 Thu Jun 14 16:55: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: 929587 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="GywnVWNy"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4168wX40Xkz9ryk for ; Fri, 15 Jun 2018 02:59:08 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 354A6C21DEC; Thu, 14 Jun 2018 16:57:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2E85BC21E0F; Thu, 14 Jun 2018 16:55:47 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 31901C21E2F; Thu, 14 Jun 2018 16:55:40 +0000 (UTC) Received: from mail-io0-f180.google.com (mail-io0-f180.google.com [209.85.223.180]) by lists.denx.de (Postfix) with ESMTPS id 5515AC21DF3 for ; Thu, 14 Jun 2018 16:55:36 +0000 (UTC) Received: by mail-io0-f180.google.com with SMTP id d22-v6so7800873iof.13 for ; Thu, 14 Jun 2018 09:55:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=4GYumHRYOhzUkBvSOV51QHLPIMmBSzISiVwDSrxV9b0=; b=GywnVWNyy+UWcEjj9r5Ja949+8dNgZqNM9qAMvbMk4S0MGfDTgJN83H+oYHrR5k4Xk D8WP3xX8WyugU/RNiSwpQcYlYXV3QQ8uWGfFo7QwZcaWMZzThfvvz8lRahuKsVS6pliU IYvCCFice4sfyiNRSr03ZV1FCJnAEG075/hy7cnahg7PtZejsYlOz4lSPuSnNzjJs3mt FNvcLVjfCJZG2giwAVcLd0pnHLwzLnlOwsXa8Y6El8J340Ham5uiyTYOJnBV0Ug8GvFR Pd0+VhuO/JvaSfXj0sTTPRKhM8Y40AtW3KqbPgFTnV3+7CZNquAcodD8/863XB9eHu+e uncA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=4GYumHRYOhzUkBvSOV51QHLPIMmBSzISiVwDSrxV9b0=; b=dNS2g1yEKHpjlK8X0FE3iQaazqGZD2cZZS4nABjQ1vGPD870n1FIbyoC9JIGOCf9LY COsOHKZk9uSWh9j4WOWzt6imkk7Rw9BNW4/7XWoKGOHXoT2u2x4ZDHI38qbD9FiMyNZ0 h4OYMdcHANZu+9Yhd5NB6zlM2nW8zz9WU4vYxNpa1sfGyJW70eYHvVzUECdXd+v8zNfU R37dVIju6ngeiiL/tae1jIxTS0K2M+VEvdWxOvMli/FU3DvQUJUiDK80lor5x1F0J0Y7 5Gr4NaB+URbKnPmBhmleDyqPUWVJg4foztlG40ppQhUV0KNBoF98qgJR1XP7ArKZzRPU aYwQ== X-Gm-Message-State: APt69E1iD6O6r30ObG6ltf1yJ9Qy18IkGK8e90dCfl7HaLP+2t2nTvTQ cqFMTwNWqh9w/Xc6q4PofEazTw== X-Google-Smtp-Source: ADUXVKL7tR1Oa9+3ViDyXk/A3vITsMJXhl40AeOwIhPVgoTwFKYxp+6IF/U538kBgu9QBj4B9cLCtw== X-Received: by 2002:a6b:17c7:: with SMTP id 190-v6mr2839758iox.17.1528995334704; Thu, 14 Jun 2018 09:55:34 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id y64-v6sm3026282itb.33.2018.06.14.09.55.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jun 2018 09:55:32 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id 45114140C16; Thu, 14 Jun 2018 10:55:31 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 14 Jun 2018 10:55:22 -0600 Message-Id: <20180614165526.183597-8-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180614165526.183597-1-sjg@chromium.org> References: <20180614165526.183597-1-sjg@chromium.org> Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v7 07/10] 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: , MIME-Version: 1.0 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 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 707d159bac..a9ebde0c75 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -347,6 +347,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; @@ -425,31 +479,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 Thu Jun 14 16:55: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: 929591 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="nwm1Oe39"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41691z2tBqz9s01 for ; Fri, 15 Jun 2018 03:03:51 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 26EBFC21E15; Thu, 14 Jun 2018 16:58:41 +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=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id F29E6C21E73; Thu, 14 Jun 2018 16:56:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7BA1FC21DF8; Thu, 14 Jun 2018 16:55:42 +0000 (UTC) Received: from mail-io0-f178.google.com (mail-io0-f178.google.com [209.85.223.178]) by lists.denx.de (Postfix) with ESMTPS id 52604C21DE8 for ; Thu, 14 Jun 2018 16:55:37 +0000 (UTC) Received: by mail-io0-f178.google.com with SMTP id e15-v6so7857922iog.1 for ; Thu, 14 Jun 2018 09:55:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ofkIafnf31LJJr66+z8s7wAdVxk1cFYOiRfM/quxR7Y=; b=nwm1Oe39j6NdB9Y/hhuI/+H9rDOlWKOamWm1dyrAyBKIcXnIwxD40jnzut7RZFAFZX GL+BjzPVJOFfE530p8sec62Hh5HmNztdodflk1pypx7ltaxm+sPgwgHbCiJ4lL8wRzdL J1CQLDS6Y+LzgydQAIdk6LYjYlK0ihVBB/5ddeby+uDpmxvmPhRu1vS5pBOlv6ClfNwW gFa2zl252lsemwBJY+6vjZ6ozbu/y8T2JY8Z5q8+uMOYL73hszMsRKCmfY3EvWdMhkLj n0wFprD5WKSErpspzai7ytS+A3HzCfAShG05+8rzgjLZ5+UXXWcalzUNDl4TXNkxwfwD O5xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ofkIafnf31LJJr66+z8s7wAdVxk1cFYOiRfM/quxR7Y=; b=XwWW0znQRHanWqWA71dIp5PoxA8RqnLEuNQ2UopFrE8+MGCZap8lNsMabZD8VUzt05 wx2mxSDfDUvB2sLKwpmZayR5Y5QoF1kR+2FnuzXK15rY6uNnMkpl+34HikrNEo4GdG97 Lnqfy3toYcKaMxUXgjO517xP8EWs05Y8xC8WkDpzma9U+ZTQP8QOskA9P16SqvF3OAf3 SGOPitBxDWREFBLqM7tZZLmm2kRh/L+rgf8vqSx7S42b0zbOcwrpkdilw/K7oP6VRLqY +PEuICd7ZpAzLpOwDV0I5Jap7X5IViwU1HczTyDLSY8KRyThDqP9QULRzwfAb1JShac4 xptQ== X-Gm-Message-State: APt69E3B6XwAEakMbVX4FvZbk9wgShFOxQwfB3fZnRBKqqMOLlsm4gh3 dNcHvI8qjHi7vgXch39vdoeclA== X-Google-Smtp-Source: ADUXVKKwpU0enlTXVz2gVuG39WpK8VXJRLgfF5WScS9wrGFQ/eGZZG2BF106mW0YX+hN63oQTG6KZA== X-Received: by 2002:a6b:f314:: with SMTP id m20-v6mr2994777ioh.253.1528995335641; Thu, 14 Jun 2018 09:55:35 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id j140-v6sm2851027itj.33.2018.06.14.09.55.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jun 2018 09:55:32 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id C7B3F140984; Thu, 14 Jun 2018 10:55:31 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 14 Jun 2018 10:55:23 -0600 Message-Id: <20180614165526.183597-9-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180614165526.183597-1-sjg@chromium.org> References: <20180614165526.183597-1-sjg@chromium.org> Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v7 08/10] 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: , MIME-Version: 1.0 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 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 a9ebde0c75..ac80074bc4 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -347,7 +347,6 @@ exit: return ret; } -#ifdef CONFIG_CMD_BOOTEFI_SELFTEST /** * bootefi_test_prepare() - prepare to run an EFI test * @@ -399,7 +398,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) { @@ -431,8 +429,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; @@ -477,11 +477,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 Thu Jun 14 16:55: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: 929586 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="kKQSBiGu"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4168wG2ZSKz9ryk for ; Fri, 15 Jun 2018 02:58:54 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 03620C21DEC; Thu, 14 Jun 2018 16:58: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=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2509EC21E56; Thu, 14 Jun 2018 16:56:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D9A35C21E56; Thu, 14 Jun 2018 16:55:45 +0000 (UTC) Received: from mail-io0-f173.google.com (mail-io0-f173.google.com [209.85.223.173]) by lists.denx.de (Postfix) with ESMTPS id 434FAC21E30 for ; Thu, 14 Jun 2018 16:55:39 +0000 (UTC) Received: by mail-io0-f173.google.com with SMTP id l25-v6so7789324ioh.12 for ; Thu, 14 Jun 2018 09:55:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Lk8BFQ2QulNjoAKisSdGh9K93F5yvdmKx60vJmzCF7g=; b=kKQSBiGuB5CnoF0fx1BKpL55M4mfyoqy/LjRX9oADh1XuVs4rxKPTAo+kRRL0+WW26 nUVI+dq99Vfup9foCNf9p71weLKb907VmvhfwFzF8FRLrmnr7+UCdPZ0t9FUZdl8UO63 8OINyOTz9MqHKSe5ufa8KZ2zFCxxMVPRbcPbEOni0xnqRr49M1zsHsxuk/zciF1BPKdI iMiW4BCnyL3yj7CUagsbTvI/d2cMFZfmQjlwObyWCyVV3zGo/vK0Y6UvaJG7ETirQ7ge yyFIfaPil5CrzLf16XOrAuWAE9J/WHRvVlZvY6Usj5suBIR5VmbSKZrKC5V1+8Z5bbnk 5dQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Lk8BFQ2QulNjoAKisSdGh9K93F5yvdmKx60vJmzCF7g=; b=nSo6aVGVEbCCcWICsrTUlYRl+zJwbHuhWN9BxjrdyqHL5Rpj+vLIxIIs62AFzBycKD uL/GL6SKMftAnC9ff/VAg4DS+DfH4omtUhLP2FSSaHa+BitAKAAkQXeIJ97o2DnBx767 nujAbuaL8xjWeTNF5zyuSFLmb3gx6CFJeibEk2Fa+oeeGXfukDg7n0Mvw/Rod+ZtM3lJ SCHw2O31EGaH+Y168yjtbxp/Z6RHD90pO11wPkx/XALYdWsQLwXVN5j0RJbwoACq1fue NhsGSNIO0Sv/c7C9l+Yutau70ajITLawk5mOEMlXjiGMYr6SbMZ77O9YM1MsB0N2mufb Xfjw== X-Gm-Message-State: APt69E1Qo6nf+2J9D1EBRHX9pYpMk7nMUomwHanc6urp1vmc0eVAiAF3 xdZzIIDz+A2vcZEDSQ5Qh2Cs2A== X-Google-Smtp-Source: ADUXVKLdh8L06G+e2mKtW4XWNEZ4A6yFVvO4VPpWH1oyxuoEBGdPIlerco7n99f3jk6zNJA6RaF4UQ== X-Received: by 2002:a6b:ea01:: with SMTP id m1-v6mr2955221ioc.210.1528995337664; Thu, 14 Jun 2018 09:55:37 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([100.67.80.24]) by smtp.gmail.com with ESMTPSA id k16-v6sm2041900iog.45.2018.06.14.09.55.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jun 2018 09:55:35 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id 547ED140484; Thu, 14 Jun 2018 10:55:32 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 14 Jun 2018 10:55:24 -0600 Message-Id: <20180614165526.183597-10-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180614165526.183597-1-sjg@chromium.org> References: <20180614165526.183597-1-sjg@chromium.org> Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v7 09/10] 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: , MIME-Version: 1.0 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 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 ac80074bc4..b9eb04531b 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_device_path *memdp = NULL; efi_status_t ret; @@ -283,19 +303,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; @@ -303,10 +317,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: */ @@ -316,8 +330,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; } @@ -329,7 +343,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); @@ -338,11 +352,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); return ret; } @@ -358,11 +372,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)); @@ -371,18 +387,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); } /** @@ -481,7 +487,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); @@ -497,7 +503,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 Thu Jun 14 16:55: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: 929592 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="AHrjs12I"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41692H73NZz9s01 for ; Fri, 15 Jun 2018 03:04:07 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id B146DC21E29; Thu, 14 Jun 2018 16:58: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=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 392BBC21D9A; Thu, 14 Jun 2018 16:55:54 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A7791C21C29; Thu, 14 Jun 2018 16:55:42 +0000 (UTC) Received: from mail-io0-f196.google.com (mail-io0-f196.google.com [209.85.223.196]) by lists.denx.de (Postfix) with ESMTPS id 506D6C21E0F for ; Thu, 14 Jun 2018 16:55:38 +0000 (UTC) Received: by mail-io0-f196.google.com with SMTP id f1-v6so7834534ioh.6 for ; Thu, 14 Jun 2018 09:55:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=HEZLhwZsHZkkGWDpucgE+TzuYVvmtN97JhwZe1eZ8Ac=; b=AHrjs12I4SeDYLNWaOQykEdSlUTg2cJrxwZ4t+NeELDSFAgtj1CWtP8PcRKFqYC9VH bPjbVK7bN8zsXT3hc4+5yuH6+xMhFwFlrmStGn9NVbpkdyG0AxMc4H95K2nbQ+LfLsh9 SVtKngtE01cfU6cfzzDTv5RciQohWAfI5kohqIQUgaeQQycjBk/88MNHJko6i8SZjeQM mIIifhJw8JuSQ3v/ez0ZEcFGP+5vz5AXw3ymR2E1ZKassQHETX2onId1wUWw9G06cbp1 9szEI2vQ07Vac0Zbq2m41nBqOJUz1WvnuYwlGo9M77sIyTDbpemcwaZqOZudwAkqpmcM nvLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=HEZLhwZsHZkkGWDpucgE+TzuYVvmtN97JhwZe1eZ8Ac=; b=GP0lTNOTq23TIMXeWyKit6KIODp6segxuMt1hTZMwp57u8GnVYuAWNydT1URMdYBGK Lr7eQ9muaR7szeOjbn3GE5axWQn7ilhkXi5uLe8LSFUmQToDP9MprTqlhcuFUPP9lWTJ qXowQfvckYYO4Lpi3kqap0cgf55HTwuR9WVMWhVmoAKFW9zXu6drA0jVboGZJLQOmagu rFA21m8m5tQTtRoclRfvri2C9Kude/Ys7eURMEMFRXO0y+9GM8RibtcUeBg0xistmfqJ GoANSzBknO5a2ntrzru61gtdFOqNjJt6geWN4QYs5/6rjI2qn36rUsA+FziFGYdeuD3V Twfw== X-Gm-Message-State: APt69E1dyXbRqm/pm5FmkEKPm/JPi1WhoxXyxFL676k8ynrUq4FsvEFR ducyr1TBV/8W/JIViEAmh1XkRA== X-Google-Smtp-Source: ADUXVKI19I9dFixfeZ7Mi4anF8JG316iK4ZU3jn6TrtH6gFZzJce2hzK4VAEBEATbBRvkULdc4tlXA== X-Received: by 2002:a6b:d80c:: with SMTP id y12-v6mr2896451iob.127.1528995336763; Thu, 14 Jun 2018 09:55:36 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id k139-v6sm2967151itk.27.2018.06.14.09.55.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jun 2018 09:55:35 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id CDE61140C6B; Thu, 14 Jun 2018 10:55:32 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 14 Jun 2018 10:55:25 -0600 Message-Id: <20180614165526.183597-11-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180614165526.183597-1-sjg@chromium.org> References: <20180614165526.183597-1-sjg@chromium.org> Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v7 10/10] 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: , MIME-Version: 1.0 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 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 b9eb04531b..7a98c9a6bb 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. @@ -355,8 +369,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); return ret; } @@ -391,20 +404,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; @@ -491,7 +490,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; @@ -509,7 +508,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