From patchwork Thu Aug 9 06:50:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 143813 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1722885ljj; Wed, 8 Aug 2018 23:50:51 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwVmfNsEr/YCEWD9pLTu8B8Kyzbr78ifiVjr53F+p4CsO78cbhx0/8MdZ9n1Gpw6IO5+afm X-Received: by 2002:a50:ab13:: with SMTP id s19-v6mr1584498edc.133.1533797451276; Wed, 08 Aug 2018 23:50:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533797451; cv=none; d=google.com; s=arc-20160816; b=fZdqTc/+lkqH73j+X3+HZ2h6uY2m8mIqC/2uObaVm+pU+OEq9qRR4HIMri4Ge8pVLy UGNOs4X1NKhGjjKM89shoH7iGVNPXqV3yQsyQ0WspHpTPkaeWjsyOQP3Wb0sMkTjxIjj l/l+EYFCVe0tPLRAZF3JlQO6XHLoqfBNd78oHImH1cNksdgmTGlYCmrifC40uIeHnPfy V9Kb9NPn2yPzS2fNIAIk5eR+ufntXPWRjg+U3lGBqWf9r/gSwlN06+txL2I91bdqxYZ9 +YUmHR1xdFT5PZ/cU+jZDtYNc+y9Ov8agS/4XvEZMc1T3Nu0sCdPwHbeNjLG0f9NrxK4 /2lQ== 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 :dkim-signature:arc-authentication-results; bh=GP/NSipsJepeC/Pz+6Cz/8qmYKIBDIf7V5LecxKbqhE=; b=1KpomMms8YxJOLYXNUkk7Em7p9v4Av9vk7axnO1y0PTiabheyH56/s5gdBPZSWwbjE MMAkRJWalMhnpZ1AZKj/3HOl/3lugyLV9tUlRC8oHXtVainHvWJYNzYWmmNKWIWjqkn/ kp7Q7eupB06T3LXmpNz4GaOO7l1Mw6CRXdfOH3xUh1wvQhxAXL8VOB3zwAe6+4Uw0zda hEx1mPg6EMgg8FXt8dGWg3IjmvX0EVrvP+tK7iNr/QVvBcHWi0Iw1iZ0RQYaEWj85GxW 2cmjzc3IqXJ76MHVObp4n6R7Yn/6sXmIAkkccUiUBPSI7s8x3nr+9LkPdls9sjEFODRR CbaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=P2dHltMo; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id y34-v6si3900733edc.338.2018.08.08.23.50.50; Wed, 08 Aug 2018 23:50:51 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=P2dHltMo; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id AA627C21C4A; Thu, 9 Aug 2018 06:50:48 +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 BEBDFC21C4A; Thu, 9 Aug 2018 06:50:46 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D4962C21C4A; Thu, 9 Aug 2018 06:50:45 +0000 (UTC) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by lists.denx.de (Postfix) with ESMTPS id 38FC9C21C27 for ; Thu, 9 Aug 2018 06:50:45 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id j26-v6so2361344pfi.10 for ; Wed, 08 Aug 2018 23:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=VQ8FA/RPewXN6lV5WzuReh88nI8+/+kAI37J5mZaTdw=; b=P2dHltMoRanyHtOsf8aLWZMhdeLqXhY31MGyB4bmMng5A+UQAGJCdiXddpsBOAhOsF mLmVcvETCiblRHM/HF+Hay1JOXzkC5Md1DVB60+gbLcgcB3ha3Ca1K3CJ5M/cQzj5Vq9 BRU4JGETLH5YaKwdGwYhHIiTvQ6tQV9Su77/4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=VQ8FA/RPewXN6lV5WzuReh88nI8+/+kAI37J5mZaTdw=; b=Qh6EyJ8RpQLHPnmZNDsWg2MzaZ4Mcx8apaUGax8tJI2elH6bmDoo3nwreMX9PdpFPo wS4CfQTK4tels/W1RmROsl9UmrFtLd3vm4BMcFSk1aA+FxR2mgU/9x1F9SFAh9OeoEhw zdNKpROkOuV/STnooQSnft1YDH3dzTKC/B84fKtL1ziHiYeIPjX4kB29eMJ0Hdz+ezWl LLMAj+FQyd8VCWFXFAqzaoC1/wqNsThHjkg2J+X8RNhKVm0N+SChElz+uuGx4c8Mp5PP tW49LucfBRZbLJiYzycD9TTu7KdFplSyn3+5OUHM1j/VgrY1E36ZQiHfcGiRaNxPSSEB ng6A== X-Gm-Message-State: AOUpUlFhGosM8G1HBMQqNGMcS1FQEQwleQ0QwZDOHPSL8yrCODN6+YVX NMq6E605sWJxkeyl77ytR0fgFQ== X-Received: by 2002:a62:8913:: with SMTP id v19-v6mr1006421pfd.127.1533797443679; Wed, 08 Aug 2018 23:50:43 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id f3-v6sm5654817pgq.49.2018.08.08.23.50.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 23:50:43 -0700 (PDT) From: AKASHI Takahiro To: agraf@suse.de Date: Thu, 9 Aug 2018 15:50:20 +0900 Message-Id: <20180809065020.8895-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH] efi_loader: execute image's unload function 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" Currently, unload function in EFI_LOADED_IMAGE_PROTOCOL is never called at UnloadImage Boot Service. This is not compliant to UEFI specification. See chapter "9.1 EFI Loaded Image Protocol." Signed-off-by: AKASHI Takahiro --- include/efi_api.h | 4 +++- lib/efi_loader/efi_boottime.c | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/efi_api.h b/include/efi_api.h index a4343ae98e2..b2806fba3b8 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -326,6 +326,8 @@ struct efi_system_table { #define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000 +typedef efi_status_t (EFIAPI *efi_image_unload_t)(efi_handle_t *image_handle); + struct efi_loaded_image { u32 revision; void *parent_handle; @@ -339,7 +341,7 @@ struct efi_loaded_image { aligned_u64 image_size; unsigned int image_code_type; unsigned int image_data_type; - unsigned long unload; + efi_image_unload_t unload; /* Below are efi loader private fields */ #ifdef CONFIG_EFI_LOADER diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 80061e10ebc..d6fcf7e0049 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1843,9 +1843,18 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle, */ static efi_status_t EFIAPI efi_unload_image(efi_handle_t image_handle) { + struct efi_loaded_image *info = image_handle; struct efi_object *efiobj; + efi_status_t ret; EFI_ENTRY("%p", image_handle); + + if (info->unload) { + ret = info->unload(image_handle); + if (ret != EFI_SUCCESS) + return EFI_EXIT(ret); + } + efiobj = efi_search_obj(image_handle); if (efiobj) list_del(&efiobj->link);