All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] add support for relative references in special sections
@ 2017-08-19 18:10 ` Ard Biesheuvel
  0 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-19 18:10 UTC (permalink / raw)
  To: linux-kernel, linux-arch
  Cc: Ard Biesheuvel, H. Peter Anvin, Arnd Bergmann, Heiko Carstens,
	Kees Cook, Will Deacon, Michael Ellerman, Thomas Garnier,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt, Martin Schwidefsky,
	Sergey Senozhatsky, Linus Torvalds, Jessica Yu

This adds support for emitting special sections such as initcall arrays,
PCI fixups and tracepoints as relative references rather than absolute
references. This reduces the size by 50% on 64-bit architectures, but
more importantly, it removes the need for carrying relocation metadata
for these sections in relocatables kernels (e.g., for KASLR) that need
to fix up these absolute references at boot time. On arm64, this reduces
the vmlinux footprint of such a reference by 8x (8 byte absolute reference
+ 24 byte RELA entry vs 4 byte relative reference)

Patch #2 was sent out before as a single patch. This series supersedes
the previous submission. This version makes relative ksymtab entries
dependent on the new Kconfig symbol HAVE_ARCH_PREL32_RELOCATIONS rather
than trying to infer from kbuild test robot replies for which architectures
it should be blacklisted.

Patch #1 introduces the new Kconfig symbol HAVE_ARCH_PREL32_RELOCATIONS,
and sets it for the main architectures that are expected to benefit the
most from this feature, i.e., 64-bit architectures, and ones that use
runtime relocation.

Patches #3 - #5 implement relative references for initcallls, PCI fixups
and tracepoints, respectively, all of which produce sections with order
~1000 entries on an arm64 defconfig kernel with tracing enabled. This
means we save about 28 KB of vmlinux space for each of these patches.

For the arm64 kernel, all patches combined reduce the size of vmlinux
by about 300 KB (with KASLR enabled).

Changes since v2:
- Revert my slightly misguided attempt to appease checkpatch, which resulted
  in needless churn and worse code. This v3 is based on v1 with a few tweaks
  that were actually reasonable checkpatch warnings: unnecessary braces (as
  pointed out by Ingo) and other minor whitespace misdemeanors.

Changes since v1:
- Remove checkpatch errors to the extent feasible: in some cases, this
  involves moving extern declarations into C files, and switching to
  struct definitions rather than typedefs. Some errors are impossible
  to fix: please find the remaining ones after the diffstat.
- Used 'int' instead if 'signed int' for the various offset fields: there
  is no ambiguity between architectures regarding its signedness (unlike
  'char')
- Refactor the different patches to be more uniform in the way they define
  the section entry type and accessors in the .h file, and avoid the need to
  add #ifdefs to the C code.

Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Thomas Garnier <thgarnie@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Morris <james.l.morris@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nicolas Pitre <nico@linaro.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jessica Yu <jeyu@kernel.org>

Ard Biesheuvel (5):
  arch: enable relative relocations for arm64, power, x86, s390 and x86
  module: use relative references for __ksymtab entries
  init: allow initcall tables to be emitted using relative references
  drivers: pci: add support for relative addressing in quirk tables
  kernel: tracepoints: add support for relative references

 arch/Kconfig                    | 10 +++++
 arch/arm64/Kconfig              |  1 +
 arch/arm64/kernel/vmlinux.lds.S |  2 +-
 arch/powerpc/Kconfig            |  1 +
 arch/s390/Kconfig               |  1 +
 arch/x86/Kconfig                |  1 +
 arch/x86/include/asm/Kbuild     |  1 +
 arch/x86/include/asm/export.h   |  4 --
 drivers/pci/quirks.c            | 13 ++++--
 include/asm-generic/export.h    | 12 +++++-
 include/linux/compiler.h        | 11 +++++
 include/linux/export.h          | 45 +++++++++++++++-----
 include/linux/init.h            | 44 ++++++++++++++-----
 include/linux/pci.h             | 20 +++++++++
 include/linux/tracepoint.h      | 19 +++++++--
 init/main.c                     | 32 +++++++-------
 kernel/module.c                 | 33 +++++++++++---
 kernel/printk/printk.c          |  4 +-
 kernel/tracepoint.c             | 17 ++++++--
 security/security.c             |  4 +-
 20 files changed, 209 insertions(+), 66 deletions(-)
 delete mode 100644 arch/x86/include/asm/export.h

-- 
2.11.0

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

* [PATCH v3 0/5] add support for relative references in special sections
@ 2017-08-19 18:10 ` Ard Biesheuvel
  0 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-19 18:10 UTC (permalink / raw)
  To: linux-kernel, linux-arch
  Cc: Ard Biesheuvel, H. Peter Anvin, Arnd Bergmann, Heiko Carstens,
	Kees Cook, Will Deacon, Michael Ellerman, Thomas Garnier,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt

This adds support for emitting special sections such as initcall arrays,
PCI fixups and tracepoints as relative references rather than absolute
references. This reduces the size by 50% on 64-bit architectures, but
more importantly, it removes the need for carrying relocation metadata
for these sections in relocatables kernels (e.g., for KASLR) that need
to fix up these absolute references at boot time. On arm64, this reduces
the vmlinux footprint of such a reference by 8x (8 byte absolute reference
+ 24 byte RELA entry vs 4 byte relative reference)

Patch #2 was sent out before as a single patch. This series supersedes
the previous submission. This version makes relative ksymtab entries
dependent on the new Kconfig symbol HAVE_ARCH_PREL32_RELOCATIONS rather
than trying to infer from kbuild test robot replies for which architectures
it should be blacklisted.

Patch #1 introduces the new Kconfig symbol HAVE_ARCH_PREL32_RELOCATIONS,
and sets it for the main architectures that are expected to benefit the
most from this feature, i.e., 64-bit architectures, and ones that use
runtime relocation.

Patches #3 - #5 implement relative references for initcallls, PCI fixups
and tracepoints, respectively, all of which produce sections with order
~1000 entries on an arm64 defconfig kernel with tracing enabled. This
means we save about 28 KB of vmlinux space for each of these patches.

For the arm64 kernel, all patches combined reduce the size of vmlinux
by about 300 KB (with KASLR enabled).

Changes since v2:
- Revert my slightly misguided attempt to appease checkpatch, which resulted
  in needless churn and worse code. This v3 is based on v1 with a few tweaks
  that were actually reasonable checkpatch warnings: unnecessary braces (as
  pointed out by Ingo) and other minor whitespace misdemeanors.

Changes since v1:
- Remove checkpatch errors to the extent feasible: in some cases, this
  involves moving extern declarations into C files, and switching to
  struct definitions rather than typedefs. Some errors are impossible
  to fix: please find the remaining ones after the diffstat.
- Used 'int' instead if 'signed int' for the various offset fields: there
  is no ambiguity between architectures regarding its signedness (unlike
  'char')
- Refactor the different patches to be more uniform in the way they define
  the section entry type and accessors in the .h file, and avoid the need to
  add #ifdefs to the C code.

Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Thomas Garnier <thgarnie@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Morris <james.l.morris@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nicolas Pitre <nico@linaro.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jessica Yu <jeyu@kernel.org>

Ard Biesheuvel (5):
  arch: enable relative relocations for arm64, power, x86, s390 and x86
  module: use relative references for __ksymtab entries
  init: allow initcall tables to be emitted using relative references
  drivers: pci: add support for relative addressing in quirk tables
  kernel: tracepoints: add support for relative references

 arch/Kconfig                    | 10 +++++
 arch/arm64/Kconfig              |  1 +
 arch/arm64/kernel/vmlinux.lds.S |  2 +-
 arch/powerpc/Kconfig            |  1 +
 arch/s390/Kconfig               |  1 +
 arch/x86/Kconfig                |  1 +
 arch/x86/include/asm/Kbuild     |  1 +
 arch/x86/include/asm/export.h   |  4 --
 drivers/pci/quirks.c            | 13 ++++--
 include/asm-generic/export.h    | 12 +++++-
 include/linux/compiler.h        | 11 +++++
 include/linux/export.h          | 45 +++++++++++++++-----
 include/linux/init.h            | 44 ++++++++++++++-----
 include/linux/pci.h             | 20 +++++++++
 include/linux/tracepoint.h      | 19 +++++++--
 init/main.c                     | 32 +++++++-------
 kernel/module.c                 | 33 +++++++++++---
 kernel/printk/printk.c          |  4 +-
 kernel/tracepoint.c             | 17 ++++++--
 security/security.c             |  4 +-
 20 files changed, 209 insertions(+), 66 deletions(-)
 delete mode 100644 arch/x86/include/asm/export.h

-- 
2.11.0

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

* [PATCH v3 1/5] arch: enable relative relocations for arm64, power, x86, s390 and x86
  2017-08-19 18:10 ` Ard Biesheuvel
@ 2017-08-19 18:10   ` Ard Biesheuvel
  -1 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-19 18:10 UTC (permalink / raw)
  To: linux-kernel, linux-arch
  Cc: Ard Biesheuvel, H. Peter Anvin, Arnd Bergmann, Heiko Carstens,
	Kees Cook, Will Deacon, Michael Ellerman, Thomas Garnier,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt, Martin Schwidefsky,
	Sergey Senozhatsky, Linus Torvalds, Jessica Yu, x86

Before updating certain subsystems to use place relative 32-bit
relocations in special sections, to save space  and reduce the
number of absolute relocations that need to be processed at runtime
by relocatable kernels, introduce the Kconfig symbol and define it
for some architectures that should be able to support and benefit
from it.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 arch/Kconfig                    | 10 ++++++++++
 arch/arm64/Kconfig              |  1 +
 arch/arm64/kernel/vmlinux.lds.S |  2 +-
 arch/powerpc/Kconfig            |  1 +
 arch/s390/Kconfig               |  1 +
 arch/x86/Kconfig                |  1 +
 6 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 21d0089117fe..4e77d8e8697e 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -940,4 +940,14 @@ config REFCOUNT_FULL
 	  against various use-after-free conditions that can be used in
 	  security flaw exploits.
 
+config HAVE_ARCH_PREL32_RELOCATIONS
+	bool
+	help
+	  May be selected by an architecture if it supports place-relative
+	  32-bit relocations, both in the toolchain and in the module loader,
+	  in which case relative references can be used in special sections
+	  for PCI fixup, initcalls etc which are only half the size on 64 bit
+	  architectures, and don't require runtime relocation on relocatable
+	  kernels.
+
 source "kernel/gcov/Kconfig"
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index dfd908630631..ce05d2d8143e 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -72,6 +72,7 @@ config ARM64
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_MMAP_RND_BITS
 	select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT
+	select HAVE_ARCH_PREL32_RELOCATIONS
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_ARCH_TRANSPARENT_HUGEPAGE
diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
index 987a00ee446c..b6d8e6504896 100644
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -171,7 +171,7 @@ SECTIONS
 		CON_INITCALL
 		SECURITY_INITCALL
 		INIT_RAM_FS
-		*(.init.rodata.* .init.bss)	/* from the EFI stub */
+		*(.init.rodata.* .init.bss .init.discard.*)	/* EFI stub */
 	}
 	.exit.data : {
 		ARM_EXIT_KEEP(EXIT_DATA)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 36f858c37ca7..f7e60ed5bdd0 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -163,6 +163,7 @@ config PPC
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_MMAP_RND_BITS
 	select HAVE_ARCH_MMAP_RND_COMPAT_BITS	if COMPAT
+	select HAVE_ARCH_PREL32_RELOCATIONS
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ARCH_TRACEHOOK
 	select ARCH_HAS_STRICT_KERNEL_RWX	if (PPC_BOOK3S_64 && !RELOCATABLE && !HIBERNATION)
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 7eeb75d758c1..1206cc7daa0d 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -127,6 +127,7 @@ config S390
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_JUMP_LABEL
 	select CPU_NO_EFFICIENT_FFS if !HAVE_MARCH_Z9_109_FEATURES
+	select HAVE_ARCH_PREL32_RELOCATIONS
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ARCH_SOFT_DIRTY
 	select HAVE_ARCH_TRACEHOOK
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 781521b7cf9e..77246125883e 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -112,6 +112,7 @@ config X86
 	select HAVE_ARCH_MMAP_RND_BITS		if MMU
 	select HAVE_ARCH_MMAP_RND_COMPAT_BITS	if MMU && COMPAT
 	select HAVE_ARCH_COMPAT_MMAP_BASES	if MMU && COMPAT
+	select HAVE_ARCH_PREL32_RELOCATIONS
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_ARCH_TRANSPARENT_HUGEPAGE
-- 
2.11.0

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

* [PATCH v3 1/5] arch: enable relative relocations for arm64, power, x86, s390 and x86
@ 2017-08-19 18:10   ` Ard Biesheuvel
  0 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-19 18:10 UTC (permalink / raw)
  To: linux-kernel, linux-arch
  Cc: Ard Biesheuvel, H. Peter Anvin, Arnd Bergmann, Heiko Carstens,
	Kees Cook, Will Deacon, Michael Ellerman, Thomas Garnier,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt

Before updating certain subsystems to use place relative 32-bit
relocations in special sections, to save space  and reduce the
number of absolute relocations that need to be processed at runtime
by relocatable kernels, introduce the Kconfig symbol and define it
for some architectures that should be able to support and benefit
from it.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 arch/Kconfig                    | 10 ++++++++++
 arch/arm64/Kconfig              |  1 +
 arch/arm64/kernel/vmlinux.lds.S |  2 +-
 arch/powerpc/Kconfig            |  1 +
 arch/s390/Kconfig               |  1 +
 arch/x86/Kconfig                |  1 +
 6 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 21d0089117fe..4e77d8e8697e 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -940,4 +940,14 @@ config REFCOUNT_FULL
 	  against various use-after-free conditions that can be used in
 	  security flaw exploits.
 
+config HAVE_ARCH_PREL32_RELOCATIONS
+	bool
+	help
+	  May be selected by an architecture if it supports place-relative
+	  32-bit relocations, both in the toolchain and in the module loader,
+	  in which case relative references can be used in special sections
+	  for PCI fixup, initcalls etc which are only half the size on 64 bit
+	  architectures, and don't require runtime relocation on relocatable
+	  kernels.
+
 source "kernel/gcov/Kconfig"
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index dfd908630631..ce05d2d8143e 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -72,6 +72,7 @@ config ARM64
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_MMAP_RND_BITS
 	select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT
+	select HAVE_ARCH_PREL32_RELOCATIONS
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_ARCH_TRANSPARENT_HUGEPAGE
diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
index 987a00ee446c..b6d8e6504896 100644
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -171,7 +171,7 @@ SECTIONS
 		CON_INITCALL
 		SECURITY_INITCALL
 		INIT_RAM_FS
-		*(.init.rodata.* .init.bss)	/* from the EFI stub */
+		*(.init.rodata.* .init.bss .init.discard.*)	/* EFI stub */
 	}
 	.exit.data : {
 		ARM_EXIT_KEEP(EXIT_DATA)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 36f858c37ca7..f7e60ed5bdd0 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -163,6 +163,7 @@ config PPC
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_MMAP_RND_BITS
 	select HAVE_ARCH_MMAP_RND_COMPAT_BITS	if COMPAT
+	select HAVE_ARCH_PREL32_RELOCATIONS
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ARCH_TRACEHOOK
 	select ARCH_HAS_STRICT_KERNEL_RWX	if (PPC_BOOK3S_64 && !RELOCATABLE && !HIBERNATION)
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 7eeb75d758c1..1206cc7daa0d 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -127,6 +127,7 @@ config S390
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_JUMP_LABEL
 	select CPU_NO_EFFICIENT_FFS if !HAVE_MARCH_Z9_109_FEATURES
+	select HAVE_ARCH_PREL32_RELOCATIONS
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ARCH_SOFT_DIRTY
 	select HAVE_ARCH_TRACEHOOK
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 781521b7cf9e..77246125883e 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -112,6 +112,7 @@ config X86
 	select HAVE_ARCH_MMAP_RND_BITS		if MMU
 	select HAVE_ARCH_MMAP_RND_COMPAT_BITS	if MMU && COMPAT
 	select HAVE_ARCH_COMPAT_MMAP_BASES	if MMU && COMPAT
+	select HAVE_ARCH_PREL32_RELOCATIONS
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_ARCH_TRANSPARENT_HUGEPAGE
-- 
2.11.0

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

* [PATCH v3 2/5] module: use relative references for __ksymtab entries
  2017-08-19 18:10 ` Ard Biesheuvel
@ 2017-08-19 18:10   ` Ard Biesheuvel
  -1 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-19 18:10 UTC (permalink / raw)
  To: linux-kernel, linux-arch
  Cc: Ard Biesheuvel, H. Peter Anvin, Arnd Bergmann, Heiko Carstens,
	Kees Cook, Will Deacon, Michael Ellerman, Thomas Garnier,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt, Martin Schwidefsky,
	Sergey Senozhatsky, Linus Torvalds, Jessica Yu, Ingo Molnar

An ordinary arm64 defconfig build has ~64 KB worth of __ksymtab
entries, each consisting of two 64-bit fields containing absolute
references, to the symbol itself and to a char array containing
its name, respectively.

When we build the same configuration with KASLR enabled, we end
up with an additional ~192 KB of relocations in the .init section,
i.e., one 24 byte entry for each absolute reference, which all need
to be processed at boot time.

Given how the struct kernel_symbol that describes each entry is
completely local to module.c (except for the references emitted
by EXPORT_SYMBOL() itself), we can easily modify it to contain
two 32-bit relative references instead. This reduces the size of
the __ksymtab section by 50% for all 64-bit architectures, and
gets rid of the runtime relocations entirely for architectures
implementing KASLR, either via standard PIE linking (arm64) or
using custom host tools (x86).

Note that the binary search involving __ksymtab contents relies
on each section being sorted by symbol name. This is implemented
based on the input section names, not the names in the ksymtab
entries, so this patch does not interfere with that.

Given that the use of place-relative relocations requires support
both in the toolchain and in the module loader, we cannot enable
this feature for all architectures. So make it dependend on whether
CONFIG_HAVE_ARCH_PREL32_RELOCATIONS is defined.

Cc: Jessica Yu <jeyu@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Thomas Garnier <thgarnie@google.com>
Cc: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 arch/x86/include/asm/Kbuild   |  1 +
 arch/x86/include/asm/export.h |  4 --
 include/asm-generic/export.h  | 12 +++++-
 include/linux/compiler.h      | 11 +++++
 include/linux/export.h        | 45 +++++++++++++++-----
 kernel/module.c               | 33 +++++++++++---
 6 files changed, 83 insertions(+), 23 deletions(-)

diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
index 5d6a53fd7521..3e8a88dcaa1d 100644
--- a/arch/x86/include/asm/Kbuild
+++ b/arch/x86/include/asm/Kbuild
@@ -9,5 +9,6 @@ generated-y += xen-hypercalls.h
 generic-y += clkdev.h
 generic-y += dma-contiguous.h
 generic-y += early_ioremap.h
+generic-y += export.h
 generic-y += mcs_spinlock.h
 generic-y += mm-arch-hooks.h
diff --git a/arch/x86/include/asm/export.h b/arch/x86/include/asm/export.h
deleted file mode 100644
index 138de56b13eb..000000000000
--- a/arch/x86/include/asm/export.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifdef CONFIG_64BIT
-#define KSYM_ALIGN 16
-#endif
-#include <asm-generic/export.h>
diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h
index 719db1968d81..97ce606459ae 100644
--- a/include/asm-generic/export.h
+++ b/include/asm-generic/export.h
@@ -5,12 +5,10 @@
 #define KSYM_FUNC(x) x
 #endif
 #ifdef CONFIG_64BIT
-#define __put .quad
 #ifndef KSYM_ALIGN
 #define KSYM_ALIGN 8
 #endif
 #else
-#define __put .long
 #ifndef KSYM_ALIGN
 #define KSYM_ALIGN 4
 #endif
@@ -25,6 +23,16 @@
 #define KSYM(name) name
 #endif
 
+.macro __put, val, name
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+	.long	\val - ., \name - .
+#elif defined(CONFIG_64BIT)
+	.quad	\val, \name
+#else
+	.long	\val, \name
+#endif
+.endm
+
 /*
  * note on .section use: @progbits vs %progbits nastiness doesn't matter,
  * since we immediately emit into those sections anyway.
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index eca8ad75e28b..363fb3e734ec 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -590,4 +590,15 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 	(_________p1); \
 })
 
+/*
+ * Force the compiler to emit 'sym' as a symbol, so that we can reference
+ * it from inline assembler. Necessary in case 'sym' could be inlined
+ * otherwise, or eliminated entirely due to lack of references that are
+ * visibile to the compiler.
+ */
+#define __ADDRESSABLE(sym) \
+	static void *__attribute__((section(".discard.text"), used))	\
+		__PASTE(__discard_##sym, __LINE__)(void)		\
+			{ return (void *)&sym; }			\
+
 #endif /* __LINUX_COMPILER_H */
diff --git a/include/linux/export.h b/include/linux/export.h
index 1a1dfdb2a5c6..156b974181a4 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -24,12 +24,6 @@
 #define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x)
 
 #ifndef __ASSEMBLY__
-struct kernel_symbol
-{
-	unsigned long value;
-	const char *name;
-};
-
 #ifdef MODULE
 extern struct module __this_module;
 #define THIS_MODULE (&__this_module)
@@ -60,17 +54,46 @@ extern struct module __this_module;
 #define __CRC_SYMBOL(sym, sec)
 #endif
 
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+/*
+ * Emit the ksymtab entry as a pair of relative references: this reduces
+ * the size by half on 64-bit architectures, and eliminates the need for
+ * absolute relocations that require runtime processing on relocatable
+ * kernels.
+ */
+#define __KSYMTAB_ENTRY(sym, sec)					\
+	__ADDRESSABLE(sym)						\
+	asm("	.section \"___ksymtab" sec "+" #sym "\", \"a\"	\n"	\
+	    "	.balign	8					\n"	\
+	    VMLINUX_SYMBOL_STR(__ksymtab_##sym) ":		\n"	\
+	    "	.long "	VMLINUX_SYMBOL_STR(sym) "- .		\n"	\
+	    "	.long "	VMLINUX_SYMBOL_STR(__kstrtab_##sym) "- .\n"	\
+	    "	.previous					\n")
+
+struct kernel_symbol {
+	signed int value_offset;
+	signed int name_offset;
+};
+#else
+#define __KSYMTAB_ENTRY(sym, sec)					\
+	static const struct kernel_symbol __ksymtab_##sym		\
+	__attribute__((section("___ksymtab" sec "+" #sym), used))	\
+	= { (unsigned long)&sym, __kstrtab_##sym }
+
+struct kernel_symbol {
+	unsigned long value;
+	const char *name;
+};
+#endif
+
 /* For every exported symbol, place a struct in the __ksymtab section */
 #define ___EXPORT_SYMBOL(sym, sec)					\
 	extern typeof(sym) sym;						\
 	__CRC_SYMBOL(sym, sec)						\
 	static const char __kstrtab_##sym[]				\
-	__attribute__((section("__ksymtab_strings"), aligned(1)))	\
+	__attribute__((section("__ksymtab_strings"), used, aligned(1)))	\
 	= VMLINUX_SYMBOL_STR(sym);					\
-	static const struct kernel_symbol __ksymtab_##sym		\
-	__used								\
-	__attribute__((section("___ksymtab" sec "+" #sym), used))	\
-	= { (unsigned long)&sym, __kstrtab_##sym }
+	__KSYMTAB_ENTRY(sym, sec)
 
 #if defined(__KSYM_DEPS__)
 
diff --git a/kernel/module.c b/kernel/module.c
index 40f983cbea81..a45423dcc32d 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -539,12 +539,31 @@ static bool check_symbol(const struct symsearch *syms,
 	return true;
 }
 
+static unsigned long kernel_symbol_value(const struct kernel_symbol *sym)
+{
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+	return (unsigned long)&sym->value_offset + sym->value_offset;
+#else
+	return sym->value;
+#endif
+}
+
+static const char *kernel_symbol_name(const struct kernel_symbol *sym)
+{
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+	return (const char *)((unsigned long)&sym->name_offset +
+			      sym->name_offset);
+#else
+	return sym->name;
+#endif
+}
+
 static int cmp_name(const void *va, const void *vb)
 {
 	const char *a;
 	const struct kernel_symbol *b;
 	a = va; b = vb;
-	return strcmp(a, b->name);
+	return strcmp(a, kernel_symbol_name(b));
 }
 
 static bool find_symbol_in_section(const struct symsearch *syms,
@@ -2190,7 +2209,7 @@ void *__symbol_get(const char *symbol)
 		sym = NULL;
 	preempt_enable();
 
-	return sym ? (void *)sym->value : NULL;
+	return sym ? (void *)kernel_symbol_value(sym) : NULL;
 }
 EXPORT_SYMBOL_GPL(__symbol_get);
 
@@ -2220,10 +2239,12 @@ static int verify_export_symbols(struct module *mod)
 
 	for (i = 0; i < ARRAY_SIZE(arr); i++) {
 		for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
-			if (find_symbol(s->name, &owner, NULL, true, false)) {
+			if (find_symbol(kernel_symbol_name(s), &owner, NULL,
+					true, false)) {
 				pr_err("%s: exports duplicate symbol %s"
 				       " (owned by %s)\n",
-				       mod->name, s->name, module_name(owner));
+				       mod->name, kernel_symbol_name(s),
+				       module_name(owner));
 				return -ENOEXEC;
 			}
 		}
@@ -2272,7 +2293,7 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
 			ksym = resolve_symbol_wait(mod, info, name);
 			/* Ok if resolved.  */
 			if (ksym && !IS_ERR(ksym)) {
-				sym[i].st_value = ksym->value;
+				sym[i].st_value = kernel_symbol_value(ksym);
 				break;
 			}
 
@@ -2532,7 +2553,7 @@ static int is_exported(const char *name, unsigned long value,
 		ks = lookup_symbol(name, __start___ksymtab, __stop___ksymtab);
 	else
 		ks = lookup_symbol(name, mod->syms, mod->syms + mod->num_syms);
-	return ks != NULL && ks->value == value;
+	return ks != NULL && kernel_symbol_value(ks) == value;
 }
 
 /* As per nm */
-- 
2.11.0

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

* [PATCH v3 2/5] module: use relative references for __ksymtab entries
@ 2017-08-19 18:10   ` Ard Biesheuvel
  0 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-19 18:10 UTC (permalink / raw)
  To: linux-kernel, linux-arch
  Cc: Ard Biesheuvel, H. Peter Anvin, Arnd Bergmann, Heiko Carstens,
	Kees Cook, Will Deacon, Michael Ellerman, Thomas Garnier,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt

An ordinary arm64 defconfig build has ~64 KB worth of __ksymtab
entries, each consisting of two 64-bit fields containing absolute
references, to the symbol itself and to a char array containing
its name, respectively.

When we build the same configuration with KASLR enabled, we end
up with an additional ~192 KB of relocations in the .init section,
i.e., one 24 byte entry for each absolute reference, which all need
to be processed at boot time.

Given how the struct kernel_symbol that describes each entry is
completely local to module.c (except for the references emitted
by EXPORT_SYMBOL() itself), we can easily modify it to contain
two 32-bit relative references instead. This reduces the size of
the __ksymtab section by 50% for all 64-bit architectures, and
gets rid of the runtime relocations entirely for architectures
implementing KASLR, either via standard PIE linking (arm64) or
using custom host tools (x86).

Note that the binary search involving __ksymtab contents relies
on each section being sorted by symbol name. This is implemented
based on the input section names, not the names in the ksymtab
entries, so this patch does not interfere with that.

Given that the use of place-relative relocations requires support
both in the toolchain and in the module loader, we cannot enable
this feature for all architectures. So make it dependend on whether
CONFIG_HAVE_ARCH_PREL32_RELOCATIONS is defined.

Cc: Jessica Yu <jeyu@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Thomas Garnier <thgarnie@google.com>
Cc: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 arch/x86/include/asm/Kbuild   |  1 +
 arch/x86/include/asm/export.h |  4 --
 include/asm-generic/export.h  | 12 +++++-
 include/linux/compiler.h      | 11 +++++
 include/linux/export.h        | 45 +++++++++++++++-----
 kernel/module.c               | 33 +++++++++++---
 6 files changed, 83 insertions(+), 23 deletions(-)

diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
index 5d6a53fd7521..3e8a88dcaa1d 100644
--- a/arch/x86/include/asm/Kbuild
+++ b/arch/x86/include/asm/Kbuild
@@ -9,5 +9,6 @@ generated-y += xen-hypercalls.h
 generic-y += clkdev.h
 generic-y += dma-contiguous.h
 generic-y += early_ioremap.h
+generic-y += export.h
 generic-y += mcs_spinlock.h
 generic-y += mm-arch-hooks.h
diff --git a/arch/x86/include/asm/export.h b/arch/x86/include/asm/export.h
deleted file mode 100644
index 138de56b13eb..000000000000
--- a/arch/x86/include/asm/export.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifdef CONFIG_64BIT
-#define KSYM_ALIGN 16
-#endif
-#include <asm-generic/export.h>
diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h
index 719db1968d81..97ce606459ae 100644
--- a/include/asm-generic/export.h
+++ b/include/asm-generic/export.h
@@ -5,12 +5,10 @@
 #define KSYM_FUNC(x) x
 #endif
 #ifdef CONFIG_64BIT
-#define __put .quad
 #ifndef KSYM_ALIGN
 #define KSYM_ALIGN 8
 #endif
 #else
-#define __put .long
 #ifndef KSYM_ALIGN
 #define KSYM_ALIGN 4
 #endif
@@ -25,6 +23,16 @@
 #define KSYM(name) name
 #endif
 
+.macro __put, val, name
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+	.long	\val - ., \name - .
+#elif defined(CONFIG_64BIT)
+	.quad	\val, \name
+#else
+	.long	\val, \name
+#endif
+.endm
+
 /*
  * note on .section use: @progbits vs %progbits nastiness doesn't matter,
  * since we immediately emit into those sections anyway.
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index eca8ad75e28b..363fb3e734ec 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -590,4 +590,15 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 	(_________p1); \
 })
 
+/*
+ * Force the compiler to emit 'sym' as a symbol, so that we can reference
+ * it from inline assembler. Necessary in case 'sym' could be inlined
+ * otherwise, or eliminated entirely due to lack of references that are
+ * visibile to the compiler.
+ */
+#define __ADDRESSABLE(sym) \
+	static void *__attribute__((section(".discard.text"), used))	\
+		__PASTE(__discard_##sym, __LINE__)(void)		\
+			{ return (void *)&sym; }			\
+
 #endif /* __LINUX_COMPILER_H */
diff --git a/include/linux/export.h b/include/linux/export.h
index 1a1dfdb2a5c6..156b974181a4 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -24,12 +24,6 @@
 #define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x)
 
 #ifndef __ASSEMBLY__
-struct kernel_symbol
-{
-	unsigned long value;
-	const char *name;
-};
-
 #ifdef MODULE
 extern struct module __this_module;
 #define THIS_MODULE (&__this_module)
@@ -60,17 +54,46 @@ extern struct module __this_module;
 #define __CRC_SYMBOL(sym, sec)
 #endif
 
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+/*
+ * Emit the ksymtab entry as a pair of relative references: this reduces
+ * the size by half on 64-bit architectures, and eliminates the need for
+ * absolute relocations that require runtime processing on relocatable
+ * kernels.
+ */
+#define __KSYMTAB_ENTRY(sym, sec)					\
+	__ADDRESSABLE(sym)						\
+	asm("	.section \"___ksymtab" sec "+" #sym "\", \"a\"	\n"	\
+	    "	.balign	8					\n"	\
+	    VMLINUX_SYMBOL_STR(__ksymtab_##sym) ":		\n"	\
+	    "	.long "	VMLINUX_SYMBOL_STR(sym) "- .		\n"	\
+	    "	.long "	VMLINUX_SYMBOL_STR(__kstrtab_##sym) "- .\n"	\
+	    "	.previous					\n")
+
+struct kernel_symbol {
+	signed int value_offset;
+	signed int name_offset;
+};
+#else
+#define __KSYMTAB_ENTRY(sym, sec)					\
+	static const struct kernel_symbol __ksymtab_##sym		\
+	__attribute__((section("___ksymtab" sec "+" #sym), used))	\
+	= { (unsigned long)&sym, __kstrtab_##sym }
+
+struct kernel_symbol {
+	unsigned long value;
+	const char *name;
+};
+#endif
+
 /* For every exported symbol, place a struct in the __ksymtab section */
 #define ___EXPORT_SYMBOL(sym, sec)					\
 	extern typeof(sym) sym;						\
 	__CRC_SYMBOL(sym, sec)						\
 	static const char __kstrtab_##sym[]				\
-	__attribute__((section("__ksymtab_strings"), aligned(1)))	\
+	__attribute__((section("__ksymtab_strings"), used, aligned(1)))	\
 	= VMLINUX_SYMBOL_STR(sym);					\
-	static const struct kernel_symbol __ksymtab_##sym		\
-	__used								\
-	__attribute__((section("___ksymtab" sec "+" #sym), used))	\
-	= { (unsigned long)&sym, __kstrtab_##sym }
+	__KSYMTAB_ENTRY(sym, sec)
 
 #if defined(__KSYM_DEPS__)
 
diff --git a/kernel/module.c b/kernel/module.c
index 40f983cbea81..a45423dcc32d 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -539,12 +539,31 @@ static bool check_symbol(const struct symsearch *syms,
 	return true;
 }
 
+static unsigned long kernel_symbol_value(const struct kernel_symbol *sym)
+{
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+	return (unsigned long)&sym->value_offset + sym->value_offset;
+#else
+	return sym->value;
+#endif
+}
+
+static const char *kernel_symbol_name(const struct kernel_symbol *sym)
+{
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+	return (const char *)((unsigned long)&sym->name_offset +
+			      sym->name_offset);
+#else
+	return sym->name;
+#endif
+}
+
 static int cmp_name(const void *va, const void *vb)
 {
 	const char *a;
 	const struct kernel_symbol *b;
 	a = va; b = vb;
-	return strcmp(a, b->name);
+	return strcmp(a, kernel_symbol_name(b));
 }
 
 static bool find_symbol_in_section(const struct symsearch *syms,
@@ -2190,7 +2209,7 @@ void *__symbol_get(const char *symbol)
 		sym = NULL;
 	preempt_enable();
 
-	return sym ? (void *)sym->value : NULL;
+	return sym ? (void *)kernel_symbol_value(sym) : NULL;
 }
 EXPORT_SYMBOL_GPL(__symbol_get);
 
@@ -2220,10 +2239,12 @@ static int verify_export_symbols(struct module *mod)
 
 	for (i = 0; i < ARRAY_SIZE(arr); i++) {
 		for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
-			if (find_symbol(s->name, &owner, NULL, true, false)) {
+			if (find_symbol(kernel_symbol_name(s), &owner, NULL,
+					true, false)) {
 				pr_err("%s: exports duplicate symbol %s"
 				       " (owned by %s)\n",
-				       mod->name, s->name, module_name(owner));
+				       mod->name, kernel_symbol_name(s),
+				       module_name(owner));
 				return -ENOEXEC;
 			}
 		}
@@ -2272,7 +2293,7 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
 			ksym = resolve_symbol_wait(mod, info, name);
 			/* Ok if resolved.  */
 			if (ksym && !IS_ERR(ksym)) {
-				sym[i].st_value = ksym->value;
+				sym[i].st_value = kernel_symbol_value(ksym);
 				break;
 			}
 
@@ -2532,7 +2553,7 @@ static int is_exported(const char *name, unsigned long value,
 		ks = lookup_symbol(name, __start___ksymtab, __stop___ksymtab);
 	else
 		ks = lookup_symbol(name, mod->syms, mod->syms + mod->num_syms);
-	return ks != NULL && ks->value == value;
+	return ks != NULL && kernel_symbol_value(ks) == value;
 }
 
 /* As per nm */
-- 
2.11.0

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

* [PATCH v3 3/5] init: allow initcall tables to be emitted using relative references
  2017-08-19 18:10 ` Ard Biesheuvel
@ 2017-08-19 18:10   ` Ard Biesheuvel
  -1 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-19 18:10 UTC (permalink / raw)
  To: linux-kernel, linux-arch
  Cc: Ard Biesheuvel, H. Peter Anvin, Arnd Bergmann, Heiko Carstens,
	Kees Cook, Will Deacon, Michael Ellerman, Thomas Garnier,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt, Martin Schwidefsky,
	Sergey Senozhatsky, Linus Torvalds, Jessica Yu

Allow the initcall tables to be emitted using relative references that
are only half the size on 64-bit architectures and don't require fixups
at runtime on relocatable kernels.

Cc: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: James Morris <james.l.morris@oracle.com>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 include/linux/init.h   | 44 +++++++++++++++-----
 init/main.c            | 32 +++++++-------
 kernel/printk/printk.c |  4 +-
 security/security.c    |  4 +-
 4 files changed, 53 insertions(+), 31 deletions(-)

diff --git a/include/linux/init.h b/include/linux/init.h
index 94769d687cf0..e816dfdbbd21 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -110,8 +110,24 @@
 typedef int (*initcall_t)(void);
 typedef void (*exitcall_t)(void);
 
-extern initcall_t __con_initcall_start[], __con_initcall_end[];
-extern initcall_t __security_initcall_start[], __security_initcall_end[];
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+typedef signed int initcall_entry_t;
+
+static inline initcall_t initcall_from_entry(initcall_entry_t *entry)
+{
+	return (initcall_t)((unsigned long)entry + *entry);
+}
+#else
+typedef initcall_t initcall_entry_t;
+
+static inline initcall_t initcall_from_entry(initcall_entry_t *entry)
+{
+	return *entry;
+}
+#endif
+
+extern initcall_entry_t __con_initcall_start[], __con_initcall_end[];
+extern initcall_entry_t __security_initcall_start[], __security_initcall_end[];
 
 /* Used for contructor calls. */
 typedef void (*ctor_fn_t)(void);
@@ -161,9 +177,20 @@ extern bool initcall_debug;
  * as KEEP() in the linker script.
  */
 
-#define __define_initcall(fn, id) \
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+#define ___define_initcall(fn, id, __sec)			\
+	__ADDRESSABLE(fn)					\
+	asm(".section	\"" #__sec ".init\", \"a\"	\n"	\
+	"__initcall_" #fn #id ":			\n"	\
+	    ".long "	VMLINUX_SYMBOL_STR(fn) " - .	\n"	\
+	    ".previous					\n");
+#else
+#define ___define_initcall(fn, id, __sec) \
 	static initcall_t __initcall_##fn##id __used \
-	__attribute__((__section__(".initcall" #id ".init"))) = fn;
+		__attribute__((__section__(#__sec ".init"))) = fn;
+#endif
+
+#define __define_initcall(fn, id) ___define_initcall(fn, id, .initcall##id)
 
 /*
  * Early initcalls run before initializing SMP.
@@ -202,13 +229,8 @@ extern bool initcall_debug;
 #define __exitcall(fn)						\
 	static exitcall_t __exitcall_##fn __exit_call = fn
 
-#define console_initcall(fn)					\
-	static initcall_t __initcall_##fn			\
-	__used __section(.con_initcall.init) = fn
-
-#define security_initcall(fn)					\
-	static initcall_t __initcall_##fn			\
-	__used __section(.security_initcall.init) = fn
+#define console_initcall(fn)	___define_initcall(fn,, .con_initcall)
+#define security_initcall(fn)	___define_initcall(fn,, .security_initcall)
 
 struct obs_kernel_param {
 	const char *str;
diff --git a/init/main.c b/init/main.c
index 052481fbe363..ac2a91f71107 100644
--- a/init/main.c
+++ b/init/main.c
@@ -833,18 +833,18 @@ int __init_or_module do_one_initcall(initcall_t fn)
 }
 
 
-extern initcall_t __initcall_start[];
-extern initcall_t __initcall0_start[];
-extern initcall_t __initcall1_start[];
-extern initcall_t __initcall2_start[];
-extern initcall_t __initcall3_start[];
-extern initcall_t __initcall4_start[];
-extern initcall_t __initcall5_start[];
-extern initcall_t __initcall6_start[];
-extern initcall_t __initcall7_start[];
-extern initcall_t __initcall_end[];
-
-static initcall_t *initcall_levels[] __initdata = {
+extern initcall_entry_t __initcall_start[];
+extern initcall_entry_t __initcall0_start[];
+extern initcall_entry_t __initcall1_start[];
+extern initcall_entry_t __initcall2_start[];
+extern initcall_entry_t __initcall3_start[];
+extern initcall_entry_t __initcall4_start[];
+extern initcall_entry_t __initcall5_start[];
+extern initcall_entry_t __initcall6_start[];
+extern initcall_entry_t __initcall7_start[];
+extern initcall_entry_t __initcall_end[];
+
+static initcall_entry_t *initcall_levels[] __initdata = {
 	__initcall0_start,
 	__initcall1_start,
 	__initcall2_start,
@@ -870,7 +870,7 @@ static char *initcall_level_names[] __initdata = {
 
 static void __init do_initcall_level(int level)
 {
-	initcall_t *fn;
+	initcall_entry_t *fn;
 
 	strcpy(initcall_command_line, saved_command_line);
 	parse_args(initcall_level_names[level],
@@ -880,7 +880,7 @@ static void __init do_initcall_level(int level)
 		   NULL, &repair_env_string);
 
 	for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
-		do_one_initcall(*fn);
+		do_one_initcall(initcall_from_entry(fn));
 }
 
 static void __init do_initcalls(void)
@@ -911,10 +911,10 @@ static void __init do_basic_setup(void)
 
 static void __init do_pre_smp_initcalls(void)
 {
-	initcall_t *fn;
+	initcall_entry_t *fn;
 
 	for (fn = __initcall_start; fn < __initcall0_start; fn++)
-		do_one_initcall(*fn);
+		do_one_initcall(initcall_from_entry(fn));
 }
 
 /*
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index fc47863f629c..39d343c1c4b2 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2623,7 +2623,7 @@ EXPORT_SYMBOL(unregister_console);
  */
 void __init console_init(void)
 {
-	initcall_t *call;
+	initcall_entry_t *call;
 
 	/* Setup the default TTY line discipline. */
 	n_tty_init();
@@ -2634,7 +2634,7 @@ void __init console_init(void)
 	 */
 	call = __con_initcall_start;
 	while (call < __con_initcall_end) {
-		(*call)();
+		initcall_from_entry(call)();
 		call++;
 	}
 }
diff --git a/security/security.c b/security/security.c
index 30132378d103..63b5f52bb098 100644
--- a/security/security.c
+++ b/security/security.c
@@ -44,10 +44,10 @@ static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
 
 static void __init do_security_initcalls(void)
 {
-	initcall_t *call;
+	initcall_entry_t *call;
 	call = __security_initcall_start;
 	while (call < __security_initcall_end) {
-		(*call) ();
+		initcall_from_entry(call)();
 		call++;
 	}
 }
-- 
2.11.0

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

* [PATCH v3 3/5] init: allow initcall tables to be emitted using relative references
@ 2017-08-19 18:10   ` Ard Biesheuvel
  0 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-19 18:10 UTC (permalink / raw)
  To: linux-kernel, linux-arch
  Cc: Ard Biesheuvel, H. Peter Anvin, Arnd Bergmann, Heiko Carstens,
	Kees Cook, Will Deacon, Michael Ellerman, Thomas Garnier,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt

Allow the initcall tables to be emitted using relative references that
are only half the size on 64-bit architectures and don't require fixups
at runtime on relocatable kernels.

Cc: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: James Morris <james.l.morris@oracle.com>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 include/linux/init.h   | 44 +++++++++++++++-----
 init/main.c            | 32 +++++++-------
 kernel/printk/printk.c |  4 +-
 security/security.c    |  4 +-
 4 files changed, 53 insertions(+), 31 deletions(-)

diff --git a/include/linux/init.h b/include/linux/init.h
index 94769d687cf0..e816dfdbbd21 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -110,8 +110,24 @@
 typedef int (*initcall_t)(void);
 typedef void (*exitcall_t)(void);
 
-extern initcall_t __con_initcall_start[], __con_initcall_end[];
-extern initcall_t __security_initcall_start[], __security_initcall_end[];
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+typedef signed int initcall_entry_t;
+
+static inline initcall_t initcall_from_entry(initcall_entry_t *entry)
+{
+	return (initcall_t)((unsigned long)entry + *entry);
+}
+#else
+typedef initcall_t initcall_entry_t;
+
+static inline initcall_t initcall_from_entry(initcall_entry_t *entry)
+{
+	return *entry;
+}
+#endif
+
+extern initcall_entry_t __con_initcall_start[], __con_initcall_end[];
+extern initcall_entry_t __security_initcall_start[], __security_initcall_end[];
 
 /* Used for contructor calls. */
 typedef void (*ctor_fn_t)(void);
@@ -161,9 +177,20 @@ extern bool initcall_debug;
  * as KEEP() in the linker script.
  */
 
-#define __define_initcall(fn, id) \
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+#define ___define_initcall(fn, id, __sec)			\
+	__ADDRESSABLE(fn)					\
+	asm(".section	\"" #__sec ".init\", \"a\"	\n"	\
+	"__initcall_" #fn #id ":			\n"	\
+	    ".long "	VMLINUX_SYMBOL_STR(fn) " - .	\n"	\
+	    ".previous					\n");
+#else
+#define ___define_initcall(fn, id, __sec) \
 	static initcall_t __initcall_##fn##id __used \
-	__attribute__((__section__(".initcall" #id ".init"))) = fn;
+		__attribute__((__section__(#__sec ".init"))) = fn;
+#endif
+
+#define __define_initcall(fn, id) ___define_initcall(fn, id, .initcall##id)
 
 /*
  * Early initcalls run before initializing SMP.
@@ -202,13 +229,8 @@ extern bool initcall_debug;
 #define __exitcall(fn)						\
 	static exitcall_t __exitcall_##fn __exit_call = fn
 
-#define console_initcall(fn)					\
-	static initcall_t __initcall_##fn			\
-	__used __section(.con_initcall.init) = fn
-
-#define security_initcall(fn)					\
-	static initcall_t __initcall_##fn			\
-	__used __section(.security_initcall.init) = fn
+#define console_initcall(fn)	___define_initcall(fn,, .con_initcall)
+#define security_initcall(fn)	___define_initcall(fn,, .security_initcall)
 
 struct obs_kernel_param {
 	const char *str;
diff --git a/init/main.c b/init/main.c
index 052481fbe363..ac2a91f71107 100644
--- a/init/main.c
+++ b/init/main.c
@@ -833,18 +833,18 @@ int __init_or_module do_one_initcall(initcall_t fn)
 }
 
 
-extern initcall_t __initcall_start[];
-extern initcall_t __initcall0_start[];
-extern initcall_t __initcall1_start[];
-extern initcall_t __initcall2_start[];
-extern initcall_t __initcall3_start[];
-extern initcall_t __initcall4_start[];
-extern initcall_t __initcall5_start[];
-extern initcall_t __initcall6_start[];
-extern initcall_t __initcall7_start[];
-extern initcall_t __initcall_end[];
-
-static initcall_t *initcall_levels[] __initdata = {
+extern initcall_entry_t __initcall_start[];
+extern initcall_entry_t __initcall0_start[];
+extern initcall_entry_t __initcall1_start[];
+extern initcall_entry_t __initcall2_start[];
+extern initcall_entry_t __initcall3_start[];
+extern initcall_entry_t __initcall4_start[];
+extern initcall_entry_t __initcall5_start[];
+extern initcall_entry_t __initcall6_start[];
+extern initcall_entry_t __initcall7_start[];
+extern initcall_entry_t __initcall_end[];
+
+static initcall_entry_t *initcall_levels[] __initdata = {
 	__initcall0_start,
 	__initcall1_start,
 	__initcall2_start,
@@ -870,7 +870,7 @@ static char *initcall_level_names[] __initdata = {
 
 static void __init do_initcall_level(int level)
 {
-	initcall_t *fn;
+	initcall_entry_t *fn;
 
 	strcpy(initcall_command_line, saved_command_line);
 	parse_args(initcall_level_names[level],
@@ -880,7 +880,7 @@ static void __init do_initcall_level(int level)
 		   NULL, &repair_env_string);
 
 	for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
-		do_one_initcall(*fn);
+		do_one_initcall(initcall_from_entry(fn));
 }
 
 static void __init do_initcalls(void)
@@ -911,10 +911,10 @@ static void __init do_basic_setup(void)
 
 static void __init do_pre_smp_initcalls(void)
 {
-	initcall_t *fn;
+	initcall_entry_t *fn;
 
 	for (fn = __initcall_start; fn < __initcall0_start; fn++)
-		do_one_initcall(*fn);
+		do_one_initcall(initcall_from_entry(fn));
 }
 
 /*
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index fc47863f629c..39d343c1c4b2 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2623,7 +2623,7 @@ EXPORT_SYMBOL(unregister_console);
  */
 void __init console_init(void)
 {
-	initcall_t *call;
+	initcall_entry_t *call;
 
 	/* Setup the default TTY line discipline. */
 	n_tty_init();
@@ -2634,7 +2634,7 @@ void __init console_init(void)
 	 */
 	call = __con_initcall_start;
 	while (call < __con_initcall_end) {
-		(*call)();
+		initcall_from_entry(call)();
 		call++;
 	}
 }
diff --git a/security/security.c b/security/security.c
index 30132378d103..63b5f52bb098 100644
--- a/security/security.c
+++ b/security/security.c
@@ -44,10 +44,10 @@ static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
 
 static void __init do_security_initcalls(void)
 {
-	initcall_t *call;
+	initcall_entry_t *call;
 	call = __security_initcall_start;
 	while (call < __security_initcall_end) {
-		(*call) ();
+		initcall_from_entry(call)();
 		call++;
 	}
 }
-- 
2.11.0

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

* [PATCH v3 4/5] drivers: pci: add support for relative addressing in quirk tables
  2017-08-19 18:10 ` Ard Biesheuvel
@ 2017-08-19 18:10   ` Ard Biesheuvel
  -1 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-19 18:10 UTC (permalink / raw)
  To: linux-kernel, linux-arch
  Cc: Ard Biesheuvel, H. Peter Anvin, Arnd Bergmann, Heiko Carstens,
	Kees Cook, Will Deacon, Michael Ellerman, Thomas Garnier,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt, Martin Schwidefsky,
	Sergey Senozhatsky, Linus Torvalds, Jessica Yu

Allow the PCI quirk tables to be emitted in a way that avoids absolute
references to the hook functions. This reduces the size of the entries,
and, more importantly, makes them invariant under runtime relocation
(e.g., for KASLR)

Cc: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 drivers/pci/quirks.c | 13 ++++++++++---
 include/linux/pci.h  | 20 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 6967c6b4cf6b..10126612e342 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3547,9 +3547,16 @@ static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
 		     f->vendor == (u16) PCI_ANY_ID) &&
 		    (f->device == dev->device ||
 		     f->device == (u16) PCI_ANY_ID)) {
-			calltime = fixup_debug_start(dev, f->hook);
-			f->hook(dev);
-			fixup_debug_report(dev, calltime, f->hook);
+			void (*hook)(struct pci_dev *dev);
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+			hook = (void *)((unsigned long)&f->hook_offset +
+					f->hook_offset);
+#else
+			hook = f->hook;
+#endif
+			calltime = fixup_debug_start(dev, hook);
+			hook(dev);
+			fixup_debug_report(dev, calltime, hook);
 		}
 }
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index a75c13673852..dd3523c1afbb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1735,7 +1735,11 @@ struct pci_fixup {
 	u16 device;		/* You can use PCI_ANY_ID here of course */
 	u32 class;		/* You can use PCI_ANY_ID here too */
 	unsigned int class_shift;	/* should be 0, 8, 16 */
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+	signed int hook_offset;
+#else
 	void (*hook)(struct pci_dev *dev);
+#endif
 };
 
 enum pci_fixup_pass {
@@ -1749,12 +1753,28 @@ enum pci_fixup_pass {
 	pci_fixup_suspend_late,	/* pci_device_suspend_late() */
 };
 
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+#define __DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class,	\
+				    class_shift, hook)			\
+	__ADDRESSABLE(hook)						\
+	asm(".section "	#sec ", \"a\"				\n"	\
+	    ".balign	16					\n"	\
+	    ".short "	#vendor ", " #device "			\n"	\
+	    ".long "	#class ", " #class_shift "		\n"	\
+	    ".long "	VMLINUX_SYMBOL_STR(hook) " - .		\n"	\
+	    ".previous						\n");
+#define DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class,	\
+				  class_shift, hook)			\
+	__DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class,	\
+				  class_shift, hook)
+#else
 /* Anonymous variables would be nice... */
 #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class,	\
 				  class_shift, hook)			\
 	static const struct pci_fixup __PASTE(__pci_fixup_##name,__LINE__) __used	\
 	__attribute__((__section__(#section), aligned((sizeof(void *)))))    \
 		= { vendor, device, class, class_shift, hook };
+#endif
 
 #define DECLARE_PCI_FIXUP_CLASS_EARLY(vendor, device, class,		\
 					 class_shift, hook)		\
-- 
2.11.0

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

* [PATCH v3 4/5] drivers: pci: add support for relative addressing in quirk tables
@ 2017-08-19 18:10   ` Ard Biesheuvel
  0 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-19 18:10 UTC (permalink / raw)
  To: linux-kernel, linux-arch
  Cc: Ard Biesheuvel, H. Peter Anvin, Arnd Bergmann, Heiko Carstens,
	Kees Cook, Will Deacon, Michael Ellerman, Thomas Garnier,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt

Allow the PCI quirk tables to be emitted in a way that avoids absolute
references to the hook functions. This reduces the size of the entries,
and, more importantly, makes them invariant under runtime relocation
(e.g., for KASLR)

Cc: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 drivers/pci/quirks.c | 13 ++++++++++---
 include/linux/pci.h  | 20 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 6967c6b4cf6b..10126612e342 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3547,9 +3547,16 @@ static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
 		     f->vendor == (u16) PCI_ANY_ID) &&
 		    (f->device == dev->device ||
 		     f->device == (u16) PCI_ANY_ID)) {
-			calltime = fixup_debug_start(dev, f->hook);
-			f->hook(dev);
-			fixup_debug_report(dev, calltime, f->hook);
+			void (*hook)(struct pci_dev *dev);
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+			hook = (void *)((unsigned long)&f->hook_offset +
+					f->hook_offset);
+#else
+			hook = f->hook;
+#endif
+			calltime = fixup_debug_start(dev, hook);
+			hook(dev);
+			fixup_debug_report(dev, calltime, hook);
 		}
 }
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index a75c13673852..dd3523c1afbb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1735,7 +1735,11 @@ struct pci_fixup {
 	u16 device;		/* You can use PCI_ANY_ID here of course */
 	u32 class;		/* You can use PCI_ANY_ID here too */
 	unsigned int class_shift;	/* should be 0, 8, 16 */
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+	signed int hook_offset;
+#else
 	void (*hook)(struct pci_dev *dev);
+#endif
 };
 
 enum pci_fixup_pass {
@@ -1749,12 +1753,28 @@ enum pci_fixup_pass {
 	pci_fixup_suspend_late,	/* pci_device_suspend_late() */
 };
 
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+#define __DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class,	\
+				    class_shift, hook)			\
+	__ADDRESSABLE(hook)						\
+	asm(".section "	#sec ", \"a\"				\n"	\
+	    ".balign	16					\n"	\
+	    ".short "	#vendor ", " #device "			\n"	\
+	    ".long "	#class ", " #class_shift "		\n"	\
+	    ".long "	VMLINUX_SYMBOL_STR(hook) " - .		\n"	\
+	    ".previous						\n");
+#define DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class,	\
+				  class_shift, hook)			\
+	__DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class,	\
+				  class_shift, hook)
+#else
 /* Anonymous variables would be nice... */
 #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class,	\
 				  class_shift, hook)			\
 	static const struct pci_fixup __PASTE(__pci_fixup_##name,__LINE__) __used	\
 	__attribute__((__section__(#section), aligned((sizeof(void *)))))    \
 		= { vendor, device, class, class_shift, hook };
+#endif
 
 #define DECLARE_PCI_FIXUP_CLASS_EARLY(vendor, device, class,		\
 					 class_shift, hook)		\
-- 
2.11.0

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

* [PATCH v3 5/5] kernel: tracepoints: add support for relative references
  2017-08-19 18:10 ` Ard Biesheuvel
@ 2017-08-19 18:10   ` Ard Biesheuvel
  -1 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-19 18:10 UTC (permalink / raw)
  To: linux-kernel, linux-arch
  Cc: Ard Biesheuvel, H. Peter Anvin, Arnd Bergmann, Heiko Carstens,
	Kees Cook, Will Deacon, Michael Ellerman, Thomas Garnier,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt, Martin Schwidefsky,
	Sergey Senozhatsky, Linus Torvalds, Jessica Yu

To avoid the need for relocating absolute references to tracepoint
structures at boot time when running relocatable kernels (which may
take a disproportionate amount of space), add the option to emit
these tables as relative references instead.

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 include/linux/tracepoint.h | 19 +++++++++++++++----
 kernel/tracepoint.c        | 17 +++++++++++++----
 2 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index a26ffbe09e71..d02bf1a695e8 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -228,6 +228,19 @@ extern void syscall_unregfunc(void);
 		return static_key_false(&__tracepoint_##name.key);	\
 	}
 
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+#define __TRACEPOINT_ENTRY(name)					 \
+	asm("	.section \"__tracepoints_ptrs\", \"a\"		     \n" \
+	    "	.balign 4					     \n" \
+	    "	.long " VMLINUX_SYMBOL_STR(__tracepoint_##name) " - .\n" \
+	    "	.previous					     \n")
+#else
+#define __TRACEPOINT_ENTRY(name)					 \
+	static struct tracepoint * const __tracepoint_ptr_##name __used	 \
+	__attribute__((section("__tracepoints_ptrs"))) =		 \
+		&__tracepoint_##name
+#endif
+
 /*
  * We have no guarantee that gcc and the linker won't up-align the tracepoint
  * structures, so we create an array of pointers that will be used for iteration
@@ -237,11 +250,9 @@ extern void syscall_unregfunc(void);
 	static const char __tpstrtab_##name[]				 \
 	__attribute__((section("__tracepoints_strings"))) = #name;	 \
 	struct tracepoint __tracepoint_##name				 \
-	__attribute__((section("__tracepoints"))) =			 \
+	__attribute__((section("__tracepoints"), used)) =		 \
 		{ __tpstrtab_##name, STATIC_KEY_INIT_FALSE, reg, unreg, NULL };\
-	static struct tracepoint * const __tracepoint_ptr_##name __used	 \
-	__attribute__((section("__tracepoints_ptrs"))) =		 \
-		&__tracepoint_##name;
+	__TRACEPOINT_ENTRY(name);
 
 #define DEFINE_TRACE(name)						\
 	DEFINE_TRACE_FN(name, NULL, NULL);
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 685c50ae6300..68b0218ef66b 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -508,12 +508,21 @@ static void for_each_tracepoint_range(struct tracepoint * const *begin,
 		void (*fct)(struct tracepoint *tp, void *priv),
 		void *priv)
 {
-	struct tracepoint * const *iter;
-
 	if (!begin)
 		return;
-	for (iter = begin; iter < end; iter++)
-		fct(*iter, priv);
+
+	if (IS_ENABLED(CONFIG_HAVE_ARCH_PREL32_RELOCATIONS)) {
+		const int *iter;
+
+		for (iter = (const int *)begin; iter < (const int *)end; iter++)
+			fct((struct tracepoint *)((unsigned long)iter + *iter),
+			    priv);
+	} else {
+		struct tracepoint * const *iter;
+
+		for (iter = begin; iter < end; iter++)
+			fct(*iter, priv);
+	}
 }
 
 /**
-- 
2.11.0

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

* [PATCH v3 5/5] kernel: tracepoints: add support for relative references
@ 2017-08-19 18:10   ` Ard Biesheuvel
  0 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-19 18:10 UTC (permalink / raw)
  To: linux-kernel, linux-arch
  Cc: Ard Biesheuvel, H. Peter Anvin, Arnd Bergmann, Heiko Carstens,
	Kees Cook, Will Deacon, Michael Ellerman, Thomas Garnier,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt

To avoid the need for relocating absolute references to tracepoint
structures at boot time when running relocatable kernels (which may
take a disproportionate amount of space), add the option to emit
these tables as relative references instead.

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 include/linux/tracepoint.h | 19 +++++++++++++++----
 kernel/tracepoint.c        | 17 +++++++++++++----
 2 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index a26ffbe09e71..d02bf1a695e8 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -228,6 +228,19 @@ extern void syscall_unregfunc(void);
 		return static_key_false(&__tracepoint_##name.key);	\
 	}
 
+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
+#define __TRACEPOINT_ENTRY(name)					 \
+	asm("	.section \"__tracepoints_ptrs\", \"a\"		     \n" \
+	    "	.balign 4					     \n" \
+	    "	.long " VMLINUX_SYMBOL_STR(__tracepoint_##name) " - .\n" \
+	    "	.previous					     \n")
+#else
+#define __TRACEPOINT_ENTRY(name)					 \
+	static struct tracepoint * const __tracepoint_ptr_##name __used	 \
+	__attribute__((section("__tracepoints_ptrs"))) =		 \
+		&__tracepoint_##name
+#endif
+
 /*
  * We have no guarantee that gcc and the linker won't up-align the tracepoint
  * structures, so we create an array of pointers that will be used for iteration
@@ -237,11 +250,9 @@ extern void syscall_unregfunc(void);
 	static const char __tpstrtab_##name[]				 \
 	__attribute__((section("__tracepoints_strings"))) = #name;	 \
 	struct tracepoint __tracepoint_##name				 \
-	__attribute__((section("__tracepoints"))) =			 \
+	__attribute__((section("__tracepoints"), used)) =		 \
 		{ __tpstrtab_##name, STATIC_KEY_INIT_FALSE, reg, unreg, NULL };\
-	static struct tracepoint * const __tracepoint_ptr_##name __used	 \
-	__attribute__((section("__tracepoints_ptrs"))) =		 \
-		&__tracepoint_##name;
+	__TRACEPOINT_ENTRY(name);
 
 #define DEFINE_TRACE(name)						\
 	DEFINE_TRACE_FN(name, NULL, NULL);
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 685c50ae6300..68b0218ef66b 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -508,12 +508,21 @@ static void for_each_tracepoint_range(struct tracepoint * const *begin,
 		void (*fct)(struct tracepoint *tp, void *priv),
 		void *priv)
 {
-	struct tracepoint * const *iter;
-
 	if (!begin)
 		return;
-	for (iter = begin; iter < end; iter++)
-		fct(*iter, priv);
+
+	if (IS_ENABLED(CONFIG_HAVE_ARCH_PREL32_RELOCATIONS)) {
+		const int *iter;
+
+		for (iter = (const int *)begin; iter < (const int *)end; iter++)
+			fct((struct tracepoint *)((unsigned long)iter + *iter),
+			    priv);
+	} else {
+		struct tracepoint * const *iter;
+
+		for (iter = begin; iter < end; iter++)
+			fct(*iter, priv);
+	}
 }
 
 /**
-- 
2.11.0

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

* Re: [PATCH v3 5/5] kernel: tracepoints: add support for relative references
  2017-08-19 18:10   ` Ard Biesheuvel
@ 2017-08-20 14:51     ` Steven Rostedt
  -1 siblings, 0 replies; 38+ messages in thread
From: Steven Rostedt @ 2017-08-20 14:51 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Martin Schwidefsky, Sergey Senozhatsky,
	Linus Torvalds, Jessica Yu

On Sat, 19 Aug 2017 19:10:35 +0100
Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

> To avoid the need for relocating absolute references to tracepoint
> structures at boot time when running relocatable kernels (which may
> take a disproportionate amount of space), add the option to emit
> these tables as relative references instead.
> 

This patch looks fine. But I want to test the series before giving it
my Acked-by. I wont be able to do that till Tuesday at the earliest.

-- Steve

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

* Re: [PATCH v3 5/5] kernel: tracepoints: add support for relative references
@ 2017-08-20 14:51     ` Steven Rostedt
  0 siblings, 0 replies; 38+ messages in thread
From: Steven Rostedt @ 2017-08-20 14:51 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre

On Sat, 19 Aug 2017 19:10:35 +0100
Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

> To avoid the need for relocating absolute references to tracepoint
> structures at boot time when running relocatable kernels (which may
> take a disproportionate amount of space), add the option to emit
> these tables as relative references instead.
> 

This patch looks fine. But I want to test the series before giving it
my Acked-by. I wont be able to do that till Tuesday at the earliest.

-- Steve

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

* Re: [PATCH v3 5/5] kernel: tracepoints: add support for relative references
  2017-08-20 14:51     ` Steven Rostedt
@ 2017-08-30 12:52       ` Ard Biesheuvel
  -1 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-30 12:52 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Martin Schwidefsky, Sergey Senozhatsky,
	Linus Torvalds, Jessica Yu

On 20 August 2017 at 15:51, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Sat, 19 Aug 2017 19:10:35 +0100
> Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
>> To avoid the need for relocating absolute references to tracepoint
>> structures at boot time when running relocatable kernels (which may
>> take a disproportionate amount of space), add the option to emit
>> these tables as relative references instead.
>>
>
> This patch looks fine. But I want to test the series before giving it
> my Acked-by. I wont be able to do that till Tuesday at the earliest.
>

I guess this has slipped between the cracks?

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

* Re: [PATCH v3 5/5] kernel: tracepoints: add support for relative references
@ 2017-08-30 12:52       ` Ard Biesheuvel
  0 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-30 12:52 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton

On 20 August 2017 at 15:51, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Sat, 19 Aug 2017 19:10:35 +0100
> Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
>> To avoid the need for relocating absolute references to tracepoint
>> structures at boot time when running relocatable kernels (which may
>> take a disproportionate amount of space), add the option to emit
>> these tables as relative references instead.
>>
>
> This patch looks fine. But I want to test the series before giving it
> my Acked-by. I wont be able to do that till Tuesday at the earliest.
>

I guess this has slipped between the cracks?

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

* Re: [PATCH v3 5/5] kernel: tracepoints: add support for relative references
  2017-08-30 12:52       ` Ard Biesheuvel
@ 2017-08-30 13:17         ` Steven Rostedt
  -1 siblings, 0 replies; 38+ messages in thread
From: Steven Rostedt @ 2017-08-30 13:17 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Martin Schwidefsky, Sergey Senozhatsky,
	Linus Torvalds, Jessica Yu

On Wed, 30 Aug 2017 13:52:26 +0100
Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

> On 20 August 2017 at 15:51, Steven Rostedt <rostedt@goodmis.org> wrote:
> > On Sat, 19 Aug 2017 19:10:35 +0100
> > Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> >  
> >> To avoid the need for relocating absolute references to tracepoint
> >> structures at boot time when running relocatable kernels (which may
> >> take a disproportionate amount of space), add the option to emit
> >> these tables as relative references instead.
> >>  
> >
> > This patch looks fine. But I want to test the series before giving it
> > my Acked-by. I wont be able to do that till Tuesday at the earliest.
> >  
> 
> I guess this has slipped between the cracks?

Yes it has. Thanks for the reminder. I'm quite overwhelmed after coming
back from vacation, and getting pulled in various directions.

I'll see if I can run it through some tests today.

-- Steve

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

* Re: [PATCH v3 5/5] kernel: tracepoints: add support for relative references
@ 2017-08-30 13:17         ` Steven Rostedt
  0 siblings, 0 replies; 38+ messages in thread
From: Steven Rostedt @ 2017-08-30 13:17 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton

On Wed, 30 Aug 2017 13:52:26 +0100
Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

> On 20 August 2017 at 15:51, Steven Rostedt <rostedt@goodmis.org> wrote:
> > On Sat, 19 Aug 2017 19:10:35 +0100
> > Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> >  
> >> To avoid the need for relocating absolute references to tracepoint
> >> structures at boot time when running relocatable kernels (which may
> >> take a disproportionate amount of space), add the option to emit
> >> these tables as relative references instead.
> >>  
> >
> > This patch looks fine. But I want to test the series before giving it
> > my Acked-by. I wont be able to do that till Tuesday at the earliest.
> >  
> 
> I guess this has slipped between the cracks?

Yes it has. Thanks for the reminder. I'm quite overwhelmed after coming
back from vacation, and getting pulled in various directions.

I'll see if I can run it through some tests today.

-- Steve

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

* Re: [PATCH v3 5/5] kernel: tracepoints: add support for relative references
  2017-08-30 13:17         ` Steven Rostedt
@ 2017-08-30 13:18           ` Ard Biesheuvel
  -1 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-30 13:18 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Martin Schwidefsky, Sergey Senozhatsky,
	Linus Torvalds, Jessica Yu

On 30 August 2017 at 14:17, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Wed, 30 Aug 2017 13:52:26 +0100
> Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
>> On 20 August 2017 at 15:51, Steven Rostedt <rostedt@goodmis.org> wrote:
>> > On Sat, 19 Aug 2017 19:10:35 +0100
>> > Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>> >
>> >> To avoid the need for relocating absolute references to tracepoint
>> >> structures at boot time when running relocatable kernels (which may
>> >> take a disproportionate amount of space), add the option to emit
>> >> these tables as relative references instead.
>> >>
>> >
>> > This patch looks fine. But I want to test the series before giving it
>> > my Acked-by. I wont be able to do that till Tuesday at the earliest.
>> >
>>
>> I guess this has slipped between the cracks?
>
> Yes it has. Thanks for the reminder. I'm quite overwhelmed after coming
> back from vacation, and getting pulled in various directions.
>
> I'll see if I can run it through some tests today.
>

Thanks, that would be much appreciated.

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

* Re: [PATCH v3 5/5] kernel: tracepoints: add support for relative references
@ 2017-08-30 13:18           ` Ard Biesheuvel
  0 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-30 13:18 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton

On 30 August 2017 at 14:17, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Wed, 30 Aug 2017 13:52:26 +0100
> Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
>> On 20 August 2017 at 15:51, Steven Rostedt <rostedt@goodmis.org> wrote:
>> > On Sat, 19 Aug 2017 19:10:35 +0100
>> > Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>> >
>> >> To avoid the need for relocating absolute references to tracepoint
>> >> structures at boot time when running relocatable kernels (which may
>> >> take a disproportionate amount of space), add the option to emit
>> >> these tables as relative references instead.
>> >>
>> >
>> > This patch looks fine. But I want to test the series before giving it
>> > my Acked-by. I wont be able to do that till Tuesday at the earliest.
>> >
>>
>> I guess this has slipped between the cracks?
>
> Yes it has. Thanks for the reminder. I'm quite overwhelmed after coming
> back from vacation, and getting pulled in various directions.
>
> I'll see if I can run it through some tests today.
>

Thanks, that would be much appreciated.

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

* Re: [PATCH v3 5/5] kernel: tracepoints: add support for relative references
  2017-08-19 18:10   ` Ard Biesheuvel
@ 2017-08-30 18:13     ` Steven Rostedt
  -1 siblings, 0 replies; 38+ messages in thread
From: Steven Rostedt @ 2017-08-30 18:13 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Martin Schwidefsky, Sergey Senozhatsky,
	Linus Torvalds, Jessica Yu

On Sat, 19 Aug 2017 19:10:35 +0100
Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

> To avoid the need for relocating absolute references to tracepoint
> structures at boot time when running relocatable kernels (which may
> take a disproportionate amount of space), add the option to emit
> these tables as relative references instead.
> 
> Cc: Steven Rostedt <rostedt@goodmis.org>

I ran this through various tests (not my full test suite mind you), and
it appears to work as it has before.

Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve

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

* Re: [PATCH v3 5/5] kernel: tracepoints: add support for relative references
@ 2017-08-30 18:13     ` Steven Rostedt
  0 siblings, 0 replies; 38+ messages in thread
From: Steven Rostedt @ 2017-08-30 18:13 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre

On Sat, 19 Aug 2017 19:10:35 +0100
Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

> To avoid the need for relocating absolute references to tracepoint
> structures at boot time when running relocatable kernels (which may
> take a disproportionate amount of space), add the option to emit
> these tables as relative references instead.
> 
> Cc: Steven Rostedt <rostedt@goodmis.org>

I ran this through various tests (not my full test suite mind you), and
it appears to work as it has before.

Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve

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

* Re: [PATCH v3 5/5] kernel: tracepoints: add support for relative references
  2017-08-30 18:13     ` Steven Rostedt
@ 2017-08-30 18:26       ` Ard Biesheuvel
  -1 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-30 18:26 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Martin Schwidefsky, Sergey Senozhatsky,
	Linus Torvalds, Jessica Yu



> On 30 Aug 2017, at 19:13, Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> On Sat, 19 Aug 2017 19:10:35 +0100
> Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> 
>> To avoid the need for relocating absolute references to tracepoint
>> structures at boot time when running relocatable kernels (which may
>> take a disproportionate amount of space), add the option to emit
>> these tables as relative references instead.
>> 
>> Cc: Steven Rostedt <rostedt@goodmis.org>
> 
> I ran this through various tests (not my full test suite mind you), and
> it appears to work as it has before.
> 
> Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> 

Thanks!

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

* Re: [PATCH v3 5/5] kernel: tracepoints: add support for relative references
@ 2017-08-30 18:26       ` Ard Biesheuvel
  0 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-08-30 18:26 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre



> On 30 Aug 2017, at 19:13, Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> On Sat, 19 Aug 2017 19:10:35 +0100
> Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> 
>> To avoid the need for relocating absolute references to tracepoint
>> structures at boot time when running relocatable kernels (which may
>> take a disproportionate amount of space), add the option to emit
>> these tables as relative references instead.
>> 
>> Cc: Steven Rostedt <rostedt@goodmis.org>
> 
> I ran this through various tests (not my full test suite mind you), and
> it appears to work as it has before.
> 
> Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> 

Thanks!

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

* Re: kernel: tracepoints: add support for relative references
  2017-08-19 18:10   ` Ard Biesheuvel
@ 2017-09-05 12:48     ` Jessica Yu
  -1 siblings, 0 replies; 38+ messages in thread
From: Jessica Yu @ 2017-09-05 12:48 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt, Martin Schwidefsky,
	Sergey Senozhatsky, Linus Torvalds

+++ Ard Biesheuvel [19/08/17 19:10 +0100]:
>To avoid the need for relocating absolute references to tracepoint
>structures at boot time when running relocatable kernels (which may
>take a disproportionate amount of space), add the option to emit
>these tables as relative references instead.
>
>Cc: Steven Rostedt <rostedt@goodmis.org>
>Cc: Ingo Molnar <mingo@redhat.com>
>Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Hi Ard,

While testing this patchset I ran into the following general protection
fault when removing a module with tracepoints:

# rmmod kvm
[   25.279049] general protection fault: 0000 [#1] SMP
[   25.279385] Modules linked in: kvm(-) irqbypass
[   25.279829] CPU: 0 PID: 125 Comm: rmmod Not tainted 4.13.0-rc2+ #1
[   25.280007] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1.fc26 04/01/2014
[   25.280315] task: ffff9697db7c0000 task.stack: ffffa907802dc000
[   25.280624] RIP: 0010:tracepoint_module_notify+0xd5/0x1d0
[   25.280782] RSP: 0018:ffffa907802dfe68 EFLAGS: 00000287
[   25.280963] RAX: ffffffffc02b6fb0 RBX: ffff9697ddb33440 RCX: ffffffffc02b70f0
[   25.281168] RDX: 000163cc00016410 RSI: ffff9697df21d860 RDI: ffff9697de001900
[   25.281371] RBP: ffffa907802dfe88 R08: 000000000001d860 R09: ffffffff941692b4
[   25.281543] R10: fffff0ec4076ccc0 R11: 0000000000000300 R12: ffffffffc02ce740
[   25.281716] R13: 0000000000000002 R14: ffffffffc02ce740 R15: 0000000000000000
[   25.281917] FS:  0000000000a6e880(0000) GS:ffff9697df200000(0000) knlGS:0000000000000000
[   25.282107] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   25.282254] CR2: 00000000004adfc0 CR3: 000000001f838000 CR4: 00000000000006f0
[   25.282517] Call Trace:
[   25.283019]  notifier_call_chain+0x4a/0x70
[   25.283287]  blocking_notifier_call_chain+0x43/0x60
[   25.283422]  SyS_delete_module+0x1b8/0x240
[   25.283542]  ? SyS_chdir+0xc4/0xe0
[   25.283648]  entry_SYSCALL_64_fastpath+0x1a/0xa5
[   25.283863] RIP: 0033:0x4ba267
[   25.283947] RSP: 002b:00007ffc3316bdf8 EFLAGS: 00000246 ORIG_RAX: 00000000000000b0
[   25.284134] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00000000004ba267
[   25.284310] RDX: 0000000000000000 RSI: 0000000000000880 RDI: 00007ffc3316be00
[   25.284511] RBP: 00007ffc3316be40 R08: 0000000000000003 R09: 0000000000000000
[   25.284699] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000637672
[   25.284916] R13: 00007ffc3316c1b0 R14: 0000000000000000 R15: 0000000000000000
[   25.285226] Code: 00 48 89 43 08 e8 9c b4 0d 00 49 8b 84 24 90 02 00 00 48 85 c0 74 28 41 8b 94 24 8c 02 00 00 48 8d 0c d0 48 39 c8 73 17 48 8b 10 <48> 83 7a 28 00 0f 85 e8 00 00 00 48 83 c0 08 48 39 c1 77 e9 48 
[   25.286199] RIP: tracepoint_module_notify+0xd5/0x1d0 RSP: ffffa907802dfe68
[   25.286708] ---[ end trace 04f35cade1663177 ]---

The offending line is in tp_module_going_check_quiescent() (shown inlined):

(gdb) list *(tracepoint_module_notify+0xd5)
0xffffffff811692d5 is in tracepoint_module_notify (/home/jeyu/work/jeyu-linux/kernel/tracepoint.c:402).
397             struct tracepoint * const *iter;
398
399             if (!begin)
400                     return;
401             for (iter = begin; iter < end; iter++)
402                     WARN_ON_ONCE((*iter)->funcs);
403     }
404
405     static int tracepoint_module_coming(struct module *mod)
406     {

The relative reference calculations need to be done here too.

Thanks,

Jessica

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

* Re: kernel: tracepoints: add support for relative references
@ 2017-09-05 12:48     ` Jessica Yu
  0 siblings, 0 replies; 38+ messages in thread
From: Jessica Yu @ 2017-09-05 12:48 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt

+++ Ard Biesheuvel [19/08/17 19:10 +0100]:
>To avoid the need for relocating absolute references to tracepoint
>structures at boot time when running relocatable kernels (which may
>take a disproportionate amount of space), add the option to emit
>these tables as relative references instead.
>
>Cc: Steven Rostedt <rostedt@goodmis.org>
>Cc: Ingo Molnar <mingo@redhat.com>
>Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Hi Ard,

While testing this patchset I ran into the following general protection
fault when removing a module with tracepoints:

# rmmod kvm
[   25.279049] general protection fault: 0000 [#1] SMP
[   25.279385] Modules linked in: kvm(-) irqbypass
[   25.279829] CPU: 0 PID: 125 Comm: rmmod Not tainted 4.13.0-rc2+ #1
[   25.280007] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1.fc26 04/01/2014
[   25.280315] task: ffff9697db7c0000 task.stack: ffffa907802dc000
[   25.280624] RIP: 0010:tracepoint_module_notify+0xd5/0x1d0
[   25.280782] RSP: 0018:ffffa907802dfe68 EFLAGS: 00000287
[   25.280963] RAX: ffffffffc02b6fb0 RBX: ffff9697ddb33440 RCX: ffffffffc02b70f0
[   25.281168] RDX: 000163cc00016410 RSI: ffff9697df21d860 RDI: ffff9697de001900
[   25.281371] RBP: ffffa907802dfe88 R08: 000000000001d860 R09: ffffffff941692b4
[   25.281543] R10: fffff0ec4076ccc0 R11: 0000000000000300 R12: ffffffffc02ce740
[   25.281716] R13: 0000000000000002 R14: ffffffffc02ce740 R15: 0000000000000000
[   25.281917] FS:  0000000000a6e880(0000) GS:ffff9697df200000(0000) knlGS:0000000000000000
[   25.282107] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   25.282254] CR2: 00000000004adfc0 CR3: 000000001f838000 CR4: 00000000000006f0
[   25.282517] Call Trace:
[   25.283019]  notifier_call_chain+0x4a/0x70
[   25.283287]  blocking_notifier_call_chain+0x43/0x60
[   25.283422]  SyS_delete_module+0x1b8/0x240
[   25.283542]  ? SyS_chdir+0xc4/0xe0
[   25.283648]  entry_SYSCALL_64_fastpath+0x1a/0xa5
[   25.283863] RIP: 0033:0x4ba267
[   25.283947] RSP: 002b:00007ffc3316bdf8 EFLAGS: 00000246 ORIG_RAX: 00000000000000b0
[   25.284134] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00000000004ba267
[   25.284310] RDX: 0000000000000000 RSI: 0000000000000880 RDI: 00007ffc3316be00
[   25.284511] RBP: 00007ffc3316be40 R08: 0000000000000003 R09: 0000000000000000
[   25.284699] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000637672
[   25.284916] R13: 00007ffc3316c1b0 R14: 0000000000000000 R15: 0000000000000000
[   25.285226] Code: 00 48 89 43 08 e8 9c b4 0d 00 49 8b 84 24 90 02 00 00 48 85 c0 74 28 41 8b 94 24 8c 02 00 00 48 8d 0c d0 48 39 c8 73 17 48 8b 10 <48> 83 7a 28 00 0f 85 e8 00 00 00 48 83 c0 08 48 39 c1 77 e9 48 
[   25.286199] RIP: tracepoint_module_notify+0xd5/0x1d0 RSP: ffffa907802dfe68
[   25.286708] ---[ end trace 04f35cade1663177 ]---

The offending line is in tp_module_going_check_quiescent() (shown inlined):

(gdb) list *(tracepoint_module_notify+0xd5)
0xffffffff811692d5 is in tracepoint_module_notify (/home/jeyu/work/jeyu-linux/kernel/tracepoint.c:402).
397             struct tracepoint * const *iter;
398
399             if (!begin)
400                     return;
401             for (iter = begin; iter < end; iter++)
402                     WARN_ON_ONCE((*iter)->funcs);
403     }
404
405     static int tracepoint_module_coming(struct module *mod)
406     {

The relative reference calculations need to be done here too.

Thanks,

Jessica

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

* Re: kernel: tracepoints: add support for relative references
  2017-09-05 12:48     ` Jessica Yu
@ 2017-09-05 12:49       ` Ard Biesheuvel
  -1 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-09-05 12:49 UTC (permalink / raw)
  To: Jessica Yu
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt, Martin Schwidefsky,
	Sergey Senozhatsky, Linus Torvalds

On 5 September 2017 at 13:48, Jessica Yu <jeyu@kernel.org> wrote:
> +++ Ard Biesheuvel [19/08/17 19:10 +0100]:
>>
>> To avoid the need for relocating absolute references to tracepoint
>> structures at boot time when running relocatable kernels (which may
>> take a disproportionate amount of space), add the option to emit
>> these tables as relative references instead.
>>
>> Cc: Steven Rostedt <rostedt@goodmis.org>
>> Cc: Ingo Molnar <mingo@redhat.com>
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
>
> Hi Ard,
>
> While testing this patchset I ran into the following general protection
> fault when removing a module with tracepoints:
>
> # rmmod kvm
> [   25.279049] general protection fault: 0000 [#1] SMP
> [   25.279385] Modules linked in: kvm(-) irqbypass
> [   25.279829] CPU: 0 PID: 125 Comm: rmmod Not tainted 4.13.0-rc2+ #1
> [   25.280007] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
> 1.10.2-1.fc26 04/01/2014
> [   25.280315] task: ffff9697db7c0000 task.stack: ffffa907802dc000
> [   25.280624] RIP: 0010:tracepoint_module_notify+0xd5/0x1d0
> [   25.280782] RSP: 0018:ffffa907802dfe68 EFLAGS: 00000287
> [   25.280963] RAX: ffffffffc02b6fb0 RBX: ffff9697ddb33440 RCX:
> ffffffffc02b70f0
> [   25.281168] RDX: 000163cc00016410 RSI: ffff9697df21d860 RDI:
> ffff9697de001900
> [   25.281371] RBP: ffffa907802dfe88 R08: 000000000001d860 R09:
> ffffffff941692b4
> [   25.281543] R10: fffff0ec4076ccc0 R11: 0000000000000300 R12:
> ffffffffc02ce740
> [   25.281716] R13: 0000000000000002 R14: ffffffffc02ce740 R15:
> 0000000000000000
> [   25.281917] FS:  0000000000a6e880(0000) GS:ffff9697df200000(0000)
> knlGS:0000000000000000
> [   25.282107] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [   25.282254] CR2: 00000000004adfc0 CR3: 000000001f838000 CR4:
> 00000000000006f0
> [   25.282517] Call Trace:
> [   25.283019]  notifier_call_chain+0x4a/0x70
> [   25.283287]  blocking_notifier_call_chain+0x43/0x60
> [   25.283422]  SyS_delete_module+0x1b8/0x240
> [   25.283542]  ? SyS_chdir+0xc4/0xe0
> [   25.283648]  entry_SYSCALL_64_fastpath+0x1a/0xa5
> [   25.283863] RIP: 0033:0x4ba267
> [   25.283947] RSP: 002b:00007ffc3316bdf8 EFLAGS: 00000246 ORIG_RAX:
> 00000000000000b0
> [   25.284134] RAX: ffffffffffffffda RBX: 0000000000000000 RCX:
> 00000000004ba267
> [   25.284310] RDX: 0000000000000000 RSI: 0000000000000880 RDI:
> 00007ffc3316be00
> [   25.284511] RBP: 00007ffc3316be40 R08: 0000000000000003 R09:
> 0000000000000000
> [   25.284699] R10: 0000000000000000 R11: 0000000000000246 R12:
> 0000000000637672
> [   25.284916] R13: 00007ffc3316c1b0 R14: 0000000000000000 R15:
> 0000000000000000
> [   25.285226] Code: 00 48 89 43 08 e8 9c b4 0d 00 49 8b 84 24 90 02 00 00
> 48 85 c0 74 28 41 8b 94 24 8c 02 00 00 48 8d 0c d0 48 39 c8 73 17 48 8b 10
> <48> 83 7a 28 00 0f 85 e8 00 00 00 48 83 c0 08 48 39 c1 77 e9 48 [
> 25.286199] RIP: tracepoint_module_notify+0xd5/0x1d0 RSP: ffffa907802dfe68
> [   25.286708] ---[ end trace 04f35cade1663177 ]---
>
> The offending line is in tp_module_going_check_quiescent() (shown inlined):
>
> (gdb) list *(tracepoint_module_notify+0xd5)
> 0xffffffff811692d5 is in tracepoint_module_notify
> (/home/jeyu/work/jeyu-linux/kernel/tracepoint.c:402).
> 397             struct tracepoint * const *iter;
> 398
> 399             if (!begin)
> 400                     return;
> 401             for (iter = begin; iter < end; iter++)
> 402                     WARN_ON_ONCE((*iter)->funcs);
> 403     }
> 404
> 405     static int tracepoint_module_coming(struct module *mod)
> 406     {
>
> The relative reference calculations need to be done here too.
>

OK, thanks for spotting that.

I will fix and resend after the merge window closes.

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

* Re: kernel: tracepoints: add support for relative references
@ 2017-09-05 12:49       ` Ard Biesheuvel
  0 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-09-05 12:49 UTC (permalink / raw)
  To: Jessica Yu
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton

On 5 September 2017 at 13:48, Jessica Yu <jeyu@kernel.org> wrote:
> +++ Ard Biesheuvel [19/08/17 19:10 +0100]:
>>
>> To avoid the need for relocating absolute references to tracepoint
>> structures at boot time when running relocatable kernels (which may
>> take a disproportionate amount of space), add the option to emit
>> these tables as relative references instead.
>>
>> Cc: Steven Rostedt <rostedt@goodmis.org>
>> Cc: Ingo Molnar <mingo@redhat.com>
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
>
> Hi Ard,
>
> While testing this patchset I ran into the following general protection
> fault when removing a module with tracepoints:
>
> # rmmod kvm
> [   25.279049] general protection fault: 0000 [#1] SMP
> [   25.279385] Modules linked in: kvm(-) irqbypass
> [   25.279829] CPU: 0 PID: 125 Comm: rmmod Not tainted 4.13.0-rc2+ #1
> [   25.280007] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
> 1.10.2-1.fc26 04/01/2014
> [   25.280315] task: ffff9697db7c0000 task.stack: ffffa907802dc000
> [   25.280624] RIP: 0010:tracepoint_module_notify+0xd5/0x1d0
> [   25.280782] RSP: 0018:ffffa907802dfe68 EFLAGS: 00000287
> [   25.280963] RAX: ffffffffc02b6fb0 RBX: ffff9697ddb33440 RCX:
> ffffffffc02b70f0
> [   25.281168] RDX: 000163cc00016410 RSI: ffff9697df21d860 RDI:
> ffff9697de001900
> [   25.281371] RBP: ffffa907802dfe88 R08: 000000000001d860 R09:
> ffffffff941692b4
> [   25.281543] R10: fffff0ec4076ccc0 R11: 0000000000000300 R12:
> ffffffffc02ce740
> [   25.281716] R13: 0000000000000002 R14: ffffffffc02ce740 R15:
> 0000000000000000
> [   25.281917] FS:  0000000000a6e880(0000) GS:ffff9697df200000(0000)
> knlGS:0000000000000000
> [   25.282107] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [   25.282254] CR2: 00000000004adfc0 CR3: 000000001f838000 CR4:
> 00000000000006f0
> [   25.282517] Call Trace:
> [   25.283019]  notifier_call_chain+0x4a/0x70
> [   25.283287]  blocking_notifier_call_chain+0x43/0x60
> [   25.283422]  SyS_delete_module+0x1b8/0x240
> [   25.283542]  ? SyS_chdir+0xc4/0xe0
> [   25.283648]  entry_SYSCALL_64_fastpath+0x1a/0xa5
> [   25.283863] RIP: 0033:0x4ba267
> [   25.283947] RSP: 002b:00007ffc3316bdf8 EFLAGS: 00000246 ORIG_RAX:
> 00000000000000b0
> [   25.284134] RAX: ffffffffffffffda RBX: 0000000000000000 RCX:
> 00000000004ba267
> [   25.284310] RDX: 0000000000000000 RSI: 0000000000000880 RDI:
> 00007ffc3316be00
> [   25.284511] RBP: 00007ffc3316be40 R08: 0000000000000003 R09:
> 0000000000000000
> [   25.284699] R10: 0000000000000000 R11: 0000000000000246 R12:
> 0000000000637672
> [   25.284916] R13: 00007ffc3316c1b0 R14: 0000000000000000 R15:
> 0000000000000000
> [   25.285226] Code: 00 48 89 43 08 e8 9c b4 0d 00 49 8b 84 24 90 02 00 00
> 48 85 c0 74 28 41 8b 94 24 8c 02 00 00 48 8d 0c d0 48 39 c8 73 17 48 8b 10
> <48> 83 7a 28 00 0f 85 e8 00 00 00 48 83 c0 08 48 39 c1 77 e9 48 [
> 25.286199] RIP: tracepoint_module_notify+0xd5/0x1d0 RSP: ffffa907802dfe68
> [   25.286708] ---[ end trace 04f35cade1663177 ]---
>
> The offending line is in tp_module_going_check_quiescent() (shown inlined):
>
> (gdb) list *(tracepoint_module_notify+0xd5)
> 0xffffffff811692d5 is in tracepoint_module_notify
> (/home/jeyu/work/jeyu-linux/kernel/tracepoint.c:402).
> 397             struct tracepoint * const *iter;
> 398
> 399             if (!begin)
> 400                     return;
> 401             for (iter = begin; iter < end; iter++)
> 402                     WARN_ON_ONCE((*iter)->funcs);
> 403     }
> 404
> 405     static int tracepoint_module_coming(struct module *mod)
> 406     {
>
> The relative reference calculations need to be done here too.
>

OK, thanks for spotting that.

I will fix and resend after the merge window closes.

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

* Re: module: use relative references for __ksymtab entries
  2017-08-19 18:10   ` Ard Biesheuvel
@ 2017-09-09 13:08     ` Jessica Yu
  -1 siblings, 0 replies; 38+ messages in thread
From: Jessica Yu @ 2017-09-09 13:08 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt, Martin Schwidefsky,
	Sergey Senozhatsky, Linus Torvalds, Ingo Molnar

+++ Ard Biesheuvel [19/08/17 19:10 +0100]:
>An ordinary arm64 defconfig build has ~64 KB worth of __ksymtab
>entries, each consisting of two 64-bit fields containing absolute
>references, to the symbol itself and to a char array containing
>its name, respectively.
>
>When we build the same configuration with KASLR enabled, we end
>up with an additional ~192 KB of relocations in the .init section,
>i.e., one 24 byte entry for each absolute reference, which all need
>to be processed at boot time.
>
>Given how the struct kernel_symbol that describes each entry is
>completely local to module.c (except for the references emitted
>by EXPORT_SYMBOL() itself), we can easily modify it to contain
>two 32-bit relative references instead. This reduces the size of
>the __ksymtab section by 50% for all 64-bit architectures, and
>gets rid of the runtime relocations entirely for architectures
>implementing KASLR, either via standard PIE linking (arm64) or
>using custom host tools (x86).
>
>Note that the binary search involving __ksymtab contents relies
>on each section being sorted by symbol name. This is implemented
>based on the input section names, not the names in the ksymtab
>entries, so this patch does not interfere with that.
>
>Given that the use of place-relative relocations requires support
>both in the toolchain and in the module loader, we cannot enable
>this feature for all architectures. So make it dependend on whether
>CONFIG_HAVE_ARCH_PREL32_RELOCATIONS is defined.
>
>Cc: Jessica Yu <jeyu@kernel.org>
>Cc: Arnd Bergmann <arnd@arndb.de>
>Cc: Andrew Morton <akpm@linux-foundation.org>
>Cc: Ingo Molnar <mingo@kernel.org>
>Cc: Kees Cook <keescook@chromium.org>
>Cc: Thomas Garnier <thgarnie@google.com>
>Cc: Nicolas Pitre <nico@linaro.org>
>Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

I ran this through some light testing and the relative ksymtab
references seem to work just fine:

Acked-by: Jessica Yu <jeyu@kernel.org> (for module changes)

> arch/x86/include/asm/Kbuild   |  1 +
> arch/x86/include/asm/export.h |  4 --
> include/asm-generic/export.h  | 12 +++++-
> include/linux/compiler.h      | 11 +++++
> include/linux/export.h        | 45 +++++++++++++++-----
> kernel/module.c               | 33 +++++++++++---
> 6 files changed, 83 insertions(+), 23 deletions(-)
>
>diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
>index 5d6a53fd7521..3e8a88dcaa1d 100644
>--- a/arch/x86/include/asm/Kbuild
>+++ b/arch/x86/include/asm/Kbuild
>@@ -9,5 +9,6 @@ generated-y += xen-hypercalls.h
> generic-y += clkdev.h
> generic-y += dma-contiguous.h
> generic-y += early_ioremap.h
>+generic-y += export.h
> generic-y += mcs_spinlock.h
> generic-y += mm-arch-hooks.h
>diff --git a/arch/x86/include/asm/export.h b/arch/x86/include/asm/export.h
>deleted file mode 100644
>index 138de56b13eb..000000000000
>--- a/arch/x86/include/asm/export.h
>+++ /dev/null
>@@ -1,4 +0,0 @@
>-#ifdef CONFIG_64BIT
>-#define KSYM_ALIGN 16
>-#endif
>-#include <asm-generic/export.h>
>diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h
>index 719db1968d81..97ce606459ae 100644
>--- a/include/asm-generic/export.h
>+++ b/include/asm-generic/export.h
>@@ -5,12 +5,10 @@
> #define KSYM_FUNC(x) x
> #endif
> #ifdef CONFIG_64BIT
>-#define __put .quad
> #ifndef KSYM_ALIGN
> #define KSYM_ALIGN 8
> #endif
> #else
>-#define __put .long
> #ifndef KSYM_ALIGN
> #define KSYM_ALIGN 4
> #endif
>@@ -25,6 +23,16 @@
> #define KSYM(name) name
> #endif
>
>+.macro __put, val, name
>+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>+	.long	\val - ., \name - .
>+#elif defined(CONFIG_64BIT)
>+	.quad	\val, \name
>+#else
>+	.long	\val, \name
>+#endif
>+.endm
>+
> /*
>  * note on .section use: @progbits vs %progbits nastiness doesn't matter,
>  * since we immediately emit into those sections anyway.
>diff --git a/include/linux/compiler.h b/include/linux/compiler.h
>index eca8ad75e28b..363fb3e734ec 100644
>--- a/include/linux/compiler.h
>+++ b/include/linux/compiler.h
>@@ -590,4 +590,15 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
> 	(_________p1); \
> })
>
>+/*
>+ * Force the compiler to emit 'sym' as a symbol, so that we can reference
>+ * it from inline assembler. Necessary in case 'sym' could be inlined
>+ * otherwise, or eliminated entirely due to lack of references that are
>+ * visibile to the compiler.
>+ */
>+#define __ADDRESSABLE(sym) \
>+	static void *__attribute__((section(".discard.text"), used))	\
>+		__PASTE(__discard_##sym, __LINE__)(void)		\
>+			{ return (void *)&sym; }			\
>+
> #endif /* __LINUX_COMPILER_H */
>diff --git a/include/linux/export.h b/include/linux/export.h
>index 1a1dfdb2a5c6..156b974181a4 100644
>--- a/include/linux/export.h
>+++ b/include/linux/export.h
>@@ -24,12 +24,6 @@
> #define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x)
>
> #ifndef __ASSEMBLY__
>-struct kernel_symbol
>-{
>-	unsigned long value;
>-	const char *name;
>-};
>-
> #ifdef MODULE
> extern struct module __this_module;
> #define THIS_MODULE (&__this_module)
>@@ -60,17 +54,46 @@ extern struct module __this_module;
> #define __CRC_SYMBOL(sym, sec)
> #endif
>
>+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>+/*
>+ * Emit the ksymtab entry as a pair of relative references: this reduces
>+ * the size by half on 64-bit architectures, and eliminates the need for
>+ * absolute relocations that require runtime processing on relocatable
>+ * kernels.
>+ */
>+#define __KSYMTAB_ENTRY(sym, sec)					\
>+	__ADDRESSABLE(sym)						\
>+	asm("	.section \"___ksymtab" sec "+" #sym "\", \"a\"	\n"	\
>+	    "	.balign	8					\n"	\
>+	    VMLINUX_SYMBOL_STR(__ksymtab_##sym) ":		\n"	\
>+	    "	.long "	VMLINUX_SYMBOL_STR(sym) "- .		\n"	\
>+	    "	.long "	VMLINUX_SYMBOL_STR(__kstrtab_##sym) "- .\n"	\
>+	    "	.previous					\n")
>+
>+struct kernel_symbol {
>+	signed int value_offset;
>+	signed int name_offset;
>+};
>+#else
>+#define __KSYMTAB_ENTRY(sym, sec)					\
>+	static const struct kernel_symbol __ksymtab_##sym		\
>+	__attribute__((section("___ksymtab" sec "+" #sym), used))	\
>+	= { (unsigned long)&sym, __kstrtab_##sym }
>+
>+struct kernel_symbol {
>+	unsigned long value;
>+	const char *name;
>+};
>+#endif
>+
> /* For every exported symbol, place a struct in the __ksymtab section */
> #define ___EXPORT_SYMBOL(sym, sec)					\
> 	extern typeof(sym) sym;						\
> 	__CRC_SYMBOL(sym, sec)						\
> 	static const char __kstrtab_##sym[]				\
>-	__attribute__((section("__ksymtab_strings"), aligned(1)))	\
>+	__attribute__((section("__ksymtab_strings"), used, aligned(1)))	\
> 	= VMLINUX_SYMBOL_STR(sym);					\
>-	static const struct kernel_symbol __ksymtab_##sym		\
>-	__used								\
>-	__attribute__((section("___ksymtab" sec "+" #sym), used))	\
>-	= { (unsigned long)&sym, __kstrtab_##sym }
>+	__KSYMTAB_ENTRY(sym, sec)
>
> #if defined(__KSYM_DEPS__)
>
>diff --git a/kernel/module.c b/kernel/module.c
>index 40f983cbea81..a45423dcc32d 100644
>--- a/kernel/module.c
>+++ b/kernel/module.c
>@@ -539,12 +539,31 @@ static bool check_symbol(const struct symsearch *syms,
> 	return true;
> }
>
>+static unsigned long kernel_symbol_value(const struct kernel_symbol *sym)
>+{
>+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>+	return (unsigned long)&sym->value_offset + sym->value_offset;
>+#else
>+	return sym->value;
>+#endif
>+}
>+
>+static const char *kernel_symbol_name(const struct kernel_symbol *sym)
>+{
>+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>+	return (const char *)((unsigned long)&sym->name_offset +
>+			      sym->name_offset);
>+#else
>+	return sym->name;
>+#endif
>+}
>+
> static int cmp_name(const void *va, const void *vb)
> {
> 	const char *a;
> 	const struct kernel_symbol *b;
> 	a = va; b = vb;
>-	return strcmp(a, b->name);
>+	return strcmp(a, kernel_symbol_name(b));
> }
>
> static bool find_symbol_in_section(const struct symsearch *syms,
>@@ -2190,7 +2209,7 @@ void *__symbol_get(const char *symbol)
> 		sym = NULL;
> 	preempt_enable();
>
>-	return sym ? (void *)sym->value : NULL;
>+	return sym ? (void *)kernel_symbol_value(sym) : NULL;
> }
> EXPORT_SYMBOL_GPL(__symbol_get);
>
>@@ -2220,10 +2239,12 @@ static int verify_export_symbols(struct module *mod)
>
> 	for (i = 0; i < ARRAY_SIZE(arr); i++) {
> 		for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
>-			if (find_symbol(s->name, &owner, NULL, true, false)) {
>+			if (find_symbol(kernel_symbol_name(s), &owner, NULL,
>+					true, false)) {
> 				pr_err("%s: exports duplicate symbol %s"
> 				       " (owned by %s)\n",
>-				       mod->name, s->name, module_name(owner));
>+				       mod->name, kernel_symbol_name(s),
>+				       module_name(owner));
> 				return -ENOEXEC;
> 			}
> 		}
>@@ -2272,7 +2293,7 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
> 			ksym = resolve_symbol_wait(mod, info, name);
> 			/* Ok if resolved.  */
> 			if (ksym && !IS_ERR(ksym)) {
>-				sym[i].st_value = ksym->value;
>+				sym[i].st_value = kernel_symbol_value(ksym);
> 				break;
> 			}
>
>@@ -2532,7 +2553,7 @@ static int is_exported(const char *name, unsigned long value,
> 		ks = lookup_symbol(name, __start___ksymtab, __stop___ksymtab);
> 	else
> 		ks = lookup_symbol(name, mod->syms, mod->syms + mod->num_syms);
>-	return ks != NULL && ks->value == value;
>+	return ks != NULL && kernel_symbol_value(ks) == value;
> }
>
> /* As per nm */
>-- 
>2.11.0
>

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

* Re: module: use relative references for __ksymtab entries
@ 2017-09-09 13:08     ` Jessica Yu
  0 siblings, 0 replies; 38+ messages in thread
From: Jessica Yu @ 2017-09-09 13:08 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-kernel, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Garnier, Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt

+++ Ard Biesheuvel [19/08/17 19:10 +0100]:
>An ordinary arm64 defconfig build has ~64 KB worth of __ksymtab
>entries, each consisting of two 64-bit fields containing absolute
>references, to the symbol itself and to a char array containing
>its name, respectively.
>
>When we build the same configuration with KASLR enabled, we end
>up with an additional ~192 KB of relocations in the .init section,
>i.e., one 24 byte entry for each absolute reference, which all need
>to be processed at boot time.
>
>Given how the struct kernel_symbol that describes each entry is
>completely local to module.c (except for the references emitted
>by EXPORT_SYMBOL() itself), we can easily modify it to contain
>two 32-bit relative references instead. This reduces the size of
>the __ksymtab section by 50% for all 64-bit architectures, and
>gets rid of the runtime relocations entirely for architectures
>implementing KASLR, either via standard PIE linking (arm64) or
>using custom host tools (x86).
>
>Note that the binary search involving __ksymtab contents relies
>on each section being sorted by symbol name. This is implemented
>based on the input section names, not the names in the ksymtab
>entries, so this patch does not interfere with that.
>
>Given that the use of place-relative relocations requires support
>both in the toolchain and in the module loader, we cannot enable
>this feature for all architectures. So make it dependend on whether
>CONFIG_HAVE_ARCH_PREL32_RELOCATIONS is defined.
>
>Cc: Jessica Yu <jeyu@kernel.org>
>Cc: Arnd Bergmann <arnd@arndb.de>
>Cc: Andrew Morton <akpm@linux-foundation.org>
>Cc: Ingo Molnar <mingo@kernel.org>
>Cc: Kees Cook <keescook@chromium.org>
>Cc: Thomas Garnier <thgarnie@google.com>
>Cc: Nicolas Pitre <nico@linaro.org>
>Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

I ran this through some light testing and the relative ksymtab
references seem to work just fine:

Acked-by: Jessica Yu <jeyu@kernel.org> (for module changes)

> arch/x86/include/asm/Kbuild   |  1 +
> arch/x86/include/asm/export.h |  4 --
> include/asm-generic/export.h  | 12 +++++-
> include/linux/compiler.h      | 11 +++++
> include/linux/export.h        | 45 +++++++++++++++-----
> kernel/module.c               | 33 +++++++++++---
> 6 files changed, 83 insertions(+), 23 deletions(-)
>
>diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
>index 5d6a53fd7521..3e8a88dcaa1d 100644
>--- a/arch/x86/include/asm/Kbuild
>+++ b/arch/x86/include/asm/Kbuild
>@@ -9,5 +9,6 @@ generated-y += xen-hypercalls.h
> generic-y += clkdev.h
> generic-y += dma-contiguous.h
> generic-y += early_ioremap.h
>+generic-y += export.h
> generic-y += mcs_spinlock.h
> generic-y += mm-arch-hooks.h
>diff --git a/arch/x86/include/asm/export.h b/arch/x86/include/asm/export.h
>deleted file mode 100644
>index 138de56b13eb..000000000000
>--- a/arch/x86/include/asm/export.h
>+++ /dev/null
>@@ -1,4 +0,0 @@
>-#ifdef CONFIG_64BIT
>-#define KSYM_ALIGN 16
>-#endif
>-#include <asm-generic/export.h>
>diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h
>index 719db1968d81..97ce606459ae 100644
>--- a/include/asm-generic/export.h
>+++ b/include/asm-generic/export.h
>@@ -5,12 +5,10 @@
> #define KSYM_FUNC(x) x
> #endif
> #ifdef CONFIG_64BIT
>-#define __put .quad
> #ifndef KSYM_ALIGN
> #define KSYM_ALIGN 8
> #endif
> #else
>-#define __put .long
> #ifndef KSYM_ALIGN
> #define KSYM_ALIGN 4
> #endif
>@@ -25,6 +23,16 @@
> #define KSYM(name) name
> #endif
>
>+.macro __put, val, name
>+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>+	.long	\val - ., \name - .
>+#elif defined(CONFIG_64BIT)
>+	.quad	\val, \name
>+#else
>+	.long	\val, \name
>+#endif
>+.endm
>+
> /*
>  * note on .section use: @progbits vs %progbits nastiness doesn't matter,
>  * since we immediately emit into those sections anyway.
>diff --git a/include/linux/compiler.h b/include/linux/compiler.h
>index eca8ad75e28b..363fb3e734ec 100644
>--- a/include/linux/compiler.h
>+++ b/include/linux/compiler.h
>@@ -590,4 +590,15 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
> 	(_________p1); \
> })
>
>+/*
>+ * Force the compiler to emit 'sym' as a symbol, so that we can reference
>+ * it from inline assembler. Necessary in case 'sym' could be inlined
>+ * otherwise, or eliminated entirely due to lack of references that are
>+ * visibile to the compiler.
>+ */
>+#define __ADDRESSABLE(sym) \
>+	static void *__attribute__((section(".discard.text"), used))	\
>+		__PASTE(__discard_##sym, __LINE__)(void)		\
>+			{ return (void *)&sym; }			\
>+
> #endif /* __LINUX_COMPILER_H */
>diff --git a/include/linux/export.h b/include/linux/export.h
>index 1a1dfdb2a5c6..156b974181a4 100644
>--- a/include/linux/export.h
>+++ b/include/linux/export.h
>@@ -24,12 +24,6 @@
> #define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x)
>
> #ifndef __ASSEMBLY__
>-struct kernel_symbol
>-{
>-	unsigned long value;
>-	const char *name;
>-};
>-
> #ifdef MODULE
> extern struct module __this_module;
> #define THIS_MODULE (&__this_module)
>@@ -60,17 +54,46 @@ extern struct module __this_module;
> #define __CRC_SYMBOL(sym, sec)
> #endif
>
>+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>+/*
>+ * Emit the ksymtab entry as a pair of relative references: this reduces
>+ * the size by half on 64-bit architectures, and eliminates the need for
>+ * absolute relocations that require runtime processing on relocatable
>+ * kernels.
>+ */
>+#define __KSYMTAB_ENTRY(sym, sec)					\
>+	__ADDRESSABLE(sym)						\
>+	asm("	.section \"___ksymtab" sec "+" #sym "\", \"a\"	\n"	\
>+	    "	.balign	8					\n"	\
>+	    VMLINUX_SYMBOL_STR(__ksymtab_##sym) ":		\n"	\
>+	    "	.long "	VMLINUX_SYMBOL_STR(sym) "- .		\n"	\
>+	    "	.long "	VMLINUX_SYMBOL_STR(__kstrtab_##sym) "- .\n"	\
>+	    "	.previous					\n")
>+
>+struct kernel_symbol {
>+	signed int value_offset;
>+	signed int name_offset;
>+};
>+#else
>+#define __KSYMTAB_ENTRY(sym, sec)					\
>+	static const struct kernel_symbol __ksymtab_##sym		\
>+	__attribute__((section("___ksymtab" sec "+" #sym), used))	\
>+	= { (unsigned long)&sym, __kstrtab_##sym }
>+
>+struct kernel_symbol {
>+	unsigned long value;
>+	const char *name;
>+};
>+#endif
>+
> /* For every exported symbol, place a struct in the __ksymtab section */
> #define ___EXPORT_SYMBOL(sym, sec)					\
> 	extern typeof(sym) sym;						\
> 	__CRC_SYMBOL(sym, sec)						\
> 	static const char __kstrtab_##sym[]				\
>-	__attribute__((section("__ksymtab_strings"), aligned(1)))	\
>+	__attribute__((section("__ksymtab_strings"), used, aligned(1)))	\
> 	= VMLINUX_SYMBOL_STR(sym);					\
>-	static const struct kernel_symbol __ksymtab_##sym		\
>-	__used								\
>-	__attribute__((section("___ksymtab" sec "+" #sym), used))	\
>-	= { (unsigned long)&sym, __kstrtab_##sym }
>+	__KSYMTAB_ENTRY(sym, sec)
>
> #if defined(__KSYM_DEPS__)
>
>diff --git a/kernel/module.c b/kernel/module.c
>index 40f983cbea81..a45423dcc32d 100644
>--- a/kernel/module.c
>+++ b/kernel/module.c
>@@ -539,12 +539,31 @@ static bool check_symbol(const struct symsearch *syms,
> 	return true;
> }
>
>+static unsigned long kernel_symbol_value(const struct kernel_symbol *sym)
>+{
>+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>+	return (unsigned long)&sym->value_offset + sym->value_offset;
>+#else
>+	return sym->value;
>+#endif
>+}
>+
>+static const char *kernel_symbol_name(const struct kernel_symbol *sym)
>+{
>+#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>+	return (const char *)((unsigned long)&sym->name_offset +
>+			      sym->name_offset);
>+#else
>+	return sym->name;
>+#endif
>+}
>+
> static int cmp_name(const void *va, const void *vb)
> {
> 	const char *a;
> 	const struct kernel_symbol *b;
> 	a = va; b = vb;
>-	return strcmp(a, b->name);
>+	return strcmp(a, kernel_symbol_name(b));
> }
>
> static bool find_symbol_in_section(const struct symsearch *syms,
>@@ -2190,7 +2209,7 @@ void *__symbol_get(const char *symbol)
> 		sym = NULL;
> 	preempt_enable();
>
>-	return sym ? (void *)sym->value : NULL;
>+	return sym ? (void *)kernel_symbol_value(sym) : NULL;
> }
> EXPORT_SYMBOL_GPL(__symbol_get);
>
>@@ -2220,10 +2239,12 @@ static int verify_export_symbols(struct module *mod)
>
> 	for (i = 0; i < ARRAY_SIZE(arr); i++) {
> 		for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
>-			if (find_symbol(s->name, &owner, NULL, true, false)) {
>+			if (find_symbol(kernel_symbol_name(s), &owner, NULL,
>+					true, false)) {
> 				pr_err("%s: exports duplicate symbol %s"
> 				       " (owned by %s)\n",
>-				       mod->name, s->name, module_name(owner));
>+				       mod->name, kernel_symbol_name(s),
>+				       module_name(owner));
> 				return -ENOEXEC;
> 			}
> 		}
>@@ -2272,7 +2293,7 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
> 			ksym = resolve_symbol_wait(mod, info, name);
> 			/* Ok if resolved.  */
> 			if (ksym && !IS_ERR(ksym)) {
>-				sym[i].st_value = ksym->value;
>+				sym[i].st_value = kernel_symbol_value(ksym);
> 				break;
> 			}
>
>@@ -2532,7 +2553,7 @@ static int is_exported(const char *name, unsigned long value,
> 		ks = lookup_symbol(name, __start___ksymtab, __stop___ksymtab);
> 	else
> 		ks = lookup_symbol(name, mod->syms, mod->syms + mod->num_syms);
>-	return ks != NULL && ks->value == value;
>+	return ks != NULL && kernel_symbol_value(ks) == value;
> }
>
> /* As per nm */
>-- 
>2.11.0
>

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

* Re: module: use relative references for __ksymtab entries
  2017-09-09 13:08     ` Jessica Yu
@ 2017-09-09 15:33       ` Thomas Garnier
  -1 siblings, 0 replies; 38+ messages in thread
From: Thomas Garnier @ 2017-09-09 15:33 UTC (permalink / raw)
  To: Jessica Yu
  Cc: Ard Biesheuvel, LKML, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt, Martin Schwidefsky,
	Sergey Senozhatsky, Linus Torvalds, Ingo Molnar

On Sat, Sep 9, 2017 at 6:08 AM, Jessica Yu <jeyu@kernel.org> wrote:
> +++ Ard Biesheuvel [19/08/17 19:10 +0100]:
>
>> An ordinary arm64 defconfig build has ~64 KB worth of __ksymtab
>> entries, each consisting of two 64-bit fields containing absolute
>> references, to the symbol itself and to a char array containing
>> its name, respectively.
>>
>> When we build the same configuration with KASLR enabled, we end
>> up with an additional ~192 KB of relocations in the .init section,
>> i.e., one 24 byte entry for each absolute reference, which all need
>> to be processed at boot time.
>>
>> Given how the struct kernel_symbol that describes each entry is
>> completely local to module.c (except for the references emitted
>> by EXPORT_SYMBOL() itself), we can easily modify it to contain
>> two 32-bit relative references instead. This reduces the size of
>> the __ksymtab section by 50% for all 64-bit architectures, and
>> gets rid of the runtime relocations entirely for architectures
>> implementing KASLR, either via standard PIE linking (arm64) or
>> using custom host tools (x86).
>>
>> Note that the binary search involving __ksymtab contents relies
>> on each section being sorted by symbol name. This is implemented
>> based on the input section names, not the names in the ksymtab
>> entries, so this patch does not interfere with that.
>>
>> Given that the use of place-relative relocations requires support
>> both in the toolchain and in the module loader, we cannot enable
>> this feature for all architectures. So make it dependend on whether
>> CONFIG_HAVE_ARCH_PREL32_RELOCATIONS is defined.

Good idea, I assume we may still get relocations given the compiler is
pretty bad at optimizing (_ptr - .) but I might be wrong. Anyway, the
size decrease is great and we can ignore these relocations if need be.
Thanks.

>>
>> Cc: Jessica Yu <jeyu@kernel.org>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Ingo Molnar <mingo@kernel.org>
>> Cc: Kees Cook <keescook@chromium.org>
>> Cc: Thomas Garnier <thgarnie@google.com>
>> Cc: Nicolas Pitre <nico@linaro.org>
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
>
> I ran this through some light testing and the relative ksymtab
> references seem to work just fine:
>
> Acked-by: Jessica Yu <jeyu@kernel.org> (for module changes)
>
>
>> arch/x86/include/asm/Kbuild   |  1 +
>> arch/x86/include/asm/export.h |  4 --
>> include/asm-generic/export.h  | 12 +++++-
>> include/linux/compiler.h      | 11 +++++
>> include/linux/export.h        | 45 +++++++++++++++-----
>> kernel/module.c               | 33 +++++++++++---
>> 6 files changed, 83 insertions(+), 23 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
>> index 5d6a53fd7521..3e8a88dcaa1d 100644
>> --- a/arch/x86/include/asm/Kbuild
>> +++ b/arch/x86/include/asm/Kbuild
>> @@ -9,5 +9,6 @@ generated-y += xen-hypercalls.h
>> generic-y += clkdev.h
>> generic-y += dma-contiguous.h
>> generic-y += early_ioremap.h
>> +generic-y += export.h
>> generic-y += mcs_spinlock.h
>> generic-y += mm-arch-hooks.h
>> diff --git a/arch/x86/include/asm/export.h b/arch/x86/include/asm/export.h
>> deleted file mode 100644
>> index 138de56b13eb..000000000000
>> --- a/arch/x86/include/asm/export.h
>> +++ /dev/null
>> @@ -1,4 +0,0 @@
>> -#ifdef CONFIG_64BIT
>> -#define KSYM_ALIGN 16
>> -#endif
>> -#include <asm-generic/export.h>
>> diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h
>> index 719db1968d81..97ce606459ae 100644
>> --- a/include/asm-generic/export.h
>> +++ b/include/asm-generic/export.h
>> @@ -5,12 +5,10 @@
>> #define KSYM_FUNC(x) x
>> #endif
>> #ifdef CONFIG_64BIT
>> -#define __put .quad
>> #ifndef KSYM_ALIGN
>> #define KSYM_ALIGN 8
>> #endif
>> #else
>> -#define __put .long
>> #ifndef KSYM_ALIGN
>> #define KSYM_ALIGN 4
>> #endif
>> @@ -25,6 +23,16 @@
>> #define KSYM(name) name
>> #endif
>>
>> +.macro __put, val, name
>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>> +       .long   \val - ., \name - .
>> +#elif defined(CONFIG_64BIT)
>> +       .quad   \val, \name
>> +#else
>> +       .long   \val, \name
>> +#endif
>> +.endm
>> +
>> /*
>>  * note on .section use: @progbits vs %progbits nastiness doesn't matter,
>>  * since we immediately emit into those sections anyway.
>> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
>> index eca8ad75e28b..363fb3e734ec 100644
>> --- a/include/linux/compiler.h
>> +++ b/include/linux/compiler.h
>> @@ -590,4 +590,15 @@ static __always_inline void
>> __write_once_size(volatile void *p, void *res, int s
>>         (_________p1); \
>> })
>>
>> +/*
>> + * Force the compiler to emit 'sym' as a symbol, so that we can reference
>> + * it from inline assembler. Necessary in case 'sym' could be inlined
>> + * otherwise, or eliminated entirely due to lack of references that are
>> + * visibile to the compiler.
>> + */
>> +#define __ADDRESSABLE(sym) \
>> +       static void *__attribute__((section(".discard.text"), used))    \
>> +               __PASTE(__discard_##sym, __LINE__)(void)                \
>> +                       { return (void *)&sym; }                        \
>> +
>> #endif /* __LINUX_COMPILER_H */
>> diff --git a/include/linux/export.h b/include/linux/export.h
>> index 1a1dfdb2a5c6..156b974181a4 100644
>> --- a/include/linux/export.h
>> +++ b/include/linux/export.h
>> @@ -24,12 +24,6 @@
>> #define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x)
>>
>> #ifndef __ASSEMBLY__
>> -struct kernel_symbol
>> -{
>> -       unsigned long value;
>> -       const char *name;
>> -};
>> -
>> #ifdef MODULE
>> extern struct module __this_module;
>> #define THIS_MODULE (&__this_module)
>> @@ -60,17 +54,46 @@ extern struct module __this_module;
>> #define __CRC_SYMBOL(sym, sec)
>> #endif
>>
>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>> +/*
>> + * Emit the ksymtab entry as a pair of relative references: this reduces
>> + * the size by half on 64-bit architectures, and eliminates the need for
>> + * absolute relocations that require runtime processing on relocatable
>> + * kernels.
>> + */
>> +#define __KSYMTAB_ENTRY(sym, sec)                                      \
>> +       __ADDRESSABLE(sym)                                              \
>> +       asm("   .section \"___ksymtab" sec "+" #sym "\", \"a\"  \n"     \
>> +           "   .balign 8                                       \n"     \
>> +           VMLINUX_SYMBOL_STR(__ksymtab_##sym) ":              \n"     \
>> +           "   .long " VMLINUX_SYMBOL_STR(sym) "- .            \n"     \
>> +           "   .long " VMLINUX_SYMBOL_STR(__kstrtab_##sym) "- .\n"     \
>> +           "   .previous                                       \n")
>> +
>> +struct kernel_symbol {
>> +       signed int value_offset;
>> +       signed int name_offset;
>> +};
>> +#else
>> +#define __KSYMTAB_ENTRY(sym, sec)                                      \
>> +       static const struct kernel_symbol __ksymtab_##sym               \
>> +       __attribute__((section("___ksymtab" sec "+" #sym), used))       \
>> +       = { (unsigned long)&sym, __kstrtab_##sym }
>> +
>> +struct kernel_symbol {
>> +       unsigned long value;
>> +       const char *name;
>> +};
>> +#endif
>> +
>> /* For every exported symbol, place a struct in the __ksymtab section */
>> #define ___EXPORT_SYMBOL(sym, sec)                                      \
>>         extern typeof(sym) sym;                                         \
>>         __CRC_SYMBOL(sym, sec)                                          \
>>         static const char __kstrtab_##sym[]                             \
>> -       __attribute__((section("__ksymtab_strings"), aligned(1)))       \
>> +       __attribute__((section("__ksymtab_strings"), used, aligned(1))) \
>>         = VMLINUX_SYMBOL_STR(sym);                                      \
>> -       static const struct kernel_symbol __ksymtab_##sym               \
>> -       __used                                                          \
>> -       __attribute__((section("___ksymtab" sec "+" #sym), used))       \
>> -       = { (unsigned long)&sym, __kstrtab_##sym }
>> +       __KSYMTAB_ENTRY(sym, sec)
>>
>> #if defined(__KSYM_DEPS__)
>>
>> diff --git a/kernel/module.c b/kernel/module.c
>> index 40f983cbea81..a45423dcc32d 100644
>> --- a/kernel/module.c
>> +++ b/kernel/module.c
>> @@ -539,12 +539,31 @@ static bool check_symbol(const struct symsearch
>> *syms,
>>         return true;
>> }
>>
>> +static unsigned long kernel_symbol_value(const struct kernel_symbol *sym)
>> +{
>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>> +       return (unsigned long)&sym->value_offset + sym->value_offset;
>> +#else
>> +       return sym->value;
>> +#endif
>> +}
>> +
>> +static const char *kernel_symbol_name(const struct kernel_symbol *sym)
>> +{
>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>> +       return (const char *)((unsigned long)&sym->name_offset +
>> +                             sym->name_offset);
>> +#else
>> +       return sym->name;
>> +#endif
>> +}
>> +
>> static int cmp_name(const void *va, const void *vb)
>> {
>>         const char *a;
>>         const struct kernel_symbol *b;
>>         a = va; b = vb;
>> -       return strcmp(a, b->name);
>> +       return strcmp(a, kernel_symbol_name(b));
>> }
>>
>> static bool find_symbol_in_section(const struct symsearch *syms,
>> @@ -2190,7 +2209,7 @@ void *__symbol_get(const char *symbol)
>>                 sym = NULL;
>>         preempt_enable();
>>
>> -       return sym ? (void *)sym->value : NULL;
>> +       return sym ? (void *)kernel_symbol_value(sym) : NULL;
>> }
>> EXPORT_SYMBOL_GPL(__symbol_get);
>>
>> @@ -2220,10 +2239,12 @@ static int verify_export_symbols(struct module
>> *mod)
>>
>>         for (i = 0; i < ARRAY_SIZE(arr); i++) {
>>                 for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
>> -                       if (find_symbol(s->name, &owner, NULL, true,
>> false)) {
>> +                       if (find_symbol(kernel_symbol_name(s), &owner,
>> NULL,
>> +                                       true, false)) {
>>                                 pr_err("%s: exports duplicate symbol %s"
>>                                        " (owned by %s)\n",
>> -                                      mod->name, s->name,
>> module_name(owner));
>> +                                      mod->name, kernel_symbol_name(s),
>> +                                      module_name(owner));
>>                                 return -ENOEXEC;
>>                         }
>>                 }
>> @@ -2272,7 +2293,7 @@ static int simplify_symbols(struct module *mod,
>> const struct load_info *info)
>>                         ksym = resolve_symbol_wait(mod, info, name);
>>                         /* Ok if resolved.  */
>>                         if (ksym && !IS_ERR(ksym)) {
>> -                               sym[i].st_value = ksym->value;
>> +                               sym[i].st_value =
>> kernel_symbol_value(ksym);
>>                                 break;
>>                         }
>>
>> @@ -2532,7 +2553,7 @@ static int is_exported(const char *name, unsigned
>> long value,
>>                 ks = lookup_symbol(name, __start___ksymtab,
>> __stop___ksymtab);
>>         else
>>                 ks = lookup_symbol(name, mod->syms, mod->syms +
>> mod->num_syms);
>> -       return ks != NULL && ks->value == value;
>> +       return ks != NULL && kernel_symbol_value(ks) == value;
>> }
>>
>> /* As per nm */
>> --
>> 2.11.0
>>
>



-- 
Thomas

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

* Re: module: use relative references for __ksymtab entries
@ 2017-09-09 15:33       ` Thomas Garnier
  0 siblings, 0 replies; 38+ messages in thread
From: Thomas Garnier @ 2017-09-09 15:33 UTC (permalink / raw)
  To: Jessica Yu
  Cc: Ard Biesheuvel, LKML, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre

On Sat, Sep 9, 2017 at 6:08 AM, Jessica Yu <jeyu@kernel.org> wrote:
> +++ Ard Biesheuvel [19/08/17 19:10 +0100]:
>
>> An ordinary arm64 defconfig build has ~64 KB worth of __ksymtab
>> entries, each consisting of two 64-bit fields containing absolute
>> references, to the symbol itself and to a char array containing
>> its name, respectively.
>>
>> When we build the same configuration with KASLR enabled, we end
>> up with an additional ~192 KB of relocations in the .init section,
>> i.e., one 24 byte entry for each absolute reference, which all need
>> to be processed at boot time.
>>
>> Given how the struct kernel_symbol that describes each entry is
>> completely local to module.c (except for the references emitted
>> by EXPORT_SYMBOL() itself), we can easily modify it to contain
>> two 32-bit relative references instead. This reduces the size of
>> the __ksymtab section by 50% for all 64-bit architectures, and
>> gets rid of the runtime relocations entirely for architectures
>> implementing KASLR, either via standard PIE linking (arm64) or
>> using custom host tools (x86).
>>
>> Note that the binary search involving __ksymtab contents relies
>> on each section being sorted by symbol name. This is implemented
>> based on the input section names, not the names in the ksymtab
>> entries, so this patch does not interfere with that.
>>
>> Given that the use of place-relative relocations requires support
>> both in the toolchain and in the module loader, we cannot enable
>> this feature for all architectures. So make it dependend on whether
>> CONFIG_HAVE_ARCH_PREL32_RELOCATIONS is defined.

Good idea, I assume we may still get relocations given the compiler is
pretty bad at optimizing (_ptr - .) but I might be wrong. Anyway, the
size decrease is great and we can ignore these relocations if need be.
Thanks.

>>
>> Cc: Jessica Yu <jeyu@kernel.org>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Ingo Molnar <mingo@kernel.org>
>> Cc: Kees Cook <keescook@chromium.org>
>> Cc: Thomas Garnier <thgarnie@google.com>
>> Cc: Nicolas Pitre <nico@linaro.org>
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
>
> I ran this through some light testing and the relative ksymtab
> references seem to work just fine:
>
> Acked-by: Jessica Yu <jeyu@kernel.org> (for module changes)
>
>
>> arch/x86/include/asm/Kbuild   |  1 +
>> arch/x86/include/asm/export.h |  4 --
>> include/asm-generic/export.h  | 12 +++++-
>> include/linux/compiler.h      | 11 +++++
>> include/linux/export.h        | 45 +++++++++++++++-----
>> kernel/module.c               | 33 +++++++++++---
>> 6 files changed, 83 insertions(+), 23 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
>> index 5d6a53fd7521..3e8a88dcaa1d 100644
>> --- a/arch/x86/include/asm/Kbuild
>> +++ b/arch/x86/include/asm/Kbuild
>> @@ -9,5 +9,6 @@ generated-y += xen-hypercalls.h
>> generic-y += clkdev.h
>> generic-y += dma-contiguous.h
>> generic-y += early_ioremap.h
>> +generic-y += export.h
>> generic-y += mcs_spinlock.h
>> generic-y += mm-arch-hooks.h
>> diff --git a/arch/x86/include/asm/export.h b/arch/x86/include/asm/export.h
>> deleted file mode 100644
>> index 138de56b13eb..000000000000
>> --- a/arch/x86/include/asm/export.h
>> +++ /dev/null
>> @@ -1,4 +0,0 @@
>> -#ifdef CONFIG_64BIT
>> -#define KSYM_ALIGN 16
>> -#endif
>> -#include <asm-generic/export.h>
>> diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h
>> index 719db1968d81..97ce606459ae 100644
>> --- a/include/asm-generic/export.h
>> +++ b/include/asm-generic/export.h
>> @@ -5,12 +5,10 @@
>> #define KSYM_FUNC(x) x
>> #endif
>> #ifdef CONFIG_64BIT
>> -#define __put .quad
>> #ifndef KSYM_ALIGN
>> #define KSYM_ALIGN 8
>> #endif
>> #else
>> -#define __put .long
>> #ifndef KSYM_ALIGN
>> #define KSYM_ALIGN 4
>> #endif
>> @@ -25,6 +23,16 @@
>> #define KSYM(name) name
>> #endif
>>
>> +.macro __put, val, name
>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>> +       .long   \val - ., \name - .
>> +#elif defined(CONFIG_64BIT)
>> +       .quad   \val, \name
>> +#else
>> +       .long   \val, \name
>> +#endif
>> +.endm
>> +
>> /*
>>  * note on .section use: @progbits vs %progbits nastiness doesn't matter,
>>  * since we immediately emit into those sections anyway.
>> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
>> index eca8ad75e28b..363fb3e734ec 100644
>> --- a/include/linux/compiler.h
>> +++ b/include/linux/compiler.h
>> @@ -590,4 +590,15 @@ static __always_inline void
>> __write_once_size(volatile void *p, void *res, int s
>>         (_________p1); \
>> })
>>
>> +/*
>> + * Force the compiler to emit 'sym' as a symbol, so that we can reference
>> + * it from inline assembler. Necessary in case 'sym' could be inlined
>> + * otherwise, or eliminated entirely due to lack of references that are
>> + * visibile to the compiler.
>> + */
>> +#define __ADDRESSABLE(sym) \
>> +       static void *__attribute__((section(".discard.text"), used))    \
>> +               __PASTE(__discard_##sym, __LINE__)(void)                \
>> +                       { return (void *)&sym; }                        \
>> +
>> #endif /* __LINUX_COMPILER_H */
>> diff --git a/include/linux/export.h b/include/linux/export.h
>> index 1a1dfdb2a5c6..156b974181a4 100644
>> --- a/include/linux/export.h
>> +++ b/include/linux/export.h
>> @@ -24,12 +24,6 @@
>> #define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x)
>>
>> #ifndef __ASSEMBLY__
>> -struct kernel_symbol
>> -{
>> -       unsigned long value;
>> -       const char *name;
>> -};
>> -
>> #ifdef MODULE
>> extern struct module __this_module;
>> #define THIS_MODULE (&__this_module)
>> @@ -60,17 +54,46 @@ extern struct module __this_module;
>> #define __CRC_SYMBOL(sym, sec)
>> #endif
>>
>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>> +/*
>> + * Emit the ksymtab entry as a pair of relative references: this reduces
>> + * the size by half on 64-bit architectures, and eliminates the need for
>> + * absolute relocations that require runtime processing on relocatable
>> + * kernels.
>> + */
>> +#define __KSYMTAB_ENTRY(sym, sec)                                      \
>> +       __ADDRESSABLE(sym)                                              \
>> +       asm("   .section \"___ksymtab" sec "+" #sym "\", \"a\"  \n"     \
>> +           "   .balign 8                                       \n"     \
>> +           VMLINUX_SYMBOL_STR(__ksymtab_##sym) ":              \n"     \
>> +           "   .long " VMLINUX_SYMBOL_STR(sym) "- .            \n"     \
>> +           "   .long " VMLINUX_SYMBOL_STR(__kstrtab_##sym) "- .\n"     \
>> +           "   .previous                                       \n")
>> +
>> +struct kernel_symbol {
>> +       signed int value_offset;
>> +       signed int name_offset;
>> +};
>> +#else
>> +#define __KSYMTAB_ENTRY(sym, sec)                                      \
>> +       static const struct kernel_symbol __ksymtab_##sym               \
>> +       __attribute__((section("___ksymtab" sec "+" #sym), used))       \
>> +       = { (unsigned long)&sym, __kstrtab_##sym }
>> +
>> +struct kernel_symbol {
>> +       unsigned long value;
>> +       const char *name;
>> +};
>> +#endif
>> +
>> /* For every exported symbol, place a struct in the __ksymtab section */
>> #define ___EXPORT_SYMBOL(sym, sec)                                      \
>>         extern typeof(sym) sym;                                         \
>>         __CRC_SYMBOL(sym, sec)                                          \
>>         static const char __kstrtab_##sym[]                             \
>> -       __attribute__((section("__ksymtab_strings"), aligned(1)))       \
>> +       __attribute__((section("__ksymtab_strings"), used, aligned(1))) \
>>         = VMLINUX_SYMBOL_STR(sym);                                      \
>> -       static const struct kernel_symbol __ksymtab_##sym               \
>> -       __used                                                          \
>> -       __attribute__((section("___ksymtab" sec "+" #sym), used))       \
>> -       = { (unsigned long)&sym, __kstrtab_##sym }
>> +       __KSYMTAB_ENTRY(sym, sec)
>>
>> #if defined(__KSYM_DEPS__)
>>
>> diff --git a/kernel/module.c b/kernel/module.c
>> index 40f983cbea81..a45423dcc32d 100644
>> --- a/kernel/module.c
>> +++ b/kernel/module.c
>> @@ -539,12 +539,31 @@ static bool check_symbol(const struct symsearch
>> *syms,
>>         return true;
>> }
>>
>> +static unsigned long kernel_symbol_value(const struct kernel_symbol *sym)
>> +{
>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>> +       return (unsigned long)&sym->value_offset + sym->value_offset;
>> +#else
>> +       return sym->value;
>> +#endif
>> +}
>> +
>> +static const char *kernel_symbol_name(const struct kernel_symbol *sym)
>> +{
>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>> +       return (const char *)((unsigned long)&sym->name_offset +
>> +                             sym->name_offset);
>> +#else
>> +       return sym->name;
>> +#endif
>> +}
>> +
>> static int cmp_name(const void *va, const void *vb)
>> {
>>         const char *a;
>>         const struct kernel_symbol *b;
>>         a = va; b = vb;
>> -       return strcmp(a, b->name);
>> +       return strcmp(a, kernel_symbol_name(b));
>> }
>>
>> static bool find_symbol_in_section(const struct symsearch *syms,
>> @@ -2190,7 +2209,7 @@ void *__symbol_get(const char *symbol)
>>                 sym = NULL;
>>         preempt_enable();
>>
>> -       return sym ? (void *)sym->value : NULL;
>> +       return sym ? (void *)kernel_symbol_value(sym) : NULL;
>> }
>> EXPORT_SYMBOL_GPL(__symbol_get);
>>
>> @@ -2220,10 +2239,12 @@ static int verify_export_symbols(struct module
>> *mod)
>>
>>         for (i = 0; i < ARRAY_SIZE(arr); i++) {
>>                 for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
>> -                       if (find_symbol(s->name, &owner, NULL, true,
>> false)) {
>> +                       if (find_symbol(kernel_symbol_name(s), &owner,
>> NULL,
>> +                                       true, false)) {
>>                                 pr_err("%s: exports duplicate symbol %s"
>>                                        " (owned by %s)\n",
>> -                                      mod->name, s->name,
>> module_name(owner));
>> +                                      mod->name, kernel_symbol_name(s),
>> +                                      module_name(owner));
>>                                 return -ENOEXEC;
>>                         }
>>                 }
>> @@ -2272,7 +2293,7 @@ static int simplify_symbols(struct module *mod,
>> const struct load_info *info)
>>                         ksym = resolve_symbol_wait(mod, info, name);
>>                         /* Ok if resolved.  */
>>                         if (ksym && !IS_ERR(ksym)) {
>> -                               sym[i].st_value = ksym->value;
>> +                               sym[i].st_value =
>> kernel_symbol_value(ksym);
>>                                 break;
>>                         }
>>
>> @@ -2532,7 +2553,7 @@ static int is_exported(const char *name, unsigned
>> long value,
>>                 ks = lookup_symbol(name, __start___ksymtab,
>> __stop___ksymtab);
>>         else
>>                 ks = lookup_symbol(name, mod->syms, mod->syms +
>> mod->num_syms);
>> -       return ks != NULL && ks->value == value;
>> +       return ks != NULL && kernel_symbol_value(ks) == value;
>> }
>>
>> /* As per nm */
>> --
>> 2.11.0
>>
>



-- 
Thomas

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

* Re: module: use relative references for __ksymtab entries
  2017-09-09 15:33       ` Thomas Garnier
@ 2017-09-09 16:48         ` Ard Biesheuvel
  -1 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-09-09 16:48 UTC (permalink / raw)
  To: Thomas Garnier
  Cc: Jessica Yu, LKML, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven Rostedt, Martin Schwidefsky,
	Sergey Senozhatsky, Linus Torvalds, Ingo Molnar


> On 9 Sep 2017, at 16:33, Thomas Garnier <thgarnie@google.com> wrote:
> 
>> On Sat, Sep 9, 2017 at 6:08 AM, Jessica Yu <jeyu@kernel.org> wrote:
>> +++ Ard Biesheuvel [19/08/17 19:10 +0100]:
>> 
>>> An ordinary arm64 defconfig build has ~64 KB worth of __ksymtab
>>> entries, each consisting of two 64-bit fields containing absolute
>>> references, to the symbol itself and to a char array containing
>>> its name, respectively.
>>> 
>>> When we build the same configuration with KASLR enabled, we end
>>> up with an additional ~192 KB of relocations in the .init section,
>>> i.e., one 24 byte entry for each absolute reference, which all need
>>> to be processed at boot time.
>>> 
>>> Given how the struct kernel_symbol that describes each entry is
>>> completely local to module.c (except for the references emitted
>>> by EXPORT_SYMBOL() itself), we can easily modify it to contain
>>> two 32-bit relative references instead. This reduces the size of
>>> the __ksymtab section by 50% for all 64-bit architectures, and
>>> gets rid of the runtime relocations entirely for architectures
>>> implementing KASLR, either via standard PIE linking (arm64) or
>>> using custom host tools (x86).
>>> 
>>> Note that the binary search involving __ksymtab contents relies
>>> on each section being sorted by symbol name. This is implemented
>>> based on the input section names, not the names in the ksymtab
>>> entries, so this patch does not interfere with that.
>>> 
>>> Given that the use of place-relative relocations requires support
>>> both in the toolchain and in the module loader, we cannot enable
>>> this feature for all architectures. So make it dependend on whether
>>> CONFIG_HAVE_ARCH_PREL32_RELOCATIONS is defined.
> 
> Good idea, I assume we may still get relocations given the compiler is
> pretty bad at optimizing (_ptr - .) but I might be wrong.

The point is that the resulting place relative static relocations are fixed up at link time (and discarded) rather than being converted into dynamic R_xxx_RELATIVE relocations that require fixing up at runtime.

The compiler rarely emits place relative relocations, in my experience, but this is probably highly arch and CFLAGS dependent. I am not sure what you mean by 'optimizing' (<sym> - . ): if such expressions are emitted into asm, it is up to the assembler to fully resolve the expression or emit a place relative relocation, depending in whether <sym> has external linkage.

> Anyway, the
> size decrease is great and we can ignore these relocations if need be.

Yes, if you are using --emit-relocs and mangling static relocations manually (which I suppose is the case for x86), you can add any resulting place relative relocations to the ignore list, although I would assume they are already on it.

Thanks.

>>> 
>>> Cc: Jessica Yu <jeyu@kernel.org>
>>> Cc: Arnd Bergmann <arnd@arndb.de>
>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>> Cc: Ingo Molnar <mingo@kernel.org>
>>> Cc: Kees Cook <keescook@chromium.org>
>>> Cc: Thomas Garnier <thgarnie@google.com>
>>> Cc: Nicolas Pitre <nico@linaro.org>
>>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> 
>> 
>> I ran this through some light testing and the relative ksymtab
>> references seem to work just fine:
>> 
>> Acked-by: Jessica Yu <jeyu@kernel.org> (for module changes)
>> 
>> 
>>> arch/x86/include/asm/Kbuild   |  1 +
>>> arch/x86/include/asm/export.h |  4 --
>>> include/asm-generic/export.h  | 12 +++++-
>>> include/linux/compiler.h      | 11 +++++
>>> include/linux/export.h        | 45 +++++++++++++++-----
>>> kernel/module.c               | 33 +++++++++++---
>>> 6 files changed, 83 insertions(+), 23 deletions(-)
>>> 
>>> diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
>>> index 5d6a53fd7521..3e8a88dcaa1d 100644
>>> --- a/arch/x86/include/asm/Kbuild
>>> +++ b/arch/x86/include/asm/Kbuild
>>> @@ -9,5 +9,6 @@ generated-y += xen-hypercalls.h
>>> generic-y += clkdev.h
>>> generic-y += dma-contiguous.h
>>> generic-y += early_ioremap.h
>>> +generic-y += export.h
>>> generic-y += mcs_spinlock.h
>>> generic-y += mm-arch-hooks.h
>>> diff --git a/arch/x86/include/asm/export.h b/arch/x86/include/asm/export.h
>>> deleted file mode 100644
>>> index 138de56b13eb..000000000000
>>> --- a/arch/x86/include/asm/export.h
>>> +++ /dev/null
>>> @@ -1,4 +0,0 @@
>>> -#ifdef CONFIG_64BIT
>>> -#define KSYM_ALIGN 16
>>> -#endif
>>> -#include <asm-generic/export.h>
>>> diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h
>>> index 719db1968d81..97ce606459ae 100644
>>> --- a/include/asm-generic/export.h
>>> +++ b/include/asm-generic/export.h
>>> @@ -5,12 +5,10 @@
>>> #define KSYM_FUNC(x) x
>>> #endif
>>> #ifdef CONFIG_64BIT
>>> -#define __put .quad
>>> #ifndef KSYM_ALIGN
>>> #define KSYM_ALIGN 8
>>> #endif
>>> #else
>>> -#define __put .long
>>> #ifndef KSYM_ALIGN
>>> #define KSYM_ALIGN 4
>>> #endif
>>> @@ -25,6 +23,16 @@
>>> #define KSYM(name) name
>>> #endif
>>> 
>>> +.macro __put, val, name
>>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>>> +       .long   \val - ., \name - .
>>> +#elif defined(CONFIG_64BIT)
>>> +       .quad   \val, \name
>>> +#else
>>> +       .long   \val, \name
>>> +#endif
>>> +.endm
>>> +
>>> /*
>>> * note on .section use: @progbits vs %progbits nastiness doesn't matter,
>>> * since we immediately emit into those sections anyway.
>>> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
>>> index eca8ad75e28b..363fb3e734ec 100644
>>> --- a/include/linux/compiler.h
>>> +++ b/include/linux/compiler.h
>>> @@ -590,4 +590,15 @@ static __always_inline void
>>> __write_once_size(volatile void *p, void *res, int s
>>>        (_________p1); \
>>> })
>>> 
>>> +/*
>>> + * Force the compiler to emit 'sym' as a symbol, so that we can reference
>>> + * it from inline assembler. Necessary in case 'sym' could be inlined
>>> + * otherwise, or eliminated entirely due to lack of references that are
>>> + * visibile to the compiler.
>>> + */
>>> +#define __ADDRESSABLE(sym) \
>>> +       static void *__attribute__((section(".discard.text"), used))    \
>>> +               __PASTE(__discard_##sym, __LINE__)(void)                \
>>> +                       { return (void *)&sym; }                        \
>>> +
>>> #endif /* __LINUX_COMPILER_H */
>>> diff --git a/include/linux/export.h b/include/linux/export.h
>>> index 1a1dfdb2a5c6..156b974181a4 100644
>>> --- a/include/linux/export.h
>>> +++ b/include/linux/export.h
>>> @@ -24,12 +24,6 @@
>>> #define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x)
>>> 
>>> #ifndef __ASSEMBLY__
>>> -struct kernel_symbol
>>> -{
>>> -       unsigned long value;
>>> -       const char *name;
>>> -};
>>> -
>>> #ifdef MODULE
>>> extern struct module __this_module;
>>> #define THIS_MODULE (&__this_module)
>>> @@ -60,17 +54,46 @@ extern struct module __this_module;
>>> #define __CRC_SYMBOL(sym, sec)
>>> #endif
>>> 
>>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>>> +/*
>>> + * Emit the ksymtab entry as a pair of relative references: this reduces
>>> + * the size by half on 64-bit architectures, and eliminates the need for
>>> + * absolute relocations that require runtime processing on relocatable
>>> + * kernels.
>>> + */
>>> +#define __KSYMTAB_ENTRY(sym, sec)                                      \
>>> +       __ADDRESSABLE(sym)                                              \
>>> +       asm("   .section \"___ksymtab" sec "+" #sym "\", \"a\"  \n"     \
>>> +           "   .balign 8                                       \n"     \
>>> +           VMLINUX_SYMBOL_STR(__ksymtab_##sym) ":              \n"     \
>>> +           "   .long " VMLINUX_SYMBOL_STR(sym) "- .            \n"     \
>>> +           "   .long " VMLINUX_SYMBOL_STR(__kstrtab_##sym) "- .\n"     \
>>> +           "   .previous                                       \n")
>>> +
>>> +struct kernel_symbol {
>>> +       signed int value_offset;
>>> +       signed int name_offset;
>>> +};
>>> +#else
>>> +#define __KSYMTAB_ENTRY(sym, sec)                                      \
>>> +       static const struct kernel_symbol __ksymtab_##sym               \
>>> +       __attribute__((section("___ksymtab" sec "+" #sym), used))       \
>>> +       = { (unsigned long)&sym, __kstrtab_##sym }
>>> +
>>> +struct kernel_symbol {
>>> +       unsigned long value;
>>> +       const char *name;
>>> +};
>>> +#endif
>>> +
>>> /* For every exported symbol, place a struct in the __ksymtab section */
>>> #define ___EXPORT_SYMBOL(sym, sec)                                      \
>>>        extern typeof(sym) sym;                                         \
>>>        __CRC_SYMBOL(sym, sec)                                          \
>>>        static const char __kstrtab_##sym[]                             \
>>> -       __attribute__((section("__ksymtab_strings"), aligned(1)))       \
>>> +       __attribute__((section("__ksymtab_strings"), used, aligned(1))) \
>>>        = VMLINUX_SYMBOL_STR(sym);                                      \
>>> -       static const struct kernel_symbol __ksymtab_##sym               \
>>> -       __used                                                          \
>>> -       __attribute__((section("___ksymtab" sec "+" #sym), used))       \
>>> -       = { (unsigned long)&sym, __kstrtab_##sym }
>>> +       __KSYMTAB_ENTRY(sym, sec)
>>> 
>>> #if defined(__KSYM_DEPS__)
>>> 
>>> diff --git a/kernel/module.c b/kernel/module.c
>>> index 40f983cbea81..a45423dcc32d 100644
>>> --- a/kernel/module.c
>>> +++ b/kernel/module.c
>>> @@ -539,12 +539,31 @@ static bool check_symbol(const struct symsearch
>>> *syms,
>>>        return true;
>>> }
>>> 
>>> +static unsigned long kernel_symbol_value(const struct kernel_symbol *sym)
>>> +{
>>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>>> +       return (unsigned long)&sym->value_offset + sym->value_offset;
>>> +#else
>>> +       return sym->value;
>>> +#endif
>>> +}
>>> +
>>> +static const char *kernel_symbol_name(const struct kernel_symbol *sym)
>>> +{
>>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>>> +       return (const char *)((unsigned long)&sym->name_offset +
>>> +                             sym->name_offset);
>>> +#else
>>> +       return sym->name;
>>> +#endif
>>> +}
>>> +
>>> static int cmp_name(const void *va, const void *vb)
>>> {
>>>        const char *a;
>>>        const struct kernel_symbol *b;
>>>        a = va; b = vb;
>>> -       return strcmp(a, b->name);
>>> +       return strcmp(a, kernel_symbol_name(b));
>>> }
>>> 
>>> static bool find_symbol_in_section(const struct symsearch *syms,
>>> @@ -2190,7 +2209,7 @@ void *__symbol_get(const char *symbol)
>>>                sym = NULL;
>>>        preempt_enable();
>>> 
>>> -       return sym ? (void *)sym->value : NULL;
>>> +       return sym ? (void *)kernel_symbol_value(sym) : NULL;
>>> }
>>> EXPORT_SYMBOL_GPL(__symbol_get);
>>> 
>>> @@ -2220,10 +2239,12 @@ static int verify_export_symbols(struct module
>>> *mod)
>>> 
>>>        for (i = 0; i < ARRAY_SIZE(arr); i++) {
>>>                for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
>>> -                       if (find_symbol(s->name, &owner, NULL, true,
>>> false)) {
>>> +                       if (find_symbol(kernel_symbol_name(s), &owner,
>>> NULL,
>>> +                                       true, false)) {
>>>                                pr_err("%s: exports duplicate symbol %s"
>>>                                       " (owned by %s)\n",
>>> -                                      mod->name, s->name,
>>> module_name(owner));
>>> +                                      mod->name, kernel_symbol_name(s),
>>> +                                      module_name(owner));
>>>                                return -ENOEXEC;
>>>                        }
>>>                }
>>> @@ -2272,7 +2293,7 @@ static int simplify_symbols(struct module *mod,
>>> const struct load_info *info)
>>>                        ksym = resolve_symbol_wait(mod, info, name);
>>>                        /* Ok if resolved.  */
>>>                        if (ksym && !IS_ERR(ksym)) {
>>> -                               sym[i].st_value = ksym->value;
>>> +                               sym[i].st_value =
>>> kernel_symbol_value(ksym);
>>>                                break;
>>>                        }
>>> 
>>> @@ -2532,7 +2553,7 @@ static int is_exported(const char *name, unsigned
>>> long value,
>>>                ks = lookup_symbol(name, __start___ksymtab,
>>> __stop___ksymtab);
>>>        else
>>>                ks = lookup_symbol(name, mod->syms, mod->syms +
>>> mod->num_syms);
>>> -       return ks != NULL && ks->value == value;
>>> +       return ks != NULL && kernel_symbol_value(ks) == value;
>>> }
>>> 
>>> /* As per nm */
>>> --
>>> 2.11.0
>>> 
>> 
> 
> 
> 
> -- 
> Thomas

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

* Re: module: use relative references for __ksymtab entries
@ 2017-09-09 16:48         ` Ard Biesheuvel
  0 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-09-09 16:48 UTC (permalink / raw)
  To: Thomas Garnier
  Cc: Jessica Yu, LKML, linux-arch, H. Peter Anvin, Arnd Bergmann,
	Heiko Carstens, Kees Cook, Will Deacon, Michael Ellerman,
	Thomas Gleixner, Serge E. Hallyn, Bjorn Helgaas,
	Benjamin Herrenschmidt, Paul Mackerras, Catalin Marinas,
	Petr Mladek, Ingo Molnar, James Morris, Andrew Morton,
	Nicolas Pitre, Steven


> On 9 Sep 2017, at 16:33, Thomas Garnier <thgarnie@google.com> wrote:
> 
>> On Sat, Sep 9, 2017 at 6:08 AM, Jessica Yu <jeyu@kernel.org> wrote:
>> +++ Ard Biesheuvel [19/08/17 19:10 +0100]:
>> 
>>> An ordinary arm64 defconfig build has ~64 KB worth of __ksymtab
>>> entries, each consisting of two 64-bit fields containing absolute
>>> references, to the symbol itself and to a char array containing
>>> its name, respectively.
>>> 
>>> When we build the same configuration with KASLR enabled, we end
>>> up with an additional ~192 KB of relocations in the .init section,
>>> i.e., one 24 byte entry for each absolute reference, which all need
>>> to be processed at boot time.
>>> 
>>> Given how the struct kernel_symbol that describes each entry is
>>> completely local to module.c (except for the references emitted
>>> by EXPORT_SYMBOL() itself), we can easily modify it to contain
>>> two 32-bit relative references instead. This reduces the size of
>>> the __ksymtab section by 50% for all 64-bit architectures, and
>>> gets rid of the runtime relocations entirely for architectures
>>> implementing KASLR, either via standard PIE linking (arm64) or
>>> using custom host tools (x86).
>>> 
>>> Note that the binary search involving __ksymtab contents relies
>>> on each section being sorted by symbol name. This is implemented
>>> based on the input section names, not the names in the ksymtab
>>> entries, so this patch does not interfere with that.
>>> 
>>> Given that the use of place-relative relocations requires support
>>> both in the toolchain and in the module loader, we cannot enable
>>> this feature for all architectures. So make it dependend on whether
>>> CONFIG_HAVE_ARCH_PREL32_RELOCATIONS is defined.
> 
> Good idea, I assume we may still get relocations given the compiler is
> pretty bad at optimizing (_ptr - .) but I might be wrong.

The point is that the resulting place relative static relocations are fixed up at link time (and discarded) rather than being converted into dynamic R_xxx_RELATIVE relocations that require fixing up at runtime.

The compiler rarely emits place relative relocations, in my experience, but this is probably highly arch and CFLAGS dependent. I am not sure what you mean by 'optimizing' (<sym> - . ): if such expressions are emitted into asm, it is up to the assembler to fully resolve the expression or emit a place relative relocation, depending in whether <sym> has external linkage.

> Anyway, the
> size decrease is great and we can ignore these relocations if need be.

Yes, if you are using --emit-relocs and mangling static relocations manually (which I suppose is the case for x86), you can add any resulting place relative relocations to the ignore list, although I would assume they are already on it.

Thanks.

>>> 
>>> Cc: Jessica Yu <jeyu@kernel.org>
>>> Cc: Arnd Bergmann <arnd@arndb.de>
>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>> Cc: Ingo Molnar <mingo@kernel.org>
>>> Cc: Kees Cook <keescook@chromium.org>
>>> Cc: Thomas Garnier <thgarnie@google.com>
>>> Cc: Nicolas Pitre <nico@linaro.org>
>>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> 
>> 
>> I ran this through some light testing and the relative ksymtab
>> references seem to work just fine:
>> 
>> Acked-by: Jessica Yu <jeyu@kernel.org> (for module changes)
>> 
>> 
>>> arch/x86/include/asm/Kbuild   |  1 +
>>> arch/x86/include/asm/export.h |  4 --
>>> include/asm-generic/export.h  | 12 +++++-
>>> include/linux/compiler.h      | 11 +++++
>>> include/linux/export.h        | 45 +++++++++++++++-----
>>> kernel/module.c               | 33 +++++++++++---
>>> 6 files changed, 83 insertions(+), 23 deletions(-)
>>> 
>>> diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
>>> index 5d6a53fd7521..3e8a88dcaa1d 100644
>>> --- a/arch/x86/include/asm/Kbuild
>>> +++ b/arch/x86/include/asm/Kbuild
>>> @@ -9,5 +9,6 @@ generated-y += xen-hypercalls.h
>>> generic-y += clkdev.h
>>> generic-y += dma-contiguous.h
>>> generic-y += early_ioremap.h
>>> +generic-y += export.h
>>> generic-y += mcs_spinlock.h
>>> generic-y += mm-arch-hooks.h
>>> diff --git a/arch/x86/include/asm/export.h b/arch/x86/include/asm/export.h
>>> deleted file mode 100644
>>> index 138de56b13eb..000000000000
>>> --- a/arch/x86/include/asm/export.h
>>> +++ /dev/null
>>> @@ -1,4 +0,0 @@
>>> -#ifdef CONFIG_64BIT
>>> -#define KSYM_ALIGN 16
>>> -#endif
>>> -#include <asm-generic/export.h>
>>> diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h
>>> index 719db1968d81..97ce606459ae 100644
>>> --- a/include/asm-generic/export.h
>>> +++ b/include/asm-generic/export.h
>>> @@ -5,12 +5,10 @@
>>> #define KSYM_FUNC(x) x
>>> #endif
>>> #ifdef CONFIG_64BIT
>>> -#define __put .quad
>>> #ifndef KSYM_ALIGN
>>> #define KSYM_ALIGN 8
>>> #endif
>>> #else
>>> -#define __put .long
>>> #ifndef KSYM_ALIGN
>>> #define KSYM_ALIGN 4
>>> #endif
>>> @@ -25,6 +23,16 @@
>>> #define KSYM(name) name
>>> #endif
>>> 
>>> +.macro __put, val, name
>>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>>> +       .long   \val - ., \name - .
>>> +#elif defined(CONFIG_64BIT)
>>> +       .quad   \val, \name
>>> +#else
>>> +       .long   \val, \name
>>> +#endif
>>> +.endm
>>> +
>>> /*
>>> * note on .section use: @progbits vs %progbits nastiness doesn't matter,
>>> * since we immediately emit into those sections anyway.
>>> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
>>> index eca8ad75e28b..363fb3e734ec 100644
>>> --- a/include/linux/compiler.h
>>> +++ b/include/linux/compiler.h
>>> @@ -590,4 +590,15 @@ static __always_inline void
>>> __write_once_size(volatile void *p, void *res, int s
>>>        (_________p1); \
>>> })
>>> 
>>> +/*
>>> + * Force the compiler to emit 'sym' as a symbol, so that we can reference
>>> + * it from inline assembler. Necessary in case 'sym' could be inlined
>>> + * otherwise, or eliminated entirely due to lack of references that are
>>> + * visibile to the compiler.
>>> + */
>>> +#define __ADDRESSABLE(sym) \
>>> +       static void *__attribute__((section(".discard.text"), used))    \
>>> +               __PASTE(__discard_##sym, __LINE__)(void)                \
>>> +                       { return (void *)&sym; }                        \
>>> +
>>> #endif /* __LINUX_COMPILER_H */
>>> diff --git a/include/linux/export.h b/include/linux/export.h
>>> index 1a1dfdb2a5c6..156b974181a4 100644
>>> --- a/include/linux/export.h
>>> +++ b/include/linux/export.h
>>> @@ -24,12 +24,6 @@
>>> #define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x)
>>> 
>>> #ifndef __ASSEMBLY__
>>> -struct kernel_symbol
>>> -{
>>> -       unsigned long value;
>>> -       const char *name;
>>> -};
>>> -
>>> #ifdef MODULE
>>> extern struct module __this_module;
>>> #define THIS_MODULE (&__this_module)
>>> @@ -60,17 +54,46 @@ extern struct module __this_module;
>>> #define __CRC_SYMBOL(sym, sec)
>>> #endif
>>> 
>>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>>> +/*
>>> + * Emit the ksymtab entry as a pair of relative references: this reduces
>>> + * the size by half on 64-bit architectures, and eliminates the need for
>>> + * absolute relocations that require runtime processing on relocatable
>>> + * kernels.
>>> + */
>>> +#define __KSYMTAB_ENTRY(sym, sec)                                      \
>>> +       __ADDRESSABLE(sym)                                              \
>>> +       asm("   .section \"___ksymtab" sec "+" #sym "\", \"a\"  \n"     \
>>> +           "   .balign 8                                       \n"     \
>>> +           VMLINUX_SYMBOL_STR(__ksymtab_##sym) ":              \n"     \
>>> +           "   .long " VMLINUX_SYMBOL_STR(sym) "- .            \n"     \
>>> +           "   .long " VMLINUX_SYMBOL_STR(__kstrtab_##sym) "- .\n"     \
>>> +           "   .previous                                       \n")
>>> +
>>> +struct kernel_symbol {
>>> +       signed int value_offset;
>>> +       signed int name_offset;
>>> +};
>>> +#else
>>> +#define __KSYMTAB_ENTRY(sym, sec)                                      \
>>> +       static const struct kernel_symbol __ksymtab_##sym               \
>>> +       __attribute__((section("___ksymtab" sec "+" #sym), used))       \
>>> +       = { (unsigned long)&sym, __kstrtab_##sym }
>>> +
>>> +struct kernel_symbol {
>>> +       unsigned long value;
>>> +       const char *name;
>>> +};
>>> +#endif
>>> +
>>> /* For every exported symbol, place a struct in the __ksymtab section */
>>> #define ___EXPORT_SYMBOL(sym, sec)                                      \
>>>        extern typeof(sym) sym;                                         \
>>>        __CRC_SYMBOL(sym, sec)                                          \
>>>        static const char __kstrtab_##sym[]                             \
>>> -       __attribute__((section("__ksymtab_strings"), aligned(1)))       \
>>> +       __attribute__((section("__ksymtab_strings"), used, aligned(1))) \
>>>        = VMLINUX_SYMBOL_STR(sym);                                      \
>>> -       static const struct kernel_symbol __ksymtab_##sym               \
>>> -       __used                                                          \
>>> -       __attribute__((section("___ksymtab" sec "+" #sym), used))       \
>>> -       = { (unsigned long)&sym, __kstrtab_##sym }
>>> +       __KSYMTAB_ENTRY(sym, sec)
>>> 
>>> #if defined(__KSYM_DEPS__)
>>> 
>>> diff --git a/kernel/module.c b/kernel/module.c
>>> index 40f983cbea81..a45423dcc32d 100644
>>> --- a/kernel/module.c
>>> +++ b/kernel/module.c
>>> @@ -539,12 +539,31 @@ static bool check_symbol(const struct symsearch
>>> *syms,
>>>        return true;
>>> }
>>> 
>>> +static unsigned long kernel_symbol_value(const struct kernel_symbol *sym)
>>> +{
>>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>>> +       return (unsigned long)&sym->value_offset + sym->value_offset;
>>> +#else
>>> +       return sym->value;
>>> +#endif
>>> +}
>>> +
>>> +static const char *kernel_symbol_name(const struct kernel_symbol *sym)
>>> +{
>>> +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
>>> +       return (const char *)((unsigned long)&sym->name_offset +
>>> +                             sym->name_offset);
>>> +#else
>>> +       return sym->name;
>>> +#endif
>>> +}
>>> +
>>> static int cmp_name(const void *va, const void *vb)
>>> {
>>>        const char *a;
>>>        const struct kernel_symbol *b;
>>>        a = va; b = vb;
>>> -       return strcmp(a, b->name);
>>> +       return strcmp(a, kernel_symbol_name(b));
>>> }
>>> 
>>> static bool find_symbol_in_section(const struct symsearch *syms,
>>> @@ -2190,7 +2209,7 @@ void *__symbol_get(const char *symbol)
>>>                sym = NULL;
>>>        preempt_enable();
>>> 
>>> -       return sym ? (void *)sym->value : NULL;
>>> +       return sym ? (void *)kernel_symbol_value(sym) : NULL;
>>> }
>>> EXPORT_SYMBOL_GPL(__symbol_get);
>>> 
>>> @@ -2220,10 +2239,12 @@ static int verify_export_symbols(struct module
>>> *mod)
>>> 
>>>        for (i = 0; i < ARRAY_SIZE(arr); i++) {
>>>                for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
>>> -                       if (find_symbol(s->name, &owner, NULL, true,
>>> false)) {
>>> +                       if (find_symbol(kernel_symbol_name(s), &owner,
>>> NULL,
>>> +                                       true, false)) {
>>>                                pr_err("%s: exports duplicate symbol %s"
>>>                                       " (owned by %s)\n",
>>> -                                      mod->name, s->name,
>>> module_name(owner));
>>> +                                      mod->name, kernel_symbol_name(s),
>>> +                                      module_name(owner));
>>>                                return -ENOEXEC;
>>>                        }
>>>                }
>>> @@ -2272,7 +2293,7 @@ static int simplify_symbols(struct module *mod,
>>> const struct load_info *info)
>>>                        ksym = resolve_symbol_wait(mod, info, name);
>>>                        /* Ok if resolved.  */
>>>                        if (ksym && !IS_ERR(ksym)) {
>>> -                               sym[i].st_value = ksym->value;
>>> +                               sym[i].st_value =
>>> kernel_symbol_value(ksym);
>>>                                break;
>>>                        }
>>> 
>>> @@ -2532,7 +2553,7 @@ static int is_exported(const char *name, unsigned
>>> long value,
>>>                ks = lookup_symbol(name, __start___ksymtab,
>>> __stop___ksymtab);
>>>        else
>>>                ks = lookup_symbol(name, mod->syms, mod->syms +
>>> mod->num_syms);
>>> -       return ks != NULL && ks->value == value;
>>> +       return ks != NULL && kernel_symbol_value(ks) == value;
>>> }
>>> 
>>> /* As per nm */
>>> --
>>> 2.11.0
>>> 
>> 
> 
> 
> 
> -- 
> Thomas

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

* Re: kernel: tracepoints: add support for relative references
  2017-09-05 12:49       ` Ard Biesheuvel
@ 2017-09-19 17:55         ` Steven Rostedt
  -1 siblings, 0 replies; 38+ messages in thread
From: Steven Rostedt @ 2017-09-19 17:55 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Jessica Yu, linux-kernel, linux-arch, H. Peter Anvin,
	Arnd Bergmann, Heiko Carstens, Kees Cook, Will Deacon,
	Michael Ellerman, Thomas Garnier, Thomas Gleixner,
	Serge E. Hallyn, Bjorn Helgaas, Benjamin Herrenschmidt,
	Paul Mackerras, Catalin Marinas, Petr Mladek, Ingo Molnar,
	James Morris, Andrew Morton, Nicolas Pitre, Martin Schwidefsky,
	Sergey Senozhatsky, Linus Torvalds

[-- Attachment #1: Type: text/plain, Size: 10443 bytes --]

On Tue, 5 Sep 2017 13:49:52 +0100
Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

> OK, thanks for spotting that.
> 
> I will fix and resend after the merge window closes.

I also just applied your patches (to 4.13-rc7) and ran the ftrace self
tests in tools/testing/selftests/ftrace/ftracetest and it triggered
this:


 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Tainted: G        W      
 -----------------------------
 /work/git/linux-trace.git/arch/x86/kernel/traps.c:305 entry code didn't wake RCU!
 
 other info that might help us debug this:

 
 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 no locks held by swapper/0/0.
 
 stack backtrace:
 CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W       4.13.0-rc7-test+ #101
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
 Call Trace:
  dump_stack+0x86/0xcf
  lockdep_rcu_suspicious+0xc5/0x100
  do_error_trap+0x125/0x130
  ? do_error_trap+0x5/0x130
  ? trace_hardirqs_off_thunk+0x1a/0x1c
  ? do_invalid_op+0x5/0x30
  do_invalid_op+0x20/0x30
  invalid_op+0x1e/0x30
 RIP: 0010:module_assert_mutex_or_preempt+0x34/0x40
 RSP: 0018:ffffffff81e03bc0 EFLAGS: 00010046
 RAX: 0000000000000000 RBX: ffffffffa000a077 RCX: 0000000000000002
 RDX: 0000000000000000 RSI: 00000000ffffffff RDI: 0000000000000046
 RBP: ffffffff81e03bc0 R08: ffffffff81e03f40 R09: 0000000000000000
 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
 R13: 0000000000000000 R14: ffffffff81e16500 R15: ffffffff81ed5760
  ? 0xffffffffa000a077
  __module_address+0x2c/0xf0
  ? 0xffffffffa000a077
  __module_text_address+0x12/0x60
  ? 0xffffffffa000a077
  is_module_text_address+0x1f/0x50
  ? 0xffffffffa000a077
  __kernel_text_address+0x30/0x90
  unwind_get_return_address+0x1f/0x30
  __save_stack_trace+0x83/0xd0
  ? 0xffffffffa000a077
  ? rcu_dynticks_eqs_exit+0x5/0x40
  save_stack_trace+0x1b/0x20
  check_stack+0xf8/0x2f0
  ? rcu_dynticks_eqs_enter+0x30/0x30
  stack_trace_call+0x6e/0x80
  0xffffffffa000a077
  ? ftrace_graph_caller+0x78/0xa8
  ? rcu_dynticks_eqs_exit+0x5/0x40
  rcu_dynticks_eqs_exit+0x5/0x40
  rcu_idle_exit+0xdf/0xf0
  ? rcu_dynticks_eqs_exit+0x5/0x40
  ? rcu_idle_exit+0xdf/0xf0
  do_idle+0x128/0x200
  cpu_startup_entry+0x1d/0x20
  rest_init+0xd6/0xe0
  start_kernel+0x40c/0x419
  ? early_idt_handler_array+0x120/0x120
  x86_64_start_reservations+0x2a/0x2c
  x86_64_start_kernel+0x13e/0x14d
  secondary_startup_64+0x9f/0x9f

 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Not tainted
 -----------------------------
 /work/git/linux-trace.git/kernel/workqueue.c:712 sched RCU or wq_pool_mutex should be held!

 other info that might help us debug this:


 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 2 locks held by swapper/0/0:
  #0:  (console_lock){+.+.+.}, at: [<ffffffff81118786>] vprintk_emit+0x246/0x3d0
  #1:  (printing_lock){......}, at: [<ffffffff81529749>] vt_console_print+0x49/0x3b0

 stack backtrace:
 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.13.0-rc7-test+ #101
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
 Call Trace:

 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Not tainted
 -----------------------------
 /work/git/linux-trace.git/include/linux/rcupdate.h:611 rcu_read_lock() used illegally while idle!

 other info that might help us debug this:


 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 3 locks held by swapper/0/0:
  #0:  (console_lock){+.+.+.}, at: [<ffffffff81118786>] vprintk_emit+0x246/0x3d0
  #1:  (printing_lock){......}, at: [<ffffffff81529749>] vt_console_print+0x49/0x3b0
  #2:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140

 stack backtrace:
 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.13.0-rc7-test+ #101
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
 Call Trace:

 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Not tainted
 -----------------------------
 /work/git/linux-trace.git/include/linux/rcupdate.h:662 rcu_read_unlock() used illegally while idle!

 other info that might help us debug this:


 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 4 locks held by swapper/0/0:
  #0:  (console_lock){+.+.+.}, at: [<ffffffff81118786>] vprintk_emit+0x246/0x3d0
  #1:  (printing_lock){......}, at: [<ffffffff81529749>] vt_console_print+0x49/0x3b0
  #2:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #3:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140

 stack backtrace:
 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.13.0-rc7-test+ #101
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
 Call Trace:

 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Not tainted
 -----------------------------
 /work/git/linux-trace.git/include/linux/rcupdate.h:611 rcu_read_lock() used illegally while idle!

 other info that might help us debug this:


 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 5 locks held by swapper/0/0:
  #0:  (console_lock){+.+.+.}, at: [<ffffffff81118786>] vprintk_emit+0x246/0x3d0
  #1:  (printing_lock){......}, at: [<ffffffff81529749>] vt_console_print+0x49/0x3b0
  #2:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #3:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #4:  (rcu_read_lock){......}, at: [<ffffffff811ca0a5>] is_bpf_text_address+0x5/0xe0

 stack backtrace:
 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.13.0-rc7-test+ #101
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
 Call Trace:

 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Not tainted
 -----------------------------
 /work/git/linux-trace.git/include/linux/rcupdate.h:662 rcu_read_unlock() used illegally while idle!

 other info that might help us debug this:


 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 6 locks held by swapper/0/0:
  #0:  (console_lock){+.+.+.}, at: [<ffffffff81118786>] vprintk_emit+0x246/0x3d0
  #1:  (printing_lock){......}, at: [<ffffffff81529749>] vt_console_print+0x49/0x3b0
  #2:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #3:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #4:  (rcu_read_lock){......}, at: [<ffffffff811ca0a5>] is_bpf_text_address+0x5/0xe0
  #5:  (rcu_read_lock){......}, at: [<ffffffff811ca0a5>] is_bpf_text_address+0x5/0xe0

 stack backtrace:
 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.13.0-rc7-test+ #101
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
 Call Trace:
  dump_stack+0x86/0xcf
  lockdep_rcu_suspicious+0xc5/0x100
  is_bpf_text_address+0xdc/0xe0
  __kernel_text_address+0x74/0x90
  show_trace_log_lvl+0x160/0x380
  ? dump_stack+0x86/0xcf
  show_stack+0x44/0x60
  dump_stack+0x86/0xcf
  lockdep_rcu_suspicious+0xc5/0x100
  is_bpf_text_address+0xb2/0xe0
  __kernel_text_address+0x74/0x90
  show_trace_log_lvl+0x160/0x380
  ? dump_stack+0x86/0xcf
  show_stack+0x44/0x60
  dump_stack+0x86/0xcf
  lockdep_rcu_suspicious+0xc5/0x100
  __is_insn_slot_addr+0x114/0x140
  __kernel_text_address+0x68/0x90
  show_trace_log_lvl+0x160/0x380
  ? dump_stack+0x86/0xcf
  show_stack+0x44/0x60
  dump_stack+0x86/0xcf
  lockdep_rcu_suspicious+0xc5/0x100
  __is_insn_slot_addr+0xe0/0x140
  __kernel_text_address+0x68/0x90
  show_trace_log_lvl+0x160/0x380
  ? dump_stack+0x86/0xcf
  show_stack+0x44/0x60
  dump_stack+0x86/0xcf
  lockdep_rcu_suspicious+0xc5/0x100
  get_work_pool+0x87/0x90
  __queue_work+0x9c/0x5e0
  queue_work_on+0x8a/0xa0

 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Not tainted
 -----------------------------
 /work/git/linux-trace.git/kernel/notifier.c:548 notify_die called but RCU thinks we're quiescent!

 other info that might help us debug this:


 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 6 locks held by swapper/0/0:
  #0:  (console_lock){+.+.+.}, at: [<ffffffff81118786>] vprintk_emit+0x246/0x3d0
  #1:  (printing_lock){......}, at: [<ffffffff81529749>] vt_console_print+0x49/0x3b0
  #2:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #3:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #4:  (rcu_read_lock){......}, at: [<ffffffff811ca0a5>] is_bpf_text_address+0x5/0xe0
  #5:  (rcu_read_lock){......}, at: [<ffffffff811ca0a5>] is_bpf_text_address+0x5/0xe0

 stack backtrace:
 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.13.0-rc7-test+ #101
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
 Call Trace:
  dump_stack+0x86/0xcf
  lockdep_rcu_suspicious+0xc5/0x100
  notify_die+0x72/0x80
  do_error_trap+0x54/0x130
  ? do_error_trap+0x5/0x130
  ? trace_hardirqs_off_thunk+0x1a/0x1c
  ? do_invalid_op+0x5/0x30

 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Not tainted
 -----------------------------
 /work/git/linux-trace.git/include/linux/rcupdate.h:611 rcu_read_lock() used illegally while idle!

 other info that might help us debug this:


 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 7 locks held by swapper/0/0:
  #0:  (console_lock){+.+.+.}, at: [<ffffffff81118786>] vprintk_emit+0x246/0x3d0
  #1:  (printing_lock){......}, at: [<ffffffff81529749>] vt_console_print+0x49/0x3b0
  #2:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #3:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_add
 Lost 1926 message(s)!


Config attached.

-- Steve

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 28432 bytes --]

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

* Re: kernel: tracepoints: add support for relative references
@ 2017-09-19 17:55         ` Steven Rostedt
  0 siblings, 0 replies; 38+ messages in thread
From: Steven Rostedt @ 2017-09-19 17:55 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Jessica Yu, linux-kernel, linux-arch, H. Peter Anvin,
	Arnd Bergmann, Heiko Carstens, Kees Cook, Will Deacon,
	Michael Ellerman, Thomas Garnier, Thomas Gleixner,
	Serge E. Hallyn, Bjorn Helgaas, Benjamin Herrenschmidt,
	Paul Mackerras, Catalin Marinas, Petr Mladek, Ingo Molnar,
	James Morris, Andr

[-- Attachment #1: Type: text/plain, Size: 10443 bytes --]

On Tue, 5 Sep 2017 13:49:52 +0100
Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

> OK, thanks for spotting that.
> 
> I will fix and resend after the merge window closes.

I also just applied your patches (to 4.13-rc7) and ran the ftrace self
tests in tools/testing/selftests/ftrace/ftracetest and it triggered
this:


 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Tainted: G        W      
 -----------------------------
 /work/git/linux-trace.git/arch/x86/kernel/traps.c:305 entry code didn't wake RCU!
 
 other info that might help us debug this:

 
 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 no locks held by swapper/0/0.
 
 stack backtrace:
 CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W       4.13.0-rc7-test+ #101
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
 Call Trace:
  dump_stack+0x86/0xcf
  lockdep_rcu_suspicious+0xc5/0x100
  do_error_trap+0x125/0x130
  ? do_error_trap+0x5/0x130
  ? trace_hardirqs_off_thunk+0x1a/0x1c
  ? do_invalid_op+0x5/0x30
  do_invalid_op+0x20/0x30
  invalid_op+0x1e/0x30
 RIP: 0010:module_assert_mutex_or_preempt+0x34/0x40
 RSP: 0018:ffffffff81e03bc0 EFLAGS: 00010046
 RAX: 0000000000000000 RBX: ffffffffa000a077 RCX: 0000000000000002
 RDX: 0000000000000000 RSI: 00000000ffffffff RDI: 0000000000000046
 RBP: ffffffff81e03bc0 R08: ffffffff81e03f40 R09: 0000000000000000
 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
 R13: 0000000000000000 R14: ffffffff81e16500 R15: ffffffff81ed5760
  ? 0xffffffffa000a077
  __module_address+0x2c/0xf0
  ? 0xffffffffa000a077
  __module_text_address+0x12/0x60
  ? 0xffffffffa000a077
  is_module_text_address+0x1f/0x50
  ? 0xffffffffa000a077
  __kernel_text_address+0x30/0x90
  unwind_get_return_address+0x1f/0x30
  __save_stack_trace+0x83/0xd0
  ? 0xffffffffa000a077
  ? rcu_dynticks_eqs_exit+0x5/0x40
  save_stack_trace+0x1b/0x20
  check_stack+0xf8/0x2f0
  ? rcu_dynticks_eqs_enter+0x30/0x30
  stack_trace_call+0x6e/0x80
  0xffffffffa000a077
  ? ftrace_graph_caller+0x78/0xa8
  ? rcu_dynticks_eqs_exit+0x5/0x40
  rcu_dynticks_eqs_exit+0x5/0x40
  rcu_idle_exit+0xdf/0xf0
  ? rcu_dynticks_eqs_exit+0x5/0x40
  ? rcu_idle_exit+0xdf/0xf0
  do_idle+0x128/0x200
  cpu_startup_entry+0x1d/0x20
  rest_init+0xd6/0xe0
  start_kernel+0x40c/0x419
  ? early_idt_handler_array+0x120/0x120
  x86_64_start_reservations+0x2a/0x2c
  x86_64_start_kernel+0x13e/0x14d
  secondary_startup_64+0x9f/0x9f

 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Not tainted
 -----------------------------
 /work/git/linux-trace.git/kernel/workqueue.c:712 sched RCU or wq_pool_mutex should be held!

 other info that might help us debug this:


 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 2 locks held by swapper/0/0:
  #0:  (console_lock){+.+.+.}, at: [<ffffffff81118786>] vprintk_emit+0x246/0x3d0
  #1:  (printing_lock){......}, at: [<ffffffff81529749>] vt_console_print+0x49/0x3b0

 stack backtrace:
 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.13.0-rc7-test+ #101
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
 Call Trace:

 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Not tainted
 -----------------------------
 /work/git/linux-trace.git/include/linux/rcupdate.h:611 rcu_read_lock() used illegally while idle!

 other info that might help us debug this:


 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 3 locks held by swapper/0/0:
  #0:  (console_lock){+.+.+.}, at: [<ffffffff81118786>] vprintk_emit+0x246/0x3d0
  #1:  (printing_lock){......}, at: [<ffffffff81529749>] vt_console_print+0x49/0x3b0
  #2:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140

 stack backtrace:
 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.13.0-rc7-test+ #101
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
 Call Trace:

 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Not tainted
 -----------------------------
 /work/git/linux-trace.git/include/linux/rcupdate.h:662 rcu_read_unlock() used illegally while idle!

 other info that might help us debug this:


 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 4 locks held by swapper/0/0:
  #0:  (console_lock){+.+.+.}, at: [<ffffffff81118786>] vprintk_emit+0x246/0x3d0
  #1:  (printing_lock){......}, at: [<ffffffff81529749>] vt_console_print+0x49/0x3b0
  #2:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #3:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140

 stack backtrace:
 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.13.0-rc7-test+ #101
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
 Call Trace:

 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Not tainted
 -----------------------------
 /work/git/linux-trace.git/include/linux/rcupdate.h:611 rcu_read_lock() used illegally while idle!

 other info that might help us debug this:


 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 5 locks held by swapper/0/0:
  #0:  (console_lock){+.+.+.}, at: [<ffffffff81118786>] vprintk_emit+0x246/0x3d0
  #1:  (printing_lock){......}, at: [<ffffffff81529749>] vt_console_print+0x49/0x3b0
  #2:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #3:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #4:  (rcu_read_lock){......}, at: [<ffffffff811ca0a5>] is_bpf_text_address+0x5/0xe0

 stack backtrace:
 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.13.0-rc7-test+ #101
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
 Call Trace:

 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Not tainted
 -----------------------------
 /work/git/linux-trace.git/include/linux/rcupdate.h:662 rcu_read_unlock() used illegally while idle!

 other info that might help us debug this:


 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 6 locks held by swapper/0/0:
  #0:  (console_lock){+.+.+.}, at: [<ffffffff81118786>] vprintk_emit+0x246/0x3d0
  #1:  (printing_lock){......}, at: [<ffffffff81529749>] vt_console_print+0x49/0x3b0
  #2:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #3:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #4:  (rcu_read_lock){......}, at: [<ffffffff811ca0a5>] is_bpf_text_address+0x5/0xe0
  #5:  (rcu_read_lock){......}, at: [<ffffffff811ca0a5>] is_bpf_text_address+0x5/0xe0

 stack backtrace:
 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.13.0-rc7-test+ #101
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
 Call Trace:
  dump_stack+0x86/0xcf
  lockdep_rcu_suspicious+0xc5/0x100
  is_bpf_text_address+0xdc/0xe0
  __kernel_text_address+0x74/0x90
  show_trace_log_lvl+0x160/0x380
  ? dump_stack+0x86/0xcf
  show_stack+0x44/0x60
  dump_stack+0x86/0xcf
  lockdep_rcu_suspicious+0xc5/0x100
  is_bpf_text_address+0xb2/0xe0
  __kernel_text_address+0x74/0x90
  show_trace_log_lvl+0x160/0x380
  ? dump_stack+0x86/0xcf
  show_stack+0x44/0x60
  dump_stack+0x86/0xcf
  lockdep_rcu_suspicious+0xc5/0x100
  __is_insn_slot_addr+0x114/0x140
  __kernel_text_address+0x68/0x90
  show_trace_log_lvl+0x160/0x380
  ? dump_stack+0x86/0xcf
  show_stack+0x44/0x60
  dump_stack+0x86/0xcf
  lockdep_rcu_suspicious+0xc5/0x100
  __is_insn_slot_addr+0xe0/0x140
  __kernel_text_address+0x68/0x90
  show_trace_log_lvl+0x160/0x380
  ? dump_stack+0x86/0xcf
  show_stack+0x44/0x60
  dump_stack+0x86/0xcf
  lockdep_rcu_suspicious+0xc5/0x100
  get_work_pool+0x87/0x90
  __queue_work+0x9c/0x5e0
  queue_work_on+0x8a/0xa0

 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Not tainted
 -----------------------------
 /work/git/linux-trace.git/kernel/notifier.c:548 notify_die called but RCU thinks we're quiescent!

 other info that might help us debug this:


 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 6 locks held by swapper/0/0:
  #0:  (console_lock){+.+.+.}, at: [<ffffffff81118786>] vprintk_emit+0x246/0x3d0
  #1:  (printing_lock){......}, at: [<ffffffff81529749>] vt_console_print+0x49/0x3b0
  #2:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #3:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #4:  (rcu_read_lock){......}, at: [<ffffffff811ca0a5>] is_bpf_text_address+0x5/0xe0
  #5:  (rcu_read_lock){......}, at: [<ffffffff811ca0a5>] is_bpf_text_address+0x5/0xe0

 stack backtrace:
 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.13.0-rc7-test+ #101
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
 Call Trace:
  dump_stack+0x86/0xcf
  lockdep_rcu_suspicious+0xc5/0x100
  notify_die+0x72/0x80
  do_error_trap+0x54/0x130
  ? do_error_trap+0x5/0x130
  ? trace_hardirqs_off_thunk+0x1a/0x1c
  ? do_invalid_op+0x5/0x30

 =============================
 WARNING: suspicious RCU usage
 4.13.0-rc7-test+ #101 Not tainted
 -----------------------------
 /work/git/linux-trace.git/include/linux/rcupdate.h:611 rcu_read_lock() used illegally while idle!

 other info that might help us debug this:


 RCU used illegally from idle CPU!
 rcu_scheduler_active = 2, debug_locks = 1
 RCU used illegally from extended quiescent state!
 7 locks held by swapper/0/0:
  #0:  (console_lock){+.+.+.}, at: [<ffffffff81118786>] vprintk_emit+0x246/0x3d0
  #1:  (printing_lock){......}, at: [<ffffffff81529749>] vt_console_print+0x49/0x3b0
  #2:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_addr+0x5/0x140
  #3:  (rcu_read_lock){......}, at: [<ffffffff8117d025>] __is_insn_slot_add
 Lost 1926 message(s)!


Config attached.

-- Steve

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 28432 bytes --]

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

* Re: kernel: tracepoints: add support for relative references
  2017-09-19 17:55         ` Steven Rostedt
@ 2017-09-20 19:29           ` Ard Biesheuvel
  -1 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-09-20 19:29 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Jessica Yu, linux-kernel, linux-arch, H. Peter Anvin,
	Arnd Bergmann, Heiko Carstens, Kees Cook, Will Deacon,
	Michael Ellerman, Thomas Garnier, Thomas Gleixner,
	Serge E. Hallyn, Bjorn Helgaas, Benjamin Herrenschmidt,
	Paul Mackerras, Catalin Marinas, Petr Mladek, Ingo Molnar,
	James Morris, Andrew Morton, Nicolas Pitre, Martin Schwidefsky,
	Sergey Senozhatsky, Linus Torvalds

[-- Attachment #1: Type: text/plain, Size: 4029 bytes --]

On 19 September 2017 at 10:55, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Tue, 5 Sep 2017 13:49:52 +0100
> Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
>> OK, thanks for spotting that.
>>
>> I will fix and resend after the merge window closes.
>
> I also just applied your patches (to 4.13-rc7) and ran the ftrace self
> tests in tools/testing/selftests/ftrace/ftracetest and it triggered
> this:
>

Thanks Steven.

I'm a bit puzzled how changing the struct tracepoint pointers into
relative references would result in a behavioral change like this, but
I take it this doesn't occur with a plain -rc7 build?
(Just asking)

Unfortunately, I am failing to reproduce this running a kernel built
from your .config on a 4-way SMP QEMU VM running under KVM (log below)

I do get a lot of trace_kprobe errors (attached), but I get these with
a plain v4.13-rc7 as well, so that seems unrelated.

So I will update my series to address the issue reported by Jessica,
and I would appreciate it if you can check whether that version still
triggers this issue, but there is not a whole lot I can do to fix it
atm.

Thanks,
Ard.





$ sudo tools/testing/selftests/ftrace/ftracetest
=== Ftrace unit tests ===
[1] Basic trace file check [PASS]
[2] Basic test for tracers [PASS]
[3] Basic trace clock test [PASS]
[4] Basic event tracing check [PASS]
[5] event tracing - enable/disable with event level files [PASS]
[6] event tracing - restricts events based on pid [PASS]
[7] event tracing - enable/disable with subsystem level files [PASS]
[8] event tracing - enable/disable with top level files [PASS]
[9] ftrace - function graph filters with stack tracer [PASS]
[10] ftrace - function graph filters [PASS]
[11] ftrace - test for function event triggers [PASS]
[12] ftrace - function glob filters [PASS]
[13] ftrace - function pid filters [PASS]
[14] ftrace - function profiler with function tracing [PASS]
[15] ftrace - test reading of set_ftrace_filter [PASS]
[16] ftrace - test for function traceon/off triggers [PASS]
[17] Test creation and deletion of trace instances while setting an event [PASS]
[18] Test creation and deletion of trace instances [PASS]
[19] Kprobe dynamic event - adding and removing [PASS]
[20] Kprobe dynamic event - busy event check [PASS]
[21] Kprobe dynamic event with arguments [PASS]
[22] Kprobes event arguments with types [PASS]
[23] Kprobe event auto/manual naming [PASS]
[24] Kprobe dynamic event with function tracer [PASS]
[25] Kprobe dynamic event - probing module [PASS]
[26] Kretprobe dynamic event with arguments [PASS]
[27] Kretprobe dynamic event with maxactive [PASS]
[28] Register/unregister many kprobe events [PASS]
[29] event trigger - test event enable/disable trigger [PASS]
[30] event trigger - test trigger filter [PASS]
[31] event trigger - test histogram modifiers [PASS]
[32] event trigger - test histogram trigger [PASS]
[33] event trigger - test multiple histogram triggers [PASS]
[34] event trigger - test snapshot-trigger [PASS]
[35] event trigger - test stacktrace-trigger [PASS]
[36] event trigger - test traceon/off trigger [PASS]
[37] (instance)  Basic test for tracers [PASS]
[38] (instance)  Basic trace clock test [PASS]
[39] (instance)  event tracing - enable/disable with event level files [PASS]
[40] (instance)  event tracing - restricts events based on pid [PASS]
[41] (instance)  event tracing - enable/disable with subsystem level
files [PASS]
[42] (instance)  ftrace - test for function event triggers [PASS]
[43] (instance)  ftrace - test for function traceon/off triggers [PASS]
[44] (instance)  event trigger - test event enable/disable trigger [PASS]
[45] (instance)  event trigger - test trigger filter [PASS]
[46] (instance)  event trigger - test histogram modifiers [PASS]
[47] (instance)  event trigger - test histogram trigger [PASS]
[48] (instance)  event trigger - test multiple histogram triggers [PASS]

# of passed:  48
# of failed:  0
# of unresolved:  0
# of untested:  0
# of unsupported:  0
# of xfailed:  0
# of undefined(test bug):  0

[-- Attachment #2: trace-kprobe-errors --]
[-- Type: application/octet-stream, Size: 26201 bytes --]

[   99.289129] trace_kprobe: Probe definition must be started with 'p', 'r' or '-'.
[   99.290203] trace_kprobe: Maxactive is too big (1000000 > 4096).
[   99.290698] trace_kprobe: Failed to parse maxactive.
[   99.700687] trace_kprobe: Could not insert probe at irq_stack_union+5: -2
[   99.701351] trace_kprobe: Could not insert probe at __per_cpu_start+5: -2
[   99.702182] trace_kprobe: Could not insert probe at exception_stacks+5: -22
[   99.702826] trace_kprobe: Could not insert probe at gdt_page+5: -22
[   99.703308] trace_kprobe: Could not insert probe at espfix_stack+5: -22
[   99.704602] trace_kprobe: Could not insert probe at this_cpu_off+5: -22
[   99.705095] trace_kprobe: Could not insert probe at x86_cpu_to_acpiid+5: -22
[   99.706427] trace_kprobe: Could not insert probe at x86_cpu_to_apicid+5: -22
[   99.707083] trace_kprobe: Could not insert probe at sched_core_priority+5: -22
[   99.707648] trace_kprobe: Could not insert probe at pmc_prev_left+5: -22
[   99.708227] trace_kprobe: Could not insert probe at cpu_hw_events+5: -22
[   99.709356] trace_kprobe: Could not insert probe at bts_ctx+5: -22
[   99.710037] trace_kprobe: Could not insert probe at pqr_state+5: -22
[   99.711152] trace_kprobe: Could not insert probe at pt_ctx+5: -22
[   99.711774] trace_kprobe: Could not insert probe at xen_clock_events+5: -22
[   99.712239] trace_kprobe: Could not insert probe at idt_desc+5: -22
[   99.712931] trace_kprobe: Could not insert probe at shadow_tls_desc+5: -22
[   99.713398] trace_kprobe: Could not insert probe at xen_current_cr3+5: -22
[   99.714112] trace_kprobe: Could not insert probe at rsp_scratch+5: -22
[   99.714903] trace_kprobe: Could not insert probe at update_debug_stack+5: -22
[   99.715381] trace_kprobe: Could not insert probe at nmi_state+5: -22
[   99.716073] trace_kprobe: Could not insert probe at last_nmi_rip+5: -22
[   99.716705] trace_kprobe: Could not insert probe at nmi_stats+5: -22
[   99.717186] trace_kprobe: Could not insert probe at vector_irq+5: -22
[   99.717877] trace_kprobe: Could not insert probe at __tss_limit_invalid+5: -22
[   99.718367] trace_kprobe: Could not insert probe at msr_misc_features_shadow+5: -22
[   99.719322] trace_kprobe: Could not insert probe at fpu_fpregs_owner_ctx+5: -22[  153.917543] serial8250: too much work for irq4

[   99.719954] trace_kprobe: Could not insert probe at debug_stack_addr+5: -22
[   99.720478] trace_kprobe: Could not insert probe at debug_stack_usage+5: -22
[   99.721156] trace_kprobe: Could not insert probe at debug_idt_ctr+5: -22
[   99.721801] trace_kprobe: Could not insert probe at __preempt_count+5: -22
[   99.722306] trace_kprobe: Could not insert probe at irq_count+5: -22
[   99.724132] trace_kprobe: Could not insert probe at irq_stack_ptr+5: -22
[   99.724748] trace_kprobe: Could not insert probe at orig_ist+5: -22
[   99.725225] trace_kprobe: Could not insert probe at current_task+5: -22
[   99.725885] trace_kprobe: Could not insert probe at mce_timer+5: -22
[   99.726367] trace_kprobe: Could not insert probe at mce_next_interval+5: -22
[   99.727792] trace_kprobe: Could not insert probe at injectm+5: -22
[   99.728258] trace_kprobe: Could not insert probe at mce_poll_count+5: -22
[   99.728951] trace_kprobe: Could not insert probe at mce_exception_count+5: -22
[   99.729482] trace_kprobe: Could not insert probe at cmci_storm_state+5: -22
[   99.730169] trace_kprobe: Could not insert probe at cmci_storm_cnt+5: -22
[   99.731578] trace_kprobe: Could not insert probe at cmci_time_stamp+5: -22
[   99.732062] trace_kprobe: Could not insert probe at cmci_backoff_cnt+5: -22
[   99.732663] trace_kprobe: Could not insert probe at threshold_banks+5: -22
[   99.733312] trace_kprobe: Could not insert probe at thermal_state+5: -22
[   99.733963] trace_kprobe: Could not insert probe at tsc_adjust+5: -22
[   99.735664] trace_kprobe: Could not insert probe at lapic_events+5: -22
[   99.736150] trace_kprobe: Could not insert probe at cpus_in_cluster+5: -22
[   99.736803] trace_kprobe: Could not insert probe at x86_cpu_to_logical_apicid+5: -22
[   99.737389] trace_kprobe: Could not insert probe at kprobe_ctlblk+5: -22
[   99.738017] trace_kprobe: Could not insert probe at current_kprobe+5: -22
[   99.739588] trace_kprobe: Could not insert probe at cpu_hpet_dev+5: -22
[   99.740072] trace_kprobe: Could not insert probe at steal_time+5: -22
[   99.740662] trace_kprobe: Could not insert probe at paravirt_lazy_mode+5: -22
[   99.741310] trace_kprobe: Could not insert probe at kmmio_ctx+5: -22
[   99.741937] trace_kprobe: Could not insert probe at cpu_trace+5: -22
[   99.742408] trace_kprobe: Could not insert probe at x86_cpu_to_node_map+5: -22
[   99.743947] trace_kprobe: Could not insert probe at cached_stacks+5: -22
[   99.744477] trace_kprobe: Could not insert probe at process_counts+5: -22
[   99.745166] trace_kprobe: Could not insert probe at __percpu_rwsem_rc_cpu_hotplug_lock+5: -22
[   99.745810] trace_kprobe: Could not insert probe at cpuhp_state+5: -22
[   99.746297] trace_kprobe: Could not insert probe at tasklet_hi_vec+5: -22
[   99.747387] trace_kprobe: Could not insert probe at tasklet_vec+5: -22
[   99.748247] trace_kprobe: Could not insert probe at ksoftirqd+5: -22
[   99.748885] trace_kprobe: Could not insert probe at wq_watchdog_touched_cpu+5: -22
[   99.749354] trace_kprobe: Could not insert probe at wq_rr_cpu_last+5: -22
[   99.750049] trace_kprobe: Could not insert probe at cpu_hotplug_state+5: -22
[   99.750958] trace_kprobe: Could not insert probe at idle_threads+5: -22
[   99.751834] trace_kprobe: Could not insert probe at kernel_cpustat+5: -22
[   99.752581] trace_kprobe: Could not insert probe at kstat+5: -22
[   99.753073] trace_kprobe: Could not insert probe at cpu_irqtime+5: -22
[   99.753649] trace_kprobe: Could not insert probe at select_idle_mask+5: -22
[   99.754305] trace_kprobe: Could not insert probe at rt_pull_head+5: -22
[   99.756120] trace_kprobe: Could not insert probe at rt_push_head+5: -22
[   99.756750] trace_kprobe: Could not insert probe at root_cpuacct_cpuusage+5: -22
[   99.757245] trace_kprobe: Could not insert probe at cpufreq_update_util_data+5: -22
[   99.757938] trace_kprobe: Could not insert probe at printk_pending+5: -22
[   99.758412] trace_kprobe: Could not insert probe at nmi_print_seq+5: -22
[   99.760021] trace_kprobe: Could not insert probe at printk_context+5: -22
[   99.760673] trace_kprobe: Could not insert probe at safe_print_seq+5: -22
[   99.761260] trace_kprobe: Could not insert probe at tasks_rcu_exit_srcu_srcu_data+5: -22
[   99.761881] trace_kprobe: Could not insert probe at disable_rcu_irq_enter+5: -22
[   99.762363] trace_kprobe: Could not insert probe at rcu_dynticks+5: -22
[   99.763913] trace_kprobe: Could not insert probe at cpu_profile_hits+5: -22
[   99.764376] trace_kprobe: Could not insert probe at timer_bases+5: -22
[   99.765097] trace_kprobe: Could not insert probe at hrtimer_bases+5: -22
[   99.765710] trace_kprobe: Could not insert probe at tick_percpu_dev+5: -22
[   99.766195] trace_kprobe: Could not insert probe at tick_cpu_device+5: -22
[   99.767829] trace_kprobe: Could not insert probe at tick_cpu_sched+5: -22
[   99.768313] trace_kprobe: Could not insert probe at cpu_stopper+5: -22
[   99.769017] trace_kprobe: Could not insert probe at kprobe_instance+5: -22
[   99.769585] trace_kprobe: Could not insert probe at hrtimer_interrupts_saved+5: -22
[   99.770226] trace_kprobe: Could not insert probe at softlockup_task_ptr_saved+5: -22
[   99.771757] trace_kprobe: Could not insert probe at soft_lockup_hrtimer_cnt+5: -22
[   99.772236] trace_kprobe: Could not insert probe at hrtimer_interrupts+5: -22
[   99.772938] trace_kprobe: Could not insert probe at soft_watchdog_warn+5: -22
[   99.773415] trace_kprobe: Could not insert probe at softlockup_touch_sync+5: -22
[   99.774124] trace_kprobe: Could not insert probe at watchdog_hrtimer+5: -22
[   99.775603] trace_kprobe: Could not insert probe at softlockup_watchdog+5: -22
[   99.776099] trace_kprobe: Could not insert probe at watchdog_touch_ts+5: -22
[   99.776716] trace_kprobe: Could not insert probe at last_timestamp+5: -22
[   99.777349] trace_kprobe: Could not insert probe at watchdog_ev+5: -22
[   99.777983] trace_kprobe: Could not insert probe at watchdog_nmi_touch+5: -22
[   99.779468] trace_kprobe: Could not insert probe at hard_watchdog_warn+5: -22
[   99.779984] trace_kprobe: Could not insert probe at listener_array+5: -22
[   99.780516] trace_kprobe: Could not insert probe at taskstats_seqnum+5: -22
[   99.781234] trace_kprobe: Could not insert probe at idle_ret_stack+5: -22
[   99.781872] trace_kprobe: Could not insert probe at ftrace_profile_stats+5: -22
[   99.782346] trace_kprobe: Could not insert probe at user_stack_count+5: -22
[   99.783942] trace_kprobe: Could not insert probe at ftrace_stack_reserve+5: -22
[   99.784401] trace_kprobe: Could not insert probe at ftrace_stack+5: -22
[   99.785115] trace_kprobe: Could not insert probe at trace_taskinfo_save+5: -22
[   99.785741] trace_kprobe: Could not insert probe at trace_buffered_event_cnt+5: -22
[   99.786244] trace_kprobe: Could not insert probe at trace_buffered_event+5: -22
[   99.787839] trace_kprobe: Could not insert probe at tracing_cpu+5: -22
[   99.788317] trace_kprobe: Could not insert probe at disable_stack_tracer+5: -22
[   99.789022] trace_kprobe: Could not insert probe at lazy_list+5: -22
[   99.789565] trace_kprobe: Could not insert probe at raised_list+5: -22
[   99.790198] trace_kprobe: Could not insert probe at bpf_user_rnd_state+5: -22
[   99.790884] trace_kprobe: Could not insert probe at nop_txn_flags+5: -22
[   99.792364] trace_kprobe: Could not insert probe at swevent_htable+5: -22
[   99.793011] trace_kprobe: Could not insert probe at perf_throttled_seq+5: -22
[   99.793557] trace_kprobe: Could not insert probe at perf_throttled_count+5: -22
[   99.794182] trace_kprobe: Could not insert probe at sched_cb_list+5: -22
[   99.795720] trace_kprobe: Could not insert probe at active_ctx_list+5: -22
[   99.796211] trace_kprobe: Could not insert probe at cgrp_cpuctx_list+5: -22
[   99.796923] trace_kprobe: Could not insert probe at running_sample_length+5: -22
[   99.797400] trace_kprobe: Could not insert probe at pmu_sb_events+5: -22
[   99.798114] trace_kprobe: Could not insert probe at perf_cgroup_events+5: -22
[   99.799766] trace_kprobe: Could not insert[  153.979562] serial8250: too much work for irq4
 probe at return_notifier_list+5: -22
[   99.800257] trace_kprobe: Could not insert probe at boot_nodestats+5: -22
[   99.800983] trace_kprobe: Could not insert probe at boot_pageset+5: -22
[   99.801561] trace_kprobe: Could not insert probe at bdp_ratelimits+5: -22
[   99.802231] trace_kprobe: Could not insert probe at dirty_throttle_leaks+5: -22
[   99.803544] trace_kprobe: Could not insert probe at activate_page_pvecs+5: -22
[   99.804085] trace_kprobe: Could not insert probe at lru_deactivate_file_pvecs+5: -22
[   99.804743] trace_kprobe: Could not insert probe at lru_rotate_pvecs+5: -22
[   99.805372] trace_kprobe: Could not insert probe at vmstat_work+5: -22
[   99.806014] trace_kprobe: Could not insert probe at vm_event_states+5: -22
[   99.806951] trace_kprobe: Could not insert probe at swp_slots+5: -22
[   99.807831] trace_kprobe: Could not insert probe at srcu_srcu_data+5: -22
[   99.808572] trace_kprobe: Could not insert probe at memcg_stock+5: -22
[   99.809080] trace_kprobe: Could not insert probe at nr_dentry_unused+5: -22
[   99.809673] trace_kprobe: Could not insert probe at nr_dentry+5: -22
[   99.810334] trace_kprobe: Could not insert probe at last_ino+5: -22
[   99.811575] trace_kprobe: Could not insert probe at bh_accounting+5: -22
[   99.812364] trace_kprobe: Could not insert probe at file_lock_list+5: -22
[   99.813030] trace_kprobe: Could not insert probe at dquot_srcu_srcu_data+5: -22
[   99.813600] trace_kprobe: Could not insert probe at debugfs_srcu_srcu_data+5: -22
[   99.814225] trace_kprobe: Could not insert probe at avc_cache_stats+5: -22
[   99.815827] trace_kprobe: Could not insert probe at net_rand_state+5: -22
[   99.816303] trace_kprobe: Could not insert probe at acpi_cstate+5: -22
[   99.817042] trace_kprobe: Could not insert probe at cpufreq_thermal_reduction_pctg+5: -22
[   99.817619] trace_kprobe: Could not insert probe at cpc_desc_ptr+5: -22
[   99.818229] trace_kprobe: Could not insert probe at xen_runstate+5: -22
[   99.819714] trace_kprobe: Could not insert probe at xed_nesting_count+5: -22
[   99.820199] trace_kprobe: Could not insert probe at ipi_to_irq+5: -22
[   99.820888] trace_kprobe: Could not insert probe at virq_to_irq+5: -22
[   99.821377] trace_kprobe: Could not insert probe at current_bit_idx+5: -22
[   99.822085] trace_kprobe: Could not insert probe at current_word_idx+5: -22
[   99.823542] trace_kprobe: Could not insert probe at cpu_evtchn_mask+5: -22
[   99.824044] trace_kprobe: Could not insert probe at cpu_control_block+5: -22
[   99.824685] trace_kprobe: Could not insert probe at bind_last_selected_cpu+5: -22
[   99.825340] trace_kprobe: Could not insert probe at batched_entropy_u32+5: -22
[   99.825991] trace_kprobe: Could not insert probe at batched_entropy_u64+5: -22
[   99.827650] trace_kprobe: Could not insert probe at proc_event_counts+5: -22
[   99.828166] trace_kprobe: Could not insert probe at device_links_srcu_srcu_data+5: -22
[   99.828858] trace_kprobe: Could not insert probe at wakeup_srcu_srcu_data+5: -22
[   99.829360] trace_kprobe: Could not insert probe at dax_srcu_srcu_data+5: -22
[   99.830074] trace_kprobe: Could not insert probe at scsi_format_log+5: -22
[   99.831625] trace_kprobe: Could not insert probe at cpufreq_cpu_data+5: -22
[   99.832121] trace_kprobe: Could not insert probe at sockets_in_use+5: -22
[   99.832777] trace_kprobe: Could not insert probe at netdev_alloc_cache+5: -22
[   99.833385] trace_kprobe: Could not insert probe at xmit_recursion+5: -22
[   99.834021] trace_kprobe: Could not insert probe at redirect_info+5: -22
[   99.835431] trace_kprobe: Could not insert probe at dm_cpu_data+5: -22
[   99.836076] trace_kprobe: Could not insert probe at nf_skb_duplicated+5: -22
[   99.836692] trace_kprobe: Could not insert probe at xt_recseq+5: -22
[   99.837185] trace_kprobe: Could not insert probe at rt_cache_stat+5: -22
[   99.837871] trace_kprobe: Could not insert probe at tcp_md5sig_pool+5: -22
[   99.838370] trace_kprobe: Could not insert probe at tsq_tasklet+5: -22
[   99.839968] trace_kprobe: Could not insert probe at ida_bitmap+5: -22
[   99.840507] trace_kprobe: Could not insert probe at radix_tree_preloads+5: -22
[   99.841165] trace_kprobe: Could not insert probe at irq_stat+5: -22
[   99.841781] trace_kprobe: Could not insert probe at cpu_tss+5: -22
[   99.842280] trace_kprobe: Could not insert probe at cpu_tlbstate+5: -22
[   99.843894] trace_kprobe: Could not insert probe at sched_clock_data+5: -22
[   99.844383] trace_kprobe: Could not insert probe at rcu_preempt_data+5: -22
[   99.845097] trace_kprobe: Could not insert probe at rcu_bh_data+5: -22
[   99.845715] trace_kprobe: Could not insert probe at rcu_sched_data+5: -22
[   99.846226] trace_kprobe: Could not insert probe at csd_data+5: -22
[   99.847871] trace_kprobe: Could not insert probe at cfd_data+5: -22
[   99.848358] trace_kprobe: Could not insert probe at softnet_data+5: -22
[   99.849082] trace_kprobe: Could not insert probe at rt_uncached_list+5: -22
[   99.849700] trace_kprobe: Could not insert probe at rt6_uncached_list+5: -22
[   99.850214] trace_kprobe: Could not insert probe at startup_64+5: -84
[   99.850216] trace_kprobe: Probing address(0xffffffff81000005) is not an instruction boundary.
[   99.851922] trace_kprobe: Could not insert probe at _stext+5: -84
[   99.851924] trace_kprobe: Probing address(0xffffffff81000005) is not an instruction boundary.
[   99.852474] trace_kprobe: Could not insert probe at _text+5: -84
[   99.852477] trace_kprobe: Probing address(0xffffffff81000005) is not an instruction boundary.
[   99.853818] trace_kprobe: Could not insert probe at verify_cpu+5: -84
[   99.853820] trace_kprobe: Probing address(0xffffffff810000d4) is not an instruction boundary.
[   99.854223] trace_kprobe: Could not insert probe at start_cpu0+5: -84
[   99.854224] trace_kprobe: Probing address(0xffffffff810001c5) is not an instruction boundary.
[   99.855876] trace_kprobe: Could not insert probe at bad_address+5: -84
[   99.855879] trace_kprobe: Probing address(0xffffffff810001d1) is not an instruction boundary.
[   99.856296] trace_kprobe: Could not insert probe at __startup_64+5: -84
[   99.856298] trace_kprobe: Probing address(0xffffffff810001d5) is not an instruction boundary.
[   99.857007] trace_kprobe: Could not insert probe at xen_hypercall_set_trap_table+5: -84
[   99.857010] trace_kprobe: Probing address(0xffffffff81001005) is not an instruction boundary.
[   99.857712] trace_kprobe: Could not insert probe at xen_hypercall_mmu_update+5: -84
[   99.857714] trace_kprobe: Probing address(0xffffffff81001025) is not an instruction boundary.
[   99.858139] trace_kprobe: Could not insert probe at xen_hypercall_set_gdt+5: -84
[   99.858141] trace_kprobe: Probing address(0xffffffff81001045) is not an instruction boundary.
[   99.859878] trace_kprobe: Could not insert probe at xen_hypercall_stack_switch+5: -84
[   99.859880] trace_kprobe: Probing address(0xffffffff81001065) is not an instruction boundary.
[   99.860318] trace_kprobe: Could not insert probe at xen_hypercall_set_callbacks+5: -84
[   99.860319] trace_kprobe: Probing address(0xffffffff81001085) is not an instruction boundary.
[   99.861038] trace_kprobe: Could not insert probe at xen_hypercall_fpu_taskswitch+5: -84
[   99.861041] trace_kprobe: Probing address(0xffffffff810010a5) is not an instruction boundary.
[   99.861749] trace_kprobe: Could not insert probe at xen_hypercall_sched_op_compat+5: -84
[   99.861751] trace_kprobe: Probing address(0xffffffff810010c5) is not an instruction boundary.
[   99.862227] trace_kprobe: Could not insert probe at xen_hypercall_platform_op+5: -84
[   99.862229] trace_kprobe: Probing address(0xffffffff810010e5) is not an instruction boundary.
[   99.863940] trace_kprobe: Could not insert probe at xen_hypercall_set_debugreg+5: -84
[   99.863942] trace_kprobe: Probing address(0xffffffff81001105) is not an instruction boundary.
[   99.864383] trace_kprobe: Could not insert probe at xen_hypercall_get_debugreg+5: -84
[   99.864384] trace_kprobe: Probing address(0xffffffff81001125) is not an instructio[  154.037803] serial8250: too much work for irq4
n boundary.
[   99.865167] trace_kprobe: Could not insert probe at xen_hypercall_update_descriptor+5: -84
[   99.865170] trace_kprobe: Probing address(0xffffffff81001145) is not an instruction boundary.
[   99.865830] trace_kprobe: Could not insert probe at xen_hypercall_memory_op+5: -84
[   99.865832] trace_kprobe: Probing address(0xffffffff81001185) is not an instruction boundary.
[   99.866253] trace_kprobe: Could not insert probe at xen_hypercall_multicall+5: -84
[   99.866255] trace_kprobe: Probing address(0xffffffff810011a5) is not an instruction boundary.
[   99.867921] trace_kprobe: Could not insert probe at xen_hypercall_update_va_mapping+5: -84
[   99.867923] trace_kprobe: Probing address(0xffffffff810011c5) is not an instruction boundary.
[   99.868351] trace_kprobe: Could not insert probe at xen_hypercall_set_timer_op+5: -84
[   99.868353] trace_kprobe: Probing address(0xffffffff810011e5) is not an instruction boundary.
[   99.869119] trace_kprobe: Could not insert probe at xen_hypercall_event_channel_op_compat+5: -84
[   99.869122] trace_kprobe: Probing address(0xffffffff81001205) is not an instruction boundary.
[   99.869787] trace_kprobe: Could not insert probe at xen_hypercall_xen_version+5: -84
[   99.869789] trace_kprobe: Probing address(0xffffffff81001225) is not an instruction boundary.
[   99.870208] trace_kprobe: Could not insert probe at xen_hypercall_console_io+5: -84
[   99.870210] trace_kprobe: Probing address(0xffffffff81001245) is not an instruction boundary.
[   99.871858] trace_kprobe: Could not insert probe at xen_hypercall_physdev_op_compat+5: -84
[   99.871860] trace_kprobe: Probing address(0xffffffff81001265) is not an instruction boundary.
[   99.872306] trace_kprobe: Could not insert probe at xen_hypercall_grant_table_op+5: -84
[   99.872308] trace_kprobe: Probing address(0xffffffff81001285) is not an instruction boundary.
[   99.873000] trace_kprobe: Could not insert probe at xen_hypercall_vm_assist+5: -84
[   99.873003] trace_kprobe: Probing address(0xffffffff810012a5) is not an instruction boundary.
[   99.873729] trace_kprobe: Could not insert probe at xen_hypercall_update_va_mapping_otherdomain+5: -84
[   99.873730] trace_kprobe: Probing address(0xffffffff810012c5) is not an instruction boundary.
[   99.874157] trace_kprobe: Could not insert probe at xen_hypercall_iret+5: -84
[   99.874159] trace_kprobe: Probing address(0xffffffff810012e5) is not an instruction boundary.
[   99.875856] trace_kprobe: Could not insert probe at xen_hypercall_vcpu_op+5: -84
[   99.875858] trace_kprobe: Probing address(0xffffffff81001305) is not an instruction boundary.
[   99.876308] trace_kprobe: Could not insert probe at xen_hypercall_set_segment_base+5: -84
[   99.876310] trace_kprobe: Probing address(0xffffffff81001325) is not an instruction boundary.
[   99.877014] trace_kprobe: Could not insert probe at xen_hypercall_mmuext_op+5: -84
[   99.877017] trace_kprobe: Probing address(0xffffffff81001345) is not an instruction boundary.
[   99.877717] trace_kprobe: Could not insert probe at xen_hypercall_xsm_op+5: -84
[   99.877719] trace_kprobe: Probing address(0xffffffff81001365) is not an instruction boundary.
[   99.878147] trace_kprobe: Could not insert probe at xen_hypercall_nmi_op+5: -84
[   99.878149] trace_kprobe: Probing address(0xffffffff81001385) is not an instruction boundary.
[   99.879695] trace_kprobe: Could not insert probe at xen_hypercall_sched_op+5: -84
[   99.879698] trace_kprobe: Probing address(0xffffffff810013a5) is not an instruction boundary.
[   99.880352] trace_kprobe: Could not insert probe at xen_hypercall_callback_op+5: -84
[   99.880353] trace_kprobe: Probing address(0xffffffff810013c5) is not an instruction boundary.
[   99.881011] trace_kprobe: Could not insert probe at xen_hypercall_xenoprof_op+5: -84
[   99.881013] trace_kprobe: Probing address(0xffffffff810013e5) is not an instruction boundary.
[   99.881506] trace_kprobe: Could not insert probe at xen_hypercall_event_channel_op+5: -84
[   99.881509] trace_kprobe: Probing address(0xffffffff81001405) is not an instruction boundary.
[   99.882245] trace_kprobe: Could not insert probe at xen_hypercall_physdev_op+5: -84
[   99.882247] trace_kprobe: Probing address(0xffffffff81001425) is not an instruction boundary.
[   99.883737] trace_kprobe: Could not insert probe at xen_hypercall_hvm_op+5: -84
[   99.883739] trace_kprobe: Probing address(0xffffffff81001445) is not an instruction boundary.
[   99.884157] trace_kprobe: Could not insert probe at xen_hypercall_sysctl+5: -84
[   99.884159] trace_kprobe: Probing address(0xffffffff81001465) is not an instruction boundary.
[   99.884722] trace_kprobe: Could not insert probe at xen_hypercall_domctl+5: -84
[   99.884725] trace_kprobe: Probing address(0xffffffff81001485) is not an instruction boundary.
[   99.885480] trace_kprobe: Could not insert probe at xen_hypercall_kexec_op+5: -84
[   99.885483] trace_kprobe: Probing address(0xffffffff810014a5) is not an instruction boundary.
[   99.886121] trace_kprobe: Could not insert probe at xen_hypercall_tmem_op+5: -84
[   99.886122] trace_kprobe: Probing address(0xffffffff810014c5) is not an instruction boundary.
[   99.887643] trace_kprobe: Could not insert probe at xen_hypercall_xc_reserved_op+5: -84
[   99.887646] trace_kprobe: Probing address(0xffffffff810014e5) is not an instruction boundary.
[   99.888088] trace_kprobe: Could not insert probe at xen_hypercall_xenpmu_op+5: -84
[   99.888090] trace_kprobe: Probing address(0xffffffff81001505) is not an instruction boundary.
[   99.888588] trace_kprobe: Could not insert probe at xen_hypercall_dm_op+5: -84
[   99.888591] trace_kprobe: Probing address(0xffffffff81001525) is not an instruction boundary.
[   99.889309] trace_kprobe: Could not insert probe at xen_hypercall_mca+5: -84
[   99.889312] trace_kprobe: Probing address(0xffffffff81001605) is not an instruction boundary.
[   99.890040] trace_kprobe: Could not insert probe at xen_hypercall_arch_1+5: -84
[   99.890042] trace_kprobe: Probing address(0xffffffff81001625) is not an instruction boundary.
[   99.891520] trace_kprobe: Could not insert probe at xen_hypercall_arch_2+5: -84
[   99.891523] trace_kprobe: Probing address(0xffffffff81001645) is not an instruction boundary.
[   99.892129] trace_kprobe: Could not insert probe at xen_hypercall_arch_3+5: -84
[   99.892131] trace_kprobe: Probing address(0xffffffff81001665) is not an instruction boundary.
[   99.892675] trace_kprobe: Could not insert probe at xen_hypercall_arch_4+5: -84
[   99.892678] trace_kprobe: Probing address(0xffffffff81001685) is not an instruction boundary.
[   99.893330] trace_kprobe: Could not insert probe at xen_hypercall_arch_5+5: -84
[   99.893332] trace_kprobe: Probing address(0xffffffff810016a5) is not an instruction boundary.
[   99.893976] trace_kprobe: Could not insert probe at xen_hypercall_arch_6+5: -84
[   99.893978] trace_kprobe: Probing address(0xffffffff810016c5) is not an instruction boundary.
[   99.894392] trace_kprobe: Could not insert probe at xen_hypercall_arch_7+5: -84
[   99.894394] trace_kprobe: Probing address(0xffffffff810016e5) is not an instruction boundary.
[  153.691978] serial8250: too much work for irq4
[  153.747048] serial8250: too much work for irq4
[  153.808546] serial8250: too much work for irq4
[  153.863311] serial8250: too much work for irq4
[  153.917543] serial8250: too much work for irq4
[  153.979562] serial8250: too much work for irq4
[  154.037803] serial8250: too much work for irq4

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

* Re: kernel: tracepoints: add support for relative references
@ 2017-09-20 19:29           ` Ard Biesheuvel
  0 siblings, 0 replies; 38+ messages in thread
From: Ard Biesheuvel @ 2017-09-20 19:29 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Jessica Yu, linux-kernel, linux-arch, H. Peter Anvin,
	Arnd Bergmann, Heiko Carstens, Kees Cook, Will Deacon,
	Michael Ellerman, Thomas Garnier, Thomas Gleixner,
	Serge E. Hallyn, Bjorn Helgaas, Benjamin Herrenschmidt,
	Paul Mackerras, Catalin Marinas, Petr Mladek, Ingo Molnar,
	James Morris, Andr

[-- Attachment #1: Type: text/plain, Size: 4029 bytes --]

On 19 September 2017 at 10:55, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Tue, 5 Sep 2017 13:49:52 +0100
> Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
>> OK, thanks for spotting that.
>>
>> I will fix and resend after the merge window closes.
>
> I also just applied your patches (to 4.13-rc7) and ran the ftrace self
> tests in tools/testing/selftests/ftrace/ftracetest and it triggered
> this:
>

Thanks Steven.

I'm a bit puzzled how changing the struct tracepoint pointers into
relative references would result in a behavioral change like this, but
I take it this doesn't occur with a plain -rc7 build?
(Just asking)

Unfortunately, I am failing to reproduce this running a kernel built
from your .config on a 4-way SMP QEMU VM running under KVM (log below)

I do get a lot of trace_kprobe errors (attached), but I get these with
a plain v4.13-rc7 as well, so that seems unrelated.

So I will update my series to address the issue reported by Jessica,
and I would appreciate it if you can check whether that version still
triggers this issue, but there is not a whole lot I can do to fix it
atm.

Thanks,
Ard.





$ sudo tools/testing/selftests/ftrace/ftracetest
=== Ftrace unit tests ===
[1] Basic trace file check [PASS]
[2] Basic test for tracers [PASS]
[3] Basic trace clock test [PASS]
[4] Basic event tracing check [PASS]
[5] event tracing - enable/disable with event level files [PASS]
[6] event tracing - restricts events based on pid [PASS]
[7] event tracing - enable/disable with subsystem level files [PASS]
[8] event tracing - enable/disable with top level files [PASS]
[9] ftrace - function graph filters with stack tracer [PASS]
[10] ftrace - function graph filters [PASS]
[11] ftrace - test for function event triggers [PASS]
[12] ftrace - function glob filters [PASS]
[13] ftrace - function pid filters [PASS]
[14] ftrace - function profiler with function tracing [PASS]
[15] ftrace - test reading of set_ftrace_filter [PASS]
[16] ftrace - test for function traceon/off triggers [PASS]
[17] Test creation and deletion of trace instances while setting an event [PASS]
[18] Test creation and deletion of trace instances [PASS]
[19] Kprobe dynamic event - adding and removing [PASS]
[20] Kprobe dynamic event - busy event check [PASS]
[21] Kprobe dynamic event with arguments [PASS]
[22] Kprobes event arguments with types [PASS]
[23] Kprobe event auto/manual naming [PASS]
[24] Kprobe dynamic event with function tracer [PASS]
[25] Kprobe dynamic event - probing module [PASS]
[26] Kretprobe dynamic event with arguments [PASS]
[27] Kretprobe dynamic event with maxactive [PASS]
[28] Register/unregister many kprobe events [PASS]
[29] event trigger - test event enable/disable trigger [PASS]
[30] event trigger - test trigger filter [PASS]
[31] event trigger - test histogram modifiers [PASS]
[32] event trigger - test histogram trigger [PASS]
[33] event trigger - test multiple histogram triggers [PASS]
[34] event trigger - test snapshot-trigger [PASS]
[35] event trigger - test stacktrace-trigger [PASS]
[36] event trigger - test traceon/off trigger [PASS]
[37] (instance)  Basic test for tracers [PASS]
[38] (instance)  Basic trace clock test [PASS]
[39] (instance)  event tracing - enable/disable with event level files [PASS]
[40] (instance)  event tracing - restricts events based on pid [PASS]
[41] (instance)  event tracing - enable/disable with subsystem level
files [PASS]
[42] (instance)  ftrace - test for function event triggers [PASS]
[43] (instance)  ftrace - test for function traceon/off triggers [PASS]
[44] (instance)  event trigger - test event enable/disable trigger [PASS]
[45] (instance)  event trigger - test trigger filter [PASS]
[46] (instance)  event trigger - test histogram modifiers [PASS]
[47] (instance)  event trigger - test histogram trigger [PASS]
[48] (instance)  event trigger - test multiple histogram triggers [PASS]

# of passed:  48
# of failed:  0
# of unresolved:  0
# of untested:  0
# of unsupported:  0
# of xfailed:  0
# of undefined(test bug):  0

[-- Attachment #2: trace-kprobe-errors --]
[-- Type: application/octet-stream, Size: 26201 bytes --]

[   99.289129] trace_kprobe: Probe definition must be started with 'p', 'r' or '-'.
[   99.290203] trace_kprobe: Maxactive is too big (1000000 > 4096).
[   99.290698] trace_kprobe: Failed to parse maxactive.
[   99.700687] trace_kprobe: Could not insert probe at irq_stack_union+5: -2
[   99.701351] trace_kprobe: Could not insert probe at __per_cpu_start+5: -2
[   99.702182] trace_kprobe: Could not insert probe at exception_stacks+5: -22
[   99.702826] trace_kprobe: Could not insert probe at gdt_page+5: -22
[   99.703308] trace_kprobe: Could not insert probe at espfix_stack+5: -22
[   99.704602] trace_kprobe: Could not insert probe at this_cpu_off+5: -22
[   99.705095] trace_kprobe: Could not insert probe at x86_cpu_to_acpiid+5: -22
[   99.706427] trace_kprobe: Could not insert probe at x86_cpu_to_apicid+5: -22
[   99.707083] trace_kprobe: Could not insert probe at sched_core_priority+5: -22
[   99.707648] trace_kprobe: Could not insert probe at pmc_prev_left+5: -22
[   99.708227] trace_kprobe: Could not insert probe at cpu_hw_events+5: -22
[   99.709356] trace_kprobe: Could not insert probe at bts_ctx+5: -22
[   99.710037] trace_kprobe: Could not insert probe at pqr_state+5: -22
[   99.711152] trace_kprobe: Could not insert probe at pt_ctx+5: -22
[   99.711774] trace_kprobe: Could not insert probe at xen_clock_events+5: -22
[   99.712239] trace_kprobe: Could not insert probe at idt_desc+5: -22
[   99.712931] trace_kprobe: Could not insert probe at shadow_tls_desc+5: -22
[   99.713398] trace_kprobe: Could not insert probe at xen_current_cr3+5: -22
[   99.714112] trace_kprobe: Could not insert probe at rsp_scratch+5: -22
[   99.714903] trace_kprobe: Could not insert probe at update_debug_stack+5: -22
[   99.715381] trace_kprobe: Could not insert probe at nmi_state+5: -22
[   99.716073] trace_kprobe: Could not insert probe at last_nmi_rip+5: -22
[   99.716705] trace_kprobe: Could not insert probe at nmi_stats+5: -22
[   99.717186] trace_kprobe: Could not insert probe at vector_irq+5: -22
[   99.717877] trace_kprobe: Could not insert probe at __tss_limit_invalid+5: -22
[   99.718367] trace_kprobe: Could not insert probe at msr_misc_features_shadow+5: -22
[   99.719322] trace_kprobe: Could not insert probe at fpu_fpregs_owner_ctx+5: -22[  153.917543] serial8250: too much work for irq4

[   99.719954] trace_kprobe: Could not insert probe at debug_stack_addr+5: -22
[   99.720478] trace_kprobe: Could not insert probe at debug_stack_usage+5: -22
[   99.721156] trace_kprobe: Could not insert probe at debug_idt_ctr+5: -22
[   99.721801] trace_kprobe: Could not insert probe at __preempt_count+5: -22
[   99.722306] trace_kprobe: Could not insert probe at irq_count+5: -22
[   99.724132] trace_kprobe: Could not insert probe at irq_stack_ptr+5: -22
[   99.724748] trace_kprobe: Could not insert probe at orig_ist+5: -22
[   99.725225] trace_kprobe: Could not insert probe at current_task+5: -22
[   99.725885] trace_kprobe: Could not insert probe at mce_timer+5: -22
[   99.726367] trace_kprobe: Could not insert probe at mce_next_interval+5: -22
[   99.727792] trace_kprobe: Could not insert probe at injectm+5: -22
[   99.728258] trace_kprobe: Could not insert probe at mce_poll_count+5: -22
[   99.728951] trace_kprobe: Could not insert probe at mce_exception_count+5: -22
[   99.729482] trace_kprobe: Could not insert probe at cmci_storm_state+5: -22
[   99.730169] trace_kprobe: Could not insert probe at cmci_storm_cnt+5: -22
[   99.731578] trace_kprobe: Could not insert probe at cmci_time_stamp+5: -22
[   99.732062] trace_kprobe: Could not insert probe at cmci_backoff_cnt+5: -22
[   99.732663] trace_kprobe: Could not insert probe at threshold_banks+5: -22
[   99.733312] trace_kprobe: Could not insert probe at thermal_state+5: -22
[   99.733963] trace_kprobe: Could not insert probe at tsc_adjust+5: -22
[   99.735664] trace_kprobe: Could not insert probe at lapic_events+5: -22
[   99.736150] trace_kprobe: Could not insert probe at cpus_in_cluster+5: -22
[   99.736803] trace_kprobe: Could not insert probe at x86_cpu_to_logical_apicid+5: -22
[   99.737389] trace_kprobe: Could not insert probe at kprobe_ctlblk+5: -22
[   99.738017] trace_kprobe: Could not insert probe at current_kprobe+5: -22
[   99.739588] trace_kprobe: Could not insert probe at cpu_hpet_dev+5: -22
[   99.740072] trace_kprobe: Could not insert probe at steal_time+5: -22
[   99.740662] trace_kprobe: Could not insert probe at paravirt_lazy_mode+5: -22
[   99.741310] trace_kprobe: Could not insert probe at kmmio_ctx+5: -22
[   99.741937] trace_kprobe: Could not insert probe at cpu_trace+5: -22
[   99.742408] trace_kprobe: Could not insert probe at x86_cpu_to_node_map+5: -22
[   99.743947] trace_kprobe: Could not insert probe at cached_stacks+5: -22
[   99.744477] trace_kprobe: Could not insert probe at process_counts+5: -22
[   99.745166] trace_kprobe: Could not insert probe at __percpu_rwsem_rc_cpu_hotplug_lock+5: -22
[   99.745810] trace_kprobe: Could not insert probe at cpuhp_state+5: -22
[   99.746297] trace_kprobe: Could not insert probe at tasklet_hi_vec+5: -22
[   99.747387] trace_kprobe: Could not insert probe at tasklet_vec+5: -22
[   99.748247] trace_kprobe: Could not insert probe at ksoftirqd+5: -22
[   99.748885] trace_kprobe: Could not insert probe at wq_watchdog_touched_cpu+5: -22
[   99.749354] trace_kprobe: Could not insert probe at wq_rr_cpu_last+5: -22
[   99.750049] trace_kprobe: Could not insert probe at cpu_hotplug_state+5: -22
[   99.750958] trace_kprobe: Could not insert probe at idle_threads+5: -22
[   99.751834] trace_kprobe: Could not insert probe at kernel_cpustat+5: -22
[   99.752581] trace_kprobe: Could not insert probe at kstat+5: -22
[   99.753073] trace_kprobe: Could not insert probe at cpu_irqtime+5: -22
[   99.753649] trace_kprobe: Could not insert probe at select_idle_mask+5: -22
[   99.754305] trace_kprobe: Could not insert probe at rt_pull_head+5: -22
[   99.756120] trace_kprobe: Could not insert probe at rt_push_head+5: -22
[   99.756750] trace_kprobe: Could not insert probe at root_cpuacct_cpuusage+5: -22
[   99.757245] trace_kprobe: Could not insert probe at cpufreq_update_util_data+5: -22
[   99.757938] trace_kprobe: Could not insert probe at printk_pending+5: -22
[   99.758412] trace_kprobe: Could not insert probe at nmi_print_seq+5: -22
[   99.760021] trace_kprobe: Could not insert probe at printk_context+5: -22
[   99.760673] trace_kprobe: Could not insert probe at safe_print_seq+5: -22
[   99.761260] trace_kprobe: Could not insert probe at tasks_rcu_exit_srcu_srcu_data+5: -22
[   99.761881] trace_kprobe: Could not insert probe at disable_rcu_irq_enter+5: -22
[   99.762363] trace_kprobe: Could not insert probe at rcu_dynticks+5: -22
[   99.763913] trace_kprobe: Could not insert probe at cpu_profile_hits+5: -22
[   99.764376] trace_kprobe: Could not insert probe at timer_bases+5: -22
[   99.765097] trace_kprobe: Could not insert probe at hrtimer_bases+5: -22
[   99.765710] trace_kprobe: Could not insert probe at tick_percpu_dev+5: -22
[   99.766195] trace_kprobe: Could not insert probe at tick_cpu_device+5: -22
[   99.767829] trace_kprobe: Could not insert probe at tick_cpu_sched+5: -22
[   99.768313] trace_kprobe: Could not insert probe at cpu_stopper+5: -22
[   99.769017] trace_kprobe: Could not insert probe at kprobe_instance+5: -22
[   99.769585] trace_kprobe: Could not insert probe at hrtimer_interrupts_saved+5: -22
[   99.770226] trace_kprobe: Could not insert probe at softlockup_task_ptr_saved+5: -22
[   99.771757] trace_kprobe: Could not insert probe at soft_lockup_hrtimer_cnt+5: -22
[   99.772236] trace_kprobe: Could not insert probe at hrtimer_interrupts+5: -22
[   99.772938] trace_kprobe: Could not insert probe at soft_watchdog_warn+5: -22
[   99.773415] trace_kprobe: Could not insert probe at softlockup_touch_sync+5: -22
[   99.774124] trace_kprobe: Could not insert probe at watchdog_hrtimer+5: -22
[   99.775603] trace_kprobe: Could not insert probe at softlockup_watchdog+5: -22
[   99.776099] trace_kprobe: Could not insert probe at watchdog_touch_ts+5: -22
[   99.776716] trace_kprobe: Could not insert probe at last_timestamp+5: -22
[   99.777349] trace_kprobe: Could not insert probe at watchdog_ev+5: -22
[   99.777983] trace_kprobe: Could not insert probe at watchdog_nmi_touch+5: -22
[   99.779468] trace_kprobe: Could not insert probe at hard_watchdog_warn+5: -22
[   99.779984] trace_kprobe: Could not insert probe at listener_array+5: -22
[   99.780516] trace_kprobe: Could not insert probe at taskstats_seqnum+5: -22
[   99.781234] trace_kprobe: Could not insert probe at idle_ret_stack+5: -22
[   99.781872] trace_kprobe: Could not insert probe at ftrace_profile_stats+5: -22
[   99.782346] trace_kprobe: Could not insert probe at user_stack_count+5: -22
[   99.783942] trace_kprobe: Could not insert probe at ftrace_stack_reserve+5: -22
[   99.784401] trace_kprobe: Could not insert probe at ftrace_stack+5: -22
[   99.785115] trace_kprobe: Could not insert probe at trace_taskinfo_save+5: -22
[   99.785741] trace_kprobe: Could not insert probe at trace_buffered_event_cnt+5: -22
[   99.786244] trace_kprobe: Could not insert probe at trace_buffered_event+5: -22
[   99.787839] trace_kprobe: Could not insert probe at tracing_cpu+5: -22
[   99.788317] trace_kprobe: Could not insert probe at disable_stack_tracer+5: -22
[   99.789022] trace_kprobe: Could not insert probe at lazy_list+5: -22
[   99.789565] trace_kprobe: Could not insert probe at raised_list+5: -22
[   99.790198] trace_kprobe: Could not insert probe at bpf_user_rnd_state+5: -22
[   99.790884] trace_kprobe: Could not insert probe at nop_txn_flags+5: -22
[   99.792364] trace_kprobe: Could not insert probe at swevent_htable+5: -22
[   99.793011] trace_kprobe: Could not insert probe at perf_throttled_seq+5: -22
[   99.793557] trace_kprobe: Could not insert probe at perf_throttled_count+5: -22
[   99.794182] trace_kprobe: Could not insert probe at sched_cb_list+5: -22
[   99.795720] trace_kprobe: Could not insert probe at active_ctx_list+5: -22
[   99.796211] trace_kprobe: Could not insert probe at cgrp_cpuctx_list+5: -22
[   99.796923] trace_kprobe: Could not insert probe at running_sample_length+5: -22
[   99.797400] trace_kprobe: Could not insert probe at pmu_sb_events+5: -22
[   99.798114] trace_kprobe: Could not insert probe at perf_cgroup_events+5: -22
[   99.799766] trace_kprobe: Could not insert[  153.979562] serial8250: too much work for irq4
 probe at return_notifier_list+5: -22
[   99.800257] trace_kprobe: Could not insert probe at boot_nodestats+5: -22
[   99.800983] trace_kprobe: Could not insert probe at boot_pageset+5: -22
[   99.801561] trace_kprobe: Could not insert probe at bdp_ratelimits+5: -22
[   99.802231] trace_kprobe: Could not insert probe at dirty_throttle_leaks+5: -22
[   99.803544] trace_kprobe: Could not insert probe at activate_page_pvecs+5: -22
[   99.804085] trace_kprobe: Could not insert probe at lru_deactivate_file_pvecs+5: -22
[   99.804743] trace_kprobe: Could not insert probe at lru_rotate_pvecs+5: -22
[   99.805372] trace_kprobe: Could not insert probe at vmstat_work+5: -22
[   99.806014] trace_kprobe: Could not insert probe at vm_event_states+5: -22
[   99.806951] trace_kprobe: Could not insert probe at swp_slots+5: -22
[   99.807831] trace_kprobe: Could not insert probe at srcu_srcu_data+5: -22
[   99.808572] trace_kprobe: Could not insert probe at memcg_stock+5: -22
[   99.809080] trace_kprobe: Could not insert probe at nr_dentry_unused+5: -22
[   99.809673] trace_kprobe: Could not insert probe at nr_dentry+5: -22
[   99.810334] trace_kprobe: Could not insert probe at last_ino+5: -22
[   99.811575] trace_kprobe: Could not insert probe at bh_accounting+5: -22
[   99.812364] trace_kprobe: Could not insert probe at file_lock_list+5: -22
[   99.813030] trace_kprobe: Could not insert probe at dquot_srcu_srcu_data+5: -22
[   99.813600] trace_kprobe: Could not insert probe at debugfs_srcu_srcu_data+5: -22
[   99.814225] trace_kprobe: Could not insert probe at avc_cache_stats+5: -22
[   99.815827] trace_kprobe: Could not insert probe at net_rand_state+5: -22
[   99.816303] trace_kprobe: Could not insert probe at acpi_cstate+5: -22
[   99.817042] trace_kprobe: Could not insert probe at cpufreq_thermal_reduction_pctg+5: -22
[   99.817619] trace_kprobe: Could not insert probe at cpc_desc_ptr+5: -22
[   99.818229] trace_kprobe: Could not insert probe at xen_runstate+5: -22
[   99.819714] trace_kprobe: Could not insert probe at xed_nesting_count+5: -22
[   99.820199] trace_kprobe: Could not insert probe at ipi_to_irq+5: -22
[   99.820888] trace_kprobe: Could not insert probe at virq_to_irq+5: -22
[   99.821377] trace_kprobe: Could not insert probe at current_bit_idx+5: -22
[   99.822085] trace_kprobe: Could not insert probe at current_word_idx+5: -22
[   99.823542] trace_kprobe: Could not insert probe at cpu_evtchn_mask+5: -22
[   99.824044] trace_kprobe: Could not insert probe at cpu_control_block+5: -22
[   99.824685] trace_kprobe: Could not insert probe at bind_last_selected_cpu+5: -22
[   99.825340] trace_kprobe: Could not insert probe at batched_entropy_u32+5: -22
[   99.825991] trace_kprobe: Could not insert probe at batched_entropy_u64+5: -22
[   99.827650] trace_kprobe: Could not insert probe at proc_event_counts+5: -22
[   99.828166] trace_kprobe: Could not insert probe at device_links_srcu_srcu_data+5: -22
[   99.828858] trace_kprobe: Could not insert probe at wakeup_srcu_srcu_data+5: -22
[   99.829360] trace_kprobe: Could not insert probe at dax_srcu_srcu_data+5: -22
[   99.830074] trace_kprobe: Could not insert probe at scsi_format_log+5: -22
[   99.831625] trace_kprobe: Could not insert probe at cpufreq_cpu_data+5: -22
[   99.832121] trace_kprobe: Could not insert probe at sockets_in_use+5: -22
[   99.832777] trace_kprobe: Could not insert probe at netdev_alloc_cache+5: -22
[   99.833385] trace_kprobe: Could not insert probe at xmit_recursion+5: -22
[   99.834021] trace_kprobe: Could not insert probe at redirect_info+5: -22
[   99.835431] trace_kprobe: Could not insert probe at dm_cpu_data+5: -22
[   99.836076] trace_kprobe: Could not insert probe at nf_skb_duplicated+5: -22
[   99.836692] trace_kprobe: Could not insert probe at xt_recseq+5: -22
[   99.837185] trace_kprobe: Could not insert probe at rt_cache_stat+5: -22
[   99.837871] trace_kprobe: Could not insert probe at tcp_md5sig_pool+5: -22
[   99.838370] trace_kprobe: Could not insert probe at tsq_tasklet+5: -22
[   99.839968] trace_kprobe: Could not insert probe at ida_bitmap+5: -22
[   99.840507] trace_kprobe: Could not insert probe at radix_tree_preloads+5: -22
[   99.841165] trace_kprobe: Could not insert probe at irq_stat+5: -22
[   99.841781] trace_kprobe: Could not insert probe at cpu_tss+5: -22
[   99.842280] trace_kprobe: Could not insert probe at cpu_tlbstate+5: -22
[   99.843894] trace_kprobe: Could not insert probe at sched_clock_data+5: -22
[   99.844383] trace_kprobe: Could not insert probe at rcu_preempt_data+5: -22
[   99.845097] trace_kprobe: Could not insert probe at rcu_bh_data+5: -22
[   99.845715] trace_kprobe: Could not insert probe at rcu_sched_data+5: -22
[   99.846226] trace_kprobe: Could not insert probe at csd_data+5: -22
[   99.847871] trace_kprobe: Could not insert probe at cfd_data+5: -22
[   99.848358] trace_kprobe: Could not insert probe at softnet_data+5: -22
[   99.849082] trace_kprobe: Could not insert probe at rt_uncached_list+5: -22
[   99.849700] trace_kprobe: Could not insert probe at rt6_uncached_list+5: -22
[   99.850214] trace_kprobe: Could not insert probe at startup_64+5: -84
[   99.850216] trace_kprobe: Probing address(0xffffffff81000005) is not an instruction boundary.
[   99.851922] trace_kprobe: Could not insert probe at _stext+5: -84
[   99.851924] trace_kprobe: Probing address(0xffffffff81000005) is not an instruction boundary.
[   99.852474] trace_kprobe: Could not insert probe at _text+5: -84
[   99.852477] trace_kprobe: Probing address(0xffffffff81000005) is not an instruction boundary.
[   99.853818] trace_kprobe: Could not insert probe at verify_cpu+5: -84
[   99.853820] trace_kprobe: Probing address(0xffffffff810000d4) is not an instruction boundary.
[   99.854223] trace_kprobe: Could not insert probe at start_cpu0+5: -84
[   99.854224] trace_kprobe: Probing address(0xffffffff810001c5) is not an instruction boundary.
[   99.855876] trace_kprobe: Could not insert probe at bad_address+5: -84
[   99.855879] trace_kprobe: Probing address(0xffffffff810001d1) is not an instruction boundary.
[   99.856296] trace_kprobe: Could not insert probe at __startup_64+5: -84
[   99.856298] trace_kprobe: Probing address(0xffffffff810001d5) is not an instruction boundary.
[   99.857007] trace_kprobe: Could not insert probe at xen_hypercall_set_trap_table+5: -84
[   99.857010] trace_kprobe: Probing address(0xffffffff81001005) is not an instruction boundary.
[   99.857712] trace_kprobe: Could not insert probe at xen_hypercall_mmu_update+5: -84
[   99.857714] trace_kprobe: Probing address(0xffffffff81001025) is not an instruction boundary.
[   99.858139] trace_kprobe: Could not insert probe at xen_hypercall_set_gdt+5: -84
[   99.858141] trace_kprobe: Probing address(0xffffffff81001045) is not an instruction boundary.
[   99.859878] trace_kprobe: Could not insert probe at xen_hypercall_stack_switch+5: -84
[   99.859880] trace_kprobe: Probing address(0xffffffff81001065) is not an instruction boundary.
[   99.860318] trace_kprobe: Could not insert probe at xen_hypercall_set_callbacks+5: -84
[   99.860319] trace_kprobe: Probing address(0xffffffff81001085) is not an instruction boundary.
[   99.861038] trace_kprobe: Could not insert probe at xen_hypercall_fpu_taskswitch+5: -84
[   99.861041] trace_kprobe: Probing address(0xffffffff810010a5) is not an instruction boundary.
[   99.861749] trace_kprobe: Could not insert probe at xen_hypercall_sched_op_compat+5: -84
[   99.861751] trace_kprobe: Probing address(0xffffffff810010c5) is not an instruction boundary.
[   99.862227] trace_kprobe: Could not insert probe at xen_hypercall_platform_op+5: -84
[   99.862229] trace_kprobe: Probing address(0xffffffff810010e5) is not an instruction boundary.
[   99.863940] trace_kprobe: Could not insert probe at xen_hypercall_set_debugreg+5: -84
[   99.863942] trace_kprobe: Probing address(0xffffffff81001105) is not an instruction boundary.
[   99.864383] trace_kprobe: Could not insert probe at xen_hypercall_get_debugreg+5: -84
[   99.864384] trace_kprobe: Probing address(0xffffffff81001125) is not an instructio[  154.037803] serial8250: too much work for irq4
n boundary.
[   99.865167] trace_kprobe: Could not insert probe at xen_hypercall_update_descriptor+5: -84
[   99.865170] trace_kprobe: Probing address(0xffffffff81001145) is not an instruction boundary.
[   99.865830] trace_kprobe: Could not insert probe at xen_hypercall_memory_op+5: -84
[   99.865832] trace_kprobe: Probing address(0xffffffff81001185) is not an instruction boundary.
[   99.866253] trace_kprobe: Could not insert probe at xen_hypercall_multicall+5: -84
[   99.866255] trace_kprobe: Probing address(0xffffffff810011a5) is not an instruction boundary.
[   99.867921] trace_kprobe: Could not insert probe at xen_hypercall_update_va_mapping+5: -84
[   99.867923] trace_kprobe: Probing address(0xffffffff810011c5) is not an instruction boundary.
[   99.868351] trace_kprobe: Could not insert probe at xen_hypercall_set_timer_op+5: -84
[   99.868353] trace_kprobe: Probing address(0xffffffff810011e5) is not an instruction boundary.
[   99.869119] trace_kprobe: Could not insert probe at xen_hypercall_event_channel_op_compat+5: -84
[   99.869122] trace_kprobe: Probing address(0xffffffff81001205) is not an instruction boundary.
[   99.869787] trace_kprobe: Could not insert probe at xen_hypercall_xen_version+5: -84
[   99.869789] trace_kprobe: Probing address(0xffffffff81001225) is not an instruction boundary.
[   99.870208] trace_kprobe: Could not insert probe at xen_hypercall_console_io+5: -84
[   99.870210] trace_kprobe: Probing address(0xffffffff81001245) is not an instruction boundary.
[   99.871858] trace_kprobe: Could not insert probe at xen_hypercall_physdev_op_compat+5: -84
[   99.871860] trace_kprobe: Probing address(0xffffffff81001265) is not an instruction boundary.
[   99.872306] trace_kprobe: Could not insert probe at xen_hypercall_grant_table_op+5: -84
[   99.872308] trace_kprobe: Probing address(0xffffffff81001285) is not an instruction boundary.
[   99.873000] trace_kprobe: Could not insert probe at xen_hypercall_vm_assist+5: -84
[   99.873003] trace_kprobe: Probing address(0xffffffff810012a5) is not an instruction boundary.
[   99.873729] trace_kprobe: Could not insert probe at xen_hypercall_update_va_mapping_otherdomain+5: -84
[   99.873730] trace_kprobe: Probing address(0xffffffff810012c5) is not an instruction boundary.
[   99.874157] trace_kprobe: Could not insert probe at xen_hypercall_iret+5: -84
[   99.874159] trace_kprobe: Probing address(0xffffffff810012e5) is not an instruction boundary.
[   99.875856] trace_kprobe: Could not insert probe at xen_hypercall_vcpu_op+5: -84
[   99.875858] trace_kprobe: Probing address(0xffffffff81001305) is not an instruction boundary.
[   99.876308] trace_kprobe: Could not insert probe at xen_hypercall_set_segment_base+5: -84
[   99.876310] trace_kprobe: Probing address(0xffffffff81001325) is not an instruction boundary.
[   99.877014] trace_kprobe: Could not insert probe at xen_hypercall_mmuext_op+5: -84
[   99.877017] trace_kprobe: Probing address(0xffffffff81001345) is not an instruction boundary.
[   99.877717] trace_kprobe: Could not insert probe at xen_hypercall_xsm_op+5: -84
[   99.877719] trace_kprobe: Probing address(0xffffffff81001365) is not an instruction boundary.
[   99.878147] trace_kprobe: Could not insert probe at xen_hypercall_nmi_op+5: -84
[   99.878149] trace_kprobe: Probing address(0xffffffff81001385) is not an instruction boundary.
[   99.879695] trace_kprobe: Could not insert probe at xen_hypercall_sched_op+5: -84
[   99.879698] trace_kprobe: Probing address(0xffffffff810013a5) is not an instruction boundary.
[   99.880352] trace_kprobe: Could not insert probe at xen_hypercall_callback_op+5: -84
[   99.880353] trace_kprobe: Probing address(0xffffffff810013c5) is not an instruction boundary.
[   99.881011] trace_kprobe: Could not insert probe at xen_hypercall_xenoprof_op+5: -84
[   99.881013] trace_kprobe: Probing address(0xffffffff810013e5) is not an instruction boundary.
[   99.881506] trace_kprobe: Could not insert probe at xen_hypercall_event_channel_op+5: -84
[   99.881509] trace_kprobe: Probing address(0xffffffff81001405) is not an instruction boundary.
[   99.882245] trace_kprobe: Could not insert probe at xen_hypercall_physdev_op+5: -84
[   99.882247] trace_kprobe: Probing address(0xffffffff81001425) is not an instruction boundary.
[   99.883737] trace_kprobe: Could not insert probe at xen_hypercall_hvm_op+5: -84
[   99.883739] trace_kprobe: Probing address(0xffffffff81001445) is not an instruction boundary.
[   99.884157] trace_kprobe: Could not insert probe at xen_hypercall_sysctl+5: -84
[   99.884159] trace_kprobe: Probing address(0xffffffff81001465) is not an instruction boundary.
[   99.884722] trace_kprobe: Could not insert probe at xen_hypercall_domctl+5: -84
[   99.884725] trace_kprobe: Probing address(0xffffffff81001485) is not an instruction boundary.
[   99.885480] trace_kprobe: Could not insert probe at xen_hypercall_kexec_op+5: -84
[   99.885483] trace_kprobe: Probing address(0xffffffff810014a5) is not an instruction boundary.
[   99.886121] trace_kprobe: Could not insert probe at xen_hypercall_tmem_op+5: -84
[   99.886122] trace_kprobe: Probing address(0xffffffff810014c5) is not an instruction boundary.
[   99.887643] trace_kprobe: Could not insert probe at xen_hypercall_xc_reserved_op+5: -84
[   99.887646] trace_kprobe: Probing address(0xffffffff810014e5) is not an instruction boundary.
[   99.888088] trace_kprobe: Could not insert probe at xen_hypercall_xenpmu_op+5: -84
[   99.888090] trace_kprobe: Probing address(0xffffffff81001505) is not an instruction boundary.
[   99.888588] trace_kprobe: Could not insert probe at xen_hypercall_dm_op+5: -84
[   99.888591] trace_kprobe: Probing address(0xffffffff81001525) is not an instruction boundary.
[   99.889309] trace_kprobe: Could not insert probe at xen_hypercall_mca+5: -84
[   99.889312] trace_kprobe: Probing address(0xffffffff81001605) is not an instruction boundary.
[   99.890040] trace_kprobe: Could not insert probe at xen_hypercall_arch_1+5: -84
[   99.890042] trace_kprobe: Probing address(0xffffffff81001625) is not an instruction boundary.
[   99.891520] trace_kprobe: Could not insert probe at xen_hypercall_arch_2+5: -84
[   99.891523] trace_kprobe: Probing address(0xffffffff81001645) is not an instruction boundary.
[   99.892129] trace_kprobe: Could not insert probe at xen_hypercall_arch_3+5: -84
[   99.892131] trace_kprobe: Probing address(0xffffffff81001665) is not an instruction boundary.
[   99.892675] trace_kprobe: Could not insert probe at xen_hypercall_arch_4+5: -84
[   99.892678] trace_kprobe: Probing address(0xffffffff81001685) is not an instruction boundary.
[   99.893330] trace_kprobe: Could not insert probe at xen_hypercall_arch_5+5: -84
[   99.893332] trace_kprobe: Probing address(0xffffffff810016a5) is not an instruction boundary.
[   99.893976] trace_kprobe: Could not insert probe at xen_hypercall_arch_6+5: -84
[   99.893978] trace_kprobe: Probing address(0xffffffff810016c5) is not an instruction boundary.
[   99.894392] trace_kprobe: Could not insert probe at xen_hypercall_arch_7+5: -84
[   99.894394] trace_kprobe: Probing address(0xffffffff810016e5) is not an instruction boundary.
[  153.691978] serial8250: too much work for irq4
[  153.747048] serial8250: too much work for irq4
[  153.808546] serial8250: too much work for irq4
[  153.863311] serial8250: too much work for irq4
[  153.917543] serial8250: too much work for irq4
[  153.979562] serial8250: too much work for irq4
[  154.037803] serial8250: too much work for irq4

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

end of thread, other threads:[~2017-09-20 19:29 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-19 18:10 [PATCH v3 0/5] add support for relative references in special sections Ard Biesheuvel
2017-08-19 18:10 ` Ard Biesheuvel
2017-08-19 18:10 ` [PATCH v3 1/5] arch: enable relative relocations for arm64, power, x86, s390 and x86 Ard Biesheuvel
2017-08-19 18:10   ` Ard Biesheuvel
2017-08-19 18:10 ` [PATCH v3 2/5] module: use relative references for __ksymtab entries Ard Biesheuvel
2017-08-19 18:10   ` Ard Biesheuvel
2017-09-09 13:08   ` Jessica Yu
2017-09-09 13:08     ` Jessica Yu
2017-09-09 15:33     ` Thomas Garnier
2017-09-09 15:33       ` Thomas Garnier
2017-09-09 16:48       ` Ard Biesheuvel
2017-09-09 16:48         ` Ard Biesheuvel
2017-08-19 18:10 ` [PATCH v3 3/5] init: allow initcall tables to be emitted using relative references Ard Biesheuvel
2017-08-19 18:10   ` Ard Biesheuvel
2017-08-19 18:10 ` [PATCH v3 4/5] drivers: pci: add support for relative addressing in quirk tables Ard Biesheuvel
2017-08-19 18:10   ` Ard Biesheuvel
2017-08-19 18:10 ` [PATCH v3 5/5] kernel: tracepoints: add support for relative references Ard Biesheuvel
2017-08-19 18:10   ` Ard Biesheuvel
2017-08-20 14:51   ` Steven Rostedt
2017-08-20 14:51     ` Steven Rostedt
2017-08-30 12:52     ` Ard Biesheuvel
2017-08-30 12:52       ` Ard Biesheuvel
2017-08-30 13:17       ` Steven Rostedt
2017-08-30 13:17         ` Steven Rostedt
2017-08-30 13:18         ` Ard Biesheuvel
2017-08-30 13:18           ` Ard Biesheuvel
2017-08-30 18:13   ` Steven Rostedt
2017-08-30 18:13     ` Steven Rostedt
2017-08-30 18:26     ` Ard Biesheuvel
2017-08-30 18:26       ` Ard Biesheuvel
2017-09-05 12:48   ` Jessica Yu
2017-09-05 12:48     ` Jessica Yu
2017-09-05 12:49     ` Ard Biesheuvel
2017-09-05 12:49       ` Ard Biesheuvel
2017-09-19 17:55       ` Steven Rostedt
2017-09-19 17:55         ` Steven Rostedt
2017-09-20 19:29         ` Ard Biesheuvel
2017-09-20 19:29           ` Ard Biesheuvel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.