Skip to content

Commit 40cb7c8

Browse files
pb8oShadowCurse
authored andcommitted
devtool: remove obsolete commands
Since we depend on libseccomp in the previous commit, these commands to update the syscall table are no longer needed. Signed-off-by: Pablo Barbáchano <[email protected]>
1 parent 8340e43 commit 40cb7c8

File tree

1 file changed

+0
-137
lines changed

1 file changed

+0
-137
lines changed

tools/devtool

Lines changed: 0 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,6 @@ cmd_help() {
375375
echo " This should be used as the last step in every commit, to ensure that the"
376376
echo " Rust style tests pass."
377377
echo ""
378-
echo " generate_syscall_tables <version>"
379-
echo " Generates the syscall tables for seccompiler, according to a given kernel version."
380-
echo " Release candidate (rc) linux versions are not allowed."
381-
echo " Outputs a rust file for each supported arch: src/seccompiler/src/syscall_table/{arch}.rs"
382-
echo " Supported architectures: x86_64 and aarch64."
383-
echo ""
384378
echo " install [-p|--path] [--debug|--release]"
385379
echo " Install firecracker, jailer and seccomp binaries to /usr/local/bin or a given path."
386380
echo " Only the musl linked binaries are supported."
@@ -1024,137 +1018,6 @@ cmd_checkenv() {
10241018
check_vulns
10251019
}
10261020

1027-
generate_syscall_table_x86_64() {
1028-
path_to_rust_file="$FC_ROOT_DIR/src/seccompiler/src/syscall_table/x86_64.rs"
1029-
1030-
echo "$header" > $path_to_rust_file
1031-
1032-
# the table for x86_64 is nicely formatted here: linux/arch/x86/entry/syscalls/syscall_64.tbl
1033-
cat linux/arch/x86/entry/syscalls/syscall_64.tbl | grep -v "^#" | grep -v -e '^$' |\
1034-
awk '{print $2,$3,$1}' | grep -v "^x32" |\
1035-
awk '{print " map.insert(\""$2"\".to_string(), "$3");"}' | sort >> $path_to_rust_file
1036-
1037-
echo "$footer" >> $path_to_rust_file
1038-
1039-
say "Generated at: $path_to_rust_file"
1040-
}
1041-
1042-
generate_syscall_table_aarch64() {
1043-
path_to_rust_file="$FC_ROOT_DIR/src/seccompiler/src/syscall_table/aarch64.rs"
1044-
1045-
# filter for substituting `#define`s that point to other macros;
1046-
# values taken from linux/include/uapi/asm-generic/unistd.h
1047-
replace+='s/__NR3264_fadvise64/223/;'
1048-
replace+='s/__NR3264_fcntl/25/;'
1049-
replace+='s/__NR3264_fstatat/79/;'
1050-
replace+='s/__NR3264_fstatfs/44/;'
1051-
replace+='s/__NR3264_fstat/80/;'
1052-
replace+='s/__NR3264_ftruncate/46/;'
1053-
replace+='s/__NR3264_lseek/62/;'
1054-
replace+='s/__NR3264_sendfile/71/;'
1055-
replace+='s/__NR3264_statfs/43/;'
1056-
replace+='s/__NR3264_truncate/45/;'
1057-
replace+='s/__NR3264_mmap/222/;'
1058-
1059-
echo "$header" > $path_to_rust_file
1060-
1061-
# run the gcc command in the Docker container (to make sure that we have gcc installed)
1062-
# the aarch64 syscall table is not located in a .tbl file, like x86; we run gcc's
1063-
# pre-processor to extract the numeric constants from header files.
1064-
run_devctr \
1065-
--user "$(id -u):$(id -g)" \
1066-
--workdir "$CTR_KERNEL_DIR" \
1067-
-- \
1068-
gcc -Ilinux/include/uapi -E -dM -D__ARCH_WANT_RENAMEAT\
1069-
-D__BITS_PER_LONG=64\
1070-
linux/arch/arm64/include/uapi/asm/unistd.h |\
1071-
grep "#define __NR_" | grep -v "__NR_syscalls" |\
1072-
grep -v "__NR_arch_specific_syscall" |\
1073-
awk -F '__NR_' '{print $2}' |\
1074-
sed $replace |\
1075-
awk '{ print " map.insert(\""$1"\".to_string(), "$2");" }' |\
1076-
sort -d >> $path_to_rust_file
1077-
ret=$?
1078-
1079-
[ $ret -ne 0 ] && return $ret
1080-
1081-
echo "$footer" >> $path_to_rust_file
1082-
1083-
say "Generated at: $path_to_rust_file"
1084-
}
1085-
1086-
cmd_generate_syscall_tables() {
1087-
# Parse any command line args.
1088-
while [ $# -gt 0 ]; do
1089-
case "$1" in
1090-
"-h"|"--help") { cmd_help; exit 1; } ;;
1091-
*) { kernel_version="$1"; break; } ;;
1092-
esac
1093-
shift
1094-
done
1095-
1096-
validate_kernel_version "$kernel_version"
1097-
1098-
kernel_major=v$(echo ${kernel_version} | cut -d . -f 1).x
1099-
kernel_baseurl=https://www.kernel.org/pub/linux/kernel/${kernel_major}
1100-
kernel_archive=linux-${kernel_version}.tar.xz
1101-
1102-
ensure_devctr
1103-
1104-
# Create the kernel clone directory
1105-
rm -rf "$KERNEL_DIR"
1106-
create_dir "$KERNEL_DIR"
1107-
cd "$KERNEL_DIR"
1108-
1109-
say "Fetching linux kernel..."
1110-
1111-
# Get sha256 checksum.
1112-
curl -fsSLO ${kernel_baseurl}/sha256sums.asc && \
1113-
kernel_sha256=$(grep ${kernel_archive} sha256sums.asc | cut -d ' ' -f 1)
1114-
# Get kernel archive.
1115-
curl -fsSLO "$kernel_baseurl/$kernel_archive" && \
1116-
# Verify checksum.
1117-
echo "${kernel_sha256} ${kernel_archive}" | sha256sum -c - && \
1118-
# Decompress the kernel source.
1119-
xz -d "${kernel_archive}" && \
1120-
cat linux-${kernel_version}.tar | tar -x && mv linux-${kernel_version} linux
1121-
1122-
ret=$?
1123-
[ $ret -ne 0 ] && return $ret
1124-
1125-
# rust file header
1126-
read -r -d '' header << EOM
1127-
// Copyright $(date +"%Y") Amazon.com, Inc. or its affiliates. All Rights Reserved.
1128-
// SPDX-License-Identifier: Apache-2.0
1129-
1130-
// This file is auto-generated by \`tools/devtool generate_syscall_tables\`.
1131-
// Do NOT manually edit!
1132-
// Generated at: $(date)
1133-
// Kernel version: $kernel_version
1134-
1135-
use std::collections::HashMap;
1136-
1137-
pub(crate) fn make_syscall_table(map: &mut HashMap<String, i64>) {
1138-
EOM
1139-
1140-
# rust file footer
1141-
read -r -d '' footer << EOM
1142-
}
1143-
1144-
EOM
1145-
1146-
# generate syscall table for x86_64
1147-
say "Generating table for x86_64..."
1148-
generate_syscall_table_x86_64 $header $footer
1149-
1150-
# generate syscall table for aarch64
1151-
say "Generating table for aarch64..."
1152-
generate_syscall_table_aarch64 $header $footer
1153-
1154-
ret=$?
1155-
[ $ret -ne 0 ] && return $ret
1156-
}
1157-
11581021
cmd_install() {
11591022
# By default we install release/musl binaries.
11601023
profile="release"

0 commit comments

Comments
 (0)