Re: [discuss] booting a kernel compiled with -mregparm=0

From: linux-os
Date: Fri Jan 14 2005 - 16:36:39 EST


On Fri, 14 Jan 2005, Jan Hubicka wrote:

Hello,

I am trying to boot a 2.6.x kernel (on x86_64) compiled with -mregparm=0
and it does not boot, i.e. hangs at the very first stage.

I know this breaks ABI/x86_64 but the reason I need to compile such a
kernel is because kdb on x86_64 cannot show the function arguments and the
only way to make it work that I found was to pass all arguments on the
stack (then kdb works fine and shows correct values for all arguments).
But obviously the module and the kernel need to match, otherwise it will
panic easily; and so I have to use the same argument passing convention in
the kernel. This is obviously for debugging only, nobody would ever ship
such "incorrectly" compiled module anywhere.

So, I have to find a "boundary" between the parts of the kernel that can
be safely compiled with -mregparm=0 and which must stay as they are. Any
ideas as to what to do in this situation?

Actually -mregparm=0 is not supposed to be even accepted by x86-64
compiler (I've disabled the function attribute but apparently missed
this one) and even if GCC produced valid code by miracle, you will get
into trouble with hand written assembly.

Huh? That's the default for a 'C' compiler (not to pass parameters
in registers). The parameters are passed on the stack as the default!
The return values don't count. They are, by default passed in eax
or edx-eax pair for a long long.

-mregparm=0 should therefore be a no-op unless overridden by
an __attribute__ macro.

I recall that Linus changed some code when it was discovered that
there was a bug in linux-2.6.8/arch/i386/kernel/semaphore.c

This forced some parameters to be passed in registers, using
the __attribute__((regparm(3))) macro in ../asm/linkage.h. This
might not be a GoodThing(tm) with x86_64.



Honza

Kind regards
Tigran

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


Cheers,
Dick Johnson
Penguin : Linux version 2.6.10 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/