public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Shuah Khan <shuah@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Andreas Larsson <andreas@gaisler.com>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	sparclinux@vger.kernel.org
Subject: Re: [PATCH] tools/nolibc: Add support for SPARC
Date: Mon, 17 Mar 2025 19:14:02 +0100	[thread overview]
Message-ID: <20250317181402.GB8377@1wt.eu> (raw)
In-Reply-To: <dacaa712-08a8-4fd6-ad47-2226040f02aa@t-8ch.de>

On Mon, Mar 17, 2025 at 06:52:57PM +0100, Thomas Weißschuh wrote:
> On 2025-03-17 08:37:46+0100, Willy Tarreau wrote:
> > On Sun, Mar 16, 2025 at 02:55:02PM +0100, Thomas Weißschuh wrote:
> > > Add support for 32bit and 64bit SPARC to nolibc.
> > 
> > Oh nice!
> > 
> > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> > > ---
> > > This is only tested on QEMU.
> > > Any tests on real hardware would be very welcome.
> > 
> > I still have a working U60 here, but under solaris. Such machines are
> > not trivial to boot on alternate OSes (and when you find a working
> > image usually it's based on an old kernel).
> 
> An old kernel should be perfectly fine, no?

I don't think so (it depends how old in fact), keep in mind that
we've removed support for a number of legacy syscalls.

> > > +/* startup code */
> > > +void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _start(void)
> > > +{
> > > +	__asm__ volatile (
> > > +		/*
> > > +		 * Save stack pointer to o0, as arg1 of _start_c.
> > > +		 * Account for window save area and stack bias.
> > > +		 */
> > > +#ifdef __arch64__
> > > +		"add %sp, 128 + 2047, %o0\n"
> > 
> > It's really unclear where this magical 2047 comes from, I think it must
> > be explained in the comment above so that someone disagreeing with it
> > later can figure whether it's right or wrong.
> 
> 128 is the context window and 2047 is the stack bias.
> I'll try to make it clearer.

OK thanks, but that remains quite strange to me. How can we end up
here with such an unaligned stack ? At the very minimum I'd expect
all offsets to be multiple of 8.

> > Also, I could be wrong, but from my old memories of playing with the
> > stack on SPARC long ago, I seem to remember that the stack is growing
> > down. Thus I find these "add" suspicious or at least confusing. You
> > mention "window save area and stack bias" above, I'm not sure what it
> > refers to, but if we can safely erase parts of the stack because too
> > much was preserved, maybe some more explanation about the initial and
> > target layouts is deserved here.
> 
> There is a graphic in the psABI [0] under "Process Stack and Registers".

Thanks for the link! Are you sure you can get rid of the window save
area ? I'm seeing that apparently it's used with save / restore, which
*if I remember well (30 years ago)* were used along with register bank
switches. In 3-12 it's written:

  Some registers have assigned roles.
    %sp or %o6 The stack pointer holds the limit of the current stack frame,
    %which is the address of the stacks bottommost, valid word. Stack contents
    %below the stack pointer are undened. At all times the stack pointer must
    %point to a doubleword aligned, 16- word window save area.

> I'll write something based on that.

Thanks!

> > > +		"b,a _start_c\n"     /* transfer to c runtime */
> > 
> > OK great, the delayed slot is covered! (that type of thing can work
> > by pure luck in one test and fail in another one depending on what
> > bytes follow the jump).
> 
> Yeah, it brings memories to the work on MIPS support.

absolutely!

Thanks,
Willy

  reply	other threads:[~2025-03-17 18:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-16 13:55 [PATCH] tools/nolibc: Add support for SPARC Thomas Weißschuh
2025-03-17  7:37 ` Willy Tarreau
2025-03-17 17:52   ` Thomas Weißschuh
2025-03-17 18:14     ` Willy Tarreau [this message]
2025-03-18  1:57       ` Chris Torek
2025-03-18  4:10         ` Willy Tarreau

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=20250317181402.GB8377@1wt.eu \
    --to=w@1wt.eu \
    --cc=andreas@gaisler.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=shuah@kernel.org \
    --cc=sparclinux@vger.kernel.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