From: Jan Kiszka <jan.kiszka@siemens.com>
To: Henning Schild <henning.schild@siemens.com>
Cc: Xenomai <xenomai@xenomai.org>, Philippe Gerum <rpm@xenomai.org>
Subject: Re: [ipipe 4.14][PATCH] x86: ipipe: Fix trap hooking for userspace routes
Date: Fri, 26 Oct 2018 14:32:36 +0100 [thread overview]
Message-ID: <ce687274-047c-79d3-be0d-704a9834d19e@siemens.com> (raw)
In-Reply-To: <20181026145035.3c031bb5@md1pvb1c.ad001.siemens.net>
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
next prev parent reply other threads:[~2018-10-26 13:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2018-10-29 9:33 ` Henning Schild
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ce687274-047c-79d3-be0d-704a9834d19e@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=henning.schild@siemens.com \
--cc=rpm@xenomai.org \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.