Re: [PATCH] Fix get ERESTARTSYS with m32 in x86_64 when debug by GDB

2014-04-30 Thread H. Peter Anvin
On 04/30/2014 06:35 AM, Mark Kettenis wrote: > > arch/x86/kernel/ptrace.c:putreg32() has this bit of code: > > case offsetof(struct user32, regs.orig_eax): > /* > * A 32-bit debugger setting orig_eax means to restore > * the state of the t

Re: [PATCH] Fix get ERESTARTSYS with m32 in x86_64 when debug by GDB

2014-04-30 Thread H. Peter Anvin
On 04/30/2014 09:35 AM, Hui Zhu wrote: > > I sorry that previous patch has some format issue, post a new one. > > Signed-off-by: Hui Zhu > --- > --- a/arch/x86/kernel/ptrace.c > +++ b/arch/x86/kernel/ptrace.c > @@ -452,6 +452,23 @@ static int putreg(struct task_struct *ch > if (child->t

Re: [PATCH] Fix get ERESTARTSYS with m32 in x86_64 when debug by GDB

2014-04-30 Thread Pedro Alves
On 04/30/2014 02:35 PM, Mark Kettenis wrote: >> Date: Tue, 29 Apr 2014 22:10:15 -0700 >> From: "H. Peter Anvin" >> >> On 04/29/2014 10:08 PM, Andrew Pinski wrote: >>> >>> restoring the values is hard since even the ptrace interface does not >>> allow for that. >>> >> >> So that begs the ultimate q

Re: [PATCH] Fix get ERESTARTSYS with m32 in x86_64 when debug by GDB

2014-04-30 Thread H. Peter Anvin
On 04/30/2014 06:35 AM, Mark Kettenis wrote: > > If (and only if) the goal of that TS_COMPAT flag solely is to trigger > the error code sign-extension in arch/x86/asm/syscall.h:syscall_get_error(), > we could work around to problem in GDB by checking "orig_ax" to see if > we're continuing an inter

Re: [PATCH] Fix get ERESTARTSYS with m32 in x86_64 when debug by GDB

2014-04-30 Thread Hui Zhu
On 05/01/14 00:28, Hui Zhu wrote: On Wed, Apr 30, 2014 at 9:35 PM, Mark Kettenis wrote: >>> Date: Tue, 29 Apr 2014 22:10:15 -0700 >>> From: "H. Peter Anvin" >>> >>> On 04/29/2014 10:08 PM, Andrew Pinski wrote: restoring the values is hard since even the ptrace interface does not >>>

Re: [PATCH] Fix get ERESTARTSYS with m32 in x86_64 when debug by GDB

2014-04-30 Thread Hui Zhu
On Wed, Apr 30, 2014 at 9:35 PM, Mark Kettenis wrote: >> Date: Tue, 29 Apr 2014 22:10:15 -0700 >> From: "H. Peter Anvin" >> >> On 04/29/2014 10:08 PM, Andrew Pinski wrote: >> > >> > restoring the values is hard since even the ptrace interface does not >> > allow for that. >> > >> >> So that begs

Re: [PATCH] Fix get ERESTARTSYS with m32 in x86_64 when debug by GDB

2014-04-30 Thread Mark Kettenis
> Date: Tue, 29 Apr 2014 22:10:15 -0700 > From: "H. Peter Anvin" > > On 04/29/2014 10:08 PM, Andrew Pinski wrote: > > > > restoring the values is hard since even the ptrace interface does not > > allow for that. > > > > So that begs the ultimate question, which is: given the fact that there >

Re: [PATCH] Fix get ERESTARTSYS with m32 in x86_64 when debug by GDB

2014-04-29 Thread H. Peter Anvin
On 04/29/2014 10:08 PM, Andrew Pinski wrote: > > restoring the values is hard since even the ptrace interface does not > allow for that. > So that begs the ultimate question, which is: given the fact that there is *state missing* from the state vector (this is the core of the problem), is there

Re: [PATCH] Fix get ERESTARTSYS with m32 in x86_64 when debug by GDB

2014-04-29 Thread Andrew Pinski
On Tue, Apr 29, 2014 at 9:50 PM, H. Peter Anvin wrote: > On 04/29/2014 08:44 PM, Hui Zhu wrote: >> >> I am sorry that the root cause of issue has something wrong. >> The right root cause is: >> When inferior call 32 bits syscall "read", Linux kernel function >> "ia32_cstar_target" will set TS_COMP

Re: [PATCH] Fix get ERESTARTSYS with m32 in x86_64 when debug by GDB

2014-04-29 Thread H. Peter Anvin
On 04/29/2014 08:44 PM, Hui Zhu wrote: > > I am sorry that the root cause of issue has something wrong. > The right root cause is: > When inferior call 32 bits syscall "read", Linux kernel function > "ia32_cstar_target" will set TS_COMPAT to current_thread_info->status. > > syscall read is interr

Re: [PATCH] Fix get ERESTARTSYS with m32 in x86_64 when debug by GDB

2014-04-29 Thread Hui Zhu
On Tue, Apr 22, 2014 at 12:33 AM, H. Peter Anvin wrote: > 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

Re: [PATCH] Fix get ERESTARTSYS with m32 in x86_64 when debug by GDB

2014-04-21 Thread H. Peter Anvin
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 handl

[PATCH] Fix get ERESTARTSYS with m32 in x86_64 when debug by GDB

2014-04-21 Thread Hui Zhu
#cat gdb.base/interrupt.c #include #include #include #include #ifdef SIGNALS #include static void sigint_handler (int signo) { } #endif int main () { char x; int nbytes; #ifdef SIGNALS signal (SIGINT, sigint_handler); #endif printf ("talk to me baby\n"); while (1) { nbyt