lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMj1kXE2abZ8v83vSr5sDZ1QNF-WMr4XCMRhZoc9EW=JAwvdCA@mail.gmail.com>
Date: Tue, 17 Dec 2024 09:49:04 +0100
From: Ard Biesheuvel <ardb@...nel.org>
To: David Woodhouse <dwmw2@...radead.org>
Cc: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>, 
	Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org, 
	"H. Peter Anvin" <hpa@...or.com>, Eric Biederman <ebiederm@...ssion.com>, 
	David Woodhouse <dwmw@...zon.co.uk>, Sourabh Jain <sourabhjain@...ux.ibm.com>, 
	Hari Bathini <hbathini@...ux.ibm.com>, Michael Ellerman <mpe@...erman.id.au>, 
	Thomas Zimmermann <tzimmermann@...e.de>, Andrew Morton <akpm@...ux-foundation.org>, 
	Baoquan He <bhe@...hat.com>, Yuntao Wang <ytcoode@...il.com>, David Kaplan <david.kaplan@....com>, 
	Tao Liu <ltao@...hat.com>, "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>, 
	Kai Huang <kai.huang@...el.com>, Josh Poimboeuf <jpoimboe@...nel.org>, 
	Breno Leitao <leitao@...ian.org>, Wei Yang <richard.weiyang@...il.com>, Rong Xu <xur@...gle.com>, 
	Thomas Weißschuh <thomas.weissschuh@...utronix.de>, 
	linux-kernel@...r.kernel.org, kexec@...ts.infradead.org, 
	Simon Horman <horms@...nel.org>, Dave Young <dyoung@...hat.com>, 
	Peter Zijlstra <peterz@...radead.org>, bsz@...zon.de, nathan@...nel.org
Subject: Re: [PATCH 9/9] x86/kexec: Use typedef for relocate_kernel_fn
 function prototype

On Tue, 17 Dec 2024 at 00:37, David Woodhouse <dwmw2@...radead.org> wrote:
>
> From: David Woodhouse <dwmw@...zon.co.uk>
>
> 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 <dwmw@...zon.co.uk>
> ---
>  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 *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);

linkage is not part of the type. 'asmlinkage' is #define'd to the
empty string today, so it doesn't matter, but better to omit it here.

>  #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 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);
>
>  #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 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 = (unsigned long)__relocate_kernel_start;
> +       relocate_kernel_fn *relocate_kernel_ptr;
>         unsigned int host_mem_enc_active;
>         int save_ftrace_enabled;
>         void *control_page;
> --
> 2.47.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ