[PATCH] tests: Add 64-bit LoongArch support
authorXiaotian Wu <wuxiaotian@loongson.cn>
Tue, 9 Feb 2021 07:52:18 +0000 (15:52 +0800)
committerFelix Geyer <fgeyer@debian.org>
Sun, 24 Nov 2024 20:54:16 +0000 (21:54 +0100)
[xen0n: LoongArch (and a few upcoming architectures / ABIs) does not
have fstat, so the fstat in 06-sim-actions is also being changed to
fstatfs for uniformity across the board.]

Signed-off-by: Xiaotian Wu <wuxiaotian@loongson.cn>
Signed-off-by: WANG Xuerui <git@xen0n.name>
Acked-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Gbp-Pq: Name tests_Add_64-bit_LoongArch_support.patch

18 files changed:
tests/06-sim-actions.py
tests/06-sim-actions.tests
tests/15-basic-resolver.c
tests/16-sim-arch_basic.c
tests/16-sim-arch_basic.py
tests/23-sim-arch_all_le_basic.c
tests/23-sim-arch_all_le_basic.py
tests/36-sim-ipc_syscalls.c
tests/38-basic-pfc_coverage.c
tests/38-basic-pfc_coverage.pfc
tests/53-sim-binary_tree.c
tests/53-sim-binary_tree.py
tests/53-sim-binary_tree.tests
tests/55-basic-pfc_binary_tree.c
tests/55-basic-pfc_binary_tree.pfc
tests/56-basic-iterate_syscalls.c
tests/56-basic-iterate_syscalls.py
tests/regression

index 253061dff9cd4d342466dcf789f1736e48d08568..cfbd4f47e2e800a190f6326dace37c4486189a9e 100755 (executable)
@@ -38,7 +38,7 @@ def test(args):
     f.add_rule(ERRNO(errno.EPERM), "write")
     f.add_rule(TRAP, "close")
     f.add_rule(TRACE(1234), "openat")
-    f.add_rule(KILL_PROCESS, "fstat")
+    f.add_rule(KILL_PROCESS, "fstatfs")
     return f
 
 args = util.get_opt()
index 6d791f07a0228b9fbd2374999c8537bda82bf3bf..c3f63be8823a04e67039882c0d6335d7c904f6a6 100644 (file)
@@ -15,12 +15,13 @@ test type: bpf-sim
 06-sim-actions all             fstatfs         4               0x856B008       N       N       N       N       KILL_PROCESS
 06-sim-actions all             rt_sigreturn    N               N               N       N       N       N       LOG
 06-sim-actions x86             0-2             N               N               N       N       N       N       KILL
-06-sim-actions x86             7-107           N               N               N       N       N       N       KILL
-06-sim-actions x86             109-172         N               N               N       N       N       N       KILL
+06-sim-actions x86             7-99            N               N               N       N       N       N       KILL
+06-sim-actions x86             101-172         N               N               N       N       N       N       KILL
 06-sim-actions x86             174-294         N               N               N       N       N       N       KILL
 06-sim-actions x86             296-350         N               N               N       N       N       N       KILL
 06-sim-actions x86_64          6-14            N               N               N       N       N       N       KILL
-06-sim-actions x86_64          16-256          N               N               N       N       N       N       KILL
+06-sim-actions x86_64          16-137          N               N               N       N       N       N       KILL
+06-sim-actions x86_64          139-256         N               N               N       N       N       N       KILL
 06-sim-actions x86_64          258-350         N               N               N       N       N       N       KILL
 
 test type: bpf-sim-fuzz
index 6db69e8632581cc97ea895a5184c5eab9f322147..c79894f0a6ecd2109b5019ae9150e6df49d7c12f 100644 (file)
@@ -32,6 +32,7 @@ unsigned int arch_list[] = {
        SCMP_ARCH_X32,
        SCMP_ARCH_ARM,
        SCMP_ARCH_AARCH64,
+       SCMP_ARCH_LOONGARCH64,
        SCMP_ARCH_MIPS,
        SCMP_ARCH_MIPS64,
        SCMP_ARCH_MIPS64N32,
index 0b141e1c0f91a6d930f7440a65e4e9375cc81844..ee1a4a56b2a94c0009fd0298bf8ebf30dafb61bb 100644 (file)
@@ -78,6 +78,9 @@ int main(int argc, char *argv[])
        if (rc != 0)
                goto out;
        rc = seccomp_arch_add(ctx, SCMP_ARCH_AARCH64);
+       if (rc != 0)
+               goto out;
+       rc = seccomp_arch_add(ctx, SCMP_ARCH_LOONGARCH64);
        if (rc != 0)
                goto out;
        rc = seccomp_arch_add(ctx, SCMP_ARCH_MIPSEL);
@@ -145,6 +148,9 @@ int main(int argc, char *argv[])
        if (rc != 0)
                goto out;
        rc = seccomp_arch_remove(ctx, SCMP_ARCH_AARCH64);
+       if (rc != 0)
+               goto out;
+       rc = seccomp_arch_remove(ctx, SCMP_ARCH_LOONGARCH64);
        if (rc != 0)
                goto out;
        rc = seccomp_arch_remove(ctx, SCMP_ARCH_MIPSEL);
index 846553fb327f57a7da9b771784580aab2eaed725..ba38b91ffe7add7d62e6c6a2a73cf8ba7a4c95f0 100755 (executable)
@@ -40,6 +40,7 @@ def test(args):
     f.add_arch(Arch("x32"))
     f.add_arch(Arch("arm"))
     f.add_arch(Arch("aarch64"))
+    f.add_arch(Arch("loongarch64"))
     f.add_arch(Arch("mipsel"))
     f.add_arch(Arch("mipsel64"))
     f.add_arch(Arch("mipsel64n32"))
index 32739e5b394ea93ff8030e8d65c934e8c1ffea6b..d10d3518f39905598e7dbe174a671a7694c5c6ed 100644 (file)
@@ -57,6 +57,9 @@ int main(int argc, char *argv[])
        if (rc != 0)
                goto out;
        rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("aarch64"));
+       if (rc != 0)
+               goto out;
+       rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("loongarch64"));
        if (rc != 0)
                goto out;
        rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("mipsel"));
index 33eedb17872f505879dc48c0b72f5412a66e56c8..0cecbc951b2114eb97a2f49f1887fe05c453d1ea 100755 (executable)
@@ -36,6 +36,7 @@ def test(args):
     f.add_arch(Arch("x32"))
     f.add_arch(Arch("arm"))
     f.add_arch(Arch("aarch64"))
+    f.add_arch(Arch("loongarch64"))
     f.add_arch(Arch("mipsel"))
     f.add_arch(Arch("mipsel64"))
     f.add_arch(Arch("mipsel64n32"))
index c9b575e0d445f562edb1c51fd2a26c8d2a3f4ce9..d3b7093d7bb9e4c3cb56984764fb99b4a3360b04 100644 (file)
@@ -57,6 +57,9 @@ int main(int argc, char *argv[])
        if (rc != 0)
                goto out;
        rc = seccomp_arch_add(ctx, SCMP_ARCH_MIPSEL);
+       if (rc != 0)
+               goto out;
+       rc = seccomp_arch_add(ctx, SCMP_ARCH_LOONGARCH64);
        if (rc != 0)
                goto out;
 
index c6829ac9e1c3ab81b51accdbc5bee8ef39d609bc..d6ac7962e8ca3f5f51221bb882e20a79a6a0daa0 100644 (file)
@@ -64,6 +64,9 @@ int main(int argc, char *argv[])
        if (rc < 0)
                goto out;
        rc = seccomp_arch_add(ctx, SCMP_ARCH_AARCH64);
+       if (rc < 0)
+               goto out;
+       rc = seccomp_arch_add(ctx, SCMP_ARCH_LOONGARCH64);
        if (rc < 0)
                goto out;
        rc = seccomp_arch_add(ctx, SCMP_ARCH_MIPSEL);
index 310928067ca108b1e6acb4f0e7858c029ec6ef18..330b21a57c7c6de96987f17aac4e8d8d51979fe6 100644 (file)
@@ -300,6 +300,103 @@ if ($arch == 3221225655)
                         action KILL;
   # default action
   action ALLOW;
+# filter for arch loongarch64 (3221225730)
+if ($arch == 3221225730)
+  # filter for syscall "open" (4294957130) [priority: 65535]
+  if ($syscall == 4294957130)
+    action KILL;
+  # filter for syscall "fstat" (4294957051) [priority: 65535]
+  if ($syscall == 4294957051)
+    action KILL_PROCESS;
+  # filter for syscall "exit_group" (94) [priority: 65535]
+  if ($syscall == 94)
+    action LOG;
+  # filter for syscall "exit" (93) [priority: 65535]
+  if ($syscall == 93)
+    action TRACE(1);
+  # filter for syscall "close" (57) [priority: 65535]
+  if ($syscall == 57)
+    action ERRNO(1);
+  # filter for syscall "write" (64) [priority: 65527]
+  if ($syscall == 64)
+    if ($a0.hi32 == 0)
+      if ($a0.lo32 == 0)
+      else
+        if ($a1.hi32 > 0)
+        else
+          if ($a1.hi32 == 0)
+            if ($a1.lo32 > 1)
+            else
+              if ($a2.hi32 > 0)
+              else
+                if ($a2.hi32 == 0)
+                  if ($a2.lo32 >= 2)
+                  else
+                    action TRAP;
+                else
+                  action TRAP;
+          else
+            if ($a2.hi32 > 0)
+            else
+              if ($a2.hi32 == 0)
+                if ($a2.lo32 >= 2)
+                else
+                  action TRAP;
+              else
+                action TRAP;
+    else
+      if ($a1.hi32 > 0)
+      else
+        if ($a1.hi32 == 0)
+          if ($a1.lo32 > 1)
+          else
+            if ($a2.hi32 > 0)
+            else
+              if ($a2.hi32 == 0)
+                if ($a2.lo32 >= 2)
+                else
+                  action TRAP;
+              else
+                action TRAP;
+        else
+          if ($a2.hi32 > 0)
+          else
+            if ($a2.hi32 == 0)
+              if ($a2.lo32 >= 2)
+              else
+                action TRAP;
+            else
+              action TRAP;
+  # filter for syscall "read" (63) [priority: 65525]
+  if ($syscall == 63)
+    if ($a0.hi32 == 0)
+      if ($a0.lo32 == 0)
+        if ($a1.hi32 > 0)
+          if ($a2.hi32 > 0)
+            if ($a3.hi32 & 0x00000000 == 0)
+              if ($a3.lo32 & 0x0000000f == 3)
+                action KILL;
+          else
+            if ($a2.hi32 == 0)
+              if ($a2.lo32 > 2)
+                if ($a3.hi32 & 0x00000000 == 0)
+                  if ($a3.lo32 & 0x0000000f == 3)
+                    action KILL;
+        else
+          if ($a1.hi32 == 0)
+            if ($a1.lo32 >= 1)
+              if ($a2.hi32 > 0)
+                if ($a3.hi32 & 0x00000000 == 0)
+                  if ($a3.lo32 & 0x0000000f == 3)
+                    action KILL;
+              else
+                if ($a2.hi32 == 0)
+                  if ($a2.lo32 > 2)
+                    if ($a3.hi32 & 0x00000000 == 0)
+                      if ($a3.lo32 & 0x0000000f == 3)
+                        action KILL;
+  # default action
+  action ALLOW;
 # filter for arch mipsel (1073741832)
 if ($arch == 1073741832)
   # filter for syscall "exit_group" (4246) [priority: 65535]
index 4aa5f136353fa97fba766ccfbf723224ceb3c8e0..98b9e2cb252d759e45833d86dc3b4fcc17119303 100644 (file)
@@ -103,6 +103,9 @@ int main(int argc, char *argv[])
                goto out;
 
        rc = seccomp_arch_add(ctx, SCMP_ARCH_AARCH64);
+       if (rc != 0)
+               goto out;
+       rc = seccomp_arch_add(ctx, SCMP_ARCH_LOONGARCH64);
        if (rc != 0)
                goto out;
        rc = seccomp_arch_add(ctx, SCMP_ARCH_PPC64LE);
index 8ee58cda13df07d8e044f67da594715de808a442..8cda81078f4d3048304e81f1ab41e5f8aae43e34 100755 (executable)
@@ -72,6 +72,7 @@ def test(args):
 
     f.remove_arch(Arch())
     f.add_arch(Arch("aarch64"))
+    f.add_arch(Arch("loongarch64"))
     f.add_arch(Arch("ppc64le"))
     f.add_arch(Arch("x86_64"))
 
index 2ebaafd55e7e734c504fde5616a290f249e98194..9813d0d699f5a9d632f1e72ab35f0c883c2a2c1c 100644 (file)
@@ -8,56 +8,56 @@
 test type: bpf-sim
 
 # Testname             Arch                            Syscall         Arg0    Arg1    Arg2    Arg3    Arg4    Arg5    Result
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       read            N       N       N       N       N       N       ERRNO(0)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       write           N       N       N       N       N       N       ERRNO(1)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  read            N       N       N       N       N       N       ERRNO(0)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  write           N       N       N       N       N       N       ERRNO(1)
 53-sim-binary_tree     +x86_64,+ppc64le                open            N       N       N       N       N       N       ERRNO(2)
-53-sim-binary_tree     +aarch64                        open            N       N       N       N       N       N       ALLOW
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       close           N       N       N       N       N       N       ALLOW
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       close           100     1234    N       N       N       N       ALLOW
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       close           100     101     N       N       N       N       ERRNO(3)
+53-sim-binary_tree     +aarch64,+loongarch64                   open            N       N       N       N       N       N       ALLOW
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  close           N       N       N       N       N       N       ALLOW
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  close           100     1234    N       N       N       N       ALLOW
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  close           100     101     N       N       N       N       ERRNO(3)
 53-sim-binary_tree     +x86_64,+ppc64le                stat            N       N       N       N       N       N       ERRNO(4)
-53-sim-binary_tree     +aarch64                        stat            N       N       N       N       N       N       ALLOW
+53-sim-binary_tree     +aarch64,+loongarch64                   stat            N       N       N       N       N       N       ALLOW
 53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       fstat           N       N       N       N       N       N       ERRNO(5)
 53-sim-binary_tree     +x86_64,+ppc64le                lstat           N       N       N       N       N       N       ERRNO(6)
-53-sim-binary_tree     +aarch64                        lstat           N       N       N       N       N       N       ALLOW
+53-sim-binary_tree     +aarch64,+loongarch64                   lstat           N       N       N       N       N       N       ALLOW
 53-sim-binary_tree     +x86_64,+ppc64le                poll            102     N       N       N       N       N       ERRNO(7)
-53-sim-binary_tree     +aarch64                        poll            102     N       N       N       N       N       ALLOW
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       lseek           103     104     N       N       N       N       ERRNO(8)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       mmap            N       N       N       N       N       N       ERRNO(9)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       mprotect        N       N       N       N       N       N       ERRNO(10)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       munmap          N       N       N       N       N       N       ERRNO(11)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       brk             N       N       N       N       N       N       ERRNO(12)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       rt_sigaction    N       N       N       N       N       N       ERRNO(13)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       rt_sigprocmask  N       N       N       N       N       N       ERRNO(14)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       rt_sigreturn    N       N       N       N       N       N       ERRNO(15)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       ioctl           N       N       N       N       N       N       ERRNO(16)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       pread64         105     N       N       N       N       N       ERRNO(17)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       pwrite64        N       N       N       N       N       N       ERRNO(18)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       readv           N       N       N       N       N       N       ERRNO(19)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       writev          N       N       N       N       N       N       ERRNO(20)
+53-sim-binary_tree     +aarch64,+loongarch64                   poll            102     N       N       N       N       N       ALLOW
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  lseek           103     104     N       N       N       N       ERRNO(8)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  mmap            N       N       N       N       N       N       ERRNO(9)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  mprotect        N       N       N       N       N       N       ERRNO(10)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  munmap          N       N       N       N       N       N       ERRNO(11)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  brk             N       N       N       N       N       N       ERRNO(12)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  rt_sigaction    N       N       N       N       N       N       ERRNO(13)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  rt_sigprocmask  N       N       N       N       N       N       ERRNO(14)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  rt_sigreturn    N       N       N       N       N       N       ERRNO(15)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  ioctl           N       N       N       N       N       N       ERRNO(16)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  pread64         105     N       N       N       N       N       ERRNO(17)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  pwrite64        N       N       N       N       N       N       ERRNO(18)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  readv           N       N       N       N       N       N       ERRNO(19)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  writev          N       N       N       N       N       N       ERRNO(20)
 53-sim-binary_tree     +x86_64,+ppc64le                access          N       N       N       N       N       N       ERRNO(21)
-53-sim-binary_tree     +aarch64                        access          N       N       N       N       N       N       ALLOW
+53-sim-binary_tree     +aarch64,+loongarch64                   access          N       N       N       N       N       N       ALLOW
 53-sim-binary_tree     +x86_64,+ppc64le                pipe            N       N       N       N       N       N       ERRNO(22)
-53-sim-binary_tree     +aarch64                        pipe            N       N       N       N       N       N       ALLOW
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       select          N       N       N       N       N       N       ALLOW
+53-sim-binary_tree     +aarch64,+loongarch64                   pipe            N       N       N       N       N       N       ALLOW
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  select          N       N       N       N       N       N       ALLOW
 53-sim-binary_tree     +x86_64,+ppc64le                select          106     107     N       N       N       N       ERRNO(23)
-53-sim-binary_tree     +aarch64                        select          106     107     N       N       N       N       ALLOW
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       sched_yield     N       N       N       N       N       N       ERRNO(24)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       mremap          N       N       N       N       N       N       ALLOW
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       mremap          108     109     N       N       N       N       ERRNO(25)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       msync           N       N       N       N       N       N       ERRNO(26)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       mincore         N       N       N       N       N       N       ERRNO(27)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       madvise         N       N       N       N       N       N       ERRNO(28)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       dup             112     N       N       N       N       N       ERRNO(32)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       dup             5678    N       N       N       N       N       ALLOW
+53-sim-binary_tree     +aarch64,+loongarch64                   select          106     107     N       N       N       N       ALLOW
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  sched_yield     N       N       N       N       N       N       ERRNO(24)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  mremap          N       N       N       N       N       N       ALLOW
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  mremap          108     109     N       N       N       N       ERRNO(25)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  msync           N       N       N       N       N       N       ERRNO(26)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  mincore         N       N       N       N       N       N       ERRNO(27)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  madvise         N       N       N       N       N       N       ERRNO(28)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  dup             112     N       N       N       N       N       ERRNO(32)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  dup             5678    N       N       N       N       N       ALLOW
 53-sim-binary_tree     +x86_64,+ppc64le                dup2            N       N       N       N       N       N       ERRNO(33)
-53-sim-binary_tree     +aarch64                        dup2            N       N       N       N       N       N       ALLOW
+53-sim-binary_tree     +aarch64,+loongarch64                   dup2            N       N       N       N       N       N       ALLOW
 53-sim-binary_tree     +x86_64,+ppc64le                pause           N       N       N       N       N       N       ERRNO(34)
-53-sim-binary_tree     +aarch64                        pause           N       N       N       N       N       N       ALLOW
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       nanosleep       N       N       N       N       N       N       ERRNO(35)
-53-sim-binary_tree     +x86_64,+ppc64le,+aarch64       getitimer       N       N       N       N       N       N       ERRNO(36)
+53-sim-binary_tree     +aarch64,+loongarch64                   pause           N       N       N       N       N       N       ALLOW
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  nanosleep       N       N       N       N       N       N       ERRNO(35)
+53-sim-binary_tree     +x86_64,+ppc64le,+aarch64,+loongarch64  getitimer       N       N       N       N       N       N       ERRNO(36)
 53-sim-binary_tree     +x86_64,+ppc64le                alarm           N       N       N       N       N       N       ERRNO(37)
-53-sim-binary_tree     +aarch64                        alarm           N       N       N       N       N       N       ALLOW
+53-sim-binary_tree     +aarch64,+loongarch64                   alarm           N       N       N       N       N       N       ALLOW
 
 test type: bpf-valgrind
 
index e364fd6b55787d4d222df3a0071d19becd2f8124..0919f6b1e52e40407b8678159b8ab170174bdadf 100644 (file)
@@ -87,6 +87,9 @@ int main(int argc, char *argv[])
        if (rc < 0)
                goto out;
        rc = seccomp_arch_add(ctx, SCMP_ARCH_AARCH64);
+       if (rc < 0)
+               goto out;
+       rc = seccomp_arch_add(ctx, SCMP_ARCH_LOONGARCH64);
        if (rc < 0)
                goto out;
        rc = seccomp_attr_set(ctx, SCMP_FLTATR_CTL_OPTIMIZE, 2);
index ba3244c440938cb7c88dd803d7f72fb4df9f7a4e..33109454489c39d177ef4997dde22777a476028a 100644 (file)
@@ -175,6 +175,93 @@ if ($arch == 3221225655)
       action ERRNO(16);
   # default action
   action ALLOW;
+# filter for arch loongarch64 (3221225730)
+if ($arch == 3221225730)
+  if ($syscall > 62)
+    if ($syscall > 214)
+      if ($syscall > 4294957051)
+        # filter for syscall "lstat" (4294957133) [priority: 65535]
+        if ($syscall == 4294957133)
+          action ERRNO(6);
+        # filter for syscall "open" (4294957130) [priority: 65535]
+        if ($syscall == 4294957130)
+          action ERRNO(2);
+        # filter for syscall "poll" (4294957127) [priority: 65535]
+        if ($syscall == 4294957127)
+          action ERRNO(7);
+        # filter for syscall "stat" (4294957122) [priority: 65535]
+        if ($syscall == 4294957122)
+          action ERRNO(4);
+      else # ($syscall <= 4294957051)
+        # filter for syscall "fstat" (4294957051) [priority: 65533]
+        if ($syscall == 4294957051)
+          if ($a0.hi32 == 0)
+            if ($a0.lo32 == 103)
+              action ERRNO(5);
+        # filter for syscall "mprotect" (226) [priority: 65533]
+        if ($syscall == 226)
+          if ($a0.hi32 == 0)
+            if ($a0.lo32 == 105)
+              action ERRNO(10);
+        # filter for syscall "mmap" (222) [priority: 65535]
+        if ($syscall == 222)
+          action ERRNO(9);
+        # filter for syscall "munmap" (215) [priority: 65535]
+        if ($syscall == 215)
+          action ERRNO(11);
+    else # ($syscall <= 214)
+      if ($syscall > 68)
+        # filter for syscall "brk" (214) [priority: 65535]
+        if ($syscall == 214)
+          action ERRNO(12);
+        # filter for syscall "rt_sigreturn" (139) [priority: 65535]
+        if ($syscall == 139)
+          action ERRNO(15);
+        # filter for syscall "rt_sigprocmask" (135) [priority: 65535]
+        if ($syscall == 135)
+          action ERRNO(14);
+        # filter for syscall "rt_sigaction" (134) [priority: 65535]
+        if ($syscall == 134)
+          action ERRNO(13);
+      else # ($syscall <= 68)
+        # filter for syscall "pwrite64" (68) [priority: 65531]
+        if ($syscall == 68)
+          if ($a0.hi32 == 0)
+            if ($a0.lo32 == 107)
+              if ($a1.hi32 == 0)
+                if ($a1.lo32 == 108)
+                  action ERRNO(18);
+        # filter for syscall "pread64" (67) [priority: 65533]
+        if ($syscall == 67)
+          if ($a0.hi32 == 0)
+            if ($a0.lo32 == 106)
+              action ERRNO(17);
+        # filter for syscall "write" (64) [priority: 65533]
+        if ($syscall == 64)
+          if ($a0.hi32 == 0)
+            if ($a0.lo32 == 102)
+              action ERRNO(1);
+        # filter for syscall "read" (63) [priority: 65531]
+        if ($syscall == 63)
+          if ($a0.hi32 == 0)
+            if ($a0.lo32 == 100)
+              if ($a1.hi32 == 0)
+                if ($a1.lo32 == 101)
+                  action ERRNO(0);
+  else # ($syscall <= 62)
+    # filter for syscall "lseek" (62) [priority: 65533]
+    if ($syscall == 62)
+      if ($a0.hi32 == 0)
+        if ($a0.lo32 == 104)
+          action ERRNO(8);
+    # filter for syscall "close" (57) [priority: 65535]
+    if ($syscall == 57)
+      action ERRNO(3);
+    # filter for syscall "ioctl" (29) [priority: 65535]
+    if ($syscall == 29)
+      action ERRNO(16);
+  # default action
+  action ALLOW;
 # invalid architecture action
 action KILL;
 #
index 5e7ab6795092028f8189f52e7d91d687b6cbae33..b514afa12c22c01d9d76d72186795b8fc8c8b890 100644 (file)
@@ -33,6 +33,7 @@ unsigned int arch_list[] = {
        SCMP_ARCH_X32,
        SCMP_ARCH_ARM,
        SCMP_ARCH_AARCH64,
+       SCMP_ARCH_LOONGARCH64,
        SCMP_ARCH_MIPS,
        SCMP_ARCH_MIPS64,
        SCMP_ARCH_MIPS64N32,
index 77a5b8934009b03a798430209a2b3d1b749f722c..d69dd0cff28f8bff190a0c5979b7ed72d23b9631 100755 (executable)
@@ -33,6 +33,7 @@ arch_list = ["x86",
              "x32",
              "arm",
              "aarch64",
+             "loongarch64",
              "mipsel",
              "mipsel64",
              "mipsel64n32",
index f938b1b987615c119cea7c08a6488dde7f9d1f4f..19f932399a0572a02122de2b463ad839df304381 100755 (executable)
@@ -24,6 +24,7 @@
 GLBL_ARCH_LE_SUPPORT=" \
        x86 x86_64 x32 \
        arm aarch64 \
+       loongarch64 \
        mipsel mipsel64 mipsel64n32 \
        ppc64le \
        riscv64"
@@ -44,6 +45,7 @@ GLBL_ARCH_32B_SUPPORT=" \
 GLBL_ARCH_64B_SUPPORT=" \
        x86_64 \
        aarch64 \
+       loongarch64 \
        mips64 \
        parisc64 \
        ppc64 \
@@ -796,7 +798,7 @@ function run_test_live() {
 
        # setup the arch specific return values
        case "$arch" in
-       x86|x86_64|x32|arm|aarch64|parisc|parisc64|ppc|ppc64|ppc64le|ppc|s390|s390x|riscv64)
+       x86|x86_64|x32|arm|aarch64|loongarch64|parisc|parisc64|ppc|ppc64|ppc64le|ppc|s390|s390x|riscv64)
                rc_kill_process=159
                rc_kill=159
                rc_allow=160