Skip to content

Commit d0bd0a4

Browse files
committed
RFE: Add Alpha support
1 parent 4b0bf50 commit d0bd0a4

25 files changed

Lines changed: 157 additions & 10 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ The libseccomp library currently supports the architectures listed below:
3131
* 32-bit x86 (x86)
3232
* 64-bit x86 (x86_64)
3333
* 64-bit x86 x32 ABI (x32)
34+
* 64-bit Alpha (alpha)
3435
* 32-bit ARM EABI (arm)
3536
* 64-bit ARM (aarch64)
3637
* 64-bit LoongArch (loongarch64)

doc/man/man1/scmp_sys_resolver.1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ special manner by libseccomp depending on the operation.
3434
.B \-a \fIARCH
3535
The architecture to use for resolving the system call. Valid
3636
.I ARCH
37-
values are "x86", "x86_64", "x32", "arm", "aarch64", "loongarch64", "m68k",
38-
"mips", "mipsel", "mips64", "mipsel64", "mips64n32", "mipsel64n32", "parisc",
39-
"parisc64", "ppc", "ppc64", "ppc64le", "s390", "s390x", "sheb" and "sh".
37+
values are "x86", "x86_64", "x32", "arm", "aarch64", "alpha", "loongarch64",
38+
"m68k", "mips", "mipsel", "mips64", "mipsel64", "mips64n32", "mipsel64n32",
39+
"parisc", "parisc64", "ppc", "ppc64", "ppc64le", "s390", "s390x", "sheb" and
40+
"sh".
4041
.TP
4142
.B \-t
4243
If necessary, translate the system call name to the proper system call number,

include/seccomp-syscalls.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@
283283
#define __PNR_getpagesize -10249
284284
#define __PNR_riscv_hwprobe -10250
285285
#define __PNR_uretprobe -10251
286+
#define __PNR_open_tree_attr -10252
286287

287288
/*
288289
* libseccomp syscall definitions
@@ -1356,6 +1357,12 @@
13561357
#define __SNR_open_tree __PNR_open_tree
13571358
#endif
13581359

1360+
#ifdef __NR_open_tree_attr
1361+
#define __SNR_open_tree_attr __NR_open_tree_attr
1362+
#else
1363+
#define __SNR_open_tree_attr __PNR_open_tree_attr
1364+
#endif
1365+
13591366
#define __SNR_openat __NR_openat
13601367

13611368
#define __SNR_openat2 __NR_openat2

include/seccomp.h.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ struct scmp_arg_cmp {
139139
*/
140140
#define SCMP_ARCH_X32 (EM_X86_64|__AUDIT_ARCH_LE)
141141

142+
/**
143+
* The Alpha architecture tokens
144+
*/
145+
#define SCMP_ARCH_ALPHA AUDIT_ARCH_ALPHA
146+
142147
/**
143148
* The ARM architecture tokens
144149
*/

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ SOURCES_ALL = \
3232
arch-x32.h arch-x32.c \
3333
arch-arm.h arch-arm.c \
3434
arch-aarch64.h arch-aarch64.c \
35+
arch-alpha.h arch-alpha.c \
3536
arch-loongarch64.h arch-loongarch64.c \
3637
arch-m68k.h arch-m68k.c \
3738
arch-mips.h arch-mips.c \

src/arch-alpha.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* This library is free software; you can redistribute it and/or modify it
3+
* under the terms of version 2.1 of the GNU Lesser General Public License as
4+
* published by the Free Software Foundation.
5+
*
6+
* This library is distributed in the hope that it will be useful, but WITHOUT
7+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
9+
* for more details.
10+
*
11+
* You should have received a copy of the GNU Lesser General Public License
12+
* along with this library; if not, see <http://www.gnu.org/licenses>.
13+
*/
14+
15+
#include <stdlib.h>
16+
#include <errno.h>
17+
#include <linux/audit.h>
18+
19+
#include "arch.h"
20+
#include "arch-alpha.h"
21+
#include "syscalls.h"
22+
23+
ARCH_DEF(alpha)
24+
25+
const struct arch_def arch_def_alpha = {
26+
.token = SCMP_ARCH_ALPHA,
27+
.token_bpf = AUDIT_ARCH_ALPHA,
28+
.size = ARCH_SIZE_64,
29+
.endian = ARCH_ENDIAN_LITTLE,
30+
.syscall_resolve_name_raw = alpha_syscall_resolve_name,
31+
.syscall_resolve_num_raw = alpha_syscall_resolve_num,
32+
.syscall_rewrite = NULL,
33+
.rule_add = NULL,
34+
.syscall_name_kver = alpha_syscall_name_kver,
35+
.syscall_num_kver = alpha_syscall_num_kver,
36+
};

src/arch-alpha.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* This library is free software; you can redistribute it and/or modify it
3+
* under the terms of version 2.1 of the GNU Lesser General Public License as
4+
* published by the Free Software Foundation.
5+
*
6+
* This library is distributed in the hope that it will be useful, but WITHOUT
7+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
9+
* for more details.
10+
*
11+
* You should have received a copy of the GNU Lesser General Public License
12+
* along with this library; if not, see <http://www.gnu.org/licenses>.
13+
*/
14+
15+
#ifndef _ARCH_ALPHA_H
16+
#define _ARCH_ALPHA_H
17+
18+
#include "arch.h"
19+
20+
ARCH_DECL(alpha)
21+
22+
#endif

src/arch-create-syscalls-csv.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
import math
2727
import os
2828

29-
arch_list = ['i386', 'x86_64', 'x32', 'arm', 'arm64', 'loongarch64', 'm68k',
30-
'mipso32', 'mips64', 'mips64n32', 'parisc', 'parisc64', 'powerpc',
31-
'powerpc64', 'riscv64', 's390', 's390x', 'sh']
29+
arch_list = ['i386', 'x86_64', 'x32', 'arm', 'arm64', 'alpha', 'loongarch64',
30+
'm68k', 'mipso32', 'mips64', 'mips64n32', 'parisc', 'parisc64',
31+
'powerpc', 'powerpc64', 'riscv64', 's390', 's390x', 'sh']
3232

3333
kernel_versions = ['3.0', '3.1', '3.2', '3.3', '3.4', '3.5', '3.6', '3.7',
3434
'3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14',

src/arch-syscall-dump.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "arch-mips64.h"
4141
#include "arch-mips64n32.h"
4242
#include "arch-aarch64.h"
43+
#include "arch-alpha.h"
4344
#include "arch-parisc.h"
4445
#include "arch-parisc64.h"
4546
#include "arch-ppc.h"
@@ -103,6 +104,9 @@ int main(int argc, char *argv[])
103104
case SCMP_ARCH_X32:
104105
sys = x32_syscall_iterate(iter);
105106
break;
107+
case SCMP_ARCH_ALPHA:
108+
sys = alpha_syscall_iterate(iter);
109+
break;
106110
case SCMP_ARCH_ARM:
107111
sys = arm_syscall_iterate(iter);
108112
break;

src/arch-syscall-validate

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,27 @@ function dump_lib_aarch64() {
330330
dump_lib_arch aarch64 | mangle_lib_syscall aarch64
331331
}
332332

333+
#
334+
# Dump the alpha system syscall table
335+
#
336+
# Arguments:
337+
# 1 path to the kernel source
338+
#
339+
# Dump the architecture's syscall table to stdout.
340+
#
341+
function dump_sys_alpha() {
342+
dump_from_syscall_tbl "$1/arch/alpha/kernel/syscalls/syscall.tbl"
343+
}
344+
345+
#
346+
# Dump the alpha library syscall table
347+
#
348+
# Dump the library's syscall table to stdout.
349+
#
350+
function dump_lib_alpha() {
351+
dump_lib_arch alpha | mangle_lib_syscall alpha
352+
}
353+
333354
#
334355
# Dump the loongarch64 syscall table
335356
#
@@ -684,6 +705,9 @@ function dump_sys() {
684705
aarch64)
685706
dump_sys_aarch64 "$2"
686707
;;
708+
alpha)
709+
dump_sys_alpha "$2"
710+
;;
687711
loongarch64)
688712
dump_sys_loongarch64 "$2"
689713
;;
@@ -757,6 +781,9 @@ function dump_lib() {
757781
aarch64)
758782
dump_lib_aarch64
759783
;;
784+
alpha)
785+
dump_lib_alpha
786+
;;
760787
loongarch64)
761788
dump_lib_loongarch64
762789
;;
@@ -827,6 +854,7 @@ function gen_csv() {
827854
abi_list=""
828855
abi_list+=" x86 x86_64 x32"
829856
abi_list+=" arm aarch64"
857+
abi_list+=" alpha"
830858
abi_list+=" loongarch64"
831859
abi_list+=" m68k"
832860
abi_list+=" mips mips64 mips64n32"
@@ -940,6 +968,7 @@ if [[ $opt_arches == "" ]]; then
940968
opt_arches=" \
941969
x86 x86_64 x32 \
942970
arm aarch64 \
971+
alpha \
943972
loongarch64 \
944973
m68k \
945974
mips mips64 mips64n32 \

0 commit comments

Comments
 (0)