From patchwork Sun Sep 30 05:26:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 147853 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2528855lji; Sat, 29 Sep 2018 22:26:36 -0700 (PDT) X-Google-Smtp-Source: ACcGV62/PkIp8hbCi7NaMo/VTK/baCHytYOXM0rQgT4n0GGUFPi1qXOFqvPSqVJeHbxRFyPXkgnx X-Received: by 2002:a50:f74b:: with SMTP id j11-v6mr11193363edn.51.1538285196692; Sat, 29 Sep 2018 22:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538285196; cv=none; d=google.com; s=arc-20160816; b=YySdUP+Oo7woGI9a3PBrVouGbuR5rvH7zjEU3ezK87NEtxlB6jOLh5D7SkrU4KwMBX YmPaf6ZSms6n7paV/l+n/ik12sha3tOAXCoytXQGdj1SR+/WNWLymY5WlsCZqF+B95It CDHH+ToUGAJMJTydAHNgZz/BbcZqhyLOvXw+KiB461XgFDbnPwJhVL0WUxdnPhnjnEBt jH7/tLRXGDcX40EQhWnMVtDFcJuMfn/8pqFhMHwgveVKWPi0lT8HXBy7CUMFzEchtLq0 vWc+l17JdEjbmI2hnsH+Mh51ol/cFePlY2Usr790xHNccHK/6LJoR6uXeh3/WuFnqrXN WLXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:message-id:date:to:from; bh=llsYVwa3QISGuWcfGYaGtfDLN7Nq/LRe9/cj2xv9Aqo=; b=TBp/uZfidf2jPcFb5H6hWuHQ0GnHA7h8b6CgYWhnS6B9qFuzCWQB2x/OGYL7A9hcns M+H3VQkANUGweIVrR8hsNaqAuSYqanSOtFsgQ+ECQqWjBD3Ofdsa1wZfiXe/i3By7r77 nw/eZmrLiYuk7a2x0Io8yjPiPxo+0mIMjYa/vkOol+JuALeAX1UEjuXlPCrQAjCzgVtn RA/1E7Qe9+LPVO2EWP8AKeRnxqc9+ush/wbfy6vInYQspt45iiG58fjk2uPMXyF3sK1v BRyMOe/izV8lM1KciU0E4lcf5UJ9ilvYX/WyeUDYFYkVjPWvdEi6ZL1hyck4pFkFiPJ+ NSxQ== 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 l21-v6si2697730ejc.125.2018.09.29.22.26.35; Sat, 29 Sep 2018 22:26:36 -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 BA04EC21F4F; Sun, 30 Sep 2018 05:26:31 +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=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE 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 192B2C21EE8; Sun, 30 Sep 2018 05:26:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9FED5C21E9F; Sun, 30 Sep 2018 05:26:27 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lists.denx.de (Postfix) with ESMTPS id 4EDFEC21EE3 for ; Sun, 30 Sep 2018 05:26:27 +0000 (UTC) Received: from LPT2.fritz.box ([91.12.27.79]) by mail.gmx.com (mrgmx003 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MegbQ-1gLn9E2Js8-00OGJ9; Sun, 30 Sep 2018 07:26:24 +0200 Received: from LPT2.fritz.box ([91.12.27.79]) by mail.gmx.com (mrgmx003 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MegbQ-1gLn9E2Js8-00OGJ9; Sun, 30 Sep 2018 07:26:24 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Sun, 30 Sep 2018 07:26:01 +0200 Message-Id: <20180930052601.7173-1-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:/CXV1BWe5fhZwPHqB7yAeZJPleH1cP/RvfukeATWknzVnkGjOKc Hm+W4lL4ZmHUNZOt/5cAzYoFU5vWxpRmBGP19oy2fuAwnloA/zTlX65SsA1DfWAoCfVWIGa 3Z7MPOYrui2wlXgAomgIzYqz0AG+qd6JfMsqdNurvivU9QgwMC+2y+/8M+c2n1bzfrgYX4y ITOVyg3R4Xnd4/JQ4Oecw== X-UI-Out-Filterresults: notjunk:1; V01:K0:w8jgjdkMQVA=:7Z0EyYWYP5HMo2NqKLQguc hRn8w/2Um0LcOK9YCLbtXR6EMC/B2wnT7X3bXfP+JjF6wrf5zm9+JXc+GpVJ/PNJw+8t5MWid EyTVBPjd5ag3eQnP8H2dEgqWxNPCj/lwrl2RVrKw4ReSZcj74dcrPhthAavSujgI+2FSk+KPi jVmHIUWcTjiygZ+6C3Wdkmxpu73Jl32yh0Tbynnp76hrjj4ZUrTj+gYmFXW/YSk/PQNbV5/CO GOzLTjIdweKYUtgGnbdzjBrKOMaWX0Lv7uHLF4+goAPMG0U/tfuCBUPYKw6Tgs8Yj6SjhUVFM 4yhV1GU3AZ3qA3KwbnDp2t1oY3LQxGze88xQgeEXPw6s2kcCx/Greadr+sEiuDF20lpYynJth KjDMAslf1NTG5IDsbwVCypoQAVqhcPum+iLDXk0/1RI2GrrEgflrHqhOlwo9DMdcA5//RPIjt LHXHeQ9JVdngf2K9+MDnH0DbMGanOAWYDmuxnvSp9dyCulK0lScBCVpVpcBif2qre88wTmAr+ p+yEH0iT6AVQfMPNeptlaECeV6cLOhIO+uQltilZbAen2yXWZvF0xkTeJ57sklS367wtPydZF 9eBOoQFojHTrAs+jNqM3MdGGLWZkoWzgVKiyDktK2zdws7wCUZtosmBPo+0/JncrySZxCjNva gws8DC9vmWefB99jfRNMv1ET3J8OF8R/8+GawjLOQ6KgQaaXlN1Am/U9v5FFMZ4T7ivSjYNt3 l339Q/9XD/An4ncYs3iEDU1tyXUO6mFriIrXF7/JJn4AvWc34T5j6+z2JB0ueOK4u9OelxdDs hSegKnifC9dQ4Xk0DYoi/Fp1xu1jQ== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 1/1] efi_loader: set image_base and image_size to correct values 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" From: AKASHI Takahiro Currently, image's image_base points to an address where the image was temporarily uploaded for further loading. Since efi_loader relocates the image to final destination, image_base and image_size should reflect that. This bug was detected in UEFI SCT, "Loaded Image Protocol Test - test 2," which shows that 'Unload' function doesn't fit into a range suggested by image_base and image_size. TestCase/UEFI/EFI/Protocol/LoadedImage/BlackBoxTest/ LoadedImageBBTestMain.c:1002 This patch also reverts a patch, "efi_loader: save image relocation address and size" since newly added fields are no longer needed. Signed-off-by: AKASHI Takahiro Rebase the patch. Keep the relocation address in struct efi_image_object. We will use the address to free the image in UnloadImage. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_image_loader.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index a18ce0a5705..39902152f3c 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -212,7 +212,6 @@ void *efi_load_pe(struct efi_loaded_image_obj *handle, void *efi, int rel_idx = IMAGE_DIRECTORY_ENTRY_BASERELOC; void *entry; uint64_t image_base; - uint64_t image_size; unsigned long virt_size = 0; int supported = 0; @@ -256,7 +255,6 @@ void *efi_load_pe(struct efi_loaded_image_obj *handle, void *efi, IMAGE_NT_HEADERS64 *nt64 = (void *)nt; IMAGE_OPTIONAL_HEADER64 *opt = &nt64->OptionalHeader; image_base = opt->ImageBase; - image_size = opt->SizeOfImage; efi_set_code_and_data_type(loaded_image_info, opt->Subsystem); efi_reloc = efi_alloc(virt_size, loaded_image_info->image_code_type); @@ -272,7 +270,6 @@ void *efi_load_pe(struct efi_loaded_image_obj *handle, void *efi, } else if (nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) { IMAGE_OPTIONAL_HEADER32 *opt = &nt->OptionalHeader; image_base = opt->ImageBase; - image_size = opt->SizeOfImage; efi_set_code_and_data_type(loaded_image_info, opt->Subsystem); efi_reloc = efi_alloc(virt_size, loaded_image_info->image_code_type); @@ -315,10 +312,10 @@ void *efi_load_pe(struct efi_loaded_image_obj *handle, void *efi, invalidate_icache_all(); /* Populate the loaded image interface bits */ - loaded_image_info->image_base = efi; - loaded_image_info->image_size = image_size; handle->reloc_base = efi_reloc; handle->reloc_size = virt_size; + loaded_image_info->image_base = efi_reloc; + loaded_image_info->image_size = virt_size; return entry; }