This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix get ERESTARTSYS with m32 in x86_64 when debug by GDB
- From: "H. Peter Anvin" <hpa at zytor dot com>
- To: Hui Zhu <teawater at gmail dot com>, Thomas Gleixner <tglx at linutronix dot de>, Ingo Molnar <mingo at redhat dot com>, x86 at kernel dot org, eparis at redhat dot com, ak at linux dot intel dot com, "linux-kernel at vger dot kernel dot org" <linux-kernel at vger dot kernel dot org>
- Cc: "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Mon, 21 Apr 2014 09:33:10 -0700
- Subject: Re: [PATCH] Fix get ERESTARTSYS with m32 in x86_64 when debug by GDB
- Authentication-results: sourceware.org; auth=none
- References: <CANFwon0oLO+qCtpewc=BxKBOm05aBMpV=yG0CxwW1isWHfnZqw at mail dot gmail dot com>
On 04/21/2014 09:19 AM, Hui Zhu wrote:
> }
> Now ax is in 32 bits now, need sign-extend to 64 bits. But
> current_thread_info()->status TS_COMPAT is cleared when GDB call "call func1()".
> Linux kernel don't know this is a 32 bits task and will not extend it.
> Then -ERESTARTSYS is not be handled and go back to user space.
>
> Then the syscall "read" get a errno in ERESTARTSYS.
>
> To fix this issue, I tried to add a local variable to "do_signal" but
> it is not works. The stack is cleared before GDB "continue".
> so I make a patch that add "test_thread_flag (TIF_IA32)" to syscall_get_error.
>
> Signed-off-by: Hui Zhu <hui@codesourcery.com>
> ---
> --- a/arch/x86/include/asm/syscall.h
> +++ b/arch/x86/include/asm/syscall.h
> @@ -48,7 +48,8 @@ static inline long syscall_get_error(str
> * TS_COMPAT is set for 32-bit syscall entries and then
> * remains set until we return to user mode.
> */
> - if (task_thread_info(task)->status & TS_COMPAT)
> + if ((task_thread_info(task)->status & TS_COMPAT)
> + || test_thread_flag (TIF_IA32))
> /*
> * Sign-extend the value so (int)-EFOO becomes (long)-EFOO
> * and will match correctly in comparisons.
>
No, this is definitely not the right fix. Your description is
incredibly hard to follow, but I feel pretty strongly that the above is
at the very best a last resort fix. TS_COMPAT is a local property
whereas TIF_IA32 is global; it is important to keep their respective
uses correct. Mixing them is almost guaranteed to be just plain wrong.
-hpa