From: "tip-bot2 for David Woodhouse" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: David Woodhouse <dwmw@amazon.co.uk>,
"Borislav Petkov (AMD)" <bp@alien8.de>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/boot] x86/kexec: Use typedef for relocate_kernel_fn function prototype
Date: Wed, 15 Jan 2025 09:17:50 -0000 [thread overview]
Message-ID: <173693267099.31546.3766901516400980865.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20250109140757.2841269-10-dwmw2@infradead.org>
The following commit has been merged into the x86/boot branch of tip:
Commit-ID: 7c61a3d8f7a8cf0f0cbdc8459dd86782ba7285f1
Gitweb: https://git.kernel.org/tip/7c61a3d8f7a8cf0f0cbdc8459dd86782ba7285f1
Author: David Woodhouse <dwmw@amazon.co.uk>
AuthorDate: Thu, 09 Jan 2025 14:04:21
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Tue, 14 Jan 2025 13:09:08 +01:00
x86/kexec: Use typedef for relocate_kernel_fn function prototype
Both i386 and x86_64 now copy the relocate_kernel() function into the control
page and execute it from there, using an open-coded function pointer.
Use a typedef for it instead.
[ bp: Put relocate_kernel_ptr ptr arithmetic on a single line. ]
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20250109140757.2841269-10-dwmw2@infradead.org
---
arch/x86/include/asm/kexec.h | 26 +++++++++++++-------------
arch/x86/kernel/machine_kexec_32.c | 7 +------
arch/x86/kernel/machine_kexec_64.c | 9 ++-------
3 files changed, 16 insertions(+), 26 deletions(-)
diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h
index 48e4f44..8ad1874 100644
--- a/arch/x86/include/asm/kexec.h
+++ b/arch/x86/include/asm/kexec.h
@@ -111,21 +111,21 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
}
#ifdef CONFIG_X86_32
-asmlinkage unsigned long
-relocate_kernel(unsigned long indirection_page,
- unsigned long control_page,
- unsigned long start_address,
- unsigned int has_pae,
- unsigned int preserve_context);
+typedef asmlinkage unsigned long
+relocate_kernel_fn(unsigned long indirection_page,
+ unsigned long control_page,
+ unsigned long start_address,
+ unsigned int has_pae,
+ unsigned int preserve_context);
#else
-unsigned long
-relocate_kernel(unsigned long indirection_page,
- unsigned long pa_control_page,
- unsigned long start_address,
- unsigned int preserve_context,
- unsigned int host_mem_enc_active);
+typedef unsigned long
+relocate_kernel_fn(unsigned long indirection_page,
+ unsigned long pa_control_page,
+ unsigned long start_address,
+ unsigned int preserve_context,
+ unsigned int host_mem_enc_active);
#endif
-
+extern relocate_kernel_fn relocate_kernel;
#define ARCH_HAS_KIMAGE_ARCH
#ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
index 1b373d7..8026516 100644
--- a/arch/x86/kernel/machine_kexec_32.c
+++ b/arch/x86/kernel/machine_kexec_32.c
@@ -160,15 +160,10 @@ void machine_kexec_cleanup(struct kimage *image)
*/
void machine_kexec(struct kimage *image)
{
+ relocate_kernel_fn *relocate_kernel_ptr;
unsigned long page_list[PAGES_NR];
void *control_page;
int save_ftrace_enabled;
- asmlinkage unsigned long
- (*relocate_kernel_ptr)(unsigned long indirection_page,
- unsigned long control_page,
- unsigned long start_address,
- unsigned int has_pae,
- unsigned int preserve_context);
#ifdef CONFIG_KEXEC_JUMP
if (image->preserve_context)
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index 1440f79..a68f5a0 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -344,12 +344,8 @@ void machine_kexec_cleanup(struct kimage *image)
*/
void __nocfi machine_kexec(struct kimage *image)
{
- unsigned long (*relocate_kernel_ptr)(unsigned long indirection_page,
- unsigned long pa_control_page,
- unsigned long start_address,
- unsigned int preserve_context,
- unsigned int host_mem_enc_active);
unsigned long reloc_start = (unsigned long)__relocate_kernel_start;
+ relocate_kernel_fn *relocate_kernel_ptr;
unsigned int host_mem_enc_active;
int save_ftrace_enabled;
void *control_page;
@@ -391,8 +387,7 @@ void __nocfi machine_kexec(struct kimage *image)
* Allow for the possibility that relocate_kernel might not be at
* the very start of the page.
*/
- relocate_kernel_ptr = control_page + (unsigned long)relocate_kernel -
- reloc_start;
+ relocate_kernel_ptr = control_page + (unsigned long)relocate_kernel - reloc_start;
/*
* The segment registers are funny things, they have both a
next prev parent reply other threads:[~2025-01-15 9:17 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-09 14:04 [PATCH v2 0/9] x86/kexec: Fixes for tip/x86/boot David Woodhouse
2025-01-09 14:04 ` [PATCH v2 1/9] x86/kexec: Disable global pages before writing to control page David Woodhouse
2025-01-15 9:17 ` [tip: x86/boot] " tip-bot2 for David Woodhouse
2025-01-09 14:04 ` [PATCH v2 2/9] x86/kexec: Ensure preserve_context flag is set on return to kernel David Woodhouse
2025-01-15 9:17 ` [tip: x86/boot] " tip-bot2 for David Woodhouse
2025-01-09 14:04 ` [PATCH v2 3/9] x86/kexec: Use correct swap page in swap_pages function David Woodhouse
2025-01-15 9:17 ` [tip: x86/boot] " tip-bot2 for David Woodhouse
2025-01-09 14:04 ` [PATCH v2 4/9] x86/kexec: Fix stack and handling of re-entry point for ::preserve_context David Woodhouse
2025-01-15 9:17 ` [tip: x86/boot] " tip-bot2 for David Woodhouse
2025-01-09 14:04 ` [PATCH v2 5/9] x86/kexec: Fix location of relocate_kernel with -ffunction-sections David Woodhouse
2025-01-15 9:17 ` [tip: x86/boot] " tip-bot2 for Nathan Chancellor
2025-01-09 14:04 ` [PATCH v2 6/9] x86/kexec: Mark machine_kexec() with __nocfi David Woodhouse
2025-01-15 9:17 ` [tip: x86/boot] " tip-bot2 for David Woodhouse
2025-01-09 14:04 ` [PATCH v2 7/9] kexec_core: Add and update comments regarding the KEXEC_JUMP flow David Woodhouse
2025-01-15 9:17 ` [tip: x86/boot] " tip-bot2 for Rafael J. Wysocki
2025-01-09 14:04 ` [PATCH v2 8/9] x86/kexec: Cope with relocate_kernel() not being at the start of the page David Woodhouse
2025-01-15 9:17 ` [tip: x86/boot] " tip-bot2 for David Woodhouse
2025-01-09 14:04 ` [PATCH v2 9/9] x86/kexec: Use typedef for relocate_kernel_fn function prototype David Woodhouse
2025-01-15 9:17 ` tip-bot2 for David Woodhouse [this message]
2025-01-14 11:34 ` [PATCH v2 0/9] x86/kexec: Fixes for tip/x86/boot David Woodhouse
2025-01-14 11:51 ` Borislav Petkov
2025-01-14 11:53 ` David Woodhouse
2025-01-14 12:11 ` Borislav Petkov
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=173693267099.31546.3766901516400980865.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=bp@alien8.de \
--cc=dwmw@amazon.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®