From patchwork Wed Apr 14 07:08:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 421085 Delivered-To: patch@linaro.org Received: by 2002:a02:c4d2:0:0:0:0:0 with SMTP id h18csp3304053jaj; Wed, 14 Apr 2021 00:09:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHwHILmvzgod5nqz1+0Jk2bfzFBD8dROLjpxJXZvVQ1BQJJNxuTEXTgHZK5E6+QrxGNZoy X-Received: by 2002:a05:6402:1004:: with SMTP id c4mr39651119edu.364.1618384154078; Wed, 14 Apr 2021 00:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618384154; cv=none; d=google.com; s=arc-20160816; b=q9mroppqdxhXUOslpcMxVHA6TUqdWbJt+CXn11stH++4QnQ9bfhMMRaXNP2I7st0hn TBy0x8NoC3dJgV8qCDjc70q0qHb4DzL2l9zdd7rBkTQrcp6vSbjRhkJve3eqt30K9YPU W5RhAPn8/wSPX61/H87Q52/H3OOxX+tYZcpnt+sd7roaUuql3bL5/zAKfG5jw+xylL8y 6rQT3I9MfM5FBtSSf7ga3MNua0mmn7qEpgXwIZ3gwIPpTIFkIJGi67I8QsZ3heZFJBgw Ggxh/Z6XcqjCCo6byjDDSwOTWyHnlwoRX+5pFKFHLmGGGvnj+sIStOdiSwTuhnypJ09V xBVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=vGaxP/bpVVH/fvWo2uRSylZejawns1CqefyTkESDDhA=; b=MlNrJqk+Le08FedxX/FbWYbazOLrJtnFLJg/7j9D8gyZaEgYBdEkFmHARDFzkt04X3 6oFxsJihZdQWZ8JexrNDAG01RggOJ2Tc3E8y3eMDfpVG0IuputZKwt/eHzsXtVi184pU q1pHdJf91I6jMfi7eaEycMdKHA3i3m1EbA4SlKHw8cq3C/4LQE7NzYMQsdCF1Kblf5eI gwCbz5M/xMM5vVo9LTfnmzlsmHPvARTFfcRLGude0Z7lZJH9AfECzi/KV0Cs9hJqUoLU KGGUEywKZed8Q+XF8JVw8OeyruxBnY5ZdzrI/0wjbgUtu1DpK1ej5sGlzx+WupH1RMGm aFpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id j7si12835470ejm.492.2021.04.14.00.09.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 00:09:14 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C350081D3B; Wed, 14 Apr 2021 09:08:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id F1A8981D35; Wed, 14 Apr 2021 09:08:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 8B6E281D35 for ; Wed, 14 Apr 2021 09:08:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 69816106F; Wed, 14 Apr 2021 00:08:48 -0700 (PDT) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.16.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C1F493F792; Wed, 14 Apr 2021 00:08:46 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Alexander Graf , Jose Marinho , Sughosh Ganu Subject: [PATCH] efi_loader: esrt: Remove incorrect invocations of EFI_CALL macro Date: Wed, 14 Apr 2021 12:38:25 +0530 Message-Id: <20210414070825.20853-1-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.17.1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean Remove function invocations using the EFI_CALL macro for those functions that do not have an EFI_ENTRY call in their definition. Such functions can use u-boot api's which rely on u-boot global data(gd) pointer. The Arm and RiscV architectures maintain a separate gd pointer, one for u-boot, and a separate gd for the efi application. Calling a function through the EFI_CALL macro changes the gd pointer to that used for the efi application, with u-boot gd being unavailable. Any function then trying to dereference u-boot's gd will result in an abort. Fix this issue by removing the EFI_CALL macro for all of such functions which do not begin by an EFI_ENTRY function call. Signed-off-by: Sughosh Ganu --- I have squashed the earlier patch[1] into this one. This patch should supersede the earlier patch. [1] - https://patchwork.ozlabs.org/project/uboot/patch/20210410150948.24240-1-sughosh.ganu@linaro.org/ lib/efi_loader/efi_esrt.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) -- 2.17.1 Reviewed-by: Heinrich Schuchardt diff --git a/lib/efi_loader/efi_esrt.c b/lib/efi_loader/efi_esrt.c index 40f53260e4..3ca55ce23a 100644 --- a/lib/efi_loader/efi_esrt.c +++ b/lib/efi_loader/efi_esrt.c @@ -139,7 +139,7 @@ efi_status_t efi_esrt_allocate_install(u32 num_entries) /* If there was a previous ESRT, deallocate its memory now. */ if (esrt) - ret = EFI_CALL(efi_free_pool(esrt)); + ret = efi_free_pool(esrt); esrt = new_esrt; @@ -253,8 +253,8 @@ efi_status_t efi_esrt_add_from_fmp(struct efi_firmware_management_protocol *fmp) return EFI_INVALID_PARAMETER; } - ret = EFI_CALL(efi_allocate_pool(EFI_BOOT_SERVICES_DATA, info_size, - (void **)&img_info)); + ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, info_size, + (void **)&img_info); if (ret != EFI_SUCCESS) { EFI_PRINT("ESRT failed to allocate memory for image info.\n"); return ret; @@ -298,7 +298,7 @@ efi_status_t efi_esrt_add_from_fmp(struct efi_firmware_management_protocol *fmp) } out: - EFI_CALL(efi_free_pool(img_info)); + efi_free_pool(img_info); return EFI_SUCCESS; } @@ -384,8 +384,8 @@ efi_status_t efi_esrt_populate(void) goto out; } - ret = EFI_CALL(efi_allocate_pool(EFI_BOOT_SERVICES_DATA, info_size, - (void **)&img_info)); + ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, info_size, + (void **)&img_info); if (ret != EFI_SUCCESS) { EFI_PRINT("ESRT failed to allocate memory for image info\n"); goto out; @@ -405,13 +405,13 @@ efi_status_t efi_esrt_populate(void) if (ret != EFI_SUCCESS) { EFI_PRINT("ESRT failed to obtain image info from FMP\n"); - EFI_CALL(efi_free_pool(img_info)); + efi_free_pool(img_info); goto out; } num_entries += desc_count; - EFI_CALL(efi_free_pool(img_info)); + efi_free_pool(img_info); } EFI_PRINT("ESRT create table with %u entries\n", num_entries); @@ -430,9 +430,9 @@ efi_status_t efi_esrt_populate(void) */ it_handle = base_handle; for (u32 idx = 0; idx < no_handles; idx++, it_handle++) { - ret = EFI_CALL(efi_search_protocol(*it_handle, - &efi_guid_firmware_management_protocol, - &handler)); + ret = efi_search_protocol(*it_handle, + &efi_guid_firmware_management_protocol, + &handler); if (ret != EFI_SUCCESS) { EFI_PRINT("ESRT unable to find FMP handle (%u)\n", @@ -448,7 +448,7 @@ efi_status_t efi_esrt_populate(void) out: - EFI_CALL(efi_free_pool(base_handle)); + efi_free_pool(base_handle); return ret; } @@ -490,8 +490,8 @@ efi_status_t efi_esrt_register(void) return ret; } - ret = EFI_CALL(efi_create_event(EVT_NOTIFY_SIGNAL, TPL_CALLBACK, - efi_esrt_new_fmp_notify, NULL, NULL, &ev)); + ret = efi_create_event(EVT_NOTIFY_SIGNAL, TPL_CALLBACK, + efi_esrt_new_fmp_notify, NULL, NULL, &ev); if (ret != EFI_SUCCESS) { EFI_PRINT("ESRT failed to create event\n"); return ret;