[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=whw31_Q_5-UR6AD4xpG5Q3LieMtr+99jP2oqwPhh-a_SA@mail.gmail.com>
Date: Sun, 17 Jul 2022 13:56:55 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Sudip Mukherjee <sudipm.mukherjee@...il.com>
Cc: Michael Ellerman <mpe@...erman.id.au>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Kees Cook <keescook@...omium.org>,
linuxppc-dev <linuxppc-dev@...ts.ozlabs.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
linux-hardening@...r.kernel.org,
Segher Boessenkool <segher@...nel.crashing.org>
Subject: Re: mainline build failure of powerpc allmodconfig for prom_init_check
On Sun, Jul 17, 2022 at 1:38 PM Sudip Mukherjee
<sudipm.mukherjee@...il.com> wrote:
>
> I have also tried adding volatile to all the members of that struct. :(
Can you read the code to figure otu what the memcpy is all about?
Or maybe there is something that disables 'volatile' with pre-processor hackery.
Because a compiler that turns a loop over volatile members into
'memset()' isn't a C compiler, it's just a random noise generator.
'volatile' is fundamental enough that I really doubt both gcc and
clang can be that broken.
I just tested this
struct hello {
volatile int array[100];
};
void test(void)
{
int i;
struct hello hello;
for (i = 0; i < 100; i++)
hello.array[i] = 0;
}
on x86-64, and sure enough, gcc-12 turns turns it into a memset
without the volatile (in fact, the above will just be optimized away
entirely since it has no user), but with the volatile it's a proper
regular loop that does 32-byte accesses one by one (and in the proper
ascending oder). Something that memset() most definitely does not
guarantee:
.L2:
movslq %eax, %rdx
addl $1, %eax
movl $0, -120(%rsp,%rdx,4)
cmpl $100, %eax
jne .L2
and honestly, anything else sounds completely unacceptable.
So I suspect there is something wrong with your testing, because gcc
simply isn't that incredibly broken. Clang is interesting in that it
seems to unroll the loop five times, but it still does the proper
"write individual 32-bit entities in ascending order".
The other alternative is that it's something else than that 'struct
prom_args'. Again, I don't read powerpc asm good.
Linus
Powered by blists - more mailing lists