[PATCH RFC v2 2/4] syscalls: Add support for x86_x32 for the common syscall table

AndrĂ© Almeida <[email protected]> Mon, 27 Jul 2026 23:47:03 -0300
Newsgroups org.kernel.vger.linux-kbuild,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
x86_x32 has a peculiar ordering: first, goes the x86 syscalls. Then, the
shared syscall numbers from the common table, and finally the x86_x32
syscall numbers. Adapt syscallhdr.sh script to take this into account.

Let's hope that x32 is deprecated before the syscall table reaches syscall
512, to avoid making the shared table more confusing.

Signed-off-by: AndrĂ© Almeida <[email protected]>
---
 scripts/syscallhdr.sh | 34 +++++++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/scripts/syscallhdr.sh b/scripts/syscallhdr.sh
index 0fc3e8dfc7e5..06372006509e 100755
--- a/scripts/syscallhdr.sh
+++ b/scripts/syscallhdr.sh
@@ -72,6 +72,12 @@ fi
 infile="$1"
 outfile="$2"
 
+is_x32=
+
+if [[ "$abis" == *"x32"* ]]; then
+	is_x32=1
+fi
+
 guard=_UAPI_ASM_$(basename "$outfile" |
 	sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
 	-e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g')
@@ -116,10 +122,32 @@ gen_hdr() {
 
 emit_start_guard > $outfile
 
-gen_hdr $infile >> $outfile
+# x32 has a special ordering. We need to get first the common numbers from x86
+# table, then the common numbers from scripts/syscall_common.tbl and finally the
+# x32 numbers
+if [ -n "$is_x32" ]; then
+
+	abis="${abis//x32|/}"
+	abis="${abis//|x32/}"
+	abis="${abis//x32/}"
+
+	if [[ $abis != "()" ]]; then
+		gen_hdr $infile >> $outfile
+
+		if [ -n "$common_tbl" ]; then
+			gen_hdr $COMMON_TBL_PATH  >> "$outfile"
+		fi
+	fi
+
+	abis="(x32)"
+
+	gen_hdr $infile >> "$outfile"
+else
+	gen_hdr $infile >> $outfile
 
-if [ -n "$common_tbl" ]; then
-	gen_hdr $COMMON_TBL_PATH  >> "$outfile"
+	if [ -n "$common_tbl" ]; then
+		gen_hdr $COMMON_TBL_PATH  >> "$outfile"
+	fi
 fi
 
 emit_nr $(($max + 1)) $prefix >> $outfile

-- 
2.55.0