From patchwork Tue Nov 6 22:57:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 993972 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 42qQ3V1HnYz9s7T for ; Wed, 7 Nov 2018 09:59:34 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id D1FCCC227FD; Tue, 6 Nov 2018 22:58: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_DNSWL_BLOCKED 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 20B41C22866; Tue, 6 Nov 2018 22:57:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8E132C22812; Tue, 6 Nov 2018 22:57:50 +0000 (UTC) Received: from mail-oi1-f202.google.com (mail-oi1-f202.google.com [209.85.167.202]) by lists.denx.de (Postfix) with ESMTPS id B5AA6C2284C for ; Tue, 6 Nov 2018 22:57:49 +0000 (UTC) Received: by mail-oi1-f202.google.com with SMTP id l204-v6so9593943oia.17 for ; Tue, 06 Nov 2018 14:57:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=SQ9BzxLL5tTTyjoCDU3WlcFdRChfPJf0HtHAYGptbYI=; b=bMwbjtI1VkqvIJPhx/IVqzdt/NdB7Xhva8DCz/7li+Qra/oVPab3vFmJL0s9HE0Jqg PQBJuoKBoYdBEvclm053BoPNUi4nweaBy1Za1r6FM+raKsva+F13SplyW9Ash2t5hiY+ 2CNO50fU1/oOC229DEF8w+3YXv2af5w2XRJs/55iKsf10C2xJcEmoF5PEz/4zlJATEPt NSvKpKk5OSsXVLPchQUZvYJON++gLEsbxhbTrH3v6yLkwuhs3kaImYGYSSu9cULgsD1C ndXda7lfBzM5dVShKyldXUf4cbV8olr1uRje+VYh6tlLEyodVvDvonqwWptVbVkK4RYv LgKQ== X-Gm-Message-State: AGRZ1gJkJcJI7sTRz5mHn649hA2A9nuNJx1ZUWSPPgKMfh6ltkEEVz7X c74bNXcQh5BOeOTcE6+rDR1C7DQ= X-Google-Smtp-Source: AJdET5d859oAa5faV0dkJBE/jFzKTavwNIWqgVTgLe2hnKKRyRHl6pTn7u0zLuLwvuHFTjtcy86QEJQ= X-Received: by 2002:a9d:541e:: with SMTP id j30mr20377081oth.27.1541545068718; Tue, 06 Nov 2018 14:57:48 -0800 (PST) Date: Tue, 6 Nov 2018 15:57:39 -0700 In-Reply-To: <20181106225744.139945-1-sjg@chromium.org> Message-Id: <20181106225744.139945-2-sjg@chromium.org> Mime-Version: 1.0 References: <20181106225744.139945-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog From: Simon Glass To: U-Boot Mailing List Cc: Eugeniu Rosca , Alexander Graf , Joe Hershberger Subject: [U-Boot] [PATCH v12 1/6] sandbox: Put CPUs under a cpu-bus node 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 CPU uclass expects that all CPUs have a parent device which is a cpu-bus. Fix up the sandbox test DT to follow this convention. This allow the code in smbios_write_type4_dm() to work, since it calls dev_get_parent_platdata() on each CPU. Signed-off-by: Simon Glass --- Changes in v12: - Update CPU nodes to comply with the DT spec Changes in v11: - Add a new patch to put CPUs under a cpu-bus node Changes in v9: None Changes in v7: None Changes in v5: None Changes in v4: None Changes in v3: None arch/sandbox/dts/test.dts | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 57e0dd76631..bec912f917f 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -344,16 +344,38 @@ mbox-names = "other", "test"; }; - cpu-test1 { - compatible = "sandbox,cpu_sandbox"; - }; + cpus { + #address-cells = <1>; + #size-cells = <0>; - cpu-test2 { - compatible = "sandbox,cpu_sandbox"; - }; + cpu@0 { + reg = <0>; + compatible = "sandbox,cpu_sandbox"; + device-type = "cpu"; - cpu-test3 { - compatible = "sandbox,cpu_sandbox"; + /* + * These are not used by sandbox, but are required by + * the latest DT spec (v0.2). + */ + clock-frequency = <0>; + timebase-frequency = <0>; + }; + + cpu@1 { + reg = <1>; + compatible = "sandbox,cpu_sandbox"; + device-type = "cpu"; + clock-frequency = <0>; + timebase-frequency = <0>; + }; + + cpu@2 { + reg = <2>; + compatible = "sandbox,cpu_sandbox"; + device-type = "cpu"; + clock-frequency = <0>; + timebase-frequency = <0>; + }; }; misc-test { From patchwork Tue Nov 6 22:57:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 993971 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 42qQ3B52GKz9s55 for ; Wed, 7 Nov 2018 09:59:18 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 4A137C22931; Tue, 6 Nov 2018 22:58: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_DNSWL_BLOCKED, 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 EEBCDC22948; Tue, 6 Nov 2018 22:57:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 43DF0C22866; Tue, 6 Nov 2018 22:57:52 +0000 (UTC) Received: from mail-yw1-f74.google.com (mail-yw1-f74.google.com [209.85.161.74]) by lists.denx.de (Postfix) with ESMTPS id D147BC2282F for ; Tue, 6 Nov 2018 22:57:51 +0000 (UTC) Received: by mail-yw1-f74.google.com with SMTP id f66-v6so11335353ywa.0 for ; Tue, 06 Nov 2018 14:57:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=FYRuU2fJL6xW09HupNg1yf7EyJTnDZdo/9t44dwQGHk=; b=jcqnxGfNbmffRhhL+rgOMHToEBVb70Yd/wCNE9Hwy/gdQaudiNveIxwrIEYYHN1Nbg 5maQybBoB6PACiF96UWF+BFAmDqq9kR3v4B63mLPeO5R/Vh8ehlqkd5W0soPAC4QDeHH vQXV5bThj7wd8L3mp1bbXGGa/CgUPNZqhxIKU4an3/qVyET+SLF/Q3iASafE1qKCuCkw lIRmzyfPDpXJalWk8Nlg4xft9A3tcPRjYuk5Ka/pS2g3o8wgO/AOK1IpcjAjU63nf4oj MeIfa1pRjiGK2bunQ/mriF+FyoLdVpkWQGjG7TaMhQB1q0RM+rB3VgWccR3DIDHLjr8b n6EA== X-Gm-Message-State: AGRZ1gL3wCyVRwiOwCFEnUU4wbus2W+9hSEAJuYZJ6FBv+/zDjt7vI+L inkPpm3Xe9VYqk1cTKHwvr8Xywk= X-Google-Smtp-Source: AJdET5fQ9D049LdM1NMT5Q9oWoVIZRmbZe2Th5QIGOO71l2bEKOm9DD5TTygnyWZoI6/GxLvPl5EuDw= X-Received: by 2002:a81:7843:: with SMTP id t64-v6mr10133971ywc.3.1541545070328; Tue, 06 Nov 2018 14:57:50 -0800 (PST) Date: Tue, 6 Nov 2018 15:57:40 -0700 In-Reply-To: <20181106225744.139945-1-sjg@chromium.org> Message-Id: <20181106225744.139945-3-sjg@chromium.org> Mime-Version: 1.0 References: <20181106225744.139945-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog From: Simon Glass To: U-Boot Mailing List Cc: Alexander Graf Subject: [U-Boot] [PATCH v12 2/6] efi_loader: Drop setup_ok 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 value is stored in data which appears to be read-only with sandbox on my Ubuntu 18.04 machine. In any case it is not good practice to store run-time data in a build-time linker list. The value does not seem to be that useful, since tests that fail to setup are likely to fail to run also. Let's drop it for now. Signed-off-by: Simon Glass --- Changes in v12: None Changes in v11: - Add a new patch to drop setup_ok Changes in v9: None Changes in v7: None Changes in v5: None Changes in v4: None Changes in v3: None include/efi_selftest.h | 2 -- lib/efi_selftest/efi_selftest.c | 14 +++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/efi_selftest.h b/include/efi_selftest.h index 56beac305ec..49d3d6d0b47 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -129,7 +129,6 @@ u16 efi_st_get_key(void); * @setup: set up the unit test * @teardown: tear down the unit test * @execute: execute the unit test - * @setup_ok: setup was successful (set at runtime) * @on_request: test is only executed on request */ struct efi_unit_test { @@ -139,7 +138,6 @@ struct efi_unit_test { const struct efi_system_table *systable); int (*execute)(void); int (*teardown)(void); - int setup_ok; bool on_request; }; diff --git a/lib/efi_selftest/efi_selftest.c b/lib/efi_selftest/efi_selftest.c index dd338db687e..dfd11be2302 100644 --- a/lib/efi_selftest/efi_selftest.c +++ b/lib/efi_selftest/efi_selftest.c @@ -74,20 +74,20 @@ void efi_st_exit_boot_services(void) */ static int setup(struct efi_unit_test *test, unsigned int *failures) { - if (!test->setup) { - test->setup_ok = EFI_ST_SUCCESS; + int ret; + + if (!test->setup) return EFI_ST_SUCCESS; - } efi_st_printc(EFI_LIGHTBLUE, "\nSetting up '%s'\n", test->name); - test->setup_ok = test->setup(handle, systable); - if (test->setup_ok != EFI_ST_SUCCESS) { + ret = test->setup(handle, systable); + if (ret) { efi_st_error("Setting up '%s' failed\n", test->name); ++*failures; } else { efi_st_printc(EFI_LIGHTGREEN, "Setting up '%s' succeeded\n", test->name); } - return test->setup_ok; + return ret; } /* @@ -197,7 +197,7 @@ void efi_st_do_tests(const u16 *testname, unsigned int phase, continue; if (steps & EFI_ST_SETUP) setup(test, failures); - if (steps & EFI_ST_EXECUTE && test->setup_ok == EFI_ST_SUCCESS) + if (steps & EFI_ST_EXECUTE) execute(test, failures); if (steps & EFI_ST_TEARDOWN) teardown(test, failures); From patchwork Tue Nov 6 22:57:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 993974 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 42qQ5f6kRDz9sCQ for ; Wed, 7 Nov 2018 10:01:26 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 94E0BC22965; Tue, 6 Nov 2018 22:58: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_DNSWL_BLOCKED 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 56ABEC22931; Tue, 6 Nov 2018 22:57:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0F737C22856; Tue, 6 Nov 2018 22:57:53 +0000 (UTC) Received: from mail-it1-f201.google.com (mail-it1-f201.google.com [209.85.166.201]) by lists.denx.de (Postfix) with ESMTPS id 0F78DC22812 for ; Tue, 6 Nov 2018 22:57:53 +0000 (UTC) Received: by mail-it1-f201.google.com with SMTP id 66-v6so10862976itz.9 for ; Tue, 06 Nov 2018 14:57:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=K1dZrLwkBqYnQP5h79AHQPY6Fy3cGFt+xf6nrl6D9p0=; b=pl1yZsmgb158wayfxB/wfR3kKAZwSVAIFoNxJWspMxR1zfTMgt4eYTDP+nLgKaA2ha 9odpXVeytx36mWRteCB3iFOUnTLMv66WBvwERrl80wFk/rIv9V+NDLXywhL+YvVBvMtz o70WFGm9mFejwq/jB6j2Kqywl25RQFS9zHyMVtkW3GifLZloAdEZ22SgrRgNUxfMBLf0 t6RokY4oeXdmcDAWztEsCjnxk8UNhiC9Fn+5Ze7e4yazW/Tztyocb/2KH1D8pzGVQEUb PKws0fQ7xS+kC0O9eeS3XVTJxagb6bu4vlj8zfuRC2Dfjmg9XcUR7pGIp7y5g4oc0VJM NClg== X-Gm-Message-State: AGRZ1gKnR1me48rz0/ci80rsQq+Be3hy5bKnHSALPKhlWsZ0HaI5eqM5 fzUjItCSuARiuhExmS5dM0ObI4s= X-Google-Smtp-Source: AJdET5dycY6qpzNqXo9PYLJGoTrnEM6spjFS8a4xnioUVj3XsYNLU68zWWtpn4xD7kwNgPh4y02PbDw= X-Received: by 2002:a24:5fc6:: with SMTP id r189-v6mr2895736itb.28.1541545072120; Tue, 06 Nov 2018 14:57:52 -0800 (PST) Date: Tue, 6 Nov 2018 15:57:41 -0700 In-Reply-To: <20181106225744.139945-1-sjg@chromium.org> Message-Id: <20181106225744.139945-4-sjg@chromium.org> Mime-Version: 1.0 References: <20181106225744.139945-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog From: Simon Glass To: U-Boot Mailing List Cc: Alexander Graf Subject: [U-Boot] [PATCH v12 3/6] 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 v12: None Changes in v11: - Fix the EFI code that has since been added and relies on broken behaviour Changes in v9: None Changes in v7: None Changes in v5: None Changes in v4: None Changes in v3: - Drop incorrect map_sysmem() in write_smbios_table() lib/efi_loader/efi_smbios.c | 20 +++++++++++++------- lib/smbios.c | 32 ++++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c index 38e42fa2432..a81488495e2 100644 --- a/lib/efi_loader/efi_smbios.c +++ b/lib/efi_loader/efi_smbios.c @@ -7,6 +7,7 @@ #include #include +#include #include static const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID; @@ -19,17 +20,19 @@ static const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID; efi_status_t efi_smbios_register(void) { /* Map within the low 32 bits, to allow for 32bit SMBIOS tables */ - u64 dmi = U32_MAX; + u64 dmi_addr = U32_MAX; efi_status_t ret; + void *dmi; /* Reserve 4kiB page for SMBIOS */ ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, - EFI_RUNTIME_SERVICES_DATA, 1, &dmi); + EFI_RUNTIME_SERVICES_DATA, 1, &dmi_addr); if (ret != EFI_SUCCESS) { /* Could not find space in lowmem, use highmem instead */ ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, - EFI_RUNTIME_SERVICES_DATA, 1, &dmi); + EFI_RUNTIME_SERVICES_DATA, 1, + &dmi_addr); if (ret != EFI_SUCCESS) return ret; @@ -39,11 +42,14 @@ efi_status_t efi_smbios_register(void) * Generate SMBIOS tables - we know that efi_allocate_pages() returns * a 4k-aligned address, so it is safe to assume that * write_smbios_table() will write the table at that address. + * + * Note that on sandbox, efi_allocate_pages() unfortunately returns a + * pointer even though it uses a uint64_t type. Convert it. */ - assert(!(dmi & 0xf)); - write_smbios_table(dmi); + assert(!(dmi_addr & 0xf)); + dmi = (void *)(uintptr_t)dmi_addr; + write_smbios_table(map_to_sysmem(dmi)); /* And expose them to our EFI payload */ - return efi_install_configuration_table(&smbios_guid, - (void *)(uintptr_t)dmi); + return efi_install_configuration_table(&smbios_guid, dmi); } diff --git a/lib/smbios.c b/lib/smbios.c index 326eb00230d..87109d431a2 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); @@ -298,6 +313,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 Tue Nov 6 22:57:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 993973 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 42qQ5Y01sJz9sCm for ; Wed, 7 Nov 2018 10:01:20 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 84516C22946; Tue, 6 Nov 2018 22:59: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_DNSWL_BLOCKED, 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 3C055C22951; Tue, 6 Nov 2018 22:58:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C8D38C22940; Tue, 6 Nov 2018 22:57:58 +0000 (UTC) Received: from mail-vs1-f74.google.com (mail-vs1-f74.google.com [209.85.217.74]) by lists.denx.de (Postfix) with ESMTPS id 05005C22851 for ; Tue, 6 Nov 2018 22:57:55 +0000 (UTC) Received: by mail-vs1-f74.google.com with SMTP id e124so566102vsc.7 for ; Tue, 06 Nov 2018 14:57:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=itaqCPenC1VxocxlUjPAUMe5XzZQASZN0KXa06SEs3E=; b=UAPbcp7COlpehUKcOzDoEyI2ZPRMlXoJrUR18MqdHaeQPooH2kqIhlOsavh33TG26U HsF3RiQ5tmZOexuVaFOeHDMKuYxqSip+NtDztprQQv/iwP4Fi9swI7h6tBBOic3W0SK4 HU5WORCP1iMR0uBTkTsmN7dcv+mKeQy+01zVBw2RE52/6Wq+mVhZY0pQ39fFCro31Tef 5quvm6HdcGCXsL2F9aotV5QeR8utgygFdFaoOHCjrXwHoQdz6lAttbleX81MxMFyF7By BqHmWkrk43f+ZZRQNDs9a4lv+9mbB+nego8Y9CRAmLjiWamz4ei5podGcxK1kz1cUR7l siQg== X-Gm-Message-State: AGRZ1gLd/3dznDbLCh/7UWNjRnEvLc9kBTbhT4B772Lx1YAGe2ay0aUH uxBu0lPy2OSi1AWzlnkvxIBQrwg= X-Google-Smtp-Source: AJdET5eyusRKQPm2p0KzePj8uaZImqZpy6a+rAGsQFhsZ4ssZrz9RdJFdntd7exVa7Z/0GHG//TSgGA= X-Received: by 2002:a1f:cc2:: with SMTP id 185mr25447752vkm.5.1541545073850; Tue, 06 Nov 2018 14:57:53 -0800 (PST) Date: Tue, 6 Nov 2018 15:57:42 -0700 In-Reply-To: <20181106225744.139945-1-sjg@chromium.org> Message-Id: <20181106225744.139945-5-sjg@chromium.org> Mime-Version: 1.0 References: <20181106225744.139945-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog From: Simon Glass To: U-Boot Mailing List Cc: Alexander Graf Subject: [U-Boot] [PATCH v12 4/6] 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" The functions in bootefi are very long because they mix high-level code and control with the low-level implementation. To help with this, 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 v12: - Rename image to image_prot Changes in v11: None Changes in v9: - Add comments to bootefi_test_prepare() about the memset()s Changes in v7: 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 cmd/bootefi.c | 85 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 20 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 4d68d807480..0dd18d594d5 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -455,6 +455,64 @@ 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. + * This struct will be inited by this function before use. + * @obj: Pointer to a struct which will hold the loaded image object + * This struct will be inited by this function before use. + * @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 **imagep, + struct efi_loaded_image_obj **objp, + const char *path, ulong test_func) +{ + efi_status_t r; + + /* 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); + r = efi_setup_loaded_image(bootefi_device_path, bootefi_image_path, + objp, imagep); + if (r) + return r; + /* + * 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(*imagep, "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_loaded_image_obj *obj) +{ + efi_restore_gd(); + free(image->load_options); + efi_delete_handle(&obj->parent); +} +#endif /* CONFIG_CMD_BOOTEFI_SELFTEST */ + static int do_bootefi_bootmgr_exec(void) { struct efi_device_path *device_path, *file_path; @@ -527,29 +585,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_obj *image_handle; - struct efi_loaded_image *loaded_image_info; - - /* 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"); - - r = efi_setup_loaded_image(bootefi_device_path, - bootefi_image_path, &image_handle, - &loaded_image_info); - if (r != EFI_SUCCESS) + struct efi_loaded_image_obj *obj; + struct efi_loaded_image *image_prot; + + if (bootefi_test_prepare(&image_prot, &obj, "\\selftest", + (uintptr_t)&efi_selftest)) return CMD_RET_FAILURE; - efi_save_gd(); - /* Transfer environment variable efi_selftest as load options */ - set_load_options(loaded_image_info, "efi_selftest"); /* Execute the test */ - r = efi_selftest(image_handle, &systab); - efi_restore_gd(); - free(loaded_image_info->load_options); - efi_delete_handle(&image_handle->parent); + r = efi_selftest(obj, &systab); + bootefi_test_finish(image_prot, obj); return r != EFI_SUCCESS; } else #endif From patchwork Tue Nov 6 22:57:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 993976 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 42qQ5w41dGz9sCQ for ; Wed, 7 Nov 2018 10:01:40 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 507A9C2293A; Tue, 6 Nov 2018 22:59:45 +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_DNSWL_BLOCKED, 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 DAD2AC22812; Tue, 6 Nov 2018 22:58:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A09FAC22929; Tue, 6 Nov 2018 22:58:00 +0000 (UTC) Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) by lists.denx.de (Postfix) with ESMTPS id 1C360C22940 for ; Tue, 6 Nov 2018 22:57:57 +0000 (UTC) Received: by mail-qk1-f202.google.com with SMTP id k66so28575033qkf.1 for ; Tue, 06 Nov 2018 14:57:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=WWGZ7iS7x8GBWh5lCIyS0oZ+78otbpxLvviZYqU2WHc=; b=rqLhNh3hUDL3KCl/JINmSU3ewrWiYIx+4Vgsum6jGKIqfoP6ecWoF55jDHs1ZnzAR6 htG2u0DemS225798Th/3b1Mhy5h5Hf2oDpdcHvo3G3G8NvQ8C/VF0Qu9dvQse2+MgU+p zjKk+HecnsQ/aJf3PpgAcoXnojnVh/tnBQF01NM36n3diY3X6edqrOdlH3S6X4d8f8NS RYki6FayKb+2utCb7/7I3NsOKr4zutFm8vWxSgYgA/+wLyVcVJR9Nh4yVI6io+XwsKCb BruQ4gyKvbdnyBd86SZ2/Cmt2drQL6GJ4X8jV26621zdJTc4XFi9HvF6P8OGpaUeUypD HLiw== X-Gm-Message-State: AGRZ1gIAe7raDB6FR6RVvqZb0LX8txBPzq2KctMFFs48x2VLp01opCXc kwEEBuaGsVe/YX86AiFFEx1XAdM= X-Google-Smtp-Source: AJdET5fUEKzewwSD+3dmyJDx0LaZkSx64QNywBUcf4UTaLjUVIO+0oc9NaMdIJ9q9UQHLfTZHY6gUe0= X-Received: by 2002:a0c:9199:: with SMTP id n25mr14568588qvn.49.1541545075980; Tue, 06 Nov 2018 14:57:55 -0800 (PST) Date: Tue, 6 Nov 2018 15:57:43 -0700 In-Reply-To: <20181106225744.139945-1-sjg@chromium.org> Message-Id: <20181106225744.139945-6-sjg@chromium.org> Mime-Version: 1.0 References: <20181106225744.139945-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog From: Simon Glass To: U-Boot Mailing List Cc: Alexander Graf Subject: [U-Boot] [PATCH v12 5/6] 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" There is still duplicated code in efi_loader for tests and normal operation. 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 v12: None Changes in v11: None Changes in v9: None Changes in v7: 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 cmd/bootefi.c | 85 +++++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 37 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 0dd18d594d5..779c1f63fa8 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -327,6 +327,30 @@ static efi_status_t efi_install_fdt(ulong fdt_addr) return ret; } +static efi_status_t bootefi_run_prepare(const char *load_options_path, + struct efi_device_path *device_path, + struct efi_device_path *image_path, + struct efi_loaded_image **imagep, + struct efi_loaded_image_obj **objp) +{ + efi_status_t ret; + + ret = efi_setup_loaded_image(device_path, image_path, objp, imagep); + if (ret != EFI_SUCCESS) + 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 as load options */ + set_load_options(*imagep, load_options_path); + + return 0; +} + /** * do_bootefi_exec() - execute EFI binary * @@ -345,8 +369,8 @@ static efi_status_t do_bootefi_exec(void *efi, efi_handle_t mem_handle = NULL; struct efi_device_path *memdp = NULL; efi_status_t ret; - struct efi_loaded_image_obj *image_handle = NULL; - struct efi_loaded_image *loaded_image_info = NULL; + struct efi_loaded_image_obj *obj = NULL; + struct efi_loaded_image *image = NULL; EFIAPI efi_status_t (*entry)(efi_handle_t image_handle, struct efi_system_table *st); @@ -376,15 +400,13 @@ static efi_status_t do_bootefi_exec(void *efi, assert(device_path && image_path); } - ret = efi_setup_loaded_image(device_path, image_path, &image_handle, - &loaded_image_info); - if (ret != EFI_SUCCESS) - goto exit; + ret = bootefi_run_prepare("bootargs", device_path, image_path, + &image, &obj); + if (ret) + return ret; - /* Transfer environment variable bootargs as load options */ - set_load_options(loaded_image_info, "bootargs"); /* Load the EFI payload */ - entry = efi_load_pe(image_handle, efi, loaded_image_info); + entry = efi_load_pe(obj, efi, image); if (!entry) { ret = EFI_LOAD_ERROR; goto exit; @@ -392,10 +414,9 @@ 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->end_address = mdp->start_address + - loaded_image_info->image_size; + mdp->memory_type = image->image_code_type; + mdp->start_address = (uintptr_t)image->image_base; + mdp->end_address = mdp->start_address + image->image_size; } /* we don't support much: */ @@ -405,8 +426,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(&image_handle->exit_jmp)) { - ret = image_handle->exit_status; + if (setjmp(&obj->exit_jmp)) { + ret = obj->exit_status; goto exit; } @@ -418,7 +439,7 @@ static efi_status_t do_bootefi_exec(void *efi, /* Move into EL2 and keep running there */ armv8_switch_to_el2((ulong)entry, - (ulong)image_handle, + (ulong)obj, (ulong)&systab, 0, (ulong)efi_run_in_el2, ES_TO_AARCH64); @@ -435,7 +456,7 @@ static efi_status_t do_bootefi_exec(void *efi, secure_ram_addr(_do_nonsec_entry)( efi_run_in_hyp, (uintptr_t)entry, - (uintptr_t)image_handle, + (uintptr_t)obj, (uintptr_t)&systab); /* Should never reach here, efi exits with longjmp */ @@ -443,12 +464,12 @@ static efi_status_t do_bootefi_exec(void *efi, } #endif - ret = efi_do_enter(image_handle, &systab, entry); + ret = efi_do_enter(obj, &systab, entry); exit: /* image has returned, loaded-image obj goes *poof*: */ - if (image_handle) - efi_delete_handle(&image_handle->parent); + if (obj) + efi_delete_handle(&obj->parent); if (mem_handle) efi_delete_handle(mem_handle); @@ -469,33 +490,22 @@ 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 **imagep, struct efi_loaded_image_obj **objp, - const char *path, ulong test_func) + const char *path, ulong test_func, + const char *load_options_path) { - efi_status_t r; - /* 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); - r = efi_setup_loaded_image(bootefi_device_path, bootefi_image_path, - objp, imagep); - if (r) - return r; - /* - * 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(*imagep, "efi_selftest"); - return 0; + return bootefi_run_prepare(load_options_path, bootefi_device_path, + bootefi_image_path, imagep, objp); } /** @@ -589,7 +599,8 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) struct efi_loaded_image *image_prot; if (bootefi_test_prepare(&image_prot, &obj, "\\selftest", - (uintptr_t)&efi_selftest)) + (uintptr_t)&efi_selftest, + "efi_selftest")) return CMD_RET_FAILURE; /* Execute the test */ From patchwork Tue Nov 6 22:57:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 993975 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 42qQ5v1Ht1z9sCm for ; Wed, 7 Nov 2018 10:01:38 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 88A0AC2293F; Tue, 6 Nov 2018 22:59: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_DNSWL_BLOCKED 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 6D381C22859; Tue, 6 Nov 2018 22:58:15 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EADB1C2294C; Tue, 6 Nov 2018 22:58:02 +0000 (UTC) Received: from mail-it1-f202.google.com (mail-it1-f202.google.com [209.85.166.202]) by lists.denx.de (Postfix) with ESMTPS id 8832EC22874 for ; Tue, 6 Nov 2018 22:57:58 +0000 (UTC) Received: by mail-it1-f202.google.com with SMTP id y144-v6so18838353itc.5 for ; Tue, 06 Nov 2018 14:57:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Bhqc4g5uuMYE2FytmOJ+Yzve6xzlJfzjRmEj0H26uq0=; b=AU0s8KCv37XbbxQhknLQeaGNlSr9S5cqGeoib/uS3qvP2aoVPtpqshngHyHOava9BL KrPN9msGLufjTj4RWfZ0zYnFoejc3/TK2hiVAZwWjYc5SSlq91XDPsitSpI/azs5QB34 US76de/ViO/K7INnxd2iqdDyqfCeNbov4eHRcLrUDdt//xP29vXuDMcvOgiAe7U9RJfl IJXThQbzaIMjBLOsMZgjlGO8l6bq+v+qRNssp/a56ne8axXm9rNUwoA0u2/FOHK1s52i iLwk22AjW7vHMW/P1qz0VVPwYeA5ui/zUti9gpvm+lifCxBxeHj83kDe7v0flqFZynld e+yw== X-Gm-Message-State: AGRZ1gLSg9fpYPkRJxcLfgIytB6I4buY5mE0Dgh9kEnV2k5xKBfs9CoB J9s69v948qwrUlRtZdqwI8VEnrQ= X-Google-Smtp-Source: AJdET5e/jjJsZBu4cpH5C7lypz1isLapTWWaXSwtz5KCgHrw9lrxfC9ZWslIa5v01DKJNcaUF34iv2o= X-Received: by 2002:a05:660c:743:: with SMTP id a3mr2892466itl.36.1541545077623; Tue, 06 Nov 2018 14:57:57 -0800 (PST) Date: Tue, 6 Nov 2018 15:57:44 -0700 In-Reply-To: <20181106225744.139945-1-sjg@chromium.org> Message-Id: <20181106225744.139945-7-sjg@chromium.org> Mime-Version: 1.0 References: <20181106225744.139945-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog From: Simon Glass To: U-Boot Mailing List Cc: Alexander Graf Subject: [U-Boot] [PATCH v12 6/6] 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 v12: None Changes in v11: - Drop patches previously applied Changes in v9: None Changes in v7: - Drop patch "efi: Init the 'rows' and 'cols' variables" - Drop patches previous applied 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() cmd/bootefi.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 779c1f63fa8..7a077995dc5 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -351,6 +351,20 @@ static efi_status_t bootefi_run_prepare(const char *load_options_path, 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_loaded_image_obj *obj) +{ + efi_restore_gd(); + free(image->load_options); + efi_delete_handle(&obj->parent); +} + /** * do_bootefi_exec() - execute EFI binary * @@ -468,8 +482,7 @@ static efi_status_t do_bootefi_exec(void *efi, exit: /* image has returned, loaded-image obj goes *poof*: */ - if (obj) - efi_delete_handle(&obj->parent); + bootefi_run_finish(image, obj); if (mem_handle) efi_delete_handle(mem_handle); @@ -507,20 +520,6 @@ static efi_status_t bootefi_test_prepare(struct efi_loaded_image **imagep, return bootefi_run_prepare(load_options_path, bootefi_device_path, bootefi_image_path, imagep, objp); } - -/** - * 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_loaded_image_obj *obj) -{ - efi_restore_gd(); - free(image->load_options); - efi_delete_handle(&obj->parent); -} #endif /* CONFIG_CMD_BOOTEFI_SELFTEST */ static int do_bootefi_bootmgr_exec(void) @@ -605,7 +604,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /* Execute the test */ r = efi_selftest(obj, &systab); - bootefi_test_finish(image_prot, obj); + bootefi_run_finish(image_prot, obj); return r != EFI_SUCCESS; } else #endif