Skip to contentSkip to conversation

x86-64: forgot asmlinkage on sys_mmap

PATCH In review [email protected] 2 participants 5 messages Mar 9, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86-64: forgot asmlinkage on sys_mmap

CC Andi Kleen <[email protected]>

I think it should be there, please check better.

---

 linux-2.6.11-paolo/arch/x86_64/kernel/sys_x86_64.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
arch/x86_64/kernel/sys_x86_64.c renamed from arch/x86_64/kernel/sys_x86_64.c~x86-64-asmlinkage-forgot +1 -1
diff -puN arch/x86_64/kernel/sys_x86_64.c~x86-64-asmlinkage-forgot arch/x86_64/kernel/sys_x86_64.c
@@ -38,7 +38,7 @@ asmlinkage long sys_pipe(int __user *fil
 	return error;
 }
 
-long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags,
+asmlinkage long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags,
 	unsigned long fd, unsigned long off)
 {
 	long error;

_

#2 lore raw
Quoted 6 lines · Andi Kleen
Quoted 3 lines · [email protected] writes:
CC Andi Kleen <[email protected]>

I think it should be there, please check better.

It doesn't matter. asmlinkage is a nop on x86-64.

Yes, otherwise nothing would work on x86-64 with mmap broken, but for cleanness and for the case this change it should be there (otherwise why asmlinkage is used in the rest of the file).

And for i386 asmlinkage acquired significance only recently.

Signature · 3 lines
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
http://www.user-mode-linux.org/~blaisorblade
#3 lore raw
Quoted 11 lines · Blaisorblade
Quoted 6 lines · Andi Kleen
Quoted 3 lines · [email protected] writes:
CC Andi Kleen <[email protected]>

I think it should be there, please check better.

It doesn't matter. asmlinkage is a nop on x86-64.

Yes, otherwise nothing would work on x86-64 with mmap broken, but for cleanness and for the case this change it should be there (otherwise why asmlinkage is used in the rest of the file).

Only because it was cut'n'pasted from i386 originally.

Quoted 2 lines

And for i386 asmlinkage acquired significance only recently.

Actually it doesn't neither on i386. That's because entry.S happens to put the arguments both into registers and the stack in the right order, so both register and stack argument calling conventions work.

But it is slightly safer to have it. When you use the stack arguments the C code is allowed to modify it, and when the system call is restarted later you could see garbage. In practice that's not a big issue because only very few system calls are restartable.

ptrace also could see corrupted state, but that's in general a non issue.

-Andi

#4 lore raw
Quoted 21 lines · Andi Kleen
Quoted 11 lines · Blaisorblade
Quoted 6 lines · Andi Kleen
Quoted 3 lines · [email protected] writes:
CC Andi Kleen <[email protected]>

I think it should be there, please check better.

It doesn't matter. asmlinkage is a nop on x86-64.

Yes, otherwise nothing would work on x86-64 with mmap broken, but for cleanness and for the case this change it should be there (otherwise why asmlinkage is used in the rest of the file).

Only because it was cut'n'pasted from i386 originally.

Quoted 1 line

And for i386 asmlinkage acquired significance only recently.

Actually it doesn't neither on i386. That's because entry.S happens to put the arguments both into registers and the stack in the right order, so both register and stack argument calling conventions work.

Quoted 6 lines

But it is slightly safer to have it. When you use the stack arguments the C code is allowed to modify it, and when the system call is restarted later you could see garbage. In practice that's not a big issue because only very few system calls are restartable.

ptrace also could see corrupted state, but that's in general a non issue.

Ok, thanks for the info, I hope it's applied anyway.

Signature · 3 lines
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
http://www.user-mode-linux.org/~blaisorblade