{"id":814733,"url":"http://patchwork.ozlabs.org/api/patches/814733/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170917225927.117917-17-sjg@chromium.org/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170917225927.117917-17-sjg@chromium.org>","list_archive_url":null,"date":"2017-09-17T22:59:27","name":"[U-Boot,16/16] efi: sandbox: Add a simple 'bootefi test' command","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"e841d24ac431fb4c217b484c7eb6271420f39671","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/people/6170/?format=json","name":"Simon Glass","email":"sjg@chromium.org"},"delegate":{"id":3400,"url":"http://patchwork.ozlabs.org/api/users/3400/?format=json","username":"agraf","first_name":"Alexander","last_name":"Graf","email":"agraf@suse.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170917225927.117917-17-sjg@chromium.org/mbox/","series":[{"id":3549,"url":"http://patchwork.ozlabs.org/api/series/3549/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=3549","date":"2017-09-17T22:59:11","name":"efi: Enable basic sandbox support for EFI loader","version":1,"mbox":"http://patchwork.ozlabs.org/series/3549/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814733/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814733/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=google.com header.i=@google.com\n\theader.b=\"D0suRx+i\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwS863Htvz9s76\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 10:49:42 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 2C13CC21EEB; Mon, 18 Sep 2017 00:49:41 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 8F53CC21EDB;\n\tSun, 17 Sep 2017 23:03:11 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 5D307C21D65; Sun, 17 Sep 2017 23:03:10 +0000 (UTC)","from mail-io0-f170.google.com (mail-io0-f170.google.com\n\t[209.85.223.170])\n\tby lists.denx.de (Postfix) with ESMTPS id 96112C21EC1\n\tfor <u-boot@lists.denx.de>; Sun, 17 Sep 2017 22:59:47 +0000 (UTC)","by mail-io0-f170.google.com with SMTP id w94so14831706ioi.7\n\tfor <u-boot@lists.denx.de>; Sun, 17 Sep 2017 15:59:47 -0700 (PDT)","from kiwi.bld.corp.google.com ([2620:0:10f2:0:50ee:364d:633f:bd4e])\n\tby smtp.gmail.com with ESMTPSA id\n\tt188sm732830oie.42.2017.09.17.15.59.42\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSun, 17 Sep 2017 15:59:45 -0700 (PDT)","by kiwi.bld.corp.google.com (Postfix, from userid 121222)\n\tid EE8841418B1; Sun, 17 Sep 2017 16:59:41 -0600 (MDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_MSPIKE_H2,\n\tT_DKIM_INVALID autolearn=unavailable autolearn_force=no\n\tversion=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=20161025; \n\th=sender:from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=b0fEGjTc+wCPoyw1wjWBG+p6ID6BatI4o8nPLGG0DOc=;\n\tb=D0suRx+iVtDBhzdAi5fXq/FqDLb76OMQtrsLdF4FOrhgowsa5NuLqRJu7TfLXjezeZ\n\tXtKQNHMoUXOnke35KXmn2mS8suzzER5Xm7cSbBiWJ+ZcJkrtLnf6f0dlBS0TcRH+vR7F\n\tv+eAdQ1nTXhgiUT4KrS1yt884VCARET9HCNqCBE9+VnSNgWWLB/xZPjwUH5d5SDPfUBF\n\tEoo2k3XhQVq07UwI2hXnLFHgfwxNCNynDOjJkEAWtfFEmO45wIE7q6jzBe2ANnh2P77F\n\tqWwGZpattwvst7bgQHn8CQ3vZ87rKJq7cYB87xsNPo4KGon3XgXkTrPFrGO8M84WdbBu\n\teJCQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:sender:from:to:cc:subject:date:message-id\n\t:in-reply-to:references;\n\tbh=b0fEGjTc+wCPoyw1wjWBG+p6ID6BatI4o8nPLGG0DOc=;\n\tb=ULqMCRbzlnK0oYShCQn1Y+gRCoYt6T36E7j1xq5sPWmnZjJ8XA4veE4swfyF+cEWsd\n\tgQWtTNVrKpWvEqhhBHvYe3vfd0MD8xB2Rh/RhidvTz9yn9wv0SfZJ+Cn1WGfuEBTwCVo\n\tznTLjhMp7nT3PLpITQ0sDYLXKfXzd6KHjKnf0HgzQpnPWCFwZVTtVqbpIsvubMzvO2VO\n\txK9BERSsgrsUdJnOVhogstR9EV3PsbLSw21j2vC7qZc0IqklKlq7tI7t+Ql7zSea+QEk\n\t5GqLYE5PfJMhBnYLSd+4015hzdFqIC01Y1sOoRkz8EryW/t4LfPsbGud2cQgAxmkBA0q\n\t39jw==","X-Gm-Message-State":"AHPjjUgkB49S4EM9Lyjo851bZ1lOqZlhDmUHIsdu/HK1xDh/zxXk03w7\n\tlLMznuex0bt8adn5","X-Google-Smtp-Source":"AOwi7QCeWnwjY5qN4Ic9CZ1P6j4D/AYS5Ig5LpTbBQFnfigSYyd24S/ZvCg+9eYUdjrvh5IQ7j35Cg==","X-Received":"by 10.202.6.6 with SMTP id 6mr1590969oig.103.1505689186020;\n\tSun, 17 Sep 2017 15:59:46 -0700 (PDT)","From":"Simon Glass <sjg@chromium.org>","To":"U-Boot Mailing List <u-boot@lists.denx.de>","Date":"Sun, 17 Sep 2017 16:59:27 -0600","Message-Id":"<20170917225927.117917-17-sjg@chromium.org>","X-Mailer":"git-send-email 2.14.1.690.gbb1197296e-goog","In-Reply-To":"<20170917225927.117917-1-sjg@chromium.org>","References":"<20170917225927.117917-1-sjg@chromium.org>","Cc":"Andy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tHeinrich Schuchardt <xypron.glpk@gmx.de>","Subject":"[U-Boot] [PATCH 16/16] efi: sandbox: Add a simple 'bootefi test'\n\tcommand","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"This jumps to test code which can call directly into the EFI support. It\ndoes not need a separate image so it is easy to write tests with it.\n\nFor now the test just outputs a message. To try it:\n\n./sandbox/u-boot -c \"bootefi test\"\nU-Boot 2017.09-00204-g696c9855fe (Sep 17 2017 - 16:43:53 -0600)\n\nDRAM:  128 MiB\nMMC:\nUsing default environment\n\nIn:    serial\nOut:   serial\nErr:   serial\nSCSI:  Net:   No ethernet found.\nIDE:   Bus 0: not available\nFound 0 disks\nHello, world!\nTest passed\n\nSigned-off-by: Simon Glass <sjg@chromium.org>\n---\n\n cmd/bootefi.c             | 18 ++++++++++++++++++\n configs/sandbox_defconfig |  1 +\n include/efi_loader.h      |  3 +++\n lib/efi_loader/Kconfig    | 10 ++++++++++\n lib/efi_loader/Makefile   |  1 +\n lib/efi_loader/efi_test.c | 17 +++++++++++++++++\n 6 files changed, 50 insertions(+)\n create mode 100644 lib/efi_loader/efi_test.c","diff":"diff --git a/cmd/bootefi.c b/cmd/bootefi.c\nindex ee07733e3e..f499103d23 100644\n--- a/cmd/bootefi.c\n+++ b/cmd/bootefi.c\n@@ -323,6 +323,24 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])\n \t\tmemcpy((char *)addr, __efi_hello_world_begin, size);\n \t} else\n #endif\n+\tif (IS_ENABLED(CONFIG_BOOTEFI_TEST) && !strcmp(argv[1], \"test\")) {\n+\t\tint ret;\n+\n+\t\t/* Initialize and populate EFI object list */\n+\t\tif (efi_init_obj_list())\n+\t\t\treturn CMD_RET_FAILURE;\n+\n+\t\tloaded_image_info.device_handle = bootefi_device_path;\n+\t\tloaded_image_info.file_path = bootefi_image_path;\n+\t\tret = efi_test(&loaded_image_info, &systab);\n+\t\tif (ret) {\n+\t\t\tprintf(\"Test failed: err=%d\\n\", ret);\n+\t\t\treturn CMD_RET_FAILURE;\n+\t\t}\n+\t\tprintf(\"Test passed\\n\");\n+\n+\t\treturn 0;\n+\t}\n #ifdef CONFIG_CMD_BOOTEFI_SELFTEST\n \tif (!strcmp(argv[1], \"selftest\")) {\n \t\t/*\ndiff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig\nindex 72600afea8..ab63f639de 100644\n--- a/configs/sandbox_defconfig\n+++ b/configs/sandbox_defconfig\n@@ -196,3 +196,4 @@ CONFIG_UT_TIME=y\n CONFIG_UT_DM=y\n CONFIG_UT_ENV=y\n CONFIG_UT_OVERLAY=y\n+CONFIG_CMD_BOOTEFI_SELFTEST=y\ndiff --git a/include/efi_loader.h b/include/efi_loader.h\nindex 79d2dad22c..43919137b0 100644\n--- a/include/efi_loader.h\n+++ b/include/efi_loader.h\n@@ -263,6 +263,9 @@ efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,\n \t\t\t\t struct efi_system_table *systab);\n #endif\n \n+/* Perform EFI tests */\n+int efi_test(efi_handle_t image_handle, struct efi_system_table *systab);\n+\n #else /* defined(EFI_LOADER) && !defined(CONFIG_SPL_BUILD) */\n \n /* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */\ndiff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig\nindex dee0a96a98..659b2b18f4 100644\n--- a/lib/efi_loader/Kconfig\n+++ b/lib/efi_loader/Kconfig\n@@ -16,3 +16,13 @@ config EFI_LOADER_BOUNCE_BUFFER\n \t  Some hardware does not support DMA to full 64bit addresses. For this\n \t  hardware we can create a bounce buffer so that payloads don't have to\n \t  worry about platform details.\n+\n+config BOOTEFI_TEST\n+\tbool \"Provide a test for the EFI loader\"\n+\tdepends on EFI_LOADER && SANDBOX\n+\tdefault y\n+\thelp\n+\t  Provides a test of the EFI loader functionality accessed via the\n+\t  command line ('bootefi test'). This runs within U-Boot so does not\n+\t  need a separate EFI application to work. It aims to include coverage\n+\t  of all EFI code which can be accessed within sandbox.\ndiff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile\nindex 30bf343a36..69eb93518d 100644\n--- a/lib/efi_loader/Makefile\n+++ b/lib/efi_loader/Makefile\n@@ -21,3 +21,4 @@ obj-$(CONFIG_DM_VIDEO) += efi_gop.o\n obj-$(CONFIG_PARTITIONS) += efi_disk.o\n obj-$(CONFIG_NET) += efi_net.o\n obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o\n+obj-$(CONFIG_BOOTEFI_TEST) += efi_test.o\ndiff --git a/lib/efi_loader/efi_test.c b/lib/efi_loader/efi_test.c\nnew file mode 100644\nindex 0000000000..3fdce78b05\n--- /dev/null\n+++ b/lib/efi_loader/efi_test.c\n@@ -0,0 +1,17 @@\n+/*\n+ * Copyright (c) 2017, Google Inc. All rights reserved.\n+ *\n+ * SPDX-License-Identifier:     GPL-2.0+\n+ */\n+\n+#include <common.h>\n+#include <efi_api.h>\n+\n+int efi_test(efi_handle_t image_handle, struct efi_system_table *systable)\n+{\n+\tstruct efi_simple_text_output_protocol *con_out = systable->con_out;\n+\n+\tcon_out->output_string(con_out, L\"Hello, world!\\n\");\n+\n+\treturn 0;\n+}\n","prefixes":["U-Boot","16/16"]}