From patchwork Fri Jun 15 07:48:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138656 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp513506lji; Fri, 15 Jun 2018 00:49:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIpVLI4WPPYIb4ijh84w98Ux8dImhl/6Gs/QA4nteLE5MkKn406UR+Kfo7ybVN0F6Vwsy5T X-Received: by 2002:a50:f743:: with SMTP id j3-v6mr939392edn.37.1529048940054; Fri, 15 Jun 2018 00:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529048940; cv=none; d=google.com; s=arc-20160816; b=ESSlvmdZidafwJhI9gU2sSjQNn5Rltz1QDmUy6IM3jE2qON17YSfmx3D8XQIst39B6 voMvY/pyZmdW8KEjzDAUJ2FHQCvqOd/yZD1Wb5H8QdGi+uWrZFMg+y2re8+OBplJE4P9 kWYgQvLTlsHvS6lk5VV/DdMDYUAp+Yfgxr/0PdoTlUBJQJfWTo00uuqFJIrIth3zDSoB 6JFHz8aBtxZomoiQQ1uqT2awqWlxVXe81Q4KuS48JDYK4DauWH+xb4x4nKuDugR1UQjb Dm0z+Y+WrxpE20deetWu8gCJgYGM1YRyuTZIpmdBaAWrt0PLJV9Y+0P/AqTntkv6wyOZ 5vsw== 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 :arc-authentication-results; bh=KYVkFqlXxnHZagayYXPboNqk7hm0ASA2CgIM1lLrHcA=; b=cHi8OxCtOA4I/GYjXjEWkT0UPi1hFIC9phc+xERLdS5nRwvy9NtX2IgV5cC6h1MHVz R4WJVF8Pce4N4K7YbzWr3TzKaF5MiZGsZ1CkwuTBCLYlU1YktZ4Idx39hqiodd1DrQ+t xjDO7yDBmZG9ClYkE5i7/tHGVJiNZ8n4/K4MJbFKE9KXiYDHj1iQctgtdK4uUvRQsgsE IWh5aT1k1qpY/7463Qwk+IyYL0H0vbBQQ7m4++wXy6dleQXHy59L7Gf4XCGMq1SSAI71 hDVmTFFW2z987BNApINrdswu9zKXL1EVNLjL5q89JoNc/w4Rir/IUwlnE9cNCda1hO57 +3Rg== 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 c11-v6si2470672edj.417.2018.06.15.00.48.59; Fri, 15 Jun 2018 00:49:00 -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 71BCCC21E68; Fri, 15 Jun 2018 07:48:55 +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=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 6C7D8C21DA1; Fri, 15 Jun 2018 07:48:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DD9B4C21DA1; Fri, 15 Jun 2018 07:48:51 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 7E20AC21D83 for ; Fri, 15 Jun 2018 07:48:51 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B2EBBACC3; Fri, 15 Jun 2018 07:48:50 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 09:48:49 +0200 Message-Id: <20180615074849.76919-1-agraf@suse.de> X-Mailer: git-send-email 2.12.3 Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH] efi_loader: Introduce ms abi vararg helpers 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" Varargs differ between sysv and ms abi. On x86_64 we have to follow the ms abi though, so we also need to make sure we use x86_64 varargs helpers. This patch introduces generic efi vararg helpers that adhere to the respective EFI ABI. That way we can deal with them properly from efi loader code and properly interpret variable arguments. This fixes the InstallMultipleProtocolInterfaces tests in the efi selftests on x86_64 for me. Signed-off-by: Alexander Graf --- include/efi.h | 8 ++++++++ lib/efi_loader/efi_boottime.c | 36 ++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/include/efi.h b/include/efi.h index e30a3c51c6..94f00466cd 100644 --- a/include/efi.h +++ b/include/efi.h @@ -22,8 +22,16 @@ #if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB) && defined(__x86_64__)) /* EFI uses the Microsoft ABI which is not the default for GCC */ #define EFIAPI __attribute__((ms_abi)) +#define efi_va_list __builtin_ms_va_list +#define efi_va_start __builtin_ms_va_start +#define efi_va_arg __builtin_va_arg +#define efi_va_end __builtin_ms_va_end #else #define EFIAPI asmlinkage +#define efi_va_list va_list +#define efi_va_start va_start +#define efi_va_arg va_arg +#define efi_va_end va_end #endif struct efi_device_path; diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 50d311548e..404743fe01 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -2273,7 +2273,7 @@ static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces( { EFI_ENTRY("%p", handle); - va_list argptr; + efi_va_list argptr; const efi_guid_t *protocol; void *protocol_interface; efi_status_t r = EFI_SUCCESS; @@ -2282,12 +2282,12 @@ static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces( if (!handle) return EFI_EXIT(EFI_INVALID_PARAMETER); - va_start(argptr, handle); + efi_va_start(argptr, handle); for (;;) { - protocol = va_arg(argptr, efi_guid_t*); + protocol = efi_va_arg(argptr, efi_guid_t*); if (!protocol) break; - protocol_interface = va_arg(argptr, void*); + protocol_interface = efi_va_arg(argptr, void*); r = EFI_CALL(efi_install_protocol_interface( handle, protocol, EFI_NATIVE_INTERFACE, @@ -2296,19 +2296,19 @@ static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces( break; i++; } - va_end(argptr); + efi_va_end(argptr); if (r == EFI_SUCCESS) return EFI_EXIT(r); /* If an error occurred undo all changes. */ - va_start(argptr, handle); + efi_va_start(argptr, handle); for (; i; --i) { - protocol = va_arg(argptr, efi_guid_t*); - protocol_interface = va_arg(argptr, void*); + protocol = efi_va_arg(argptr, efi_guid_t*); + protocol_interface = efi_va_arg(argptr, void*); EFI_CALL(efi_uninstall_protocol_interface(handle, protocol, protocol_interface)); } - va_end(argptr); + efi_va_end(argptr); return EFI_EXIT(r); } @@ -2332,7 +2332,7 @@ static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces( { EFI_ENTRY("%p", handle); - va_list argptr; + efi_va_list argptr; const efi_guid_t *protocol; void *protocol_interface; efi_status_t r = EFI_SUCCESS; @@ -2341,12 +2341,12 @@ static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces( if (!handle) return EFI_EXIT(EFI_INVALID_PARAMETER); - va_start(argptr, handle); + efi_va_start(argptr, handle); for (;;) { - protocol = va_arg(argptr, efi_guid_t*); + protocol = efi_va_arg(argptr, efi_guid_t*); if (!protocol) break; - protocol_interface = va_arg(argptr, void*); + protocol_interface = efi_va_arg(argptr, void*); r = EFI_CALL(efi_uninstall_protocol_interface( handle, protocol, protocol_interface)); @@ -2354,20 +2354,20 @@ static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces( break; i++; } - va_end(argptr); + efi_va_end(argptr); if (r == EFI_SUCCESS) return EFI_EXIT(r); /* If an error occurred undo all changes. */ - va_start(argptr, handle); + efi_va_start(argptr, handle); for (; i; --i) { - protocol = va_arg(argptr, efi_guid_t*); - protocol_interface = va_arg(argptr, void*); + protocol = efi_va_arg(argptr, efi_guid_t*); + protocol_interface = efi_va_arg(argptr, void*); EFI_CALL(efi_install_protocol_interface(&handle, protocol, EFI_NATIVE_INTERFACE, protocol_interface)); } - va_end(argptr); + efi_va_end(argptr); return EFI_EXIT(r); }