mbox series

[0/3] riscv: add support for restartable sequence

Message ID 1572919114-3886-1-git-send-email-vincent.chen@sifive.com (mailing list archive)
Headers show
Series riscv: add support for restartable sequence | expand

Message

Vincent Chen Nov. 5, 2019, 1:58 a.m. UTC
Add RSEQ, restartable sequence, support and related selftest to RISCV.
The Kconfig option HAVE_REGS_AND_STACK_ACCESS_API is also required by
RSEQ because RSEQ will modify the content of pt_regs.sepc through
instruction_pointer_set() during the fixup procedure. In order to select
the config HAVE_REGS_AND_STACK_ACCESS_API, the missing APIs for accessing
pt_regs are also added in this patch set.
  
The relevant RSEQ tests in kselftest require the Binutils patch "RISC-V:
Fix linker problems with TLS copy relocs" to avoid placing
PREINIT_ARRAY and TLS variable of librseq.so at the same address.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=3e7bd7f24146f162565edf878840449f36a8d974
A segmental fault will happen if the Binutils misses this patch.



Vincent Chen (3):
  riscv: add required functions to enable HAVE_REGS_AND_STACK_ACCESS_API
  riscv: Add support for restartable sequence
  rseq/selftests: Add support for riscv

 arch/riscv/Kconfig                        |   2 +
 arch/riscv/include/asm/ptrace.h           |  29 +-
 arch/riscv/kernel/entry.S                 |   4 +
 arch/riscv/kernel/ptrace.c                |  99 +++++
 arch/riscv/kernel/signal.c                |   3 +
 tools/testing/selftests/rseq/param_test.c |  23 ++
 tools/testing/selftests/rseq/rseq-riscv.h | 622 ++++++++++++++++++++++++++++++
 tools/testing/selftests/rseq/rseq.h       |   2 +
 8 files changed, 783 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/rseq/rseq-riscv.h

Comments

Palmer Dabbelt Jan. 13, 2020, 6:47 p.m. UTC | #1
On Mon, 04 Nov 2019 17:58:31 PST (-0800), vincent.chen@sifive.com wrote:
> Add RSEQ, restartable sequence, support and related selftest to RISCV.
> The Kconfig option HAVE_REGS_AND_STACK_ACCESS_API is also required by
> RSEQ because RSEQ will modify the content of pt_regs.sepc through
> instruction_pointer_set() during the fixup procedure. In order to select
> the config HAVE_REGS_AND_STACK_ACCESS_API, the missing APIs for accessing
> pt_regs are also added in this patch set.
>
> The relevant RSEQ tests in kselftest require the Binutils patch "RISC-V:
> Fix linker problems with TLS copy relocs" to avoid placing
> PREINIT_ARRAY and TLS variable of librseq.so at the same address.
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=3e7bd7f24146f162565edf878840449f36a8d974
> A segmental fault will happen if the Binutils misses this patch.
>
>
>
> Vincent Chen (3):
>   riscv: add required functions to enable HAVE_REGS_AND_STACK_ACCESS_API
>   riscv: Add support for restartable sequence
>   rseq/selftests: Add support for riscv
>
>  arch/riscv/Kconfig                        |   2 +
>  arch/riscv/include/asm/ptrace.h           |  29 +-
>  arch/riscv/kernel/entry.S                 |   4 +
>  arch/riscv/kernel/ptrace.c                |  99 +++++
>  arch/riscv/kernel/signal.c                |   3 +
>  tools/testing/selftests/rseq/param_test.c |  23 ++
>  tools/testing/selftests/rseq/rseq-riscv.h | 622 ++++++++++++++++++++++++++++++
>  tools/testing/selftests/rseq/rseq.h       |   2 +
>  8 files changed, 783 insertions(+), 1 deletion(-)
>  create mode 100644 tools/testing/selftests/rseq/rseq-riscv.h

This, with Paul's updated patch 1, isn't building on my end:

In file included from <command-line>:
arch/riscv/kernel/ptrace.c:137:18: error: ‘struct pt_regs’ has no member named ‘sepc’; did you mean ‘epc’?
  REG_OFFSET_NAME(sepc),
                  ^~~~
././include/linux/compiler_types.h:129:57: note: in definition of macro ‘__compiler_offsetof’
 #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
                                                         ^
arch/riscv/kernel/ptrace.c:133:51: note: in expansion of macro ‘offsetof’
 #define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
                                                   ^~~~~~~~
arch/riscv/kernel/ptrace.c:137:2: note: in expansion of macro ‘REG_OFFSET_NAME’
  REG_OFFSET_NAME(sepc),
  ^~~~~~~~~~~~~~~
arch/riscv/kernel/ptrace.c:169:18: error: ‘struct pt_regs’ has no member named ‘sstatus’; did you mean ‘status’?
  REG_OFFSET_NAME(sstatus),
                  ^~~~~~~
././include/linux/compiler_types.h:129:57: note: in definition of macro ‘__compiler_offsetof’
 #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
                                                         ^
arch/riscv/kernel/ptrace.c:133:51: note: in expansion of macro ‘offsetof’
 #define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
                                                   ^~~~~~~~
arch/riscv/kernel/ptrace.c:169:2: note: in expansion of macro ‘REG_OFFSET_NAME’
  REG_OFFSET_NAME(sstatus),
  ^~~~~~~~~~~~~~~
arch/riscv/kernel/ptrace.c:170:18: error: ‘struct pt_regs’ has no member named ‘sbadaddr’; did you mean ‘badaddr’?
  REG_OFFSET_NAME(sbadaddr),
                  ^~~~~~~~
././include/linux/compiler_types.h:129:57: note: in definition of macro ‘__compiler_offsetof’
 #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
                                                         ^
arch/riscv/kernel/ptrace.c:133:51: note: in expansion of macro ‘offsetof’
 #define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
                                                   ^~~~~~~~
arch/riscv/kernel/ptrace.c:170:2: note: in expansion of macro ‘REG_OFFSET_NAME’
  REG_OFFSET_NAME(sbadaddr),
  ^~~~~~~~~~~~~~~
arch/riscv/kernel/ptrace.c:171:18: error: ‘struct pt_regs’ has no member named ‘scause’; did you mean ‘cause’?
  REG_OFFSET_NAME(scause),
                  ^~~~~~
././include/linux/compiler_types.h:129:57: note: in definition of macro ‘__compiler_offsetof’
 #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
                                                         ^
arch/riscv/kernel/ptrace.c:133:51: note: in expansion of macro ‘offsetof’
 #define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
                                                   ^~~~~~~~
arch/riscv/kernel/ptrace.c:171:2: note: in expansion of macro ‘REG_OFFSET_NAME’
  REG_OFFSET_NAME(scause),
Vincent Chen March 9, 2020, 2:53 a.m. UTC | #2
On Tue, Jan 14, 2020 at 2:47 AM Palmer Dabbelt <palmerdabbelt@google.com> wrote:
>
> On Mon, 04 Nov 2019 17:58:31 PST (-0800), vincent.chen@sifive.com wrote:
> > Add RSEQ, restartable sequence, support and related selftest to RISCV.
> > The Kconfig option HAVE_REGS_AND_STACK_ACCESS_API is also required by
> > RSEQ because RSEQ will modify the content of pt_regs.sepc through
> > instruction_pointer_set() during the fixup procedure. In order to select
> > the config HAVE_REGS_AND_STACK_ACCESS_API, the missing APIs for accessing
> > pt_regs are also added in this patch set.
> >
> > The relevant RSEQ tests in kselftest require the Binutils patch "RISC-V:
> > Fix linker problems with TLS copy relocs" to avoid placing
> > PREINIT_ARRAY and TLS variable of librseq.so at the same address.
> > https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=3e7bd7f24146f162565edf878840449f36a8d974
> > A segmental fault will happen if the Binutils misses this patch.
> >
> >
> >
> > Vincent Chen (3):
> >   riscv: add required functions to enable HAVE_REGS_AND_STACK_ACCESS_API
> >   riscv: Add support for restartable sequence
> >   rseq/selftests: Add support for riscv
> >
> >  arch/riscv/Kconfig                        |   2 +
> >  arch/riscv/include/asm/ptrace.h           |  29 +-
> >  arch/riscv/kernel/entry.S                 |   4 +
> >  arch/riscv/kernel/ptrace.c                |  99 +++++
> >  arch/riscv/kernel/signal.c                |   3 +
> >  tools/testing/selftests/rseq/param_test.c |  23 ++
> >  tools/testing/selftests/rseq/rseq-riscv.h | 622 ++++++++++++++++++++++++++++++
> >  tools/testing/selftests/rseq/rseq.h       |   2 +
> >  8 files changed, 783 insertions(+), 1 deletion(-)
> >  create mode 100644 tools/testing/selftests/rseq/rseq-riscv.h
>
> This, with Paul's updated patch 1, isn't building on my end:
>
> In file included from <command-line>:
> arch/riscv/kernel/ptrace.c:137:18: error: ‘struct pt_regs’ has no member named ‘sepc’; did you mean ‘epc’?
>   REG_OFFSET_NAME(sepc),
>                   ^~~~
> ././include/linux/compiler_types.h:129:57: note: in definition of macro ‘__compiler_offsetof’
>  #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
>                                                          ^
> arch/riscv/kernel/ptrace.c:133:51: note: in expansion of macro ‘offsetof’
>  #define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
>                                                    ^~~~~~~~
> arch/riscv/kernel/ptrace.c:137:2: note: in expansion of macro ‘REG_OFFSET_NAME’
>   REG_OFFSET_NAME(sepc),
>   ^~~~~~~~~~~~~~~
> arch/riscv/kernel/ptrace.c:169:18: error: ‘struct pt_regs’ has no member named ‘sstatus’; did you mean ‘status’?
>   REG_OFFSET_NAME(sstatus),
>                   ^~~~~~~
> ././include/linux/compiler_types.h:129:57: note: in definition of macro ‘__compiler_offsetof’
>  #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
>                                                          ^
> arch/riscv/kernel/ptrace.c:133:51: note: in expansion of macro ‘offsetof’
>  #define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
>                                                    ^~~~~~~~
> arch/riscv/kernel/ptrace.c:169:2: note: in expansion of macro ‘REG_OFFSET_NAME’
>   REG_OFFSET_NAME(sstatus),
>   ^~~~~~~~~~~~~~~
> arch/riscv/kernel/ptrace.c:170:18: error: ‘struct pt_regs’ has no member named ‘sbadaddr’; did you mean ‘badaddr’?
>   REG_OFFSET_NAME(sbadaddr),
>                   ^~~~~~~~
> ././include/linux/compiler_types.h:129:57: note: in definition of macro ‘__compiler_offsetof’
>  #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
>                                                          ^
> arch/riscv/kernel/ptrace.c:133:51: note: in expansion of macro ‘offsetof’
>  #define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
>                                                    ^~~~~~~~
> arch/riscv/kernel/ptrace.c:170:2: note: in expansion of macro ‘REG_OFFSET_NAME’
>   REG_OFFSET_NAME(sbadaddr),
>   ^~~~~~~~~~~~~~~
> arch/riscv/kernel/ptrace.c:171:18: error: ‘struct pt_regs’ has no member named ‘scause’; did you mean ‘cause’?
>   REG_OFFSET_NAME(scause),
>                   ^~~~~~
> ././include/linux/compiler_types.h:129:57: note: in definition of macro ‘__compiler_offsetof’
>  #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
>                                                          ^
> arch/riscv/kernel/ptrace.c:133:51: note: in expansion of macro ‘offsetof’
>  #define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
>                                                    ^~~~~~~~
> arch/riscv/kernel/ptrace.c:171:2: note: in expansion of macro ‘REG_OFFSET_NAME’
>   REG_OFFSET_NAME(scause),

Sorry, I really missed this email. I will fix these errors and resend
this patch set. Thank you