From patchwork Sat Apr 10 12:09:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 418837 Delivered-To: patch@linaro.org Received: by 2002:a02:c4d2:0:0:0:0:0 with SMTP id h18csp262923jaj; Sat, 10 Apr 2021 05:09:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyh/twEtvvbHYZaxeXifyG5iwixNwBNocqhQw4XwbZAxIHxv8Ka4qkCKuKfT8nDYWzW8wJA X-Received: by 2002:a17:906:2bc3:: with SMTP id n3mr19909861ejg.418.1618056593583; Sat, 10 Apr 2021 05:09:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618056593; cv=none; d=google.com; s=arc-20160816; b=R3pV74G/RLrB3bD7R3R6WrWdN1ZxDgXwSgKhGPDFYbpI/po56flkvco4jGipJpm36q P1bvjM9nwio0woEXCDqcowuGboAGdBT43QACnZAOWgww+kjsz1V65BgIYKhiyoPR/H8s P1vAlK5gbIhN3s+SHWbROU523KwN5cecpMi+Mwl1mUK596IKiftHu8gqq8AV3b6DPOBI SnhO/nf/8/USV7db9MnCd6LsCw7qDLjxKS79Fn61kl5IVrblGKw7LZkqyQvzDrZ0KGif xkcor56C2eGomfqMRgtlY2cgqfrSCko2erDsjbvlkm2WCkOK9K9BiddjgAGroYLMmk/w gXzg== 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=QRW6jC7MySyYHwlwbmTGXx0boiGIooebwKyK+S5HA2Y=; b=dMDFOUdBN0HazLLQzR8rLF54iJ/E300nsCxHfrjPsRgPPJItPqmJxvaXfO0RHqM3nu VYQCy1rujI54i2WhBMNmzjcRCaEkhgK1/lchHDHdx4j/XDV03WgVze855aFpK4RuRhxG fLtPBy2vpFvYtCiMAQWeMSCH8+cXVwgqm09+YlxaiuOi/Do2UWZmOb+tiMzsadPL/9ww nrABtgEBkazPRfnwE581ws5kmhOIbyPJgufB5p1cEB0vkfyrTgfUkKQUl/w6C9BTZb9L FcZQKlF1HsXmdCD8ITiQhf6tbEkPi13x+nu/sPMrKy9aXkwGDAojINEK/wj7NkWaYDFa P6nw== 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 n11si4057750edi.36.2021.04.10.05.09.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Apr 2021 05:09:53 -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 0E65E8017D; Sat, 10 Apr 2021 14:09:49 +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 19BE98017D; Sat, 10 Apr 2021 14:09:47 +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 DA62380050 for ; Sat, 10 Apr 2021 14:09:43 +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 496761FB; Sat, 10 Apr 2021 05:09:42 -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 A08D13F792; Sat, 10 Apr 2021 05:09:40 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Tom Rini , Jose Marinho , Sughosh Ganu Subject: [PATCH] efi_loader: esrt: Remove EFI_CALL invocation in efi_esrt_register Date: Sat, 10 Apr 2021 17:39:27 +0530 Message-Id: <20210410120927.10210-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 The efi_esrt_register function calls efi_create_event and efi_register_protocol_notify functions. These function calls are made through the EFI_CALL macro. For the Arm and RiscV architecture platforms, the EFI_CALL macro, before invoking the corresponding function, modifies the global_data pointer. Before the function calls, the gd is set to app_gd, which is the value used by UEFI app, and after the function call, it is restored back to u-boot's gd. This becomes an issue when the EFI_CALL is used for the two function invocations, since these functions make calls to calloc, which dereferences the gd pointer. With the gd pointer being no longer valid, this results in an abort. Since these functions are using u-boot's api's, they should not be called through the EFI_CALL macro. Fix this issue by calling these functions directly, without the EFI_CALL macro. Signed-off-by: Sughosh Ganu --- This issue can be seen by executing a 'printenv -e' command on an arm architecture platform. Executing the command results in an abort. lib/efi_loader/efi_esrt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/lib/efi_loader/efi_esrt.c b/lib/efi_loader/efi_esrt.c index 947bdb5e95..141baabb01 100644 --- a/lib/efi_loader/efi_esrt.c +++ b/lib/efi_loader/efi_esrt.c @@ -490,15 +490,15 @@ 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; } - ret = EFI_CALL(efi_register_protocol_notify(&efi_guid_firmware_management_protocol, - ev, ®istration)); + ret = efi_register_protocol_notify(&efi_guid_firmware_management_protocol, + ev, ®istration); if (ret != EFI_SUCCESS) { EFI_PRINT("ESRT failed to register FMP callback\n"); return ret;