Mailing List Archive

[Xen-merge] fs/gs handling
Any reason that fs/gs are specifically handled with mov not movl in
these cases?

#define deactivate_mm(tsk, mm) \
- asm("movl %0,%%fs ; movl %0,%%gs": :"r" (0))
+ asm("mov %0,%%fs ; mov %0,%%gs": :"r" (0))

or

+static inline void __prepare_arch_switch(void)
...
+ __asm__ __volatile__ ( "mov %%fs,%0 ; mov %%gs,%1"
+ : "=m" (*(int *)&current->thread.fs),
+ "=m" (*(int *)&current->thread.gs));
+ __asm__ __volatile__ ( "mov %0,%%fs ; mov %0,%%gs"
+ : : "r" (0) );



_______________________________________________
Xen-merge mailing list
Xen-merge@lists.xensource.com
http://lists.xensource.com/xen-merge
Re: [Xen-merge] fs/gs handling [ In reply to ]
Hi Chris,

On Thu, Aug 11, 2005 at 07:41:45PM -0700, Chris Wright wrote:
> Any reason that fs/gs are specifically handled with mov not movl in
> these cases?
>
> #define deactivate_mm(tsk, mm) \
> - asm("movl %0,%%fs ; movl %0,%%gs": :"r" (0))
> + asm("mov %0,%%fs ; mov %0,%%gs": :"r" (0))

mov works for both x86 and x86-64 ...
... though I don't know whether that's relevant here.

Best,
--
Kurt Garloff <kurt@garloff.de> [Koeln, DE]
Physics:Plasma modeling <garloff@plasimo.phys.tue.nl> [TU Eindhoven, NL]
Linux: SUSE Labs (Director) <garloff@suse.de> [Novell Inc]
Re: [Xen-merge] fs/gs handling [ In reply to ]
On Fri, Aug 12, 2005 at 05:11:49AM +0200, Kurt Garloff wrote:
> Hi Chris,
>
> On Thu, Aug 11, 2005 at 07:41:45PM -0700, Chris Wright wrote:
> > Any reason that fs/gs are specifically handled with mov not movl in
> > these cases?
> >
> > #define deactivate_mm(tsk, mm) \
> > - asm("movl %0,%%fs ; movl %0,%%gs": :"r" (0))
> > + asm("mov %0,%%fs ; mov %0,%%gs": :"r" (0))
>
> mov works for both x86 and x86-64 ...
> ... though I don't know whether that's relevant here.

It's not. Segment registers cannot be 64bit.

-Andi

_______________________________________________
Xen-merge mailing list
Xen-merge@lists.xensource.com
http://lists.xensource.com/xen-merge
Re: [Xen-merge] fs/gs handling [ In reply to ]
Hi Andi,

On Fri, Aug 12, 2005 at 11:26:27AM +0200, Andi Kleen wrote:
> On Fri, Aug 12, 2005 at 05:11:49AM +0200, Kurt Garloff wrote:
> > On Thu, Aug 11, 2005 at 07:41:45PM -0700, Chris Wright wrote:
> > > #define deactivate_mm(tsk, mm) \
> > > - asm("movl %0,%%fs ; movl %0,%%gs": :"r" (0))
> > > + asm("mov %0,%%fs ; mov %0,%%gs": :"r" (0))
> >
> > mov works for both x86 and x86-64 ...
> > ... though I don't know whether that's relevant here.
>
> It's not. Segment registers cannot be 64bit.

mov will work (the assembler knows the size of a segment register),
movl won't. movw would be correct. segment selectors are 16bit.

Best,
--
Kurt Garloff, Director SUSE Labs, Novell Inc.
Re: [Xen-merge] fs/gs handling [ In reply to ]
On Wednesday 24 August 2005 01:36, Kurt Garloff wrote:
> Hi Andi,
>
> On Fri, Aug 12, 2005 at 11:26:27AM +0200, Andi Kleen wrote:
> > On Fri, Aug 12, 2005 at 05:11:49AM +0200, Kurt Garloff wrote:
> > > On Thu, Aug 11, 2005 at 07:41:45PM -0700, Chris Wright wrote:
> > > > #define deactivate_mm(tsk, mm) \
> > > > - asm("movl %0,%%fs ; movl %0,%%gs": :"r" (0))
> > > > + asm("mov %0,%%fs ; mov %0,%%gs": :"r" (0))
> > >
> > > mov works for both x86 and x86-64 ...
> > > ... though I don't know whether that's relevant here.
> >
> > It's not. Segment registers cannot be 64bit.
>
> mov will work (the assembler knows the size of a segment register),
> movl won't. movw would be correct. segment selectors are 16bit.

Actually movl works too for segment registers.
movw is even discouraged because it generates a unnecessary 16bit prefix.

-Andi

_______________________________________________
Xen-merge mailing list
Xen-merge@lists.xensource.com
http://lists.xensource.com/xen-merge
Re: [Xen-merge] fs/gs handling [ In reply to ]
On Wed, Aug 24, 2005 at 03:29:02AM +0200, Andi Kleen wrote:
> Actually movl works too for segment registers.

... if the target is a 32bit register (or mem location).
--
Kurt Garloff, Director SUSE Labs, Novell Inc.