From: Chris Metcalf <cmetcalf@tilera.com>
To: "H. Peter Anvin" <hpa@zytor.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
<libc-ports@sourceware.org>
Cc: David Daney <ddaney.cavm@gmail.com>,
Ralf Baechle <ralf@linux-mips.org>,
"H.J. Lu" <hjl.tools@gmail.com>, <linux-kernel@vger.kernel.org>,
<linux-arch@vger.kernel.org>, <mingo@kernel.org>,
<tglx@linutronix.de>, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH 08/10] Use __kernel_ulong_t in struct msqid64_ds
Date: Fri, 18 May 2012 11:03:15 -0400 [thread overview]
Message-ID: <4FB664B3.7090100@tilera.com> (raw)
In-Reply-To: <4FB599AC.1010807@zytor.com>
(Cc'ing libc-ports and Arnd Bergmann.)
On 5/17/2012 8:37 PM, H. Peter Anvin wrote:
> It looks like MIPS has a private definition of struct msqid64_ds, as do
> most other architectures; the MIPS one is completely broken for user
> space usages as it uses CONFIG_* macros:
>
> #if defined(CONFIG_32BIT) && !defined(CONFIG_CPU_LITTLE_ENDIAN)
> unsigned long __unused2;
> #endif
> __kernel_time_t msg_rtime; /* last msgrcv time */
> #if defined(CONFIG_32BIT) && defined(CONFIG_CPU_LITTLE_ENDIAN)
> unsigned long __unused2;
> #endif
>
> It looks like the only users of asm-generic here are:
>
> arch/microblaze/include/asm/msgbuf.h:#include <asm-generic/msgbuf.h>
> arch/score/include/asm/msgbuf.h:#include <asm-generic/msgbuf.h>
> arch/sh/include/asm/msgbuf.h:#include <asm-generic/msgbuf.h>
> arch/x86/include/asm/msgbuf.h:#include <asm-generic/msgbuf.h>
>
> ... and unless I'm mistaken, x86 is the only one of those which isn't 32
> bits only, which explains the reason it "works"...
Don't forget the newer architectures that use generic-y:
arch/blackfin/include/asm/Kbuild:generic-y += msgbuf.h
arch/c6x/include/asm/Kbuild:generic-y += msgbuf.h
arch/hexagon/include/asm/Kbuild:generic-y += msgbuf.h
arch/openrisc/include/asm/Kbuild:generic-y += msgbuf.h
arch/tile/include/asm/Kbuild:generic-y += msgbuf.h
arch/unicore32/include/asm/Kbuild:generic-y += msgbuf.h
On 5/17/2012 8:22 PM, Linus Torvalds wrote:
> That's why I think it's unfixable. It started out broken, and I
> presume that 32-bit user land on a 64-bit MIPS/PPC thing either do not
> work, or there's some compat crap (like special user-land headers)
> fixing things up. Or they just don't use that buggered msqid64_ds
> thing at all.
Yes, it's compat crap. Each architecture defines its own compat_msqid64_ds
that carefully places the padding in the same place as the corresponding
native 32-bit kernel puts it, and glibc doesn't use <asm/msgbuf.h> at all,
but instead provides a hand-rolled <bits/msq.h>.
I added a glibc <bits/msq.h> that targets the asm-generic version of the
header, so it puts the padding after the time_t, even on big-endian
platforms. This is of course crazy, but it's what you need to do to use
the current asm-generic header.
However, now is a good time to ask whether this is the right thing to do
going forward. The tile architecture is the only one that currently offers
a 32-bit big-endian userspace (only in linux-next, queued for 3.5) and also
uses <asm-generic> for the SysV stuff, so if someone wants to advocate for
changing this, now is definitely a good time for it.
We could modify asm-generic so that it puts the padding where it "ought" to
go, easily enough. This would then allow three of the four big-endian
32-bit architectures (sparc, parisc, powerpc) to use the generic headers,
if they wished. (The fourth one, s390, puts the padding after, like
asm-generic currently does.)
This might then allow us to consider making "struct compat_msqid64_ds" and
friends something that is defined in <linux/compat.h> rather than
per-architecture, though we'd need a hook to allow architectures like s390
to override and provide their own definition.
As far as x32 goes, this should all be largely irrelevant, since it likely
won't use the compat structures anyway, and since we're not proposing
breaking the little-endian layout. But future x32-style compat big-endian
architectures would benefit from having a msqid64_ds structure that
actually lays out the same in 32- or 64-bit mode.
--
Chris Metcalf, Tilera Corp.
http://www.tilera.com
next prev parent reply other threads:[~2012-05-18 15:03 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-17 22:13 [RFC PATCH 00/10] Use __kernel_[u]long_t for x32 user space compatibility H.J. Lu
2012-05-17 22:13 ` [PATCH 01/10] Use __kernel_long_t in struct timex H.J. Lu
2012-05-17 22:32 ` Linus Torvalds
2012-05-17 22:41 ` H. Peter Anvin
2012-05-17 22:50 ` H. Peter Anvin
2012-05-17 22:50 ` Linus Torvalds
2012-05-17 22:55 ` H. Peter Anvin
2012-05-17 22:58 ` Linus Torvalds
2012-05-17 22:56 ` Linus Torvalds
2012-05-17 22:57 ` H. Peter Anvin
2012-05-17 23:51 ` David Daney
2012-05-17 22:13 ` [PATCH 02/10] Use __kernel_ulong_t in struct shm_info H.J. Lu
2012-05-17 22:13 ` [PATCH 03/10] Use __kernel_[u]long_t in linux/resource.h H.J. Lu
2012-05-17 22:13 ` [PATCH 04/10] Use __kernel_long_t in struct msgbuf H.J. Lu
2012-05-17 22:13 ` [PATCH 05/10] Use __kernel_long_t in struct mq_attr H.J. Lu
2012-05-17 22:13 ` [PATCH 06/10] Use __kernel_ulong_t in x86 struct semid64_ds H.J. Lu
2012-05-17 22:13 ` [PATCH 07/10] Use __kernel_ulong_t in struct shmid64_ds/shminfo64 H.J. Lu
2012-05-17 22:13 ` [PATCH 08/10] Use __kernel_ulong_t in struct msqid64_ds H.J. Lu
2012-05-17 23:51 ` H. Peter Anvin
2012-05-18 0:07 ` Linus Torvalds
2012-05-18 0:14 ` H. Peter Anvin
2012-05-18 0:22 ` Linus Torvalds
2012-05-18 0:27 ` H. Peter Anvin
2012-05-18 0:41 ` Linus Torvalds
2012-05-18 11:44 ` David Howells
2012-05-18 21:31 ` Arnd Bergmann
2012-05-18 21:41 ` H. Peter Anvin
2012-05-18 21:58 ` Arnd Bergmann
2012-05-18 22:08 ` H. Peter Anvin
2012-05-19 7:56 ` Arnd Bergmann
2012-05-19 14:35 ` Al Viro
2012-05-18 0:29 ` David Daney
2012-05-18 0:31 ` H. Peter Anvin
2012-05-18 0:45 ` David Daney
2012-05-18 0:37 ` H. Peter Anvin
2012-05-18 15:03 ` Chris Metcalf [this message]
2012-05-18 3:21 ` H. Peter Anvin
2012-05-18 3:39 ` H.J. Lu
2012-05-18 3:43 ` H.J. Lu
2012-05-18 3:47 ` H.J. Lu
2012-05-18 3:49 ` Linus Torvalds
2012-05-18 3:55 ` H. Peter Anvin
2012-05-18 3:59 ` H.J. Lu
2012-05-18 4:05 ` Linus Torvalds
2012-05-18 4:13 ` H.J. Lu
2012-05-18 21:21 ` Arnd Bergmann
2012-05-19 23:47 ` H. Peter Anvin
2012-05-20 1:32 ` H.J. Lu
2012-05-20 2:08 ` H. Peter Anvin
2012-05-18 11:53 ` David Howells
2012-05-18 12:06 ` H.J. Lu
2012-05-18 3:56 ` H.J. Lu
2012-05-18 21:06 ` H. Peter Anvin
2012-05-17 22:13 ` [PATCH 09/10] Use __kernel_ulong_t in struct ipc64_perm H.J. Lu
2012-05-17 22:13 ` [PATCH 10/10] Use __kernel_[u]long_t in x86-64 struct stat H.J. Lu
2012-05-17 23:07 ` [RFC PATCH 00/10] Use __kernel_[u]long_t for x32 user space compatibility David Daney
2012-05-17 23:11 ` H. Peter Anvin
2012-05-17 23:25 ` David Daney
2012-05-17 23:31 ` H. Peter Anvin
2012-05-18 0:19 ` Mike Frysinger
2012-05-18 0:21 ` H. Peter Anvin
2012-05-18 0:38 ` Mike Frysinger
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=4FB664B3.7090100@tilera.com \
--to=cmetcalf@tilera.com \
--cc=arnd@arndb.de \
--cc=ddaney.cavm@gmail.com \
--cc=hjl.tools@gmail.com \
--cc=hpa@zytor.com \
--cc=libc-ports@sourceware.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=ralf@linux-mips.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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).