]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - tools/testing/selftests/seccomp/seccomp_bpf.c
selftests/seccomp: powerpc: Fix seccomp return value testing
[mirror_ubuntu-jammy-kernel.git] / tools / testing / selftests / seccomp / seccomp_bpf.c
index 84766a001ed07e6421e22bec56040ee341cbdcb1..bc0fb463c70927aba9e61f68a197bb1096c8e5aa 100644 (file)
@@ -1750,6 +1750,21 @@ TEST_F(TRACE_poke, getpid_runs_normally)
 # define ARCH_REGS             struct pt_regs
 # define SYSCALL_NUM(_regs)    (_regs).gpr[0]
 # define SYSCALL_RET(_regs)    (_regs).gpr[3]
+# define SYSCALL_RET_SET(_regs, _val)                          \
+       do {                                                    \
+               typeof(_val) _result = (_val);                  \
+               /*                                              \
+                * A syscall error is signaled by CR0 SO bit    \
+                * and the code is stored as a positive value.  \
+                */                                             \
+               if (_result < 0) {                              \
+                       SYSCALL_RET(_regs) = -result;           \
+                       (_regs).ccr |= 0x10000000;              \
+               } else {                                        \
+                       SYSCALL_RET(_regs) = result;            \
+                       (_regs).ccr &= ~0x10000000;             \
+               }                                               \
+       } while (0)
 #elif defined(__s390__)
 # define ARCH_REGS             s390_regs
 # define SYSCALL_NUM(_regs)    (_regs).gprs[2]