lkml.org 
[lkml]   [1998]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subjectlinux-2.0.34pre5 fixes
Date
Hello Alan,
There are many places in the kernel where 16 bit versions of
`mov reg,segreg' are used, that should really use the 32 bit version
for speed and code size reasons, because the latest version of gas
will (correctly) emit an operand size prefix for the 16 bit forms.
Here's a patch that changes as many as I could find. I'm using
`movl %ax,%ds' rather than the more strictly correct `movl %eax,%ds'
so that older versions of gas can still assemble the kernel. Also
included in this patch, I make sure that segment reg pushes and pops
use the explicit 32 bit version of the instruction.
The cyrix patch has also been cleaned up a little. Instructions
like `orb $1,%ax' should really be written as `orb $1,%al', as the b
suffix doesn't agree with the word register %ax. Newer versions of
gas will give warnings on such instructions.

Alan Modra


diff -urp linux-2.0.34pre5/arch/i386/boot/compressed/head.S linux/arch/i386/boot/compressed/head.S
--- linux-2.0.34pre5/arch/i386/boot/compressed/head.S Sat Mar 9 22:01:42 1996
+++ linux/arch/i386/boot/compressed/head.S Wed Apr 1 09:31:12 1998
@@ -38,10 +38,10 @@ startup_32:
cld
cli
movl $(KERNEL_DS),%eax
- mov %ax,%ds
- mov %ax,%es
- mov %ax,%fs
- mov %ax,%gs
+ movl %ax,%ds
+ movl %ax,%es
+ movl %ax,%fs
+ movl %ax,%gs
#ifdef __SMP__
orw %bx,%bx # What state are we in BX=1 for SMP
# 0 for boot
@@ -50,7 +50,7 @@ startup_32:
/*
* We are trampolining an SMP processor
*/
- mov %ax,%ss
+ movl %ax,%ss
xorl %eax,%eax # Back to 0
mov %cx,%ax # SP low 16 bits
movl %eax,%esp
diff -urp linux-2.0.34pre5/arch/i386/kernel/entry.S linux/arch/i386/kernel/entry.S
--- linux-2.0.34pre5/arch/i386/kernel/entry.S Sat Oct 18 17:11:34 1997
+++ linux/arch/i386/kernel/entry.S Wed Apr 1 09:26:27 1998
@@ -86,10 +86,10 @@ ENOSYS = 38

#define SAVE_ALL \
cld; \
- push %gs; \
- push %fs; \
- push %es; \
- push %ds; \
+ pushl %gs; \
+ pushl %fs; \
+ pushl %es; \
+ pushl %ds; \
pushl %eax; \
pushl %ebp; \
pushl %edi; \
@@ -98,10 +98,10 @@ ENOSYS = 38
pushl %ecx; \
pushl %ebx; \
movl $(KERNEL_DS),%edx; \
- mov %dx,%ds; \
- mov %dx,%es; \
+ movl %dx,%ds; \
+ movl %dx,%es; \
movl $(USER_DS),%edx; \
- mov %dx,%fs;
+ movl %dx,%fs;

#ifdef __SMP__

@@ -228,10 +228,10 @@ ENOSYS = 38
popl %edi; \
popl %ebp; \
popl %eax; \
- pop %ds; \
- pop %es; \
- pop %fs; \
- pop %gs; \
+ popl %ds; \
+ popl %es; \
+ popl %fs; \
+ popl %gs; \
addl $4,%esp; \
iret

@@ -251,10 +251,10 @@ ENOSYS = 38
popl %edi; \
popl %ebp; \
popl %eax; \
- pop %ds; \
- pop %es; \
- pop %fs; \
- pop %gs; \
+ popl %ds; \
+ popl %es; \
+ popl %fs; \
+ popl %gs; \
addl $4,%esp; \
iret
#endif
@@ -400,9 +400,9 @@ ENTRY(divide_error)
pushl $ SYMBOL_NAME(do_divide_error)
ALIGN
error_code:
- push %fs
- push %es
- push %ds
+ pushl %fs
+ pushl %es
+ pushl %ds
pushl %eax
xorl %eax,%eax
pushl %ebp
@@ -421,10 +421,10 @@ error_code:
pushl %eax # push the error code
pushl %edx
movl $(KERNEL_DS),%edx
- mov %dx,%ds
- mov %dx,%es
+ movl %dx,%ds
+ movl %dx,%es
movl $(USER_DS),%edx
- mov %dx,%fs
+ movl %dx,%fs
#ifdef __SMP__
ENTER_KERNEL
GET_PROCESSOR_OFFSET(%eax)
diff -urp linux-2.0.34pre5/arch/i386/kernel/head.S linux/arch/i386/kernel/head.S
--- linux-2.0.34pre5/arch/i386/kernel/head.S Wed Apr 1 05:31:59 1998
+++ linux/arch/i386/kernel/head.S Wed Apr 1 10:44:09 1998
@@ -28,17 +28,17 @@ ENTRY(_stext)
startup_32:
cld
movl $(KERNEL_DS),%eax
- mov %ax,%ds
- mov %ax,%es
- mov %ax,%fs
- mov %ax,%gs
+ movl %ax,%ds
+ movl %ax,%es
+ movl %ax,%fs
+ movl %ax,%gs
#ifdef __SMP__
orw %bx,%bx
jz 1f /* Initial CPU cleans BSS */
/*
* Set up the stack
*/
- mov %ax,%ss
+ movl %ax,%ss
xorl %eax,%eax
movw %cx, %ax
movl %eax,%esp
@@ -138,15 +138,15 @@ checkCPUtype:
* do all this with interrupts off.
*/
#define setCx86(reg, val) \
- movb reg,%ax; \
- outb %ax,$0x22; \
- movb val,%ax; \
- outb %ax,$0x23
+ movb reg,%al; \
+ outb %al,$0x22; \
+ movb val,%al; \
+ outb %al,$0x23

#define getCx86(reg) \
- movb reg,%ax; \
- outb %ax,$0x22; \
- inb $0x23,%ax
+ movb reg,%al; \
+ outb %al,$0x22; \
+ inb $0x23,%al

/*
* Cyrix screwed this up. You have to do the basic cyrix
@@ -165,27 +165,27 @@ checkCPUtype:

cli
getCx86($0xc3) # get CCR3
- movb %ax,%cx # Save old value
- movb %ax,%bx
- andb $0x0f,%bx # Enable access to all config registers
- orb $0x10,%bx # by setting bit 4
- setCx86($0xc3,%bx)
+ movb %al,%cl # Save old value
+ movb %al,%bl
+ andb $0x0f,%bl # Enable access to all config registers
+ orb $0x10,%bl # by setting bit 4
+ setCx86($0xc3,%bl)

getCx86($0xe8) # now we can get CCR4
- orb $0x80,%ax # and set bit 7 (CPUIDEN)
- movb %ax,%bx # to enable CPUID execution
- setCx86($0xe8,%bx)
+ orb $0x80,%al # and set bit 7 (CPUIDEN)
+ movb %al,%bl # to enable CPUID execution
+ setCx86($0xe8,%bl)

getCx86($0xfe) # DIR0 : let's check this is a 6x86(L)
- andb $0xf0,%ax # should be 3xh
- cmpb $0x30,%ax #
+ andb $0xf0,%al # should be 3xh
+ cmpb $0x30,%al #
jne n6x86
getCx86($0xe9) # CCR5 : we reset the SLOP bit
- andb $0xfd,%ax # so that udelay calculation
- movb %ax,%bx # is correct on 6x86(L) CPUs
- setCx86($0xe9,%bx)
+ andb $0xfd,%al # so that udelay calculation
+ movb %al,%bl # is correct on 6x86(L) CPUs
+ setCx86($0xe9,%bl)

-n6x86: setCx86($0xc3,%cx) # Restore old CCR3
+n6x86: setCx86($0xc3,%cl) # Restore old CCR3
sti

ncyrix: movl $3, SYMBOL_NAME(x86)
@@ -218,11 +218,15 @@ isnew: pushl %ecx # restore original EF
*/
/* get processor type */
movl $1, %eax # Use the CPUID instruction to
+#ifdef GAS_KNOWS_CPUID
+ cpuid # check the processor type
+#else
.byte 0x0f, 0xa2 # check the processor type
+#endif
movb %al, %cl # save reg for future use
andb $0x0f,%ah # mask processor family
movb %ah,SYMBOL_NAME(x86)
- andb $0xf0, %eax # mask model
+ andb $0xf0, %al # mask model
shrb $4, %al
movb %al,SYMBOL_NAME(x86_model)
andb $0x0f, %cl # mask mask revision
@@ -234,10 +238,10 @@ isnew: pushl %ecx # restore original EF
* This trips some PPro/PII's and overwrites the mask
* with crap. Removed until the Linux/Cyrix guys fix it.
*/
- xor %ax,%ax # test again for Cyrix CPU
+ xorl %eax,%eax # test again for Cyrix CPU
sahf
- movb $5,%ax
- movb $2,%bx
+ movb $5,%al
+ movb $2,%bl
div %bl
lahf
cmpb $2,%ah
@@ -247,7 +251,11 @@ isnew: pushl %ecx # restore original EF
#endif
/* get vendor info */
ncyrx2: xorl %eax, %eax # call CPUID with 0 -> return vendor ID
+#ifdef GAS_KNOWS_CPUID
+ cpuid
+#else
.byte 0x0f, 0xa2 # CPUID
+#endif
movl %ebx,SYMBOL_NAME(x86_vendor_id) # lo 4 chars
movl %edx,SYMBOL_NAME(x86_vendor_id)+4 # next 4 chars
movl %ecx,SYMBOL_NAME(x86_vendor_id)+8 # last 4 chars
@@ -270,8 +278,8 @@ is386: pushl %ecx # restore original EF
2: movl %eax,%cr0
call check_x87
#ifdef __SMP__
- movb ready,%eax
- orb %eax,%eax
+ movb ready,%al
+ orb %al,%al
jz 3f
movl $ SYMBOL_NAME(swapper_pg_dir), %eax
movl %eax, %cr3
@@ -299,13 +307,13 @@ is386: pushl %ecx # restore original EF
lidt idt_descr
ljmp $(KERNEL_CS),$1f
1: movl $(KERNEL_DS),%eax # reload all the segment registers
- mov %ax,%ds # after changing gdt.
- mov %ax,%es
- mov %ax,%fs
- mov %ax,%gs
+ movl %ax,%ds # after changing gdt.
+ movl %ax,%es
+ movl %ax,%fs
+ movl %ax,%gs
#ifdef __SMP__
movl $(KERNEL_DS), %eax
- mov %ax,%ss # Reload the stack pointer (segment only)
+ movl %ax,%ss # Reload the stack pointer (segment only)
#else
lss stack_start,%esp # Load processor stack
#endif
@@ -455,19 +463,19 @@ ignore_int:
pushl %eax
pushl %ecx
pushl %edx
- push %ds
- push %es
- push %fs
+ pushl %ds
+ pushl %es
+ pushl %fs
movl $(KERNEL_DS),%eax
- mov %ax,%ds
- mov %ax,%es
- mov %ax,%fs
+ movl %ax,%ds
+ movl %ax,%es
+ movl %ax,%fs
pushl $int_msg
call SYMBOL_NAME(printk)
popl %eax
- pop %fs
- pop %es
- pop %ds
+ popl %fs
+ popl %es
+ popl %ds
popl %edx
popl %ecx
popl %eax
diff -urp linux-2.0.34pre5/arch/i386/kernel/process.c linux/arch/i386/kernel/process.c
--- linux-2.0.34pre5/arch/i386/kernel/process.c Thu Mar 26 07:48:03 1998
+++ linux/arch/i386/kernel/process.c Wed Apr 1 09:19:28 1998
@@ -363,12 +363,12 @@ void hard_reset_now (void)
registers don't have to be reloaded after switching to real mode:
the values are consistent for real mode operation already. */

- __asm__ __volatile__ ("movw $0x0010,%%ax\n"
- "\tmovw %%ax,%%ds\n"
- "\tmovw %%ax,%%es\n"
- "\tmovw %%ax,%%fs\n"
- "\tmovw %%ax,%%gs\n"
- "\tmovw %%ax,%%ss" : : : "eax");
+ __asm__ __volatile__ ("movl $0x0010,%%ax\n"
+ "\tmovl %%ax,%%ds\n"
+ "\tmovl %%ax,%%es\n"
+ "\tmovl %%ax,%%fs\n"
+ "\tmovl %%ax,%%gs\n"
+ "\tmovl %%ax,%%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
@@ -405,7 +405,7 @@ void exit_thread(void)
if (last_task_used_math == current)
last_task_used_math = NULL;
/* forget local segments */
- __asm__ __volatile__("mov %w0,%%fs ; mov %w0,%%gs ; lldt %w0"
+ __asm__ __volatile__("movl %w0,%%fs ; movl %w0,%%gs ; lldt %w0"
: /* no outputs */
: "r" (0));
current->tss.ldt = 0;
diff -urp linux-2.0.34pre5/arch/i386/kernel/traps.c linux/arch/i386/kernel/traps.c
--- linux-2.0.34pre5/arch/i386/kernel/traps.c Wed Dec 17 21:58:30 1997
+++ linux/arch/i386/kernel/traps.c Wed Apr 1 09:20:38 1998
@@ -61,19 +61,19 @@ asmlinkage void do_##name(struct pt_regs

#define get_seg_byte(seg,addr) ({ \
register unsigned char __res; \
-__asm__("push %%fs;mov %%ax,%%fs;movb %%fs:%2,%%al;pop %%fs" \
+__asm__("pushl %%fs;movl %%ax,%%fs;movb %%fs:%2,%%al;popl %%fs" \
:"=a" (__res):"0" (seg),"m" (*(addr))); \
__res;})

#define get_seg_long(seg,addr) ({ \
register unsigned long __res; \
-__asm__("push %%fs;mov %%ax,%%fs;movl %%fs:%2,%%eax;pop %%fs" \
+__asm__("pushl %%fs;movl %%ax,%%fs;movl %%fs:%2,%%eax;popl %%fs" \
:"=a" (__res):"0" (seg),"m" (*(addr))); \
__res;})

#define _fs() ({ \
register unsigned short __res; \
-__asm__("mov %%fs,%%ax":"=a" (__res):); \
+__asm__("movl %%fs,%%ax":"=a" (__res):); \
__res;})

void page_exception(void);
diff -urp linux-2.0.34pre5/drivers/char/apm_bios.c linux/drivers/char/apm_bios.c
--- linux-2.0.34pre5/drivers/char/apm_bios.c Thu Mar 26 08:28:00 1998
+++ linux/drivers/char/apm_bios.c Wed Apr 1 09:53:41 1998
@@ -212,10 +212,10 @@ extern unsigned long get_cmos_time(void)
"pushl %%fs\n\t" \
"pushl %%gs\n\t" \
"xorl %%edx, %%edx\n\t" \
- "mov %%dx, %%ds\n\t" \
- "mov %%dx, %%es\n\t" \
- "mov %%dx, %%fs\n\t" \
- "mov %%dx, %%gs\n\t"
+ "movl %%dx, %%ds\n\t" \
+ "movl %%dx, %%es\n\t" \
+ "movl %%dx, %%fs\n\t" \
+ "movl %%dx, %%gs\n\t"
# define APM_DO_RESTORE_SEGS \
"popl %%gs\n\t" \
"popl %%fs\n\t" \
diff -urp linux-2.0.34pre5/include/asm-i386/irq.h linux/include/asm-i386/irq.h
--- linux-2.0.34pre5/include/asm-i386/irq.h Sat Oct 18 17:11:49 1997
+++ linux/include/asm-i386/irq.h Wed Apr 1 09:55:10 1998
@@ -24,10 +24,10 @@ extern void enable_irq(unsigned int);

#define SAVE_ALL \
"cld\n\t" \
- "push %gs\n\t" \
- "push %fs\n\t" \
- "push %es\n\t" \
- "push %ds\n\t" \
+ "pushl %gs\n\t" \
+ "pushl %fs\n\t" \
+ "pushl %es\n\t" \
+ "pushl %ds\n\t" \
"pushl %eax\n\t" \
"pushl %ebp\n\t" \
"pushl %edi\n\t" \
@@ -36,10 +36,10 @@ extern void enable_irq(unsigned int);
"pushl %ecx\n\t" \
"pushl %ebx\n\t" \
"movl $" STR(KERNEL_DS) ",%edx\n\t" \
- "mov %dx,%ds\n\t" \
- "mov %dx,%es\n\t" \
+ "movl %dx,%ds\n\t" \
+ "movl %dx,%es\n\t" \
"movl $" STR(USER_DS) ",%edx\n\t" \
- "mov %dx,%fs\n\t" \
+ "movl %dx,%fs\n\t" \
"movl $0,%edx\n\t" \
"movl %edx,%db7\n\t"

@@ -59,21 +59,21 @@ extern void enable_irq(unsigned int);
*/
#define SAVE_MOST \
"cld\n\t" \
- "push %es\n\t" \
- "push %ds\n\t" \
+ "pushl %es\n\t" \
+ "pushl %ds\n\t" \
"pushl %eax\n\t" \
"pushl %edx\n\t" \
"pushl %ecx\n\t" \
"movl $" STR(KERNEL_DS) ",%edx\n\t" \
- "mov %dx,%ds\n\t" \
- "mov %dx,%es\n\t"
+ "movl %dx,%ds\n\t" \
+ "movl %dx,%es\n\t"

#define RESTORE_MOST \
"popl %ecx\n\t" \
"popl %edx\n\t" \
"popl %eax\n\t" \
- "pop %ds\n\t" \
- "pop %es\n\t" \
+ "popl %ds\n\t" \
+ "popl %es\n\t" \
"iret"

/*
diff -urp linux-2.0.34pre5/include/asm-i386/segment.h linux/include/asm-i386/segment.h
--- linux-2.0.34pre5/include/asm-i386/segment.h Thu Apr 11 22:28:33 1996
+++ linux/include/asm-i386/segment.h Wed Apr 1 09:13:13 1998
@@ -84,10 +84,10 @@ static inline void __generic_memcpy_tofs
{
__asm__ volatile
(" cld
- push %%es
- push %%fs
+ pushl %%es
+ pushl %%fs
cmpl $3,%0
- pop %%es
+ popl %%es
jbe 1f
movl %%edi,%%ecx
negl %%ecx
@@ -100,7 +100,7 @@ static inline void __generic_memcpy_tofs
andl $3,%0
1: movl %0,%%ecx
rep; movsb
- pop %%es"
+ popl %%es"
:"=abd" (n)
:"0" (n),"D" ((long) to),"S" ((long) from)
:"cx","di","si");
@@ -142,12 +142,12 @@ static inline void __constant_memcpy_tof
}
#define COMMON(x) \
__asm__("cld\n\t" \
- "push %%es\n\t" \
- "push %%fs\n\t" \
- "pop %%es\n\t" \
+ "pushl %%es\n\t" \
+ "pushl %%fs\n\t" \
+ "popl %%es\n\t" \
"rep ; movsl\n\t" \
x \
- "pop %%es" \
+ "popl %%es" \
: /* no outputs */ \
:"c" (n/4),"D" ((long) to),"S" ((long) from) \
:"cx","di","si")
@@ -318,20 +318,20 @@ static inline void put_user_long(unsigne
static inline unsigned long get_fs(void)
{
unsigned long _v;
- __asm__("mov %%fs,%w0":"=r" (_v):"0" (0));
+ __asm__("movl %%fs,%w0":"=r" (_v):"0" (0));
return _v;
}

static inline unsigned long get_ds(void)
{
unsigned long _v;
- __asm__("mov %%ds,%w0":"=r" (_v):"0" (0));
+ __asm__("movl %%ds,%w0":"=r" (_v):"0" (0));
return _v;
}

static inline void set_fs(unsigned long val)
{
- __asm__ __volatile__("mov %w0,%%fs": /* no output */ :"r" (val));
+ __asm__ __volatile__("movl %w0,%%fs": /* no output */ :"r" (val));
}

#endif /* __ASSEMBLY__ */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:42    [W:0.030 / U:2.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site