From: "H. J. Lu" <hjl@lucon.org>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Andi Kleen <ak@muc.de>, linux kernel <linux-kernel@vger.kernel.org>
Subject: Re: i386/x86_64 segment register issuses (Re: PATCH: Fix x86 segment register access)
Date: Tue, 29 Mar 2005 20:00:17 -0800 [thread overview]
Message-ID: <20050330040017.GA29523@lucon.org> (raw)
In-Reply-To: <Pine.LNX.4.58.0503291815570.6036@ppc970.osdl.org>
On Tue, Mar 29, 2005 at 06:44:18PM -0800, Linus Torvalds wrote:
>
>
> On Tue, 29 Mar 2005, H. J. Lu wrote:
> >
> > > the smaller and faster version do not want to just rely on gas
> > > automatically getting it right, especially since gas has historically been
> > > very very bad at getting things right.
> >
> > We are fixing those issues in assembler. If people run into problems
> > like that with gas, they can report them. They will be fixed.
>
> It's fine if gas fixes things. It's not fine if gas breaks things that
> used to work, for no really good reason.
>
> > > What is the advantage of not allowing "movl %ds,mem"? Really? Especially
> > > since I suspect the kernel is pretty much the only one who does this, and
> > > the kernel really does do it on purpose. The kernel explicitly wants the
> > > 32-bit version, knowing that the upper bits are undefined.
> > >
> >
> > Kernel has
> >
> > unsigned gsindex;
> > asm volatile("movl %%gs,%0" : "=g" (gsindex));
>
> Ok, that's a real x86-64 bug, it seems. Andi, please fix, preferably by
> just making the "g" be a "r".
>
> However, your argument isn't very valid, since:
>
> > The new assembler will make sure that it won't happen.
>
> Not true, since the suggestion was just to change all segment "movl"
> things to "mov", at which point the same old bug is still there, and the
> assembler didn't really help us at all.
The new assembler won't accept
movl %gs,128(%rsp)
It makes it harder to generate binary code user doesn't tend. FWIW,
what I suggested are in
http://sourceware.org/ml/binutils/2005-03/msg00873.html
Thera are things like
- asm volatile("movl %%fs,%0" : "=g" (fsindex));
+ asm volatile("movl %%fs,%0" : "=r" (fsindex));
>
> See the problem? You're not actually protecting anything. The change just
> makes it _harder_ to make sizes explicit, and suddenly we have to trust an
> assembler to be clever about sizes, when that assembler historically has
> definitely _not_ been very clever about them at all.
>
There is no such an instruction of "movl %ds,(%eax)". The old assembler
accepts it and turns it into "movw %ds,(%eax)". It won't catch problems
like
unsigned fsindex;
asm volatile("movl %%fs,%0" : "=m" (fsindex));
The "movw %ds,(%eax)" bug was fixed in binutils 2.15.94.0.1. Gas no
longer generates 0x66 for it. If you find gas preventing you from doing
what the hardware supports, I will be happy to fix it.
H.J.
next prev parent reply other threads:[~2005-03-30 4:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20050326020506.GA8068@lucon.org>
2005-03-27 22:24 ` H. J. Lu
2005-03-28 15:47 ` Andi Kleen
2005-03-28 17:46 ` H. J. Lu
2005-03-28 18:22 ` H. J. Lu
2005-03-30 0:30 ` Linus Torvalds
2005-03-30 1:53 ` H. J. Lu
2005-03-30 2:44 ` Linus Torvalds
2005-03-30 4:00 ` H. J. Lu [this message]
2005-03-30 15:57 ` Linus Torvalds
2005-03-30 16:23 ` linux-os
2005-03-30 21:11 ` H. J. Lu
2005-03-30 21:08 ` H. J. Lu
2005-03-30 22:18 ` Pau Aliagas
2005-03-31 0:34 ` H. J. Lu
2005-03-31 0:57 ` Pau Aliagas
2005-03-31 1:52 ` H. J. Lu
2005-03-31 10:19 ` Andi Kleen
2005-03-30 15:25 ` Andi Kleen
2005-03-29 19:17 ` PATCH: i386/x86_64 segment register access update H. J. Lu
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=20050330040017.GA29523@lucon.org \
--to=hjl@lucon.org \
--cc=ak@muc.de \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.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
Powered by JetHome