All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: Zhangjin Wu <falcon@tinylab.org>
Cc: thomas@t-8ch.de, arnd@arndb.de, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, tanyuan@tinylab.org
Subject: Re: [PATCH v4 08/12] selftests/nolibc: add test support for ppc
Date: Thu, 3 Aug 2023 06:37:20 +0200	[thread overview]
Message-ID: <20230803043720.GA24073@1wt.eu> (raw)
In-Reply-To: <20230803025855.6925-1-falcon@tinylab.org>

On Thu, Aug 03, 2023 at 10:58:55AM +0800, Zhangjin Wu wrote:
> Yes, ppc series at first, will renew it today. let's delay the whole tinyconfig
> series (include part1) in v6.7, we have no enough time to test them carefully
> for v6.6.

Thanks.

> > > > > Further compared the preprocessed files, found the root cause is the new
> > > > > compiler using 'no_stack_protector' instead of
> > > > > '__optimize__("-fno-stack-protector")'. And the attribute 'no_stack_protector'
> > > > > breaks our "omit-frame-pointer" like the failure with '-O0' we fixed before.
> > > > > 
> > > > > I checked some of the other architectures, they didn't have the same issue, but
> > > > > test shows the 'no_stack_protector' attribute does have such compability issue
> > > > > here.
> > > > > 
> > > > > I learned the commit message of tools/include/nolibc/compiler.h, seems
> > > > > __optimize__("-fno-stack-protector") is enough for all of the nolibc supported
> > > > > architectures? is it ok for us to simply give up 'no_stack_protector'
> > > > > eventully? otherwise, we should manually disable 'no_stack_protector' for
> > > > > ppc32:
> > > > > 
> > > > >     #define __no_stack_protector __attribute__((__optimize__("-fno-stack-protector")))
> > > > >
> > > > 
> > > > Hello, any suggestion here? ;-)
> > > 
> > > Patience :-)
> > > 
> > > no_stack_protector is the offically documented mechanism to disable
> > > stack protector for a function. As it works for all other architectures
> > > this seems like a compiler bug.
> >
> > Or a limitation. To be honest we're playing with compiler limits by
> > adjusting their optimizations per function.  But as long as we don't
> > break what currently works, we can accept to have some limits in a first
> > version (e.g. if ppc32 doesn't support -O0 for now it's not dramatic).
> > Also, some other archs use optimize("Os", "omit-frame-pointer")), maybe
> > that's needed there as well.
> >
> 
> Since it is really related, let's summarize yesterdays's further test here for
> a reference:
> 
> Yesterday's test result on randomly chosen x86_64 and riscv64 shows,
> from at least gcc 12.3.0 (may differs from archs), even with
> optimize("Os", "omit-frame-pointer")), whatever with or without
> '-fno-stack-protector', -O0 forbids the per function's
> "omit-frame-pointer" as the doc [1] describes (as we discussed before),
> that means some imtermediate gcc versions deviate from their docs and
> now, the latest gcc version come back to follow its doc [1] and become
> even more strict and then breaks our optimize("Os",
> "omit-frame-pointer") workaround eventually:
> 
>     Most optimizations are completely disabled at -O0 or if an -O level
>     is not set on the command line, even if individual optimization
>     flags are specified.

Note that the quoted paragraph above is mostly independent. The point
here is that optimize("-Os") seems to be ignored then -O0 is passed
on the command line. But I'm not that much surprised, because as we
said, changing optimizations on the fly is tricky given that some have
effects beyond just a function.

> So, it is ok for us to simply ignore -O0 currently, let's work on them
> in v6.7.

Yeah I'm fine with this. In the worst case those using -O0 can also avoid
using stack-protector.

> > > If we want to work around it I would prefer to have both attributes.
> > 
> > Also if you remember we also used to have a work-around for the
> > function's entry code consisting in renaming _start and having a _start
> > pointer in the asm code itself. That can remain an option to experiment
> > with later.
> 
> Yes, the 'asm' style of _start may be a choice to prevent gcc touching
> our startup code.

That was the case. We had an earlier version where _start was a label
inside the asm statement, resulting in some unused prologue and epilogue
for the function around that code. It was a bit ugly and I think it had
some shortcomings but we may go back to that later if it brings some
value.

Willy

  reply	other threads:[~2023-08-03  4:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01 19:36 [PATCH v4 00/12] tools/nolibc: add 32/64-bit powerpc support Zhangjin Wu
2023-08-01 19:37 ` [PATCH v4 01/12] tools/nolibc: add support for powerpc Zhangjin Wu
2023-08-01 19:38 ` [PATCH v4 02/12] tools/nolibc: add support for powerpc64 Zhangjin Wu
2023-08-01 19:39 ` [PATCH v4 03/12] selftests/nolibc: fix up O= option support Zhangjin Wu
2023-08-01 19:40 ` [PATCH v4 04/12] selftests/nolibc: add macros to reduce duplicated changes Zhangjin Wu
2023-08-01 19:41 ` [PATCH v4 05/12] selftests/nolibc: add XARCH and ARCH mapping support Zhangjin Wu
2023-08-01 19:42 ` [PATCH v4 06/12] selftests/nolibc: add nolibc-test-config target Zhangjin Wu
2023-08-01 19:43 ` [PATCH v4 07/12] selftests/nolibc: add help for " Zhangjin Wu
2023-08-01 19:44 ` [PATCH v4 08/12] selftests/nolibc: add test support for ppc Zhangjin Wu
2023-08-02  5:21   ` Zhangjin Wu
2023-08-02  7:48     ` Willy Tarreau
2023-08-02 10:32       ` Zhangjin Wu
2023-08-02 16:03         ` Zhangjin Wu
2023-08-02 21:36           ` Thomas Weißschuh
2023-08-03  2:05             ` Willy Tarreau
2023-08-03  2:58               ` Zhangjin Wu
2023-08-03  4:37                 ` Willy Tarreau [this message]
2023-08-03  7:51               ` Zhangjin Wu
2023-08-01 19:45 ` [PATCH v4 09/12] selftests/nolibc: add test support for ppc64le Zhangjin Wu
2023-08-01 19:46 ` [PATCH v4 10/12] selftests/nolibc: add test support for ppc64 Zhangjin Wu
2023-08-01 19:47 ` [PATCH v4 11/12] selftests/nolibc: allow customize CROSS_COMPILE by architecture Zhangjin Wu
2023-08-01 19:49 ` [PATCH v4 12/12] selftests/nolibc: customize CROSS_COMPILE for 32/64-bit powerpc Zhangjin Wu

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=20230803043720.GA24073@1wt.eu \
    --to=w@1wt.eu \
    --cc=arnd@arndb.de \
    --cc=falcon@tinylab.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=tanyuan@tinylab.org \
    --cc=thomas@t-8ch.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.