From: Ard Biesheuvel <ardb@kernel.org>
To: grub-devel@gnu.org
Cc: Ard Biesheuvel <ardb@kernel.org>,
Daniel Kiper <daniel.kiper@oracle.com>,
Glenn Washburn <development@efficientek.com>
Subject: [PATCH v3 4/5] efi: Remove x86_64 call wrappers
Date: Tue, 23 May 2023 10:23:54 +0200 [thread overview]
Message-ID: <20230523082355.690271-5-ardb@kernel.org> (raw)
In-Reply-To: <20230523082355.690271-1-ardb@kernel.org>
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 <ardb@kernel.org>
---
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 c69c4a3321d27ecd..1d88c4d1c2555f7f 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -236,7 +236,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 <http://www.gnu.org/licenses/>.
- */
-
-#include <config.h>
-#include <grub/symbol.h>
-
-/*
- * 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 ebfa6c40fba34eae..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) || defined (__loongarch__)
-
-#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
next prev parent reply other threads:[~2023-05-23 8:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-23 8:23 [PATCH v3 0/5] efi: Implement generic EFI boot for x86 Ard Biesheuvel
2023-05-23 8:23 ` [PATCH v3 1/5] efi: Make EFI PXE protocol methods non-callable Ard Biesheuvel
2023-05-23 8:23 ` [PATCH v3 2/5] efi: Add calling convention annotation to all prototypes Ard Biesheuvel
2023-05-23 8:23 ` [PATCH v3 3/5] efi: Drop all uses of efi_call_XX wrappers Ard Biesheuvel
2023-05-23 8:23 ` Ard Biesheuvel [this message]
2023-05-23 8:23 ` [PATCH v3 5/5] efi: Use generic EFI loader for x86_64 and i386 Ard Biesheuvel
2023-05-23 15:14 ` [PATCH v3 0/5] efi: Implement generic EFI boot for x86 Daniel Kiper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230523082355.690271-5-ardb@kernel.org \
--to=ardb@kernel.org \
--cc=daniel.kiper@oracle.com \
--cc=development@efficientek.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.