Skip to contentSkip to conversation

rename 'unused' in sys_iopl to somethign else, since it is used

DISCUSSION Rusty Russell 2 participants 2 messages Jul 30, 2002 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

In message <[email protected]> you write:

Quoted 3 lines

sys_iopl on i386 accepts one parameter, 'unsigned long unused'. Then it goes ahead and uses it to get a pointer to struct pt_regs. This patch changes its name to 'location'.=20

Hmmm.... Andi, the x86_64 version is different: do you really push one arg on the stack then the regs? Please check...

Quoted 5 lines

diff -Nru a/arch/i386/kernel/ioport.c b/arch/i386/kernel/ioport.c

arch/i386/kernel/ioport.c +0 -0
@@ -102,9 +102,9 @@
  * code.

arch/i386/kernel/ioport.c line 110

Quoted 10 lines
arch/i386/kernel/ioport.c +2 -2
  */
 
-asmlinkage int sys_iopl(unsigned long unused)
+asmlinkage int sys_iopl(unsigned long location)
 {
-	struct pt_regs * regs =3D (struct pt_regs *) &unused;
+	struct pt_regs * regs =3D (struct pt_regs *) &location;=20
 	unsigned int level =3D regs->ebx;
 	unsigned int old =3D (regs->eflags >> 12) & 3;
 

It also then rereads the arg out of regs->ebx. I prefer the following patch, which makes it obvious that the arg *is* required, and what it means:

arch/i386/kernel/ioport.c +2 -3
diff -urpN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.29/arch/i386/kernel/ioport.c working-2.5.29-iopl/arch/i386/kernel/ioport.c
@@ -102,10 +102,9 @@ asmlinkage int sys_ioperm(unsigned long 
  * code.
  */
 
-asmlinkage int sys_iopl(unsigned long unused)
+asmlinkage int sys_iopl(unsigned int level)
 {
-	struct pt_regs * regs = (struct pt_regs *) &unused;
-	unsigned int level = regs->ebx;
+	struct pt_regs * regs = (struct pt_regs *) &level;
 	unsigned int old = (regs->eflags >> 12) & 3;
 
 	if (level > 3)

Thanks!
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#2 lore raw
Quoted 7 lines · Rusty Russell

In message <[email protected]> you write:

Quoted 3 lines

sys_iopl on i386 accepts one parameter, 'unsigned long unused'. Then it goes ahead and uses it to get a pointer to struct pt_regs. This patch changes its name to 'location'.=20

Hmmm.... Andi, the x86_64 version is different: do you really push one arg on the stack then the regs? Please check...

level is in a register (rdi), but pt_regs is on the stack. The calling convention automatically switches to stack location for structures bigger than one register.

On i386 it is probably cleanest when you need both pt_regs and arguments to declare pt_regs only and get the first argument directly out of regs->ebx.

-Andi