This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Kernel 2.1.117 OOPS w/egcs


In article <199808221138.EAA04876.cygnus.egcs@dm.cobaltmicro.com>,
David S. Miller <davem@dm.cobaltmicro.com> wrote:
>And thus if __switch_to (a C function elsewhere in the kernel) is not
>compiled with regparm semantics, the kernel crashes.  The reports
>disassembly output is that of __switch_to, showing how egcs did not
>respect the regparm attribute.
>
>Even if regparm cannot be made to work, this is a bug if egcs silently
>just doesn't do it without issuing a warning or a flat out error
>disagnostic.

Agreed. 

Due to reload lossage on SMALL_REGISTER_CLASS machines, no version of
gcc can reliably set up the parameters calling a regparm function.  Why
it didn't respect it on the called side, I don't know, but its probably
not worth delving into, since we can't adequately support calling such
functions.

We should just turn off regparm so that you get a compile-time error.

>It's a real shame this can't work reliably, these routines will be
>slow as shit without regparms...

While it will be less efficient, I wouldn't call 3 or 4 additional
cycles "slow as shit".  Witness:

   extern void __attribute__((stdcall))
   __switch_to(struct task_struct *prev, struct task_struct *next);

The stdcall has one important feature we are looking for: it pops
its own arguments.  This because __switch_to doesn't always return
to its call site, making things otherwise hairy. 

We then write

		     "movl %%esp,%0\n\t"	/* save ESP */
		     "movl %5,%%esp\n\t"	/* restore ESP */
		     "movl $1f,%1\n\t"		/* save EIP */
+		     "pushl %8\n\t"		/* push next */
+		     "pushl %7\n\t"		/* push prev */
		     "pushl %6\n\t"		/* restore EIP */
		     "jmp __switch_to\n"

Whee, all done.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]