[PATCH v9 16/16] arm64: allow LTO to be selected

2020-12-11 Thread Sami Tolvanen
Allow CONFIG_LTO_CLANG to be enabled. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook Acked-by: Will Deacon --- arch/arm64/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index cf7eaaa0fb2f..59abe44845f3 100644 --- a/arch/arm64/Kconfig

[PATCH v9 11/16] scripts/mod: disable LTO for empty.c

2020-12-11 Thread Sami Tolvanen
With CONFIG_LTO_CLANG, clang generates LLVM IR instead of ELF object files. As empty.o is used for probing target properties, disable LTO for it to produce an object file instead. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- scripts/mod/Makefile | 1 + 1 file changed, 1 insertion

[PATCH v9 05/16] kbuild: lto: merge module sections

2020-12-11 Thread Sami Tolvanen
LLD always splits sections with LTO, which increases module sizes. This change adds linker script rules to merge the split sections in the final module. Suggested-by: Nick Desaulniers Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- scripts/module.lds.S | 24 1

[PATCH v9 08/16] init: lto: fix PREL32 relocations

2020-12-11 Thread Sami Tolvanen
are used. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- include/linux/init.h | 31 +++ 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/include/linux/init.h b/include/linux/init.h index d466bea7ecba..27b9478dcdef 100644 --- a/include/linux

[PATCH v9 14/16] arm64: vdso: disable LTO

2020-12-11 Thread Sami Tolvanen
Disable LTO for the vDSO by filtering out CC_FLAGS_LTO, as there's no point in using link-time optimization for the small amount of C code. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook Acked-by: Will Deacon --- arch/arm64/kernel/vdso/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1

[PATCH v9 09/16] PCI: Fix PREL32 relocations for LTO

2020-12-11 Thread Sami Tolvanen
when PREL32 relocations are used. Signed-off-by: Sami Tolvanen Acked-by: Bjorn Helgaas Reviewed-by: Kees Cook --- include/linux/pci.h | 19 ++- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/include/linux/pci.h b/include/linux/pci.h index 22207a79762c

[PATCH v9 03/16] kbuild: lto: fix module versioning

2020-12-11 Thread Sami Tolvanen
they are all linked into vmlinux.o at the same time. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- .gitignore | 1 + Makefile | 3 ++- arch/Kconfig | 1 - scripts/Makefile.build | 33 +++-- scripts/Makefile.modpost

[PATCH v9 02/16] kbuild: add support for Clang LTO

2020-12-11 Thread Sami Tolvanen
LLVM_IAS=1 To prepare for LTO support with other compilers, common parts are gated behind the CONFIG_LTO option, and LTO can be disabled for specific files by filtering out CC_FLAGS_LTO. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- Makefile | 19 ++- arch

[PATCH v9 00/16] Add support for Clang LTO

2020-12-11 Thread Sami Tolvanen
tion with LTO unless enabled. - Included Peter's proposed objtool mcount patch in the series and replaced recordmcount with the objtool pass to avoid whitelisting relocations that are not calls. - Updated several commit messages with better explanations. Sami Tolvanen (16): tracing:

Re: [PATCH v8 00/16] Add support for Clang LTO

2020-12-09 Thread Sami Tolvanen
On Wed, Dec 9, 2020 at 4:36 AM Arnd Bergmann wrote: > > On Tue, Dec 8, 2020 at 1:15 PM Arnd Bergmann wrote: > > > > - one build seems to have dropped all symbols the string operations > > from vmlinux, > > so while the link goes through, modules cannot be loaded: > > ERROR: modpost: "memmove"

Re: [PATCH v8 00/16] Add support for Clang LTO

2020-12-09 Thread Sami Tolvanen
On Tue, Dec 8, 2020 at 2:20 PM Arnd Bergmann wrote: > > On Tue, Dec 8, 2020 at 10:10 PM 'Nick Desaulniers' via Clang Built > Linux wrote: > > > > On Tue, Dec 8, 2020 at 1:00 PM Arnd Bergmann wrote: > > > > > > On Tue, Dec 8, 2020 at 5:43 PM 'Sami Tolva

Re: [PATCH v8 00/16] Add support for Clang LTO

2020-12-09 Thread Sami Tolvanen
On Tue, Dec 8, 2020 at 1:02 PM Arnd Bergmann wrote: > > On Tue, Dec 8, 2020 at 9:59 PM Arnd Bergmann wrote: > > > > Attaching the config for "ld.lld: error: Never resolved function from > > blockaddress (Producer: 'LLVM12.0.0' Reader: 'LLVM 12.0.0')" > > And here is a new one: "ld.lld: error:

Re: [PATCH v8 00/16] Add support for Clang LTO

2020-12-08 Thread Sami Tolvanen
On Tue, Dec 8, 2020 at 5:55 AM Arnd Bergmann wrote: > > On Tue, Dec 8, 2020 at 1:15 PM Arnd Bergmann wrote: > > On Tue, Dec 1, 2020 at 10:37 PM 'Sami Tolvanen' via Clang Built Linux > > wrote: > > > > - many builds complain about thousands of duplicate s

Re: [PATCH v8 00/16] Add support for Clang LTO

2020-12-08 Thread Sami Tolvanen
On Tue, Dec 8, 2020 at 4:15 AM Arnd Bergmann wrote: > > On Tue, Dec 1, 2020 at 10:37 PM 'Sami Tolvanen' via Clang Built Linux > wrote: > > > > This patch series adds support for building the kernel with Clang's > > Link Time Optimization (LTO). In addition

Re: [PATCH v8 00/16] Add support for Clang LTO

2020-12-06 Thread Sami Tolvanen
On Sat, Dec 5, 2020 at 10:50 PM Nathan Chancellor wrote: > > On Fri, Dec 04, 2020 at 02:52:41PM -0800, Sami Tolvanen wrote: > > On Thu, Dec 3, 2020 at 2:32 PM Nick Desaulniers > > wrote: > > > > > > So I'd recommend to Sami to simply make the Kconfig als

Re: [PATCH v8 00/16] Add support for Clang LTO

2020-12-04 Thread Sami Tolvanen
On Thu, Dec 3, 2020 at 2:32 PM Nick Desaulniers wrote: > > So I'd recommend to Sami to simply make the Kconfig also depend on > clang's integrated assembler (not just llvm-nm and llvm-ar). Sure, sounds good to me. What's the preferred way to test for this in Kconfig? It looks like actually

Re: [PATCH v6 14/25] kbuild: lto: remove duplicate dependencies from .mod files

2020-12-03 Thread Sami Tolvanen
On Thu, Dec 3, 2020 at 10:00 AM Masahiro Yamada wrote: > > On Thu, Oct 15, 2020 at 7:50 AM Kees Cook wrote: > > > > On Mon, Oct 12, 2020 at 05:31:52PM -0700, Sami Tolvanen wrote: > > > With LTO, llvm-nm prints out symbols for each archive member > > >

Re: [PATCH] kbuild: avoid split lines in .mod files

2020-12-03 Thread Sami Tolvanen
ppen because > scripts/gen_autoksyms.sh expects all undefined symbols are placed in > the second line of .mod files. > > One possible way is to replace "xargs echo" with > "sed ':x;N;$!bx;s/\n/ /g'" or something, but I rewrote the code by > using awk because it is more re

Re: [PATCH v8 00/16] Add support for Clang LTO

2020-12-03 Thread Sami Tolvanen
On Thu, Dec 3, 2020 at 3:26 AM Will Deacon wrote: > > Hi Sami, > > On Tue, Dec 01, 2020 at 01:36:51PM -0800, Sami Tolvanen wrote: > > This patch series adds support for building the kernel with Clang's > > Link Time Optimization (LTO). In addition to performance, th

Re: [PATCH v7 00/17] Add support for Clang LTO

2020-12-01 Thread Sami Tolvanen
On Tue, Dec 1, 2020 at 6:43 PM Masahiro Yamada wrote: > > On Wed, Dec 2, 2020 at 2:31 AM Kees Cook wrote: > > > > On Mon, Nov 30, 2020 at 12:01:31PM +, Will Deacon wrote: > > > Hi Sami, > > > > > > On Wed, Nov 18, 2020 at 02:07:14PM -0800, Sami T

[PATCH v8 16/16] arm64: allow LTO to be selected

2020-12-01 Thread Sami Tolvanen
Allow CONFIG_LTO_CLANG to be enabled. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook Acked-by: Will Deacon --- arch/arm64/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index c7f07978f5b6..9d29c48ecd4f 100644 --- a/arch/arm64/Kconfig

Re: [PATCH v7 00/17] Add support for Clang LTO

2020-12-01 Thread Sami Tolvanen
On Tue, Dec 1, 2020 at 11:51 AM 'Nick Desaulniers' via Clang Built Linux wrote: > > On Tue, Dec 1, 2020 at 9:31 AM Kees Cook wrote: > > > > On Mon, Nov 30, 2020 at 12:01:31PM +, Will Deacon wrote: > > > Hi Sami, > > > > > > On Wed, Nov 18,

[PATCH v8 13/16] drivers/misc/lkdtm: disable LTO for rodata.o

2020-12-01 Thread Sami Tolvanen
Disable LTO for rodata.o to allow objcopy to be used to manipulate sections. Signed-off-by: Sami Tolvanen Acked-by: Kees Cook --- drivers/misc/lkdtm/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/misc/lkdtm/Makefile b/drivers/misc/lkdtm/Makefile index c70b3822013f

[PATCH v8 15/16] arm64: disable recordmcount with DYNAMIC_FTRACE_WITH_REGS

2020-12-01 Thread Sami Tolvanen
work with LTO as we have LLVM bitcode instead of ELF objects. This change selects FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY, which disables recordmcount when patchable function entries are used instead. Signed-off-by: Sami Tolvanen Acked-by: Will Deacon --- arch/arm64/Kconfig | 2 ++ 1 file

[PATCH v8 14/16] arm64: vdso: disable LTO

2020-12-01 Thread Sami Tolvanen
Disable LTO for the vDSO by filtering out CC_FLAGS_LTO, as there's no point in using link-time optimization for the small amount of C code. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook Acked-by: Will Deacon --- arch/arm64/kernel/vdso/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1

[PATCH v8 12/16] efi/libstub: disable LTO

2020-12-01 Thread Sami Tolvanen
With CONFIG_LTO_CLANG, we produce LLVM bitcode instead of ELF object files. Since LTO is not really needed here and the Makefile assumes we produce an object file, disable LTO for libstub. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- drivers/firmware/efi/libstub/Makefile | 2 ++ 1

[PATCH v8 11/16] scripts/mod: disable LTO for empty.c

2020-12-01 Thread Sami Tolvanen
With CONFIG_LTO_CLANG, clang generates LLVM IR instead of ELF object files. As empty.o is used for probing target properties, disable LTO for it to produce an object file instead. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- scripts/mod/Makefile | 1 + 1 file changed, 1 insertion

[PATCH v8 09/16] PCI: Fix PREL32 relocations for LTO

2020-12-01 Thread Sami Tolvanen
when PREL32 relocations are used. Signed-off-by: Sami Tolvanen Acked-by: Bjorn Helgaas Reviewed-by: Kees Cook --- include/linux/pci.h | 19 ++- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/include/linux/pci.h b/include/linux/pci.h index 22207a79762c

[PATCH v8 10/16] modpost: lto: strip .lto from module names

2020-12-01 Thread Sami Tolvanen
Wendling Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- scripts/mod/modpost.c| 16 +++- scripts/mod/modpost.h| 9 + scripts/mod/sumversion.c | 6 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod

[PATCH v8 07/16] init: lto: ensure initcall ordering

2020-12-01 Thread Sami Tolvanen
script that specifies the same order for initcalls that we would have without LTO. With LTO enabled, the script is called in link-vmlinux.sh through jobserver-exec to limit the number of jobs spawned. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- include/linux/init.h | 52

[PATCH v8 08/16] init: lto: fix PREL32 relocations

2020-12-01 Thread Sami Tolvanen
are used. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- include/linux/init.h | 31 +++ 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/include/linux/init.h b/include/linux/init.h index d466bea7ecba..27b9478dcdef 100644 --- a/include/linux

[PATCH v8 05/16] kbuild: lto: merge module sections

2020-12-01 Thread Sami Tolvanen
LLD always splits sections with LTO, which increases module sizes. This change adds linker script rules to merge the split sections in the final module. Suggested-by: Nick Desaulniers Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- scripts/module.lds.S | 24 1

[PATCH v8 06/16] kbuild: lto: remove duplicate dependencies from .mod files

2020-12-01 Thread Sami Tolvanen
and split the dependency list to multiple lines, which results in used symbols getting trimmed. This change removes duplicate dependencies, which will reduce the probability of this happening and makes .mod files smaller and easier to read. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook

[PATCH v8 04/16] kbuild: lto: limit inlining

2020-12-01 Thread Sami Tolvanen
defconfig, we found that a limit of 5 is a reasonable compromise between performance and binary size, reducing the size of a stripped vmlinux by 11%. Suggested-by: George Burgess IV Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff

[PATCH v8 03/16] kbuild: lto: fix module versioning

2020-12-01 Thread Sami Tolvanen
they are all linked into vmlinux.o at the same time. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- .gitignore | 1 + Makefile | 3 ++- arch/Kconfig | 1 - scripts/Makefile.build | 33 +++-- scripts/Makefile.modpost

[PATCH v8 01/16] tracing: move function tracer options to Kconfig

2020-12-01 Thread Sami Tolvanen
in a different environment. Signed-off-by: Sami Tolvanen --- Makefile | 20 kernel/trace/Kconfig | 16 scripts/Makefile.build | 6 ++ 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 43ecedeb3f02

[PATCH v8 02/16] kbuild: add support for Clang LTO

2020-12-01 Thread Sami Tolvanen
LLVM tools must be used: CC=clang LD=ld.lld AR=llvm-ar NM=llvm-nm To prepare for LTO support with other compilers, common parts are gated behind the CONFIG_LTO option, and LTO can be disabled for specific files by filtering out CC_FLAGS_LTO. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook

[PATCH v8 00/16] Add support for Clang LTO

2020-12-01 Thread Sami Tolvanen
ies and replaced recordmcount with the objtool pass to avoid whitelisting relocations that are not calls. - Updated several commit messages with better explanations. Sami Tolvanen (17): tracing: move function tracer options to Kconfig kbuild: add support for Clang LTO kbuild: lto: fix mod

Re: [PATCH v3 0/2] scs: switch to vmapped shadow stacks

2020-12-01 Thread Sami Tolvanen
On Tue, Dec 1, 2020 at 3:40 AM Will Deacon wrote: > > On Mon, 30 Nov 2020 15:34:40 -0800, Sami Tolvanen wrote: > > As discussed a few months ago [1][2], virtually mapped shadow call stacks > > are better for safety and robustness. This series dusts off the VMAP > > opti

[tip: x86/misc] x86/pci: Fix the function type for check_reserved_t

2020-12-01 Thread tip-bot2 for Sami Tolvanen
The following commit has been merged into the x86/misc branch of tip: Commit-ID: 83321c335dccba262a57378361d63da96b8166d6 Gitweb: https://git.kernel.org/tip/83321c335dccba262a57378361d63da96b8166d6 Author:Sami Tolvanen AuthorDate:Mon, 30 Nov 2020 11:39:00 -08:00 Committer

Re: [PATCH v7 14/17] arm64: vdso: disable LTO

2020-11-30 Thread Sami Tolvanen
On Mon, Nov 30, 2020 at 3:52 AM Will Deacon wrote: > > On Wed, Nov 18, 2020 at 02:07:28PM -0800, Sami Tolvanen wrote: > > Disable LTO for the vDSO by filtering out CC_FLAGS_LTO, as there's no > > point in using link-time optimization for the small about of C code. > > &qu

[PATCH v3 0/2] scs: switch to vmapped shadow stacks

2020-11-30 Thread Sami Tolvanen
/sdei.c, and removed the now unneeded scs.c. Sami Tolvanen (2): scs: switch to vmapped shadow stacks arm64: scs: use vmapped IRQ and SDEI shadow stacks arch/arm64/kernel/Makefile | 1 - arch/arm64/kernel/entry.S | 6 ++-- arch/arm64/kernel/irq.c| 19 ++ arch/arm64/kernel/scs.c

[PATCH v3 2/2] arm64: scs: use vmapped IRQ and SDEI shadow stacks

2020-11-30 Thread Sami Tolvanen
Use scs_alloc() to allocate also IRQ and SDEI shadow stacks instead of using statically allocated stacks. Signed-off-by: Sami Tolvanen Acked-by: Will Deacon --- arch/arm64/kernel/Makefile | 1 - arch/arm64/kernel/entry.S | 6 ++-- arch/arm64/kernel/irq.c| 19 +++ arch/arm64

[PATCH v3 1/2] scs: switch to vmapped shadow stacks

2020-11-30 Thread Sami Tolvanen
shadow stack size to a full page and provides more robust overflow detection, similarly to VMAP_STACK. Signed-off-by: Sami Tolvanen Acked-by: Will Deacon --- include/linux/scs.h | 12 kernel/scs.c| 71 ++--- 2 files changed, 66 insertions

Re: [PATCH v2 2/2] arm64: scs: use vmapped IRQ and SDEI shadow stacks

2020-11-30 Thread Sami Tolvanen
On Mon, Nov 30, 2020 at 3:49 AM Will Deacon wrote: > > On Tue, Nov 24, 2020 at 11:59:40AM -0800, Sami Tolvanen wrote: > > Use scs_alloc() to allocate also IRQ and SDEI shadow stacks instead of > > using statically allocated stacks. > > > > Signed-off-by: Sami Tol

Re: [PATCH v2 1/2] scs: switch to vmapped shadow stacks

2020-11-30 Thread Sami Tolvanen
On Mon, Nov 30, 2020 at 3:44 AM Will Deacon wrote: > > On Tue, Nov 24, 2020 at 11:59:39AM -0800, Sami Tolvanen wrote: > > +void *scs_alloc(int node) > > { > > - void *s = kmem_cache_alloc_node(scs_cache, GFP_SCS, node); > > + int i; > > + vo

[PATCH v3] x86/pci: fix the function type for check_reserved_t

2020-11-30 Thread Sami Tolvanen
-by: Sami Tolvanen --- arch/x86/pci/mmconfig-shared.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c index 6fa42e9c4e6f..234998f196d4 100644 --- a/arch/x86/pci/mmconfig-shared.c +++ b/arch/x86/pci/mmconfig

Re: [PATCH] x86/e820: fix the function type for e820__mapped_all

2020-11-30 Thread Sami Tolvanen
On Fri, Nov 27, 2020 at 4:15 AM Borislav Petkov wrote: > I think the proper fix is to fix the typedef to: > > typedef bool (*check_reserved_t)(u64 start, u64 end, enum e820_type > type); > > because > > * is_mmconf_reserved() is passing in E820_TYPE_RESERVED which is enum > e820_type >

[PATCH v2 2/2] arm64: scs: use vmapped IRQ and SDEI shadow stacks

2020-11-24 Thread Sami Tolvanen
Use scs_alloc() to allocate also IRQ and SDEI shadow stacks instead of using statically allocated stacks. Signed-off-by: Sami Tolvanen --- arch/arm64/kernel/Makefile | 1 - arch/arm64/kernel/entry.S | 6 ++-- arch/arm64/kernel/irq.c| 19 ++ arch/arm64/kernel/scs.c| 16

[PATCH v2 0/2] scs: switch to vmapped shadow stacks

2020-11-24 Thread Sami Tolvanen
() to scs_alloc() when using a cached shadow stack instead of calling it in scs_free(). - Added a comment to scs_free(). - Moved arm64 IRQ and SDEI shadow stack initialization to irq/sdei.c, and removed the now unneeded scs.c. Sami Tolvanen (2): scs: switch to vmapped shadow stacks arm64: scs

[PATCH v2 1/2] scs: switch to vmapped shadow stacks

2020-11-24 Thread Sami Tolvanen
shadow stack size to a full page and provides more robust overflow detection, similarly to VMAP_STACK. Signed-off-by: Sami Tolvanen --- include/linux/scs.h | 12 - kernel/scs.c| 66 + 2 files changed, 61 insertions(+), 17 deletions(-) diff

Re: [PATCH v7 15/17] KVM: arm64: disable LTO for the nVHE directory

2020-11-23 Thread Sami Tolvanen
On Mon, Nov 23, 2020 at 2:21 AM David Brazdil wrote: > > Hey Sami, > > On Wed, Nov 18, 2020 at 02:07:29PM -0800, Sami Tolvanen wrote: > > We use objcopy to manipulate ELF binaries for the nVHE code, > > which fails with LTO as the compiler produces LLVM bitcode

Re: [PATCH v7 02/17] kbuild: add support for Clang LTO

2020-11-20 Thread Sami Tolvanen
On Fri, Nov 20, 2020 at 3:59 PM Kees Cook wrote: > > On Fri, Nov 20, 2020 at 12:58:41PM -0800, Sami Tolvanen wrote: > > On Fri, Nov 20, 2020 at 12:43 PM Kees Cook wrote: > > > > > > On Fri, Nov 20, 2020 at 01:29:35PM -0700, Nathan Chancellor wrote: > > &g

Re: [PATCH v7 02/17] kbuild: add support for Clang LTO

2020-11-20 Thread Sami Tolvanen
On Fri, Nov 20, 2020 at 12:43 PM Kees Cook wrote: > > On Fri, Nov 20, 2020 at 01:29:35PM -0700, Nathan Chancellor wrote: > > On Fri, Nov 20, 2020 at 11:47:21AM -0800, Kees Cook wrote: > > > On Fri, Nov 20, 2020 at 08:23:11AM -0800, Sami Tolvanen wrote: > > >

Re: [PATCH v7 00/17] Add support for Clang LTO

2020-11-20 Thread Sami Tolvanen
On Thu, Nov 19, 2020 at 8:04 PM Josh Poimboeuf wrote: > > On Wed, Nov 18, 2020 at 02:07:14PM -0800, Sami Tolvanen wrote: > > This patch series adds support for building the kernel with Clang's > > Link Time Optimization (LTO). In addition to performance, the primary >

Re: [PATCH 1/2] scs: switch to vmapped shadow stacks

2020-11-20 Thread Sami Tolvanen
On Thu, Nov 19, 2020 at 5:00 AM Will Deacon wrote: > > Hi Sami, > > On Thu, Oct 22, 2020 at 01:23:54PM -0700, Sami Tolvanen wrote: > > The kernel currently uses kmem_cache to allocate shadow call stacks, > > which means an overflow may not be immediately detected and ca

Re: [PATCH v7 02/17] kbuild: add support for Clang LTO

2020-11-20 Thread Sami Tolvanen
On Wed, Nov 18, 2020 at 3:49 PM Nick Desaulniers wrote: > > On Wed, Nov 18, 2020 at 2:07 PM Sami Tolvanen wrote: > > > > This change adds build system support for Clang's Link Time > > Optimization (LTO). With -flto, instead of ELF object files, Clang > > produces L

[tip: perf/urgent] perf/x86: fix sysfs type mismatches

2020-11-19 Thread tip-bot2 for Sami Tolvanen
The following commit has been merged into the perf/urgent branch of tip: Commit-ID: ebd19fc372e3e78bf165f230e7c084e304441c08 Gitweb: https://git.kernel.org/tip/ebd19fc372e3e78bf165f230e7c084e304441c08 Author:Sami Tolvanen AuthorDate:Fri, 13 Nov 2020 10:31:26 -08:00

[PATCH v7 09/17] PCI: Fix PREL32 relocations for LTO

2020-11-18 Thread Sami Tolvanen
when PREL32 relocations are used. Signed-off-by: Sami Tolvanen Acked-by: Bjorn Helgaas Reviewed-by: Kees Cook --- include/linux/pci.h | 19 ++- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/include/linux/pci.h b/include/linux/pci.h index 22207a79762c

[PATCH v7 10/17] modpost: lto: strip .lto from module names

2020-11-18 Thread Sami Tolvanen
Wendling Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- scripts/mod/modpost.c| 16 +++- scripts/mod/modpost.h| 9 + scripts/mod/sumversion.c | 6 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod

[PATCH v7 16/17] arm64: disable recordmcount with DYNAMIC_FTRACE_WITH_REGS

2020-11-18 Thread Sami Tolvanen
work with LTO as we have LLVM bitcode instead of ELF objects. This change selects FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY, which disables recordmcount when patchable function entries are used instead. Signed-off-by: Sami Tolvanen --- arch/arm64/Kconfig | 2 ++ 1 file changed, 2 insertions

[PATCH v7 17/17] arm64: allow LTO_CLANG and THINLTO to be selected

2020-11-18 Thread Sami Tolvanen
Allow CONFIG_LTO_CLANG and CONFIG_THINLTO to be enabled. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- arch/arm64/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index c7f07978f5b6..56bd83a764f4 100644 --- a/arch/arm64/Kconfig

[PATCH v7 15/17] KVM: arm64: disable LTO for the nVHE directory

2020-11-18 Thread Sami Tolvanen
We use objcopy to manipulate ELF binaries for the nVHE code, which fails with LTO as the compiler produces LLVM bitcode instead. Disable LTO for this code to allow objcopy to be used. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- arch/arm64/kvm/hyp/nvhe/Makefile | 4 ++-- 1 file

[PATCH v7 12/17] efi/libstub: disable LTO

2020-11-18 Thread Sami Tolvanen
With CONFIG_LTO_CLANG, we produce LLVM bitcode instead of ELF object files. Since LTO is not really needed here and the Makefile assumes we produce an object file, disable LTO for libstub. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- drivers/firmware/efi/libstub/Makefile | 2 ++ 1

[PATCH v7 13/17] drivers/misc/lkdtm: disable LTO for rodata.o

2020-11-18 Thread Sami Tolvanen
Disable LTO for rodata.o to allow objcopy to be used to manipulate sections. Signed-off-by: Sami Tolvanen Acked-by: Kees Cook --- drivers/misc/lkdtm/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/misc/lkdtm/Makefile b/drivers/misc/lkdtm/Makefile index c70b3822013f

[PATCH v7 14/17] arm64: vdso: disable LTO

2020-11-18 Thread Sami Tolvanen
Disable LTO for the vDSO by filtering out CC_FLAGS_LTO, as there's no point in using link-time optimization for the small about of C code. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- arch/arm64/kernel/vdso/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git

[PATCH v7 08/17] init: lto: fix PREL32 relocations

2020-11-18 Thread Sami Tolvanen
are used. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- include/linux/init.h | 31 +++ 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/include/linux/init.h b/include/linux/init.h index d466bea7ecba..27b9478dcdef 100644 --- a/include/linux

[PATCH v7 11/17] scripts/mod: disable LTO for empty.c

2020-11-18 Thread Sami Tolvanen
With CONFIG_LTO_CLANG, clang generates LLVM IR instead of ELF object files. As empty.o is used for probing target properties, disable LTO for it to produce an object file instead. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- scripts/mod/Makefile | 1 + 1 file changed, 1 insertion

[PATCH v7 07/17] init: lto: ensure initcall ordering

2020-11-18 Thread Sami Tolvanen
script that specifies the same order for initcalls that we would have without LTO. With LTO enabled, the script is called in link-vmlinux.sh through jobserver-exec to limit the number of jobs spawned. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- include/linux/init.h | 52

[PATCH v7 05/17] kbuild: lto: merge module sections

2020-11-18 Thread Sami Tolvanen
LLD always splits sections with LTO, which increases module sizes. This change adds linker script rules to merge the split sections in the final module. Suggested-by: Nick Desaulniers Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- scripts/module.lds.S | 24 1

[PATCH v7 06/17] kbuild: lto: remove duplicate dependencies from .mod files

2020-11-18 Thread Sami Tolvanen
and split the dependency list to multiple lines, which results in used symbols getting trimmed. This change removes duplicate dependencies, which will reduce the probability of this happening and makes .mod files smaller and easier to read. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook

[PATCH v7 04/17] kbuild: lto: limit inlining

2020-11-18 Thread Sami Tolvanen
defconfig, we found that a limit of 5 is a reasonable compromise between performance and binary size, reducing the size of a stripped vmlinux by 11%. Suggested-by: George Burgess IV Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff

[PATCH v7 03/17] kbuild: lto: fix module versioning

2020-11-18 Thread Sami Tolvanen
they are all linked into vmlinux.o at the same time. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- .gitignore | 1 + Makefile | 3 ++- arch/Kconfig | 1 - scripts/Makefile.build | 33 +++-- scripts/Makefile.modpost

[PATCH v7 02/17] kbuild: add support for Clang LTO

2020-11-18 Thread Sami Tolvanen
LLVM tools must be used: CC=clang LD=ld.lld AR=llvm-ar NM=llvm-nm To prepare for LTO support with other compilers, common parts are gated behind the CONFIG_LTO option, and LTO can be disabled for specific files by filtering out CC_FLAGS_LTO. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook

[PATCH v7 01/17] tracing: move function tracer options to Kconfig

2020-11-18 Thread Sami Tolvanen
in a different environment. Signed-off-by: Sami Tolvanen --- Makefile | 20 kernel/trace/Kconfig | 16 scripts/Makefile.build | 6 ++ 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index e2c3f65c4721

[PATCH v7 00/17] Add support for Clang LTO

2020-11-18 Thread Sami Tolvanen
ies and replaced recordmcount with the objtool pass to avoid whitelisting relocations that are not calls. - Updated several commit messages with better explanations. Sami Tolvanen (17): tracing: move function tracer options to Kconfig kbuild: add support for Clang LTO kbuild: lto:

Re: [PATCH net] cfg80211: fix callback type mismatches in wext-compat

2020-11-17 Thread Sami Tolvanen
On Tue, Nov 17, 2020 at 1:45 PM Kees Cook wrote: > > On Tue, Nov 17, 2020 at 12:59:02PM -0800, Sami Tolvanen wrote: > > Instead of casting callback functions to type iw_handler, which trips > > indirect call checking with Clang's Control-Flow Integrity (CFI), add

[PATCH net] cfg80211: fix callback type mismatches in wext-compat

2020-11-17 Thread Sami Tolvanen
Instead of casting callback functions to type iw_handler, which trips indirect call checking with Clang's Control-Flow Integrity (CFI), add stub functions with the correct function type for the callbacks. Reported-by: Sedat Dilek Signed-off-by: Sami Tolvanen --- net/wireless/wext-compat.c

Re: [PATCH] samples/ftrace: mark my_tramp[12]? global

2020-11-16 Thread Sami Tolvanen
On Mon, Nov 16, 2020 at 1:18 PM Steven Rostedt wrote: > > On Mon, 16 Nov 2020 13:10:57 -0800 > Sami Tolvanen wrote: > > > Clang doesn't warn about this as we're building a module, it just > > generates a reference to a non-existing global "my_tramp" symbol, >

Re: [PATCH] samples/ftrace: mark my_tramp[12]? global

2020-11-16 Thread Sami Tolvanen
On Mon, Nov 16, 2020 at 12:38 PM Steven Rostedt wrote: > > On Mon, 16 Nov 2020 12:10:10 -0800 > Sami Tolvanen wrote: > > > On Mon, Nov 16, 2020 at 8:39 AM Steven Rostedt wrote: > > > > > > On Fri, 13 Nov 2020 10:34:14 -0800 > > > Sami Tolvanen wr

Re: [PATCH] samples/ftrace: mark my_tramp[12]? global

2020-11-16 Thread Sami Tolvanen
On Mon, Nov 16, 2020 at 8:39 AM Steven Rostedt wrote: > > On Fri, 13 Nov 2020 10:34:14 -0800 > Sami Tolvanen wrote: > > > my_tramp[12]? are declared as global functions in C, but they are not > > marked global in the inline assembly definition. This mismatch confuses

[PATCH v2 1/2] x86/pci: use unsigned int in check_reserved_t

2020-11-13 Thread Sami Tolvanen
Use unsigned int instead of raw unsigned in check_reserved_t to follow the kernel's style guidelines. Signed-off-by: Sami Tolvanen --- arch/x86/pci/mmconfig-shared.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig

[PATCH v2 2/2] x86/e820: fix the function type for e820__mapped_all

2020-11-13 Thread Sami Tolvanen
to unsigned to fix the type mismatch. Reported-by: Sedat Dilek Signed-off-by: Sami Tolvanen --- arch/x86/include/asm/e820/api.h | 2 +- arch/x86/kernel/e820.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/e820/api.h b/arch/x86/include/asm/e820

Re: [PATCH v6 22/25] x86/asm: annotate indirect jumps

2020-11-13 Thread Sami Tolvanen
On Fri, Nov 13, 2020 at 2:34 PM Josh Poimboeuf wrote: > > On Fri, Nov 13, 2020 at 12:24:32PM -0800, Sami Tolvanen wrote: > > > I still don't see this warning for some reason. > > > > Do you have CONFIG_XEN enabled? I can reproduce this on ToT master as > > foll

Re: [PATCH v6 22/25] x86/asm: annotate indirect jumps

2020-11-13 Thread Sami Tolvanen
On Fri, Nov 13, 2020 at 2:34 PM Josh Poimboeuf wrote: > > On Fri, Nov 13, 2020 at 12:24:32PM -0800, Sami Tolvanen wrote: > > > I still don't see this warning for some reason. > > > > Do you have CONFIG_XEN enabled? I can reproduce this on ToT master as > > foll

Re: [PATCH v6 22/25] x86/asm: annotate indirect jumps

2020-11-13 Thread Sami Tolvanen
On Fri, Nov 13, 2020 at 11:54 AM Josh Poimboeuf wrote: > > On Tue, Nov 10, 2020 at 10:59:55AM -0800, Sami Tolvanen wrote: > > On Tue, Nov 10, 2020 at 9:46 AM Josh Poimboeuf wrote: > > > > > > On Mon, Nov 09, 2020 at 08:29:24PM -0600, Josh Poimboeuf wrote: > &g

Re: [PATCH] x86/e820: fix the function type for e820__mapped_all

2020-11-13 Thread Sami Tolvanen
On Fri, Nov 13, 2020 at 10:35 AM Randy Dunlap wrote: > > On 11/13/20 10:26 AM, Sami Tolvanen wrote: > > e820__mapped_all is passed as a callback to is_mmconf_reserved, which > > expects a function of type: > > > > typedef bool (*check_reserved_t)(u64

[PATCH] samples/ftrace: mark my_tramp[12]? global

2020-11-13 Thread Sami Tolvanen
my_tramp[12]? are declared as global functions in C, but they are not marked global in the inline assembly definition. This mismatch confuses Clang's Control-Flow Integrity checking. Fix the definitions by adding .globl. Signed-off-by: Sami Tolvanen --- samples/ftrace/ftrace-direct-modify.c | 2

[PATCH] perf/x86: fix sysfs type mismatches

2020-11-13 Thread Sami Tolvanen
This change switches rapl to use PMU_FORMAT_ATTR, and fixes two other macros to use device_attribute instead of kobj_attribute to avoid callback type mismatches that trip indirect call checking with Clang's Control-Flow Integrity (CFI). Reported-by: Sedat Dilek Signed-off-by: Sami Tolvanen

[PATCH] x86/e820: fix the function type for e820__mapped_all

2020-11-13 Thread Sami Tolvanen
to unsigned to fix the type mismatch. Reported-by: Sedat Dilek Signed-off-by: Sami Tolvanen --- arch/x86/include/asm/e820/api.h | 2 +- arch/x86/kernel/e820.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/e820/api.h b/arch/x86/include/asm/e820

Re: [PATCH v6 22/25] x86/asm: annotate indirect jumps

2020-11-10 Thread Sami Tolvanen
On Tue, Nov 10, 2020 at 9:46 AM Josh Poimboeuf wrote: > > On Mon, Nov 09, 2020 at 08:29:24PM -0600, Josh Poimboeuf wrote: > > On Mon, Nov 09, 2020 at 03:11:41PM -0800, Sami Tolvanen wrote: > > > CONFIG_XEN > > > > > > __swi

Re: [PATCH v6 22/25] x86/asm: annotate indirect jumps

2020-11-09 Thread Sami Tolvanen
On Mon, Nov 9, 2020 at 6:29 PM Josh Poimboeuf wrote: > How would I recreate all these warnings? You can reproduce all of these using a normal gcc build without any of the LTO patches by running objtool check -arfld vmlinux.o. However, with gcc you'll see even more warnings due to duplicate

Re: [PATCH v6 22/25] x86/asm: annotate indirect jumps

2020-11-09 Thread Sami Tolvanen
On Fri, Oct 23, 2020 at 10:36 AM Sami Tolvanen wrote: > > On Wed, Oct 21, 2020 at 05:22:59PM -0700, Sami Tolvanen wrote: > > There are a couple of differences, like the first "undefined stack > > state" warning pointing to set_bringup_idt_handler.constprop.0() > &g

Re: [PATCH v6 22/25] x86/asm: annotate indirect jumps

2020-10-23 Thread Sami Tolvanen
On Thu, Oct 22, 2020 at 09:25:53AM +0200, Peter Zijlstra wrote: > On Wed, Oct 21, 2020 at 04:27:47PM -0500, Josh Poimboeuf wrote: > > On Wed, Oct 21, 2020 at 11:32:13AM +0200, Peter Zijlstra wrote: > > > On Wed, Oct 21, 2020 at 10:56:06AM +0200, Peter Zijlstra wrote: > > > > > > > I do not see

Re: [PATCH v6 22/25] x86/asm: annotate indirect jumps

2020-10-23 Thread Sami Tolvanen
On Wed, Oct 21, 2020 at 05:22:59PM -0700, Sami Tolvanen wrote: > There are a couple of differences, like the first "undefined stack > state" warning pointing to set_bringup_idt_handler.constprop.0() > instead of __switch_to_asm(). I tried running this with --backtrace, >

[PATCH 2/2] arm64: scs: use vmapped IRQ and SDEI shadow stacks

2020-10-22 Thread Sami Tolvanen
Use scs_alloc() to allocate also IRQ and SDEI shadow stacks instead of using statically allocated stacks. Signed-off-by: Sami Tolvanen --- arch/arm64/include/asm/scs.h | 21 ++- arch/arm64/kernel/entry.S| 6 ++-- arch/arm64/kernel/irq.c | 2 ++ arch/arm64/kernel/scs.c

[PATCH 0/2] scs: switch to vmapped shadow stacks

2020-10-22 Thread Sami Tolvanen
://lore.kernel.org/lkml/20200515172355.GD23334@willie-the-truck/ [2] https://lore.kernel.org/lkml/20200427220942.gb80...@google.com/ Sami Tolvanen (2): scs: switch to vmapped shadow stacks arm64: scs: use vmapped IRQ and SDEI shadow stacks arch/arm64/include/asm/scs.h | 21 ++- arch

[PATCH 1/2] scs: switch to vmapped shadow stacks

2020-10-22 Thread Sami Tolvanen
size to a full page and provides more robust overflow detection similarly to VMAP_STACK. Signed-off-by: Sami Tolvanen --- include/linux/scs.h | 7 + kernel/scs.c| 63 ++--- 2 files changed, 55 insertions(+), 15 deletions(-) diff --git a/include

Re: [PATCH v6 22/25] x86/asm: annotate indirect jumps

2020-10-21 Thread Sami Tolvanen
On Wed, Oct 21, 2020 at 1:56 AM Peter Zijlstra wrote: > > On Tue, Oct 20, 2020 at 12:24:37PM -0700, Sami Tolvanen wrote: > > > > Building allyesconfig with this series and LTO enabled, I still see > > > > the following objtool warnings for vmlinux.o, grouped by sou

Re: [PATCH v6 22/25] x86/asm: annotate indirect jumps

2020-10-21 Thread Sami Tolvanen
On Wed, Oct 21, 2020 at 1:56 AM Peter Zijlstra wrote: > > On Tue, Oct 20, 2020 at 12:24:37PM -0700, Sami Tolvanen wrote: > > > > Building allyesconfig with this series and LTO enabled, I still see > > > > the following objtool warnings for vmlinux.o, grouped by sou

<    1   2   3   4   5   6   7   8   9   10   >