From: David Laight <David.Laight@ACULAB.COM>
To: 'Linus Torvalds' <torvalds@linux-foundation.org>,
Peter Anvin <hpa@zytor.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
the arch/x86 maintainers <x86@kernel.org>,
"Sean Christopherson" <sean.j.christopherson@intel.com>,
Naresh Kamboju <naresh.kamboju@linaro.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] x86/uaccess: fix code generation in put_user()
Date: Fri, 23 Oct 2020 21:52:16 +0000 [thread overview]
Message-ID: <bca28d6e33a3475193478e762214c6ea@AcuMS.aculab.com> (raw)
In-Reply-To: <CAHk-=wg9L3EZk=cBjt5R3LkE8Y6swwOZ8sxhpQYcJO3Fj1wLbQ@mail.gmail.com>
From: Linus Torvalds
> Sent: 23 October 2020 22:11
>
> On Fri, Oct 23, 2020 at 2:00 PM <hpa@zytor.com> wrote:
> >
> > There is no same reason to mess around with hacks when we are talking about dx:ax, though.
>
> Sure there is.
>
> "A" doesn't actually mean %edx:%eax like you seem to think.
>
> It actually means %eax OR %edx, and then if given a 64-bit value, it
> will use the combination (with %edx being the high bits).
>
> So using "A" unconditionally doesn't work - it gives random behavior
> for 32-bit (or smaller) types.
>
> Or you'd have to cast the value to always be 64-bit, and have the
> extra code generation.
>
> IOW, an unconditional "A" is wrong.
>
> And the alternative is to just duplicate things, and go back to the
> explicit size testing, but honestly, I really think that's much worse
> than relying on a documented feature of "register asm()" that gcc
> _documents_ is for this kind of inline asm use.
Could do_put_user() do an initial check for 64 bit
then expand a different #define that contains the actual
code passing either "a" or "A" for the constriant.
Apart from another level of indirection nothing is duplicated.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2020-10-23 21:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-23 20:31 Rasmus Villemoes
2020-10-23 20:42 ` Andy Lutomirski
2020-10-23 20:52 ` Linus Torvalds
2020-10-23 20:54 ` hpa
2020-10-23 20:55 ` Linus Torvalds
2020-10-23 20:59 ` hpa
2020-10-23 21:11 ` Linus Torvalds
2020-10-23 21:52 ` David Laight [this message]
2020-10-23 23:39 ` hpa
2020-10-24 16:58 ` David Laight
2020-10-23 22:52 ` hpa
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=bca28d6e33a3475193478e762214c6ea@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mingo@redhat.com \
--cc=naresh.kamboju@linaro.org \
--cc=sean.j.christopherson@intel.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=x86@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
all inboxes | Powered by JetHome®