From patchwork Thu Oct 31 11:57:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 2004635 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Tfh2nQk8; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=ozG65gOI; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=H4rh9rDE; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=8V4aAS89; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XfMvQ3rznz1xx7 for ; Thu, 31 Oct 2024 22:58:10 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id F1CC13CBF85 for ; Thu, 31 Oct 2024 12:58:07 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 6382B3C1AFC for ; Thu, 31 Oct 2024 12:57:42 +0100 (CET) Authentication-Results: in-6.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.223.131; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 9A11E14431E8 for ; Thu, 31 Oct 2024 12:57:41 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AC4C91FBF0; Thu, 31 Oct 2024 11:57:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730375861; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BMtGH4TtjUHy9ikf6+CVvNyvHNdpv/ffUYF+tE3IpKg=; b=Tfh2nQk8Qjs3Rr4lW3IS8N6RUTu5q7DxP8EFJI7I2vuNIrKPpshJHcuPR+0cm7DTfKEV88 UsFzXCTXuW/aMRA9eQFuZXt44IPe4JePZFhE+EiGxyQ+5WnmOnEE50FPcWjPMP+J2C0aDG lH9Ia0dKC1OQj+4Biyib5CsYHhz4u2w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730375861; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BMtGH4TtjUHy9ikf6+CVvNyvHNdpv/ffUYF+tE3IpKg=; b=ozG65gOIIMEOARS1rQv66TBVeQ60oz7+R+164yIL96OpEHdAEOT3RxcoTvGC/+FUfSQhI9 l9lODNqN308RobBA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=H4rh9rDE; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=8V4aAS89 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730375859; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BMtGH4TtjUHy9ikf6+CVvNyvHNdpv/ffUYF+tE3IpKg=; b=H4rh9rDEebbSqGSHGJBB+PiusA4/j1tRBN+ryzhBhOB2SygXlnB3bqacBGZgXSeRskT5Hk EX/s/4dsIamZrskgjV4HCctZMFAMNsCkcpFIFTPjRgShmveC3MW0afBmIe5+Z93M/tFbFm 5eHIiPYed+gKmEvLL/KxQ1EmYdUYoFM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730375859; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BMtGH4TtjUHy9ikf6+CVvNyvHNdpv/ffUYF+tE3IpKg=; b=8V4aAS89VXaW4fLSDo2uHvZZmud4M2VxxBl6mRi3qEF5LgcIjuvLb5KcVcajoL6x2TQyC1 RELVgLx6WP5rnYAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id DF2D813A53; Thu, 31 Oct 2024 11:57:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id KCmeJLJwI2dxWgAAD6G6ig (envelope-from ); Thu, 31 Oct 2024 11:57:38 +0000 From: Andrea Cervesato Date: Thu, 31 Oct 2024 12:57:32 +0100 MIME-Version: 1.0 Message-Id: <20241031-generate_syscalls-v7-1-f3e26c06814e@suse.com> References: <20241031-generate_syscalls-v7-0-f3e26c06814e@suse.com> In-Reply-To: <20241031-generate_syscalls-v7-0-f3e26c06814e@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730375857; l=8431; i=andrea.cervesato@suse.com; s=20240812; h=from:subject:message-id; bh=lLhuC4kyH1w4tBninGQ/aQUNnwUI7w8JSyl3n3PHZOU=; b=FJFhoRQ9KXlHDxrTClQS7XJdIuJuJw/MnAJgwyX2HOvqDJR8p22xiAO6hEoGgp7DXqixuPXTq V0OcAbECoSDDFfMQVufn0wsOdQUNXjeaRVo0Kxui7GFrBb6LHmGQ4nv X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=RG/nLJ5snb1tLKGwSORQXBJ5XA4juT0WF2Pc/lq9meo= X-Rspamd-Queue-Id: AC4C91FBF0 X-Spam-Level: X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.com:email,suse.com:mid,generate_syscalls.sh:url,configure.ac:url,suse.de:dkim,regen.sh:url,suse.cz:email]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -4.51 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-6.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-6.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v7 1/4] Refactor regen.sh script to generate syscalls X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Rename regen.sh into a more meaningful generate_syscalls.sh name, rename order into a more meaningful supported-syscalls.txt name and rewrite part of the regen.sh script code in order to execute it from anywhere in the filesystem, without need to be in its own folder. The new code is also more clear and concise, using native sh features which are simplifying the code. Reviewed-by: Li Wang Reviewed-by: Petr Vorel Signed-off-by: Andrea Cervesato --- configure.ac | 2 +- include/lapi/syscalls/generate_syscalls.sh | 109 +++++++++++++++++ include/lapi/syscalls/regen.sh | 129 --------------------- .../lapi/syscalls/{order => supported-arch.txt} | 0 4 files changed, 110 insertions(+), 130 deletions(-) diff --git a/configure.ac b/configure.ac index d327974efa71f263d7f7f5aec9d2c5831d53dd0e..cd1233d19fad376973fc880d6689859845613fb0 100644 --- a/configure.ac +++ b/configure.ac @@ -386,7 +386,7 @@ else AC_SUBST([WITH_REALTIME_TESTSUITE],["no"]) fi -AC_CONFIG_COMMANDS([syscalls.h], [cd ${ac_top_srcdir}/include/lapi/syscalls; ./regen.sh; cd - >/dev/null]) +AC_CONFIG_COMMANDS([syscalls.h], [cd ${ac_top_srcdir}/include/lapi/syscalls; ./generate_syscalls.sh ../syscalls.h; cd - >/dev/null]) # custom functions # NOTE: don't create custom functions for simple checks, put them into this file diff --git a/include/lapi/syscalls/generate_syscalls.sh b/include/lapi/syscalls/generate_syscalls.sh new file mode 100755 index 0000000000000000000000000000000000000000..e94a6ea3c1f1623f0f846c724c8c5ff2b95450af --- /dev/null +++ b/include/lapi/syscalls/generate_syscalls.sh @@ -0,0 +1,109 @@ +#!/bin/sh -eux +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Generate the syscalls.h file, merging all architectures syscalls input file +# which are in the current folder and defined inside supported-arch.txt file. + +SYSCALLS_FILE="$1" + +if [ -z "${SYSCALLS_FILE}" ]; then + echo "Please provide the syscalls.h directory:" + echo "" + echo "$0 path/of/syscalls.h" + echo "" + exit 1 +fi + +SCRIPT_DIR="$(realpath $(dirname "$0"))" +SUPPORTED_ARCH="${SCRIPT_DIR}/supported-arch.txt" + +echo '// SPDX-License-Identifier: GPL-2.0-or-later +/************************************************ + * GENERATED FILE: DO NOT EDIT/PATCH THIS FILE * + * change your arch specific .in file instead * + ************************************************/ + +/* + * Here we stick all the ugly *fallback* logic for linux + * system call numbers (those __NR_ thingies). + */ + +#ifndef LAPI_SYSCALLS_H__ +#define LAPI_SYSCALLS_H__ + +#include +#include +#include + +#ifdef TST_TEST_H__ +#define TST_SYSCALL_BRK__(NR, SNR) ({ \ +tst_brk(TCONF, \ + "syscall(%d) " SNR " not supported on your arch", NR); \ +}) +#else +inline static void dummy_cleanup(void) {} + +#define TST_SYSCALL_BRK__(NR, SNR) ({ \ +tst_brkm(TCONF, dummy_cleanup, \ + "syscall(%d) " SNR " not supported on your arch", NR); \ +}) +#endif + +#define tst_syscall(NR, ...) ({ \ +intptr_t tst_ret; \ +if (NR == __LTP__NR_INVALID_SYSCALL) { \ + errno = ENOSYS; \ + tst_ret = -1; \ +} else { \ + tst_ret = syscall(NR, ##__VA_ARGS__); \ +} \ +if (tst_ret == -1 && errno == ENOSYS) { \ + TST_SYSCALL_BRK__(NR, #NR); \ +} \ +tst_ret; \ +}) + +#define __LTP__NR_INVALID_SYSCALL -1' >${SYSCALLS_FILE} + +while IFS= read -r arch; do + ( + echo + case ${arch} in + sparc64) echo "#if defined(__sparc__) && defined(__arch64__)" ;; + sparc) echo "#if defined(__sparc__) && !defined(__arch64__)" ;; + s390) echo "#if defined(__s390__) && !defined(__s390x__)" ;; + mips64n32) echo "#if defined(__mips__) && defined(_ABIN32)" ;; + mips64) echo "#if defined(__mips__) && defined(_ABI64)" ;; + mipso32) echo "#if defined(__mips__) && defined(_ABIO32) && _MIPS_SZLONG == 32" ;; + parisc) echo "#ifdef __hppa__" ;; + loongarch64) echo "#ifdef __loongarch__" ;; + arm64) echo "#ifdef __aarch64__" ;; + *) echo "#ifdef __${arch}__" ;; + esac + + while read -r line; do + set -- ${line} + syscall_nr="__NR_$1" + shift + + echo "# ifndef ${syscall_nr}" + echo "# define ${syscall_nr} $*" + echo "# endif" + done <"${SCRIPT_DIR}/${arch}.in" + echo "#endif" + echo + ) >>${SYSCALLS_FILE} +done <${SUPPORTED_ARCH} + +( + echo + echo "/* Common stubs */" + for num in $(awk '{print $1}' "${SCRIPT_DIR}/"*.in | sort -u); do + syscall_nr="__NR_${num}" + + echo "# ifndef ${syscall_nr}" + echo "# define ${syscall_nr} __LTP__NR_INVALID_SYSCALL" + echo "# endif" + done + echo "#endif" +) >>${SYSCALLS_FILE} diff --git a/include/lapi/syscalls/regen.sh b/include/lapi/syscalls/regen.sh deleted file mode 100755 index 663ce4458bbc67c3a9e8073dfe8359164a9da0ee..0000000000000000000000000000000000000000 --- a/include/lapi/syscalls/regen.sh +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/sh - -output="syscalls.h" -rm -f "${output}".[1-9]* -output_pid="${output}.$$" - -max_jobs=$(getconf _NPROCESSORS_ONLN 2>/dev/null) -: ${max_jobs:=1} - -srcdir=${0%/*} - -err() { - echo "$*" 1>&2 - exit 1 -} - -cat << EOF > "${output_pid}" -/************************************************ - * GENERATED FILE: DO NOT EDIT/PATCH THIS FILE * - * change your arch specific .in file instead * - ************************************************/ - -/* - * Here we stick all the ugly *fallback* logic for linux - * system call numbers (those __NR_ thingies). - * - * Licensed under the GPLv2 or later, see the COPYING file. - */ - -#ifndef LAPI_SYSCALLS_H__ -#define LAPI_SYSCALLS_H__ - -#include -#include -#include - -#ifdef TST_TEST_H__ -#define TST_SYSCALL_BRK__(NR, SNR) ({ \\ - tst_brk(TCONF, \\ - "syscall(%d) " SNR " not supported on your arch", NR); \\ -}) -#else -inline static void dummy_cleanup(void) {} - -#define TST_SYSCALL_BRK__(NR, SNR) ({ \\ - tst_brkm(TCONF, dummy_cleanup, \\ - "syscall(%d) " SNR " not supported on your arch", NR); \\ -}) -#endif - -#define tst_syscall(NR, ...) ({ \\ - intptr_t tst_ret; \\ - if (NR == __LTP__NR_INVALID_SYSCALL) { \\ - errno = ENOSYS; \\ - tst_ret = -1; \\ - } else { \\ - tst_ret = syscall(NR, ##__VA_ARGS__); \\ - } \\ - if (tst_ret == -1 && errno == ENOSYS) { \\ - TST_SYSCALL_BRK__(NR, #NR); \\ - } \\ - tst_ret; \\ -}) - -EOF - -jobs=0 -for arch in $(cat "${srcdir}/order") ; do - ( - echo "Generating data for arch $arch ... " - - ( - echo - case ${arch} in - sparc64) echo "#if defined(__sparc__) && defined(__arch64__)" ;; - sparc) echo "#if defined(__sparc__) && !defined(__arch64__)" ;; - s390) echo "#if defined(__s390__) && !defined(__s390x__)" ;; - mips_n32) echo "#if defined(__mips__) && defined(_ABIN32)" ;; - mips_n64) echo "#if defined(__mips__) && defined(_ABI64)" ;; - mips_o32) echo "#if defined(__mips__) && defined(_ABIO32) && _MIPS_SZLONG == 32" ;; - *) echo "#ifdef __${arch}__" ;; - esac - while read line ; do - set -- ${line} - nr="__NR_$1" - shift - if [ $# -eq 0 ] ; then - err "invalid line found: $line" - fi - echo "# ifndef ${nr}" - echo "# define ${nr} $*" - echo "# endif" - done < "${srcdir}/${arch}.in" - echo "#endif" - echo - ) >> "${output_pid}.${arch}" - - ) & - - jobs=$(( jobs + 1 )) - if [ ${jobs} -ge ${max_jobs} ] ; then - wait || exit 1 - jobs=0 - fi -done - -echo "Generating stub list ... " -( -echo -echo "/* Common stubs */" -echo "#define __LTP__NR_INVALID_SYSCALL -1" >> "${output_pid}" -for nr in $(awk '{print $1}' "${srcdir}/"*.in | sort -u) ; do - nr="__NR_${nr}" - echo "# ifndef ${nr}" - echo "# define ${nr} __LTP__NR_INVALID_SYSCALL" - echo "# endif" -done -echo "#endif" -) >> "${output_pid}._footer" - -wait || exit 1 - -printf "Combining them all ... " -for arch in $(cat "${srcdir}/order") _footer ; do - cat "${output_pid}.${arch}" -done >> "${output_pid}" -mv "${output_pid}" "../${output}" -rm -f "${output_pid}"* -echo "OK!" diff --git a/include/lapi/syscalls/order b/include/lapi/syscalls/supported-arch.txt similarity index 100% rename from include/lapi/syscalls/order rename to include/lapi/syscalls/supported-arch.txt From patchwork Thu Oct 31 11:57:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 2004637 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=fMhmUWDW; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=RzoABH9m; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=bo766AkC; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=D2D/VoMj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XfMw372Rxz1xx7 for ; Thu, 31 Oct 2024 22:58:43 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E66DC3CBF79 for ; Thu, 31 Oct 2024 12:58:41 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 2EEC63CBF83 for ; Thu, 31 Oct 2024 12:57:45 +0100 (CET) Authentication-Results: in-4.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:2; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id AD59711F0154 for ; Thu, 31 Oct 2024 12:57:43 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5A1E01FE4B; Thu, 31 Oct 2024 11:57:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730375862; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1eHil1/19jStm+ZFYs5EWWcigW7mlrf4SfJgI2/j47Y=; b=fMhmUWDW32a6grXyXQpjZW4yagW+KyvcAzOPQUNEt5jaYuX06ZhxMH2+/qVyfWMoCfcFfn 50/ot/Vn/DbHx9le+5fDNmEeTIexc1Oo8wOD4qaDBpXroK3EvKA9cMytJFHsv9gn3JecyT LGA27PgEzpE1BbCFwCGzAaLJUuC3Oos= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730375862; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1eHil1/19jStm+ZFYs5EWWcigW7mlrf4SfJgI2/j47Y=; b=RzoABH9mT/Dc1l6kPMI3m5exNyvJyEcmPlGV6q2ESM82jTb+7AwwH4EdSxE9p9EC+BFI0w +U729RkjnxfvTVBw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=bo766AkC; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="D2D/VoMj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730375861; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1eHil1/19jStm+ZFYs5EWWcigW7mlrf4SfJgI2/j47Y=; b=bo766AkCWsnH2MQcsl2LMhIxc0qZZKLFs4jf7DlLPY5tnLYzklWjsQNBhGOE6akyJVKFeT RJVBCyCUpBAiU6mn0KmXUyvlWhUGoou6jrIlOezlK8JsZRYJnKTVzzRVLjdg9Cv07tgKnJ 75YGz9jLkiLWeCJ55+FYEAKUOr207CE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730375861; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1eHil1/19jStm+ZFYs5EWWcigW7mlrf4SfJgI2/j47Y=; b=D2D/VoMjSR/H+JRu2FTU8e3lLcIqwoMrcaLRvyFpZXOShCAx7rwz2UaarWf52ti1c0Tqqe MRnZL9b8Nbblg/AA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C69E713B01; Thu, 31 Oct 2024 11:57:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id CNI8KrNwI2dxWgAAD6G6ig (envelope-from ); Thu, 31 Oct 2024 11:57:39 +0000 From: Andrea Cervesato Date: Thu, 31 Oct 2024 12:57:33 +0100 MIME-Version: 1.0 Message-Id: <20241031-generate_syscalls-v7-2-f3e26c06814e@suse.com> References: <20241031-generate_syscalls-v7-0-f3e26c06814e@suse.com> In-Reply-To: <20241031-generate_syscalls-v7-0-f3e26c06814e@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730375857; l=8069; i=andrea.cervesato@suse.com; s=20240812; h=from:subject:message-id; bh=SbyGn3RDkDq/EanoHWsnTPrOzWiIEgueeNdiG2RuukE=; b=/vVWWSlVlmc6sJT/29uy5iioX1rpIru5EvLO9qmmNf9GL2fPrrMxbK1RWcpibc31rBh000Fkm 91XyfS6B7fKBSOmBv3xi5cUh62NqQGWlvH5iUR4tTp4E+j8oq3eeh5j X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=RG/nLJ5snb1tLKGwSORQXBJ5XA4juT0WF2Pc/lq9meo= X-Rspamd-Queue-Id: 5A1E01FE4B X-Spam-Score: -4.51 X-Rspamd-Action: no action X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; ASN(0.00)[asn:25478, ipnet:::/0, country:RU]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.cz:email,suse.de:dkim]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-4.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-4.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v7 2/4] Add script to generate arch(s) dependant syscalls X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Add generate_arch.sh script which can be used to generate arch(s) dependant syscalls file. The way it works is pretty simple: for each architecture defined into supported-arch.txt, compile kernel headers, extract the list of syscalls and generate a .in file containing all of them, associated with their own syscall's number. The way syscalls files are generated, passes through a C application which is automatically checking the availability of the syscalls in the user space environment. Reviewed-by: Li Wang Reviewed-by: Cyril Hrubis Reviewed-by: Petr Vorel Signed-off-by: Andrea Cervesato --- include/lapi/syscalls/{aarch64.in => arm64.in} | 0 include/lapi/syscalls/generate_arch.sh | 211 +++++++++++++++++++++ .../lapi/syscalls/{loongarch.in => loongarch64.in} | 0 include/lapi/syscalls/{mips_n64.in => mips64.in} | 0 .../lapi/syscalls/{mips_n32.in => mips64n32.in} | 0 include/lapi/syscalls/{mips_o32.in => mipso32.in} | 0 include/lapi/syscalls/{hppa.in => parisc.in} | 0 include/lapi/syscalls/supported-arch.txt | 12 +- 8 files changed, 217 insertions(+), 6 deletions(-) diff --git a/include/lapi/syscalls/aarch64.in b/include/lapi/syscalls/arm64.in similarity index 100% rename from include/lapi/syscalls/aarch64.in rename to include/lapi/syscalls/arm64.in diff --git a/include/lapi/syscalls/generate_arch.sh b/include/lapi/syscalls/generate_arch.sh new file mode 100755 index 0000000000000000000000000000000000000000..c88ca945127c3c26162a48babcd6b0f8ca552311 --- /dev/null +++ b/include/lapi/syscalls/generate_arch.sh @@ -0,0 +1,211 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# +# This is an adaptation of the update-tables.sh script, included in the +# syscalls-table project (https://github.com/hrw/syscalls-table) and released +# under the MIT license. +# +# Author: Andrea Cervesato + +KERNELSRC="$1" + +# to keep sorting in order +export LC_ALL=C + +if [ -z "$KERNELSRC" ]; then + echo "Please provide kernel sources:" + echo "" + echo "$0 path/to/Linux/kernel/sources" + echo "" + exit 1 +fi + +if [ ! -d "$KERNELSRC" ]; then + echo "$KERNELSRC is not a directory" + exit 1 +fi + +if [ ! -e "${KERNELSRC}/Makefile" ]; then + echo "No Makefile in $KERNELSRC directory" + exit 1 +fi + +TEMP="$(mktemp -d)" +KVER="$(make -C ${KERNELSRC} kernelversion -s)" + +SCRIPT_DIR="$(realpath $(dirname "$0"))" +SUPPORTED_ARCH="${SCRIPT_DIR}/supported-arch.txt" +LINUX_HEADERS="${TEMP}/headers" + +grab_syscall_names_from_tables() +{ + for tbl_file in $(find ${KERNELSRC}/arch -name syscall*.tbl); do + grep -E -v "(^#|^$|sys_ni_syscall)" $tbl_file | + awk '{ print $3 }' >> ${TEMP}/syscall-names.tosort + done + + drop_bad_entries +} + +grab_syscall_names_from_unistd_h() +{ + grep -E -h "^#define __NR_" \ + ${LINUX_HEADERS}/usr/include/asm/unistd*.h \ + ${LINUX_HEADERS}/usr/include/asm-generic/unistd.h \ + >${TEMP}/syscall-names.tosort + + drop_bad_entries +} + +drop_bad_entries() +{ + grep -E -v "(unistd.h|NR3264|__NR_syscall|__SC_COMP|__NR_.*Linux|__NR_FAST)" \ + ${TEMP}/syscall-names.tosort | + grep -E -v "(__SYSCALL|SYSCALL_BASE|SYSCALL_MASK)" | + sed -e "s/#define\s*__NR_//g" -e "s/\s.*//g" | + sort -u >${TEMP}/syscall-names.txt +} + +generate_table() +{ + echo "- $arch" + + if [ $bits == 32 ]; then + extraflags="${extraflags} -D__BITS_PER_LONG=32" + fi + + local uppercase_arch=$(echo "$arch" | tr '[:lower:]' '[:upper:]') + + gcc ${TEMP}/list-syscalls.c -U__LP64__ -U__ILP32__ -U__i386__ \ + -D${uppercase_arch} \ + -D__${arch}__ ${extraflags} \ + -I ${LINUX_HEADERS}/usr/include/ \ + -o ${TEMP}/list-syscalls &>/dev/null + + ${TEMP}/list-syscalls > "${TEMP}/${arch}.in.tosort" + + sort -k2,2n "${TEMP}/${arch}.in.tosort" > "${TEMP}/${arch}.in" +} + +generate_list_syscalls_c() +{ + ( + echo + echo " + #include + #include + + int main(void) + { + " + for syscall in $(cat ${TEMP}/syscall-names.txt); do + echo " + #ifdef __NR_$syscall + printf(\"$syscall %d\\n\", __NR_$syscall); + #endif + " + done + echo " return 0; + }" + ) > ${TEMP}/list-syscalls.c +} + +export_headers() +{ + make -s -C ${KERNELSRC} ARCH=${arch} O=${LINUX_HEADERS} \ + headers_install &>/dev/null +} + +do_all_tables() +{ + for archdir in ${KERNELSRC}/arch/*; do + arch=$(basename $archdir) + + bits=64 + extraflags= + + case ${arch} in + Kconfig) + continue + ;; + um) + continue + ;; + esac + + export_headers + grab_syscall_names_from_unistd_h + + case ${arch} in + arm) + bits=32 + arch=armoabi extraflags= generate_table + arch=arm extraflags=-D__ARM_EABI__ generate_table + ;; + loongarch) + # 32-bit variant of loongarch may appear + arch=loongarch64 extraflags=-D_LOONGARCH_SZLONG=64 generate_table + ;; + mips) + arch=mips64 extraflags=-D_MIPS_SIM=_MIPS_SIM_ABI64 generate_table + bits=32 + arch=mipso32 extraflags=-D_MIPS_SIM=_MIPS_SIM_ABI32 generate_table + arch=mips64n32 extraflags=-D_MIPS_SIM=_MIPS_SIM_NABI32 generate_table + ;; + powerpc) + generate_table + arch=powerpc64 generate_table + ;; + riscv) + arch=riscv64 extraflags=-D__LP64__ generate_table + bits=32 + arch=riscv32 extraflags=-D__SIZEOF_POINTER__=4 generate_table + ;; + s390) + bits=32 + generate_table + bits=64 + arch=s390x generate_table + ;; + sparc) + bits=32 + extraflags=-D__32bit_syscall_numbers__ generate_table + bits=64 + arch=sparc64 extraflags=-D__arch64__ generate_table + ;; + x86) + arch=x86_64 extraflags=-D__LP64__ generate_table + bits=32 + arch=i386 generate_table + arch=x32 extraflags=-D__ILP32__ generate_table + ;; + arc | csky | hexagon | m68k | microblaze | nios2 | openrisc | sh | xtensa) + bits=32 generate_table + ;; + *) + generate_table + ;; + esac + done +} + +copy_supported_arch() +{ + while IFS= read -r arch; do + if [ -f "${TEMP}/${arch}.in" ]; then + echo "- ${arch}" + cp "${TEMP}/${arch}.in" "${SCRIPT_DIR}/${arch}.in" + fi + done < ${SUPPORTED_ARCH} +} + +echo "Temporary directory ${TEMP}" +echo "Extracting syscalls" + +grab_syscall_names_from_tables +generate_list_syscalls_c + +do_all_tables + +echo "Copying supported syscalls" +copy_supported_arch diff --git a/include/lapi/syscalls/loongarch.in b/include/lapi/syscalls/loongarch64.in similarity index 100% rename from include/lapi/syscalls/loongarch.in rename to include/lapi/syscalls/loongarch64.in diff --git a/include/lapi/syscalls/mips_n64.in b/include/lapi/syscalls/mips64.in similarity index 100% rename from include/lapi/syscalls/mips_n64.in rename to include/lapi/syscalls/mips64.in diff --git a/include/lapi/syscalls/mips_n32.in b/include/lapi/syscalls/mips64n32.in similarity index 100% rename from include/lapi/syscalls/mips_n32.in rename to include/lapi/syscalls/mips64n32.in diff --git a/include/lapi/syscalls/mips_o32.in b/include/lapi/syscalls/mipso32.in similarity index 100% rename from include/lapi/syscalls/mips_o32.in rename to include/lapi/syscalls/mipso32.in diff --git a/include/lapi/syscalls/hppa.in b/include/lapi/syscalls/parisc.in similarity index 100% rename from include/lapi/syscalls/hppa.in rename to include/lapi/syscalls/parisc.in diff --git a/include/lapi/syscalls/supported-arch.txt b/include/lapi/syscalls/supported-arch.txt index c18aa38cf4546cdf3ac8c89a45bd1b202ffa7711..c5c5191ac08482d89f0a8c39dfae936538f58f7f 100644 --- a/include/lapi/syscalls/supported-arch.txt +++ b/include/lapi/syscalls/supported-arch.txt @@ -1,13 +1,13 @@ -aarch64 arc +arm64 arm -hppa i386 ia64 -loongarch -mips_n32 -mips_n64 -mips_o32 +loongarch64 +mips64n32 +mips64 +mipso32 +parisc powerpc64 powerpc s390x From patchwork Thu Oct 31 11:57:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 2004638 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=qtni7DZl; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=tHeq8h2C; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=2Otw3g1h; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=2JKXC4Er; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XfMwW2Kn0z1xx7 for ; Thu, 31 Oct 2024 22:59:07 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 587FB3CBF7A for ; Thu, 31 Oct 2024 12:59:05 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 2E5733CBF77 for ; Thu, 31 Oct 2024 12:57:46 +0100 (CET) Authentication-Results: in-4.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:2; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 3E84D11F0155 for ; Thu, 31 Oct 2024 12:57:45 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id F3D5F1FE52; Thu, 31 Oct 2024 11:57:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730375864; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SdI0qDpKUOs2XaSh+hPyt9S2Rfdj5WQxJEo08i3e1rE=; b=qtni7DZlwDyv5hrYG5g+CsiOkoLCNBQbRZjiTZY/yvNRQOcGw57o6IL3kDxd6ySTi+mekt MQHNaA8qQ0dpEcaYjTJaE7XTvNvFFyG+NZws0m0Yf/wQjsLUOxcDZHTe3X9jn0lPueopq3 3zH10dH4TPguYrI9hekvnQnO78Kl/vY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730375864; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SdI0qDpKUOs2XaSh+hPyt9S2Rfdj5WQxJEo08i3e1rE=; b=tHeq8h2Cn+quhPOxROVoxvucHFAmtCq81Cj31PouO8ec3X4oOMXoD2AejKrd+FNZ0fHti+ k+VBWHDkmVGIcIDQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730375863; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SdI0qDpKUOs2XaSh+hPyt9S2Rfdj5WQxJEo08i3e1rE=; b=2Otw3g1hAGuZ/3RAOXZEA2helCyfH/rgl+p++701JEOkyOkitVXnT0hKzZg/H4i3J1dDDz j6XyUuDC1guYE5cdniioRb8Bcq+cOMjjzkv+p8kLdXSuVXfg1KhcZbT3HnLUNB20RV9alk 0Pc2Bi7NT00ByjebnH2Lh1YRZS5pmlU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730375863; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SdI0qDpKUOs2XaSh+hPyt9S2Rfdj5WQxJEo08i3e1rE=; b=2JKXC4ErU9YuHXMvcmxIpNaYD9uo9t6Pfk1yX4WottEltjBlclPnMyt8gGJy3YGFL9/eBa yG3hqs+/zR0EmSDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 890C413A53; Thu, 31 Oct 2024 11:57:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id sG29GrVwI2dxWgAAD6G6ig (envelope-from ); Thu, 31 Oct 2024 11:57:41 +0000 From: Andrea Cervesato Date: Thu, 31 Oct 2024 12:57:34 +0100 MIME-Version: 1.0 Message-Id: <20241031-generate_syscalls-v7-3-f3e26c06814e@suse.com> References: <20241031-generate_syscalls-v7-0-f3e26c06814e@suse.com> In-Reply-To: <20241031-generate_syscalls-v7-0-f3e26c06814e@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730375857; l=1094; i=andrea.cervesato@suse.com; s=20240812; h=from:subject:message-id; bh=F7I1keLFvhriKu4IZMOwZ51V8RIvSwlzc5gA76cLfTQ=; b=MLFFCNtzRCb55I16ozTpT5SHgb+jkZiAKxoZyzVDz/RnoQ67qip2REmnA6DJSe0jF1W+AOMtr Sgpzb23v0cVBE7mSXO5R3TPsO6imseGy4lA71rBiOBKzRC0qnVweZ1O X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=RG/nLJ5snb1tLKGwSORQXBJ5XA4juT0WF2Pc/lq9meo= X-Spam-Score: -4.30 X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email, imap1.dmz-prg2.suse.org:helo, suse.com:mid, suse.com:email, i386.in:url] X-Spam-Level: X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-4.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-4.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v7 3/4] Delete obsolete strip_syscall.awk file X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Reviewed-by: Li Wang Reviewed-by: Petr Vorel Reviewed-by: Cyril Hrubis Signed-off-by: Andrea Cervesato --- include/lapi/syscalls/strip_syscall.awk | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/include/lapi/syscalls/strip_syscall.awk b/include/lapi/syscalls/strip_syscall.awk deleted file mode 100755 index e8dff422e2667745c144ed984a4d66461fcce0c6..0000000000000000000000000000000000000000 --- a/include/lapi/syscalls/strip_syscall.awk +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/awk -f -# -# Dumb script that can be used to strip all of the syscall information from -# the arch-respective unistd*.h. -# -# Examples: -# -# 1. Grab the i386 32-bit syscalls from unistd_32.h and put them in i386.in -# strip_syscall.awk arch/x86/include/asm/unistd_32.h > i386.in -# - -/^#define[[:space:]]+__NR_[0-9a-z]+/ { - - sub (/#define[[:space:]]+__NR_/, "", $0); - sub (/[[:space:]]*(\/\*.*)/, "", $0); - sub (/[[:space:]]+/, " ", $0); - - print -} From patchwork Thu Oct 31 11:57:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 2004636 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=osHNPxCZ; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=zJZQO7J7; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=osHNPxCZ; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=zJZQO7J7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XfMvk5Ymyz1xx7 for ; Thu, 31 Oct 2024 22:58:26 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id A837A3CBFAD for ; Thu, 31 Oct 2024 12:58:24 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id A9F513CBF6E for ; Thu, 31 Oct 2024 12:57:44 +0100 (CET) Authentication-Results: in-5.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.223.131; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 23B4260D49E for ; Thu, 31 Oct 2024 12:57:43 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9DB3A1FE54 for ; Thu, 31 Oct 2024 11:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730375863; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JiN7MmbmKOXBZoM3hrYgvl9qvrKK1URIbuaj05lmFYg=; b=osHNPxCZv5zIa+uE1+koeZBskNwtkr4CUTm92jcMpFGMYckrio9nOJHYkzCfnDY5l/KoOI 6Dwl7BIckdg+hghhfPJVI+8yeyTnGpy5oNbvXsYKogk1ssTvUoZNjPpWKhcYfZVltcIzZF JqydpzA/wVZjaRFWM/LOvUFALDEmGg0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730375863; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JiN7MmbmKOXBZoM3hrYgvl9qvrKK1URIbuaj05lmFYg=; b=zJZQO7J7Vw1OPHX38qF9fmcg+CiZCs1sL4OGRH8OMenbRw/aL56Eq0InVZWPowCHQf8KcX aR12fh1s3hmh2WBg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730375863; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JiN7MmbmKOXBZoM3hrYgvl9qvrKK1URIbuaj05lmFYg=; b=osHNPxCZv5zIa+uE1+koeZBskNwtkr4CUTm92jcMpFGMYckrio9nOJHYkzCfnDY5l/KoOI 6Dwl7BIckdg+hghhfPJVI+8yeyTnGpy5oNbvXsYKogk1ssTvUoZNjPpWKhcYfZVltcIzZF JqydpzA/wVZjaRFWM/LOvUFALDEmGg0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730375863; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JiN7MmbmKOXBZoM3hrYgvl9qvrKK1URIbuaj05lmFYg=; b=zJZQO7J7Vw1OPHX38qF9fmcg+CiZCs1sL4OGRH8OMenbRw/aL56Eq0InVZWPowCHQf8KcX aR12fh1s3hmh2WBg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6EBC013B01 for ; Thu, 31 Oct 2024 11:57:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id mDJmC7dwI2dxWgAAD6G6ig (envelope-from ) for ; Thu, 31 Oct 2024 11:57:43 +0000 From: Andrea Cervesato Date: Thu, 31 Oct 2024 12:57:35 +0100 MIME-Version: 1.0 Message-Id: <20241031-generate_syscalls-v7-4-f3e26c06814e@suse.com> References: <20241031-generate_syscalls-v7-0-f3e26c06814e@suse.com> In-Reply-To: <20241031-generate_syscalls-v7-0-f3e26c06814e@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730375857; l=2647; i=andrea.cervesato@suse.com; s=20240812; h=from:subject:message-id; bh=3XQkoRbEpDQSeykAdArghNEG6x1l25QJsrILZcYybpo=; b=R5VcIH757Gri1CJ1qaYDnzzbHG3X7en0E0fynwKEQ6e93Q2skI3mU4qCSJpjPogB+asf/cr4D 6vIlUpFOg+3CZxroIwM7BBrJMGZaKqeaSvaCVgbrchY7Y+TXZjwTp5l X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=RG/nLJ5snb1tLKGwSORQXBJ5XA4juT0WF2Pc/lq9meo= X-Spam-Score: -4.30 X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; PREVIOUSLY_DELIVERED(0.00)[ltp@lists.linux.it]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, suse.com:mid, suse.com:email] X-Spam-Level: X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-5.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-5.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v7 4/4] Add documentation about syscalls.h generator X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Signed-off-by: Andrea Cervesato --- doc/developers/test_case_tutorial.rst | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/doc/developers/test_case_tutorial.rst b/doc/developers/test_case_tutorial.rst index be9a0ea8bac1d690b4ed4879d110f87c3f2a381a..b48ea4a7a3594266466fcca364f5d0ff1e42d235 100644 --- a/doc/developers/test_case_tutorial.rst +++ b/doc/developers/test_case_tutorial.rst @@ -302,24 +302,25 @@ for a distribution's C library version to be older than its kernel or it may use cut down C library in comparison to the GNU one. So we must call ``statx()`` using the general ``syscall()`` interface. -The LTP contains a library for dealing with the ``syscall`` interface, which is +LTP contains a library for dealing with the ``syscall`` interface, which is located in :master:`include/lapi`. System call numbers are listed against the relevant call in the ``*.in`` files (e.g. ``x86_64.in``) which are used to generate -``syscalls.h``, which is the header you should include. On rare occasions you -may find the system call number is missing from the ``*.in`` files and will need -to add it (see :master:`include/lapi/syscalls/strip_syscall.awk`). +``syscalls.h``, the header you should include. -System call numbers vary between architectures, hence there are multiple -``*.in`` files for each architecture. You can find the various values for the -``statx`` system call across a number of ``unistd.h`` files in the Linux kernel. +On rare occasions, you may find that system call number is missing from ``*.in`` +files. In these cases, they will need to be updated using +`include/lapi/syscalls/generate_arch.sh` script as following: -Note that we don't use the system-call-identifier value available in -``/usr/include/linux/uinstd.h`` because the kernel might be much newer than the -user land development packages. +.. code-block:: bash + + $ include/lapi/syscalls/generate_arch.sh /path/of/linux/sources + +The script will generate all the needed ``*.in`` files according to the Linux +source code which has been used. Make sure that your Linux source code has +been updated to the latest version. -For ``statx`` we had to add ``statx 332`` to :master:`include/lapi/syscalls/x86_64.in`, -``statx 383`` to :master:`include/lapi/syscalls/powerpc.in`, etc. Now lets look at -the code, which I will explain in more detail further down. +Once the new syscalls files have been updated, to rebuild our ``syscalls.h`` +file, please use ``./configure`` command. .. code-block:: c