All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] [ipipe 4.14][PATCH] x86: ipipe: Fix trap hooking for userspace routes
@ 2018-10-10 11:05 Jan Kiszka
  2018-10-13  0:56 ` Alec Ari
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jan Kiszka @ 2018-10-10 11:05 UTC (permalink / raw)
  To: Xenomai, Philippe Gerum

Also hook into the trap path when the exception was taken over userspace
code.

Fixes: e6b81a0ce7fb (x86: ipipe: route traps to co-kernel)
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

Makes sense? I'm not feeling 100% safe yet /wrt paranoid and the
userspace path. Should we handle this identically to the kernel path or
not?

Eventually this should be merged into the original patch, at least on
next major rebase.

 arch/x86/entry/entry_64.S | 80 +++++++++++++++++++++++++++--------------------
 1 file changed, 46 insertions(+), 34 deletions(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index f6fe849d66ed..42e31d1fddc6 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -904,6 +904,46 @@ ENTRY(switch_to_thread_stack)
 	ret
 END(switch_to_thread_stack)
 
+.macro ipipe_idtentry_prologue paranoid=0 trapnr=-1 skip_label=-invalid-
+#ifdef CONFIG_IPIPE
+	movq	EFLAGS(%rsp), %r14		/* regs->flags */
+	movq	%rsp, %rdi			/* pt_regs pointer */
+	movl	$\trapnr, %esi			/* trap number */
+	subq	$8, %rsp
+	movq	%rsp, %rdx			/* &flags */
+	call	__ipipe_trap_prologue
+	popq	%r13
+	mov	%rax, %r12			/* save propagation status */
+	.if \paranoid == 0			/* paranoid may not skip handler */
+	testl	%eax, %eax
+	jg	\skip_label			/* skip regular handler if > 0 */
+	.endif
+#endif
+.endm
+
+.macro ipipe_idtentry_epilogue paranoid=0 skip_label=-invalid-
+#ifdef CONFIG_IPIPE
+	testl	%r12d, %r12d
+	jnz	1000f
+	movq	%rsp, %rdi			/* pt_regs pointer */
+	movq	%r13, %rsi			/* &flags from prologue */
+	movq	%r14, %rdx			/* original regs->flags before fixup */
+	call	__ipipe_trap_epilogue
+1000:
+	.if \paranoid == 0			/* paranoid implies normal epilogue */
+	testl	%r12d, %r12d
+	jz	1001f
+\skip_label:
+	UNWIND_HINT_REGS
+	DISABLE_INTERRUPTS(CLBR_ANY)
+	testl	%ebx, %ebx	/* %ebx: return to kernel mode */
+	jnz	retint_kernel_early
+	jmp	retint_user_early
+	.endif
+1001:
+#endif
+.endm
+
 .macro idtentry sym do_sym has_error_code:req paranoid=0 shift_ist=-1 trapnr=-1
 ENTRY(\sym)
 	UNWIND_HINT_IRET_REGS offset=\has_error_code*8
@@ -940,20 +980,7 @@ ENTRY(\sym)
 	.endif
 	.endif
 
-#ifdef CONFIG_IPIPE
-	movq	EFLAGS(%rsp), %r14		/* regs->flags */
-	movq	%rsp, %rdi			/* pt_regs pointer */
-	movl	$\trapnr, %esi			/* trap number */
-	subq	$8, %rsp
-	movq	%rsp, %rdx			/* &flags */
-	call	__ipipe_trap_prologue
-	popq	%r13
-	mov	%rax, %r12			/* save propagation status */
-	.if \paranoid == 0			/* paranoid may not skip handler */
-	testl	%eax, %eax
-	jg	98f				/* skip regular handler if > 0 */
-	.endif
-#endif
+	ipipe_idtentry_prologue paranoid=\paranoid trapnr=\trapnr skip_label=kernel_skip_\@
 
 	movq	%rsp, %rdi			/* pt_regs pointer */
 
@@ -970,26 +997,7 @@ ENTRY(\sym)
 
 	call	\do_sym
 
-#ifdef CONFIG_IPIPE
-	testl	%r12d, %r12d
-	jnz	97f
-	movq	%rsp, %rdi			/* pt_regs pointer */
-	movq	%r13, %rsi			/* &flags from prologue */
-	movq	%r14, %rdx			/* original regs->flags before fixup */
-	call	__ipipe_trap_epilogue
-97:
-	.if \paranoid == 0			/* paranoid implies normal epilogue */
-	testl	%r12d, %r12d
-	jz	99f
-98:
-	UNWIND_HINT_REGS
-	DISABLE_INTERRUPTS(CLBR_ANY)
-	testl	%ebx, %ebx	/* %ebx: return to kernel mode */
-	jnz	retint_kernel_early
-	jmp	retint_user_early
-	.endif
-99:
-#endif
+	ipipe_idtentry_epilogue paranoid=\paranoid skip_label=kernel_skip_\@
 
 	.if \shift_ist != -1
 	addq	$EXCEPTION_STKSZ, CPU_TSS_IST(\shift_ist)
@@ -1011,6 +1019,8 @@ ENTRY(\sym)
 .Lfrom_usermode_switch_stack_\@:
 	call	error_entry
 
+	ipipe_idtentry_prologue paranoid=\paranoid trapnr=\trapnr skip_label=user_skip_\@
+
 	movq	%rsp, %rdi			/* pt_regs pointer */
 
 	.if \has_error_code
@@ -1022,6 +1032,8 @@ ENTRY(\sym)
 
 	call	\do_sym
 
+	ipipe_idtentry_epilogue paranoid=\paranoid skip_label=user_skip_\@
+
 	jmp	error_exit
 	.endif
 END(\sym)
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Xenomai] [ipipe 4.14][PATCH] x86: ipipe: Fix trap hooking for userspace routes
  2018-10-10 11:05 [Xenomai] [ipipe 4.14][PATCH] x86: ipipe: Fix trap hooking for userspace routes Jan Kiszka
@ 2018-10-13  0:56 ` Alec Ari
  2018-10-15 11:18   ` Jan Kiszka
  2018-10-13 13:52 ` Philippe Gerum
  2018-10-26 12:50 ` Henning Schild
  2 siblings, 1 reply; 8+ messages in thread
From: Alec Ari @ 2018-10-13  0:56 UTC (permalink / raw)
  To: Xenomai

Until this bug is properly sorted out, would it be a good idea to revert e6b81a0ce7fb86cf1f1db9f80b982c9b5f95c4c1 and 20db5ea2eee38b123c9641003fe55c895a1fd514 for the time being? The assembly code worked fine the way it was before. At least I never had any issues with it.

Alec


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xenomai] [ipipe 4.14][PATCH] x86: ipipe: Fix trap hooking for userspace routes
  2018-10-10 11:05 [Xenomai] [ipipe 4.14][PATCH] x86: ipipe: Fix trap hooking for userspace routes Jan Kiszka
  2018-10-13  0:56 ` Alec Ari
@ 2018-10-13 13:52 ` Philippe Gerum
  2018-10-26 12:50 ` Henning Schild
  2 siblings, 0 replies; 8+ messages in thread
From: Philippe Gerum @ 2018-10-13 13:52 UTC (permalink / raw)
  To: Jan Kiszka, Xenomai

On 10/10/2018 01:05 PM, Jan Kiszka wrote:
> Also hook into the trap path when the exception was taken over userspace
> code.
> 
> Fixes: e6b81a0ce7fb (x86: ipipe: route traps to co-kernel)
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> 
> Makes sense? I'm not feeling 100% safe yet /wrt paranoid and the
> userspace path. Should we handle this identically to the kernel path or
> not?
> 

It looks ok to me. We should always branch to error_exit in the paranoid
case for the user path, never taking the fast path out. This is
particularly important for handling debug traps properly.

-- 
Philippe.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xenomai] [ipipe 4.14][PATCH] x86: ipipe: Fix trap hooking for userspace routes
  2018-10-13  0:56 ` Alec Ari
@ 2018-10-15 11:18   ` Jan Kiszka
  2018-10-15 21:01     ` Alec Ari
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Kiszka @ 2018-10-15 11:18 UTC (permalink / raw)
  To: Alec Ari, Xenomai

On 13.10.18 02:56, Alec Ari wrote:
> Until this bug is properly sorted out, would it be a good idea to revert e6b81a0ce7fb86cf1f1db9f80b982c9b5f95c4c1 and 20db5ea2eee38b123c9641003fe55c895a1fd514 for the time being? The assembly code worked fine the way it was before. At least I never had any issues with it.

Those two commits install fundamental features of the I-pipe patch set, you 
can't reasonably run Xenomai without them. E.g., hell will break loose if a 
Xenomai thread triggers a memory-mapped file access fault during startup while 
it happened to be in RT mode. And debugging will not work either.

The proposed fix may not yet be optimal, but it is apparently sufficient.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xenomai] [ipipe 4.14][PATCH] x86: ipipe: Fix trap hooking for userspace routes
  2018-10-15 11:18   ` Jan Kiszka
@ 2018-10-15 21:01     ` Alec Ari
  0 siblings, 0 replies; 8+ messages in thread
From: Alec Ari @ 2018-10-15 21:01 UTC (permalink / raw)
  To: Jan Kiszka, Xenomai

>Those two commits install fundamental features of the I-pipe patch set, you 
>can't reasonably run Xenomai without them.

The 3.18.20-x86-9 patch for example works just fine, and the only function I see that's related to e6b81a0ce7fb86cf1f1db9f80b982c9b5f95c4c1in that patch is __ipipe_trap_prologue.

I only took a quick glance at any of this so don't mind me, but all those trapnrs weren't added to entry_64.S previously, and there wasn't massive breakage everywhere.

Assembly isn't my thing so my best bet is to just use whatever worked before, but if the fix is sufficient, then never mind. :)

Alec


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ipipe 4.14][PATCH] x86: ipipe: Fix trap hooking for userspace routes
  2018-10-10 11:05 [Xenomai] [ipipe 4.14][PATCH] x86: ipipe: Fix trap hooking for userspace routes Jan Kiszka
  2018-10-13  0:56 ` Alec Ari
  2018-10-13 13:52 ` Philippe Gerum
@ 2018-10-26 12:50 ` Henning Schild
  2018-10-26 13:32   ` Jan Kiszka
  2 siblings, 1 reply; 8+ messages in thread
From: Henning Schild @ 2018-10-26 12:50 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Xenomai, Philippe Gerum

Hey,

looks like this one is for the #PF from the sigdebug smokey test. With
this patch applied i do not see the crash anymore, but the test gets
stuck.
Did it work for you, or did i get the context wrong?

Henning

Am Wed, 10 Oct 2018 13:05:28 +0200
schrieb Jan Kiszka <jan.kiszka@siemens.com>:

> Also hook into the trap path when the exception was taken over
> userspace code.
> 
> Fixes: e6b81a0ce7fb (x86: ipipe: route traps to co-kernel)
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> 
> Makes sense? I'm not feeling 100% safe yet /wrt paranoid and the
> userspace path. Should we handle this identically to the kernel path
> or not?
> 
> Eventually this should be merged into the original patch, at least on
> next major rebase.
> 
>  arch/x86/entry/entry_64.S | 80
> +++++++++++++++++++++++++++-------------------- 1 file changed, 46
> insertions(+), 34 deletions(-)
> 
> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> index f6fe849d66ed..42e31d1fddc6 100644
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -904,6 +904,46 @@ ENTRY(switch_to_thread_stack)
>  	ret
>  END(switch_to_thread_stack)
>  
> +.macro ipipe_idtentry_prologue paranoid=0 trapnr=-1
> skip_label=-invalid- +#ifdef CONFIG_IPIPE
> +	movq	EFLAGS(%rsp), %r14		/* regs->flags
> */
> +	movq	%rsp, %rdi			/* pt_regs
> pointer */
> +	movl	$\trapnr, %esi			/* trap
> number */
> +	subq	$8, %rsp
> +	movq	%rsp, %rdx			/* &flags */
> +	call	__ipipe_trap_prologue
> +	popq	%r13
> +	mov	%rax, %r12			/* save
> propagation status */
> +	.if \paranoid == 0			/* paranoid may
> not skip handler */
> +	testl	%eax, %eax
> +	jg	\skip_label			/* skip regular
> handler if > 0 */
> +	.endif
> +#endif
> +.endm
> +
> +.macro ipipe_idtentry_epilogue paranoid=0 skip_label=-invalid-
> +#ifdef CONFIG_IPIPE
> +	testl	%r12d, %r12d
> +	jnz	1000f
> +	movq	%rsp, %rdi			/* pt_regs
> pointer */
> +	movq	%r13, %rsi			/* &flags from
> prologue */
> +	movq	%r14, %rdx			/* original
> regs->flags before fixup */
> +	call	__ipipe_trap_epilogue
> +1000:
> +	.if \paranoid == 0			/* paranoid
> implies normal epilogue */
> +	testl	%r12d, %r12d
> +	jz	1001f
> +\skip_label:
> +	UNWIND_HINT_REGS
> +	DISABLE_INTERRUPTS(CLBR_ANY)
> +	testl	%ebx, %ebx	/* %ebx: return to kernel
> mode */
> +	jnz	retint_kernel_early
> +	jmp	retint_user_early
> +	.endif
> +1001:
> +#endif
> +.endm
> +
>  .macro idtentry sym do_sym has_error_code:req paranoid=0
> shift_ist=-1 trapnr=-1 ENTRY(\sym)
>  	UNWIND_HINT_IRET_REGS offset=\has_error_code*8
> @@ -940,20 +980,7 @@ ENTRY(\sym)
>  	.endif
>  	.endif
>  
> -#ifdef CONFIG_IPIPE
> -	movq	EFLAGS(%rsp), %r14		/* regs->flags
> */
> -	movq	%rsp, %rdi			/* pt_regs
> pointer */
> -	movl	$\trapnr, %esi			/* trap
> number */
> -	subq	$8, %rsp
> -	movq	%rsp, %rdx			/* &flags */
> -	call	__ipipe_trap_prologue
> -	popq	%r13
> -	mov	%rax, %r12			/* save
> propagation status */
> -	.if \paranoid == 0			/* paranoid may
> not skip handler */
> -	testl	%eax, %eax
> -	jg	98f				/* skip regular
> handler if > 0 */
> -	.endif
> -#endif
> +	ipipe_idtentry_prologue paranoid=\paranoid trapnr=\trapnr
> skip_label=kernel_skip_\@ 
>  	movq	%rsp, %rdi			/* pt_regs
> pointer */ 
> @@ -970,26 +997,7 @@ ENTRY(\sym)
>  
>  	call	\do_sym
>  
> -#ifdef CONFIG_IPIPE
> -	testl	%r12d, %r12d
> -	jnz	97f
> -	movq	%rsp, %rdi			/* pt_regs
> pointer */
> -	movq	%r13, %rsi			/* &flags from
> prologue */
> -	movq	%r14, %rdx			/* original
> regs->flags before fixup */
> -	call	__ipipe_trap_epilogue
> -97:
> -	.if \paranoid == 0			/* paranoid
> implies normal epilogue */
> -	testl	%r12d, %r12d
> -	jz	99f
> -98:
> -	UNWIND_HINT_REGS
> -	DISABLE_INTERRUPTS(CLBR_ANY)
> -	testl	%ebx, %ebx	/* %ebx: return to kernel
> mode */
> -	jnz	retint_kernel_early
> -	jmp	retint_user_early
> -	.endif
> -99:
> -#endif
> +	ipipe_idtentry_epilogue paranoid=\paranoid
> skip_label=kernel_skip_\@ 
>  	.if \shift_ist != -1
>  	addq	$EXCEPTION_STKSZ, CPU_TSS_IST(\shift_ist)
> @@ -1011,6 +1019,8 @@ ENTRY(\sym)
>  .Lfrom_usermode_switch_stack_\@:
>  	call	error_entry
>  
> +	ipipe_idtentry_prologue paranoid=\paranoid trapnr=\trapnr
> skip_label=user_skip_\@ +
>  	movq	%rsp, %rdi			/* pt_regs
> pointer */ 
>  	.if \has_error_code
> @@ -1022,6 +1032,8 @@ ENTRY(\sym)
>  
>  	call	\do_sym
>  
> +	ipipe_idtentry_epilogue paranoid=\paranoid
> skip_label=user_skip_\@ +
>  	jmp	error_exit
>  	.endif
>  END(\sym)



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ipipe 4.14][PATCH] x86: ipipe: Fix trap hooking for userspace routes
  2018-10-26 12:50 ` Henning Schild
@ 2018-10-26 13:32   ` Jan Kiszka
  2018-10-29  9:33     ` Henning Schild
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Kiszka @ 2018-10-26 13:32 UTC (permalink / raw)
  To: Henning Schild; +Cc: Xenomai, Philippe Gerum

On 26.10.18 13:50, Henning Schild wrote:
> Hey,
> 
> looks like this one is for the #PF from the sigdebug smokey test. With
> this patch applied i do not see the crash anymore, but the test gets
> stuck.
> Did it work for you, or did i get the context wrong?

Yes, this solved the issue for me, and I was able to finish the test. But that 
might be related to configuration variations (I think I sent my configuration 
earlier to the list).

Jan

> 
> Henning
> 
> Am Wed, 10 Oct 2018 13:05:28 +0200
> schrieb Jan Kiszka <jan.kiszka@siemens.com>:
> 
>> Also hook into the trap path when the exception was taken over
>> userspace code.
>>
>> Fixes: e6b81a0ce7fb (x86: ipipe: route traps to co-kernel)
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>>
>> Makes sense? I'm not feeling 100% safe yet /wrt paranoid and the
>> userspace path. Should we handle this identically to the kernel path
>> or not?
>>
>> Eventually this should be merged into the original patch, at least on
>> next major rebase.
>>
>>   arch/x86/entry/entry_64.S | 80
>> +++++++++++++++++++++++++++-------------------- 1 file changed, 46
>> insertions(+), 34 deletions(-)
>>
>> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
>> index f6fe849d66ed..42e31d1fddc6 100644
>> --- a/arch/x86/entry/entry_64.S
>> +++ b/arch/x86/entry/entry_64.S
>> @@ -904,6 +904,46 @@ ENTRY(switch_to_thread_stack)
>>   	ret
>>   END(switch_to_thread_stack)
>>   
>> +.macro ipipe_idtentry_prologue paranoid=0 trapnr=-1
>> skip_label=-invalid- +#ifdef CONFIG_IPIPE
>> +	movq	EFLAGS(%rsp), %r14		/* regs->flags
>> */
>> +	movq	%rsp, %rdi			/* pt_regs
>> pointer */
>> +	movl	$\trapnr, %esi			/* trap
>> number */
>> +	subq	$8, %rsp
>> +	movq	%rsp, %rdx			/* &flags */
>> +	call	__ipipe_trap_prologue
>> +	popq	%r13
>> +	mov	%rax, %r12			/* save
>> propagation status */
>> +	.if \paranoid == 0			/* paranoid may
>> not skip handler */
>> +	testl	%eax, %eax
>> +	jg	\skip_label			/* skip regular
>> handler if > 0 */
>> +	.endif
>> +#endif
>> +.endm
>> +
>> +.macro ipipe_idtentry_epilogue paranoid=0 skip_label=-invalid-
>> +#ifdef CONFIG_IPIPE
>> +	testl	%r12d, %r12d
>> +	jnz	1000f
>> +	movq	%rsp, %rdi			/* pt_regs
>> pointer */
>> +	movq	%r13, %rsi			/* &flags from
>> prologue */
>> +	movq	%r14, %rdx			/* original
>> regs->flags before fixup */
>> +	call	__ipipe_trap_epilogue
>> +1000:
>> +	.if \paranoid == 0			/* paranoid
>> implies normal epilogue */
>> +	testl	%r12d, %r12d
>> +	jz	1001f
>> +\skip_label:
>> +	UNWIND_HINT_REGS
>> +	DISABLE_INTERRUPTS(CLBR_ANY)
>> +	testl	%ebx, %ebx	/* %ebx: return to kernel
>> mode */
>> +	jnz	retint_kernel_early
>> +	jmp	retint_user_early
>> +	.endif
>> +1001:
>> +#endif
>> +.endm
>> +
>>   .macro idtentry sym do_sym has_error_code:req paranoid=0
>> shift_ist=-1 trapnr=-1 ENTRY(\sym)
>>   	UNWIND_HINT_IRET_REGS offset=\has_error_code*8
>> @@ -940,20 +980,7 @@ ENTRY(\sym)
>>   	.endif
>>   	.endif
>>   
>> -#ifdef CONFIG_IPIPE
>> -	movq	EFLAGS(%rsp), %r14		/* regs->flags
>> */
>> -	movq	%rsp, %rdi			/* pt_regs
>> pointer */
>> -	movl	$\trapnr, %esi			/* trap
>> number */
>> -	subq	$8, %rsp
>> -	movq	%rsp, %rdx			/* &flags */
>> -	call	__ipipe_trap_prologue
>> -	popq	%r13
>> -	mov	%rax, %r12			/* save
>> propagation status */
>> -	.if \paranoid == 0			/* paranoid may
>> not skip handler */
>> -	testl	%eax, %eax
>> -	jg	98f				/* skip regular
>> handler if > 0 */
>> -	.endif
>> -#endif
>> +	ipipe_idtentry_prologue paranoid=\paranoid trapnr=\trapnr
>> skip_label=kernel_skip_\@
>>   	movq	%rsp, %rdi			/* pt_regs
>> pointer */
>> @@ -970,26 +997,7 @@ ENTRY(\sym)
>>   
>>   	call	\do_sym
>>   
>> -#ifdef CONFIG_IPIPE
>> -	testl	%r12d, %r12d
>> -	jnz	97f
>> -	movq	%rsp, %rdi			/* pt_regs
>> pointer */
>> -	movq	%r13, %rsi			/* &flags from
>> prologue */
>> -	movq	%r14, %rdx			/* original
>> regs->flags before fixup */
>> -	call	__ipipe_trap_epilogue
>> -97:
>> -	.if \paranoid == 0			/* paranoid
>> implies normal epilogue */
>> -	testl	%r12d, %r12d
>> -	jz	99f
>> -98:
>> -	UNWIND_HINT_REGS
>> -	DISABLE_INTERRUPTS(CLBR_ANY)
>> -	testl	%ebx, %ebx	/* %ebx: return to kernel
>> mode */
>> -	jnz	retint_kernel_early
>> -	jmp	retint_user_early
>> -	.endif
>> -99:
>> -#endif
>> +	ipipe_idtentry_epilogue paranoid=\paranoid
>> skip_label=kernel_skip_\@
>>   	.if \shift_ist != -1
>>   	addq	$EXCEPTION_STKSZ, CPU_TSS_IST(\shift_ist)
>> @@ -1011,6 +1019,8 @@ ENTRY(\sym)
>>   .Lfrom_usermode_switch_stack_\@:
>>   	call	error_entry
>>   
>> +	ipipe_idtentry_prologue paranoid=\paranoid trapnr=\trapnr
>> skip_label=user_skip_\@ +
>>   	movq	%rsp, %rdi			/* pt_regs
>> pointer */
>>   	.if \has_error_code
>> @@ -1022,6 +1032,8 @@ ENTRY(\sym)
>>   
>>   	call	\do_sym
>>   
>> +	ipipe_idtentry_epilogue paranoid=\paranoid
>> skip_label=user_skip_\@ +
>>   	jmp	error_exit
>>   	.endif
>>   END(\sym)
> 

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ipipe 4.14][PATCH] x86: ipipe: Fix trap hooking for userspace routes
  2018-10-26 13:32   ` Jan Kiszka
@ 2018-10-29  9:33     ` Henning Schild
  0 siblings, 0 replies; 8+ messages in thread
From: Henning Schild @ 2018-10-29  9:33 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Xenomai, Philippe Gerum

Am Fri, 26 Oct 2018 14:32:36 +0100
schrieb Jan Kiszka <jan.kiszka@siemens.com>:

> On 26.10.18 13:50, Henning Schild wrote:
> > Hey,
> > 
> > looks like this one is for the #PF from the sigdebug smokey test.
> > With this patch applied i do not see the crash anymore, but the
> > test gets stuck.
> > Did it work for you, or did i get the context wrong?  
> 
> Yes, this solved the issue for me, and I was able to finish the test.
> But that might be related to configuration variations (I think I sent
> my configuration earlier to the list).

I was still using a modified copy of the test, looks like it works just
fine. I guess we can release if we are ok with not supporting x86_32
for now ... or for the future.

Henning

> Jan
> 
> > 
> > Henning
> > 
> > Am Wed, 10 Oct 2018 13:05:28 +0200
> > schrieb Jan Kiszka <jan.kiszka@siemens.com>:
> >   
> >> Also hook into the trap path when the exception was taken over
> >> userspace code.
> >>
> >> Fixes: e6b81a0ce7fb (x86: ipipe: route traps to co-kernel)
> >> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> >> ---
> >>
> >> Makes sense? I'm not feeling 100% safe yet /wrt paranoid and the
> >> userspace path. Should we handle this identically to the kernel
> >> path or not?
> >>
> >> Eventually this should be merged into the original patch, at least
> >> on next major rebase.
> >>
> >>   arch/x86/entry/entry_64.S | 80
> >> +++++++++++++++++++++++++++-------------------- 1 file changed, 46
> >> insertions(+), 34 deletions(-)
> >>
> >> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> >> index f6fe849d66ed..42e31d1fddc6 100644
> >> --- a/arch/x86/entry/entry_64.S
> >> +++ b/arch/x86/entry/entry_64.S
> >> @@ -904,6 +904,46 @@ ENTRY(switch_to_thread_stack)
> >>   	ret
> >>   END(switch_to_thread_stack)
> >>   
> >> +.macro ipipe_idtentry_prologue paranoid=0 trapnr=-1
> >> skip_label=-invalid- +#ifdef CONFIG_IPIPE
> >> +	movq	EFLAGS(%rsp), %r14		/*
> >> regs->flags */
> >> +	movq	%rsp, %rdi			/* pt_regs
> >> pointer */
> >> +	movl	$\trapnr, %esi			/* trap
> >> number */
> >> +	subq	$8, %rsp
> >> +	movq	%rsp, %rdx			/* &flags */
> >> +	call	__ipipe_trap_prologue
> >> +	popq	%r13
> >> +	mov	%rax, %r12			/* save
> >> propagation status */
> >> +	.if \paranoid == 0			/* paranoid may
> >> not skip handler */
> >> +	testl	%eax, %eax
> >> +	jg	\skip_label			/* skip
> >> regular handler if > 0 */
> >> +	.endif
> >> +#endif
> >> +.endm
> >> +
> >> +.macro ipipe_idtentry_epilogue paranoid=0 skip_label=-invalid-
> >> +#ifdef CONFIG_IPIPE
> >> +	testl	%r12d, %r12d
> >> +	jnz	1000f
> >> +	movq	%rsp, %rdi			/* pt_regs
> >> pointer */
> >> +	movq	%r13, %rsi			/* &flags
> >> from prologue */
> >> +	movq	%r14, %rdx			/* original
> >> regs->flags before fixup */
> >> +	call	__ipipe_trap_epilogue
> >> +1000:
> >> +	.if \paranoid == 0			/* paranoid
> >> implies normal epilogue */
> >> +	testl	%r12d, %r12d
> >> +	jz	1001f
> >> +\skip_label:
> >> +	UNWIND_HINT_REGS
> >> +	DISABLE_INTERRUPTS(CLBR_ANY)
> >> +	testl	%ebx, %ebx	/* %ebx: return to kernel
> >> mode */
> >> +	jnz	retint_kernel_early
> >> +	jmp	retint_user_early
> >> +	.endif
> >> +1001:
> >> +#endif
> >> +.endm
> >> +
> >>   .macro idtentry sym do_sym has_error_code:req paranoid=0
> >> shift_ist=-1 trapnr=-1 ENTRY(\sym)
> >>   	UNWIND_HINT_IRET_REGS offset=\has_error_code*8
> >> @@ -940,20 +980,7 @@ ENTRY(\sym)
> >>   	.endif
> >>   	.endif
> >>   
> >> -#ifdef CONFIG_IPIPE
> >> -	movq	EFLAGS(%rsp), %r14		/*
> >> regs->flags */
> >> -	movq	%rsp, %rdi			/* pt_regs
> >> pointer */
> >> -	movl	$\trapnr, %esi			/* trap
> >> number */
> >> -	subq	$8, %rsp
> >> -	movq	%rsp, %rdx			/* &flags */
> >> -	call	__ipipe_trap_prologue
> >> -	popq	%r13
> >> -	mov	%rax, %r12			/* save
> >> propagation status */
> >> -	.if \paranoid == 0			/* paranoid may
> >> not skip handler */
> >> -	testl	%eax, %eax
> >> -	jg	98f				/* skip
> >> regular handler if > 0 */
> >> -	.endif
> >> -#endif
> >> +	ipipe_idtentry_prologue paranoid=\paranoid trapnr=\trapnr
> >> skip_label=kernel_skip_\@
> >>   	movq	%rsp, %rdi			/* pt_regs
> >> pointer */
> >> @@ -970,26 +997,7 @@ ENTRY(\sym)
> >>   
> >>   	call	\do_sym
> >>   
> >> -#ifdef CONFIG_IPIPE
> >> -	testl	%r12d, %r12d
> >> -	jnz	97f
> >> -	movq	%rsp, %rdi			/* pt_regs
> >> pointer */
> >> -	movq	%r13, %rsi			/* &flags
> >> from prologue */
> >> -	movq	%r14, %rdx			/* original
> >> regs->flags before fixup */
> >> -	call	__ipipe_trap_epilogue
> >> -97:
> >> -	.if \paranoid == 0			/* paranoid
> >> implies normal epilogue */
> >> -	testl	%r12d, %r12d
> >> -	jz	99f
> >> -98:
> >> -	UNWIND_HINT_REGS
> >> -	DISABLE_INTERRUPTS(CLBR_ANY)
> >> -	testl	%ebx, %ebx	/* %ebx: return to kernel
> >> mode */
> >> -	jnz	retint_kernel_early
> >> -	jmp	retint_user_early
> >> -	.endif
> >> -99:
> >> -#endif
> >> +	ipipe_idtentry_epilogue paranoid=\paranoid
> >> skip_label=kernel_skip_\@
> >>   	.if \shift_ist != -1
> >>   	addq	$EXCEPTION_STKSZ, CPU_TSS_IST(\shift_ist)
> >> @@ -1011,6 +1019,8 @@ ENTRY(\sym)
> >>   .Lfrom_usermode_switch_stack_\@:
> >>   	call	error_entry
> >>   
> >> +	ipipe_idtentry_prologue paranoid=\paranoid trapnr=\trapnr
> >> skip_label=user_skip_\@ +
> >>   	movq	%rsp, %rdi			/* pt_regs
> >> pointer */
> >>   	.if \has_error_code
> >> @@ -1022,6 +1032,8 @@ ENTRY(\sym)
> >>   
> >>   	call	\do_sym
> >>   
> >> +	ipipe_idtentry_epilogue paranoid=\paranoid
> >> skip_label=user_skip_\@ +
> >>   	jmp	error_exit
> >>   	.endif
> >>   END(\sym)  
> >   
> 



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-10-29  9:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-10 11:05 [Xenomai] [ipipe 4.14][PATCH] x86: ipipe: Fix trap hooking for userspace routes Jan Kiszka
2018-10-13  0:56 ` Alec Ari
2018-10-15 11:18   ` Jan Kiszka
2018-10-15 21:01     ` Alec Ari
2018-10-13 13:52 ` Philippe Gerum
2018-10-26 12:50 ` Henning Schild
2018-10-26 13:32   ` Jan Kiszka
2018-10-29  9:33     ` Henning Schild

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.