Re: [PATCH 74/74] lto, workaround: Mark do_futex noinline to prevent clobbering ebp
On 08/22/2012 07:29 PM, Andi Kleen wrote: How about just use register arguments for the first three arguments. This should work for the syscalls at least (may be too risky for all other asm entry points) Well, it's just an effort to convert each one in turn... And for syscalls with more than three generate a stub that saves on the stack explicitely. This could be done using the new fancy SYSCALL definition macros (except that arch/x86 would need to start using them too in its own code) I don't think there is any point. Just push the six potential arguments to the stack and be done with it. Or is there some subtle reason with syscall restart and updated args that prevents it? Perhaps newer gcc can do regparm(X), X > 3 too, may be worth trying. No, there is no such ABI defined. Don't have time to look into this currently though. Always the problem. -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 74/74] lto, workaround: Mark do_futex noinline to prevent clobbering ebp
> The right thing to do is to change head_32.S to not violate the i386 > ABI. Arguments pushed (by value) on the stack are property of the > callee, that is, they are volatile, so the hack of making them do double > duty as both being saved and passed as arguments is just plain bogus. > The problem is that it works "just well enough" that people (including > myself) keep hacking around it with hacks like this, with assembly > macros, and whatnot instead of fixing the root cause. How about just use register arguments for the first three arguments. This should work for the syscalls at least (may be too risky for all other asm entry points) And for syscalls with more than three generate a stub that saves on the stack explicitely. This could be done using the new fancy SYSCALL definition macros (except that arch/x86 would need to start using them too in its own code) Or is there some subtle reason with syscall restart and updated args that prevents it? Perhaps newer gcc can do regparm(X), X > 3 too, may be worth trying. Don't have time to look into this currently though. -Andi -- a...@linux.intel.com -- Speaking for myself only -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 74/74] lto, workaround: Mark do_futex noinline to prevent clobbering ebp
On 08/22/2012 05:17 PM, H. Peter Anvin wrote: On 08/18/2012 07:57 PM, Andi Kleen wrote: From: Andi Kleen On a 32bit build gcc 4.7 with LTO decides to clobber the 6th argument on the stack. Unfortunately this corrupts the user EBP and leads to later crashes. For now mark do_futex noinline to prevent this. I wish there was a generic way to handle this. Seems like a ticking time bomb problem. There is a generic way to handle this. This is actually a bug in Linux that has been known for at least 15 years and which we keep hacking around. The right thing to do is to change head_32.S to not violate the i386 ABI. Arguments pushed (by value) on the stack are property of the callee, that is, they are volatile, so the hack of making them do double duty as both being saved and passed as arguments is just plain bogus. The problem is that it works "just well enough" that people (including myself) keep hacking around it with hacks like this, with assembly macros, and whatnot instead of fixing the root cause. -hpa Just a clarification (Andi knows this, I'm sure, but others might not): this wasn't done the way it is for no reason; back when Linus originally wrote the code, i386 passed *all* arguments on the stack, and we still do that for "asmlinkage" functions on i386. Since gcc back then rarely if ever mucked with the stack arguments, it made sense to make them "double duty." Fixing this really should entail changing the invocation of system calls on i386 to use the regparm convention, which means we only need to push three arguments twice, rather than six. -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 74/74] lto, workaround: Mark do_futex noinline to prevent clobbering ebp
On 08/18/2012 07:57 PM, Andi Kleen wrote: > From: Andi Kleen > > On a 32bit build gcc 4.7 with LTO decides to clobber the 6th argument on the > stack. Unfortunately this corrupts the user EBP and leads to later crashes. > For now mark do_futex noinline to prevent this. > > I wish there was a generic way to handle this. Seems like a ticking time > bomb problem. > There is a generic way to handle this. This is actually a bug in Linux that has been known for at least 15 years and which we keep hacking around. The right thing to do is to change head_32.S to not violate the i386 ABI. Arguments pushed (by value) on the stack are property of the callee, that is, they are volatile, so the hack of making them do double duty as both being saved and passed as arguments is just plain bogus. The problem is that it works "just well enough" that people (including myself) keep hacking around it with hacks like this, with assembly macros, and whatnot instead of fixing the root cause. -hpa -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 74/74] lto, workaround: Mark do_futex noinline to prevent clobbering ebp
On 08/18/2012 07:57 PM, Andi Kleen wrote: From: Andi Kleen a...@linux.intel.com On a 32bit build gcc 4.7 with LTO decides to clobber the 6th argument on the stack. Unfortunately this corrupts the user EBP and leads to later crashes. For now mark do_futex noinline to prevent this. I wish there was a generic way to handle this. Seems like a ticking time bomb problem. There is a generic way to handle this. This is actually a bug in Linux that has been known for at least 15 years and which we keep hacking around. The right thing to do is to change head_32.S to not violate the i386 ABI. Arguments pushed (by value) on the stack are property of the callee, that is, they are volatile, so the hack of making them do double duty as both being saved and passed as arguments is just plain bogus. The problem is that it works just well enough that people (including myself) keep hacking around it with hacks like this, with assembly macros, and whatnot instead of fixing the root cause. -hpa -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 74/74] lto, workaround: Mark do_futex noinline to prevent clobbering ebp
On 08/22/2012 05:17 PM, H. Peter Anvin wrote: On 08/18/2012 07:57 PM, Andi Kleen wrote: From: Andi Kleen a...@linux.intel.com On a 32bit build gcc 4.7 with LTO decides to clobber the 6th argument on the stack. Unfortunately this corrupts the user EBP and leads to later crashes. For now mark do_futex noinline to prevent this. I wish there was a generic way to handle this. Seems like a ticking time bomb problem. There is a generic way to handle this. This is actually a bug in Linux that has been known for at least 15 years and which we keep hacking around. The right thing to do is to change head_32.S to not violate the i386 ABI. Arguments pushed (by value) on the stack are property of the callee, that is, they are volatile, so the hack of making them do double duty as both being saved and passed as arguments is just plain bogus. The problem is that it works just well enough that people (including myself) keep hacking around it with hacks like this, with assembly macros, and whatnot instead of fixing the root cause. -hpa Just a clarification (Andi knows this, I'm sure, but others might not): this wasn't done the way it is for no reason; back when Linus originally wrote the code, i386 passed *all* arguments on the stack, and we still do that for asmlinkage functions on i386. Since gcc back then rarely if ever mucked with the stack arguments, it made sense to make them double duty. Fixing this really should entail changing the invocation of system calls on i386 to use the regparm convention, which means we only need to push three arguments twice, rather than six. -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 74/74] lto, workaround: Mark do_futex noinline to prevent clobbering ebp
The right thing to do is to change head_32.S to not violate the i386 ABI. Arguments pushed (by value) on the stack are property of the callee, that is, they are volatile, so the hack of making them do double duty as both being saved and passed as arguments is just plain bogus. The problem is that it works just well enough that people (including myself) keep hacking around it with hacks like this, with assembly macros, and whatnot instead of fixing the root cause. How about just use register arguments for the first three arguments. This should work for the syscalls at least (may be too risky for all other asm entry points) And for syscalls with more than three generate a stub that saves on the stack explicitely. This could be done using the new fancy SYSCALL definition macros (except that arch/x86 would need to start using them too in its own code) Or is there some subtle reason with syscall restart and updated args that prevents it? Perhaps newer gcc can do regparm(X), X 3 too, may be worth trying. Don't have time to look into this currently though. -Andi -- a...@linux.intel.com -- Speaking for myself only -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 74/74] lto, workaround: Mark do_futex noinline to prevent clobbering ebp
On 08/22/2012 07:29 PM, Andi Kleen wrote: How about just use register arguments for the first three arguments. This should work for the syscalls at least (may be too risky for all other asm entry points) Well, it's just an effort to convert each one in turn... And for syscalls with more than three generate a stub that saves on the stack explicitely. This could be done using the new fancy SYSCALL definition macros (except that arch/x86 would need to start using them too in its own code) I don't think there is any point. Just push the six potential arguments to the stack and be done with it. Or is there some subtle reason with syscall restart and updated args that prevents it? Perhaps newer gcc can do regparm(X), X 3 too, may be worth trying. No, there is no such ABI defined. Don't have time to look into this currently though. Always the problem. -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/