All of lore.kernel.org
 help / color / mirror / Atom feed
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 17:53:12 -0800	[thread overview]
Message-ID: <20050330015312.GA27309@lucon.org> (raw)
In-Reply-To: <Pine.LNX.4.58.0503291618520.6036@ppc970.osdl.org>

On Tue, Mar 29, 2005 at 04:30:01PM -0800, Linus Torvalds wrote:
> 
> 
> On Mon, 28 Mar 2005, Andi Kleen wrote:
> >
> > "H. J. Lu" <hjl@lucon.org> writes:
> > > The new assembler will disallow them since those instructions with
> > > memory operand will only use the first 16bits. If the memory operand
> > > is 16bit, you won't see any problems. But if the memory destinatin
> > > is 32bit, the upper 16bits may have random values. The new assembler
> > 
> > Does it really have random values on existing x86 hardware?
> 
> The upper bits are not written at all, so it's not random.
> 
> > If it is a only a "theoretical" problem that does not happen
> > in practice I would advise to not do the change.
> 
> My preference too. The reason we use "movl" is because we really do want 
> the 32-bit versions, since they are faster. It's a conscious choice. In 
> contrast "movw" generates bigger and slower code on all assemblers out 
> there, and "mov" doesn't make it clear which one it is. Is it the slow 
> one, or the fast one? 

"mov" shouldn't generate the 0x66 prefix, at least with the assembler
since binutils 2.14.90.0.4 20030523. The assembler in CVS won't generate
0x66 for "movw" either.

> Now, those versions of gas may be so old that nobody cares, but the
> explicit size still is a GOOD THING. The size DOES MATTER. People who want

Suggesting "mov" instead of "movw" is for the existing assemblers. Or
kernel can check assembler version to decide if "movw" should be used.
I can verify the first Linux assembler which won't generate 0x66 for
"movw".

> 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.

> 
> 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));
	...
	if (gsindex)
		

It is OK if gcc never generates memory access like

	movl %gs,0x128(%rsp)

Otherwise, the upper bits in gsindex are undefined. The new
assembler will make sure that it won't happen.


H.J.

  reply	other threads:[~2005-03-30  1:53 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 ` i386/x86_64 segment register issuses (Re: PATCH: Fix x86 segment register access) 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 [this message]
2005-03-30  2:44         ` Linus Torvalds
2005-03-30  4:00           ` H. J. Lu
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=20050330015312.GA27309@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.