From: "H. Peter Anvin" <hpa@zytor.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Jamie Lokier <jamie@shareable.org>,
ville.syrjala@linux.intel.com, Borislav Petkov <bp@alien8.de>,
Russell King - ARM Linux <linux@arm.linux.org.uk>,
Thomas Gleixner <tglx@linutronix.de>,
linux-tip-commits@vger.kernel.org,
"H.J. Lu" <hjl.tools@gmail.com>
Subject: Re: [tip:x86/mm] x86, mm: Use a bitfield to mask nuisance get_user() warnings
Date: Mon, 11 Feb 2013 20:21:31 -0800 [thread overview]
Message-ID: <5119C34B.70207@zytor.com> (raw)
In-Reply-To: <CA+55aFxaUUMQuw3bgLbZLARp05eM19E_qTXBYePPk9mvEsSp=g@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 623 bytes --]
On 02/11/2013 07:33 PM, Linus Torvalds wrote:
> On Mon, Feb 11, 2013 at 5:37 PM, tip-bot for H. Peter Anvin
> <hpa@zytor.com> wrote:
>>
>> However, we can declare a bitfield using sizeof(), which is legal
>> because sizeof() is a constant expression. This quiets the warning,
>> although the code generated isn't 100% identical from the baseline
>> before 96477b4 x86-32: Add support for 64bit get_user():
>
> Christ. This is so ugly that it's almost a work of art.
:)
> Has anybody run this past any gcc developers? And if so, did they run
> away screaming?
I haven't no... H.J., any comments on this patch?
-hpa
[-- Attachment #2: Attached Message --]
[-- Type: message/rfc822, Size: 6168 bytes --]
From: "tip-bot for H. Peter Anvin" <hpa@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org, torvalds@linux-foundation.org, jamie@shareable.org, ville.syrjala@linux.intel.com, bp@alien8.de, linux@arm.linux.org.uk, tglx@linutronix.de
Subject: [tip:x86/mm] x86, mm: Use a bitfield to mask nuisance get_user() warnings
Date: Mon, 11 Feb 2013 17:37:52 -0800
Message-ID: <tip-b390784dc1649f6e6c5e66e5f53c21e715ccf39b@git.kernel.org>
Commit-ID: b390784dc1649f6e6c5e66e5f53c21e715ccf39b
Gitweb: http://git.kernel.org/tip/b390784dc1649f6e6c5e66e5f53c21e715ccf39b
Author: H. Peter Anvin <hpa@zytor.com>
AuthorDate: Mon, 11 Feb 2013 16:27:28 -0800
Committer: H. Peter Anvin <hpa@zytor.com>
CommitDate: Mon, 11 Feb 2013 17:26:51 -0800
x86, mm: Use a bitfield to mask nuisance get_user() warnings
Even though it is never executed, gcc wants to warn for casting from
a large integer to a pointer. Furthermore, using a variable with
__typeof__() doesn't work because __typeof__ retains storage
specifiers (const, restrict, volatile).
However, we can declare a bitfield using sizeof(), which is legal
because sizeof() is a constant expression. This quiets the warning,
although the code generated isn't 100% identical from the baseline
before 96477b4 x86-32: Add support for 64bit get_user():
[x86-mb is baseline, x86-mm is this commit]
text data bss filename
113716147 15858380 35037184 tip.x86-mb/o.i386-allconfig/vmlinux
113716145 15858380 35037184 tip.x86-mm/o.i386-allconfig/vmlinux
12989837 3597944 12255232 tip.x86-mb/o.i386-modconfig/vmlinux
12989831 3597944 12255232 tip.x86-mm/o.i386-modconfig/vmlinux
1462784 237608 1401988 tip.x86-mb/o.i386-noconfig/vmlinux
1462837 237608 1401964 tip.x86-mm/o.i386-noconfig/vmlinux
7938994 553688 7639040 tip.x86-mb/o.i386-pae/vmlinux
7943136 557784 7639040 tip.x86-mm/o.i386-pae/vmlinux
7186126 510572 6574080 tip.x86-mb/o.i386/vmlinux
7186124 510572 6574080 tip.x86-mm/o.i386/vmlinux
103747269 33578856 65888256 tip.x86-mb/o.x86_64-allconfig/vmlinux
103746949 33578856 65888256 tip.x86-mm/o.x86_64-allconfig/vmlinux
12116695 11035832 20160512 tip.x86-mb/o.x86_64-modconfig/vmlinux
12116567 11035832 20160512 tip.x86-mm/o.x86_64-modconfig/vmlinux
1700790 380524 511808 tip.x86-mb/o.x86_64-noconfig/vmlinux
1700790 380524 511808 tip.x86-mm/o.x86_64-noconfig/vmlinux
12413612 1133376 1101824 tip.x86-mb/o.x86_64/vmlinux
12413484 1133376 1101824 tip.x86-mm/o.x86_64/vmlinux
Cc: Jamie Lokier <jamie@shareable.org>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20130209110031.GA17833@n2100.arm.linux.org.uk
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
arch/x86/include/asm/uaccess.h | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 1e96326..a8d1265 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -168,31 +168,29 @@ do { \
#define get_user(x, ptr) \
({ \
int __ret_gu; \
- unsigned long __val_gu; \
- unsigned long long __val_gu8; \
+ struct { \
+ unsigned long long __val_n : 8*sizeof(*(ptr)); \
+ } __val_gu; \
__chk_user_ptr(ptr); \
might_fault(); \
switch (sizeof(*(ptr))) { \
case 1: \
- __get_user_x(1, __ret_gu, __val_gu, ptr); \
+ __get_user_x(1, __ret_gu, __val_gu.__val_n, ptr); \
break; \
case 2: \
- __get_user_x(2, __ret_gu, __val_gu, ptr); \
+ __get_user_x(2, __ret_gu, __val_gu.__val_n, ptr); \
break; \
case 4: \
- __get_user_x(4, __ret_gu, __val_gu, ptr); \
+ __get_user_x(4, __ret_gu, __val_gu.__val_n, ptr); \
break; \
case 8: \
- __get_user_8(__ret_gu, __val_gu8, ptr); \
+ __get_user_8(__ret_gu, __val_gu.__val_n, ptr); \
break; \
default: \
- __get_user_x(X, __ret_gu, __val_gu, ptr); \
+ __get_user_x(X, __ret_gu, __val_gu.__val_n, ptr); \
break; \
} \
- if (sizeof(*(ptr)) == 8) \
- (x) = (__typeof__(*(ptr)))__val_gu8; \
- else \
- (x) = (__typeof__(*(ptr)))__val_gu; \
+ (x) = (__typeof__(*(ptr)))__val_gu.__val_n; \
__ret_gu; \
})
next prev parent reply other threads:[~2013-02-12 4:22 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-12 11:34 [PATCH] x86: Add support for 64bit get_user() on x86-32 ville.syrjala
2012-12-12 16:15 ` H. Peter Anvin
2012-12-12 16:32 ` Ville Syrjälä
2012-12-12 16:45 ` H. Peter Anvin
2013-02-07 16:53 ` Ville Syrjälä
2013-02-07 17:59 ` H. Peter Anvin
2013-02-08 16:24 ` Ville Syrjälä
2013-02-08 17:30 ` H. Peter Anvin
2013-02-08 18:23 ` Ville Syrjälä
2013-02-08 19:08 ` H. Peter Anvin
2013-02-09 10:41 ` Borislav Petkov
2013-02-09 11:00 ` Russell King - ARM Linux
2013-02-12 1:37 ` [tip:x86/mm] x86, mm: Use a bitfield to mask nuisance get_user() warnings tip-bot for H. Peter Anvin
2013-02-12 3:33 ` Linus Torvalds
2013-02-12 4:21 ` H. Peter Anvin [this message]
2013-02-12 4:42 ` Linus Torvalds
2013-02-12 4:47 ` Linus Torvalds
2013-02-12 4:51 ` H. Peter Anvin
2013-02-12 7:12 ` H. Peter Anvin
2013-02-12 8:10 ` Ingo Molnar
2013-02-12 16:38 ` H.J. Lu
2013-02-12 17:00 ` Linus Torvalds
2013-02-12 17:14 ` H. Peter Anvin
2013-02-12 17:30 ` H.J. Lu
2013-02-12 18:25 ` H. Peter Anvin
2013-02-12 18:29 ` H.J. Lu
2013-02-12 18:46 ` Linus Torvalds
2013-02-12 18:58 ` H. Peter Anvin
2013-02-12 20:55 ` [tip:x86/mm] x86, mm: Redesign get_user with a __builtin_choose_expr hack tip-bot for H. Peter Anvin
2013-02-12 23:06 ` Linus Torvalds
2013-02-12 23:19 ` H. Peter Anvin
2013-02-12 23:49 ` Linus Torvalds
2013-02-12 23:52 ` H. Peter Anvin
2013-02-13 0:01 ` [tip:x86/mm] x86, doc: Clarify the use of asm("%edx") in uaccess.h tip-bot for H. Peter Anvin
2013-02-12 23:21 ` [tip:x86/mm] x86, mm: Redesign get_user with a __builtin_choose_expr hack Russell King - ARM Linux
2013-02-12 17:32 ` [tip:x86/mm] x86, mm: Use a bitfield to mask nuisance get_user() warnings Linus Torvalds
2013-02-12 17:35 ` H. Peter Anvin
2013-02-12 17:49 ` Linus Torvalds
2013-02-12 17:57 ` Russell King - ARM Linux
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=5119C34B.70207@zytor.com \
--to=hpa@zytor.com \
--cc=bp@alien8.de \
--cc=hjl.tools@gmail.com \
--cc=jamie@shareable.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=ville.syrjala@linux.intel.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).