From 1922c1c615f79c0ecd6bd5f694d872c8894c4a31 Mon Sep 17 00:00:00 2001 From: Huang Yang Date: Mon, 8 Sep 2025 10:43:26 +0800 Subject: [PATCH] add loongarch64 support --- ...-libseccomp-golang-0.9.1-add-loong64.patch | 94 +++++++++++++++++++ golang-github-seccomp-libseccomp.spec | 8 +- 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 0001-libseccomp-golang-0.9.1-add-loong64.patch diff --git a/0001-libseccomp-golang-0.9.1-add-loong64.patch b/0001-libseccomp-golang-0.9.1-add-loong64.patch new file mode 100644 index 0000000..5f9d8c4 --- /dev/null +++ b/0001-libseccomp-golang-0.9.1-add-loong64.patch @@ -0,0 +1,94 @@ +From d2aa9da2dff534e1de6f3eb82679ca8148e1d1e0 Mon Sep 17 00:00:00 2001 +From: Huang Yang +Date: Mon, 8 Sep 2025 09:46:38 +0800 +Subject: [PATCH] libseccomp-golang 0.9.1 add loong64 + +--- + seccomp.go | 6 ++++++ + seccomp_internal.go | 11 ++++++++++- + 2 files changed, 16 insertions(+), 1 deletion(-) + +diff --git a/seccomp.go b/seccomp.go +index a3cc538..e67659e 100644 +--- a/seccomp.go ++++ b/seccomp.go +@@ -117,6 +117,8 @@ const ( + ArchS390 ScmpArch = iota + // ArchS390X represents 64-bit System z/390 syscalls + ArchS390X ScmpArch = iota ++ // ArchLOONGARCH64 represents 64-bit loongarch syscalls ++ ArchLOONGARCH64 ScmpArch = iota + ) + + const ( +@@ -214,6 +216,8 @@ func GetArchFromString(arch string) (ScmpArch, error) { + return ArchS390, nil + case "s390x": + return ArchS390X, nil ++ case "loong64": ++ return ArchLOONGARCH64, nil + default: + return ArchInvalid, fmt.Errorf("cannot convert unrecognized string %q", arch) + } +@@ -254,6 +258,8 @@ func (a ScmpArch) String() string { + return "s390" + case ArchS390X: + return "s390x" ++ case ArchLOONGARCH64: ++ return "loong64" + case ArchNative: + return "native" + case ArchInvalid: +diff --git a/seccomp_internal.go b/seccomp_internal.go +index 4e36b27..04023c9 100644 +--- a/seccomp_internal.go ++++ b/seccomp_internal.go +@@ -50,6 +50,10 @@ const uint32_t C_ARCH_BAD = ARCH_BAD; + #define SCMP_ARCH_S390X ARCH_BAD + #endif + ++#ifndef SCMP_ARCH_LOONGARCH64 ++#define SCMP_ARCH_LOONGARCH64 ARCH_BAD ++#endif ++ + const uint32_t C_ARCH_NATIVE = SCMP_ARCH_NATIVE; + const uint32_t C_ARCH_X86 = SCMP_ARCH_X86; + const uint32_t C_ARCH_X86_64 = SCMP_ARCH_X86_64; +@@ -67,6 +71,7 @@ const uint32_t C_ARCH_PPC64 = SCMP_ARCH_PPC64; + const uint32_t C_ARCH_PPC64LE = SCMP_ARCH_PPC64LE; + const uint32_t C_ARCH_S390 = SCMP_ARCH_S390; + const uint32_t C_ARCH_S390X = SCMP_ARCH_S390X; ++const uint32_t C_ARCH_LOONGARCH64 = SCMP_ARCH_LOONGARCH64; + + #ifndef SCMP_ACT_LOG + #define SCMP_ACT_LOG 0x7ffc0000U +@@ -200,7 +205,7 @@ const ( + scmpError C.int = -1 + // Comparison boundaries to check for architecture validity + archStart ScmpArch = ArchNative +- archEnd ScmpArch = ArchS390X ++ archEnd ScmpArch = ArchLOONGARCH64 + // Comparison boundaries to check for action validity + actionStart ScmpAction = ActKill + actionEnd ScmpAction = ActLog +@@ -443,6 +448,8 @@ func archFromNative(a C.uint32_t) (ScmpArch, error) { + return ArchS390, nil + case C.C_ARCH_S390X: + return ArchS390X, nil ++ case C.C_ARCH_LOONGARCH64: ++ return ArchLOONGARCH64, nil + default: + return 0x0, fmt.Errorf("unrecognized architecture %#x", uint32(a)) + } +@@ -483,6 +490,8 @@ func (a ScmpArch) toNative() C.uint32_t { + return C.C_ARCH_S390 + case ArchS390X: + return C.C_ARCH_S390X ++ case ArchLOONGARCH64: ++ return C.C_ARCH_LOONGARCH64 + case ArchNative: + return C.C_ARCH_NATIVE + default: +-- +2.43.7 + diff --git a/golang-github-seccomp-libseccomp.spec b/golang-github-seccomp-libseccomp.spec index e472904..e78463b 100644 --- a/golang-github-seccomp-libseccomp.spec +++ b/golang-github-seccomp-libseccomp.spec @@ -24,12 +24,13 @@ library.} %global godocs CHANGELOG README Name: %{goname} -Release: 2%{?dist} +Release: 3%{?dist} Summary: Libseccomp Go bindings License: BSD URL: %{gourl} Source0: %{gosource} +Patch3000: 0001-libseccomp-golang-0.9.1-add-loong64.patch %if %{with check} BuildRequires: pkgconfig(libseccomp) @@ -42,6 +43,7 @@ BuildRequires: pkgconfig(libseccomp) %prep %goprep +%autopatch -p1 %install %gopkginstall @@ -54,6 +56,10 @@ BuildRequires: pkgconfig(libseccomp) %gopkgfiles %changelog +*Mon Sep 08 2025 Huang Yang - 0.9.1-3 +- [Type] bugfix +- [DESC] Add loongarch64 support + * Mon Jun 09 2025 bbrucezhang - 0.9.1-2 - Rebuilt for loongarch64 -- Gitee