[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87k08bdqm1.fsf@mpe.ellerman.id.au>
Date: Mon, 18 Jul 2022 13:52:38 +1000
From: Michael Ellerman <mpe@...erman.id.au>
To: Segher Boessenkool <segher@...nel.crashing.org>,
Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Sudip Mukherjee <sudipm.mukherjee@...il.com>,
Kees Cook <keescook@...omium.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
Paul Mackerras <paulus@...ba.org>,
linux-hardening@...r.kernel.org,
linuxppc-dev <linuxppc-dev@...ts.ozlabs.org>
Subject: Re: mainline build failure of powerpc allmodconfig for prom_init_check
Segher Boessenkool <segher@...nel.crashing.org> writes:
> On Sun, Jul 17, 2022 at 07:44:22AM -0700, Linus Torvalds wrote:
>> On Sun, Jul 17, 2022 at 2:13 AM Sudip Mukherjee
>> <sudipm.mukherjee@...il.com> wrote:
>> > I was trying to check it. With gcc-11 the assembly code generated is
>> > not using memset, but using __memset.
>> > But with gcc-12, I can see the assembly code is using memset. One
>> > example from the assembly:
>>
>> You could try making the 'args' array in 'struct prom_args' be marked
>> 'volatile'.
>>
>> Ie something like this:
>>
>> --- a/arch/powerpc/kernel/prom_init.c
>> +++ b/arch/powerpc/kernel/prom_init.c
>> @@ -115,6 +115,6 @@ struct prom_args {
>> __be32 service;
>> __be32 nargs;
>> __be32 nret;
>> - __be32 args[10];
>> + volatile __be32 args[10];
>> };
>>
>> because I think it's just the compilers turning the small loop over
>> those fields into a "memset()".
>
> Yes. See <https://gcc.gnu.org/onlinedocs/gcc/Standards.html#C-Language>
> near the end:
> Most of the compiler support routines used by GCC are present in
> libgcc, but there are a few exceptions. GCC requires the freestanding
> environment provide memcpy, memmove, memset and memcmp. Finally, if
> __builtin_trap is used, and the target does not implement the trap
> pattern, then GCC emits a call to abort.
>
> Can't we simply have a small simple implementation of these functions in
> arch/powerpc/boot/? This stuff is not performance-critical, and this is
> not the first time we hit these problems.
prom_init.c isn't in arch/powerpc/boot :)
It's linked into the kernel proper, but we want it to behave like a
pre-boot environment (because not all boot paths run it) which is why we
restrict what symbols it can call.
We could have a prom_memset() etc. but we'd need to do some tricks to
rewrite references to memset() to prom_memset() before linking.
cheers
Powered by blists - more mailing lists