linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] efi/libstub/arm64: link stub lib.a conditionally
@ 2020-06-04  2:20 Masahiro Yamada
  2020-06-04  2:20 ` [PATCH v2 2/2] efi/libstub: refactor Makefile to not use lib-y syntax Masahiro Yamada
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Masahiro Yamada @ 2020-06-04  2:20 UTC (permalink / raw)
  To: Ard Biesheuvel, linux-efi
  Cc: Masahiro Yamada, Catalin Marinas, Will Deacon, linux-arm-kernel,
	linux-kernel

Since commit 799c43415442 ("kbuild: thin archives make default for
all archs"), core-y is passed to the linker with --whole-archive.
Hence, the whole of stub library is linked to vmlinux.

Use libs-y so that lib.a is passed after --no-whole-archive for
conditional linking.

The unused drivers/firmware/efi/libstub/relocate.o will be dropped
for ARCH=arm64.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

This patch touches under arch/arm64/, but
this is more related to efi.
I am sending this to Ard.

 arch/arm64/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 650e1185c190..48a6afa774fc 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -145,7 +145,7 @@ export	TEXT_OFFSET
 
 core-y		+= arch/arm64/
 libs-y		:= arch/arm64/lib/ $(libs-y)
-core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
+libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
 
 # Default target when executing plain make
 boot		:= arch/arm64/boot
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/2] efi/libstub: refactor Makefile to not use lib-y syntax
  2020-06-04  2:20 [PATCH v2 1/2] efi/libstub/arm64: link stub lib.a conditionally Masahiro Yamada
@ 2020-06-04  2:20 ` Masahiro Yamada
  2020-06-15 10:26   ` Ard Biesheuvel
  2020-06-10  7:58 ` [PATCH v2 1/2] efi/libstub/arm64: link stub lib.a conditionally Will Deacon
  2020-07-22 22:48 ` [tip: efi/urgent] " tip-bot2 for Masahiro Yamada
  2 siblings, 1 reply; 10+ messages in thread
From: Masahiro Yamada @ 2020-06-04  2:20 UTC (permalink / raw)
  To: Ard Biesheuvel, linux-efi
  Cc: Masahiro Yamada, Arvind Sankar, Atish Patra, Ingo Molnar,
	Kees Cook, linux-kernel

Documentation/kbuild/makefiles.rst says:

  Use of lib-y is normally restricted to `lib/` and `arch/*/lib`.

This is because lib-y is inteded to be hooked to KBUILD_VMLINUX_LIBS,
which is passed down to scripts/link-vmlinux.sh.

Besides, lib-y is not so interesting because objects from lib-y are
mostly linked in normal usecases. For example, lib-y only saves 364
bytes for x86_64_defconfig. You can see the details in commit
7273ad2b08f8 ("kbuild: link lib-y objects to vmlinux forcibly when
CONFIG_MODULES=y").

I think we should consider to deprecate lib-y syntax at some point
because we should aim for better solution like dead code elimination
or LTO.

Other than lib/ and arch/*/lib, this Makefile is the only user of
lib-y. Replace lib-y with a custom rule.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

Changes in v2:
  - Add more description

 drivers/firmware/efi/libstub/Makefile | 49 +++++++++++++++------------
 1 file changed, 27 insertions(+), 22 deletions(-)

diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index cce4a7436052..7d81dc45cadf 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -44,7 +44,7 @@ OBJECT_FILES_NON_STANDARD	:= y
 # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
 KCOV_INSTRUMENT			:= n
 
-lib-y				:= efi-stub-helper.o gop.o secureboot.o tpm.o \
+stub-obj-y			:= efi-stub-helper.o gop.o secureboot.o tpm.o \
 				   file.o mem.o random.o randomalloc.o pci.o \
 				   skip_spaces.o lib-cmdline.o lib-ctype.o \
 				   alignedmem.o relocate.o vsprintf.o
@@ -55,15 +55,19 @@ efi-deps-y := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c fdt_empty_tree.c fdt_sw.c
 $(obj)/lib-%.o: $(srctree)/lib/%.c FORCE
 	$(call if_changed_rule,cc_o_c)
 
-lib-$(CONFIG_EFI_GENERIC_STUB)	+= efi-stub.o fdt.o string.o \
+stub-obj-$(CONFIG_EFI_GENERIC_STUB)	+= efi-stub.o fdt.o string.o \
 				   $(patsubst %.c,lib-%.o,$(efi-deps-y))
 
-lib-$(CONFIG_ARM)		+= arm32-stub.o
-lib-$(CONFIG_ARM64)		+= arm64-stub.o
-lib-$(CONFIG_X86)		+= x86-stub.o
+stub-obj-$(CONFIG_ARM)		+= arm32-stub.o
+stub-obj-$(CONFIG_ARM64)	+= arm64-stub.o
+stub-obj-$(CONFIG_X86)		+= x86-stub.o
 CFLAGS_arm32-stub.o		:= -DTEXT_OFFSET=$(TEXT_OFFSET)
 CFLAGS_arm64-stub.o		:= -DTEXT_OFFSET=$(TEXT_OFFSET)
 
+targets				+= $(stub-obj-y)
+stub-obj-y			:= $(patsubst %.o,%.stub.o, $(stub-obj-y))
+targets				+= $(stub-obj-y)
+
 #
 # For x86, bootloaders like systemd-boot or grub-efi do not zero-initialize the
 # .bss section, so the .bss section of the EFI stub needs to be included in the
@@ -83,23 +87,6 @@ STUBCOPY_FLAGS-$(CONFIG_ARM)	+= --rename-section .data=.data.efistub	\
 				   --rename-section .bss=.bss.efistub,load,alloc
 STUBCOPY_RELOC-$(CONFIG_ARM)	:= R_ARM_ABS
 
-#
-# arm64 puts the stub in the kernel proper, which will unnecessarily retain all
-# code indefinitely unless it is annotated as __init/__initdata/__initconst etc.
-# So let's apply the __init annotations at the section level, by prefixing
-# the section names directly. This will ensure that even all the inline string
-# literals are covered.
-# The fact that the stub and the kernel proper are essentially the same binary
-# also means that we need to be extra careful to make sure that the stub does
-# not rely on any absolute symbol references, considering that the virtual
-# kernel mapping that the linker uses is not active yet when the stub is
-# executing. So build all C dependencies of the EFI stub into libstub, and do
-# a verification pass to see if any absolute relocations exist in any of the
-# object files.
-#
-extra-y				:= $(lib-y)
-lib-y				:= $(patsubst %.o,%.stub.o,$(lib-y))
-
 STUBCOPY_FLAGS-$(CONFIG_ARM64)	+= --prefix-alloc-sections=.init \
 				   --prefix-symbols=__efistub_
 STUBCOPY_RELOC-$(CONFIG_ARM64)	:= R_AARCH64_ABS
@@ -121,3 +108,21 @@ quiet_cmd_stubcopy = STUBCPY $@
 		/bin/false;						\
 	fi;								\
 	$(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@
+
+# arm64 puts the stub in the kernel proper, which will unnecessarily retain all
+# code indefinitely unless it is annotated as __init/__initdata/__initconst etc.
+# So let's apply the __init annotations at the section level, by prefixing
+# the section names directly. This will ensure that even all the inline string
+# literals are covered.
+# The fact that the stub and the kernel proper are essentially the same binary
+# also means that we need to be extra careful to make sure that the stub does
+# not rely on any absolute symbol references, considering that the virtual
+# kernel mapping that the linker uses is not active yet when the stub is
+# executing. So build all C dependencies of the EFI stub into libstub, and do
+# a verification pass to see if any absolute relocations exist in any of the
+# object files.
+#
+extra-y += lib.a
+
+$(obj)/lib.a: $(addprefix $(obj)/, $(stub-obj-y)) FORCE
+	$(call if_changed,ar)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] efi/libstub/arm64: link stub lib.a conditionally
  2020-06-04  2:20 [PATCH v2 1/2] efi/libstub/arm64: link stub lib.a conditionally Masahiro Yamada
  2020-06-04  2:20 ` [PATCH v2 2/2] efi/libstub: refactor Makefile to not use lib-y syntax Masahiro Yamada
@ 2020-06-10  7:58 ` Will Deacon
  2020-06-10  8:00   ` Ard Biesheuvel
  2020-07-22 22:48 ` [tip: efi/urgent] " tip-bot2 for Masahiro Yamada
  2 siblings, 1 reply; 10+ messages in thread
From: Will Deacon @ 2020-06-10  7:58 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Ard Biesheuvel, linux-efi, Catalin Marinas, linux-arm-kernel,
	linux-kernel

On Thu, Jun 04, 2020 at 11:20:30AM +0900, Masahiro Yamada wrote:
> Since commit 799c43415442 ("kbuild: thin archives make default for
> all archs"), core-y is passed to the linker with --whole-archive.
> Hence, the whole of stub library is linked to vmlinux.
> 
> Use libs-y so that lib.a is passed after --no-whole-archive for
> conditional linking.
> 
> The unused drivers/firmware/efi/libstub/relocate.o will be dropped
> for ARCH=arm64.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
> This patch touches under arch/arm64/, but
> this is more related to efi.
> I am sending this to Ard.

Ok, I'll ignore this then. Ard -- please yell if you want me to do anything
else with it.

Will


> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index 650e1185c190..48a6afa774fc 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -145,7 +145,7 @@ export	TEXT_OFFSET
>  
>  core-y		+= arch/arm64/
>  libs-y		:= arch/arm64/lib/ $(libs-y)
> -core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
> +libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
>  
>  # Default target when executing plain make
>  boot		:= arch/arm64/boot
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] efi/libstub/arm64: link stub lib.a conditionally
  2020-06-10  7:58 ` [PATCH v2 1/2] efi/libstub/arm64: link stub lib.a conditionally Will Deacon
@ 2020-06-10  8:00   ` Ard Biesheuvel
  2020-06-10  8:42     ` Will Deacon
  0 siblings, 1 reply; 10+ messages in thread
From: Ard Biesheuvel @ 2020-06-10  8:00 UTC (permalink / raw)
  To: Will Deacon
  Cc: Masahiro Yamada, linux-efi, Catalin Marinas, Linux ARM,
	Linux Kernel Mailing List

On Wed, 10 Jun 2020 at 09:58, Will Deacon <will@kernel.org> wrote:
>
> On Thu, Jun 04, 2020 at 11:20:30AM +0900, Masahiro Yamada wrote:
> > Since commit 799c43415442 ("kbuild: thin archives make default for
> > all archs"), core-y is passed to the linker with --whole-archive.
> > Hence, the whole of stub library is linked to vmlinux.
> >
> > Use libs-y so that lib.a is passed after --no-whole-archive for
> > conditional linking.
> >
> > The unused drivers/firmware/efi/libstub/relocate.o will be dropped
> > for ARCH=arm64.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> > This patch touches under arch/arm64/, but
> > this is more related to efi.
> > I am sending this to Ard.
>
> Ok, I'll ignore this then. Ard -- please yell if you want me to do anything
> else with it.
>

I am going to send a batch of EFI fixes early next week, so I can take
this as well, or alternatively, you can apply it directly.

>
> > diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> > index 650e1185c190..48a6afa774fc 100644
> > --- a/arch/arm64/Makefile
> > +++ b/arch/arm64/Makefile
> > @@ -145,7 +145,7 @@ export    TEXT_OFFSET
> >
> >  core-y               += arch/arm64/
> >  libs-y               := arch/arm64/lib/ $(libs-y)
> > -core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
> > +libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
> >
> >  # Default target when executing plain make
> >  boot         := arch/arm64/boot
> > --
> > 2.25.1
> >

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] efi/libstub/arm64: link stub lib.a conditionally
  2020-06-10  8:00   ` Ard Biesheuvel
@ 2020-06-10  8:42     ` Will Deacon
  0 siblings, 0 replies; 10+ messages in thread
From: Will Deacon @ 2020-06-10  8:42 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Masahiro Yamada, linux-efi, Catalin Marinas, Linux ARM,
	Linux Kernel Mailing List

On Wed, Jun 10, 2020 at 10:00:19AM +0200, Ard Biesheuvel wrote:
> On Wed, 10 Jun 2020 at 09:58, Will Deacon <will@kernel.org> wrote:
> >
> > On Thu, Jun 04, 2020 at 11:20:30AM +0900, Masahiro Yamada wrote:
> > > Since commit 799c43415442 ("kbuild: thin archives make default for
> > > all archs"), core-y is passed to the linker with --whole-archive.
> > > Hence, the whole of stub library is linked to vmlinux.
> > >
> > > Use libs-y so that lib.a is passed after --no-whole-archive for
> > > conditional linking.
> > >
> > > The unused drivers/firmware/efi/libstub/relocate.o will be dropped
> > > for ARCH=arm64.
> > >
> > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > ---
> > >
> > > This patch touches under arch/arm64/, but
> > > this is more related to efi.
> > > I am sending this to Ard.
> >
> > Ok, I'll ignore this then. Ard -- please yell if you want me to do anything
> > else with it.
> >
> 
> I am going to send a batch of EFI fixes early next week, so I can take
> this as well, or alternatively, you can apply it directly.

No, please take it. Just wanted to make sure it didn't slip through the
cracks, that's all.

Will

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] efi/libstub: refactor Makefile to not use lib-y syntax
  2020-06-04  2:20 ` [PATCH v2 2/2] efi/libstub: refactor Makefile to not use lib-y syntax Masahiro Yamada
@ 2020-06-15 10:26   ` Ard Biesheuvel
  2020-06-15 10:41     ` Ard Biesheuvel
  0 siblings, 1 reply; 10+ messages in thread
From: Ard Biesheuvel @ 2020-06-15 10:26 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-efi, Arvind Sankar, Atish Patra, Ingo Molnar, Kees Cook,
	Linux Kernel Mailing List

On Thu, 4 Jun 2020 at 04:20, Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Documentation/kbuild/makefiles.rst says:
>
>   Use of lib-y is normally restricted to `lib/` and `arch/*/lib`.
>
> This is because lib-y is inteded to be hooked to KBUILD_VMLINUX_LIBS,
> which is passed down to scripts/link-vmlinux.sh.
>
> Besides, lib-y is not so interesting because objects from lib-y are
> mostly linked in normal usecases. For example, lib-y only saves 364
> bytes for x86_64_defconfig. You can see the details in commit
> 7273ad2b08f8 ("kbuild: link lib-y objects to vmlinux forcibly when
> CONFIG_MODULES=y").
>
> I think we should consider to deprecate lib-y syntax at some point
> because we should aim for better solution like dead code elimination
> or LTO.
>
> Other than lib/ and arch/*/lib, this Makefile is the only user of
> lib-y. Replace lib-y with a custom rule.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Series queued in efi/urgent.

Thanks

> ---
>
> Changes in v2:
>   - Add more description
>
>  drivers/firmware/efi/libstub/Makefile | 49 +++++++++++++++------------
>  1 file changed, 27 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
> index cce4a7436052..7d81dc45cadf 100644
> --- a/drivers/firmware/efi/libstub/Makefile
> +++ b/drivers/firmware/efi/libstub/Makefile
> @@ -44,7 +44,7 @@ OBJECT_FILES_NON_STANDARD     := y
>  # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
>  KCOV_INSTRUMENT                        := n
>
> -lib-y                          := efi-stub-helper.o gop.o secureboot.o tpm.o \
> +stub-obj-y                     := efi-stub-helper.o gop.o secureboot.o tpm.o \
>                                    file.o mem.o random.o randomalloc.o pci.o \
>                                    skip_spaces.o lib-cmdline.o lib-ctype.o \
>                                    alignedmem.o relocate.o vsprintf.o
> @@ -55,15 +55,19 @@ efi-deps-y := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c fdt_empty_tree.c fdt_sw.c
>  $(obj)/lib-%.o: $(srctree)/lib/%.c FORCE
>         $(call if_changed_rule,cc_o_c)
>
> -lib-$(CONFIG_EFI_GENERIC_STUB) += efi-stub.o fdt.o string.o \
> +stub-obj-$(CONFIG_EFI_GENERIC_STUB)    += efi-stub.o fdt.o string.o \
>                                    $(patsubst %.c,lib-%.o,$(efi-deps-y))
>
> -lib-$(CONFIG_ARM)              += arm32-stub.o
> -lib-$(CONFIG_ARM64)            += arm64-stub.o
> -lib-$(CONFIG_X86)              += x86-stub.o
> +stub-obj-$(CONFIG_ARM)         += arm32-stub.o
> +stub-obj-$(CONFIG_ARM64)       += arm64-stub.o
> +stub-obj-$(CONFIG_X86)         += x86-stub.o
>  CFLAGS_arm32-stub.o            := -DTEXT_OFFSET=$(TEXT_OFFSET)
>  CFLAGS_arm64-stub.o            := -DTEXT_OFFSET=$(TEXT_OFFSET)
>
> +targets                                += $(stub-obj-y)
> +stub-obj-y                     := $(patsubst %.o,%.stub.o, $(stub-obj-y))
> +targets                                += $(stub-obj-y)
> +
>  #
>  # For x86, bootloaders like systemd-boot or grub-efi do not zero-initialize the
>  # .bss section, so the .bss section of the EFI stub needs to be included in the
> @@ -83,23 +87,6 @@ STUBCOPY_FLAGS-$(CONFIG_ARM) += --rename-section .data=.data.efistub \
>                                    --rename-section .bss=.bss.efistub,load,alloc
>  STUBCOPY_RELOC-$(CONFIG_ARM)   := R_ARM_ABS
>
> -#
> -# arm64 puts the stub in the kernel proper, which will unnecessarily retain all
> -# code indefinitely unless it is annotated as __init/__initdata/__initconst etc.
> -# So let's apply the __init annotations at the section level, by prefixing
> -# the section names directly. This will ensure that even all the inline string
> -# literals are covered.
> -# The fact that the stub and the kernel proper are essentially the same binary
> -# also means that we need to be extra careful to make sure that the stub does
> -# not rely on any absolute symbol references, considering that the virtual
> -# kernel mapping that the linker uses is not active yet when the stub is
> -# executing. So build all C dependencies of the EFI stub into libstub, and do
> -# a verification pass to see if any absolute relocations exist in any of the
> -# object files.
> -#
> -extra-y                                := $(lib-y)
> -lib-y                          := $(patsubst %.o,%.stub.o,$(lib-y))
> -
>  STUBCOPY_FLAGS-$(CONFIG_ARM64) += --prefix-alloc-sections=.init \
>                                    --prefix-symbols=__efistub_
>  STUBCOPY_RELOC-$(CONFIG_ARM64) := R_AARCH64_ABS
> @@ -121,3 +108,21 @@ quiet_cmd_stubcopy = STUBCPY $@
>                 /bin/false;                                             \
>         fi;                                                             \
>         $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@
> +
> +# arm64 puts the stub in the kernel proper, which will unnecessarily retain all
> +# code indefinitely unless it is annotated as __init/__initdata/__initconst etc.
> +# So let's apply the __init annotations at the section level, by prefixing
> +# the section names directly. This will ensure that even all the inline string
> +# literals are covered.
> +# The fact that the stub and the kernel proper are essentially the same binary
> +# also means that we need to be extra careful to make sure that the stub does
> +# not rely on any absolute symbol references, considering that the virtual
> +# kernel mapping that the linker uses is not active yet when the stub is
> +# executing. So build all C dependencies of the EFI stub into libstub, and do
> +# a verification pass to see if any absolute relocations exist in any of the
> +# object files.
> +#
> +extra-y += lib.a
> +
> +$(obj)/lib.a: $(addprefix $(obj)/, $(stub-obj-y)) FORCE
> +       $(call if_changed,ar)
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] efi/libstub: refactor Makefile to not use lib-y syntax
  2020-06-15 10:26   ` Ard Biesheuvel
@ 2020-06-15 10:41     ` Ard Biesheuvel
  2020-06-15 14:14       ` Masahiro Yamada
  0 siblings, 1 reply; 10+ messages in thread
From: Ard Biesheuvel @ 2020-06-15 10:41 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-efi, Arvind Sankar, Atish Patra, Ingo Molnar, Kees Cook,
	Linux Kernel Mailing List

On Mon, 15 Jun 2020 at 12:26, Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Thu, 4 Jun 2020 at 04:20, Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > Documentation/kbuild/makefiles.rst says:
> >
> >   Use of lib-y is normally restricted to `lib/` and `arch/*/lib`.
> >
> > This is because lib-y is inteded to be hooked to KBUILD_VMLINUX_LIBS,
> > which is passed down to scripts/link-vmlinux.sh.
> >
> > Besides, lib-y is not so interesting because objects from lib-y are
> > mostly linked in normal usecases. For example, lib-y only saves 364
> > bytes for x86_64_defconfig. You can see the details in commit
> > 7273ad2b08f8 ("kbuild: link lib-y objects to vmlinux forcibly when
> > CONFIG_MODULES=y").
> >
> > I think we should consider to deprecate lib-y syntax at some point
> > because we should aim for better solution like dead code elimination
> > or LTO.
> >
> > Other than lib/ and arch/*/lib, this Makefile is the only user of
> > lib-y. Replace lib-y with a custom rule.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
>
> Series queued in efi/urgent.
>

Actually, I am seeing this now

/home/ard/linux/scripts/Makefile.build:421: warning: overriding recipe
for target 'drivers/firmware/efi/libstub/lib.a'
/home/ard/linux/drivers/firmware/efi/libstub/Makefile:131: warning:
ignoring old recipe for target 'drivers/firmware/efi/libstub/lib.a'

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] efi/libstub: refactor Makefile to not use lib-y syntax
  2020-06-15 10:41     ` Ard Biesheuvel
@ 2020-06-15 14:14       ` Masahiro Yamada
  2020-06-15 14:20         ` Ard Biesheuvel
  0 siblings, 1 reply; 10+ messages in thread
From: Masahiro Yamada @ 2020-06-15 14:14 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-efi, Arvind Sankar, Atish Patra, Ingo Molnar, Kees Cook,
	Linux Kernel Mailing List

On Mon, Jun 15, 2020 at 7:41 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Mon, 15 Jun 2020 at 12:26, Ard Biesheuvel <ardb@kernel.org> wrote:
> >
> > On Thu, 4 Jun 2020 at 04:20, Masahiro Yamada <masahiroy@kernel.org> wrote:
> > >
> > > Documentation/kbuild/makefiles.rst says:
> > >
> > >   Use of lib-y is normally restricted to `lib/` and `arch/*/lib`.
> > >
> > > This is because lib-y is inteded to be hooked to KBUILD_VMLINUX_LIBS,
> > > which is passed down to scripts/link-vmlinux.sh.
> > >
> > > Besides, lib-y is not so interesting because objects from lib-y are
> > > mostly linked in normal usecases. For example, lib-y only saves 364
> > > bytes for x86_64_defconfig. You can see the details in commit
> > > 7273ad2b08f8 ("kbuild: link lib-y objects to vmlinux forcibly when
> > > CONFIG_MODULES=y").
> > >
> > > I think we should consider to deprecate lib-y syntax at some point
> > > because we should aim for better solution like dead code elimination
> > > or LTO.
> > >
> > > Other than lib/ and arch/*/lib, this Makefile is the only user of
> > > lib-y. Replace lib-y with a custom rule.
> > >
> > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> >
> > Series queued in efi/urgent.
> >
>
> Actually, I am seeing this now
>
> /home/ard/linux/scripts/Makefile.build:421: warning: overriding recipe
> for target 'drivers/firmware/efi/libstub/lib.a'
> /home/ard/linux/drivers/firmware/efi/libstub/Makefile:131: warning:
> ignoring old recipe for target 'drivers/firmware/efi/libstub/lib.a'



Sorry, please drop this patch for now.

(Actually, it was working when I submitted it,
but is broken after e578edc72276280b8fae57f6bf79cb443ceee7a2)



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] efi/libstub: refactor Makefile to not use lib-y syntax
  2020-06-15 14:14       ` Masahiro Yamada
@ 2020-06-15 14:20         ` Ard Biesheuvel
  0 siblings, 0 replies; 10+ messages in thread
From: Ard Biesheuvel @ 2020-06-15 14:20 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-efi, Arvind Sankar, Atish Patra, Ingo Molnar, Kees Cook,
	Linux Kernel Mailing List

On Mon, 15 Jun 2020 at 16:15, Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Mon, Jun 15, 2020 at 7:41 PM Ard Biesheuvel <ardb@kernel.org> wrote:
> >
> > On Mon, 15 Jun 2020 at 12:26, Ard Biesheuvel <ardb@kernel.org> wrote:
> > >
> > > On Thu, 4 Jun 2020 at 04:20, Masahiro Yamada <masahiroy@kernel.org> wrote:
> > > >
> > > > Documentation/kbuild/makefiles.rst says:
> > > >
> > > >   Use of lib-y is normally restricted to `lib/` and `arch/*/lib`.
> > > >
> > > > This is because lib-y is inteded to be hooked to KBUILD_VMLINUX_LIBS,
> > > > which is passed down to scripts/link-vmlinux.sh.
> > > >
> > > > Besides, lib-y is not so interesting because objects from lib-y are
> > > > mostly linked in normal usecases. For example, lib-y only saves 364
> > > > bytes for x86_64_defconfig. You can see the details in commit
> > > > 7273ad2b08f8 ("kbuild: link lib-y objects to vmlinux forcibly when
> > > > CONFIG_MODULES=y").
> > > >
> > > > I think we should consider to deprecate lib-y syntax at some point
> > > > because we should aim for better solution like dead code elimination
> > > > or LTO.
> > > >
> > > > Other than lib/ and arch/*/lib, this Makefile is the only user of
> > > > lib-y. Replace lib-y with a custom rule.
> > > >
> > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > >
> > > Series queued in efi/urgent.
> > >
> >
> > Actually, I am seeing this now
> >
> > /home/ard/linux/scripts/Makefile.build:421: warning: overriding recipe
> > for target 'drivers/firmware/efi/libstub/lib.a'
> > /home/ard/linux/drivers/firmware/efi/libstub/Makefile:131: warning:
> > ignoring old recipe for target 'drivers/firmware/efi/libstub/lib.a'
>
>
>
> Sorry, please drop this patch for now.
>
> (Actually, it was working when I submitted it,
> but is broken after e578edc72276280b8fae57f6bf79cb443ceee7a2)
>

OK.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [tip: efi/urgent] efi/libstub/arm64: link stub lib.a conditionally
  2020-06-04  2:20 [PATCH v2 1/2] efi/libstub/arm64: link stub lib.a conditionally Masahiro Yamada
  2020-06-04  2:20 ` [PATCH v2 2/2] efi/libstub: refactor Makefile to not use lib-y syntax Masahiro Yamada
  2020-06-10  7:58 ` [PATCH v2 1/2] efi/libstub/arm64: link stub lib.a conditionally Will Deacon
@ 2020-07-22 22:48 ` tip-bot2 for Masahiro Yamada
  2 siblings, 0 replies; 10+ messages in thread
From: tip-bot2 for Masahiro Yamada @ 2020-07-22 22:48 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Masahiro Yamada, Ard Biesheuvel, x86, LKML

The following commit has been merged into the efi/urgent branch of tip:

Commit-ID:     c1aac64ddc01112e137121a43645b96c3633c41b
Gitweb:        https://git.kernel.org/tip/c1aac64ddc01112e137121a43645b96c3633c41b
Author:        Masahiro Yamada <masahiroy@kernel.org>
AuthorDate:    Thu, 04 Jun 2020 11:20:30 +09:00
Committer:     Ard Biesheuvel <ardb@kernel.org>
CommitterDate: Thu, 09 Jul 2020 09:45:09 +03:00

efi/libstub/arm64: link stub lib.a conditionally

Since commit 799c43415442 ("kbuild: thin archives make default for
all archs"), core-y is passed to the linker with --whole-archive.
Hence, the whole of stub library is linked to vmlinux.

Use libs-y so that lib.a is passed after --no-whole-archive for
conditional linking.

The unused drivers/firmware/efi/libstub/relocate.o will be dropped
for ARCH=arm64.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Link: https://lore.kernel.org/r/20200604022031.164207-1-masahiroy@kernel.org
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/arm64/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 76359cf..4621fb6 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -143,7 +143,7 @@ export	TEXT_OFFSET
 
 core-y		+= arch/arm64/
 libs-y		:= arch/arm64/lib/ $(libs-y)
-core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
+libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
 
 # Default target when executing plain make
 boot		:= arch/arm64/boot

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-07-22 22:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-04  2:20 [PATCH v2 1/2] efi/libstub/arm64: link stub lib.a conditionally Masahiro Yamada
2020-06-04  2:20 ` [PATCH v2 2/2] efi/libstub: refactor Makefile to not use lib-y syntax Masahiro Yamada
2020-06-15 10:26   ` Ard Biesheuvel
2020-06-15 10:41     ` Ard Biesheuvel
2020-06-15 14:14       ` Masahiro Yamada
2020-06-15 14:20         ` Ard Biesheuvel
2020-06-10  7:58 ` [PATCH v2 1/2] efi/libstub/arm64: link stub lib.a conditionally Will Deacon
2020-06-10  8:00   ` Ard Biesheuvel
2020-06-10  8:42     ` Will Deacon
2020-07-22 22:48 ` [tip: efi/urgent] " tip-bot2 for Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).