Thread (29 messages) 29 messages, 5 authors, 2019-11-28

Re: [PATCH v3 3/3] powerpc/prom_init: Use -ffreestanding to avoid a reference to bcmp

From: Nick Desaulniers <hidden>
Date: 2019-09-12 17:31:11
Also in: lkml

On Wed, Sep 11, 2019 at 10:43 PM Nathan Chancellor
[off-list ref] wrote:
On Wed, Sep 11, 2019 at 02:01:59PM -0700, Nick Desaulniers wrote:
quoted
On Wed, Sep 11, 2019 at 11:21 AM Nathan Chancellor
[off-list ref] wrote:
quoted
r370454 gives LLVM the ability to convert certain loops into a reference
to bcmp as an optimization; this breaks prom_init_check.sh:

  CALL    arch/powerpc/kernel/prom_init_check.sh
Error: External symbol 'bcmp' referenced from prom_init.c
make[2]: *** [arch/powerpc/kernel/Makefile:196: prom_init_check] Error 1

bcmp is defined in lib/string.c as a wrapper for memcmp so this could be
added to the whitelist. However, commit 450e7dd4001f ("powerpc/prom_init:
don't use string functions from lib/") copied memcmp as prom_memcmp to
avoid KASAN instrumentation so having bcmp be resolved to regular memcmp
would break that assumption. Furthermore, because the compiler is the
one that inserted bcmp, we cannot provide something like prom_bcmp.

To prevent LLVM from being clever with optimizations like this, use
-ffreestanding to tell LLVM we are not hosted so it is not free to make
transformations like this.

Link: https://github.com/ClangBuiltLinux/linux/issues/647
Link: https://github.com/llvm/llvm-project/commit/5c9f3cfec78f9e9ae013de9a0d092a68e3e79e002
The above link doesn't work for me (HTTP 404).  PEBKAC?
https://github.com/llvm/llvm-project/commit/5c9f3cfec78f9e9ae013de9a0d092a68e3e79e002
Not really sure how an extra 2 got added on the end of that... Must have
screwed up in vim somehow.

Link: https://github.com/llvm/llvm-project/commit/5c9f3cfec78f9e9ae013de9a0d092a68e3e79e00
That looks better.  Assuming Michael doesn't mind amending the link
when applying:
Reviewed-by: Nick Desaulneris <redacted>
I can resend unless the maintainer is able to fix that up when it gets
applied.

Cheers,
Nathan


-- 
Thanks,
~Nick Desaulniers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help