The next patch adds DEFINE_DYNAMIC_DEBUG_TABLE(), which broke several
subtrees, including efi, vdso, and some of arch/*/boot/compressed,
with various relocation errors, iirc.
Avoid those problems by adding a define to suppress the "transparent"
DEFINE_DYNAMIC_DEBUG_TABLE() invocation. I found the x86 problems
myself, [email protected] found arm & sparc problems, and may yet find
others.
Reported-by: <[email protected]> # on [jimc:lkp-test/dyndbg-diet] recently
Signed-off-by: Jim Cromie <[email protected]>
---
arch/arm/boot/compressed/Makefile | 2 ++
arch/sparc/vdso/Makefile | 2 ++
arch/x86/boot/compressed/Makefile | 1 +
arch/x86/entry/vdso/Makefile | 3 +++
arch/x86/purgatory/Makefile | 1 +
drivers/firmware/efi/libstub/Makefile | 3 ++-
6 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index fd94e27ba4fa..72f056a00ad4 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -82,6 +82,8 @@ compress-$(CONFIG_KERNEL_LZMA) = lzma
compress-$(CONFIG_KERNEL_XZ) = xzkern
compress-$(CONFIG_KERNEL_LZ4) = lz4
+KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE
+
libfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o
ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
diff --git a/arch/sparc/vdso/Makefile b/arch/sparc/vdso/Makefile
index c5e1545bc5cf..960ed0fb6804 100644
--- a/arch/sparc/vdso/Makefile
+++ b/arch/sparc/vdso/Makefile
@@ -30,6 +30,8 @@ obj-y += $(vdso_img_objs)
targets += $(vdso_img_cfiles)
targets += $(vdso_img_sodbg) $(vdso_img-y:%=vdso%.so)
+KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE
+
CPPFLAGS_vdso.lds += -P -C
VDSO_LDFLAGS_vdso.lds = -m elf64_sparc -soname linux-vdso.so.1 --no-undefined \
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index e0bc3988c3fa..ada4eb960d95 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -31,6 +31,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
KBUILD_CFLAGS := -m$(BITS) -O2
KBUILD_CFLAGS += -fno-strict-aliasing -fPIE
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
+KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE
cflags-$(CONFIG_X86_32) := -march=i386
cflags-$(CONFIG_X86_64) := -mcmodel=small -mno-red-zone
KBUILD_CFLAGS += $(cflags-y)
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
index 05c4abc2fdfd..619878f2c427 100644
--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -29,6 +29,9 @@ vobjs32-y := vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o
vobjs32-y += vdso32/vclock_gettime.o
vobjs-$(CONFIG_X86_SGX) += vsgx.o
+# avoid a x86_64_RELATIVE error
+KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE
+
# files to link into kernel
obj-y += vma.o extable.o
KASAN_SANITIZE_vma.o := y
diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile
index 95ea17a9d20c..95ba7b18410f 100644
--- a/arch/x86/purgatory/Makefile
+++ b/arch/x86/purgatory/Makefile
@@ -35,6 +35,7 @@ PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel
PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss -g0
PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING
PURGATORY_CFLAGS += -fno-stack-protector
+PURGATORY_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE
# Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That
# in turn leaves some undefined symbols like __fentry__ in purgatory and not
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index c23466e05e60..def8febefbd3 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -13,7 +13,8 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ \
-Wno-pointer-sign \
$(call cc-disable-warning, address-of-packed-member) \
$(call cc-disable-warning, gnu) \
- -fno-asynchronous-unwind-tables
+ -fno-asynchronous-unwind-tables \
+ -DNO_DYNAMIC_DEBUG_TABLE
# arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly
# disable the stackleak plugin
--
2.31.1
On Tue, 11 May 2021 at 20:51, Jim Cromie <[email protected]> wrote:
>
> The next patch adds DEFINE_DYNAMIC_DEBUG_TABLE(), which broke several
> subtrees, including efi, vdso, and some of arch/*/boot/compressed,
> with various relocation errors, iirc.
>
> Avoid those problems by adding a define to suppress the "transparent"
> DEFINE_DYNAMIC_DEBUG_TABLE() invocation. I found the x86 problems
> myself, [email protected] found arm & sparc problems, and may yet find
> others.
>
Given that I was only cc'ed on this patch in isolation, would you mind
adding more clarification here? What is DEFINE_DYNAMIC_DEBUG_TABLE()
supposed to do, and why is it breaking standalone binaries?
> Reported-by: <[email protected]> # on [jimc:lkp-test/dyndbg-diet] recently
> Signed-off-by: Jim Cromie <[email protected]>
> ---
> arch/arm/boot/compressed/Makefile | 2 ++
> arch/sparc/vdso/Makefile | 2 ++
> arch/x86/boot/compressed/Makefile | 1 +
> arch/x86/entry/vdso/Makefile | 3 +++
> arch/x86/purgatory/Makefile | 1 +
> drivers/firmware/efi/libstub/Makefile | 3 ++-
> 6 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
> index fd94e27ba4fa..72f056a00ad4 100644
> --- a/arch/arm/boot/compressed/Makefile
> +++ b/arch/arm/boot/compressed/Makefile
> @@ -82,6 +82,8 @@ compress-$(CONFIG_KERNEL_LZMA) = lzma
> compress-$(CONFIG_KERNEL_XZ) = xzkern
> compress-$(CONFIG_KERNEL_LZ4) = lz4
>
> +KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE
> +
> libfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o
>
> ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
> diff --git a/arch/sparc/vdso/Makefile b/arch/sparc/vdso/Makefile
> index c5e1545bc5cf..960ed0fb6804 100644
> --- a/arch/sparc/vdso/Makefile
> +++ b/arch/sparc/vdso/Makefile
> @@ -30,6 +30,8 @@ obj-y += $(vdso_img_objs)
> targets += $(vdso_img_cfiles)
> targets += $(vdso_img_sodbg) $(vdso_img-y:%=vdso%.so)
>
> +KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE
> +
> CPPFLAGS_vdso.lds += -P -C
>
> VDSO_LDFLAGS_vdso.lds = -m elf64_sparc -soname linux-vdso.so.1 --no-undefined \
> diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
> index e0bc3988c3fa..ada4eb960d95 100644
> --- a/arch/x86/boot/compressed/Makefile
> +++ b/arch/x86/boot/compressed/Makefile
> @@ -31,6 +31,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
> KBUILD_CFLAGS := -m$(BITS) -O2
> KBUILD_CFLAGS += -fno-strict-aliasing -fPIE
> KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
> +KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE
> cflags-$(CONFIG_X86_32) := -march=i386
> cflags-$(CONFIG_X86_64) := -mcmodel=small -mno-red-zone
> KBUILD_CFLAGS += $(cflags-y)
> diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
> index 05c4abc2fdfd..619878f2c427 100644
> --- a/arch/x86/entry/vdso/Makefile
> +++ b/arch/x86/entry/vdso/Makefile
> @@ -29,6 +29,9 @@ vobjs32-y := vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o
> vobjs32-y += vdso32/vclock_gettime.o
> vobjs-$(CONFIG_X86_SGX) += vsgx.o
>
> +# avoid a x86_64_RELATIVE error
> +KBUILD_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE
> +
> # files to link into kernel
> obj-y += vma.o extable.o
> KASAN_SANITIZE_vma.o := y
> diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile
> index 95ea17a9d20c..95ba7b18410f 100644
> --- a/arch/x86/purgatory/Makefile
> +++ b/arch/x86/purgatory/Makefile
> @@ -35,6 +35,7 @@ PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel
> PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss -g0
> PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING
> PURGATORY_CFLAGS += -fno-stack-protector
> +PURGATORY_CFLAGS += -DNO_DYNAMIC_DEBUG_TABLE
>
> # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That
> # in turn leaves some undefined symbols like __fentry__ in purgatory and not
> diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
> index c23466e05e60..def8febefbd3 100644
> --- a/drivers/firmware/efi/libstub/Makefile
> +++ b/drivers/firmware/efi/libstub/Makefile
> @@ -13,7 +13,8 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ \
> -Wno-pointer-sign \
> $(call cc-disable-warning, address-of-packed-member) \
> $(call cc-disable-warning, gnu) \
> - -fno-asynchronous-unwind-tables
> + -fno-asynchronous-unwind-tables \
> + -DNO_DYNAMIC_DEBUG_TABLE
>
> # arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly
> # disable the stackleak plugin
> --
> 2.31.1
>
On Wed, May 12, 2021 at 8:55 AM Ard Biesheuvel <[email protected]> wrote:
>
> On Tue, 11 May 2021 at 20:51, Jim Cromie <[email protected]> wrote:
> >
> > The next patch adds DEFINE_DYNAMIC_DEBUG_TABLE(), which broke several
> > subtrees, including efi, vdso, and some of arch/*/boot/compressed,
> > with various relocation errors, iirc.
> >
> > Avoid those problems by adding a define to suppress the "transparent"
> > DEFINE_DYNAMIC_DEBUG_TABLE() invocation. I found the x86 problems
> > myself, [email protected] found arm & sparc problems, and may yet find
> > others.
> >
>
> Given that I was only cc'ed on this patch in isolation, would you mind
> adding more clarification here? What is DEFINE_DYNAMIC_DEBUG_TABLE()
> supposed to do, and why is it breaking standalone binaries?
>
>
hi Ard,
the thread starts here:
https://lore.kernel.org/linux-mm/[email protected]/
the _TABLE macro derives from DEFINE_DYNAMIC_DEBUG_METADATA,
which puts private static struct _ddebug's in section("__dyndbg")
the _TABLE macro populates a different section(".gnu.linkonce.dyndbg"),
which is then placed by linker script at the start of the section.
ISTM that the new section might be whats breaking things.
And maybe that the vmlinux linker script isnt involved.
so the storage the _TABLE wants to define is unbound
(and unused, since there are no pr_debugs)
I did see relocation errors somewhere...
This is my 1st time doing something creative with the linker
As to larger purpose, I'll try to restate the patchset mission:
theres ~45kb savings possible by compressing the highly redundant data (~70kb)
which decorates pr_debug messages.
1 - split the compressible/decoration columns to a different
section|block, for block compression
this adds temporary .site pointer from _ddebug -> _ddebug_site
2 - change code so !site is safe.
_TABLEs only real job is to provide a header record, at the beginning
of the section/array,
for a single .site pointer to the _dyndbg_sites section added in 1.
Because the header has a fixed offset from any pr_debug in the vector,
all pr_debugs can use the headers copy of .site, and dont need their own.
specialize & unionize
So it allows to drop the temporary pointer, restoring memory size
parity with master.
And we then have the _dyndbg_sites section, full of redundant data,
ready to compress.
suppression with -DNO_DYNAMIC_DEBUG was a workaround, didnt think
about it afterwards
does this clarify ?
thanks
Jim