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


   Date: Fri, 21 Aug 1998 23:40:39 -0600
   From: Jeffrey A Law <law@cygnus.com>

   There's no information in this message which helps me determine what
   the right thing to do is or what we are doing wrong.  Also no testcase.

   I can't do anything with such bug reports.

Linux, as of 2.1.115 or 2.1.116, relies on the regparm calling
convention in hard coded inline asm statements on the Intel.
Something like:

#define FASTCALL(x)     x __attribute__((regparm(3)))
extern void FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next));

#define switch_to(prev,next) do {					\
	unsigned long eax, edx, ecx;					\
	asm volatile("pushl %%ebx\n\t"					\
		     "pushl %%esi\n\t"					\
		     "pushl %%edi\n\t"					\
		     "pushl %%ebp\n\t"					\
		     "movl %%esp,%0\n\t"	/* save ESP */		\
		     "movl %5,%%esp\n\t"	/* restore ESP */	\
		     "movl $1f,%1\n\t"		/* save EIP */		\
		     "pushl %6\n\t"		/* restore EIP */	\
		     "jmp __switch_to\n"				\
		     "1:\t"						\
		     "popl %%ebp\n\t"					\
		     "popl %%edi\n\t"					\
		     "popl %%esi\n\t"					\
		     "popl %%ebx"					\
		     :"=m" (prev->tss.esp),"=m" (prev->tss.eip),	\
		      "=a" (eax), "=d" (edx), "=c" (ecx)		\
		     :"m" (next->tss.esp),"m" (next->tss.eip),		\
		      "a" (prev), "d" (next)); 				\
} while (0)

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.

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

Later,
David S. Miller
davem@dm.cobaltmicro.com


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