linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Christophe Leroy <christophe.leroy@c-s.fr>
Cc: linux-kernel@vger.kernel.org, Paul Mackerras <paulus@samba.org>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: GCC bug ? Re: [PATCH v2 10/10] powerpc/32s: Implement Kernel Userspace Access Protection
Date: Wed, 22 Jan 2020 07:36:26 -0600	[thread overview]
Message-ID: <20200122133626.GL3191@gate.crashing.org> (raw)
In-Reply-To: <af9ad296-401c-cb5c-868a-7a6f91d1e8bc@c-s.fr>

On Wed, Jan 22, 2020 at 07:52:02AM +0100, Christophe Leroy wrote:
> Le 21/01/2020 à 20:55, Segher Boessenkool a écrit :
> >On Tue, Jan 21, 2020 at 05:22:32PM +0000, Christophe Leroy wrote:
> >>g1() should return 3, not 5.
> >
> >What makes you say that?
> 
> What makes me say that is that NULL is obviously a constant pointer and 
> I think we are all expecting gcc to see it as a constant during kernel 
> build, ie at -O2

But apparently at the point where the builtin was checked it did not
yet know it is passed a null pointer.

Please make a self-contained test case if we need further investigation?

> >"A return of 0 does not indicate that the
> >  value is _not_ a constant, but merely that GCC cannot prove it is a
> >  constant with the specified value of the '-O' option."
> >
> >(And the rules it uses for this are *not* the same as C "constant
> >expressions" or C "integer constant expression" or C "arithmetic
> >constant expression" or anything like that -- which should be already
> >obvious from that it changes with different -Ox).
> >
> >You can use builtin_constant_p to have the compiler do something better
> >if the compiler feels like it, but not anything more.  Often people
> >want stronger guarantees, but when they see how much less often it then
> >returns "true", they do not want that either.

> If GCC doesn't see NULL as a constant, then the above doesn't work as 
> expected.

That's not the question.  Of course GCC sees it as a null pointer
constant, because it is one.  But this builtin does its work very
early, during preprocessing already.  Its concept of "constant" is
very different.

Does it work if you write just "0" instead of "NULL", btw?  "0" is
also a null pointer constant eventually (here, that is).

The question is why (and if, it still needs verification after all)
builtin_constant_p didn't return true.


Segher

  reply	other threads:[~2020-01-22 13:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-11  8:30 [PATCH v2 00/10] Kernel Userspace protection for PPC32 Christophe Leroy
2019-03-11  8:30 ` [PATCH v2 01/10] powerpc/6xx: fix setup and use of SPRN_SPRG_PGDIR for hash32 Christophe Leroy
2019-03-20 13:04   ` [v2, " Michael Ellerman
2019-03-11  8:30 ` [PATCH v2 02/10] powerpc/mm: Detect bad KUAP faults (Squash of v5 series) Christophe Leroy
2019-03-11  8:30 ` [PATCH v2 03/10] powerpc/32: Remove MSR_PR test when returning from syscall Christophe Leroy
2019-04-21 14:18   ` [v2, " Michael Ellerman
2019-03-11  8:30 ` [PATCH v2 04/10] powerpc/32: Prepare for Kernel Userspace Access Protection Christophe Leroy
2019-03-11  8:30 ` [PATCH v2 05/10] powerpc/8xx: Only define APG0 and APG1 Christophe Leroy
2019-03-11  8:30 ` [PATCH v2 06/10] powerpc/8xx: Add Kernel Userspace Execution Prevention Christophe Leroy
2019-03-11  8:30 ` [PATCH v2 07/10] powerpc/8xx: Add Kernel Userspace Access Protection Christophe Leroy
2019-04-18  6:53   ` Michael Ellerman
2019-03-11  8:30 ` [PATCH v2 08/10] powerpc/32s: Implement Kernel Userspace Execution Prevention Christophe Leroy
2019-03-11  8:30 ` [PATCH v2 09/10] powerpc/32s: Prepare Kernel Userspace Access Protection Christophe Leroy
2019-03-11  8:30 ` [PATCH v2 10/10] powerpc/32s: Implement " Christophe Leroy
2019-04-18  6:55   ` Michael Ellerman
2019-04-23  9:26     ` Christophe Leroy
2020-01-21 17:22     ` GCC bug ? " Christophe Leroy
2020-01-21 19:55       ` Segher Boessenkool
2020-01-22  6:52         ` Christophe Leroy
2020-01-22 13:36           ` Segher Boessenkool [this message]
2020-01-22 14:45             ` Christophe Leroy
2020-01-22  6:57         ` Christophe Leroy
2020-01-22 13:18           ` Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200122133626.GL3191@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).