mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Stian Halseth <stian@itx.no>
Cc: Andreas Larsson <andreas@gaisler.com>,
	"David S . Miller" <davem@davemloft.net>,
	sparclinux@vger.kernel.org, Andy Lutomirski <luto@amacapital.net>,
	Will Drewry <wad@chromium.org>, Oleg Nesterov <oleg@redhat.com>,
	Shuah Khan <shuah@kernel.org>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Subject: Re: [PATCH 2/2] selftests/seccomp: add sparc64 support
Date: Tue, 1 Sep 2026 17:02:16 -0700	[thread overview]
Message-ID: <202609011700.E21C37761@keescook> (raw)
In-Reply-To: <20260901220811.3369666-3-stian@itx.no>

On Wed, Sep 02, 2026 at 12:08:11AM +0200, Stian Halseth wrote:
> sparc64 now selects HAVE_ARCH_SECCOMP_FILTER, so teach seccomp_bpf
> how to read and write its registers: the syscall number lives in %g1
> and the return value in %o0, addressed through the NT_PRSTATUS regset
> (16 u_regs, 16 window registers, then tstate/tpc/tnpc/y).
> 
> Errors are signaled by the carry bit in tstate with a positive errno
> value in %o0, so provide a SYSCALL_RET_SET that maintains both, and
> mark the arch SYSCALL_RET_SET_ON_PTRACE_EXIT since a return value
> poked at entry would be overwritten by the syscall skip path, as on
> powerpc.
> 
> Passes 95 of 95 on an UltraSPARC T4-1 (16 skipped for missing
> optional features such as uprobes).

Thanks for getting the working on sparc! :)

> 
> Link: https://github.com/sparclinux/issues/issues/11
> Signed-off-by: Stian Halseth <stian@itx.no>
> ---
>  tools/testing/selftests/seccomp/seccomp_bpf.c | 35 +++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
> index 0622bc2acad4..30b777f357d8 100644
> --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
> +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
> @@ -1872,6 +1872,41 @@ TEST_F(TRACE_poke, getpid_runs_normally)
>  # define ARCH_REGS		struct user_regs_struct
>  # define SYSCALL_NUM(_regs)	(_regs).orig_d0
>  # define SYSCALL_RET(_regs)	(_regs).d0
> +#elif defined(__sparc__) && defined(__arch64__)
> +/*
> + * The NT_PRSTATUS regset: %g0-%g7 and %o0-%o7, the 16 window
> + * registers as read back from the stack, then tstate, tpc, tnpc
> + * and y.
> + */
> +struct sparc64_user_regs {
> +	__u64 u_regs[16];
> +	__u64 window[16];
> +	__u64 tstate;
> +	__u64 tpc;
> +	__u64 tnpc;
> +	__u64 y;
> +};
> +# define ARCH_REGS		struct sparc64_user_regs

Is struct sparc64_user_regs not exported to userspace anywhere? We
haven't normally needed to put the raw user_regs struct definition into
the test before.

But beyond that question, looks good!

-Kees

-- 
Kees Cook

  reply	other threads:[~2026-09-02  0:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 22:08 [PATCH 0/2] sparc64: add seccomp filter support Stian Halseth
2026-09-01 22:08 ` [PATCH 1/2] " Stian Halseth
2026-09-01 22:08 ` [PATCH 2/2] selftests/seccomp: add sparc64 support Stian Halseth
2026-09-02  0:02   ` Kees Cook [this message]
2026-09-02  7:15     ` Stian Halseth
2026-09-02  7:21       ` Stian Halseth

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=202609011700.E21C37761@keescook \
    --to=kees@kernel.org \
    --cc=andreas@gaisler.com \
    --cc=davem@davemloft.net \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=oleg@redhat.com \
    --cc=shuah@kernel.org \
    --cc=sparclinux@vger.kernel.org \
    --cc=stian@itx.no \
    --cc=wad@chromium.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®