[PATCH 05/10] tools headers: Update the syscall table with the kernel sources

Namhyung Kim posted 10 patches 8 months, 1 week ago
[PATCH 05/10] tools headers: Update the syscall table with the kernel sources
Posted by Namhyung Kim 8 months, 1 week ago
To pick up the changes in:

  c4a16820d9019940 fs: add open_tree_attr()
  2df1ad0d25803399 x86/arch_prctl: Simplify sys_arch_prctl()
  e632bca07c8eef1d arm64: generate 64-bit syscall.tbl

This is basically to support the new open_tree_attr syscall.  But it
also needs to update asm-generic unistd.h header to get the new syscall
number.  And arm64 unistd.h header was converted to use the generic
64-bit header.

Addressing this perf tools build warning:

  Warning: Kernel ABI header differences:
    diff -u tools/scripts/syscall.tbl scripts/syscall.tbl
    diff -u tools/perf/arch/x86/entry/syscalls/syscall_32.tbl arch/x86/entry/syscalls/syscall_32.tbl
    diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl
    diff -u tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/syscalls/syscall.tbl
    diff -u tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl
    diff -u tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl arch/mips/kernel/syscalls/syscall_n64.tbl
    diff -u tools/perf/arch/arm/entry/syscalls/syscall.tbl arch/arm/tools/syscall.tbl
    diff -u tools/perf/arch/sh/entry/syscalls/syscall.tbl arch/sh/kernel/syscalls/syscall.tbl
    diff -u tools/perf/arch/sparc/entry/syscalls/syscall.tbl arch/sparc/kernel/syscalls/syscall.tbl
    diff -u tools/perf/arch/xtensa/entry/syscalls/syscall.tbl arch/xtensa/kernel/syscalls/syscall.tbl
    diff -u tools/arch/arm64/include/uapi/asm/unistd.h arch/arm64/include/uapi/asm/unistd.h
    diff -u tools/include/uapi/asm-generic/unistd.h include/uapi/asm-generic/unistd.h

Please see tools/include/uapi/README for further details.

Cc: linux-arch@vger.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/arch/arm64/include/uapi/asm/unistd.h    | 24 +------------------
 tools/include/uapi/asm-generic/unistd.h       |  4 +++-
 .../perf/arch/arm/entry/syscalls/syscall.tbl  |  1 +
 .../arch/mips/entry/syscalls/syscall_n64.tbl  |  1 +
 .../arch/powerpc/entry/syscalls/syscall.tbl   |  1 +
 .../perf/arch/s390/entry/syscalls/syscall.tbl |  1 +
 tools/perf/arch/sh/entry/syscalls/syscall.tbl |  1 +
 .../arch/sparc/entry/syscalls/syscall.tbl     |  1 +
 .../arch/x86/entry/syscalls/syscall_32.tbl    |  3 ++-
 .../arch/x86/entry/syscalls/syscall_64.tbl    |  1 +
 .../arch/xtensa/entry/syscalls/syscall.tbl    |  1 +
 tools/scripts/syscall.tbl                     |  1 +
 12 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/tools/arch/arm64/include/uapi/asm/unistd.h b/tools/arch/arm64/include/uapi/asm/unistd.h
index 9306726337fe005e..df36f23876e863ff 100644
--- a/tools/arch/arm64/include/uapi/asm/unistd.h
+++ b/tools/arch/arm64/include/uapi/asm/unistd.h
@@ -1,24 +1,2 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/*
- * Copyright (C) 2012 ARM Ltd.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#define __ARCH_WANT_RENAMEAT
-#define __ARCH_WANT_NEW_STAT
-#define __ARCH_WANT_SET_GET_RLIMIT
-#define __ARCH_WANT_TIME32_SYSCALLS
-#define __ARCH_WANT_MEMFD_SECRET
-
-#include <asm-generic/unistd.h>
+#include <asm/unistd_64.h>
diff --git a/tools/include/uapi/asm-generic/unistd.h b/tools/include/uapi/asm-generic/unistd.h
index 88dc393c2bca38c0..2892a45023af6d3e 100644
--- a/tools/include/uapi/asm-generic/unistd.h
+++ b/tools/include/uapi/asm-generic/unistd.h
@@ -849,9 +849,11 @@ __SYSCALL(__NR_getxattrat, sys_getxattrat)
 __SYSCALL(__NR_listxattrat, sys_listxattrat)
 #define __NR_removexattrat 466
 __SYSCALL(__NR_removexattrat, sys_removexattrat)
+#define __NR_open_tree_attr 467
+__SYSCALL(__NR_open_tree_attr, sys_open_tree_attr)
 
 #undef __NR_syscalls
-#define __NR_syscalls 467
+#define __NR_syscalls 468
 
 /*
  * 32 bit systems traditionally used different
diff --git a/tools/perf/arch/arm/entry/syscalls/syscall.tbl b/tools/perf/arch/arm/entry/syscalls/syscall.tbl
index 49eeb2ad8dbd8e07..27c1d5ebcd91c8c2 100644
--- a/tools/perf/arch/arm/entry/syscalls/syscall.tbl
+++ b/tools/perf/arch/arm/entry/syscalls/syscall.tbl
@@ -481,3 +481,4 @@
 464	common	getxattrat			sys_getxattrat
 465	common	listxattrat			sys_listxattrat
 466	common	removexattrat			sys_removexattrat
+467	common	open_tree_attr			sys_open_tree_attr
diff --git a/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl b/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
index c844cd5cda620b28..1e8c44c7b61492ea 100644
--- a/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
+++ b/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
@@ -381,3 +381,4 @@
 464	n64	getxattrat			sys_getxattrat
 465	n64	listxattrat			sys_listxattrat
 466	n64	removexattrat			sys_removexattrat
+467	n64	open_tree_attr			sys_open_tree_attr
diff --git a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
index d8b4ab78bef076bd..9a084bdb892694bc 100644
--- a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
+++ b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
@@ -557,3 +557,4 @@
 464	common	getxattrat			sys_getxattrat
 465	common	listxattrat			sys_listxattrat
 466	common	removexattrat			sys_removexattrat
+467	common	open_tree_attr			sys_open_tree_attr
diff --git a/tools/perf/arch/s390/entry/syscalls/syscall.tbl b/tools/perf/arch/s390/entry/syscalls/syscall.tbl
index e9115b4d8b635b84..a4569b96ef06c54c 100644
--- a/tools/perf/arch/s390/entry/syscalls/syscall.tbl
+++ b/tools/perf/arch/s390/entry/syscalls/syscall.tbl
@@ -469,3 +469,4 @@
 464  common	getxattrat		sys_getxattrat			sys_getxattrat
 465  common	listxattrat		sys_listxattrat			sys_listxattrat
 466  common	removexattrat		sys_removexattrat		sys_removexattrat
+467  common	open_tree_attr		sys_open_tree_attr		sys_open_tree_attr
diff --git a/tools/perf/arch/sh/entry/syscalls/syscall.tbl b/tools/perf/arch/sh/entry/syscalls/syscall.tbl
index c8cad33bf250ea11..52a7652fcff6394b 100644
--- a/tools/perf/arch/sh/entry/syscalls/syscall.tbl
+++ b/tools/perf/arch/sh/entry/syscalls/syscall.tbl
@@ -470,3 +470,4 @@
 464	common	getxattrat			sys_getxattrat
 465	common	listxattrat			sys_listxattrat
 466	common	removexattrat			sys_removexattrat
+467	common	open_tree_attr			sys_open_tree_attr
diff --git a/tools/perf/arch/sparc/entry/syscalls/syscall.tbl b/tools/perf/arch/sparc/entry/syscalls/syscall.tbl
index 727f99d333b304b3..83e45eb6c095a36b 100644
--- a/tools/perf/arch/sparc/entry/syscalls/syscall.tbl
+++ b/tools/perf/arch/sparc/entry/syscalls/syscall.tbl
@@ -512,3 +512,4 @@
 464	common	getxattrat			sys_getxattrat
 465	common	listxattrat			sys_listxattrat
 466	common	removexattrat			sys_removexattrat
+467	common	open_tree_attr			sys_open_tree_attr
diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_32.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_32.tbl
index 4d0fb2fba7e208ae..ac007ea00979dc28 100644
--- a/tools/perf/arch/x86/entry/syscalls/syscall_32.tbl
+++ b/tools/perf/arch/x86/entry/syscalls/syscall_32.tbl
@@ -396,7 +396,7 @@
 381	i386	pkey_alloc		sys_pkey_alloc
 382	i386	pkey_free		sys_pkey_free
 383	i386	statx			sys_statx
-384	i386	arch_prctl		sys_arch_prctl			compat_sys_arch_prctl
+384	i386	arch_prctl		sys_arch_prctl
 385	i386	io_pgetevents		sys_io_pgetevents_time32	compat_sys_io_pgetevents
 386	i386	rseq			sys_rseq
 393	i386	semget			sys_semget
@@ -472,3 +472,4 @@
 464	i386	getxattrat		sys_getxattrat
 465	i386	listxattrat		sys_listxattrat
 466	i386	removexattrat		sys_removexattrat
+467	i386	open_tree_attr		sys_open_tree_attr
diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
index 5eb708bff1c791de..cfb5ca41e30de1a4 100644
--- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
+++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
@@ -390,6 +390,7 @@
 464	common	getxattrat		sys_getxattrat
 465	common	listxattrat		sys_listxattrat
 466	common	removexattrat		sys_removexattrat
+467	common	open_tree_attr		sys_open_tree_attr
 
 #
 # Due to a historical design error, certain syscalls are numbered differently
diff --git a/tools/perf/arch/xtensa/entry/syscalls/syscall.tbl b/tools/perf/arch/xtensa/entry/syscalls/syscall.tbl
index 37effc1b134eea06..f657a77314f8667f 100644
--- a/tools/perf/arch/xtensa/entry/syscalls/syscall.tbl
+++ b/tools/perf/arch/xtensa/entry/syscalls/syscall.tbl
@@ -437,3 +437,4 @@
 464	common	getxattrat			sys_getxattrat
 465	common	listxattrat			sys_listxattrat
 466	common	removexattrat			sys_removexattrat
+467	common	open_tree_attr			sys_open_tree_attr
diff --git a/tools/scripts/syscall.tbl b/tools/scripts/syscall.tbl
index ebbdb3c42e9f7461..580b4e246aecd5f0 100644
--- a/tools/scripts/syscall.tbl
+++ b/tools/scripts/syscall.tbl
@@ -407,3 +407,4 @@
 464	common	getxattrat			sys_getxattrat
 465	common	listxattrat			sys_listxattrat
 466	common	removexattrat			sys_removexattrat
+467	common	open_tree_attr			sys_open_tree_attr
-- 
2.49.0.504.g3bcea36a83-goog
Re: [PATCH 05/10] tools headers: Update the syscall table with the kernel sources
Posted by James Clark 8 months, 1 week ago

On 10/04/2025 1:11 am, Namhyung Kim wrote:
> To pick up the changes in:
> 
>    c4a16820d9019940 fs: add open_tree_attr()
>    2df1ad0d25803399 x86/arch_prctl: Simplify sys_arch_prctl()
>    e632bca07c8eef1d arm64: generate 64-bit syscall.tbl
> 
> This is basically to support the new open_tree_attr syscall.  But it
> also needs to update asm-generic unistd.h header to get the new syscall
> number.  And arm64 unistd.h header was converted to use the generic
> 64-bit header.
> 
> Addressing this perf tools build warning:
> 
>    Warning: Kernel ABI header differences:
>      diff -u tools/scripts/syscall.tbl scripts/syscall.tbl
>      diff -u tools/perf/arch/x86/entry/syscalls/syscall_32.tbl arch/x86/entry/syscalls/syscall_32.tbl
>      diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl
>      diff -u tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/syscalls/syscall.tbl
>      diff -u tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl
>      diff -u tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl arch/mips/kernel/syscalls/syscall_n64.tbl
>      diff -u tools/perf/arch/arm/entry/syscalls/syscall.tbl arch/arm/tools/syscall.tbl
>      diff -u tools/perf/arch/sh/entry/syscalls/syscall.tbl arch/sh/kernel/syscalls/syscall.tbl
>      diff -u tools/perf/arch/sparc/entry/syscalls/syscall.tbl arch/sparc/kernel/syscalls/syscall.tbl
>      diff -u tools/perf/arch/xtensa/entry/syscalls/syscall.tbl arch/xtensa/kernel/syscalls/syscall.tbl
>      diff -u tools/arch/arm64/include/uapi/asm/unistd.h arch/arm64/include/uapi/asm/unistd.h
>      diff -u tools/include/uapi/asm-generic/unistd.h include/uapi/asm-generic/unistd.h
> 
> Please see tools/include/uapi/README for further details.
> 
> Cc: linux-arch@vger.kernel.org
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>   tools/arch/arm64/include/uapi/asm/unistd.h    | 24 +------------------
>   tools/include/uapi/asm-generic/unistd.h       |  4 +++-
>   .../perf/arch/arm/entry/syscalls/syscall.tbl  |  1 +
>   .../arch/mips/entry/syscalls/syscall_n64.tbl  |  1 +
>   .../arch/powerpc/entry/syscalls/syscall.tbl   |  1 +
>   .../perf/arch/s390/entry/syscalls/syscall.tbl |  1 +
>   tools/perf/arch/sh/entry/syscalls/syscall.tbl |  1 +
>   .../arch/sparc/entry/syscalls/syscall.tbl     |  1 +
>   .../arch/x86/entry/syscalls/syscall_32.tbl    |  3 ++-
>   .../arch/x86/entry/syscalls/syscall_64.tbl    |  1 +
>   .../arch/xtensa/entry/syscalls/syscall.tbl    |  1 +
>   tools/scripts/syscall.tbl                     |  1 +
>   12 files changed, 15 insertions(+), 25 deletions(-)
> 
> diff --git a/tools/arch/arm64/include/uapi/asm/unistd.h b/tools/arch/arm64/include/uapi/asm/unistd.h
> index 9306726337fe005e..df36f23876e863ff 100644
> --- a/tools/arch/arm64/include/uapi/asm/unistd.h
> +++ b/tools/arch/arm64/include/uapi/asm/unistd.h
> @@ -1,24 +1,2 @@
>   /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> -/*
> - * Copyright (C) 2012 ARM Ltd.
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> - */
> -
> -#define __ARCH_WANT_RENAMEAT
> -#define __ARCH_WANT_NEW_STAT
> -#define __ARCH_WANT_SET_GET_RLIMIT
> -#define __ARCH_WANT_TIME32_SYSCALLS
> -#define __ARCH_WANT_MEMFD_SECRET
> -
> -#include <asm-generic/unistd.h>
> +#include <asm/unistd_64.h>

Hi Namhyung,

Since we're not including the generic syscalls here anymore we now need 
to generate the syscall header file for the Perf build to work (build 
error pasted at the end for reference).

I had a go at adding the rule for it, but I saw that we'd need to pull 
in quite a bit from the kernel so it was blurring the lines about the 
separation of the tools/ folder. For example this file has the arm64 defs:

  arch/arm64/kernel/Makefile.syscalls

To make this common part of the makefile work:

  scripts/Makefile.asm-headers

Maybe we can just copy or reimplement Makefile.syscalls, but I'm not 
even sure if Makefile.asm-headers will work with the tools/ build 
structure so maybe that has to be re-implemented too. Adding Arnd to see 
what he thinks.

As far as I can tell this is a separate issue to the work that Charlie 
and Ian did recently to build all arch's syscall numbers into Perf to 
use for reporting, as this is requires a single header for the build.

Thanks
James

---

In file included from /usr/include/aarch64-linux-gnu/sys/syscall.h:24,
                  from evsel.c:4:
/home/jamcla02/workspace/linux/linux/tools/arch/arm64/include/uapi/asm/unistd.h:2:10: 
fatal error: asm/unistd_64.h: No such file or directory
     2 | #include <asm/unistd_64.h>
       |          ^~~~~~~~~~~~~~~~~
Re: [PATCH 05/10] tools headers: Update the syscall table with the kernel sources
Posted by James Clark 8 months ago

On 14/04/2025 5:28 pm, James Clark wrote:
> 
> 
> On 10/04/2025 1:11 am, Namhyung Kim wrote:
>> To pick up the changes in:
>>
>>    c4a16820d9019940 fs: add open_tree_attr()
>>    2df1ad0d25803399 x86/arch_prctl: Simplify sys_arch_prctl()
>>    e632bca07c8eef1d arm64: generate 64-bit syscall.tbl
>>
>> This is basically to support the new open_tree_attr syscall.  But it
>> also needs to update asm-generic unistd.h header to get the new syscall
>> number.  And arm64 unistd.h header was converted to use the generic
>> 64-bit header.
>>
>> Addressing this perf tools build warning:
>>
>>    Warning: Kernel ABI header differences:
>>      diff -u tools/scripts/syscall.tbl scripts/syscall.tbl
>>      diff -u tools/perf/arch/x86/entry/syscalls/syscall_32.tbl arch/ 
>> x86/entry/syscalls/syscall_32.tbl
>>      diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/ 
>> x86/entry/syscalls/syscall_64.tbl
>>      diff -u tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/ 
>> powerpc/kernel/syscalls/syscall.tbl
>>      diff -u tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/ 
>> s390/kernel/syscalls/syscall.tbl
>>      diff -u tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl arch/ 
>> mips/kernel/syscalls/syscall_n64.tbl
>>      diff -u tools/perf/arch/arm/entry/syscalls/syscall.tbl arch/arm/ 
>> tools/syscall.tbl
>>      diff -u tools/perf/arch/sh/entry/syscalls/syscall.tbl arch/sh/ 
>> kernel/syscalls/syscall.tbl
>>      diff -u tools/perf/arch/sparc/entry/syscalls/syscall.tbl arch/ 
>> sparc/kernel/syscalls/syscall.tbl
>>      diff -u tools/perf/arch/xtensa/entry/syscalls/syscall.tbl arch/ 
>> xtensa/kernel/syscalls/syscall.tbl
>>      diff -u tools/arch/arm64/include/uapi/asm/unistd.h arch/arm64/ 
>> include/uapi/asm/unistd.h
>>      diff -u tools/include/uapi/asm-generic/unistd.h include/uapi/asm- 
>> generic/unistd.h
>>
>> Please see tools/include/uapi/README for further details.
>>
>> Cc: linux-arch@vger.kernel.org
>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>> ---
>>   tools/arch/arm64/include/uapi/asm/unistd.h    | 24 +------------------
>>   tools/include/uapi/asm-generic/unistd.h       |  4 +++-
>>   .../perf/arch/arm/entry/syscalls/syscall.tbl  |  1 +
>>   .../arch/mips/entry/syscalls/syscall_n64.tbl  |  1 +
>>   .../arch/powerpc/entry/syscalls/syscall.tbl   |  1 +
>>   .../perf/arch/s390/entry/syscalls/syscall.tbl |  1 +
>>   tools/perf/arch/sh/entry/syscalls/syscall.tbl |  1 +
>>   .../arch/sparc/entry/syscalls/syscall.tbl     |  1 +
>>   .../arch/x86/entry/syscalls/syscall_32.tbl    |  3 ++-
>>   .../arch/x86/entry/syscalls/syscall_64.tbl    |  1 +
>>   .../arch/xtensa/entry/syscalls/syscall.tbl    |  1 +
>>   tools/scripts/syscall.tbl                     |  1 +
>>   12 files changed, 15 insertions(+), 25 deletions(-)
>>
>> diff --git a/tools/arch/arm64/include/uapi/asm/unistd.h b/tools/arch/ 
>> arm64/include/uapi/asm/unistd.h
>> index 9306726337fe005e..df36f23876e863ff 100644
>> --- a/tools/arch/arm64/include/uapi/asm/unistd.h
>> +++ b/tools/arch/arm64/include/uapi/asm/unistd.h
>> @@ -1,24 +1,2 @@
>>   /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
>> -/*
>> - * Copyright (C) 2012 ARM Ltd.
>> - *
>> - * This program is free software; you can redistribute it and/or modify
>> - * it under the terms of the GNU General Public License version 2 as
>> - * published by the Free Software Foundation.
>> - *
>> - * This program is distributed in the hope that it will be useful,
>> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> - * GNU General Public License for more details.
>> - *
>> - * You should have received a copy of the GNU General Public License
>> - * along with this program.  If not, see <http://www.gnu.org/licenses/>.
>> - */
>> -
>> -#define __ARCH_WANT_RENAMEAT
>> -#define __ARCH_WANT_NEW_STAT
>> -#define __ARCH_WANT_SET_GET_RLIMIT
>> -#define __ARCH_WANT_TIME32_SYSCALLS
>> -#define __ARCH_WANT_MEMFD_SECRET
>> -
>> -#include <asm-generic/unistd.h>
>> +#include <asm/unistd_64.h>
> 
> Hi Namhyung,
> 
> Since we're not including the generic syscalls here anymore we now need 
> to generate the syscall header file for the Perf build to work (build 
> error pasted at the end for reference).
> 
> I had a go at adding the rule for it, but I saw that we'd need to pull 
> in quite a bit from the kernel so it was blurring the lines about the 
> separation of the tools/ folder. For example this file has the arm64 defs:
> 
>   arch/arm64/kernel/Makefile.syscalls
> 
> To make this common part of the makefile work:
> 
>   scripts/Makefile.asm-headers
> 
> Maybe we can just copy or reimplement Makefile.syscalls, but I'm not 
> even sure if Makefile.asm-headers will work with the tools/ build 
> structure so maybe that has to be re-implemented too. Adding Arnd to see 
> what he thinks.
> 
> As far as I can tell this is a separate issue to the work that Charlie 
> and Ian did recently to build all arch's syscall numbers into Perf to 
> use for reporting, as this is requires a single header for the build.
> 
> Thanks
> James
> 
> ---
> 
> In file included from /usr/include/aarch64-linux-gnu/sys/syscall.h:24,
>                   from evsel.c:4:
> /home/jamcla02/workspace/linux/linux/tools/arch/arm64/include/uapi/asm/ 
> unistd.h:2:10: fatal error: asm/unistd_64.h: No such file or directory
>      2 | #include <asm/unistd_64.h>
>        |          ^~~~~~~~~~~~~~~~~
> 
> 
> 

Hmmm I see this was also mentioned a while ago here [1]. Maybe I can 
have another go at adding the makerule to generate the file. I'll 
probably start by including as much as possible from the existing make 
rules from the kernel side. I think something similar was already done 
for generating the sysreg defs in commit 02e85f74668e ("tools: arm64: 
Add a Makefile for generating sysreg-defs.h")


[1]: 
https://lore.kernel.org/lkml/ZrO5HR9x2xyPKttx@google.com/T/#m269c1d3c64e3e0c96f45102d358d9583c69b722f



Re: [PATCH 05/10] tools headers: Update the syscall table with the kernel sources
Posted by Jon Hunter 7 months, 4 weeks ago
On 16/04/2025 14:26, James Clark wrote:
> 
> 
> On 14/04/2025 5:28 pm, James Clark wrote:
>>
>>
>> On 10/04/2025 1:11 am, Namhyung Kim wrote:
>>> To pick up the changes in:
>>>
>>>    c4a16820d9019940 fs: add open_tree_attr()
>>>    2df1ad0d25803399 x86/arch_prctl: Simplify sys_arch_prctl()
>>>    e632bca07c8eef1d arm64: generate 64-bit syscall.tbl
>>>
>>> This is basically to support the new open_tree_attr syscall.  But it
>>> also needs to update asm-generic unistd.h header to get the new syscall
>>> number.  And arm64 unistd.h header was converted to use the generic
>>> 64-bit header.
>>>
>>> Addressing this perf tools build warning:
>>>
>>>    Warning: Kernel ABI header differences:
>>>      diff -u tools/scripts/syscall.tbl scripts/syscall.tbl
>>>      diff -u tools/perf/arch/x86/entry/syscalls/syscall_32.tbl arch/ 
>>> x86/entry/syscalls/syscall_32.tbl
>>>      diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/ 
>>> x86/entry/syscalls/syscall_64.tbl
>>>      diff -u tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/ 
>>> powerpc/kernel/syscalls/syscall.tbl
>>>      diff -u tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/ 
>>> s390/kernel/syscalls/syscall.tbl
>>>      diff -u tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl 
>>> arch/ mips/kernel/syscalls/syscall_n64.tbl
>>>      diff -u tools/perf/arch/arm/entry/syscalls/syscall.tbl arch/arm/ 
>>> tools/syscall.tbl
>>>      diff -u tools/perf/arch/sh/entry/syscalls/syscall.tbl arch/sh/ 
>>> kernel/syscalls/syscall.tbl
>>>      diff -u tools/perf/arch/sparc/entry/syscalls/syscall.tbl arch/ 
>>> sparc/kernel/syscalls/syscall.tbl
>>>      diff -u tools/perf/arch/xtensa/entry/syscalls/syscall.tbl arch/ 
>>> xtensa/kernel/syscalls/syscall.tbl
>>>      diff -u tools/arch/arm64/include/uapi/asm/unistd.h arch/arm64/ 
>>> include/uapi/asm/unistd.h
>>>      diff -u tools/include/uapi/asm-generic/unistd.h include/uapi/ 
>>> asm- generic/unistd.h
>>>
>>> Please see tools/include/uapi/README for further details.
>>>
>>> Cc: linux-arch@vger.kernel.org
>>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>>> ---
>>>   tools/arch/arm64/include/uapi/asm/unistd.h    | 24 +------------------
>>>   tools/include/uapi/asm-generic/unistd.h       |  4 +++-
>>>   .../perf/arch/arm/entry/syscalls/syscall.tbl  |  1 +
>>>   .../arch/mips/entry/syscalls/syscall_n64.tbl  |  1 +
>>>   .../arch/powerpc/entry/syscalls/syscall.tbl   |  1 +
>>>   .../perf/arch/s390/entry/syscalls/syscall.tbl |  1 +
>>>   tools/perf/arch/sh/entry/syscalls/syscall.tbl |  1 +
>>>   .../arch/sparc/entry/syscalls/syscall.tbl     |  1 +
>>>   .../arch/x86/entry/syscalls/syscall_32.tbl    |  3 ++-
>>>   .../arch/x86/entry/syscalls/syscall_64.tbl    |  1 +
>>>   .../arch/xtensa/entry/syscalls/syscall.tbl    |  1 +
>>>   tools/scripts/syscall.tbl                     |  1 +
>>>   12 files changed, 15 insertions(+), 25 deletions(-)
>>>
>>> diff --git a/tools/arch/arm64/include/uapi/asm/unistd.h b/tools/arch/ 
>>> arm64/include/uapi/asm/unistd.h
>>> index 9306726337fe005e..df36f23876e863ff 100644
>>> --- a/tools/arch/arm64/include/uapi/asm/unistd.h
>>> +++ b/tools/arch/arm64/include/uapi/asm/unistd.h
>>> @@ -1,24 +1,2 @@
>>>   /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
>>> -/*
>>> - * Copyright (C) 2012 ARM Ltd.
>>> - *
>>> - * This program is free software; you can redistribute it and/or modify
>>> - * it under the terms of the GNU General Public License version 2 as
>>> - * published by the Free Software Foundation.
>>> - *
>>> - * This program is distributed in the hope that it will be useful,
>>> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> - * GNU General Public License for more details.
>>> - *
>>> - * You should have received a copy of the GNU General Public License
>>> - * along with this program.  If not, see <http://www.gnu.org/ 
>>> licenses/>.
>>> - */
>>> -
>>> -#define __ARCH_WANT_RENAMEAT
>>> -#define __ARCH_WANT_NEW_STAT
>>> -#define __ARCH_WANT_SET_GET_RLIMIT
>>> -#define __ARCH_WANT_TIME32_SYSCALLS
>>> -#define __ARCH_WANT_MEMFD_SECRET
>>> -
>>> -#include <asm-generic/unistd.h>
>>> +#include <asm/unistd_64.h>
>>
>> Hi Namhyung,
>>
>> Since we're not including the generic syscalls here anymore we now 
>> need to generate the syscall header file for the Perf build to work 
>> (build error pasted at the end for reference).
>>
>> I had a go at adding the rule for it, but I saw that we'd need to pull 
>> in quite a bit from the kernel so it was blurring the lines about the 
>> separation of the tools/ folder. For example this file has the arm64 
>> defs:
>>
>>   arch/arm64/kernel/Makefile.syscalls
>>
>> To make this common part of the makefile work:
>>
>>   scripts/Makefile.asm-headers
>>
>> Maybe we can just copy or reimplement Makefile.syscalls, but I'm not 
>> even sure if Makefile.asm-headers will work with the tools/ build 
>> structure so maybe that has to be re-implemented too. Adding Arnd to 
>> see what he thinks.
>>
>> As far as I can tell this is a separate issue to the work that Charlie 
>> and Ian did recently to build all arch's syscall numbers into Perf to 
>> use for reporting, as this is requires a single header for the build.
>>
>> Thanks
>> James
>>
>> ---
>>
>> In file included from /usr/include/aarch64-linux-gnu/sys/syscall.h:24,
>>                   from evsel.c:4:
>> /home/jamcla02/workspace/linux/linux/tools/arch/arm64/include/uapi/ 
>> asm/ unistd.h:2:10: fatal error: asm/unistd_64.h: No such file or 
>> directory
>>      2 | #include <asm/unistd_64.h>
>>        |          ^~~~~~~~~~~~~~~~~
>>
>>
>>
> 
> Hmmm I see this was also mentioned a while ago here [1]. Maybe I can 
> have another go at adding the makerule to generate the file. I'll 
> probably start by including as much as possible from the existing make 
> rules from the kernel side. I think something similar was already done 
> for generating the sysreg defs in commit 02e85f74668e ("tools: arm64: 
> Add a Makefile for generating sysreg-defs.h")
> 
> 
> [1]: https://lore.kernel.org/lkml/ZrO5HR9x2xyPKttx@google.com/T/ 
> #m269c1d3c64e3e0c96f45102d358d9583c69b722f


FWIW I am seeing this build issue too on ARM64 and these changes have 
now landed in the mainline :-(

So would be great to get this fixed or reverted.

Jon

-- 
nvpublic

Re: [PATCH 05/10] tools headers: Update the syscall table with the kernel sources
Posted by James Clark 7 months, 4 weeks ago

On 23/04/2025 10:24 am, Jon Hunter wrote:
> 
> On 16/04/2025 14:26, James Clark wrote:
>>
>>
>> On 14/04/2025 5:28 pm, James Clark wrote:
>>>
>>>
>>> On 10/04/2025 1:11 am, Namhyung Kim wrote:
>>>> To pick up the changes in:
>>>>
>>>>    c4a16820d9019940 fs: add open_tree_attr()
>>>>    2df1ad0d25803399 x86/arch_prctl: Simplify sys_arch_prctl()
>>>>    e632bca07c8eef1d arm64: generate 64-bit syscall.tbl
>>>>
>>>> This is basically to support the new open_tree_attr syscall.  But it
>>>> also needs to update asm-generic unistd.h header to get the new syscall
>>>> number.  And arm64 unistd.h header was converted to use the generic
>>>> 64-bit header.
>>>>
>>>> Addressing this perf tools build warning:
>>>>
>>>>    Warning: Kernel ABI header differences:
>>>>      diff -u tools/scripts/syscall.tbl scripts/syscall.tbl
>>>>      diff -u tools/perf/arch/x86/entry/syscalls/syscall_32.tbl arch/ 
>>>> x86/entry/syscalls/syscall_32.tbl
>>>>      diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/ 
>>>> x86/entry/syscalls/syscall_64.tbl
>>>>      diff -u tools/perf/arch/powerpc/entry/syscalls/syscall.tbl 
>>>> arch/ powerpc/kernel/syscalls/syscall.tbl
>>>>      diff -u tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/ 
>>>> s390/kernel/syscalls/syscall.tbl
>>>>      diff -u tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl 
>>>> arch/ mips/kernel/syscalls/syscall_n64.tbl
>>>>      diff -u tools/perf/arch/arm/entry/syscalls/syscall.tbl arch/ 
>>>> arm/ tools/syscall.tbl
>>>>      diff -u tools/perf/arch/sh/entry/syscalls/syscall.tbl arch/sh/ 
>>>> kernel/syscalls/syscall.tbl
>>>>      diff -u tools/perf/arch/sparc/entry/syscalls/syscall.tbl arch/ 
>>>> sparc/kernel/syscalls/syscall.tbl
>>>>      diff -u tools/perf/arch/xtensa/entry/syscalls/syscall.tbl arch/ 
>>>> xtensa/kernel/syscalls/syscall.tbl
>>>>      diff -u tools/arch/arm64/include/uapi/asm/unistd.h arch/arm64/ 
>>>> include/uapi/asm/unistd.h
>>>>      diff -u tools/include/uapi/asm-generic/unistd.h include/uapi/ 
>>>> asm- generic/unistd.h
>>>>
>>>> Please see tools/include/uapi/README for further details.
>>>>
>>>> Cc: linux-arch@vger.kernel.org
>>>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>>>> ---
>>>>   tools/arch/arm64/include/uapi/asm/unistd.h    | 24 
>>>> +------------------
>>>>   tools/include/uapi/asm-generic/unistd.h       |  4 +++-
>>>>   .../perf/arch/arm/entry/syscalls/syscall.tbl  |  1 +
>>>>   .../arch/mips/entry/syscalls/syscall_n64.tbl  |  1 +
>>>>   .../arch/powerpc/entry/syscalls/syscall.tbl   |  1 +
>>>>   .../perf/arch/s390/entry/syscalls/syscall.tbl |  1 +
>>>>   tools/perf/arch/sh/entry/syscalls/syscall.tbl |  1 +
>>>>   .../arch/sparc/entry/syscalls/syscall.tbl     |  1 +
>>>>   .../arch/x86/entry/syscalls/syscall_32.tbl    |  3 ++-
>>>>   .../arch/x86/entry/syscalls/syscall_64.tbl    |  1 +
>>>>   .../arch/xtensa/entry/syscalls/syscall.tbl    |  1 +
>>>>   tools/scripts/syscall.tbl                     |  1 +
>>>>   12 files changed, 15 insertions(+), 25 deletions(-)
>>>>
>>>> diff --git a/tools/arch/arm64/include/uapi/asm/unistd.h b/tools/ 
>>>> arch/ arm64/include/uapi/asm/unistd.h
>>>> index 9306726337fe005e..df36f23876e863ff 100644
>>>> --- a/tools/arch/arm64/include/uapi/asm/unistd.h
>>>> +++ b/tools/arch/arm64/include/uapi/asm/unistd.h
>>>> @@ -1,24 +1,2 @@
>>>>   /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
>>>> -/*
>>>> - * Copyright (C) 2012 ARM Ltd.
>>>> - *
>>>> - * This program is free software; you can redistribute it and/or 
>>>> modify
>>>> - * it under the terms of the GNU General Public License version 2 as
>>>> - * published by the Free Software Foundation.
>>>> - *
>>>> - * This program is distributed in the hope that it will be useful,
>>>> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>>> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>>> - * GNU General Public License for more details.
>>>> - *
>>>> - * You should have received a copy of the GNU General Public License
>>>> - * along with this program.  If not, see <http://www.gnu.org/ 
>>>> licenses/>.
>>>> - */
>>>> -
>>>> -#define __ARCH_WANT_RENAMEAT
>>>> -#define __ARCH_WANT_NEW_STAT
>>>> -#define __ARCH_WANT_SET_GET_RLIMIT
>>>> -#define __ARCH_WANT_TIME32_SYSCALLS
>>>> -#define __ARCH_WANT_MEMFD_SECRET
>>>> -
>>>> -#include <asm-generic/unistd.h>
>>>> +#include <asm/unistd_64.h>
>>>
>>> Hi Namhyung,
>>>
>>> Since we're not including the generic syscalls here anymore we now 
>>> need to generate the syscall header file for the Perf build to work 
>>> (build error pasted at the end for reference).
>>>
>>> I had a go at adding the rule for it, but I saw that we'd need to 
>>> pull in quite a bit from the kernel so it was blurring the lines 
>>> about the separation of the tools/ folder. For example this file has 
>>> the arm64 defs:
>>>
>>>   arch/arm64/kernel/Makefile.syscalls
>>>
>>> To make this common part of the makefile work:
>>>
>>>   scripts/Makefile.asm-headers
>>>
>>> Maybe we can just copy or reimplement Makefile.syscalls, but I'm not 
>>> even sure if Makefile.asm-headers will work with the tools/ build 
>>> structure so maybe that has to be re-implemented too. Adding Arnd to 
>>> see what he thinks.
>>>
>>> As far as I can tell this is a separate issue to the work that 
>>> Charlie and Ian did recently to build all arch's syscall numbers into 
>>> Perf to use for reporting, as this is requires a single header for 
>>> the build.
>>>
>>> Thanks
>>> James
>>>
>>> ---
>>>
>>> In file included from /usr/include/aarch64-linux-gnu/sys/syscall.h:24,
>>>                   from evsel.c:4:
>>> /home/jamcla02/workspace/linux/linux/tools/arch/arm64/include/uapi/ 
>>> asm/ unistd.h:2:10: fatal error: asm/unistd_64.h: No such file or 
>>> directory
>>>      2 | #include <asm/unistd_64.h>
>>>        |          ^~~~~~~~~~~~~~~~~
>>>
>>>
>>>
>>
>> Hmmm I see this was also mentioned a while ago here [1]. Maybe I can 
>> have another go at adding the makerule to generate the file. I'll 
>> probably start by including as much as possible from the existing make 
>> rules from the kernel side. I think something similar was already done 
>> for generating the sysreg defs in commit 02e85f74668e ("tools: arm64: 
>> Add a Makefile for generating sysreg-defs.h")
>>
>>
>> [1]: https://lore.kernel.org/lkml/ZrO5HR9x2xyPKttx@google.com/T/ 
>> #m269c1d3c64e3e0c96f45102d358d9583c69b722f
> 
> 
> FWIW I am seeing this build issue too on ARM64 and these changes have 
> now landed in the mainline :-(
> 
> So would be great to get this fixed or reverted.
> 
> Jon
> 

Hi Jon,

I probably should have updated this thread, but the fix is here:

https://lore.kernel.org/linux-perf-users/20250417-james-perf-fix-gen-syscall-v1-1-1d268c923901@linaro.org/

Thanks
James

Re: [PATCH 05/10] tools headers: Update the syscall table with the kernel sources
Posted by Jon Hunter 7 months, 4 weeks ago
On 23/04/2025 15:57, James Clark wrote:

...

>> FWIW I am seeing this build issue too on ARM64 and these changes have 
>> now landed in the mainline :-(
>>
>> So would be great to get this fixed or reverted.
>>
>> Jon
>>
> 
> Hi Jon,
> 
> I probably should have updated this thread, but the fix is here:
> 
> https://lore.kernel.org/linux-perf-users/20250417-james-perf-fix-gen- 
> syscall-v1-1-1d268c923901@linaro.org/

Great!

Tested-by: Jon Hunter <jonathanh@nvidia.com>

Thanks for fixing and sharing!

Jon

-- 
nvpublic