linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Rich Felker <dalias@libc.org>
To: Will Springer <skirmisher@protonmail.com>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: [musl] ppc64le and 32-bit LE userland compatibility
Date: Tue, 9 Jun 2020 12:06:34 -0400	[thread overview]
Message-ID: <20200609160633.GF1079@brightrain.aerifal.cx> (raw)
In-Reply-To: <20948555.hxa6pUQ8Du@sheen>

On Tue, Jun 09, 2020 at 10:29:57AM +0000, Will Springer wrote:
> On Saturday, May 30, 2020 3:56:47 PM PDT you wrote:
> > On Friday, May 29, 2020 12:24:27 PM PDT Rich Felker wrote:
> > > The argument passing for pread/pwrite is historically a mess and
> > > differs between archs. musl has a dedicated macro that archs can
> > > define to override it. But it looks like it should match regardless of
> > > BE vs LE, and musl already defines it for powerpc with the default
> > > definition, adding a zero arg to start on an even arg-slot index,
> > > which is an odd register (since ppc32 args start with an odd one, r3).
> > > 
> > > > [6]:
> > > > https://gist.github.com/Skirmisher/02891c1a8cafa0ff18b2460933ef4f3c
> > > 
> > > I don't think this is correct, but I'm confused about where it's
> > > getting messed up because it looks like it should already be right.
> > 
> > Hmm, interesting. Will have to go back to it I guess...
> > 
> > > > This was enough to fix up the `file` bug. I'm no seasoned kernel
> > > > hacker, though, and there is still concern over the right way to
> > > > approach this, whether it should live in the kernel or libc, etc.
> > > > Frankly, I don't know the ABI structure enough to understand why the
> > > > register padding has to be different in this case, or what
> > > > lower-level component is responsible for it.. For comparison, I had
> > > > a
> > > > look at the mips tree, since it's bi-endian and has a similar 32/64
> > > > situation. There is a macro conditional upon endianness that is
> > > > responsible for munging long longs; it uses __MIPSEB__ and
> > > > __MIPSEL__
> > > > instead of an if/else on the generic __LITTLE_ENDIAN__. Not sure
> > > > what
> > > > to make of that. (It also simply swaps registers for LE, unlike what
> > > > I did for ppc.)
> > > 
> > > Indeed the problem is probably that you need to swap registers for LE,
> > > not remove the padding slot. Did you check what happens if you pass a
> > > value larger than 32 bits?
> > > 
> > > If so, the right way to fix this on the kernel side would be to
> > > construct the value as a union rather than by bitwise ops so it's
> > > 
> > > endian-agnostic:
> > > 	(union { u32 parts[2]; u64 val; }){{ arg1, arg2 }}.val
> > > 
> > > But the kernel folks might prefer endian ifdefs for some odd reason...
> > 
> > You are right, this does seem odd considering what the other archs do.
> > It's quite possible I made a silly mistake, of course...
> > 
> > I haven't tested with values outside the 32-bit range yet; again, this
> > is new territory for me, so I haven't exactly done exhaustive tests on
> > everything. I'll give it a closer look.
> 
> I took some cues from the mips linux32 syscall setup, and drafted a new 
> patch defining a macro to compose the hi/lo parts within the function, 
> instead of swapping the args at the function definition. `file /bin/bash` 
> and `truncate -s 5G test` both work correctly now. This appears to be the 
> correct solution, so I'm not sure what silly mistake I made before, but 
> apologies for the confusion. I've updated my gist with the new patch [1].
> [...]
> 
> [1]: https://gist.github.com/Skirmisher/02891c1a8cafa0ff18b2460933ef4f3c

This patch looks correct. I prefer the union approach with no #ifdef
but I'm fine with either.

Rich

  reply	other threads:[~2020-06-09 16:08 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-29 19:03 ppc64le and 32-bit LE userland compatibility Will Springer
2020-05-29 19:24 ` [musl] " Rich Felker
2020-05-30 22:56   ` Will Springer
2020-06-09 10:29     ` Will Springer
2020-06-09 16:06       ` Rich Felker [this message]
2020-05-30 15:37 ` Christophe Leroy
2020-05-30 22:17   ` Will Springer
2020-06-05 23:54     ` Will Springer
2020-06-12  5:13       ` Christophe Leroy
2020-05-30 19:22 ` Segher Boessenkool
2020-05-31  0:57   ` Will Springer
2020-05-31 20:42     ` Segher Boessenkool
2020-05-31 22:29       ` [musl] " Daniel Kolesa
2020-06-02  1:36         ` Segher Boessenkool
2020-06-01 21:28 ` Joseph Myers
2020-06-01 21:36   ` [musl] " Rich Felker
2020-06-01 23:26   ` Daniel Kolesa
2020-06-01 23:45     ` Joseph Myers
2020-06-01 23:55       ` Joseph Myers
2020-06-02  0:13         ` Daniel Kolesa
2020-06-02  0:11       ` Daniel Kolesa
2020-06-02 13:40         ` Joseph Myers
2020-06-02 14:23           ` Michal Suchánek
2020-06-02 15:13             ` Daniel Kolesa
2020-06-02 15:27               ` Michal Suchánek
2020-06-02 15:40                 ` Daniel Kolesa
2020-06-02 15:56                   ` Michal Suchánek
2020-06-04 17:20                 ` Segher Boessenkool
2020-06-04 17:12               ` Segher Boessenkool
2020-06-04 17:18                 ` [musl] " Rich Felker
2020-06-04 17:33                   ` Segher Boessenkool
2020-06-04 17:46                     ` Rich Felker
2020-06-04 19:00                       ` David Edelsohn
2020-06-04 19:37                         ` Rich Felker
2020-06-04 20:39                     ` Daniel Kolesa
2020-06-04 21:10                       ` Segher Boessenkool
2020-06-04 21:43                         ` Daniel Kolesa
2020-06-04 22:08                           ` Joseph Myers
2020-06-04 22:26                             ` Daniel Kolesa
2020-06-05  0:02                               ` Segher Boessenkool
2020-06-04 23:42                             ` Segher Boessenkool
2020-06-04 23:35                           ` Segher Boessenkool
2020-06-05  2:18                             ` Daniel Kolesa
2020-06-05 17:27                               ` Segher Boessenkool
2020-06-05 17:50                                 ` Rich Felker
2020-06-05 23:45                                   ` Segher Boessenkool
2020-06-05 21:59                                 ` Daniel Kolesa
2020-06-06  0:12                                   ` Segher Boessenkool
2020-06-06  2:13                                     ` Daniel Kolesa
2020-06-04 21:55                       ` Phil Blundell
2020-06-04 22:06                         ` Daniel Kolesa
2020-06-04 23:06                         ` Segher Boessenkool
2020-06-04 23:43                           ` Phil Blundell
2020-06-02 14:52           ` Daniel Kolesa
2020-06-02  2:12       ` Segher Boessenkool
2020-06-02  2:17         ` Daniel Kolesa
2020-06-02 13:50         ` Joseph Myers
2020-06-02 17:47           ` Segher Boessenkool
2020-06-02  1:58     ` Segher Boessenkool
2020-06-02  2:09       ` [musl] " Jeffrey Walton
2020-06-02  2:12       ` Daniel Kolesa
2020-06-02  2:36         ` Segher Boessenkool
2020-06-02  2:55           ` Daniel Kolesa
2020-06-02  1:42   ` Segher Boessenkool
2020-06-02  2:03     ` Daniel Kolesa

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=20200609160633.GF1079@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=skirmisher@protonmail.com \
    /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).