[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAhV-H53DkR6oK1chXQtoczqxYBCU-FMKrD99bjEvfXapND1Vw@mail.gmail.com>
Date: Fri, 5 Sep 2025 12:36:16 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: Josh Poimboeuf <jpoimboe@...nel.org>
Cc: Tiezhu Yang <yangtiezhu@...ngson.cn>, Peter Zijlstra <peterz@...radead.org>,
Nathan Chancellor <nathan@...nel.org>, loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 2/3] objtool/LoongArch: Fix unreachable instruction
warnings about EFISTUB
Hi, Josh,
On Fri, Sep 5, 2025 at 5:46 AM Josh Poimboeuf <jpoimboe@...nel.org> wrote:
>
> On Thu, Sep 04, 2025 at 10:39:30AM -0700, Josh Poimboeuf wrote:
> > On Thu, Sep 04, 2025 at 11:59:30AM +0800, Huacai Chen wrote:
> > > This is from RISC-V code.
> > >
> > > __HEAD
> > > SYM_CODE_START(_start)
> > > /*
> > > * Image header expected by Linux boot-loaders. The image header data
> > > * structure is described in asm/image.h.
> > > * Do not modify it without modifying the structure and all bootloaders
> > > * that expects this header format!!
> > > */
> > > #ifdef CONFIG_EFI
> > > /*
> > > * This instruction decodes to "MZ" ASCII required by UEFI.
> > > */
> > > c.li s4,-13
> > > j _start_kernel
> > > #else
> > > /* jump to start kernel */
> > > j _start_kernel
> > > /* reserved */
> > > .word 0
> > > #endif
> > >
> > > The HEAD section has instructions, if you change it into a data
> > > section then it loses the "x" attribute.
>
> Actually, the "x" attribute isn't needed for vmlinux. The vmlinux
> linker script places it in the text region regardless.
>
> Moving the data to a data section should be really simple, something
> like the below.
>
> And yes, even the above RISC-V code can be in a data section. Those
> instructions are part of the 'struct riscv_image_header' data structure.
This may work but also look strange (code in data section), it is more
like a "workaround". :)
Huacai
>
> diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S
> index e3865e92a917a..c42500d9fad81 100644
> --- a/arch/loongarch/kernel/head.S
> +++ b/arch/loongarch/kernel/head.S
> @@ -17,7 +17,7 @@
>
> #include "efi-header.S"
>
> - __HEAD
> + __HEADDATA
>
> _head:
> .word IMAGE_DOS_SIGNATURE /* "MZ", MS-DOS header */
> diff --git a/arch/loongarch/kernel/vmlinux.lds.S b/arch/loongarch/kernel/vmlinux.lds.S
> index 08ea921cdec16..fc35ef349aba6 100644
> --- a/arch/loongarch/kernel/vmlinux.lds.S
> +++ b/arch/loongarch/kernel/vmlinux.lds.S
> @@ -38,6 +38,7 @@ SECTIONS
> . = VMLINUX_LOAD_ADDRESS;
>
> _text = .;
> + HEAD_DATA_SECTION
> HEAD_TEXT_SECTION
>
> . = ALIGN(PECOFF_SEGMENT_ALIGN);
> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index 6b2311fa41393..c74492e1baa5a 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -629,6 +629,11 @@
> *(.static_call.text) \
> __static_call_text_end = .;
>
> +#define HEAD_DATA_SECTION \
> + .head.data : AT(ADDR(.head.data) - LOAD_OFFSET) { \
> + KEEP(*(.head.data)) \
> + }
> +
> /* Section used for early init (in .S files) */
> #define HEAD_TEXT KEEP(*(.head.text))
>
> diff --git a/include/linux/init.h b/include/linux/init.h
> index 331886205049e..fcb02ab3faae2 100644
> --- a/include/linux/init.h
> +++ b/include/linux/init.h
> @@ -98,6 +98,7 @@
>
> /* For assembly routines */
> #define __HEAD .section ".head.text","ax"
> +#define __HEADDATA .section ".head.data","aw"
> #define __INIT .section ".init.text","ax"
> #define __FINIT .previous
>
>
Powered by blists - more mailing lists