From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1px54X-0005TG-8j for mharc-grub-devel@gnu.org; Thu, 11 May 2023 08:07:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1px54T-0005RW-R3 for grub-devel@gnu.org; Thu, 11 May 2023 08:06:57 -0400 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1px54R-0002T8-0B for grub-devel@gnu.org; Thu, 11 May 2023 08:06:57 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B602B64C5F; Thu, 11 May 2023 12:06:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 542DAC4339E; Thu, 11 May 2023 12:06:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683806812; bh=oF4YttQWjhfTrOxaCYXQ8ehFLhVTM0MrbI1KS2iEP8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fzzs2xQ8Qek5cjRd/Pu4KL98fOp6BZjhZBQuUgjYn4cZDK5BrkbBbu3jWx7eN1jwA pg4dsi7mKfObKe1xETN6356QpQDlxhhGooUtS2vSbZTLGFEH/T2ab4bBSe8KNQftpx fGHWrdhzscZ05kKjoPd4/zRvdlw1qHDo8ZYq7VMv7iF4jF3ufjx4Iq+1hXicmESF51 Pgr2t2pwbX9dWJGJlT+xASdEfJs0vgwCor2qE0eCdUt0c4hpVw/IQVHcS/RnhnB/H0 PNNlDs9MWugGMNS4gBNH1Zif7GQcxCmKdRQqSh+eJ3dOf0BAV9SdEKN0OQhROwRqcV Uq8ZgXswnfM2g== From: Ard Biesheuvel To: grub-devel@gnu.org Cc: dkiper@net-space.pl, Ard Biesheuvel Subject: [PATCH v2 5/6] efi: Remove x86_64 call wrappers Date: Thu, 11 May 2023 14:06:39 +0200 Message-Id: <20230511120640.3518732-6-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230511120640.3518732-1-ardb@kernel.org> References: <20230511120640.3518732-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8362; i=ardb@kernel.org; h=from:subject; bh=oF4YttQWjhfTrOxaCYXQ8ehFLhVTM0MrbI1KS2iEP8U=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JISXmll/mpqWLNS7/4n695Jxvr3Df0WkGU7k2HUu7t6ruV NiSrl+VHaUsDGIcDLJiiiwCs/++23l6olSt8yxZmDmsTCBDGLg4BWAiZg8YGR6nyYfMWl1RUX1g i9+6DEUds8RQe/Ety8SzF1/Ypt9h687IsPYgy+adP0/oM8yVn9hy9sKLC9EpG+8u4c9xzuuZz11 9kB0A X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2604:1380:4641:c500::1; envelope-from=ardb@kernel.org; helo=dfw.source.kernel.org X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 May 2023 12:06:58 -0000 The call wrappers are no longer needed now that GCC can generate function calls using MS calling convention, so let's get rid of them. Signed-off-by: Ard Biesheuvel --- grub-core/Makefile.core.def | 1 - grub-core/kern/x86_64/efi/callwrap.S | 129 -------------------- include/grub/efi/api.h | 73 ----------- 3 files changed, 203 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 9194be1d4f796bd7..8ee2bd89c4205761 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -227,7 +227,6 @@ kernel = { x86_64 = kern/x86_64/dl.c; x86_64_xen = kern/x86_64/dl.c; - x86_64_efi = kern/x86_64/efi/callwrap.S; x86_64_efi = kern/i386/efi/init.c; x86_64_efi = bus/pci.c; diff --git a/grub-core/kern/x86_64/efi/callwrap.S b/grub-core/kern/x86_64/efi/callwrap.S deleted file mode 100644 index 1337fd9fc823f8a4..0000000000000000 --- a/grub-core/kern/x86_64/efi/callwrap.S +++ /dev/null @@ -1,129 +0,0 @@ -/* callwrap.S - wrapper for x86_64 efi calls */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007,2009 Free Software Foundation, Inc. - * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GRUB is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . - */ - -#include -#include - -/* - * x86_64 uses registry to pass parameters. Unfortunately, gcc and efi use - * different call conversion, so we need to do some conversion. - * - * gcc: - * %rdi, %rsi, %rdx, %rcx, %r8, %r9, 8(%rsp), 16(%rsp), ... - * - * efi: - * %rcx, %rdx, %r8, %r9, 32(%rsp), 40(%rsp), 48(%rsp), ... - * - */ - - .file "callwrap.S" - .text - -FUNCTION(efi_wrap_0) - subq $40, %rsp - call *%rdi - addq $40, %rsp - ret - -FUNCTION(efi_wrap_1) - subq $40, %rsp - mov %rsi, %rcx - call *%rdi - addq $40, %rsp - ret - -FUNCTION(efi_wrap_2) - subq $40, %rsp - mov %rsi, %rcx - call *%rdi - addq $40, %rsp - ret - -FUNCTION(efi_wrap_3) - subq $40, %rsp - mov %rcx, %r8 - mov %rsi, %rcx - call *%rdi - addq $40, %rsp - ret - -FUNCTION(efi_wrap_4) - subq $40, %rsp - mov %r8, %r9 - mov %rcx, %r8 - mov %rsi, %rcx - call *%rdi - addq $40, %rsp - ret - -FUNCTION(efi_wrap_5) - subq $40, %rsp - mov %r9, 32(%rsp) - mov %r8, %r9 - mov %rcx, %r8 - mov %rsi, %rcx - call *%rdi - addq $40, %rsp - ret - -FUNCTION(efi_wrap_6) - subq $56, %rsp - mov 56+8(%rsp), %rax - mov %rax, 40(%rsp) - mov %r9, 32(%rsp) - mov %r8, %r9 - mov %rcx, %r8 - mov %rsi, %rcx - call *%rdi - addq $56, %rsp - ret - -FUNCTION(efi_wrap_7) - subq $88, %rsp - mov 88+16(%rsp), %rax - mov %rax, 48(%rsp) - mov 88+8(%rsp), %rax - mov %rax, 40(%rsp) - mov %r9, 32(%rsp) - mov %r8, %r9 - mov %rcx, %r8 - mov %rsi, %rcx - call *%rdi - addq $88, %rsp - ret - -FUNCTION(efi_wrap_10) - subq $88, %rsp - mov 88+40(%rsp), %rax - mov %rax, 72(%rsp) - mov 88+32(%rsp), %rax - mov %rax, 64(%rsp) - mov 88+24(%rsp), %rax - mov %rax, 56(%rsp) - mov 88+16(%rsp), %rax - mov %rax, 48(%rsp) - mov 88+8(%rsp), %rax - mov %rax, 40(%rsp) - mov %r9, 32(%rsp) - mov %r8, %r9 - mov %rcx, %r8 - mov %rsi, %rcx - call *%rdi - addq $88, %rsp - ret diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index b145211003954092..fb881ae12d5ae73a 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -1824,77 +1824,4 @@ struct initrd_media_device_path { } GRUB_PACKED; typedef struct initrd_media_device_path initrd_media_device_path_t; -#if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \ - || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) \ - || defined(__riscv) - -#define efi_call_0(func) (func)() -#define efi_call_1(func, a) (func)(a) -#define efi_call_2(func, a, b) (func)(a, b) -#define efi_call_3(func, a, b, c) (func)(a, b, c) -#define efi_call_4(func, a, b, c, d) (func)(a, b, c, d) -#define efi_call_5(func, a, b, c, d, e) (func)(a, b, c, d, e) -#define efi_call_6(func, a, b, c, d, e, f) (func)(a, b, c, d, e, f) -#define efi_call_7(func, a, b, c, d, e, f, g) (func)(a, b, c, d, e, f, g) -#define efi_call_10(func, a, b, c, d, e, f, g, h, i, j) (func)(a, b, c, d, e, f, g, h, i, j) - -#else - -#define efi_call_0(func) \ - efi_wrap_0(func) -#define efi_call_1(func, a) \ - efi_wrap_1(func, (grub_uint64_t) (a)) -#define efi_call_2(func, a, b) \ - efi_wrap_2(func, (grub_uint64_t) (a), (grub_uint64_t) (b)) -#define efi_call_3(func, a, b, c) \ - efi_wrap_3(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \ - (grub_uint64_t) (c)) -#define efi_call_4(func, a, b, c, d) \ - efi_wrap_4(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \ - (grub_uint64_t) (c), (grub_uint64_t) (d)) -#define efi_call_5(func, a, b, c, d, e) \ - efi_wrap_5(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \ - (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e)) -#define efi_call_6(func, a, b, c, d, e, f) \ - efi_wrap_6(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \ - (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e), \ - (grub_uint64_t) (f)) -#define efi_call_7(func, a, b, c, d, e, f, g) \ - efi_wrap_7(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \ - (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e), \ - (grub_uint64_t) (f), (grub_uint64_t) (g)) -#define efi_call_10(func, a, b, c, d, e, f, g, h, i, j) \ - efi_wrap_10(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \ - (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e), \ - (grub_uint64_t) (f), (grub_uint64_t) (g), (grub_uint64_t) (h), \ - (grub_uint64_t) (i), (grub_uint64_t) (j)) - -grub_uint64_t EXPORT_FUNC(efi_wrap_0) (void *func); -grub_uint64_t EXPORT_FUNC(efi_wrap_1) (void *func, grub_uint64_t arg1); -grub_uint64_t EXPORT_FUNC(efi_wrap_2) (void *func, grub_uint64_t arg1, - grub_uint64_t arg2); -grub_uint64_t EXPORT_FUNC(efi_wrap_3) (void *func, grub_uint64_t arg1, - grub_uint64_t arg2, grub_uint64_t arg3); -grub_uint64_t EXPORT_FUNC(efi_wrap_4) (void *func, grub_uint64_t arg1, - grub_uint64_t arg2, grub_uint64_t arg3, - grub_uint64_t arg4); -grub_uint64_t EXPORT_FUNC(efi_wrap_5) (void *func, grub_uint64_t arg1, - grub_uint64_t arg2, grub_uint64_t arg3, - grub_uint64_t arg4, grub_uint64_t arg5); -grub_uint64_t EXPORT_FUNC(efi_wrap_6) (void *func, grub_uint64_t arg1, - grub_uint64_t arg2, grub_uint64_t arg3, - grub_uint64_t arg4, grub_uint64_t arg5, - grub_uint64_t arg6); -grub_uint64_t EXPORT_FUNC(efi_wrap_7) (void *func, grub_uint64_t arg1, - grub_uint64_t arg2, grub_uint64_t arg3, - grub_uint64_t arg4, grub_uint64_t arg5, - grub_uint64_t arg6, grub_uint64_t arg7); -grub_uint64_t EXPORT_FUNC(efi_wrap_10) (void *func, grub_uint64_t arg1, - grub_uint64_t arg2, grub_uint64_t arg3, - grub_uint64_t arg4, grub_uint64_t arg5, - grub_uint64_t arg6, grub_uint64_t arg7, - grub_uint64_t arg8, grub_uint64_t arg9, - grub_uint64_t arg10); -#endif - #endif /* ! GRUB_EFI_API_HEADER */ -- 2.39.2