/* message buffer for msgsnd and msgrcv calls */
struct msgbuf {
- long mtype; /* type of message */
- char mtext[1]; /* message text */
+ __kernel_long_t mtype; /* type of message */
+ char mtext[1]; /* message text */
};
/* buffer for msgctl calls IPC_INFO, MSG_INFO */
-- 1.7.6.5
struct mq_attr {
- long mq_flags; /* message queue flags */
- long mq_maxmsg; /* maximum number of messages */
- long mq_msgsize; /* maximum message size */
- long mq_curmsgs; /* number of messages currently queued */
- long __reserved[4]; /* ignored for input, zeroed for output */
+ __kernel_long_t mq_flags; /* message queue flags */
+ __kernel_long_t mq_maxmsg; /* maximum number of messages */
+ __kernel_long_t mq_msgsize; /* maximum message size */
+ __kernel_long_t mq_curmsgs; /* number of messages currently queued */
+ __kernel_long_t __reserved[4]; /* ignored for input, zeroed for output */
};
This patch set changes a number of places where the kernel headers are
exported to user space and currently use explicit "long" or "unsigned
long" to use __kernel_[u]long_t in order to be compatible with the x32
user space ABI. These location are places where x32 uses the x86-64
ABI.
It is quite possible that some, or even all, of these locations should
really use dedicated types, but in the meantime this gives the correct
results which the current headers do not.
Replace unsigned long with __kernel_ulong_t in struct msqid64_ds for
user space. Don't change unsigned long when __BITS_PER_LONG != 64
since __kernel_ulong_t == unsigned long in this case.
diff --git a/include/asm-generic/msgbuf.h b/include/asm-generic/msgbuf.h
index aec850d..f55ecc4 100644
--- a/include/asm-generic/msgbuf.h
+++ b/include/asm-generic/msgbuf.h
@@ -35,13 +35,13 @@ struct msqid64_ds {
#if __BITS_PER_LONG != 64
unsigned long __unused3;
#endif
- unsigned long msg_cbytes; /* current number of bytes on queue */
- unsigned long msg_qnum; /* number of messages in queue */
- unsigned long msg_qbytes; /* max number of bytes on queue */
+ __kernel_ulong_t msg_cbytes; /* current number of bytes on queue */
+ __kernel_ulong_t msg_qnum; /* number of messages in queue */
+ __kernel_ulong_t msg_qbytes; /* max number of bytes on queue */
__kernel_pid_t msg_lspid; /* pid of last msgsnd */
__kernel_pid_t msg_lrpid; /* last receive pid */
- unsigned long __unused4;
- unsigned long __unused5;
+ __kernel_ulong_t __unused4;
+ __kernel_ulong_t __unused5;
};
On Thu, May 17, 2012 at 3:13 PM, H.J. Lu <hjl.to...@gmail.com> wrote:
> Replace long with __kernel_long_t in struct timex for user space.
I absolutely detest these types.
I realize that we already have a few users, but just looking at these
diffs *hurts*. It's disgusting.
The whole __kernel_ prefix was a mistake, but it at least makes sense
for certain things where it is really about some random kernel choice
(ie __kernel_pid_t). Even there I despise it, because it's not really
about "kernel choice", it's about just the real native type for uid_t
- the fact that user-mode then occasionally screwed up because glibc
has chosen crazy extended types is really not a "kernel" issue at all.
So the naming in general is painful.
When it comes to the x32 thing I think it's *doubly* wrong, because
this isn't even about a "kernel choice". It's damn well the native
machine word-size. The fact that a limited user-mode ABI then limits
"long" to 32-bit is not the kernels problem.
So I'd really like to see some discussion about naming. What does this
have to do with "kernel"? Nothing. It's the native word-size of the
machine, for crying out loud. The fact that some user interfaces may
limit themselves is not a "user mode vs kernel" thing.
> The whole __kernel_ prefix was a mistake, but it at least makes sense
> for certain things where it is really about some random kernel choice
> (ie __kernel_pid_t). Even there I despise it, because it's not really
> about "kernel choice", it's about just the real native type for uid_t
> - the fact that user-mode then occasionally screwed up because glibc
> has chosen crazy extended types is really not a "kernel" issue at all.
> So the naming in general is painful.
> When it comes to the x32 thing I think it's *doubly* wrong, because
> this isn't even about a "kernel choice". It's damn well the native
> machine word-size. The fact that a limited user-mode ABI then limits
> "long" to 32-bit is not the kernels problem.
> So I'd really like to see some discussion about naming. What does this
> have to do with "kernel"? Nothing. It's the native word-size of the
> machine, for crying out loud. The fact that some user interfaces may
> limit themselves is not a "user mode vs kernel" thing.
It also puts a clear line between the kernel and user space namespaces,
which has been an ongoing problem (we *still* haven't cleaned out some
namespace pollution in the i386 <asm/signal.h> for example.)
That being said, this is a lot like the __u* and __s* types which we use
instead of <stdint.h> for similar reasons. I don't know if
__ulong/__slong or __uword/__sword would be better here?
-hpa
-- H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
On Thu, May 17, 2012 at 3:41 PM, H. Peter Anvin <h...@zytor.com> wrote:
> It also puts a clear line between the kernel and user space namespaces,
> which has been an ongoing problem (we *still* haven't cleaned out some
> namespace pollution in the i386 <asm/signal.h> for example.)
> That being said, this is a lot like the __u* and __s* types which we use
> instead of <stdint.h> for similar reasons. I don't know if
> __ulong/__slong or __uword/__sword would be better here?
Yes, I do think this is closer to the "__u32" kind of usage, and in
general I tend to think that's true of most of the __kernel_ prefix
things. There is very little "kernely" things about it.
Yes, we have to have the double underscore (or single+capitalized),
but I think that at least personally, I'd be happier with just
"__long" and "__ulong".
I think __word would be good too, *except* for the fact that
especially in x86 land, I think there's the legacy confusion with
"word" being 16-bit. Ugh.
So I don't know. I just do know that I don't see the point in that
"__kernel_" prefix.
> Yes, I do think this is closer to the "__u32" kind of usage, and in
> general I tend to think that's true of most of the __kernel_ prefix
> things. There is very little "kernely" things about it.
The only think "kernely" about it is that it describes the kernel ABI.
> Yes, we have to have the double underscore (or single+capitalized),
> but I think that at least personally, I'd be happier with just
> "__long" and "__ulong".
I would suggest __slong and __ulong then, to keep with the __[su]*
namespace, or does the extra "s" look too much like crap?
-hpa
-- H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
> I think __word would be good too, *except* for the fact that
> especially in x86 land, I think there's the legacy confusion with
> "word" being 16-bit. Ugh.
Looking at the x32 case, I have to say that "long" in general looks
horrible. Especially when we have things like
typedef long long __kernel_long_t;
(and __long really wouldn't look any nicer). Any sane person would go
"Eww" at looking at that - we're using 'long long' to typedef a type
that is named 'long'.
It would make much more sense to use "__word" for reasons like that.
But I really don't think that works well in a x86 context.
Other ideas? Maybe "__wordsize" would be less associated with x86 16-bit words?
> This patch set changes a number of places where the kernel headers are
> exported to user space and currently use explicit "long" or "unsigned
> long" to use __kernel_[u]long_t in order to be compatible with the x32
> user space ABI. These location are places where x32 uses the x86-64
> ABI.
Has anybody checked how this affects MIPS n32 userspace?
I think it totally breaks it.
In addition, 109a1f32 (sysinfo: Use explicit types in <linux/sysinfo.h>) is probably bad. I think it may need to be reverted, or somebody should fix all the __kernel_{,u}long_t definitions for the ABI that may have been broken by the change.
> It is quite possible that some, or even all, of these locations should
> really use dedicated types, but in the meantime this gives the correct
> results which the current headers do not.
>> Has anybody checked how this affects MIPS n32 userspace?
>> I think it totally breaks it.
> Do you have any basis whatsoever for that statement?
You should have asked for a 'solid basis'.
My basis is that the name '__kernel_ulong_t' implies, in my mind, that it would have the width of a kernel unsigned long.
Really it should be called something like __abi_alternate_ulong_t.
> This should have
> zero effect on any non-x32 platforms.
After further reflection on this, you are probably right.
Sorry for raising the alarm (or would that be crying Wolf?).
>> In addition, 109a1f32 (sysinfo: Use explicit types in<linux/sysinfo.h>)
>> is probably bad. I think it may need to be reverted, or somebody should
>> fix all the __kernel_{,u}long_t definitions for the ABI that may have
>> been broken by the change.
> You realize __kernel_[u]long_t didn't even exist until the 3.4 kernel,
> right?
> Replace unsigned long with __kernel_ulong_t in struct msqid64_ds for
> user space. Don't change unsigned long when __BITS_PER_LONG != 64
> since __kernel_ulong_t == unsigned long in this case.
.. which means __BITS_PER_LONG == 64 on x86-64. This seems wrong. The
result would seem to be that the padding members around __kernel_time_t
in struct shmid64_ds (not visible in patch 07/10 but existing in the
same structure) work by accident (I also wonder how the heck they're
currently supposed to work on bigendian architectures!!)
However, whereas struct shmid64_ds seems to work okay, this patch would
now seem to be wrong.
The sane thing would seem to be to change __BITS_PER_LONG to 32 on x32
and fix the padding hacks in struct shmid64_ds; H.J., would you agree?
-hpa
-- H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
> On Thu, May 17, 2012 at 3:50 PM, Linus Torvalds
> <torva...@linux-foundation.org> wrote:
>> I think __word would be good too, *except* for the fact that
>> especially in x86 land, I think there's the legacy confusion with
>> "word" being 16-bit. Ugh.
> Looking at the x32 case, I have to say that "long" in general looks
> horrible. Especially when we have things like
> typedef long long __kernel_long_t;
> (and __long really wouldn't look any nicer). Any sane person would go
> "Eww" at looking at that - we're using 'long long' to typedef a type
> that is named 'long'.
> It would make much more sense to use "__word" for reasons like that.
> But I really don't think that works well in a x86 context.
> Other ideas? Maybe "__wordsize" would be less associated with x86 16-bit words?
FWIW: "__abi_wordsize" to indicate that it is not really a property of the machine itself, but rather the ABI in use.
On Thu, May 17, 2012 at 4:51 PM, H. Peter Anvin <h...@zytor.com> wrote:
> The sane thing would seem to be to change __BITS_PER_LONG to 32 on x32
> and fix the padding hacks in struct shmid64_ds; H.J., would you agree?
Ugh. That looks like a disaster.
The padding hacks that depend on __BITS_PER_LONG seem pretty damn broken anyway.
They only work if the kernel agrees with the value (which is against
the whole point of making __BITS_PER_LONG be about some user-level ABI
thing) or for little-endian machines.
IOW, all the __BITS_PER_LONG games look totally broken to me. I can't
see how they could possibly even be fixed.
> On Thu, May 17, 2012 at 4:51 PM, H. Peter Anvin <h...@zytor.com> wrote:
>> The sane thing would seem to be to change __BITS_PER_LONG to 32 on x32
>> and fix the padding hacks in struct shmid64_ds; H.J., would you agree?
> Ugh. That looks like a disaster.
> The padding hacks that depend on __BITS_PER_LONG seem pretty damn broken anyway.
> They only work if the kernel agrees with the value (which is against
> the whole point of making __BITS_PER_LONG be about some user-level ABI
> thing) or for little-endian machines.
> IOW, all the __BITS_PER_LONG games look totally broken to me. I can't
> see how they could possibly even be fixed.
Well, on existing compat (e.g. i386) __BITS_PER_LONG is definitely not
the same as kernel. And yes, I don't see how the heck this was ever
correct on bigendian machines or even for compat in any form (if the
kernel tries to interpret the extra bits and user space didn't
initialize them we're lost.)
The "logical" thing to do here seems to just use __s64, but I have no
idea if that would suddenly break bigendian architectures...
David, Ralf, do you have any idea what e.g. MIPS does here?
-hpa
-- H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
> On Thursday 17 May 2012 18:13:26 H.J. Lu wrote:
>> From: H.J. Lu <hjl.to...@gmail.com>
>> This patch set changes a number of places where the kernel
>> headers are exported to user space and currently use explicit
>> "long" or "unsigned long" to use __kernel_[u]long_t in order to
>> be compatible with the x32 user space ABI. These location are
>> places where x32 uses the x86-64 ABI.
>> It is quite possible that some, or even all, of these locations
>> should really use dedicated types, but in the meantime this gives
>> the correct results which the current headers do not.
> tangentially related, but what happened to the x86 asm/ptrace.h
> patch i sent that changed all the registers from unsigned long to
> u64 ? e.g. struct pt_regs { - unsigned long r15; + __u64 r15; > -mike
Link please?
-hpa
-- H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.