System call table generation support is provided for
alpha, ia64, m68k, microblaze, mips, parisc, powerpc,
sh, sparc and xtensa architectures. The implementat-
ions are almost similar across all the above archte-
ctures. In order to reduce the source code across all
the above architectures, create common ".sh" files and
keep it in the common directory, script/. This will
be a generic scripts which can use for all the above
architectures.
This patch depends on;
https://lore.kernel.org/lkml/[email protected]/
Firoz Khan (2):
xtensa: remove nargs from __SYSCALL
xtensa: generate uapi header and syscall table header files
arch/xtensa/kernel/syscall.c | 2 +-
arch/xtensa/kernel/syscalls/Makefile | 11 ++++++++--
arch/xtensa/kernel/syscalls/syscallhdr.sh | 36 -------------------------------
arch/xtensa/kernel/syscalls/syscalltbl.sh | 32 ---------------------------
4 files changed, 10 insertions(+), 71 deletions(-)
delete mode 100644 arch/xtensa/kernel/syscalls/syscallhdr.sh
delete mode 100644 arch/xtensa/kernel/syscalls/syscalltbl.sh
--
1.9.1
The __SYSCALL macro's arguments are system call number,
system call entry name and number of arguments for the
system call.
Argument- nargs in __SYSCALL(nr, entry, nargs) is neither
calculated nor used anywhere. So it would be better to
keep the implementaion as __SYSCALL(nr, entry). This will
unifies the implementation with some other architetures
too.
Signed-off-by: Firoz Khan <[email protected]>
---
arch/xtensa/kernel/syscall.c | 2 +-
arch/xtensa/kernel/syscalls/syscalltbl.sh | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/xtensa/kernel/syscall.c b/arch/xtensa/kernel/syscall.c
index 2c415fc..0665339 100644
--- a/arch/xtensa/kernel/syscall.c
+++ b/arch/xtensa/kernel/syscall.c
@@ -31,7 +31,7 @@
syscall_t sys_call_table[__NR_syscalls] /* FIXME __cacheline_aligned */= {
[0 ... __NR_syscalls - 1] = (syscall_t)&sys_ni_syscall,
-#define __SYSCALL(nr, entry, nargs)[nr] = (syscall_t)entry,
+#define __SYSCALL(nr, entry)[nr] = (syscall_t)entry,
#include <asm/syscall_table.h>
#undef __SYSCALL
};
diff --git a/arch/xtensa/kernel/syscalls/syscalltbl.sh b/arch/xtensa/kernel/syscalls/syscalltbl.sh
index 85d78d9..904b8e6 100644
--- a/arch/xtensa/kernel/syscalls/syscalltbl.sh
+++ b/arch/xtensa/kernel/syscalls/syscalltbl.sh
@@ -13,10 +13,10 @@ emit() {
t_entry="$3"
while [ $t_nxt -lt $t_nr ]; do
- printf "__SYSCALL(%s, sys_ni_syscall, )\n" "${t_nxt}"
+ printf "__SYSCALL(%s,sys_ni_syscall)\n" "${t_nxt}"
t_nxt=$((t_nxt+1))
done
- printf "__SYSCALL(%s, %s, )\n" "${t_nxt}" "${t_entry}"
+ printf "__SYSCALL(%s,%s)\n" "${t_nxt}" "${t_entry}"
}
grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
--
1.9.1
Unified system call table generation script must be run to
generate unistd_32.h and syscall_table.h files. This patch
will have changes which will invokes the script.
This patch will generate unistd_32.h and syscall_table.h
files by the syscall table generation script invoked by
xtensa/Makefile and the generated files against the removed
files must be identical.
The generated uapi header file will be included in uapi/-
asm/unistd.h and generated system call table header file
will be included by kernel/syscall.c file.
Signed-off-by: Firoz Khan <[email protected]>
---
arch/xtensa/kernel/syscalls/Makefile | 11 ++++++++--
arch/xtensa/kernel/syscalls/syscallhdr.sh | 36 -------------------------------
arch/xtensa/kernel/syscalls/syscalltbl.sh | 32 ---------------------------
3 files changed, 9 insertions(+), 70 deletions(-)
delete mode 100644 arch/xtensa/kernel/syscalls/syscallhdr.sh
delete mode 100644 arch/xtensa/kernel/syscalls/syscalltbl.sh
diff --git a/arch/xtensa/kernel/syscalls/Makefile b/arch/xtensa/kernel/syscalls/Makefile
index 659faef..75c7421 100644
--- a/arch/xtensa/kernel/syscalls/Makefile
+++ b/arch/xtensa/kernel/syscalls/Makefile
@@ -6,8 +6,9 @@ _dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \
$(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
syscall := $(srctree)/$(src)/syscall.tbl
-syshdr := $(srctree)/$(src)/syscallhdr.sh
-systbl := $(srctree)/$(src)/syscalltbl.sh
+syshdr := $(srctree)/scripts/syscallhdr.sh
+sysnr := $(srctree)/scripts/syscallnr.sh
+systbl := $(srctree)/scripts/syscalltbl.sh
quiet_cmd_syshdr = SYSHDR $@
cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@' \
@@ -15,6 +16,12 @@ quiet_cmd_syshdr = SYSHDR $@
'$(syshdr_pfx_$(basetarget))' \
'$(syshdr_offset_$(basetarget))'
+quiet_cmd_sysnr = SYSNR $@
+ cmd_sysnr = $(CONFIG_SHELL) '$(sysnr)' '$<' '$@' \
+ '$(sysnr_abis_$(basetarget))' \
+ '$(sysnr_pfx_$(basetarget))' \
+ '$(sysnr_offset_$(basetarget))'
+
quiet_cmd_systbl = SYSTBL $@
cmd_systbl = $(CONFIG_SHELL) '$(systbl)' '$<' '$@' \
'$(systbl_abis_$(basetarget))' \
diff --git a/arch/xtensa/kernel/syscalls/syscallhdr.sh b/arch/xtensa/kernel/syscalls/syscallhdr.sh
deleted file mode 100644
index d37db64..0000000
--- a/arch/xtensa/kernel/syscalls/syscallhdr.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-# SPDX-License-Identifier: GPL-2.0
-
-in="$1"
-out="$2"
-my_abis=`echo "($3)" | tr ',' '|'`
-prefix="$4"
-offset="$5"
-
-fileguard=_UAPI_ASM_XTENSA_`basename "$out" | sed \
- -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
- -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'`
-grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
- printf "#ifndef %s\n" "${fileguard}"
- printf "#define %s\n" "${fileguard}"
- printf "\n"
-
- nxt=0
- while read nr abi name entry ; do
- if [ -z "$offset" ]; then
- printf "#define __NR_%s%s\t%s\n" \
- "${prefix}" "${name}" "${nr}"
- else
- printf "#define __NR_%s%s\t(%s + %s)\n" \
- "${prefix}" "${name}" "${offset}" "${nr}"
- fi
- nxt=$((nr+1))
- done
-
- printf "\n"
- printf "#ifdef __KERNEL__\n"
- printf "#define __NR_syscalls\t%s\n" "${nxt}"
- printf "#endif\n"
- printf "\n"
- printf "#endif /* %s */" "${fileguard}"
-) > "$out"
diff --git a/arch/xtensa/kernel/syscalls/syscalltbl.sh b/arch/xtensa/kernel/syscalls/syscalltbl.sh
deleted file mode 100644
index 904b8e6..0000000
--- a/arch/xtensa/kernel/syscalls/syscalltbl.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-# SPDX-License-Identifier: GPL-2.0
-
-in="$1"
-out="$2"
-my_abis=`echo "($3)" | tr ',' '|'`
-my_abi="$4"
-offset="$5"
-
-emit() {
- t_nxt="$1"
- t_nr="$2"
- t_entry="$3"
-
- while [ $t_nxt -lt $t_nr ]; do
- printf "__SYSCALL(%s,sys_ni_syscall)\n" "${t_nxt}"
- t_nxt=$((t_nxt+1))
- done
- printf "__SYSCALL(%s,%s)\n" "${t_nxt}" "${t_entry}"
-}
-
-grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
- nxt=0
- if [ -z "$offset" ]; then
- offset=0
- fi
-
- while read nr abi name entry ; do
- emit $((nxt+offset)) $((nr+offset)) $entry
- nxt=$((nr+1))
- done
-) > "$out"
--
1.9.1
Hi Firoz,
On Wed, Jan 2, 2019 at 7:29 AM Firoz Khan <[email protected]> wrote:
> Unified system call table generation script must be run to
> generate unistd_32.h and syscall_table.h files. This patch
> will have changes which will invokes the script.
>
> This patch will generate unistd_32.h and syscall_table.h
> files by the syscall table generation script invoked by
> xtensa/Makefile and the generated files against the removed
> files must be identical.
>
> The generated uapi header file will be included in uapi/-
> asm/unistd.h and generated system call table header file
> will be included by kernel/syscall.c file.
>
> Signed-off-by: Firoz Khan <[email protected]>
> ---
> arch/xtensa/kernel/syscalls/Makefile | 11 ++++++++--
> arch/xtensa/kernel/syscalls/syscallhdr.sh | 36 -------------------------------
> arch/xtensa/kernel/syscalls/syscalltbl.sh | 32 ---------------------------
> 3 files changed, 9 insertions(+), 70 deletions(-)
> delete mode 100644 arch/xtensa/kernel/syscalls/syscallhdr.sh
> delete mode 100644 arch/xtensa/kernel/syscalls/syscalltbl.sh
>
> diff --git a/arch/xtensa/kernel/syscalls/Makefile b/arch/xtensa/kernel/syscalls/Makefile
> index 659faef..75c7421 100644
> --- a/arch/xtensa/kernel/syscalls/Makefile
> +++ b/arch/xtensa/kernel/syscalls/Makefile
> @@ -6,8 +6,9 @@ _dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \
> $(shell [ -d '$(kapi)' ] || mkdir -p '$(kapi)')
>
> syscall := $(srctree)/$(src)/syscall.tbl
> -syshdr := $(srctree)/$(src)/syscallhdr.sh
> -systbl := $(srctree)/$(src)/syscalltbl.sh
> +syshdr := $(srctree)/scripts/syscallhdr.sh
> +sysnr := $(srctree)/scripts/syscallnr.sh
> +systbl := $(srctree)/scripts/syscalltbl.sh
>
> quiet_cmd_syshdr = SYSHDR $@
> cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@' \
> @@ -15,6 +16,12 @@ quiet_cmd_syshdr = SYSHDR $@
> '$(syshdr_pfx_$(basetarget))' \
> '$(syshdr_offset_$(basetarget))'
>
> +quiet_cmd_sysnr = SYSNR $@
> + cmd_sysnr = $(CONFIG_SHELL) '$(sysnr)' '$<' '$@' \
> + '$(sysnr_abis_$(basetarget))' \
> + '$(sysnr_pfx_$(basetarget))' \
> + '$(sysnr_offset_$(basetarget))'
> +
This patch seems to do more than it says in the description.
Perhaps adding cmd_sysnr needs a separate patch with its
own description?
--
Thanks.
-- Max
On Wed, Jan 2, 2019 at 7:29 AM Firoz Khan <[email protected]> wrote:
>
> The __SYSCALL macro's arguments are system call number,
> system call entry name and number of arguments for the
> system call.
>
> Argument- nargs in __SYSCALL(nr, entry, nargs) is neither
> calculated nor used anywhere. So it would be better to
> keep the implementaion as __SYSCALL(nr, entry). This will
> unifies the implementation with some other architetures
> too.
Perhaps "This will help unify the implementation with other architectures"?
> Signed-off-by: Firoz Khan <[email protected]>
> ---
> arch/xtensa/kernel/syscall.c | 2 +-
> arch/xtensa/kernel/syscalls/syscalltbl.sh | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/xtensa/kernel/syscall.c b/arch/xtensa/kernel/syscall.c
> index 2c415fc..0665339 100644
> --- a/arch/xtensa/kernel/syscall.c
> +++ b/arch/xtensa/kernel/syscall.c
> @@ -31,7 +31,7 @@
> syscall_t sys_call_table[__NR_syscalls] /* FIXME __cacheline_aligned */= {
> [0 ... __NR_syscalls - 1] = (syscall_t)&sys_ni_syscall,
>
> -#define __SYSCALL(nr, entry, nargs)[nr] = (syscall_t)entry,
> +#define __SYSCALL(nr, entry)[nr] = (syscall_t)entry,
> #include <asm/syscall_table.h>
> #undef __SYSCALL
> };
> diff --git a/arch/xtensa/kernel/syscalls/syscalltbl.sh b/arch/xtensa/kernel/syscalls/syscalltbl.sh
> index 85d78d9..904b8e6 100644
> --- a/arch/xtensa/kernel/syscalls/syscalltbl.sh
> +++ b/arch/xtensa/kernel/syscalls/syscalltbl.sh
> @@ -13,10 +13,10 @@ emit() {
> t_entry="$3"
>
> while [ $t_nxt -lt $t_nr ]; do
> - printf "__SYSCALL(%s, sys_ni_syscall, )\n" "${t_nxt}"
> + printf "__SYSCALL(%s,sys_ni_syscall)\n" "${t_nxt}"
Please add space after the comma.
> t_nxt=$((t_nxt+1))
> done
> - printf "__SYSCALL(%s, %s, )\n" "${t_nxt}" "${t_entry}"
> + printf "__SYSCALL(%s,%s)\n" "${t_nxt}" "${t_entry}"
Ditto.
> }
>
> grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
> --
> 1.9.1
With the above changes:
Acked-by: Max Filippov <[email protected]>
--
Thanks.
-- Max
Hi Max,
Thanks for your feedback.
On Fri, 4 Jan 2019 at 04:14, Max Filippov <[email protected]> wrote:
> >
> > +quiet_cmd_sysnr = SYSNR $@
> > + cmd_sysnr = $(CONFIG_SHELL) '$(sysnr)' '$<' '$@' \
> > + '$(sysnr_abis_$(basetarget))' \
> > + '$(sysnr_pfx_$(basetarget))' \
> > + '$(sysnr_offset_$(basetarget))'
> > +
>
> This patch seems to do more than it says in the description.
> Perhaps adding cmd_sysnr needs a separate patch with its
> own description?
This build rule is unused now as I was tried to implement
something else. Hopefully I'll remove the the above change
in my v2.
Thanks
Firoz
Hi Max,
Thanks for your reply.
On Fri, 4 Jan 2019 at 08:28, Max Filippov <[email protected]> wrote:
> On Wed, Jan 2, 2019 at 7:29 AM Firoz Khan <[email protected]> wrote:
> > while [ $t_nxt -lt $t_nr ]; do
> > - printf "__SYSCALL(%s, sys_ni_syscall, )\n" "${t_nxt}"
> > + printf "__SYSCALL(%s,sys_ni_syscall)\n" "${t_nxt}"
>
> Please add space after the comma.
This was intentional as I was trying compile other one architecture with the
previous implementation, it was giving the error. So I modified without space
after comma.
Firoz
On Thu, Jan 3, 2019 at 9:17 PM Firoz Khan <[email protected]> wrote:
> On Fri, 4 Jan 2019 at 08:28, Max Filippov <[email protected]> wrote:
> > On Wed, Jan 2, 2019 at 7:29 AM Firoz Khan <[email protected]> wrote:
> > > while [ $t_nxt -lt $t_nr ]; do
> > > - printf "__SYSCALL(%s, sys_ni_syscall, )\n" "${t_nxt}"
> > > + printf "__SYSCALL(%s,sys_ni_syscall)\n" "${t_nxt}"
> >
> > Please add space after the comma.
>
> This was intentional as I was trying compile other one architecture with the
> previous implementation, it was giving the error. So I modified without space
> after comma.
I have tested that presence or absence of space does not affect the build
for xtensa, and normally we put space after a comma, so I've mentioned that.
Since this script is anyway removed in the next patch of the series it doesn't
really matter whether the spaces are present or not.
So, with or without this change:
Acked-by: Max Filippov <[email protected]>
--
Thanks.
-- Max
On Thu, Jan 3, 2019 at 9:13 PM Firoz Khan <[email protected]> wrote:
> On Fri, 4 Jan 2019 at 04:14, Max Filippov <[email protected]> wrote:
> > >
> > > +quiet_cmd_sysnr = SYSNR $@
> > > + cmd_sysnr = $(CONFIG_SHELL) '$(sysnr)' '$<' '$@' \
> > > + '$(sysnr_abis_$(basetarget))' \
> > > + '$(sysnr_pfx_$(basetarget))' \
> > > + '$(sysnr_offset_$(basetarget))'
> > > +
> >
> > This patch seems to do more than it says in the description.
> > Perhaps adding cmd_sysnr needs a separate patch with its
> > own description?
>
> This build rule is unused now as I was tried to implement
> something else. Hopefully I'll remove the the above change
> in my v2.
Then maybe there's a way to move all these macros to a common
makefile, as they seem to be fairly generic?
--
Thanks.
-- Max
Hi Max,
On Fri, 4 Jan 2019 at 11:29, Max Filippov <[email protected]> wrote:
>
> On Thu, Jan 3, 2019 at 9:13 PM Firoz Khan <[email protected]> wrote:
> > On Fri, 4 Jan 2019 at 04:14, Max Filippov <[email protected]> wrote:
> >
> > This build rule is unused now as I was tried to implement
> > something else. Hopefully I'll remove the the above change
> > in my v2.
>
> Then maybe there's a way to move all these macros to a common
> makefile, as they seem to be fairly generic?
Good idea! Sure, I'll look into it.
Thanks
Firoz
Hi Max,
On Fri, 4 Jan 2019 at 11:25, Max Filippov <[email protected]> wrote:
> On Thu, Jan 3, 2019 at 9:17 PM Firoz Khan <[email protected]> wrote:
> > On Fri, 4 Jan 2019 at 08:28, Max Filippov <[email protected]> wrote:
> > > On Wed, Jan 2, 2019 at 7:29 AM Firoz Khan <[email protected]> wrote:
> > This was intentional as I was trying compile other one architecture with the
> > previous implementation, it was giving the error. So I modified without space
> > after comma.
>
> I have tested that presence or absence of space does not affect the build
> for xtensa, and normally we put space after a comma, so I've mentioned that.
>
> Since this script is anyway removed in the next patch of the series it doesn't
> really matter whether the spaces are present or not.
Yes, you are right, there is no effect in xtensa but if I'm right
there is a problem
in powerpc architecture (not remembering exactly which arch) with this space
after comma.
BTW, the script from all architecture will be removed and keep it in
scripts directory
is our plan. So to satisfy powerpc (again I'm not sure which arch) I
just did this
change.
Thanks for your feedback.
Firoz