Skip to content

Commit 1d7b297

Browse files
libct/seccomp: add riscv64
Co-authored-by: Kir Kolyshkin <[email protected]> Signed-off-by: Akihiro Suda <[email protected]> Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent dafcacb commit 1d7b297

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

libcontainer/seccomp/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ var archs = map[string]string{
6666
"SCMP_ARCH_PPC": "ppc",
6767
"SCMP_ARCH_PPC64": "ppc64",
6868
"SCMP_ARCH_PPC64LE": "ppc64le",
69+
"SCMP_ARCH_RISCV64": "riscv64",
6970
"SCMP_ARCH_S390": "s390",
7071
"SCMP_ARCH_S390X": "s390x",
7172
}

libcontainer/seccomp/patchbpf/enosys_linux.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ const uintptr_t C_FILTER_FLAG_LOG = SECCOMP_FILTER_FLAG_LOG;
4848
#endif
4949
const uintptr_t C_FILTER_FLAG_NEW_LISTENER = SECCOMP_FILTER_FLAG_NEW_LISTENER;
5050
51+
#ifndef AUDIT_ARCH_RISCV64
52+
#ifndef EM_RISCV
53+
#define EM_RISCV 243
54+
#endif
55+
#define AUDIT_ARCH_RISCV64 (EM_RISCV|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
56+
#endif
57+
5158
// We use the AUDIT_ARCH_* values because those are the ones used by the kernel
5259
// and SCMP_ARCH_* sometimes has fake values (such as SCMP_ARCH_X32). But we
5360
// use <seccomp.h> so we get libseccomp's fallback definitions of AUDIT_ARCH_*.
@@ -67,6 +74,7 @@ const uint32_t C_AUDIT_ARCH_PPC64 = AUDIT_ARCH_PPC64;
6774
const uint32_t C_AUDIT_ARCH_PPC64LE = AUDIT_ARCH_PPC64LE;
6875
const uint32_t C_AUDIT_ARCH_S390 = AUDIT_ARCH_S390;
6976
const uint32_t C_AUDIT_ARCH_S390X = AUDIT_ARCH_S390X;
77+
const uint32_t C_AUDIT_ARCH_RISCV64 = AUDIT_ARCH_RISCV64;
7078
*/
7179
import "C"
7280

@@ -197,6 +205,8 @@ func archToNative(arch libseccomp.ScmpArch) (nativeArch, error) {
197205
return nativeArch(C.C_AUDIT_ARCH_S390), nil
198206
case libseccomp.ArchS390X:
199207
return nativeArch(C.C_AUDIT_ARCH_S390X), nil
208+
case libseccomp.ArchRISCV64:
209+
return nativeArch(C.C_AUDIT_ARCH_RISCV64), nil
200210
default:
201211
return invalidArch, fmt.Errorf("unknown architecture: %v", arch)
202212
}

0 commit comments

Comments
 (0)