From patchwork Sat Apr 10 15:09:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 418857 Delivered-To: patch@linaro.org Received: by 2002:a02:c4d2:0:0:0:0:0 with SMTP id h18csp372684jaj; Sat, 10 Apr 2021 08:10:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ9/XRxqTExToPFfU7lNBWYAgz/vdqFP2al1J/k3ag3mx9YQWeSkR8eCJLHMkopUikjXds X-Received: by 2002:a17:906:9605:: with SMTP id s5mr20892195ejx.287.1618067426778; Sat, 10 Apr 2021 08:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618067426; cv=none; d=google.com; s=arc-20160816; b=N9N8hGy3gDeRBPxpwVq5VB0/S8PNTEEg6BYLkOdIiIJuSVe+r8teUJcJSvmQPbmpND e0dzMkc7wQC3P3Khkq1CDKWGXlu6OuWlIsc0HqZqL2MwjvVJhtP9hw2WJq1i9jmiqZ0v DL2qAarFa6N9e2aI/ct3VK0KzNJlUjHaueJmTFbznVbCumZWYZsBUonMTtm3hEkPzV/X jza1h2xCdMWxu05bK1sQaxAxrCQmvilReA3tY/KuppBW1uHh5Hvcr9WqvnFcQo1AdHAd +8O42Zn9tMfFBUjlXmbzljdS8feOHXZnzBEJqNp4/XAwAO+OQJxdlz4KeFLnJc7WngWd IYaA== 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=ImRsqYPR/8OF9ZuCpNCihhJCPTfmW96g4QCehm54svg=; b=CvPjqth1X5DsjEel0K/vzvwM0sZxPe4UgaI/m96Bw+jhaCNLdfuSmYBkXCCvT7Ba+D HgyRu1bG+/SvFWS0P5Rky+hx1hIuiGAXLDNz8CicUhv7BByvri3QbKlNYh6PMvWvIhor B6Z+3L018nDtL9UrCNmqpeDBY5BO7nfI/0fwkhb6VQBss13NATDCYoUGhxCJwtXrCdvL vs7brvJn3Li/QY+niE/YMRV5uKu0jc2bABPcF2H/hhvPRzviSDFAFNmYJOKeHHx5JV/2 VIAZQWd7e+6bT7artkCv7dKj5ll+mlPvVJqt5cl21mkO4mDem8kkFjUhfCpwUuG/J9oF SFGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id e10si4382815ejb.452.2021.04.10.08.10.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Apr 2021 08:10:26 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 F24C8801F0; Sat, 10 Apr 2021 17:10:19 +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 69635801FD; Sat, 10 Apr 2021 17:10:18 +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 C29BA800B3 for ; Sat, 10 Apr 2021 17:10:14 +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 87C9FD6E; Sat, 10 Apr 2021 08:10:12 -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 A11B03F73D; Sat, 10 Apr 2021 08:10:10 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Tom Rini , Jose Marinho , Alexander Graf , Sughosh Ganu Subject: [PATCH v2] efi_loader: esrt: Remove EFI_CALL invocation for efi_create_event Date: Sat, 10 Apr 2021 20:39:48 +0530 Message-Id: <20210410150948.24240-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 the efi_create_event function 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 function invocation, since the function makes calls to calloc, which dereferences the gd pointer. With the gd pointer being no longer valid, this results in an abort. Since this function is using u-boot's api's, it should not be called through the EFI_CALL macro. Fix this issue by calling the function directly, without the EFI_CALL macro. Signed-off-by: Sughosh Ganu --- Changes since V1: Remove the EFI_CALL macro only for efi_create_event function invocation, and not for the efi_register_protocol_notify invocation, since the later has an EFI_ENTRY function call. lib/efi_loader/efi_esrt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 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 947bdb5e95..461bd4b937 100644 --- a/lib/efi_loader/efi_esrt.c +++ b/lib/efi_loader/efi_esrt.c @@ -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;