arch/loongarch/Kconfig | 3 + arch/loongarch/Makefile | 17 +++++ arch/loongarch/include/asm/elf.h | 37 ++++++++++ arch/loongarch/include/asm/module.h | 23 ++++++ arch/loongarch/include/asm/module.lds.h | 1 + arch/loongarch/include/asm/percpu.h | 8 +++ arch/loongarch/kernel/head.S | 10 +-- arch/loongarch/kernel/module-sections.c | 56 +++++++++++++-- arch/loongarch/kernel/module.c | 93 ++++++++++++++++++++++++- 9 files changed, 238 insertions(+), 10 deletions(-)
The version 2.00 of LoongArch ELF ABI specification introduced new
relocation types, and the development tree of Binutils and GCC has
started to use them. If the kernel is built with the latest snapshot of
Binutils or GCC, it will fail to load the modules because of unrecognized
relocation types in modules.
Add support for GOT and new relocation types for the module loader, so
the kernel (with modules) can be built with the "normal" code model and
function properly.
This series does not break the compatibility with old toolchain using
stack-based relocation types, so with the patches applied the kernel can
be be built with both old and new toolchains. But, the combination of
"new" Binutils and "old" GCC is not supported.
Tested by building the kernel with the following combinations:
- GCC 12 and Binutils 2.39
- GCC trunk and Binutils trunk
and running the builds with 35 in-tree modules loaded, and loading one
module with 20 GOT loads and a per-CPU variable (loaded addresses
verified by comparing with /proc/kallsyms).
Changes from v6 to v7:
- Simplify apply_r_larch_pcala.
- Remove a build check only for excluding early GCC 13 dev snapshots.
- Squash model attribute addition into the previous patch.
- Retain "-fplt".
Changes from v5 to v6:
- Restore version number.
- Rename CONFIG_CC_HAS_EXPLICIT_RELOCS to CONFIG_AS_HAS_EXPLICIT_RELOCS.
It now only checks assembler.
- No longer support "old GCC with new Binutils", so R_LARCH_ABS* is
dropped.
- "Old GCC with old Binutils" is still supported until Arnd ack.
- "New GCC with old Binutils" is still supported as it does not
require additional code.
- Remove "cc-option" around "-mexplicit-relocs". For unsupported
"old GCC with new Binutils" combination, forcing -mexplicit-relocs
makes assembling fail, instead of silently producing unloadable
modules.
- Move the error report for "lacking model attribute" into Makefile.
- Squash the two patches for R_LARCH_B26 and R_LARCH_PCALA* into one.
Changes from v4 to v5 ("v5" missed in the subject):
- Change subject.
- Introduce CONFIG_CC_HAS_EXPLICIT_RELOCS.
- Retain -Wa,-mla-* options for old toolchains
(!CONFIG_CC_HAS_EXPLICIT_RELOCS).
- Use __attribute__((model("extreme"))) in PER_CPU_ATTRIBUTES, to fix
a breakage with per-CPU variables defined in modules.
- Handle R_LARCH_PCALA64_{HI12,LO12} for extreme model.
- Handle R_LARCH_ABS* for "old GCC with new Binutils".
- Separate the last patch into more small patches.
- Avoid BUG_ON() for the handling of GOT.
Changes from v3 to v4:
- No code change. Reword the commit message of the 3rd patch again
based on suggestion from Huacai.
Changes from v2 to v3:
- Use `union loongarch_instruction` instead of explicit bit shifts
applying the relocation. Suggested by Youling.
- For R_LARCH_B26, move the alignment check before the range check to be
consistent with stack pop relocations. Suggested by Youling.
- Reword the commit message of the 3rd patch. Suggested by Huacai.
Changes from v1 to v2:
- Fix a stupid programming error (confusion between the number of PLT
entries and the number of GOT entries). (Bug spotted by Youling).
- Synthesize the _GLOBAL_OFFSET_TABLE_ symbol with module.lds, instead
of faking it at runtime. The 3rd patch from V1 is now merged into
the 1st patch because it would be a one-line change. (Suggested by
Jinyang).
- Keep reloc_rela_handlers[] ordered by the relocation type ID.
(Suggested by Youling).
- Remove -fplt along with -Wa,-mla-* options because it's the default.
(Suggested by Youling).
Xi Ruoyao (5):
LoongArch: Add CONFIG_AS_HAS_EXPLICIT_RELOCS
LoongArch: Adjust symbol addressing for CONFIG_AS_HAS_EXPLICIT_RELOCS
LoongArch: Define ELF relocation types added in v2.00 ABI
LoongArch: Support PC-relative relocations in modules
LoongArch: Support R_LARCH_GOT_PC* in modules
arch/loongarch/Kconfig | 3 +
arch/loongarch/Makefile | 17 +++++
arch/loongarch/include/asm/elf.h | 37 ++++++++++
arch/loongarch/include/asm/module.h | 23 ++++++
arch/loongarch/include/asm/module.lds.h | 1 +
arch/loongarch/include/asm/percpu.h | 8 +++
arch/loongarch/kernel/head.S | 10 +--
arch/loongarch/kernel/module-sections.c | 56 +++++++++++++--
arch/loongarch/kernel/module.c | 93 ++++++++++++++++++++++++-
9 files changed, 238 insertions(+), 10 deletions(-)
--
2.37.0
Hi, Ruoyao,
Thank you for your contribution, this whole series will be queued for
6.1. Though lkp reported some warnings, I will fix them myself.
Huacai
On Tue, Aug 30, 2022 at 6:48 PM Xi Ruoyao <xry111@xry111.site> wrote:
>
> The version 2.00 of LoongArch ELF ABI specification introduced new
> relocation types, and the development tree of Binutils and GCC has
> started to use them. If the kernel is built with the latest snapshot of
> Binutils or GCC, it will fail to load the modules because of unrecognized
> relocation types in modules.
>
> Add support for GOT and new relocation types for the module loader, so
> the kernel (with modules) can be built with the "normal" code model and
> function properly.
>
> This series does not break the compatibility with old toolchain using
> stack-based relocation types, so with the patches applied the kernel can
> be be built with both old and new toolchains. But, the combination of
> "new" Binutils and "old" GCC is not supported.
>
> Tested by building the kernel with the following combinations:
>
> - GCC 12 and Binutils 2.39
> - GCC trunk and Binutils trunk
>
> and running the builds with 35 in-tree modules loaded, and loading one
> module with 20 GOT loads and a per-CPU variable (loaded addresses
> verified by comparing with /proc/kallsyms).
>
> Changes from v6 to v7:
>
> - Simplify apply_r_larch_pcala.
> - Remove a build check only for excluding early GCC 13 dev snapshots.
> - Squash model attribute addition into the previous patch.
> - Retain "-fplt".
>
> Changes from v5 to v6:
>
> - Restore version number.
> - Rename CONFIG_CC_HAS_EXPLICIT_RELOCS to CONFIG_AS_HAS_EXPLICIT_RELOCS.
> It now only checks assembler.
> - No longer support "old GCC with new Binutils", so R_LARCH_ABS* is
> dropped.
> - "Old GCC with old Binutils" is still supported until Arnd ack.
> - "New GCC with old Binutils" is still supported as it does not
> require additional code.
> - Remove "cc-option" around "-mexplicit-relocs". For unsupported
> "old GCC with new Binutils" combination, forcing -mexplicit-relocs
> makes assembling fail, instead of silently producing unloadable
> modules.
> - Move the error report for "lacking model attribute" into Makefile.
> - Squash the two patches for R_LARCH_B26 and R_LARCH_PCALA* into one.
>
> Changes from v4 to v5 ("v5" missed in the subject):
>
> - Change subject.
> - Introduce CONFIG_CC_HAS_EXPLICIT_RELOCS.
> - Retain -Wa,-mla-* options for old toolchains
> (!CONFIG_CC_HAS_EXPLICIT_RELOCS).
> - Use __attribute__((model("extreme"))) in PER_CPU_ATTRIBUTES, to fix
> a breakage with per-CPU variables defined in modules.
> - Handle R_LARCH_PCALA64_{HI12,LO12} for extreme model.
> - Handle R_LARCH_ABS* for "old GCC with new Binutils".
> - Separate the last patch into more small patches.
> - Avoid BUG_ON() for the handling of GOT.
>
> Changes from v3 to v4:
>
> - No code change. Reword the commit message of the 3rd patch again
> based on suggestion from Huacai.
>
> Changes from v2 to v3:
>
> - Use `union loongarch_instruction` instead of explicit bit shifts
> applying the relocation. Suggested by Youling.
> - For R_LARCH_B26, move the alignment check before the range check to be
> consistent with stack pop relocations. Suggested by Youling.
> - Reword the commit message of the 3rd patch. Suggested by Huacai.
>
> Changes from v1 to v2:
>
> - Fix a stupid programming error (confusion between the number of PLT
> entries and the number of GOT entries). (Bug spotted by Youling).
> - Synthesize the _GLOBAL_OFFSET_TABLE_ symbol with module.lds, instead
> of faking it at runtime. The 3rd patch from V1 is now merged into
> the 1st patch because it would be a one-line change. (Suggested by
> Jinyang).
> - Keep reloc_rela_handlers[] ordered by the relocation type ID.
> (Suggested by Youling).
> - Remove -fplt along with -Wa,-mla-* options because it's the default.
> (Suggested by Youling).
>
> Xi Ruoyao (5):
> LoongArch: Add CONFIG_AS_HAS_EXPLICIT_RELOCS
> LoongArch: Adjust symbol addressing for CONFIG_AS_HAS_EXPLICIT_RELOCS
> LoongArch: Define ELF relocation types added in v2.00 ABI
> LoongArch: Support PC-relative relocations in modules
> LoongArch: Support R_LARCH_GOT_PC* in modules
>
> arch/loongarch/Kconfig | 3 +
> arch/loongarch/Makefile | 17 +++++
> arch/loongarch/include/asm/elf.h | 37 ++++++++++
> arch/loongarch/include/asm/module.h | 23 ++++++
> arch/loongarch/include/asm/module.lds.h | 1 +
> arch/loongarch/include/asm/percpu.h | 8 +++
> arch/loongarch/kernel/head.S | 10 +--
> arch/loongarch/kernel/module-sections.c | 56 +++++++++++++--
> arch/loongarch/kernel/module.c | 93 ++++++++++++++++++++++++-
> 9 files changed, 238 insertions(+), 10 deletions(-)
>
> --
> 2.37.0
>
On 8/30/22 21:05, Huacai Chen wrote: > Hi, Ruoyao, > > Thank you for your contribution, this whole series will be queued for > 6.1. Though lkp reported some warnings, I will fix them myself. And of course add my Tested-by: Tested-by: WANG Xuerui <git@xen0n.name> (I've run the v6 actually, but there is not substantial change from v6 to v7 so the status should stay good.) -- WANG "xen0n" Xuerui Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/
Hi, Ruoyao and Xuerui,
On Wed, Aug 31, 2022 at 12:38 AM WANG Xuerui <kernel@xen0n.name> wrote:
>
> On 8/30/22 21:05, Huacai Chen wrote:
> > Hi, Ruoyao,
> >
> > Thank you for your contribution, this whole series will be queued for
> > 6.1. Though lkp reported some warnings, I will fix them myself.
>
> And of course add my Tested-by:
>
> Tested-by: WANG Xuerui <git@xen0n.name>
>
> (I've run the v6 actually, but there is not substantial change from v6
> to v7 so the status should stay good.)
With this series applied and ARCH_WANT_LD_ORPHAN_WARN enabled, we get
loongarch64-unknown-linux-gnu-ld: warning: orphan section `.got' from
`arch/loongarch/kernel/head.o' being placed in section `.got'
loongarch64-unknown-linux-gnu-ld: warning: orphan section `.got.plt'
from `arch/loongarch/kernel/head.o' being placed in section `.got.plt'
I think we should add this lines in vmlinux.lds.S
.got : { *(.got) }
.got.plt : { *(.got.plt) }
But put them to which patch? Patch 2 or Patch 5?
Huacai
>
> --
> WANG "xen0n" Xuerui
>
> Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/
>
On Wed, 2022-08-31 at 13:44 +0800, Huacai Chen wrote:
> With this series applied and ARCH_WANT_LD_ORPHAN_WARN enabled, we get
> loongarch64-unknown-linux-gnu-ld: warning: orphan section `.got' from
> `arch/loongarch/kernel/head.o' being placed in section `.got'
> loongarch64-unknown-linux-gnu-ld: warning: orphan section `.got.plt'
> from `arch/loongarch/kernel/head.o' being placed in section `.got.plt'
>
> I think we should add this lines in vmlinux.lds.S
> .got : { *(.got) }
> .got.plt : { *(.got.plt) }
>
> But put them to which patch? Patch 2 or Patch 5?
In patch 2 IMO. Because in patch 2 we already know "-Wa,-mla-global-
with-pcrel" does not prevent the generation of GOT with new toolchain.
If you need a v8 please tell me to send it, but I don't know how to
handle -Woverride-init warnings (IMO the fix for this warning should be
a standalone patch outside of the series).
P. S. The ld warning message seems a little strange because "head.o"
does not contain .got or .got.plt sections... I guess there is a linker
bug causing it outputs the very first input file in the message, instead
of the first input file really containing an orphaned section.
Another P. S.: the use of GOT is actually unneeded in main kernel image
but we don't have something equivalent to "-Wa,-mla-global-with-pcrel"
in the new toolchain. Perhaps we can add this feature to GCC later.
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
On 08/31/2022 02:10 PM, Xi Ruoyao wrote:
> On Wed, 2022-08-31 at 13:44 +0800, Huacai Chen wrote:
>
>> With this series applied and ARCH_WANT_LD_ORPHAN_WARN enabled, we get
>> loongarch64-unknown-linux-gnu-ld: warning: orphan section `.got' from
>> `arch/loongarch/kernel/head.o' being placed in section `.got'
>> loongarch64-unknown-linux-gnu-ld: warning: orphan section `.got.plt'
>> from `arch/loongarch/kernel/head.o' being placed in section `.got.plt'
>>
>> I think we should add this lines in vmlinux.lds.S
>> .got : { *(.got) }
>> .got.plt : { *(.got.plt) }
>>
>> But put them to which patch? Patch 2 or Patch 5?
> In patch 2 IMO. Because in patch 2 we already know "-Wa,-mla-global-
> with-pcrel" does not prevent the generation of GOT with new toolchain.
>
> If you need a v8 please tell me to send it, but I don't know how to
> handle -Woverride-init warnings (IMO the fix for this warning should be
> a standalone patch outside of the series).
>
> P. S. The ld warning message seems a little strange because "head.o"
> does not contain .got or .got.plt sections... I guess there is a linker
> bug causing it outputs the very first input file in the message, instead
> of the first input file really containing an orphaned section.
>
> Another P. S.: the use of GOT is actually unneeded in main kernel image
> but we don't have something equivalent to "-Wa,-mla-global-with-pcrel"
> in the new toolchain. Perhaps we can add this feature to GCC later.
>
That's right. Also I am wondering why new toolchain produce .got* in
kernel. It's unneeded. In the past, gcc create la.global and parsed
to la.pcrel by gas, and kernel works well. Now it seems we lost this
feature in gcc. I checked the x86 asm code just now. And some info
follows,
LoongArch64, ./net/ipv4/udp_diag.s, *have reloc hint*
pcalau12i $r4,%got_pc_hi20(udplite_table)
ld.d $r4,$r4,%got_pc_lo12(udplite_table)
b udp_dump
x86_64, ./net/ipv4/udp_diag.s
movq $udplite_table, %rdi
jmp udp_dump
It seems related to -fno-PIE and -cmodel=kernel on x86_64.
Hope new gcc with this feature now.
On Wed, 2022-08-31 at 14:58 +0800, Jinyang He wrote: > That's right. Also I am wondering why new toolchain produce .got* in > kernel. It's unneeded. In the past, gcc create la.global and parsed > to la.pcrel by gas, and kernel works well. Now it seems we lost this > feature in gcc. I checked the x86 asm code just now. And some info > follows, > > LoongArch64, ./net/ipv4/udp_diag.s, *have reloc hint* > pcalau12i $r4,%got_pc_hi20(udplite_table) > ld.d $r4,$r4,%got_pc_lo12(udplite_table) > b udp_dump > > x86_64, ./net/ipv4/udp_diag.s > movq $udplite_table, %rdi > jmp udp_dump > > It seems related to -fno-PIE and -cmodel=kernel on x86_64. > Hope new gcc with this feature now. On x86_64 -mcmodel=kernel means "all code and data are located in [- 2GiB, 0) range. We actually don't strictly require a "high" range as we're mostly a PIC-friendly architecture: note that we use a pcalau12i/addi.d pair for PIC addressing in [PC-2GiB, PC+2GiB, and a lu12i.w/addi.d pair for "non-PIC" addressing in [-2GiB, 2GiB), both are 2-insn sequence. If we can put the main kernel image and the modules in one 2GiB VA range, we can avoid GOT completely. But it's not possible for now because main kernel image is loaded in XKPRANGE but the modules are in XKVRANGE. So the best we can achieve before implementing CONFIG_RELOCATION is using GOT in modules, and avoid GOT in the main kernel image (with a new code model in GCC, which will benefit both the kernel and statically linked executables). -- Xi Ruoyao <xry111@xry111.site> School of Aerospace Science and Technology, Xidian University
On Wed, Aug 31, 2022 at 4:09 PM Xi Ruoyao <xry111@xry111.site> wrote: > > On Wed, 2022-08-31 at 14:58 +0800, Jinyang He wrote: > > That's right. Also I am wondering why new toolchain produce .got* in > > kernel. It's unneeded. In the past, gcc create la.global and parsed > > to la.pcrel by gas, and kernel works well. Now it seems we lost this > > feature in gcc. I checked the x86 asm code just now. And some info > > follows, > > > > LoongArch64, ./net/ipv4/udp_diag.s, *have reloc hint* > > pcalau12i $r4,%got_pc_hi20(udplite_table) > > ld.d $r4,$r4,%got_pc_lo12(udplite_table) > > b udp_dump > > > > x86_64, ./net/ipv4/udp_diag.s > > movq $udplite_table, %rdi > > jmp udp_dump > > > > It seems related to -fno-PIE and -cmodel=kernel on x86_64. > > Hope new gcc with this feature now. > > On x86_64 -mcmodel=kernel means "all code and data are located in [- > 2GiB, 0) range. We actually don't strictly require a "high" range as > we're mostly a PIC-friendly architecture: note that we use a > pcalau12i/addi.d pair for PIC addressing in [PC-2GiB, PC+2GiB, and a > lu12i.w/addi.d pair for "non-PIC" addressing in [-2GiB, 2GiB), both are > 2-insn sequence. > > If we can put the main kernel image and the modules in one 2GiB VA > range, we can avoid GOT completely. But it's not possible for now > because main kernel image is loaded in XKPRANGE but the modules are in > XKVRANGE. So the best we can achieve before implementing > CONFIG_RELOCATION is using GOT in modules, and avoid GOT in the main > kernel image (with a new code model in GCC, which will benefit both the > kernel and statically linked executables). Emmm, can you implement this new code model in the near future? Huacai > > -- > Xi Ruoyao <xry111@xry111.site> > School of Aerospace Science and Technology, Xidian University >
On Wed, 2022-08-31 at 22:40 +0800, Huacai Chen wrote: > On Wed, Aug 31, 2022 at 4:09 PM Xi Ruoyao <xry111@xry111.site> wrote: > > > > On Wed, 2022-08-31 at 14:58 +0800, Jinyang He wrote: > > > That's right. Also I am wondering why new toolchain produce .got* in > > > kernel. It's unneeded. In the past, gcc create la.global and parsed > > > to la.pcrel by gas, and kernel works well. Now it seems we lost this > > > feature in gcc. I checked the x86 asm code just now. And some info > > > follows, > > > > > > LoongArch64, ./net/ipv4/udp_diag.s, *have reloc hint* > > > pcalau12i $r4,%got_pc_hi20(udplite_table) > > > ld.d $r4,$r4,%got_pc_lo12(udplite_table) > > > b udp_dump > > > > > > x86_64, ./net/ipv4/udp_diag.s > > > movq $udplite_table, %rdi > > > jmp udp_dump > > > > > > It seems related to -fno-PIE and -cmodel=kernel on x86_64. > > > Hope new gcc with this feature now. > > > > On x86_64 -mcmodel=kernel means "all code and data are located in [- > > 2GiB, 0) range. We actually don't strictly require a "high" range as > > we're mostly a PIC-friendly architecture: note that we use a > > pcalau12i/addi.d pair for PIC addressing in [PC-2GiB, PC+2GiB, and a > > lu12i.w/addi.d pair for "non-PIC" addressing in [-2GiB, 2GiB), both are > > 2-insn sequence. > > > > If we can put the main kernel image and the modules in one 2GiB VA > > range, we can avoid GOT completely. But it's not possible for now > > because main kernel image is loaded in XKPRANGE but the modules are in > > XKVRANGE. So the best we can achieve before implementing > > CONFIG_RELOCATION is using GOT in modules, and avoid GOT in the main > > kernel image (with a new code model in GCC, which will benefit both the > > kernel and statically linked executables). > Emmm, can you implement this new code model in the near future? I have a plan to make our toolchain addressing the symbols better: (1) https://sourceware.org/pipermail/binutils/2022-August/122682.html. This change will allow the linker to link a main executable image (dynamically linked or statically linked, PIE or non-PIE, kernel or userspace) with R_LARCH_COPY instead of GOT. (Note that R_LARCH_COPY will not show up in the kernel because we don't link to shared objects, but GOT will be gone.) (2) Change GCC to stop using GOT unless -fPIC. (Technically it's a one- line change.) (3) In kernel, for main kernel image the default of toolchain will be good enough (no GOT). For modules we have two options: (a) get rid of XKPRANGE. (b) force -mcmodel=extreme globally. (c) use -Wl,nocopyreloc to produce GOT. (a) is the best, the performance of (b) and (c) will be worse than (a). I'm not sure which one in (b) and (c) is better, but as (a) will be the final solution we can just choose one in (b) and (c) "randomly" for now. I don't want to add a new code model now, because if (1) works fine we'll not need a new code model. (1) is also the most tricky step in the plan (I've sent the patch but not sure if it's completely correct), (2) and (3) should be trivial. -- Xi Ruoyao <xry111@xry111.site> School of Aerospace Science and Technology, Xidian University
Hi, Ruoyao, On Wed, Aug 31, 2022 at 11:15 PM Xi Ruoyao <xry111@xry111.site> wrote: > > On Wed, 2022-08-31 at 22:40 +0800, Huacai Chen wrote: > > On Wed, Aug 31, 2022 at 4:09 PM Xi Ruoyao <xry111@xry111.site> wrote: > > > > > > On Wed, 2022-08-31 at 14:58 +0800, Jinyang He wrote: > > > > That's right. Also I am wondering why new toolchain produce .got* in > > > > kernel. It's unneeded. In the past, gcc create la.global and parsed > > > > to la.pcrel by gas, and kernel works well. Now it seems we lost this > > > > feature in gcc. I checked the x86 asm code just now. And some info > > > > follows, > > > > > > > > LoongArch64, ./net/ipv4/udp_diag.s, *have reloc hint* > > > > pcalau12i $r4,%got_pc_hi20(udplite_table) > > > > ld.d $r4,$r4,%got_pc_lo12(udplite_table) > > > > b udp_dump > > > > > > > > x86_64, ./net/ipv4/udp_diag.s > > > > movq $udplite_table, %rdi > > > > jmp udp_dump > > > > > > > > It seems related to -fno-PIE and -cmodel=kernel on x86_64. > > > > Hope new gcc with this feature now. > > > > > > On x86_64 -mcmodel=kernel means "all code and data are located in [- > > > 2GiB, 0) range. We actually don't strictly require a "high" range as > > > we're mostly a PIC-friendly architecture: note that we use a > > > pcalau12i/addi.d pair for PIC addressing in [PC-2GiB, PC+2GiB, and a > > > lu12i.w/addi.d pair for "non-PIC" addressing in [-2GiB, 2GiB), both are > > > 2-insn sequence. > > > > > > If we can put the main kernel image and the modules in one 2GiB VA > > > range, we can avoid GOT completely. But it's not possible for now > > > because main kernel image is loaded in XKPRANGE but the modules are in > > > XKVRANGE. So the best we can achieve before implementing > > > CONFIG_RELOCATION is using GOT in modules, and avoid GOT in the main > > > kernel image (with a new code model in GCC, which will benefit both the > > > kernel and statically linked executables). > > > Emmm, can you implement this new code model in the near future? > > I have a plan to make our toolchain addressing the symbols better: > > (1) https://sourceware.org/pipermail/binutils/2022-August/122682.html. > This change will allow the linker to link a main executable image > (dynamically linked or statically linked, PIE or non-PIE, kernel or > userspace) with R_LARCH_COPY instead of GOT. (Note that R_LARCH_COPY > will not show up in the kernel because we don't link to shared objects, > but GOT will be gone.) > > (2) Change GCC to stop using GOT unless -fPIC. (Technically it's a one- > line change.) > > (3) In kernel, for main kernel image the default of toolchain will be > good enough (no GOT). For modules we have two options: > > (a) get rid of XKPRANGE. > (b) force -mcmodel=extreme globally. > (c) use -Wl,nocopyreloc to produce GOT. > > (a) is the best, the performance of (b) and (c) will be worse than (a). > I'm not sure which one in (b) and (c) is better, but as (a) will be the > final solution we can just choose one in (b) and (c) "randomly" for now. > > I don't want to add a new code model now, because if (1) works fine > we'll not need a new code model. (1) is also the most tricky step in > the plan (I've sent the patch but not sure if it's completely correct), > (2) and (3) should be trivial. Now all global variable accesses are via got, I think the performance may be much worse than before when we didn't use explicit-relocs. I don't know whether "a new code model" or your "(1)(2)(3)" is easier to implement, but I think it is better to solve the performance issue before 6.1-rc1. Huacai > -- > Xi Ruoyao <xry111@xry111.site> > School of Aerospace Science and Technology, Xidian University >
On Thu, 2022-09-01 at 10:17 +0800, Huacai Chen wrote:
> Now all global variable accesses are via got, I think the performance
> may be much worse than before when we didn't use explicit-relocs.
> I don't know whether "a new code model" or your "(1)(2)(3)" is easier
> to implement, but I think it is better to solve the performance issue
> before 6.1-rc1.
Hi Huacai,
We've added a GCC option for this at https://gcc.gnu.org/r13-2433. On
the kernel side we need a one-line change:
diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
index 92c4a52c4c3e..69b39ba3a09d 100644
--- a/arch/loongarch/Makefile
+++ b/arch/loongarch/Makefile
@@ -54,6 +54,7 @@ LDFLAGS_vmlinux += -G0 -static -n -nostdlib
# upgrade the compiler or downgrade the assembler.
ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS
cflags-y += -mexplicit-relocs
+KBUILD_CFLAGS_KERNEL += -mdirect-extern-access
else
cflags-y += $(call cc-option,-mno-explicit-relocs)
KBUILD_AFLAGS_KERNEL += -Wa,-mla-global-with-pcrel
And we also need a one-line change in the EFI stub patch (under review):
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index 8931ed24379e..8c1225b92492 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -27,7 +27,7 @@ cflags-$(CONFIG_ARM) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
cflags-$(CONFIG_RISCV) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
-fpic
cflags-$(CONFIG_LOONGARCH) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
- -fpic
+ -fpie
cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt
(Some explanation: -fpic does not only mean "generate position-
independent code", but "generate position-independent code *suitable for
use in a shared library*". On LoongArch -mdirect-extern-access cannot
work for a shared library so the "-fpic -mdirect-extern-access"
combination is rejected deliberately.)
Not sure how to submit these changes properly... Do you prefer me to
send V8 of this series or a single patch on top of your tree on GitHub?
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
Hi, Ruoyao, On Tue, Sep 6, 2022 at 8:32 AM Xi Ruoyao <xry111@xry111.site> wrote: > > On Thu, 2022-09-01 at 10:17 +0800, Huacai Chen wrote: > > > Now all global variable accesses are via got, I think the performance > > may be much worse than before when we didn't use explicit-relocs. > > I don't know whether "a new code model" or your "(1)(2)(3)" is easier > > to implement, but I think it is better to solve the performance issue > > before 6.1-rc1. > > Hi Huacai, > > We've added a GCC option for this at https://gcc.gnu.org/r13-2433. On > the kernel side we need a one-line change: > > diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile > index 92c4a52c4c3e..69b39ba3a09d 100644 > --- a/arch/loongarch/Makefile > +++ b/arch/loongarch/Makefile > @@ -54,6 +54,7 @@ LDFLAGS_vmlinux += -G0 -static -n -nostdlib > # upgrade the compiler or downgrade the assembler. > ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS > cflags-y += -mexplicit-relocs > +KBUILD_CFLAGS_KERNEL += -mdirect-extern-access > else > cflags-y += $(call cc-option,-mno-explicit-relocs) > KBUILD_AFLAGS_KERNEL += -Wa,-mla-global-with-pcrel > > And we also need a one-line change in the EFI stub patch (under review): > > diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile > index 8931ed24379e..8c1225b92492 100644 > --- a/drivers/firmware/efi/libstub/Makefile > +++ b/drivers/firmware/efi/libstub/Makefile > @@ -27,7 +27,7 @@ cflags-$(CONFIG_ARM) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ > cflags-$(CONFIG_RISCV) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ > -fpic > cflags-$(CONFIG_LOONGARCH) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ > - -fpic > + -fpie > > cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt > > (Some explanation: -fpic does not only mean "generate position- > independent code", but "generate position-independent code *suitable for > use in a shared library*". On LoongArch -mdirect-extern-access cannot > work for a shared library so the "-fpic -mdirect-extern-access" > combination is rejected deliberately.) > > Not sure how to submit these changes properly... Do you prefer me to > send V8 of this series or a single patch on top of your tree on GitHub? Don't need V8, I will squash it into the previous patch myself. But can we keep efistub as is? Huacai > > -- > Xi Ruoyao <xry111@xry111.site> > School of Aerospace Science and Technology, Xidian University >
On Tue, 2022-09-06 at 09:52 +0800, Huacai Chen wrote: > > cflags-$(CONFIG_LOONGARCH) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ > > - -fpic > > + -fpie > > > > cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt > > > > (Some explanation: -fpic does not only mean "generate position- > > independent code", but "generate position-independent code *suitable for > > use in a shared library*". On LoongArch -mdirect-extern-access cannot > > work for a shared library so the "-fpic -mdirect-extern-access" > > combination is rejected deliberately.) > > > > Not sure how to submit these changes properly... Do you prefer me to > > send V8 of this series or a single patch on top of your tree on GitHub? > Don't need V8, I will squash it into the previous patch myself. But > can we keep efistub as is? No, we can't allow -mdirect-extern-access -fpic on LoongArch because without copy relocation such a combination just does not make sense (i. e. we cannot find a sensible way to handle such a combination in GCC). So such a combination will cause GCC refuse to run. Note that -fpic/-fPIC is "position-independent code *suitable for use in a shared library*", while -fpie/-fPIE is more like just "position-independent code". The names of those options are confusing. (When -fpic was invented first time, people mostly believed "PIC had been only for shared libraries", so it's named -fpic instead of -shlib or something.) IMO in the EFI stub for other ports, -fpie should be used instead of -fpic as well because the EFI stub is not similar to a shared library in any means. -- Xi Ruoyao <xry111@xry111.site> School of Aerospace Science and Technology, Xidian University
Hi, Ruoyao, On Tue, Sep 6, 2022 at 12:27 PM Xi Ruoyao <xry111@xry111.site> wrote: > > On Tue, 2022-09-06 at 09:52 +0800, Huacai Chen wrote: > > > cflags-$(CONFIG_LOONGARCH) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ > > > - -fpic > > > + -fpie > > > > > > cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt > > > > > > (Some explanation: -fpic does not only mean "generate position- > > > independent code", but "generate position-independent code *suitable for > > > use in a shared library*". On LoongArch -mdirect-extern-access cannot > > > work for a shared library so the "-fpic -mdirect-extern-access" > > > combination is rejected deliberately.) > > > > > > Not sure how to submit these changes properly... Do you prefer me to > > > send V8 of this series or a single patch on top of your tree on GitHub? > > > Don't need V8, I will squash it into the previous patch myself. But > > can we keep efistub as is? > > No, we can't allow -mdirect-extern-access -fpic on LoongArch because > without copy relocation such a combination just does not make sense (i. > e. we cannot find a sensible way to handle such a combination in GCC). > So such a combination will cause GCC refuse to run. > > Note that -fpic/-fPIC is "position-independent code *suitable for > use in a shared library*", while -fpie/-fPIE is more like just > "position-independent code". The names of those options are confusing. > (When -fpic was invented first time, people mostly believed "PIC had > been only for shared libraries", so it's named -fpic instead of -shlib > or something.) IMO in the EFI stub for other ports, -fpie should be > used instead of -fpic as well because the EFI stub is not similar to a > shared library in any means. You are right, but I guess that Ard doesn't want to squash the efistub change into the LoongArch efistub support patch. :) Huacai > > -- > Xi Ruoyao <xry111@xry111.site> > School of Aerospace Science and Technology, Xidian University >
On Tue, 6 Sept 2022 at 06:43, Huacai Chen <chenhuacai@kernel.org> wrote: > > Hi, Ruoyao, > > On Tue, Sep 6, 2022 at 12:27 PM Xi Ruoyao <xry111@xry111.site> wrote: > > > > On Tue, 2022-09-06 at 09:52 +0800, Huacai Chen wrote: > > > > cflags-$(CONFIG_LOONGARCH) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ > > > > - -fpic > > > > + -fpie > > > > > > > > cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt > > > > > > > > (Some explanation: -fpic does not only mean "generate position- > > > > independent code", but "generate position-independent code *suitable for > > > > use in a shared library*". On LoongArch -mdirect-extern-access cannot > > > > work for a shared library so the "-fpic -mdirect-extern-access" > > > > combination is rejected deliberately.) > > > > > > > > Not sure how to submit these changes properly... Do you prefer me to > > > > send V8 of this series or a single patch on top of your tree on GitHub? > > > > > Don't need V8, I will squash it into the previous patch myself. But > > > can we keep efistub as is? > > > > No, we can't allow -mdirect-extern-access -fpic on LoongArch because > > without copy relocation such a combination just does not make sense (i. > > e. we cannot find a sensible way to handle such a combination in GCC). > > So such a combination will cause GCC refuse to run. > > > > Note that -fpic/-fPIC is "position-independent code *suitable for > > use in a shared library*", while -fpie/-fPIE is more like just > > "position-independent code". The names of those options are confusing. > > (When -fpic was invented first time, people mostly believed "PIC had > > been only for shared libraries", so it's named -fpic instead of -shlib > > or something.) IMO in the EFI stub for other ports, -fpie should be > > used instead of -fpic as well because the EFI stub is not similar to a > > shared library in any means. > You are right, but I guess that Ard doesn't want to squash the efistub > change into the LoongArch efistub support patch. :) > I don't mind changing the stable tag at this point - I don't have anything queued up on top of it at the moment. But I don't see the actual patch: please send me the delta patch that you want to apply, and I will update it. Then, you can rebase your v6.1 tree on top of it.
On Tue, Sep 6, 2022 at 3:18 PM Ard Biesheuvel <ardb@kernel.org> wrote: > > On Tue, 6 Sept 2022 at 06:43, Huacai Chen <chenhuacai@kernel.org> wrote: > > > > Hi, Ruoyao, > > > > On Tue, Sep 6, 2022 at 12:27 PM Xi Ruoyao <xry111@xry111.site> wrote: > > > > > > On Tue, 2022-09-06 at 09:52 +0800, Huacai Chen wrote: > > > > > cflags-$(CONFIG_LOONGARCH) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ > > > > > - -fpic > > > > > + -fpie > > > > > > > > > > cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt > > > > > > > > > > (Some explanation: -fpic does not only mean "generate position- > > > > > independent code", but "generate position-independent code *suitable for > > > > > use in a shared library*". On LoongArch -mdirect-extern-access cannot > > > > > work for a shared library so the "-fpic -mdirect-extern-access" > > > > > combination is rejected deliberately.) > > > > > > > > > > Not sure how to submit these changes properly... Do you prefer me to > > > > > send V8 of this series or a single patch on top of your tree on GitHub? > > > > > > > Don't need V8, I will squash it into the previous patch myself. But > > > > can we keep efistub as is? > > > > > > No, we can't allow -mdirect-extern-access -fpic on LoongArch because > > > without copy relocation such a combination just does not make sense (i. > > > e. we cannot find a sensible way to handle such a combination in GCC). > > > So such a combination will cause GCC refuse to run. > > > > > > Note that -fpic/-fPIC is "position-independent code *suitable for > > > use in a shared library*", while -fpie/-fPIE is more like just > > > "position-independent code". The names of those options are confusing. > > > (When -fpic was invented first time, people mostly believed "PIC had > > > been only for shared libraries", so it's named -fpic instead of -shlib > > > or something.) IMO in the EFI stub for other ports, -fpie should be > > > used instead of -fpic as well because the EFI stub is not similar to a > > > shared library in any means. > > You are right, but I guess that Ard doesn't want to squash the efistub > > change into the LoongArch efistub support patch. :) > > > > I don't mind changing the stable tag at this point - I don't have > anything queued up on top of it at the moment. > > But I don't see the actual patch: please send me the delta patch that > you want to apply, and I will update it. Then, you can rebase your > v6.1 tree on top of it. OK, Ruoyao, please send a patch to change the efistub cflags. Thank you. Huacai
On Tue, Sep 6, 2022 at 4:20 PM Huacai Chen <chenhuacai@kernel.org> wrote:
>
> On Tue, Sep 6, 2022 at 3:18 PM Ard Biesheuvel <ardb@kernel.org> wrote:
> >
> > On Tue, 6 Sept 2022 at 06:43, Huacai Chen <chenhuacai@kernel.org> wrote:
> > >
> > > Hi, Ruoyao,
> > >
> > > On Tue, Sep 6, 2022 at 12:27 PM Xi Ruoyao <xry111@xry111.site> wrote:
> > > >
> > > > On Tue, 2022-09-06 at 09:52 +0800, Huacai Chen wrote:
> > > > > > cflags-$(CONFIG_LOONGARCH) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
> > > > > > - -fpic
> > > > > > + -fpie
> > > > > >
> > > > > > cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt
> > > > > >
> > > > > > (Some explanation: -fpic does not only mean "generate position-
> > > > > > independent code", but "generate position-independent code *suitable for
> > > > > > use in a shared library*". On LoongArch -mdirect-extern-access cannot
> > > > > > work for a shared library so the "-fpic -mdirect-extern-access"
> > > > > > combination is rejected deliberately.)
> > > > > >
> > > > > > Not sure how to submit these changes properly... Do you prefer me to
> > > > > > send V8 of this series or a single patch on top of your tree on GitHub?
> > > >
> > > > > Don't need V8, I will squash it into the previous patch myself. But
> > > > > can we keep efistub as is?
> > > >
> > > > No, we can't allow -mdirect-extern-access -fpic on LoongArch because
> > > > without copy relocation such a combination just does not make sense (i.
> > > > e. we cannot find a sensible way to handle such a combination in GCC).
> > > > So such a combination will cause GCC refuse to run.
> > > >
> > > > Note that -fpic/-fPIC is "position-independent code *suitable for
> > > > use in a shared library*", while -fpie/-fPIE is more like just
> > > > "position-independent code". The names of those options are confusing.
> > > > (When -fpic was invented first time, people mostly believed "PIC had
> > > > been only for shared libraries", so it's named -fpic instead of -shlib
> > > > or something.) IMO in the EFI stub for other ports, -fpie should be
> > > > used instead of -fpic as well because the EFI stub is not similar to a
> > > > shared library in any means.
> > > You are right, but I guess that Ard doesn't want to squash the efistub
> > > change into the LoongArch efistub support patch. :)
> > >
> >
> > I don't mind changing the stable tag at this point - I don't have
> > anything queued up on top of it at the moment.
> >
> > But I don't see the actual patch: please send me the delta patch that
> > you want to apply, and I will update it. Then, you can rebase your
> > v6.1 tree on top of it.
> OK, Ruoyao, please send a patch to change the efistub cflags. Thank you.
Oh, I think you needn't send, just showing the diff to Ard is OK. :)
diff --git a/drivers/firmware/efi/libstub/Makefile
b/drivers/firmware/efi/libstub/Makefile
index 8931ed24379e..8c1225b92492 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -27,7 +27,7 @@ cflags-$(CONFIG_ARM) := $(subst
$(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
cflags-$(CONFIG_RISCV) := $(subst
$(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
-fpic
cflags-$(CONFIG_LOONGARCH) := $(subst
$(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
- -fpic
+ -fpie
cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt
Huacai
>
> Huacai
On Tue, 6 Sept 2022 at 10:59, Huacai Chen <chenhuacai@kernel.org> wrote: > > On Tue, Sep 6, 2022 at 4:20 PM Huacai Chen <chenhuacai@kernel.org> wrote: > > > > On Tue, Sep 6, 2022 at 3:18 PM Ard Biesheuvel <ardb@kernel.org> wrote: > > > > > > On Tue, 6 Sept 2022 at 06:43, Huacai Chen <chenhuacai@kernel.org> wrote: > > > > > > > > Hi, Ruoyao, > > > > > > > > On Tue, Sep 6, 2022 at 12:27 PM Xi Ruoyao <xry111@xry111.site> wrote: > > > > > > > > > > On Tue, 2022-09-06 at 09:52 +0800, Huacai Chen wrote: > > > > > > > cflags-$(CONFIG_LOONGARCH) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ > > > > > > > - -fpic > > > > > > > + -fpie > > > > > > > > > > > > > > cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt > > > > > > > > > > > > > > (Some explanation: -fpic does not only mean "generate position- > > > > > > > independent code", but "generate position-independent code *suitable for > > > > > > > use in a shared library*". On LoongArch -mdirect-extern-access cannot > > > > > > > work for a shared library so the "-fpic -mdirect-extern-access" > > > > > > > combination is rejected deliberately.) > > > > > > > > > > > > > > Not sure how to submit these changes properly... Do you prefer me to > > > > > > > send V8 of this series or a single patch on top of your tree on GitHub? > > > > > > > > > > > Don't need V8, I will squash it into the previous patch myself. But > > > > > > can we keep efistub as is? > > > > > > > > > > No, we can't allow -mdirect-extern-access -fpic on LoongArch because > > > > > without copy relocation such a combination just does not make sense (i. > > > > > e. we cannot find a sensible way to handle such a combination in GCC). > > > > > So such a combination will cause GCC refuse to run. > > > > > > > > > > Note that -fpic/-fPIC is "position-independent code *suitable for > > > > > use in a shared library*", while -fpie/-fPIE is more like just > > > > > "position-independent code". The names of those options are confusing. > > > > > (When -fpic was invented first time, people mostly believed "PIC had > > > > > been only for shared libraries", so it's named -fpic instead of -shlib > > > > > or something.) IMO in the EFI stub for other ports, -fpie should be > > > > > used instead of -fpic as well because the EFI stub is not similar to a > > > > > shared library in any means. > > > > You are right, but I guess that Ard doesn't want to squash the efistub > > > > change into the LoongArch efistub support patch. :) > > > > > > > > > > I don't mind changing the stable tag at this point - I don't have > > > anything queued up on top of it at the moment. > > > > > > But I don't see the actual patch: please send me the delta patch that > > > you want to apply, and I will update it. Then, you can rebase your > > > v6.1 tree on top of it. > > OK, Ruoyao, please send a patch to change the efistub cflags. Thank you. > Oh, I think you needn't send, just showing the diff to Ard is OK. :) > > diff --git a/drivers/firmware/efi/libstub/Makefile > b/drivers/firmware/efi/libstub/Makefile > index 8931ed24379e..8c1225b92492 100644 > --- a/drivers/firmware/efi/libstub/Makefile > +++ b/drivers/firmware/efi/libstub/Makefile > @@ -27,7 +27,7 @@ cflags-$(CONFIG_ARM) := $(subst > $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ > cflags-$(CONFIG_RISCV) := $(subst > $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ > -fpic > cflags-$(CONFIG_LOONGARCH) := $(subst > $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ > - -fpic > + -fpie > > cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt > I have merged this into the patch, and updated the tag efi-loongarch-for-v6.1 ead384d956345681e1ddf97890d5e15ded015f07 It should be in linux-next tomorrow, you can merge the tag now from git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git
On Tue, 2022-09-06 at 12:43 +0800, Huacai Chen wrote: > > Note that -fpic/-fPIC is "position-independent code *suitable for > > use in a shared library*", while -fpie/-fPIE is more like just > > "position-independent code". The names of those options are confusing. > > (When -fpic was invented first time, people mostly believed "PIC had > > been only for shared libraries", so it's named -fpic instead of -shlib > > or something.) IMO in the EFI stub for other ports, -fpie should be > > used instead of -fpic as well because the EFI stub is not similar to a > > shared library in any means. > You are right, but I guess that Ard doesn't want to squash the efistub > change into the LoongArch efistub support patch. :) It only changes cflags-$(CONFIG_LOONGARCH), which is LoongArch specific. And arm64 is also using -fpie. Should I send the one-line EFI stub change to linux-efi first? -- Xi Ruoyao <xry111@xry111.site> School of Aerospace Science and Technology, Xidian University
Hi, Ruoyao, On Tue, Sep 6, 2022 at 1:01 PM Xi Ruoyao <xry111@xry111.site> wrote: > > On Tue, 2022-09-06 at 12:43 +0800, Huacai Chen wrote: > > > Note that -fpic/-fPIC is "position-independent code *suitable for > > > use in a shared library*", while -fpie/-fPIE is more like just > > > "position-independent code". The names of those options are confusing. > > > (When -fpic was invented first time, people mostly believed "PIC had > > > been only for shared libraries", so it's named -fpic instead of -shlib > > > or something.) IMO in the EFI stub for other ports, -fpie should be > > > used instead of -fpic as well because the EFI stub is not similar to a > > > shared library in any means. > > > You are right, but I guess that Ard doesn't want to squash the efistub > > change into the LoongArch efistub support patch. :) > > It only changes cflags-$(CONFIG_LOONGARCH), which is LoongArch specific. > And arm64 is also using -fpie. > > Should I send the one-line EFI stub change to linux-efi first? I know that should be changed. I just don't like the one-line patch and hope it can be squashed to the original patch. Of course Ard is free to decide how to handle it. Huacai > > -- > Xi Ruoyao <xry111@xry111.site> > School of Aerospace Science and Technology, Xidian University
On Thu, 2022-09-01 at 10:17 +0800, Huacai Chen wrote: > Now all global variable accesses are via got, I think the performance > may be much worse than before when we didn't use explicit-relocs. > I don't know whether "a new code model" or your "(1)(2)(3)" is easier > to implement, but I think it is better to solve the performance issue > before 6.1-rc1. Both won't be too difficult, but I need to debate with toolchain developers :(. If we are running out of time: cflags-y += $(cc-option -mno-explicit-relocs) This will at least make the new toolchain work, though we cannot be benefited from the optimizations allowed by explicit relocations. -- Xi Ruoyao <xry111@xry111.site> School of Aerospace Science and Technology, Xidian University
On Tue, 2022-08-30 at 21:05 +0800, Huacai Chen wrote: > Hi, Ruoyao, > > Thank you for your contribution, this whole series will be queued for > 6.1. Though lkp reported some warnings, I will fix them myself. Hmm, we are using -Wimplicit-fallthrough=5 so "fallthrough;" (which expands into some magic) should be used instead of "/* fallthrough */". For -Woverride-init I'm not sure how to fix it properly. -- Xi Ruoyao <xry111@xry111.site> School of Aerospace Science and Technology, Xidian University
© 2016 - 2026 Red Hat, Inc.