libseccomp icon indicating copy to clipboard operation
libseccomp copied to clipboard

RFE: Add support for SPARC

Open glaubitz opened this issue 4 months ago • 19 comments

This PR adds support for both 32-bit and 64-bit SPARC.

SPARC is one of the two remaining architectures, the other one being Alpha, that is currently not supported by libseccomp. As the kernel already supports SECCOMP on SPARC, we just have to add support to libseccomp.

glaubitz avatar Aug 24 '25 18:08 glaubitz

Coverage Status

coverage: 88.97% (-0.08%) from 89.046% when pulling 51a837accc334a6fb9124cc5b83cf8eef6c31c24 on glaubitz:sparc-support into 9b9ea8e7a173b96e59fb21e8d461365110e7b4ef on seccomp:main.

coveralls avatar Aug 24 '25 18:08 coveralls

The sparc patch looks reasonable at a quick glance. I'll try to dig up a sparc machine so that I can test it out :)

drakenclimber avatar Aug 29 '25 19:08 drakenclimber

On Aug 29, 2025, at 9:45 PM, Tom Hromatka @.> wrote:drakenclimber left a comment (seccomp/libseccomp#471) The sparc patch looks reasonable at a quick glance. I'll try to dig up a sparc machine so that I can test it out :)Message ID: @.>

Thanks!There is gcc202 in the GCC Compile Farm which is currently offline but should be back online next week after hardware maintenance.

glaubitz avatar Aug 29 '25 20:08 glaubitz

There is gcc202 in the GCC Compile Farm which is currently offline but should be back online next week after hardware maintenance.

I found a Sparc box here within Oracle (not a surprise), but I need to put a newer Linux on it. I expect that to happen next week.

If my box doesn't work out, I'll try out the gcc box.

drakenclimber avatar Sep 04 '25 12:09 drakenclimber

There is gcc202 in the GCC Compile Farm which is currently offline but should be back online next week after hardware maintenance.

I found a Sparc box here within Oracle (not a surprise), but I need to put a newer Linux on it. I expect that to happen next week.

Ah, nice. Great that this is still possible ;-).

If my box doesn't work out, I'll try out the gcc box.

The GCC porterbox is expected to return to service tomorrow (crossing fingers).

glaubitz avatar Sep 04 '25 13:09 glaubitz

I have my sparc64 box up and running.

$ lscpu
Architecture:          sparc64
  CPU op-mode(s):      32-bit, 64-bit
  Byte Order:          Big Endian
CPU(s):                256
  On-line CPU(s) list: 0-255
Model name:            SPARC-M7
  Thread(s) per core:  8
  Core(s) per socket:  32
  Socket(s):           1
  Flags:               sun4v
Caches (sum of all):
  L1d:                 4 MiB (256 instances)
  L1i:                 4 MiB (256 instances)
  L2:                  64 MiB (256 instances)

I'm getting test failures on test 36 and 37 with this patchset. I'll try and look into it later this week.

$ ./regression -b 36-sim-ipc_syscalls
=============== Mon Sep  8 10:28:33 AM EDT 2025 ===============
Regression Test Report ("regression -b 36-sim-ipc_syscalls")
 batch name: 36-sim-ipc_syscalls
 test mode:  c
 test type:  bpf-sim
 test arch:  x86
Test 36-sim-ipc_syscalls%%001-00001 result:   ERROR 36-sim-ipc_syscalls rc=33
...
$ ./regression -b 37-sim-ipc_syscalls_be
=============== Mon Sep  8 10:29:40 AM EDT 2025 ===============
Regression Test Report ("regression -b 37-sim-ipc_syscalls_be")
 batch name: 37-sim-ipc_syscalls_be
 test mode:  c
 test type:  bpf-sim
 test arch:  s390
Test 37-sim-ipc_syscalls_be%%001-00001 result:   ERROR 37-sim-ipc_syscalls_be rc=14
...

drakenclimber avatar Sep 08 '25 20:09 drakenclimber

Thanks a lot! We're having delays with our SPARC T5, so I'm glad you got a machine yourself.

FWIW, I think the Linux kernel on SPARC might need some additional fixes for seccomp. I'm looking into that as well.

glaubitz avatar Sep 08 '25 20:09 glaubitz

I found the bug that was causing tests 36 and 37 to fail. Definitely not what I expected :).

Here's the fix for those test failures:

diff --git a/src/syscalls.h b/src/syscalls.h
index b2720fc..ccdff1b 100644
--- a/src/syscalls.h
+++ b/src/syscalls.h
@@ -43,6 +43,9 @@ struct arch_syscall_table {
        /* each arch listed here must be defined in syscalls.c  */
        /* NOTE: see the warning above - BEWARE! */

+       /* NOTE: the order of the members of this structure must exactly
+        *       match the order of the columns in syscalls.csv! */
+
        int x86;
        enum scmp_kver x86_kver;
        int x86_64;
@@ -86,13 +89,13 @@ struct arch_syscall_table {
        int s390x;
        enum scmp_kver s390x_kver;

+       int sh;
+       enum scmp_kver sh_kver;
+
        int sparc;
        enum scmp_kver sparc_kver;
        int sparc64;
        enum scmp_kver sparc64_kver;
-
-       int sh;
-       enum scmp_kver sh_kver;
 };

drakenclimber avatar Sep 09 '25 16:09 drakenclimber

For completeness, I'd recommend adding sparc and sparc64 to test 37:

diff --git a/tests/37-sim-ipc_syscalls_be.c b/tests/37-sim-ipc_syscalls_be.c
index d1bd57e..118c4a8 100644
--- a/tests/37-sim-ipc_syscalls_be.c
+++ b/tests/37-sim-ipc_syscalls_be.c
@@ -51,6 +51,12 @@ int main(int argc, char *argv[])
        if (rc != 0)
                goto out;
        rc = seccomp_arch_add(ctx, SCMP_ARCH_PPC);
+       if (rc != 0)
+               goto out;
+       rc = seccomp_arch_add(ctx, SCMP_ARCH_SPARC);
+       if (rc != 0)
+               goto out;
+       rc = seccomp_arch_add(ctx, SCMP_ARCH_SPARC64);
        if (rc != 0)
                goto out;

diff --git a/tests/37-sim-ipc_syscalls_be.tests b/tests/37-sim-ipc_syscalls_be.tests
index 96a5c81..b9224e4 100644
--- a/tests/37-sim-ipc_syscalls_be.tests
+++ b/tests/37-sim-ipc_syscalls_be.tests
@@ -7,19 +7,19 @@

 test type: bpf-sim

-# Testname             Arch                    Syscall         Arg0    Arg1    Arg2    Arg3    Arg4
Arg5    Result
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             1       N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             2       N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             3       N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             4       N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             11      N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             12      N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             13      N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             14      N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             21      N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             22      N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             23      N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             24      N       N       N       N
N       ALLOW
+# Testname             Arch                                    Syscall         Arg0    Arg1    Arg2
Arg3    Arg4    Arg5    Result
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             1       N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             2       N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             3       N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             4       N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             11      N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             12      N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             13      N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             14      N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             21      N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             22      N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             23      N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             24      N       N
N       N       N       ALLOW

 test type: bpf-valgrind

drakenclimber avatar Sep 09 '25 16:09 drakenclimber

FWIW, I think the Linux kernel on SPARC might need some additional fixes for seccomp. I'm looking into that as well.

I agree. Test 52 is a test that loads a really simple seccomp filter in the kernel. It's failing in the seccomp() syscall.

$ ./regression -b 52-basic-load
=============== Tue Sep  9 06:06:17 AM EDT 2025 ===============
Regression Test Report ("regression -b 52-basic-load")
 batch name: 52-basic-load
 test mode:  c
 test type:  basic
Test 52-basic-load%%001-00001 result:   FAILURE 52-basic-load rc=127
Regression Test Summary
 tests run: 1
 tests skipped: 0
 tests passed: 0
 tests failed: 1
 tests errored: 0
============================================================

drakenclimber avatar Sep 09 '25 16:09 drakenclimber

I found the bug that was causing tests 36 and 37 to fail. Definitely not what I expected :).

Here's the fix for those test failures:

diff --git a/src/syscalls.h b/src/syscalls.h
index b2720fc..ccdff1b 100644
--- a/src/syscalls.h
+++ b/src/syscalls.h
@@ -43,6 +43,9 @@ struct arch_syscall_table {
        /* each arch listed here must be defined in syscalls.c  */
        /* NOTE: see the warning above - BEWARE! */

+       /* NOTE: the order of the members of this structure must exactly
+        *       match the order of the columns in syscalls.csv! */
+
        int x86;
        enum scmp_kver x86_kver;
        int x86_64;
@@ -86,13 +89,13 @@ struct arch_syscall_table {
        int s390x;
        enum scmp_kver s390x_kver;

+       int sh;
+       enum scmp_kver sh_kver;
+
        int sparc;
        enum scmp_kver sparc_kver;
        int sparc64;
        enum scmp_kver sparc64_kver;
-
-       int sh;
-       enum scmp_kver sh_kver;
 };

Oh, wow. I would have never guessed that. I will fix that. Thanks so much for the thorough review!

glaubitz avatar Sep 09 '25 16:09 glaubitz

For completeness, I'd recommend adding sparc and sparc64 to test 37:

diff --git a/tests/37-sim-ipc_syscalls_be.c b/tests/37-sim-ipc_syscalls_be.c
index d1bd57e..118c4a8 100644
--- a/tests/37-sim-ipc_syscalls_be.c
+++ b/tests/37-sim-ipc_syscalls_be.c
@@ -51,6 +51,12 @@ int main(int argc, char *argv[])
        if (rc != 0)
                goto out;
        rc = seccomp_arch_add(ctx, SCMP_ARCH_PPC);
+       if (rc != 0)
+               goto out;
+       rc = seccomp_arch_add(ctx, SCMP_ARCH_SPARC);
+       if (rc != 0)
+               goto out;
+       rc = seccomp_arch_add(ctx, SCMP_ARCH_SPARC64);
        if (rc != 0)
                goto out;

diff --git a/tests/37-sim-ipc_syscalls_be.tests b/tests/37-sim-ipc_syscalls_be.tests
index 96a5c81..b9224e4 100644
--- a/tests/37-sim-ipc_syscalls_be.tests
+++ b/tests/37-sim-ipc_syscalls_be.tests
@@ -7,19 +7,19 @@

 test type: bpf-sim

-# Testname             Arch                    Syscall         Arg0    Arg1    Arg2    Arg3    Arg4
Arg5    Result
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             1       N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             2       N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             3       N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             4       N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             11      N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             12      N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             13      N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             14      N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             21      N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             22      N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             23      N       N       N       N
N       ALLOW
-37-sim-ipc_syscalls_be +s390,+s390x,+ppc       ipc             24      N       N       N       N
N       ALLOW
+# Testname             Arch                                    Syscall         Arg0    Arg1    Arg2
Arg3    Arg4    Arg5    Result
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             1       N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             2       N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             3       N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             4       N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             11      N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             12      N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             13      N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             14      N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             21      N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             22      N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             23      N       N
N       N       N       ALLOW
+37-sim-ipc_syscalls_be +s390,+s390x,+ppc,+sparc,+sparc64       ipc             24      N       N
N       N       N       ALLOW

 test type: bpf-valgrind

Do I just have to modify tests/37-sim-ipc_syscalls_be.c or also tests/37-sim-ipc_syscalls_be.tests?

glaubitz avatar Sep 09 '25 16:09 glaubitz

Do I just have to modify tests/37-sim-ipc_syscalls_be.c or also tests/37-sim-ipc_syscalls_be.tests?

We'll need to modify tests/37-sim-ipc_syscalls_be.c, tests/37-sim-ipc_syscalls_be.py (which I forgot to add), and tests/37-sim-ipc_syscalls_be.tests. Here's the entire diff:

diff --git a/tests/37-sim-ipc_syscalls_be.c b/tests/37-sim-ipc_syscalls_be.c
index d1bd57e..118c4a8 100644
--- a/tests/37-sim-ipc_syscalls_be.c
+++ b/tests/37-sim-ipc_syscalls_be.c
@@ -51,6 +51,12 @@ int main(int argc, char *argv[])
 	if (rc != 0)
 		goto out;
 	rc = seccomp_arch_add(ctx, SCMP_ARCH_PPC);
+	if (rc != 0)
+		goto out;
+	rc = seccomp_arch_add(ctx, SCMP_ARCH_SPARC);
+	if (rc != 0)
+		goto out;
+	rc = seccomp_arch_add(ctx, SCMP_ARCH_SPARC64);
 	if (rc != 0)
 		goto out;
 
diff --git a/tests/37-sim-ipc_syscalls_be.py b/tests/37-sim-ipc_syscalls_be.py
index 18a09d0..34b0201 100755
--- a/tests/37-sim-ipc_syscalls_be.py
+++ b/tests/37-sim-ipc_syscalls_be.py
@@ -34,6 +34,8 @@ def test(args):
     f.add_arch(Arch("s390"))
     f.add_arch(Arch("s390x"))
     f.add_arch(Arch("ppc"))
+    f.add_arch(Arch("sparc"))
+    f.add_arch(Arch("sparc64"))
     f.add_rule(ALLOW, "semop")
     f.add_rule(ALLOW, "semtimedop")
     f.add_rule(ALLOW, "semget")
diff --git a/tests/37-sim-ipc_syscalls_be.tests b/tests/37-sim-ipc_syscalls_be.tests
index 96a5c81..b9224e4 100644
--- a/tests/37-sim-ipc_syscalls_be.tests
+++ b/tests/37-sim-ipc_syscalls_be.tests
@@ -7,19 +7,19 @@
 
 test type: bpf-sim
 
-# Testname		Arch			Syscall		Arg0	Arg1	Arg2	Arg3	Arg4	Arg5	Result
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		1	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		2	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		3	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		4	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		11	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		12	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		13	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		14	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		21	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		22	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		23	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		24	N	N	N	N	N	ALLOW
+# Testname		Arch					Syscall		Arg0	Arg1	Arg2	Arg3	Arg4	Arg5	Result
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		1	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		2	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		3	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		4	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		11	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		12	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		13	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		14	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		21	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		22	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		23	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		24	N	N	N	N	N	ALLOW
 
 test type: bpf-valgrind

drakenclimber avatar Sep 09 '25 16:09 drakenclimber

Do I just have to modify tests/37-sim-ipc_syscalls_be.c or also tests/37-sim-ipc_syscalls_be.tests?

We'll need to modify tests/37-sim-ipc_syscalls_be.c, tests/37-sim-ipc_syscalls_be.py (which I forgot to add), and tests/37-sim-ipc_syscalls_be.tests. Here's the entire diff:

diff --git a/tests/37-sim-ipc_syscalls_be.c b/tests/37-sim-ipc_syscalls_be.c
index d1bd57e..118c4a8 100644
--- a/tests/37-sim-ipc_syscalls_be.c
+++ b/tests/37-sim-ipc_syscalls_be.c
@@ -51,6 +51,12 @@ int main(int argc, char *argv[])
 	if (rc != 0)
 		goto out;
 	rc = seccomp_arch_add(ctx, SCMP_ARCH_PPC);
+	if (rc != 0)
+		goto out;
+	rc = seccomp_arch_add(ctx, SCMP_ARCH_SPARC);
+	if (rc != 0)
+		goto out;
+	rc = seccomp_arch_add(ctx, SCMP_ARCH_SPARC64);
 	if (rc != 0)
 		goto out;
 
diff --git a/tests/37-sim-ipc_syscalls_be.py b/tests/37-sim-ipc_syscalls_be.py
index 18a09d0..34b0201 100755
--- a/tests/37-sim-ipc_syscalls_be.py
+++ b/tests/37-sim-ipc_syscalls_be.py
@@ -34,6 +34,8 @@ def test(args):
     f.add_arch(Arch("s390"))
     f.add_arch(Arch("s390x"))
     f.add_arch(Arch("ppc"))
+    f.add_arch(Arch("sparc"))
+    f.add_arch(Arch("sparc64"))
     f.add_rule(ALLOW, "semop")
     f.add_rule(ALLOW, "semtimedop")
     f.add_rule(ALLOW, "semget")
diff --git a/tests/37-sim-ipc_syscalls_be.tests b/tests/37-sim-ipc_syscalls_be.tests
index 96a5c81..b9224e4 100644
--- a/tests/37-sim-ipc_syscalls_be.tests
+++ b/tests/37-sim-ipc_syscalls_be.tests
@@ -7,19 +7,19 @@
 
 test type: bpf-sim
 
-# Testname		Arch			Syscall		Arg0	Arg1	Arg2	Arg3	Arg4	Arg5	Result
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		1	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		2	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		3	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		4	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		11	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		12	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		13	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		14	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		21	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		22	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		23	N	N	N	N	N	ALLOW
-37-sim-ipc_syscalls_be	+s390,+s390x,+ppc	ipc		24	N	N	N	N	N	ALLOW
+# Testname		Arch					Syscall		Arg0	Arg1	Arg2	Arg3	Arg4	Arg5	Result
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		1	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		2	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		3	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		4	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		11	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		12	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		13	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		14	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		21	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		22	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		23	N	N	N	N	N	ALLOW
+37-sim-ipc_syscalls_be	+s390,+s390x,+ppc,+sparc,+sparc64	ipc		24	N	N	N	N	N	ALLOW
 
 test type: bpf-valgrind

Thank you so much!

glaubitz avatar Sep 09 '25 16:09 glaubitz

Requested changes have been implemented. Please retry.

glaubitz avatar Sep 09 '25 16:09 glaubitz

Unfortunately I wasn't able to successfully run the python tests. Either I screwed something up, or there are problems with the Python/Debian/Pip repos. I'm guessing the former :)

I'm going to retest on Debian unstable sparc64 later this week.

I'm still seeing a failure with test 52 (which loads the filter into the kernel). Seems like an issue with the sparc/seccomp kernel itself. I'll gladly help test/review kernel changes to get this working.

We're currently working on fixing many issues in the Linux kernel running on SPARC. Oracle engineers actually made a lot of contributions here, but they stopped upstreaming these changes when they abandoned the project.

The patches are part of the UEK 4/Update 7 kernel.

All in all, this looks good to me. I had a few small nitpicks, but they're easily fixed.

I think I'd prefer to wait to merge it until we get it fully working, but I'll defer to others here. Once we get it running, I'll add my Reviewed-by.

Sure, no problem.

Thanks for the hard work, @glaubitz. It's always cool to see another architecture added :)

Once SPARC support has been merged, Alpha will be the last unsupported platform and I'm sure we'll get that eventually added as well. ;-)

glaubitz avatar Sep 10 '25 20:09 glaubitz

I found the bug that was causing tests 36 and 37 to fail. Definitely not what I expected :). Here's the fix for those test failures:

diff --git a/src/syscalls.h b/src/syscalls.h
index b2720fc..ccdff1b 100644
--- a/src/syscalls.h
+++ b/src/syscalls.h
@@ -43,6 +43,9 @@ struct arch_syscall_table {
        /* each arch listed here must be defined in syscalls.c  */
        /* NOTE: see the warning above - BEWARE! */

+       /* NOTE: the order of the members of this structure must exactly
+        *       match the order of the columns in syscalls.csv! */
+
        int x86;
        enum scmp_kver x86_kver;
        int x86_64;
@@ -86,13 +89,13 @@ struct arch_syscall_table {
        int s390x;
        enum scmp_kver s390x_kver;

+       int sh;
+       enum scmp_kver sh_kver;
+
        int sparc;
        enum scmp_kver sparc_kver;
        int sparc64;
        enum scmp_kver sparc64_kver;
-
-       int sh;
-       enum scmp_kver sh_kver;
 };

Oh, wow. I would have never guessed that. I will fix that. Thanks so much for the thorough review!

Yeah ... oops! Does anyone want to submit a separate PR to fix that?

pcmoore avatar Oct 07 '25 20:10 pcmoore

Oh, wow. I would have never guessed that. I will fix that. Thanks so much for the thorough review!

Yeah ... oops! Does anyone want to submit a separate PR to fix that?

What issue exactly do you mean?

And I just realized you requested some additional changes. I will look into these in the weekend.

FWIW, there is a Debian unstable machine running on a SPARC T5 LDOM in the GCC Compile Farm now available for testing (cfarm202.cfarm.net).

I will ask for help to implement SECCOMP_FILTER on SPARC, I have filed an issue for it already.

glaubitz avatar Oct 07 '25 20:10 glaubitz

What issue exactly do you mean?

My apologies, I thought the sh arch/ABI was located incorrectly in the arch_syscall_table struct in the current codebase, but I realize it was just an issue with the code in the PR. Sorry for the noise :)

pcmoore avatar Oct 07 '25 22:10 pcmoore