Re: [PATCH 0/4] dm verity: add support for error correction

2015-11-09 Thread Sami Tolvanen
On Mon, Nov 09, 2015 at 11:37:35AM -0500, Mike Snitzer wrote: > I'm left wondering: can the new error correction code be made an > optional feature that is off by default? -- so as to preserve some > isolation of this new code from the old dm-verity behaviour. It's optional in the sense that you

[PATCH 3/4] dm verity: add support for forward error correction

2015-11-04 Thread Sami Tolvanen
blocks need to corrected. For a 2 GiB partition, RS(255, 253) (two parity bytes for each 253-byte block) can correct up to 16 MiB of consecutive corrupted blocks if erasures can be located, and 8 MiB if they cannot, with 16 MiB space overhead. Signed-off-by: Sami Tolvanen <samitolva...@google.

[PATCH 1/4] dm verity: clean up duplicate hashing code

2015-11-04 Thread Sami Tolvanen
Handle dm-verity salting in one place to simplify the code. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- drivers/md/dm-verity.c | 262 +++-- 1 file changed, 147 insertions(+), 115 deletions(-) diff --git a/drivers/md/dm-veri

[PATCH 4/4] dm verity: ignore zero blocks

2015-11-04 Thread Sami Tolvanen
Add ignore_zero_blocks option, which returns zeros for blocks matching a zero hash without validating the content. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- Documentation/device-mapper/verity.txt | 5 ++ drivers/md/dm-verity.c

[PATCH 0/4] dm verity: add support for error correction

2015-11-04 Thread Sami Tolvanen
. Sami Tolvanen (4): dm verity: clean up duplicate hashing code dm verity: separate function for parsing opt args dm verity: add support for forward error correction dm verity: ignore zero blocks Documentation/device-mapper/verity.txt | 34 ++ drivers/md/dm-verity.c

[PATCH 2/4] dm verity: separate function for parsing opt args

2015-11-04 Thread Sami Tolvanen
Move optional argument parsing into a separate function to make it easier to add more of them without making verity_ctr even longer. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- drivers/md/dm-verity.c | 31 ++- 1 file changed, 22 insertions

Re: [PATCH 0/4] dm verity: add support for error correction

2015-11-05 Thread Sami Tolvanen
On Thu, Nov 05, 2015 at 08:34:04AM +0100, Milan Broz wrote: > could you please elaborate why is all this needed? To extend support > of some faulty flash chips? This makes dm-verity more robust against corruption caused by either hardware or software bugs, both of which we have seen in the past

Re: [PATCH 0/4] dm verity: add support for error correction

2015-11-06 Thread Sami Tolvanen
On Fri, Nov 06, 2015 at 12:23:29PM -0500, Mikulas Patocka wrote: > I'm also wondering what is this patch useful for. Disks and flash > controllers have their own error detection and correction I think I addressed this earlier. Some storage devices are able to correct bit flips, but don't have

Re: [dm-devel] [PATCH 0/4] dm verity: add support for error correction

2015-11-06 Thread Sami Tolvanen
On Fri, Nov 06, 2015 at 08:20:15PM +0100, Zdenek Kabelac wrote: > i.e. you have 1G of space - you want to give 250MB as 'redundancy' - > so create 4 partition We cannot afford to set aside 25% of read-only partition space for redundancy on mobile devices, and would rather not impact

Re: [dm-devel] [PATCH 0/4] dm verity: add support for error correction

2015-11-06 Thread Sami Tolvanen
On Fri, Nov 06, 2015 at 10:05:24PM +0100, Zdenek Kabelac wrote: > So how do you want to correctly 'restore' missing full sectors > with just 0.8% data overhead ?? We use interleaving. Each byte in a 4k block is part of a different Reed-Solomon block, which means an entire lost 4k data block

Re: [PATCH v2 0/2] dm verity: add support for error correction

2015-12-07 Thread Sami Tolvanen
On Fri, Dec 04, 2015 at 04:09:35PM -0500, Mike Snitzer wrote: > I'd really appreciate it if you could do some regression testing, > etc on your end to verify I didn't break anything while tweaking > things. Sure. The changes look fine. I applied them to my tree and everything still works as

Re: [PATCH v2 0/2] dm verity: add support for error correction

2015-12-08 Thread Sami Tolvanen
On Mon, Dec 07, 2015 at 02:07:43PM -0500, Mike Snitzer wrote: > I'm not seeing any verification of the metadata in fec_read_parity() -- > so it would seem that corrupt RS blocks would result in -EBADMSG being > returned from decode_rs8() (by virtue of incorrect parity being passed > to

Re: [PATCH v2 0/2] dm verity: add support for error correction

2015-12-07 Thread Sami Tolvanen
On Mon, Dec 07, 2015 at 09:58:14AM -0500, Mike Snitzer wrote: > Great. Moving forward it'd be awesome if you could work to get your > verity FEC support regression tests into cryptsetup's tests. Sure. These tests would basically involve generating a valid disk image, corrupting it up to the

Re: [PATCH 0/4] dm verity: add support for error correction

2015-12-03 Thread Sami Tolvanen
On Wed, Dec 02, 2015 at 03:22:03PM -0500, Mike Snitzer wrote: > Any progress on v2 that takes into account previous review feedback? Yes. Sorry for the delay, the changes have gone through a couple of rounds of internal reviews and testing first. > Note I've staged the first 2 patches in this

Re: [PATCH 0/4] dm verity: add support for error correction

2015-12-03 Thread Sami Tolvanen
On Thu, Nov 12, 2015 at 11:30:00AM +0100, Milan Broz wrote: > Yes, please, patches do not to be production ready (I can integrate > it to veritysetup upstream myself) I'm working on this and should have a patch for veritysetup for you next week. Sami -- To unsubscribe from this list: send the

Re: [PATCH 0/4] dm verity: add support for error correction

2015-12-03 Thread Sami Tolvanen
On Thu, Nov 12, 2015 at 01:50:04PM -0500, Mikulas Patocka wrote: > What flash controller and chips do you use? Considering the number of different devices running Android, I don't have a good answer for this. I'm guessing most of them. > Is the silent data corruption permanent or transient?

Re: [PATCH v2 0/2] dm verity: add support for error correction

2015-12-04 Thread Sami Tolvanen
On Thu, Dec 03, 2015 at 06:05:38PM -0500, Mike Snitzer wrote: > If you're OK with those changes I'll fold that commit into your main FEC > commit. Yes, these changes look fine. Thanks! Sami -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to

[PATCH v2 0/2] dm verity: add support for error correction

2015-12-03 Thread Sami Tolvanen
GFP_NOIO) and uses them if available. - Added graceful handling of IO errors, which are now treated as any other corruption. - Rebased against linux-dm/for-next. Sami Tolvanen (2): dm verity: add support for forward error correction dm verity: ignore zero blocks Documentation/device

[PATCH v2 1/2] dm verity: add support for forward error correction

2015-12-03 Thread Sami Tolvanen
blocks need to corrected. For a 2 GiB partition, RS(255, 253) (two parity bytes for each 253-byte block) can correct up to 16 MiB of consecutive corrupted blocks if erasures can be located, and 8 MiB if they cannot, with 16 MiB space overhead. Signed-off-by: Sami Tolvanen <samitolva...@google.

[PATCH v2 2/2] dm verity: ignore zero blocks

2015-12-03 Thread Sami Tolvanen
Add ignore_zero_blocks option, which returns zeros for blocks matching a zero hash without validating the content. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- Documentation/device-mapper/verity.txt | 5 ++ drivers/md/dm-verity-fec.c | 8 +++- drivers/md/dm-

Re: [PATCH] dm verity: deferred hash checking for restart/logging mode

2017-04-24 Thread Sami Tolvanen
On Mon, Apr 24, 2017 at 10:05:03AM +0200, Milan Broz wrote: > Isn't one of the goal of integrity checking to PREVENT that userspace > accesses tampered data? Absolutely. It's not acceptable for dm-verity to return unverified data to userspace in restart mode. Sami

[PATCH v2 03/18] kbuild: move gcc-version.sh to cc-version.sh and add clang support

2017-11-15 Thread Sami Tolvanen
Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- scripts/Kbuild.include | 4 ++-- scripts/cc-version.sh | 45 + scripts/gcc-version.sh | 33 - 3 files changed, 47 insertions(+), 35 deletions(-) creat

[PATCH v2 05/18] arm64: fix -m for GNU gold

2017-11-15 Thread Sami Tolvanen
GNU gold supports different emulations than bfd. Use aarch64_elf64_*_vec instead of aarch64linux. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/Makefile | 8 1 file changed, 8 insertions(+) diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile

[PATCH v2 04/18] arm64: use -mno-implicit-float instead of -mgeneral-regs-only

2017-11-15 Thread Sami Tolvanen
Cc: Matthias Kaehlcke <m...@chromium.org> [added cc-ifversion to enable the workaround only for clang <6.0] Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/Makefile | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Makefile

[PATCH v2 07/18] arm64: keep .altinstructions and .altinstr_replacement

2017-11-15 Thread Sami Tolvanen
Make sure the linker doesn't remove .altinstructions or .altinstr_replacement when CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is enabled. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/kernel/vmlinux.lds.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff

[PATCH v2 11/18] arm64: make mrs_s and msr_s macros work with LTO

2017-11-15 Thread Sami Tolvanen
y Norov <yno...@caviumnetworks.com> Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/include/asm/kvm_hyp.h | 8 -- arch/arm64/include/asm/sysreg.h | 55 +++- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git

[PATCH v2 17/18] arm64: disable RANDOMIZE_MODULE_REGION_FULL with LTO_CLANG

2017-11-15 Thread Sami Tolvanen
RANDOMIZE_MODULE_REGION_FULL results in "overflow in relocation type 275" when loading a module linked with GNU gold. As a workaround, disable when LTO_CLANG is selected. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/Kconfig | 2 +- 1 file changed, 1

[PATCH v2 09/18] arm64: explicitly pass --no-fix-cortex-a53-843419 to GNU gold

2017-11-15 Thread Sami Tolvanen
the erratum fix is not used even if the linker is configured to enable it by default. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/Makefile | 5 + 1 file changed, 5 insertions(+) diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 6059c8169513..ca700b201736

[PATCH v2 08/18] arm64: don't disable ADR_PREL_PG_HI21* with ARM64_ERRATUM_843419

2017-11-15 Thread Sami Tolvanen
CONFIG_LTO_CLANG depends on GNU gold, which can generate ADR_PREL_PG_HI21* relocations even with --fix-cortex-a53-843419. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/kernel/module.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/arm64/kernel/module.c

[PATCH v2 12/18] kbuild: add support for clang LTO

2017-11-15 Thread Sami Tolvanen
is in LD_LIBRARY_PATH and CONFIG_LTO_CLANG has been selected, an LTO kernel can be built simply by running make CC=clang. Recommended versions are >= 5.0 for clang, and >= 2.27 for binutils. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- .gitignore | 2

[PATCH v2 18/18] arm64: select ARCH_SUPPORTS_LTO_CLANG

2017-11-15 Thread Sami Tolvanen
Allow CONFIG_LTO_CLANG to be enabled for the architecture. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 3a70f763e18a..58504327b9f6 100644 --- a/arch/arm64/K

[PATCH v2 10/18] arm64: add a workaround for GNU gold with ARM64_MODULE_PLTS

2017-11-15 Thread Sami Tolvanen
. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/kernel/module.lds | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/module.lds b/arch/arm64/kernel/module.lds index f7c9781a9d48..eacb5c67f61e 100644 --- a/arch/arm64/kernel/modu

Re: [PATCH v2 03/18] kbuild: move gcc-version.sh to cc-version.sh and add clang support

2017-11-15 Thread Sami Tolvanen
On Wed, Nov 15, 2017 at 01:48:52PM -0800, Kees Cook wrote: > It might make sense to split this patch: do the move and refactoring, > then add clang support. Sure. > Though, won't this confuse some tests? A lot of cc-version tests are > expecting only gcc, yes? There's already a chance of this

[PATCH v2 13/18] kbuild: fix dynamic ftrace with clang LTO

2017-11-15 Thread Sami Tolvanen
, and a __norecordmcount attribute for moving functions to this section. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/Kconfig | 2 +- include/asm-generic/vmlinux.lds.h | 1 + include/linux/compiler-clang.h| 7 +++ include/linux/compiler_t

[PATCH v2 14/18] scripts/mod: disable LTO for empty.c

2017-11-15 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 <samitolva...@google.com> --- scripts/mod/Makefile | 1 + 1 file changed, 1 ins

[PATCH v2 01/18] kbuild: add ld-name macro and support for GNU gold

2017-11-15 Thread Sami Tolvanen
GNU gold may require different flags than GNU ld. Add a macro for detecting the linker and conditionally add gold specific flags from LDFLAGS_GOLD. Reviewed-by: Nick Desaulniers <ndesaulni...@google.com> Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- Makefile

[PATCH v2 00/18] Add support for clang LTO

2017-11-15 Thread Sami Tolvanen
lex Matveev (1): arm64: make mrs_s and msr_s macros work with LTO Greg Hackmann (1): arm64: use -mno-implicit-float instead of -mgeneral-regs-only Sami Tolvanen (16): kbuild: add ld-name macro and support for GNU gold kbuild: fix LD_DEAD_CODE_DATA_ELIMINATION with GNU gold kbuild: move

[PATCH v2 02/18] kbuild: fix LD_DEAD_CODE_DATA_ELIMINATION with GNU gold

2017-11-15 Thread Sami Tolvanen
Don't remove .head.text or .exitcall.exit when linking with --gc-sections, and include .init.text.* in .init.text and .init.rodata.* in .init.rodata. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- include/asm-generic/vmlinux.lds.h | 8 1 file changed, 4 insertions

[PATCH v2 15/18] efi/libstub: disable LTO

2017-11-15 Thread Sami Tolvanen
With CONFIG_LTO_CLANG, we produce LLVM IR instead of object files. Since LTO is not really needed here and the Makefile assumes we produce an object file, disable LTO for libstub. Acked-by: Ard Biesheuvel <ard.biesheu...@linaro.org> Signed-off-by: Sami Tolvanen <samitolva...@g

[PATCH v2 06/18] arm64: kvm: use -fno-jump-tables with clang

2017-11-15 Thread Sami Tolvanen
Use -fno-jump-tables to make sure clang doesn't generate branches to EL1 virtual addresses. Suggested-by: AKASHI Takahiro <takahiro.aka...@linaro.org> Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/kvm/hyp/Makefile | 4 1 file changed, 4 insertions(+)

[PATCH v2 16/18] arm64: crypto: disable LTO for aes-ce-cipher.c

2017-11-15 Thread Sami Tolvanen
CONFIG_LTO_CLANG requires the use of clang's integrated assembler, which doesn't understand the inline assembly in aes-ce-cipher.c. Disable LTO for the file to work around the issue. Acked-by: Ard Biesheuvel <ard.biesheu...@linaro.org> Signed-off-by: Sami Tolvanen <samitolva...@g

Re: [PATCH 3/3] arm64: use -mno-implicit-float instead of -mgeneral-regs-only

2017-11-29 Thread Sami Tolvanen
On Wed, Nov 29, 2017 at 12:15:14PM +, Ard Biesheuvel wrote: > Do we still need these patches now that the AES code has been fixed? With your AES patch that Herbert just applied, this patch is no longer needed. Version macros in the first two patches will still be useful in future though.

Re: [PATCH 2/3] kbuild: add cc-if-name-version and compiler-specific variants

2017-11-30 Thread Sami Tolvanen
On Thu, Nov 30, 2017 at 09:21:49PM +0900, Masahiro Yamada wrote: > BTW, did this patch work in your test? Yes, but it looks like /bin/sh is symlinked to bash on my system. I can reproduce the issue with dash. > As for the macro names, maybe > > __cc-ifversion, __cc-if-fullversion for

Re: [PATCH 1/7] kbuild: add ld-name macro and support for GNU gold

2017-11-30 Thread Sami Tolvanen
On Wed, Nov 29, 2017 at 04:32:52PM -0800, Nick Desaulniers wrote: > Right, but you're still only ever using one linker per build, correct? Correct. LDFLAGS_GOLD makes it move convenient to add gold specific flags without explicit $(ld-name) checks everywhere, but I'm fine with removing it in v2.

Re: [PATCH 6/7] arm64: explicitly pass --no-fix-cortex-a53-843419 to GNU gold

2017-11-30 Thread Sami Tolvanen
On Wed, Nov 29, 2017 at 04:30:33PM -0800, Nick Desaulniers wrote: > Rather than: > > if CONFIG_ARM64_ERRATUM_843419 == y: > ... > if CONFIG_ARM64_ERRATUM_843419 == '': > ... > > could this be: > > if CONFIG_ARM64_ERRATUM_843419 == y: > ... > else > ... > > ? Sure. I'll clean this up

Re: [PATCH 5/7] arm64: keep .altinstructions and .altinstr_replacement

2017-11-30 Thread Sami Tolvanen
On Thu, Nov 30, 2017 at 11:58:27AM +1000, Nicholas Piggin wrote: > So yes please if it's not too much trouble, could you remove > the "gold" name from the generic patch and put it at the front > of the series with this arm64 patch. Sure, I'll do this in v2. > Possibly then you could also do a

[PATCH 4/7] arm64: fix -m for GNU gold

2017-11-29 Thread Sami Tolvanen
GNU gold supports different emulations than bfd. Use aarch64_elf64_*_vec instead of aarch64linux. Signed-off-by: Sami Tolvanen <samitolva...@google.com> Acked-by: Yury Norov <yno...@caviumnetworks.com> --- arch/arm64/Makefile | 8 1 file changed, 8 insertions(+) diff --git

[PATCH 1/7] kbuild: add ld-name macro and support for GNU gold

2017-11-29 Thread Sami Tolvanen
GNU gold may require different flags than GNU ld. Add a macro for detecting the linker and conditionally add gold specific flags from LDFLAGS_GOLD. Signed-off-by: Sami Tolvanen <samitolva...@google.com> Reviewed-by: Nick Desaulniers <ndesaulni...@google.com> --- Makefile

[PATCH 5/7] arm64: keep .altinstructions and .altinstr_replacement

2017-11-29 Thread Sami Tolvanen
Make sure the linker doesn't remove .altinstructions or .altinstr_replacement when CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is enabled. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/kernel/vmlinux.lds.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff

[PATCH 3/7] kbuild: fix LD_DEAD_CODE_DATA_ELIMINATION with GNU gold

2017-11-29 Thread Sami Tolvanen
Don't remove .head.text or .exitcall.exit when linking with --gc-sections, and include .init.text.* in .init.text and .init.rodata.* in .init.rodata. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- include/asm-generic/vmlinux.lds.h | 8 1 file changed, 4 insertions

[PATCH v2 7/7] arm64: add a workaround for GNU gold with ARM64_MODULE_PLTS

2017-11-30 Thread Sami Tolvanen
All current versions of GNU gold crash when linking kernel modules with ARM64_MODULE_PLTS due to a known bug: https://sourceware.org/bugzilla/show_bug.cgi?id=14592 To work around the problem, this change removes NOLOAD from .plt and .init.plt. Signed-off-by: Sami Tolvanen <samito

[PATCH v2 0/7] Add support for GNU gold

2017-11-30 Thread Sami Tolvanen
-if-name-version to __ld-ifversion for consistency - cleaned up the erratum changes in arch/arm64/Makefile Sami Tolvanen (7): kbuild: fix LD_DEAD_CODE_DATA_ELIMINATION arm64: keep .altinstructions and .altinstr_replacement kbuild: add ld-name macro kbuild: add __ld-ifversion and linker

[PATCH v2 5/7] arm64: fix -m for GNU gold

2017-11-30 Thread Sami Tolvanen
GNU gold supports different emulations than bfd. Use aarch64_elf64_*_vec instead of aarch64linux. Signed-off-by: Sami Tolvanen <samitolva...@google.com> Acked-by: Yury Norov <yno...@caviumnetworks.com> --- arch/arm64/Makefile | 8 1 file changed, 8 insertions(+) diff --git

[PATCH v2 2/7] arm64: keep .altinstructions and .altinstr_replacement

2017-11-30 Thread Sami Tolvanen
Make sure the linker doesn't remove .altinstructions or .altinstr_replacement when CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is enabled. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/kernel/vmlinux.lds.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff

[PATCH v2 6/7] arm64: explicitly pass --no-fix-cortex-a53-843419 to GNU gold

2017-11-30 Thread Sami Tolvanen
the erratum fix is not used even if the linker is configured to enable it by default. This change also adds a warning if the erratum fix is enabled and gold version <1.14 is used. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/Makefile | 9 + 1 file changed, 9 i

[PATCH v2 1/2] kbuild: add clang-version.sh

2017-11-30 Thread Sami Tolvanen
Based on gcc-version.sh, clang-version.sh prints out the correct version of clang. Signed-off-by: Sami Tolvanen <samitolva...@google.com> Tested-by: Nick Desaulniers <ndesaulni...@google.com> --- scripts/clang-version.sh | 33 + 1 file changed, 3

[PATCH v2 3/7] kbuild: add ld-name macro

2017-11-30 Thread Sami Tolvanen
GNU gold may require different flags than GNU ld. Add a macro for detecting the linker. Signed-off-by: Sami Tolvanen <samitolva...@google.com> Reviewed-by: Nick Desaulniers <ndesaulni...@google.com> --- scripts/Kbuild.include | 4 1 file changed, 4 insertions(+) diff --g

[PATCH v2 1/7] kbuild: fix LD_DEAD_CODE_DATA_ELIMINATION

2017-11-30 Thread Sami Tolvanen
Don't remove .head.text or .exitcall.exit when linking with --gc-sections, and include .init.text.* in .init.text and .init.rodata.* in .init.rodata. Signed-off-by: Sami Tolvanen <samitolva...@google.com> Reviewed-by: Nicholas Piggin <npig...@gmail.com> --- include/asm-generic/vmlin

[PATCH v2 0/2] Add version macros for clang

2017-11-30 Thread Sami Tolvanen
This patch set adds macros for checking clang version. Changes from v1: - fixed a comment in clang-version.sh - renamed macros to __cc-ifversion and __cc-if-fullversion - fixed a bug with non-bash shells - dropped the arm64 patch as unnecessary Sami Tolvanen (2): kbuild: add clang

[PATCH v2 4/7] kbuild: add __ld-ifversion and linker-specific macros

2017-11-30 Thread Sami Tolvanen
Add macros for testing both linker name and version. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- scripts/Kbuild.include | 12 1 file changed, 12 insertions(+) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 899863e4cd05..2991b463b4ce

[PATCH v2 2/2] kbuild: add __cc-ifversion and compiler-specific variants

2017-11-30 Thread Sami Tolvanen
This change adds macros for testing both compiler name and version. Current cc-version, cc-ifversion etc. macros that test gcc version are left unchanged to prevent compatibility issues with existing tests. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- scripts/Kbuild.includ

Re: Link time optimization for LTO/x86

2017-11-29 Thread Sami Tolvanen
Hi Andi, On Mon, Nov 27, 2017 at 01:34:02PM -0800, Andi Kleen wrote: > This is an updated version of my older LTO patchkit for gcc/x86 > This version doesn't need special binutils, but requires gcc 5+. > It also is compatible with near all options (except MODVERSIONS) Would you mind changing the

Re: [v2,12/18] kbuild: add support for clang LTO

2017-11-29 Thread Sami Tolvanen
On Tue, Nov 21, 2017 at 11:01:52AM +1000, Nicholas Piggin wrote: > I just wonder are you doing this because there is some worthwhile > performance gain? Or to enable more testing and development of LTO? > Any clues for why a user would want to enable it. I'm primarily interested in CFI, which

[PATCH 2/7] kbuild: add ld-if-name-version and linker-specific macros

2017-11-29 Thread Sami Tolvanen
Add macros for testing both linker name and version. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- scripts/Kbuild.include | 12 1 file changed, 12 insertions(+) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index a7c7843c2cf1..5d286d69e8dc

[PATCH 7/7] arm64: add a workaround for GNU gold with ARM64_MODULE_PLTS

2017-11-29 Thread Sami Tolvanen
All current versions of GNU gold crash when linking kernel modules with ARM64_MODULE_PLTS due to a known bug: https://sourceware.org/bugzilla/show_bug.cgi?id=14592 To work around the problem, this change removes NOLOAD from .plt and .init.plt. Signed-off-by: Sami Tolvanen <samito

[PATCH 0/7] Add support for GNU gold

2017-11-29 Thread Sami Tolvanen
These patches add macros for detecting the linker name and version, and apply fixes and workarounds needed to link the arm64 kernel with GNU gold. Sami Tolvanen (7): kbuild: add ld-name macro and support for GNU gold kbuild: add ld-if-name-version and linker-specific macros kbuild: fix

[PATCH 6/7] arm64: explicitly pass --no-fix-cortex-a53-843419 to GNU gold

2017-11-29 Thread Sami Tolvanen
the erratum fix is not used even if the linker is configured to enable it by default. This change also adds a warning if the erratum fix is enabled and gold version <1.14 is used. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/Makefile | 9 + 1 file changed, 9 i

[PATCH 1/3] kbuild: add clang-version.sh

2017-11-28 Thread Sami Tolvanen
Based on gcc-version.sh, clang-version.sh prints out the correct version of clang. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- scripts/clang-version.sh | 33 + 1 file changed, 33 insertions(+) create mode 100755 scripts/clang-version.sh diff

[PATCH 2/3] kbuild: add cc-if-name-version and compiler-specific variants

2017-11-28 Thread Sami Tolvanen
This change adds macros for testing both compiler name and version. Current cc-version, cc-ifversion etc. macros that test gcc version are left unchanged to prevent compatibility issues with existing tests. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- scripts/Kbuild.includ

[PATCH 0/3] Add version macros for clang and fix arm64 for clang <6.0

2017-11-28 Thread Sami Tolvanen
m64: use -mno-implicit-float instead of -mgeneral-regs-only Sami Tolvanen (2): kbuild: add clang-version.sh kbuild: add cc-if-name-version and compiler-specific variants arch/arm64/Makefile | 5 - scripts/Kbuild.include | 31 +++ scripts/clang-version

[PATCH 3/3] arm64: use -mno-implicit-float instead of -mgeneral-regs-only

2017-11-28 Thread Sami Tolvanen
Cc: Matthias Kaehlcke <m...@chromium.org> [added clang-ifversion to enable the workaround only for clang <6.0] Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/Makefile | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Makefile

Re: [PATCH v2 09/18] arm64: explicitly pass --no-fix-cortex-a53-843419 to GNU gold

2017-11-16 Thread Sami Tolvanen
On Thu, Nov 16, 2017 at 11:47:23AM +, Will Deacon wrote: > But if ARM64_ERRATUM_843419 is enabled, we'll go ahead and generate > broken code? This bug has been fixed in all current versions of GNU gold, but of course, if someone is using a broken linker, it will generate broken code. We can't

Re: [PATCH v2 18/18] arm64: select ARCH_SUPPORTS_LTO_CLANG

2017-11-16 Thread Sami Tolvanen
On Thu, Nov 16, 2017 at 11:58:11AM +, Will Deacon wrote: > I'll be honest with you: I'm absolutely terrified about enabling this. That's understandable, I wouldn't want to enable this by default quite yet either. This patch doesn't enable LTO for arm64, just makes it possible to enable the

Re: [PATCH v2 10/18] arm64: add a workaround for GNU gold with ARM64_MODULE_PLTS

2017-11-16 Thread Sami Tolvanen
On Thu, Nov 16, 2017 at 11:50:12AM +, Will Deacon wrote: > Why don't we just not do LTO if the toolchain is busted? Because LTO can not only potentially improve performance, especially when combined with PGO (Profile Guided Optimization), but it also makes it possible to enable features like

Re: [PATCH v2 06/18] arm64: kvm: use -fno-jump-tables with clang

2017-11-16 Thread Sami Tolvanen
On Thu, Nov 16, 2017 at 11:46:17AM +, Will Deacon wrote: > Can you elaborate a bit more on exactly what you saw failing here, > please? Mark noticed that clang built kernels fail to boot when the kernel starts at EL2: http://lkml.iu.edu/hypermail/linux/kernel/1711.0/02817.html Turns out

Re: [PATCH v2 11/18] arm64: make mrs_s and msr_s macros work with LTO

2017-11-16 Thread Sami Tolvanen
On Thu, Nov 16, 2017 at 11:54:33AM +, Will Deacon wrote: > What limitations? Can you elaborate please? Is this a fix? The commit message in v1 was more informative, I'll change this back for v3: -- Clang's integrated assembler does not allow assembly macros defined in one inline asm block

Re: [PATCH v2 11/18] arm64: make mrs_s and msr_s macros work with LTO

2017-11-16 Thread Sami Tolvanen
On Thu, Nov 16, 2017 at 11:01:44AM -0600, Segher Boessenkool wrote: > The thing with .purgem can work. Inelegant, sure, but it can work :-) It works, there are already functions in the kernel that use these macros more than once. I agree that this might not be the most elegant solution, but at

Re: [PATCH v2 08/18] arm64: don't disable ADR_PREL_PG_HI21* with ARM64_ERRATUM_843419

2017-11-16 Thread Sami Tolvanen
On Thu, Nov 16, 2017 at 11:44:06AM +, Will Deacon wrote: > Right, and this would also mean that we silently load vulnerable > modules that are linked with either LD that doesn't support > --fix-cortex-a53-843419 or simply wasn't passed. You'll see a warning at least if the linker doesn't

Re: [PATCH v2 11/18] arm64: make mrs_s and msr_s macros work with LTO

2017-11-16 Thread Sami Tolvanen
On Thu, Nov 16, 2017 at 07:56:50AM -0600, Segher Boessenkool wrote: > The compiler is fine, the assembler is fine (and the linker has > nothing to do with it). Your code is not fine. Would you care to elaborate? The current code assumes that macros are visible in other inline assembly blocks,

Re: [PATCH v2 08/18] arm64: don't disable ADR_PREL_PG_HI21* with ARM64_ERRATUM_843419

2017-11-17 Thread Sami Tolvanen
On Fri, Nov 17, 2017 at 09:54:48AM +, Ard Biesheuvel wrote: > OK, so all IR objects are converted into a single .o file > encapsulating the module image. Does this give the same benefits as > LTO linking IR objects to a fully linked executable? Yes, it does. > Even if it does, partial

Re: [PATCH v2 09/18] arm64: explicitly pass --no-fix-cortex-a53-843419 to GNU gold

2017-11-20 Thread Sami Tolvanen
On Mon, Nov 20, 2017 at 02:47:20PM +, Mark Rutland wrote: > However, we could instead check ld-version, produce a warning, and > abort the build in such cases. I believe the version number of gold didn't change in binutils 2.28.1, where this was fixed, but we could certainly warn about older

Re: [PATCH v2 16/18] arm64: crypto: disable LTO for aes-ce-cipher.c

2017-11-20 Thread Sami Tolvanen
On Mon, Nov 20, 2017 at 03:25:31PM +, Ard Biesheuvel wrote: > However, under LTO this all changes, and it is no longer guaranteed > that the NEON registers are only touched between the kernel mode > neon begin/end calls. LTO operates on LLVM IR, so disabling LTO for this file should make sure

Re: [v2,12/18] kbuild: add support for clang LTO

2017-11-20 Thread Sami Tolvanen
On Sat, Nov 18, 2017 at 01:21:39PM +1000, Nicholas Piggin wrote: > Do you have any kind of numbers for this, out of curiosity? Binary > size, performance, build time? I don't have performance numbers to share. Are there any specific benchmarks you'd be interested in seeing? Build time typically

Re: [PATCH v2 16/18] arm64: crypto: disable LTO for aes-ce-cipher.c

2017-11-20 Thread Sami Tolvanen
On Mon, Nov 20, 2017 at 03:20:14PM +, Mark Rutland wrote: > Could you elaborate on what the integrated asembler doesn't like? Here's the error, looks like in aes_sub: :1:69: error: invalid operand for instruction dup v1.4s, w12 ;movi v0.16b, #0 ;aese

Re: [PATCH v2 00/18] Add support for clang LTO

2017-11-20 Thread Sami Tolvanen
On Mon, Nov 20, 2017 at 03:21:40PM +, Mark Rutland wrote: > Would it be possible to split this into: > > (1) (basic) arm64 clang support > (2) gold support (no LTO) > (3) LTO support > > ... with any necessary workarounds added as-required to the relevant > series? Absolutely. I'll split

Re: [PATCH v2 18/18] arm64: select ARCH_SUPPORTS_LTO_CLANG

2017-11-16 Thread Sami Tolvanen
On Thu, Nov 16, 2017 at 11:13:07AM -0800, Paul E. McKenney wrote: > Ah, if "this patch set" meant "adding LTO", I stand corrected and I > apologize for my confusion. Again, I'm not proposing for LTO to be enabled by default. These patches just make it possible to enable it. Are you saying the

Re: [PATCH v2 08/18] arm64: don't disable ADR_PREL_PG_HI21* with ARM64_ERRATUM_843419

2017-11-16 Thread Sami Tolvanen
On Thu, Nov 16, 2017 at 10:14:17PM +, Ard Biesheuvel wrote: > OK, so my concern here is that this code probably only operates on > fully linked binaries, and not partially linked object files like > kernel modules. Right. That makes sense. > What is preventing us from using the large model

Re: [PATCH v2 08/18] arm64: don't disable ADR_PREL_PG_HI21* with ARM64_ERRATUM_843419

2017-11-16 Thread Sami Tolvanen
On Thu, Nov 16, 2017 at 04:34:03PM +, Ard Biesheuvel wrote: > You still have not explained to us how GOLD avoids the erratum. Sorry, I didn't realize you were asking that. If gold spots erratum sequences, looks like it creates stubs to break them up:

Re: [PATCH v2 00/18] Add support for clang LTO

2017-11-16 Thread Sami Tolvanen
On Thu, Nov 16, 2017 at 11:53:00PM +0300, Yury Norov wrote: > I would suggest you to add the patch that checks their versions and > disables LTO if needed. Sure, sounds reasonable. I'll add this in the next version. Sami

Re: [PATCH v2 08/18] arm64: don't disable ADR_PREL_PG_HI21* with ARM64_ERRATUM_843419

2017-11-16 Thread Sami Tolvanen
On Thu, Nov 16, 2017 at 11:20:40PM +, Ard Biesheuvel wrote: > So at which point is the IR in a partially linked object file > converted into executable code? At the final module link step (cmd_ld_ko_o) in scripts/Makefile.modpost, added in patch 12. Sami

[PATCH 01/15] kbuild: add ld-name macro and support for GNU gold

2017-11-03 Thread Sami Tolvanen
GNU gold may require different flags than GNU ld. Add a macro for detecting the linker and conditionally add gold specific flags from LDFLAGS_GOLD. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- Makefile | 5 + scripts/Kbuild.include | 4 2 files chan

[PATCH 05/15] scripts/mod: disable LTO for empty.c

2017-11-03 Thread Sami Tolvanen
With CONFIG_CLANG_LTO, 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 <samitolva...@google.com> --- scripts/mod/Makefile | 1 + 1 file changed, 1 ins

[PATCH 03/15] kbuild: add support for clang LTO

2017-11-03 Thread Sami Tolvanen
=ld.gold LD_FINAL_VMLINUX=ld Recommended versions are >= 5.0 for clang, and >= 2.27 for binutils. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- .gitignore | 2 ++ Makefile | 16 - arch/Kconfig | 32 + scripts/Ma

[PATCH 07/15] arm64: use -mno-implicit-float instead of -mgeneral-regs-only

2017-11-03 Thread Sami Tolvanen
Cc: Matthias Kaehlcke <m...@chromium.org> Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/Makefile | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 939b310913cf..eb6f3c9ec6cb 100644 --- a/arch/a

[PATCH 08/15] arm64: don't pass -maarch64linux to GNU gold

2017-11-03 Thread Sami Tolvanen
This change fixes the following error message when linking with GNU gold: ld.gold: error: unrecognized emulation aarch64linux Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/Makefile | 4 1 file changed, 4 insertions(+) diff --git a/arch/arm64/Makefile b/arch

[PATCH 09/15] arm64: keep .altinstructions and .altinstr_replacement

2017-11-03 Thread Sami Tolvanen
Make sure the linker doesn't remove .altinstructions or .altinstr_replacement when CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is enabled. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/kernel/vmlinux.lds.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff

[PATCH 12/15] arm64: add a workaround for GNU gold with ARM64_MODULE_PLTS

2017-11-03 Thread Sami Tolvanen
RANDOMIZE_MODULE_REGION_FULL is selected, 2) and disables RANDOMIZE_MODULE_REGION_FULL with clang LTO. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig

[PATCH 13/15] arm64: fix mrs_s/msr_s macros for clang LTO

2017-11-03 Thread Sami Tolvanen
m> Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/include/asm/kvm_hyp.h | 2 ++ arch/arm64/include/asm/sysreg.h | 71 ++-- 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/arch/arm64/include/asm/kvm_hyp.h b/arch

[PATCH 15/15] arm64: select ARCH_SUPPORTS_CLANG_LTO

2017-11-03 Thread Sami Tolvanen
Allow CONFIG_CLANG_LTO to be enabled for the architecture. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index a301fdc90319..6ae31f0c58ee 100644 --- a/arch/arm64/K

[PATCH 11/15] arm64: explicitly pass --no-fix-cortex-a53-843419 to GNU gold

2017-11-03 Thread Sami Tolvanen
the erratum fix is not used even if the linker is configured to enable it by default. Signed-off-by: Sami Tolvanen <samitolva...@google.com> --- arch/arm64/Makefile | 5 + 1 file changed, 5 insertions(+) diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index c16bd1ab37f8..0c1fb297c98e

  1   2   3   4   5   6   7   8   9   10   >