Skip to contentSkip to conversation

copy_from_user broken on i386 since 2.5.57

DISCUSSION Brice Goglin 5 participants 5 messages Jan 22, 2003 – Jan 24, 2003 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi,

Trying to compile a very very simple module for 2.5, I got an error from gcc saying that assembly code is incorrect.
This problem appeared in 2.5.57 and is still here in 2.5.59.
I only tried on i386.

Here's a very simple example code :

#define __KERNEL__
#define MODULE
#include "linux/module.h"
#include "asm/uaccess.h"

int func(void *to, const void *from) {
return __copy_from_user(to, from, 1);
}

Here's gcc report :

mp760:~/tmp% gcc user.c -c -o user.o -Ipath_to_2.5.57/include /tmp/cceAbcRd.s: Assembler messages:
/tmp/cceAbcRd.s:120: Error: %al' not allowed with movl' /tmp/cceAbcRd.s:124: Error: %al' not allowed with xorl' /tmp/cceAbcRd.s:209: Warning: using %eax' instead of %ax' due to l' suffix /tmp/cceAbcRd.s:213: Warning: using %eax' instead of %ax' due to l' suffix /tmp/cceAbcRd.s:213: Warning: using %eax' instead of %ax' due to `l' suffix

Regards

Brice Goglin
============
Ph.D Student
Laboratoire de l'Informatique et du Parallélisme
ENS Lyon
France

#1 lore raw
Quoted 24 lines · Brice Goglin

Hi,

Trying to compile a very very simple module for 2.5, I got an error from gcc saying that assembly code is incorrect.
This problem appeared in 2.5.57 and is still here in 2.5.59.
I only tried on i386.

Here's a very simple example code :

#define __KERNEL__
#define MODULE
#include "linux/module.h"
#include "asm/uaccess.h"

int func(void *to, const void *from) {
return __copy_from_user(to, from, 1);
}

Here's gcc report :

Quoted 7 lines

mp760:~/tmp% gcc user.c -c -o user.o -Ipath_to_2.5.57/include /tmp/cceAbcRd.s: Assembler messages:
/tmp/cceAbcRd.s:120: Error: %al' not allowed with movl' /tmp/cceAbcRd.s:124: Error: %al' not allowed with xorl' /tmp/cceAbcRd.s:209: Warning: using %eax' instead of %ax' due to l' suffix /tmp/cceAbcRd.s:213: Warning: using %eax' instead of %ax' due to l' suffix /tmp/cceAbcRd.s:213: Warning: using %eax' instead of %ax' due to `l' suffix

Add `-O2' to the compiler switches.

No, I don't know either ;)

#2 lore raw
Quoted 33 lines · Andrew Morton
Quoted 24 lines · Brice Goglin

Hi,

Trying to compile a very very simple module for 2.5, I got an error from gcc saying that assembly code is incorrect.
This problem appeared in 2.5.57 and is still here in 2.5.59.
I only tried on i386.

Here's a very simple example code :

#define __KERNEL__
#define MODULE
#include "linux/module.h"
#include "asm/uaccess.h"

int func(void *to, const void *from) {
return __copy_from_user(to, from, 1);
}

Here's gcc report :

Quoted 7 lines

mp760:~/tmp% gcc user.c -c -o user.o -Ipath_to_2.5.57/include /tmp/cceAbcRd.s: Assembler messages:
/tmp/cceAbcRd.s:120: Error: %al' not allowed with movl' /tmp/cceAbcRd.s:124: Error: %al' not allowed with xorl' /tmp/cceAbcRd.s:209: Warning: using %eax' instead of %ax' due to l' suffix /tmp/cceAbcRd.s:213: Warning: using %eax' instead of %ax' due to l' suffix /tmp/cceAbcRd.s:213: Warning: using %eax' instead of %ax' due to `l' suffix

Quoted 3 lines

Add `-O2' to the compiler switches.

No, I don't know either ;)

So, does this actually fix the problem or simply optimize the suspect code out of existance until some later date?

Signature · 3 lines
bill davidsen <[email protected]>
  CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.

A message that is not in the archive (sent off-list or not yet received): [email protected] m

#4 lore raw
Quoted 36 lines · Bill Davidsen
Quoted 23 lines · Andrew Morton
Quoted 22 lines · Brice Goglin

Hi,

Trying to compile a very very simple module for 2.5, I got an error from gcc saying that assembly code is incorrect.
This problem appeared in 2.5.57 and is still here in 2.5.59.
I only tried on i386.

Here's a very simple example code :

#define __KERNEL__
#define MODULE
#include "linux/module.h"
#include "asm/uaccess.h"

int func(void *to, const void *from) {
return __copy_from_user(to, from, 1);
}

Quoted 7 lines
Quoted 7 lines

Here's gcc report :

mp760:~/tmp% gcc user.c -c -o user.o -Ipath_to_2.5.57/include /tmp/cceAbcRd.s: Assembler messages:
/tmp/cceAbcRd.s:120: Error: %al' not allowed with movl' /tmp/cceAbcRd.s:124: Error: %al' not allowed with xorl' /tmp/cceAbcRd.s:209: Warning: using %eax' instead of %ax' due to

`l' suffix

Quoted 1 line
Quoted 1 line

/tmp/cceAbcRd.s:213: Warning: using %eax' instead of %ax' due to

`l' suffix

Quoted 1 line
Quoted 1 line

/tmp/cceAbcRd.s:213: Warning: using %eax' instead of %ax' due to

Quoted 8 lines

`l' suffix

Quoted 4 lines

Add `-O2' to the compiler switches.

No, I don't know either ;)

So, does this actually fix the problem or simply optimize the suspect code out of existance until some later date?

Compiler bug? With -O2, gcc-2.95.3 emits movb and xorb at the same spot.

gcc-3.2.1 doesn't have a problem with that code optimized or not... it flat refuses to suck up any inline assembly unless you use at least -O -finline-limit=1580. (why 1580?)

-Mike

#5 lore raw
In reply to Brice Goglin
Quoted 5 lines · Brice Goglin

Hi,

Trying to compile a very very simple module for 2.5, I got an error from gcc saying that assembly code is incorrect.

[snip]

Quoted 4 lines

Here's gcc report :

mp760:~/tmp% gcc user.c -c -o user.o -Ipath_to_2.5.57/include

Use:
make -C path/to/kernel/src SUBDIRS=$PWD modules

The way you specify is broken with recent kernels. Btw. do not define __KERNEL__ and MODULE, thats already done, when compiling a module like this.

Sam