build fix for x86_64...
Subsystems (2)
hi vasily,
commit b716395e2b8e450e294537de0c91476ded2f0395 breaks the build for x86_64 (and ia64 too, i guess) if CONFIG_COMPAT is not turned on. here is a patch, which i think is more complete than the previous one posted to LKML by Doug Chapman (which only fixes ia64, i think). it lets the build continue, but i have no idea if it's correct or not..
arthur
fs/quota.c +1 -1
@@ -387,7 +387,7 @@ asmlinkage long sys_quotactl(unsigned int cmd, const char __user *special, qid_treturn ret; } -#if defined(CONFIG_X86_64 ) || defined(CONFIG_IA64 ) +#if defined(CONFIG_COMPAT ) && (defined(CONFIG_X86_64 ) || defined(CONFIG_IA64 ))/* * This code works only for 32 bit quota tools over 64 bit OS (x86_64, ia64) * and is necessary due to alignment problems.
Quoted 9 lines · On Friday 20 July 2007 00:24:11 Arthur Jones wrote:
hi vasily,
commit
b716395e2b8e450e294537de0c91476ded2f0395breaks the build forx86_64(and ia64 too, i guess) ifCONFIG_COMPATis not turned on. here is a patch, which i think is more complete than the previous one posted to LKML by Doug Chapman (which only fixes ia64, i think). it lets the build continue, but i have no idea if it's correct or not..
Looks good,
Tony, perhaps it would make sense to define some common CONFIG for COMPAT_FOR_U64_ALIGNMENT longer term to make the #ifs for this case a little less ugly.
-Andi
Quoted 1 line
Looks good.
Looks good to me too (I'm to blame for the version posted by Doug that only fixed ia64 ... I didn't take the time to check whether there was a CONFIG_COMPAT option for x86_64 ... oops).
Quoted 3 lines
Tony, perhaps it would make sense to define some common CONFIG for
COMPAT_FOR_U64_ALIGNMENTlonger term to make the #ifs for this case a little less ugly.
Certainly if there is ever a third architecture that needs this the #if mess will be beyond bad. But with only the two of us we'd trade one ugly #ifdef line here for another half-dozen lines in each of our Kconfig files to define the new term. I'm not sure whether that is a win.
-Tony
Quoted 8 lines · Tony
Quoted 3 lines
Tony, perhaps it would make sense to define some common CONFIG for
COMPAT_FOR_U64_ALIGNMENTlonger term to make the #ifs for this case a little less ugly.Certainly if there is ever a third architecture that needs this the #if mess will be beyond bad. But with only the two of us we'd trade one ugly #ifdef line here for another half-dozen lines in each of our
Kconfigfiles to define the new term.
Half dozens?
config COMPAT_FOR_U64_ALIGNMENT
bool
default y
-Andi
Quoted 11 lines · On Fri, 20 Jul 2007 10:32:47 +0200 Andi Kleen wrote:
Quoted 8 lines · Tony
Quoted 3 lines
Tony, perhaps it would make sense to define some common CONFIG for
COMPAT_FOR_U64_ALIGNMENTlonger term to make the #ifs for this case a little less ugly.Certainly if there is ever a third architecture that needs this the #if mess will be beyond bad. But with only the two of us we'd trade one ugly #ifdef line here for another half-dozen lines in each of our
Kconfigfiles to define the new term.
Quoted 5 lines
Half dozens?
config
COMPAT_FOR_U64_ALIGNMENT
bool
default y
or even
def_bool y
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
Quoted 1 line
Half dozens?
I was imagining having to have "help" messages ... which of course we don't.
Quoted 3 lines
config
COMPAT_FOR_U64_ALIGNMENT
bool
default y
Plausible.
Randy suggested:
Quoted 1 line
def_booly
Which is better. But if we unconditionally set this CONFIG variable, then the code in fs/quota.c will have to read:
#if defined(CONFIG_COMPAT) && defined(CONFIG_COMPAT_FOR_U64_ALIGNMENT)
We can keep it simpler if the Kconfig file does the conditional for us:
config COMPAT_FOR_U64_ALIGNMENT
def_bool y
depends on COMPAT
Then the patch looks like this:
arch/ia64/Kconfig +4 -0
@@ -425,6 +425,10 @@ config COMPAT depends on IA32_SUPPORT default y +config COMPAT_FOR_U64_ALIGNMENT + def_bool y + depends on COMPAT + config IA64_MCA_RECOVERY tristate "MCA recovery from errors other than TLB."
arch/x86_64/Kconfig +4 -0
@@ -753,6 +753,10 @@ config COMPAT depends on IA32_EMULATION default y +config COMPAT_FOR_U64_ALIGNMENT + def_bool y + depends on COMPAT + config SYSVIPC_COMPAT bool depends on COMPAT && SYSVIPC
fs/quota.c +1 -1
@@ -387,7 +387,7 @@ asmlinkage long sys_quotactl(unsigned int cmd, const char __user *special, qid_treturn ret; } -#if defined(CONFIG_X86_64 ) || defined(CONFIG_IA64 ) +#if defined(CONFIG_COMPAT_FOR_U64_ALIGNMENT )/* * This code works only for 32 bit quota tools over 64 bit OS (x86_64, ia64) * and is necessary due to alignment problems.
Quoted 10 lines · Tony
Which is better. But if we unconditionally set this CONFIG variable, then the code in
fs/quota.cwill have to read:#if
defined(CONFIG_COMPAT)&&defined(CONFIG_COMPAT_FOR_U64_ALIGNMENT)We can keep it simpler if the
Kconfigfile does the conditional for us:config
COMPAT_FOR_U64_ALIGNMENT
def_booly
depends on COMPAT
Ah, but you can do better:
config COMPAT_FOR_U64_ALIGNMENT
def_bool COMPAT
I hand-edited your patch:
arch/ia64/Kconfig +3 -0
@@ -425,6 +425,9 @@ config COMPAT depends on IA32_SUPPORT default y +config COMPAT_FOR_U64_ALIGNMENT + def_bool COMPAT + config IA64_MCA_RECOVERY tristate "MCA recovery from errors other than TLB."
arch/x86_64/Kconfig +3 -0
@@ -753,6 +753,9 @@ config COMPAT depends on IA32_EMULATION default y +config COMPAT_FOR_U64_ALIGNMENT + def_bool COMPAT + config SYSVIPC_COMPAT bool depends on COMPAT && SYSVIPC
fs/quota.c +1 -1
@@ -387,7 +387,7 @@ asmlinkage long sys_quotactl(unsigned int cmd, const char __user *special, qid_treturn ret; } -#if defined(CONFIG_X86_64 ) || defined(CONFIG_IA64 ) +#if defined(CONFIG_COMPAT_FOR_U64_ALIGNMENT )/* * This code works only for 32 bit quota tools over 64 bit OS (x86_64, ia64) * and is necessary due to alignment problems.
Signature · 3 lines
"Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Quoted 4 lines · Tony
Which is better. But if we unconditionally set this CONFIG variable, then the code in
fs/quota.cwill have to read:
Quoted 8 lines
#if
defined(CONFIG_COMPAT)&&defined(CONFIG_COMPAT_FOR_U64_ALIGNMENT)We can keep it simpler if the
Kconfigfile does the conditional for us:config
COMPAT_FOR_U64_ALIGNMENT
def_booly
depends on COMPAT
No, that would be bad. If compat_u64 is used to carry 32-bit ABIs forward into 64-bit space without needing compatibility hacks, then this would actually introduce ABI incompatibilities depending on CONFIG_COMPAT!
-hpa
Quoted 6 lines · H. Peter Anvin
Quoted 5 lines · Tony
Which is better. But if we unconditionally set this CONFIG variable, then the code in
fs/quota.cwill have to read:#if
defined(CONFIG_COMPAT)&&defined(CONFIG_COMPAT_FOR_U64_ALIGNMENT)
Quoted 7 lines
Quoted 5 lines
We can keep it simpler if the
Kconfigfile does the conditional for us:config
COMPAT_FOR_U64_ALIGNMENT
def_booly
depends on COMPATNo, that would be bad. If
compat_u64is used to carry 32-bit ABIs
That doesn't help for any old interfaces, like the one here. For those still ifdefs are needed. Interfaces that use compat_u64 just use a normal #ifdef CONFIG_COMPAT.
Besides I have my doubts compat_u64 will be the solution
to these worries. We have hundreds of people adding various interfaces to Linux and it's unlikely they all heard about it. So likely these cases will occur again and again.
-Andi
Quoted 10 lines · Andi Kleen
That doesn't help for any old interfaces, like the one here. For those still ifdefs are needed. Interfaces that use
compat_u64just use a normal #ifdefCONFIG_COMPAT.Besides I have my doubts
compat_u64will be the solution
to these worries. We have hundreds of people adding various interfaces to Linux and it's unlikely they all heard about it. So likely these cases will occur again and again.
Of course they will. compat_u64 will have no effect on a properly designed interface where everything is aligned.
To me, the whole point with compat_u64 is that when someone has designed an interface improperly (so it's alignment-dependent) then we can replace u64 with compat_u64 and use the same structure on 64 bits even though the original interface was broken.
-hpa
Quoted 3 lines · H. Peter Anvin
No, that would be bad. If
compat_u64is used to carry 32-bit ABIs forward into 64-bit space without needing compatibility hacks, then this would actually introduce ABI incompatibilities depending onCONFIG_COMPAT!
But without CONFIG_COMPAT there is no 32-bit ABI, thus no need for compat_u64 in the first place.
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 9 lines · Andreas Schwab
Quoted 3 lines · H. Peter Anvin
No, that would be bad. If
compat_u64is used to carry 32-bit ABIs forward into 64-bit space without needing compatibility hacks, then this would actually introduce ABI incompatibilities depending onCONFIG_COMPAT!But without
CONFIG_COMPATthere is no 32-bit ABI, thus no need forcompat_u64in the first place.
You're missing the point.
Someone introduces an interface, which uses a structure:
struct foo {
u32 bar;
u64 baz;
u32 quux;
};Now, we want to port that to 64 bits. We can either introduce a thunking function to mangle the argument, or we can redefine the structure:
struct foo {
u32 bar;
compat_u64 baz;
u32 quux;
};... which is still ABI compatible on 32 bits, but doesn't require thunking.
Obviously, this is not a panacea; if the original "struct foo" has also been introduced on 64 bits before the bug is caught, then you're screwed.
-hpa
Quoted 3 lines
Obviously, this is not a panacea; if the original "struct foo" has also been introduced on 64 bits before the bug is caught,
That's usually the case. There is already an established 64bit ABI
-Andi
Quoted 5 lines · Andi Kleen
Quoted 2 lines
Obviously, this is not a panacea; if the original "struct foo" has also been introduced on 64 bits before the bug is caught,
That's usually the case. There is already an established 64bit ABI
This is true.
Kind of makes me wonder if the right thing is to introduce an "interface" 64-bit type, call it __iu64 (__is64) defined as:
typedef __u64 __attribute__((aligned(8))) __iu64;
typedef __s64 __attribute__((aligned(8))) __is64;
... and encourage people to use it when creating new interfaces.
Don't know if that would do any good.
-hpa
At the moment our problem is that there is some code that has been added to handle the compatability problem caused by u64 objects having different alignment when running on 32-bit and 64-bit systems. This only affects ia64 and x86-64 because all the other 32/64 bit capable systems wisely avoided this issue by making 64-bit objects *always* 8-byte aligned.
It is possible that in the future more such issues will arise (either because we find some more existing interfaces that have this problem, or because new interfaces are introduced that also have this problem). Such new code will also require some compatability functions. These functions will also only be needed on ia64 and x86-64, and even on these systems the code will only be needed if CONFIG_COMPAT=y
So I'm failing to see what's wrong with putting such compatabilty code inside a
#if defined(CONFIG_COMPAT_FOR_U64_ALIGNMENT)
...
#endif
to prevent it wasting object code space in kernels that don't need it.
-Tony
Quoted 7 lines · Tony
At the moment our problem is that there is some code that has been added to handle the compatability problem caused by u64 objects having different alignment when running on 32-bit and 64-bit systems. This only affects ia64 and x86-64 because all the other 32/64 bit capable systems wisely avoided this issue by making 64-bit objects *always* 8-byte aligned.
Quoted 7 lines
It is possible that in the future more such issues will arise (either because we find some more existing interfaces that have this problem, or because new interfaces are introduced that also have this problem). Such new code will also require some compatability functions. These functions will also only be needed on ia64 and x86-64, and even on these systems the code will only be needed if
CONFIG_COMPAT=y
The issue here is I was looking at it from a new interfaces perspective, and not from a legacy interfaces perspective. However, for new interfaces we want the opposite -- properly aligned elements -- so please disregard previous objection.
However, I'm still thinking it might be worthwhile to consider the __i[us]64 typedefs previously discussed as a way to avoid alignment bloopers in new interfaces.
-hpa
Quoted 5 lines · H. Peter Anvin
struct foo {
u32 bar;
compat_u64 baz;
u32 quux;
};compat_u64 is only for use in CONFIG_COMPAT code.
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."