2018-07-07 05:34:43 +08:00
|
|
|
#!/bin/sh
|
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
#
|
|
|
|
# Generate system call table for perf. Derived from
|
|
|
|
# powerpc script.
|
|
|
|
#
|
|
|
|
# Copyright IBM Corp. 2017
|
|
|
|
# Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
|
|
|
|
# Changed by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
|
|
|
|
# Changed by: Kim Phillips <kim.phillips@arm.com>
|
|
|
|
|
|
|
|
gcc=$1
|
|
|
|
hostcc=$2
|
2018-08-07 06:28:00 +08:00
|
|
|
incpath=$3
|
|
|
|
input=$4
|
2018-07-07 05:34:43 +08:00
|
|
|
|
|
|
|
if ! test -r $input; then
|
|
|
|
echo "Could not read input file" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
create_table_from_c()
|
|
|
|
{
|
|
|
|
local sc nr last_sc
|
|
|
|
|
2018-10-18 16:26:13 +08:00
|
|
|
create_table_exe=`mktemp ${TMPDIR:-/tmp}/create-table-XXXXXX`
|
2018-07-07 05:34:43 +08:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cat <<-_EoHEADER
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "$input"
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
_EoHEADER
|
|
|
|
|
|
|
|
while read sc nr; do
|
|
|
|
printf "%s\n" " printf(\"\\t[%d] = \\\"$sc\\\",\\n\", __NR_$sc);"
|
|
|
|
last_sc=$sc
|
|
|
|
done
|
|
|
|
|
|
|
|
printf "%s\n" " printf(\"#define SYSCALLTBL_ARM64_MAX_ID %d\\n\", __NR_$last_sc);"
|
|
|
|
printf "}\n"
|
|
|
|
|
2018-08-07 06:28:00 +08:00
|
|
|
} | $hostcc -I $incpath/include/uapi -o $create_table_exe -x c -
|
2018-07-07 05:34:43 +08:00
|
|
|
|
|
|
|
$create_table_exe
|
|
|
|
|
|
|
|
rm -f $create_table_exe
|
|
|
|
}
|
|
|
|
|
|
|
|
create_table()
|
|
|
|
{
|
|
|
|
echo "static const char *syscalltbl_arm64[] = {"
|
|
|
|
create_table_from_c
|
|
|
|
echo "};"
|
|
|
|
}
|
|
|
|
|
perf arm64: Fix mksyscalltbl when system kernel headers are ahead of the kernel
When a host system has kernel headers that are newer than a compiling
kernel, mksyscalltbl fails with errors such as:
<stdin>: In function 'main':
<stdin>:271:44: error: '__NR_kexec_file_load' undeclared (first use in this function)
<stdin>:271:44: note: each undeclared identifier is reported only once for each function it appears in
<stdin>:272:46: error: '__NR_pidfd_send_signal' undeclared (first use in this function)
<stdin>:273:43: error: '__NR_io_uring_setup' undeclared (first use in this function)
<stdin>:274:43: error: '__NR_io_uring_enter' undeclared (first use in this function)
<stdin>:275:46: error: '__NR_io_uring_register' undeclared (first use in this function)
tools/perf/arch/arm64/entry/syscalls//mksyscalltbl: line 48: /tmp/create-table-xvUQdD: Permission denied
mksyscalltbl is compiled with default host includes, but run with
compiling kernel tree includes, causing some syscall numbers to being
undeclared.
Committer testing:
Before this patch, in my cross build environment, no build problems, but
these new syscalls were not in the syscalls.c generated from the
unistd.h file, which is a bug, this patch fixes it:
perfbuilder@6e20056ed532:/git/perf$ tail /tmp/build/perf/arch/arm64/include/generated/asm/syscalls.c
[292] = "io_pgetevents",
[293] = "rseq",
[294] = "kexec_file_load",
[424] = "pidfd_send_signal",
[425] = "io_uring_setup",
[426] = "io_uring_enter",
[427] = "io_uring_register",
[428] = "syscalls",
};
perfbuilder@6e20056ed532:/git/perf$ strings /tmp/build/perf/perf | egrep '^(io_uring_|pidfd_|kexec_file)'
kexec_file_load
pidfd_send_signal
io_uring_setup
io_uring_enter
io_uring_register
perfbuilder@6e20056ed532:/git/perf$
$
Well, there is that last "syscalls" thing, but that looks like some
other bug.
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Michael Petlan <mpetlan@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Hendrik Brueckner <brueckner@linux.ibm.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kim Phillips <kim.phillips@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/20190521030203.1447-1-vt@altlinux.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-05-21 11:02:03 +08:00
|
|
|
$gcc -E -dM -x c -I $incpath/include/uapi $input \
|
2018-07-07 05:34:43 +08:00
|
|
|
|sed -ne 's/^#define __NR_//p' \
|
|
|
|
|sort -t' ' -k2 -nu \
|
|
|
|
|create_table
|