From patchwork Wed Jul 26 11:41:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 108754 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp692045qge; Wed, 26 Jul 2017 04:41:15 -0700 (PDT) X-Received: by 10.80.214.89 with SMTP id c25mr595904edj.232.1501069275652; Wed, 26 Jul 2017 04:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501069275; cv=none; d=google.com; s=arc-20160816; b=Zld19iMQQMpGlnq1PpCKB02R6hT9xMmdeJ6k1LO819Eu+4YjrWfd2JVbS9FN6+bAC3 peDYdpZ9jVstMHqHHD+aPA44FzZn7atQAjHtnWrUnHIDKeNAPHGdhCpHBCG6XdoZwUSc btsRKcoAAT6GvNMRxVh3Qcf1mmny43JFoC8CXvlEIGM+aAEDNXFnyo0W3rR5y/ICAbbH qIyv28ecReE2NKgQ1P77LWEk54TKgc022YfPr1niTTcBGmrykUuyXaHfOAd/YvjxBnQ2 4a6QDfDi6VWlJqfpm4s+vo1Yyl5A28s1IzfaKHUrafLSQWxKePYDZnNRy3I8t3kpLtaH 152Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from :arc-authentication-results; bh=s9rdscZohTm0c5bfWFuoWwNz8yvVRUmdqqecWcRdULY=; b=FEX84VOy74baZtPXXmmSsI8AmFu9jztz9vcvRUpSirv7JF1oNEBk6fN+k5uKwymplw XRLG4Cd44wD8KmnT1HpkYWiqOsu/B3MldqD9VgjAwgrSn1kjOVfHIj00Wh/2D5oysu+R mWX4CGtvu9JTOZlIBQASwbLU/LIAlaWQKaR6V52LjC5WH91gL1PRY9l7bW6uteYRFjSk 6inh10yMUMusd3HAb8BU61y8Ie4zxYiFbmNdAfb59ukv40COt3/AZL8gYAeFb1fTQiyE ZhFekgJA0cJrg8xQPtB6uKA+9GjYCOw23wdPKvvhMHm4FSEUVRc4Snu3kVXg5lpvLmhl qTXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id g30si11256162ede.335.2017.07.26.04.41.14; Wed, 26 Jul 2017 04:41:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id ADC05C21F88; Wed, 26 Jul 2017 11:41:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED 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 8413BC21E31; Wed, 26 Jul 2017 11:41:08 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 38C15C21E31; Wed, 26 Jul 2017 11:41:07 +0000 (UTC) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id DE1B4C21DA3 for ; Wed, 26 Jul 2017 11:41:06 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 664B7AB1E; Wed, 26 Jul 2017 11:41:06 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Wed, 26 Jul 2017 13:41:04 +0200 Message-Id: <20170726114105.51159-1-agraf@suse.de> X-Mailer: git-send-email 2.12.3 Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH 1/2] efi_loader: Improve install_configuration_table 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" The INSTALL_CONFIGURATION_TABLE callback also provides the ability to remove table entries. This patch adds that functionality. Signed-off-by: Alexander Graf --- lib/efi_loader/efi_boottime.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 9a1a93fade..17c531a480 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -630,6 +630,17 @@ static efi_status_t EFIAPI efi_locate_device_path(efi_guid_t *protocol, return EFI_EXIT(EFI_NOT_FOUND); } +/* Collapses configuration table entries, removing index i */ +static void efi_remove_configuration_table(int i) +{ + struct efi_configuration_table *this = &efi_conf_table[i]; + struct efi_configuration_table *next = &efi_conf_table[i+1]; + struct efi_configuration_table *end = &efi_conf_table[systab.nr_tables]; + + memmove(this, next, (ulong)end - (ulong)next); + systab.nr_tables--; +} + efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table) { int i; @@ -637,11 +648,17 @@ efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table /* Check for guid override */ for (i = 0; i < systab.nr_tables; i++) { if (!guidcmp(guid, &efi_conf_table[i].guid)) { - efi_conf_table[i].table = table; + if (table) + efi_conf_table[i].table = table; + else + efi_remove_configuration_table(i); return EFI_SUCCESS; } } + if (!table) + return EFI_NOT_FOUND; + /* No override, check for overflow */ if (i >= ARRAY_SIZE(efi_conf_table)) return EFI_OUT_OF_RESOURCES; From patchwork Wed Jul 26 11:41:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 108755 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp692337qge; Wed, 26 Jul 2017 04:41:33 -0700 (PDT) X-Received: by 10.80.164.18 with SMTP id u18mr587562edb.250.1501069293743; Wed, 26 Jul 2017 04:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501069293; cv=none; d=google.com; s=arc-20160816; b=CwA4e4uTCtS3G88Z/wlxbFY3egdPoNqo3o9xA6T1aE7xlsLjUFabQINdR2w5M3N6JC eK33f0FR9XVzD1seEbDowBpZE8fdby04f6XuDfx40KTsAwwndF17amGo1u61CcUEyGtw 3PL6jdpmUphsITsTKuK3hqeXoyzlGcxVWHScLbQQTkvVPtPkYD1SXDq1FzQBBakOoRVG g9wks36espSqX9fhgG6FgZThnLaM1UTBX15z/3ST0c83I8UfJf/6RKhA7pGjRFwBaUCu kJ8lVIpmufoLRC07Y6QewHIyPEpALPpssQjSVufJka+zhQLRBxCFxzr4sTdFFPd0Qnd3 WJYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=WZ6bJcNZyoxOExlrcfVfP3klJSJ6lAzwte6xxqvzE3w=; b=IY9Cw1xrBnUFzdBYmZ2yrVzKJ9Y6lHWoiPjR6yVpXbpiWhfZHLb5ejNmy6JyDqfGg1 DbhLafjmr58ZrCchuWG8Ea1YQyMjB0jYYT52gcUyklY6ifwUT84cKzaJHyuUWwlzv4g8 lb4QtIZUgEZ7fd6e6UxrZMk+9K5P9tOIRengFjAhTpN8qQxV3WkcCFVirsEp+lxLM2ru 0NzXxXHu0rOGG+Q930jl9MhsUwtsSke//TyuCGRNTNrd1KJd5fEssZFGQBrt7jEMLff/ gQmM6Z3MKkfJMb8Sx+/mKyHTYDF3bI8QmMb3fiP/w0mhhLAmAFprq+bcswyrPjZWHuGB vsMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 4si773830edc.490.2017.07.26.04.41.33; Wed, 26 Jul 2017 04:41:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 49A73C2206B; Wed, 26 Jul 2017 11:41:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED 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 49B87C2206B; Wed, 26 Jul 2017 11:41:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 97D50C22051; Wed, 26 Jul 2017 11:41:12 +0000 (UTC) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 8F33CC21FD6 for ; Wed, 26 Jul 2017 11:41:09 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 61452AB1E; Wed, 26 Jul 2017 11:41:09 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Wed, 26 Jul 2017 13:41:05 +0200 Message-Id: <20170726114105.51159-2-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170726114105.51159-1-agraf@suse.de> References: <20170726114105.51159-1-agraf@suse.de> Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH 2/2] efi_loader: Fix configuration table override 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" Before commit 7cbc12415d ("efi_loader: initalize EFI object list only once") we recreated the world on every bootefi invocation. That included the object tree as well as the configuration tables. Now however we don't recreate them, which means we must not explicitly override the configuration tables, as otherwise we may lose our SMBIOS table from the configuration table list on second bootefi invocation. This patch makes bootefi call our normal configuration table modification APIs to add/remove the FDT instead of recreating all tables from scratch. That way the SMBIOS table gets preserved across multiple invocations. Signed-off-by: Alexander Graf --- cmd/bootefi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 9526f6c60d..d20775eccd 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -215,6 +215,7 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt) ulong (*entry)(void *image_handle, struct efi_system_table *st) asmlinkage; ulong fdt_pages, fdt_size, fdt_start, fdt_end; + const efi_guid_t fdt_guid = EFI_FDT_GUID; bootm_headers_t img = { 0 }; /* @@ -233,9 +234,7 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt) } /* Link to it in the efi tables */ - systab.tables[0].guid = EFI_FDT_GUID; - systab.tables[0].table = fdt; - systab.nr_tables = 1; + efi_install_configuration_table(&fdt_guid, fdt); /* And reserve the space in the memory map */ fdt_start = ((ulong)fdt) & ~EFI_PAGE_MASK; @@ -248,7 +247,7 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt) EFI_BOOT_SERVICES_DATA, true); } else { printf("WARNING: Invalid device tree, expect boot to fail\n"); - systab.nr_tables = 0; + efi_install_configuration_table(&fdt_guid, NULL); } /* Load the EFI payload */