From nobody Thu Dec 18 00:07:24 2025 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8FC5219E8F for ; Thu, 9 Jan 2025 14:08:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736431715; cv=none; b=u8AhedY06y5u6AZjiVqQf8u58iQpyy5S94OiiqfsGkktrr4PO76lDf7sa0lA74JukjBpZcp5LKd07TIOuVET1+tsApPIim692P1coVf8SNyLXquBKXeJ7YORbJsdo4n78T+T+MiD75PsBziCIycMFuarqNIFxRVYSrp9zZj+HKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736431715; c=relaxed/simple; bh=66bK3hS4MjiVy30c7KVE9tQcd7zIjJHoi4zEicwN8Po=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TB1bxbKYYEPetEi1gLP1RIgBmCVHQfqN7B81rqXE5VD50jKZNxKBVyNfH06+SzjgVO/TYS8D9kg0vSNDN7KLnQD0BPEKzKNHr/HO9uv3U89ZM0nZLXUOJAuafly7o4IyjYlQAyHXcaMROB0X5x4+sYrAHrQmjZq16meguxug6yU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=desiato.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=LheePo9B; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=desiato.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="LheePo9B" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:To:From:Reply-To: Cc:Content-Type:Content-ID:Content-Description; bh=2QdnXzG6oBq2pMrwUNHKRzdcvGBvqjVeazTvAuBzw50=; b=LheePo9Br2Wd1F2sVHVFh9KY5F AH9CN9GC2iLeD4BI0v/rNS3oE5X704fVlk15HdgU/3Y8DpHdvAUa+6tmELwwau8hzBnWWwpHkFrSG z22xJb3HXUDtfOVR68jhLgFrKG8+d+YKOa+anod3bI1RgbV94rQAJxe7aE8xzso1tPFWZ8xy35mcu s9vdPpYmmUacgWxsrJimVlSx/WX0kR03pir/VKz0H3OiAUET1cvIb9PtYjfWxAd88U4KmAvpv5XF5 5c2c6VNLPhetGEogt+gyiW63xudikxjBS6LVAQKZD6VQIINM2p/lf87IogYyKocHu+1aWO1Uqq2AS GaJEjiXw==; Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by desiato.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tVtCa-00000009Zhh-3DJa; Thu, 09 Jan 2025 14:08:01 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tVtCY-0000000Bx6Y-41XW; Thu, 09 Jan 2025 14:07:58 +0000 From: David Woodhouse To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , Eric Biederman , David Woodhouse , Sourabh Jain , Hari Bathini , Michael Ellerman , Thomas Zimmermann , Andrew Morton , Baoquan He , Yuntao Wang , David Kaplan , Tao Liu , "Kirill A . Shutemov" , Kai Huang , Ard Biesheuvel , Josh Poimboeuf , Breno Leitao , Wei Yang , Rong Xu , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kernel@vger.kernel.org, kexec@lists.infradead.org, Simon Horman , Dave Young , Peter Zijlstra , bsz@amazon.de, nathan@kernel.org Subject: [PATCH v2 9/9] x86/kexec: Use typedef for relocate_kernel_fn function prototype Date: Thu, 9 Jan 2025 14:04:21 +0000 Message-ID: <20250109140757.2841269-10-dwmw2@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250109140757.2841269-1-dwmw2@infradead.org> References: <20250109140757.2841269-1-dwmw2@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by desiato.infradead.org. See http://www.infradead.org/rpr.html Content-Type: text/plain; charset="utf-8" From: David Woodhouse 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. Signed-off-by: David Woodhouse --- arch/x86/include/asm/kexec.h | 26 +++++++++++++------------- arch/x86/kernel/machine_kexec_32.c | 7 +------ arch/x86/kernel/machine_kexec_64.c | 6 +----- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h index 48e4f44f794f..8ad187462b68 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 *n= ewregs, } =20 #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 =20 #ifdef CONFIG_X86_32 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_k= exec_32.c index 1b373d79cedc..80265162aeff 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); =20 #ifdef CONFIG_KEXEC_JUMP if (image->preserve_context) diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_k= exec_64.c index 1440f792a86d..dd75a51463a2 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 =3D (unsigned long)__relocate_kernel_start; + relocate_kernel_fn *relocate_kernel_ptr; unsigned int host_mem_enc_active; int save_ftrace_enabled; void *control_page; --=20 2.47.0