Linux-kernel mailing list archive 1999-32,: linux-2.2.11-pre7: i386 asm cleanup

# linux-2.2.11-pre7: i386 asm cleanup

Horst von Brand (vonbrand@sleipnir.valparaiso.cl)
Mon, 09 Aug 1999 00:01:31 -0400

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Alan Curry: "Re: info format (was Re: Linux 2.2.11pre4)"
- Previous message: Peter Waltenberg: "Re: SMP Scheduling"
- Next in thread: Alan Cox: "Re: linux-2.2.11-pre7: i386 asm cleanup"
- Reply: Alan Cox: "Re: linux-2.2.11-pre7: i386 asm cleanup"
- Reply: Horst von Brand: "Re: linux-2.2.11-pre7: i386 asm cleanup"

I've got a i586 UP, gcc-2.95, binutils-2.9.5.0.5. The following patch
cleans up the assembler warnings I've encountered. The resulting kernel is
what I'm running right now, booted from lilo.

- The compiler uses %kX to refer to the 32-bit version of argument X to an
asm(). Several places say "movl %w0,...", which means "move the 32 bit
long from the 16-bit version of the register argument", this makes no
sense. Either use "movw %w0,..." to move the lower half or use the full
register, "movl %k0,...". This is what I do below. Looks somewhat fishy
to me anyway, if gcc just fills in the lower half and we use the full
register, we get a random upper half... perhaps the best course of action
would be just to omit the [wl] here? Or force a 32-bit register in the
constraints?

- AFAIU, there is no point in using just the lower half of a register to
fill in a segment register, with a movl to boot.

In all cases the assembler warnings imply that the full register is being
used regardless, because of the "l" suffix to the instruction, so this
should be safe.

--- linux/include/asm-i386/processor.h.dist-2.2.11-pre7 Tue Jul 20 22:28:52 1999
+++ linux/include/asm-i386/processor.h Sun Aug 8 21:55:11 1999
@@ -268,7 +268,7 @@
}
#define start_thread(regs, new_eip, new_esp) do { \
- __asm__("movl %w0,%%fs ; movl %w0,%%gs": :"r" (0)); \
+ __asm__("movl %k0,%%fs ; movl %k0,%%gs": :"r" (0)); \
set_fs(USER_DS); \
regs->xds = __USER_DS; \
regs->xes = __USER_DS; \
--- linux/arch/i386/boot/compressed/head.S.dist-2.2.11-pre7 Sun Mar 29 15:31:16 1998
+++ linux/arch/i386/boot/compressed/head.S Sun Aug 8 22:48:05 1999
@@ -37,10 +37,10 @@
cld
cli
movl $(__KERNEL_DS),%eax
- movl %ax,%ds
- movl %ax,%es
- movl %ax,%fs
- movl %ax,%gs
+ movl %eax,%ds
+ movl %eax,%es
+ movl %eax,%fs
+ movl %eax,%gs
#ifdef __SMP__
orw %bx,%bx # What state are we in BX=1 for SMP
# 0 for boot
--- linux/arch/i386/kernel/head.S.dist-2.2.11-pre7 Fri Jan 15 03:57:25 1999
+++ linux/arch/i386/kernel/head.S Sun Aug 8 22:42:43 1999
@@ -45,10 +45,10 @@
*/
cld
movl $(__KERNEL_DS),%eax
- movl %ax,%ds
- movl %ax,%es
- movl %ax,%fs
- movl %ax,%gs
+ movl %eax,%ds
+ movl %eax,%es
+ movl %eax,%fs
+ movl %eax,%gs
#ifdef __SMP__
orw %bx,%bx
jz 1f
@@ -229,10 +229,10 @@
lidt idt_descr
ljmp $(__KERNEL_CS),$1f
1: movl $(__KERNEL_DS),%eax # reload all the segment registers
- movl %ax,%ds # after changing gdt.
- movl %ax,%es
- movl %ax,%fs
- movl %ax,%gs
+ movl %eax,%ds # after changing gdt.
+ movl %eax,%es
+ movl %eax,%fs
+ movl %eax,%gs
#ifdef __SMP__
movl $(__KERNEL_DS), %eax
mov %ax,%ss # Reload the stack pointer (segment only)
@@ -312,8 +312,8 @@
pushl %es
pushl %ds
movl $(__KERNEL_DS),%eax
- movl %ax,%ds
- movl %ax,%es
+ movl %eax,%ds
+ movl %eax,%es
pushl $int_msg
call SYMBOL_NAME(printk)
popl %eax
--- linux/arch/i386/kernel/signal.c.dist-2.2.11-pre7 Sun Jul 11 10:33:14 1999
+++ linux/arch/i386/kernel/signal.c Sun Aug 8 22:07:18 1999
@@ -339,9 +339,9 @@
int tmp, err = 0;
tmp = 0;
- __asm__("movl %%gs,%w0" : "=r"(tmp): "0"(tmp));
+ __asm__("movl %%gs,%k0" : "=r"(tmp): "0"(tmp));
err |= __put_user(tmp, (unsigned int *)&sc->gs);
- __asm__("movl %%fs,%w0" : "=r"(tmp): "0"(tmp));
+ __asm__("movl %%fs,%k0" : "=r"(tmp): "0"(tmp));
err |= __put_user(tmp, (unsigned int *)&sc->fs);
err |= __put_user(regs->xes, (unsigned int *)&sc->es);
--- linux/arch/i386/kernel/entry.S.dist-2.2.11-pre7 Fri Apr 30 11:13:37 1999
+++ linux/arch/i386/kernel/entry.S Sun Aug 8 22:16:26 1999
@@ -92,8 +92,8 @@
pushl %ecx; \
pushl %ebx; \
movl $(__KERNEL_DS),%edx; \
- movl %dx,%ds; \
- movl %dx,%es;
+ movl %edx,%ds; \
+ movl %edx,%es;
#define RESTORE_ALL \
popl %ebx; \
@@ -264,15 +264,15 @@
pushl %ecx
pushl %ebx
cld
- movl %es,%cx
+ movl %es,%ecx
xchgl %eax, ORIG_EAX(%esp) # orig_eax (get the error code. )
movl %esp,%edx
xchgl %ecx, ES(%esp) # get the address and save es.
pushl %eax # push the error code
pushl %edx
movl $(__KERNEL_DS),%edx
- movl %dx,%ds
- movl %dx,%es
+ movl %edx,%ds
+ movl %edx,%es
GET_CURRENT(%ebx)
call *%ecx
addl $8,%esp
--- linux/arch/i386/kernel/process.c.dist-2.2.11-pre7 Tue Jul 20 22:20:25 1999
+++ linux/arch/i386/kernel/process.c Sun Aug 8 22:03:36 1999
@@ -365,11 +365,11 @@
the values are consistent for real mode operation already. */
__asm__ __volatile__ ("movl $0x0010,%%eax\n"
- "\tmovl %%ax,%%ds\n"
- "\tmovl %%ax,%%es\n"
- "\tmovl %%ax,%%fs\n"
- "\tmovl %%ax,%%gs\n"
- "\tmovl %%ax,%%ss" : : : "eax");
+ "\tmovl %%eax,%%ds\n"
+ "\tmovl %%eax,%%es\n"
+ "\tmovl %%eax,%%fs\n"
+ "\tmovl %%eax,%%gs\n"
+ "\tmovl %%eax,%%ss" : : : "eax");
/* Jump to the 16-bit code that we copied earlier. It disables paging
and the cache, switches to real mode, and jumps to the BIOS reset
@@ -489,7 +489,7 @@
void forget_segments(void)
{
/* forget local segments */
- __asm__ __volatile__("movl %w0,%%fs ; movl %w0,%%gs"
+ __asm__ __volatile__("movl %k0,%%fs ; movl %k0,%%gs"
: /* no outputs */
: "r" (0));
--- linux/arch/i386/kernel/traps.c.dist-2.2.11-pre7 Tue Feb 16 19:20:05 1999
+++ linux/arch/i386/kernel/traps.c Sun Aug 8 22:23:33 1999
@@ -558,7 +558,7 @@
((limit) & 0x0ffff); }
#define _set_tssldt_desc(n,addr,limit,type) \
-__asm__ __volatile__ ("movw %3,0(%2)\n\t" \
+__asm__ __volatile__ ("movw %w3,0(%2)\n\t" \
"movw %%ax,2(%2)\n\t" \
"rorl $16,%%eax\n\t" \
"movb %%al,4(%2)\n\t" \
--- linux/arch/i386/kernel/irq.h.dist-2.2.11-pre7 Tue Jul 20 22:50:31 1999
+++ linux/arch/i386/kernel/irq.h Sun Aug 8 22:30:40 1999
@@ -169,8 +169,8 @@
"pushl %ecx\n\t" \
"pushl %ebx\n\t" \
"movl $" STR(__KERNEL_DS) ",%edx\n\t" \
- "movl %dx,%ds\n\t" \
- "movl %dx,%es\n\t"
+ "movl %edx,%ds\n\t" \
+ "movl %edx,%es\n\t"
#define IRQ_NAME2(nr) nr##_interrupt(void)
#define IRQ_NAME(nr) IRQ_NAME2(IRQ##nr)
--- linux/arch/i386/kernel/vm86.c.dist-2.2.11-pre7 Tue Dec 1 16:28:24 1998
+++ linux/arch/i386/kernel/vm86.c Sun Aug 8 22:37:38 1999
@@ -256,7 +256,7 @@
mark_screen_rdonly(tsk);
unlock_kernel();
__asm__ __volatile__(
- "xorl %%eax,%%eax; movl %%ax,%%fs; movl %%ax,%%gs\n\t"
+ "xorl %%eax,%%eax; movl %%eax,%%fs; movl %%eax,%%gs\n\t"
"movl %0,%%esp\n\t"
"jmp ret_from_sys_call"
: /* no outputs */

    --
    Horst von Brand                             vonbrand@sleipnir.valparaiso.cl
    Casilla 9G, Viņa del Mar, Chile                               +56 32 672616

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu
    Please read the FAQ at http://www.tux.org/lkml/

- Next message: Alan Curry: "Re: info format (was Re: Linux 2.2.11pre4)"
- Previous message: Peter Waltenberg: "Re: SMP Scheduling"
- Next in thread: Alan Cox: "Re: linux-2.2.11-pre7: i386 asm cleanup"
- Reply: Alan Cox: "Re: linux-2.2.11-pre7: i386 asm cleanup"
- Reply: Horst von Brand: "Re: linux-2.2.11-pre7: i386 asm cleanup"