Re: [PATCH 2/2] m68k: generate uapi header and syscall table header files

2019-01-03 Thread Firoz Khan
Hi Geert,

Thanks for your feedback!

On Thu, 3 Jan 2019 at 17:13, Geert Uytterhoeven  wrote:
> > 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/syscalltable.S file.
>
> This doesn't really describe what this patch is doing.
> This patch switches m68k over to use the common scripts for
> system call header file generation.

Sure. I'll compose new commit message.

> >  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
>
> What's the purpose of adding sysnr?

Yes. This is not really required here. I planned to change the
implementation in some other way, but didn't looks perfect and
this was left here unnoticed.

> >
> > +quiet_cmd_sysnr = SYSNR  $@
> > +  cmd_sysnr = $(CONFIG_SHELL) '$(sysnr)' '$<' '$@' \
> > + '$(sysnr_abis_$(basetarget))' \
> > + '$(sysnr_pfx_$(basetarget))'  \
> > + '$(sysnr_offset_$(basetarget))'
> > +
>
> What's the purpose of adding this build rule, which is unused?

Sure.

Firoz


Re: [PATCH 1/2] m68k: remove nargs from __SYSCALL

2019-01-03 Thread Firoz Khan
Hi Geert,

Thanks for your feedback.

On Thu, 3 Jan 2019 at 16:15, Geert Uytterhoeven  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 keep the space after the comma.

This is intentional as I was facing some compilation issue with
one architecture (If I'm right it is powerpc) when I keep the space
after comma.

Firoz


[PATCH 1/2] m68k: remove nargs from __SYSCALL

2019-01-02 Thread Firoz Khan
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 
---
 arch/m68k/kernel/syscalls/syscalltbl.sh | 4 ++--
 arch/m68k/kernel/syscalltable.S | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/m68k/kernel/syscalls/syscalltbl.sh 
b/arch/m68k/kernel/syscalls/syscalltbl.sh
index 85d78d9..904b8e6 100644
--- a/arch/m68k/kernel/syscalls/syscalltbl.sh
+++ b/arch/m68k/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 | (
diff --git a/arch/m68k/kernel/syscalltable.S b/arch/m68k/kernel/syscalltable.S
index d329cc7..0082664 100644
--- a/arch/m68k/kernel/syscalltable.S
+++ b/arch/m68k/kernel/syscalltable.S
@@ -18,7 +18,7 @@
 #define sys_mmap2  sys_mmap_pgoff
 #endif
 
-#define __SYSCALL(nr, entry, nargs) .long entry
+#define __SYSCALL(nr, entry)   .long entry
.section .rodata
 ALIGN
 ENTRY(sys_call_table)
-- 
1.9.1



[PATCH 0/2] m68k: Unify the system call scripts

2019-01-02 Thread Firoz Khan
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/1546439331-18646-1-git-send-email-firoz.k...@linaro.org/

Firoz Khan (2):
  m68k: remove nargs from __SYSCALL
  m68k: generate uapi header and syscall table header files

 arch/m68k/kernel/syscalls/Makefile  | 11 --
 arch/m68k/kernel/syscalls/syscallhdr.sh | 36 -
 arch/m68k/kernel/syscalls/syscalltbl.sh | 32 -
 arch/m68k/kernel/syscalltable.S |  2 +-
 4 files changed, 10 insertions(+), 71 deletions(-)
 delete mode 100644 arch/m68k/kernel/syscalls/syscallhdr.sh
 delete mode 100644 arch/m68k/kernel/syscalls/syscalltbl.sh

-- 
1.9.1



[PATCH 2/2] m68k: generate uapi header and syscall table header files

2019-01-02 Thread Firoz Khan
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
m68k/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/syscalltable.S file.

Signed-off-by: Firoz Khan 
---
 arch/m68k/kernel/syscalls/Makefile  | 11 --
 arch/m68k/kernel/syscalls/syscallhdr.sh | 36 -
 arch/m68k/kernel/syscalls/syscalltbl.sh | 32 -
 3 files changed, 9 insertions(+), 70 deletions(-)
 delete mode 100644 arch/m68k/kernel/syscalls/syscallhdr.sh
 delete mode 100644 arch/m68k/kernel/syscalls/syscalltbl.sh

diff --git a/arch/m68k/kernel/syscalls/Makefile 
b/arch/m68k/kernel/syscalls/Makefile
index 659faef..75c7421 100644
--- a/arch/m68k/kernel/syscalls/Makefile
+++ b/arch/m68k/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/m68k/kernel/syscalls/syscallhdr.sh 
b/arch/m68k/kernel/syscalls/syscallhdr.sh
deleted file mode 100644
index 6f357d6..000
--- a/arch/m68k/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_M68K_`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 */\n" "${fileguard}"
-) > "$out"
diff --git a/arch/m68k/kernel/syscalls/syscalltbl.sh 
b/arch/m68k/kernel/syscalls/syscalltbl.sh
deleted file mode 100644
index 904b8e6..000
--- a/arch/m68k/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



Re: [PATCH v5 0/3] m68k: system call table generation support

2018-12-04 Thread Firoz Khan
Hi Geert,

On Tue, 4 Dec 2018 at 14:22, Geert Uytterhoeven  wrote:
>
> On Tue, Nov 13, 2018 at 7:01 AM Firoz Khan  wrote:
> > The purpose of this patch series is, we can easily
> > add/modify/delete system call table support by cha-
> > nging entry in syscall.tbl file instead of manually
> > changing many files. The other goal is to unify the
> > system call table generation support implementation
> > across all the architectures.
> >
> > The system call tables are in different format in
> > all architecture. It will be difficult to manually
> > add, modify or delete the system calls in the resp-
> > ective files manually. To make it easy by keeping a
> > script and which'll generate uapi header file and
> > syscall table file.
> >
> > syscall.tbl contains the list of available system
> > calls along with system call number and correspond-
> > ing entry point. Add a new system call in this arch-
> > itecture will be possible by adding new entry in the
> > syscall.tbl file.
> >
> > Adding a new table entry consisting of:
> > - System call number.
> > - ABI.
> > - System call name.
> > - Entry point name.
> >
> > ARM, s390 and x86 architecuture does exist the sim-
> > ilar support. I leverage their implementation to
> > come up with a generic solution.
> >
> > I have done the same support for work for alpha, ia64,
> > microblaze, mips, parisc, powerpc, sh, sparc and xtensa.
> > Below mentioned git repository contains more details
> > about the workflow.
> >
> > https://github.com/frzkhn/system_call_table_generator/
> >
> > Finally, this is the ground work to solve the Y2038
> > issue. We need to add two dozen of system calls to
> > solve Y2038 issue. So this patch series will help to
> > add new system calls easily by adding new entry in
> > the syscall.tbl.
> >
> > changes since v4:
> >  - changed from generic-y to generated-y in Kbuild.
> >  - remove the patch "0001-m68k-rename-system-call-
> >table-file-name.patch".
> >
> > changes since v3:
> >  - optimized/updated the syscall table generation
> >scripts.
> >  - fixed all mixed indentation issues in syscall.tbl.
> >  - added "comments" in syscall_*.tbl.
> >
> > changes since v2:
> >  - removed __IGNORE entries which was added in v2
> >to suppress the warning.
> >  - added missing new line.
> >
> > changes since v1:
> >  - enclosed __NR_sycalls macro with __KERNEL__.
> >
> > Firoz Khan (3):
> >   m68k: add __NR_syscalls along with NR_syscalls
> >   m68k: add system call table generation support
> >   m68k: generate uapi header and syscall table header files
> >
> >  arch/m68k/Makefile  |   3 +
> >  arch/m68k/include/asm/Kbuild|   1 +
> >  arch/m68k/include/asm/unistd.h  |   3 +-
> >  arch/m68k/include/uapi/asm/Kbuild   |   1 +
> >  arch/m68k/include/uapi/asm/unistd.h | 385 
> > +--
> >  arch/m68k/kernel/syscalls/Makefile  |  38 
> >  arch/m68k/kernel/syscalls/syscall.tbl   | 389 
> > 
> >  arch/m68k/kernel/syscalls/syscallhdr.sh |  36 +++
> >  arch/m68k/kernel/syscalls/syscalltbl.sh |  32 +++
> >  arch/m68k/kernel/syscalltable.S | 387 
> > +--
> >  10 files changed, 507 insertions(+), 768 deletions(-)
> >  create mode 100644 arch/m68k/kernel/syscalls/Makefile
> >  create mode 100644 arch/m68k/kernel/syscalls/syscall.tbl
> >  create mode 100644 arch/m68k/kernel/syscalls/syscallhdr.sh
> >  create mode 100644 arch/m68k/kernel/syscalls/syscalltbl.sh
>
> Thanks, applied and queued for v4.21 (with the missing newline added).

Great, Thanks!

Firoz

>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds


Re: [PATCH v5 2/3] m68k: add system call table generation support

2018-12-04 Thread Firoz Khan
Hi Geert,

On Tue, 4 Dec 2018 at 13:26, Geert Uytterhoeven  wrote:
>
> Hi Firoz,
>
> On Tue, Dec 4, 2018 at 4:22 AM Firoz Khan  wrote:
> > On Sun, 2 Dec 2018 at 19:27, Geert Uytterhoeven  
> > wrote:
> > > On Tue, Nov 13, 2018 at 7:01 AM Firoz Khan  wrote:
> > > > The system call tables are in different format in all
> > > > architecture and it will be difficult to manually add,
> > > > modify or delete the syscall table entries in the res-
> > > > pective files. To make it easy by keeping a script and
> > > > which will generate the uapi header and syscall table
> > > > file. This change will also help to unify the implemen-
> > > > tation across all architectures.
> > > >
> > > > The system call table generation script is added in
> > > > kernel/syscalls directory which contain the scripts to
> > > > generate both uapi header file and system call table
> > > > files. The syscall.tbl will be input for the scripts.
> > > >
> > > > syscall.tbl contains the list of available system calls
> > > > along with system call number and corresponding entry
> > > > point. Add a new system call in this architecture will
> > > > be possible by adding new entry in the syscall.tbl file.
> > > >
> > > > Adding a new table entry consisting of:
> > > > - System call number.
> > > > - ABI.
> > > > - System call name.
> > > > - Entry point name.
> > > >
> > > > syscallhdr.sh and syscalltbl.sh will generate uapi header
> > > > unistd_32.h and syscall_table.h files respectively. Both
> > > > .sh files will parse the content syscall.tbl to generate
> > > > the header and table files. unistd_32.h will be included
> > > > by uapi/asm/unistd.h and syscall_table.h is included by
> > > > kernel/syscall_table.S - the real system call table.
> > > >
> > > > ARM, s390 and x86 architecuture does have similar support.
> > > > I leverage their implementation to come up with a generic
> > > > solution.
> > > >
> > > > Signed-off-by: Firoz Khan 
> > >
> > > Thanks for your patch!
> > >
> > > > --- /dev/null
> > > > +++ b/arch/m68k/kernel/syscalls/syscallhdr.sh
>
> > > > +   printf "#endif\n"
> > > > +   printf "\n"
> > > > +   printf "#endif /* %s */" "${fileguard}"
> > >
> > > The above line is lacking a "\n", causing:
> > >
> > > ./arch/m68k/include/generated/uapi/asm/unistd_32.h:370:42:
> > > warning: no newline at end of file
> >
> > I was wondering, I haven't seen this warning when I compiled it.
>
> It seems to depend on the compiler version.
> One more thing found by my good old gcc-4.1 ;-)
> (which I plan to retire soon, as I need to revert too many "drop support
>  for old gcc" patches to keep it working :-(.
>
> > > Changing it to:
> > >
> > > printf "#endif /* %s */\n" "${fileguard}"
> > >
> > > fixes this.
> >
> > Yes.
> >
> > > Interestingly, this issue seems to be present on powerpc, parisc, sparc,
> > > sh, xtensa (and probably more, I gave up looking), too?
> >
> > I kept the script to generate files *almost* identical. so this will be 
> > present
> > all 10 architecture.
> >
> > > Apart from that, it seems to work fine on m68k.
> >
> > I have three options here to fix this;
> > 1. I can send v6 by fixing this one.
> > 2. I can post a single patch which add \n in the script.
> > 3. Could you able to add \n in the script.
> >
> > Please choose one, I can act accordingly.
>
> So your plan is for me to apply your series to the m68k tree?

Yes.

> In that case there's no need to send a v6, I can incorporate the fix myself.

Sure, Another line - printf "\n" would be great. Thanks :)

Firoz

>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds


Re: [PATCH v5 2/3] m68k: add system call table generation support

2018-12-03 Thread Firoz Khan
Hi Geert,

On Sun, 2 Dec 2018 at 19:27, Geert Uytterhoeven  wrote:
>
> Hi Firoz,
>
> On Tue, Nov 13, 2018 at 7:01 AM Firoz Khan  wrote:
> > The system call tables are in different format in all
> > architecture and it will be difficult to manually add,
> > modify or delete the syscall table entries in the res-
> > pective files. To make it easy by keeping a script and
> > which will generate the uapi header and syscall table
> > file. This change will also help to unify the implemen-
> > tation across all architectures.
> >
> > The system call table generation script is added in
> > kernel/syscalls directory which contain the scripts to
> > generate both uapi header file and system call table
> > files. The syscall.tbl will be input for the scripts.
> >
> > syscall.tbl contains the list of available system calls
> > along with system call number and corresponding entry
> > point. Add a new system call in this architecture will
> > be possible by adding new entry in the syscall.tbl file.
> >
> > Adding a new table entry consisting of:
> > - System call number.
> > - ABI.
> > - System call name.
> > - Entry point name.
> >
> > syscallhdr.sh and syscalltbl.sh will generate uapi header
> > unistd_32.h and syscall_table.h files respectively. Both
> > .sh files will parse the content syscall.tbl to generate
> > the header and table files. unistd_32.h will be included
> > by uapi/asm/unistd.h and syscall_table.h is included by
> > kernel/syscall_table.S - the real system call table.
> >
> > ARM, s390 and x86 architecuture does have similar support.
> > I leverage their implementation to come up with a generic
> > solution.
> >
> > Signed-off-by: Firoz Khan 
>
> Thanks for your patch!
>
> > --- /dev/null
> > +++ b/arch/m68k/kernel/syscalls/syscallhdr.sh
> > @@ -0,0 +1,36 @@
> > +#!/bin/sh
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +in="$1"
> > +out="$2"
> > +my_abis=`echo "($3)" | tr ',' '|'`
> > +prefix="$4"
> > +offset="$5"
> > +
> > +fileguard=_UAPI_ASM_M68K_`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}"
>
> The above line is lacking a "\n", causing:
>
> ./arch/m68k/include/generated/uapi/asm/unistd_32.h:370:42:
> warning: no newline at end of file

I was wondering, I haven't seen this warning when I compiled it.

>
> Changing it to:
>
> printf "#endif /* %s */\n" "${fileguard}"
>
> fixes this.

Yes.

>
> Interestingly, this issue seems to be present on powerpc, parisc, sparc,
> sh, xtensa (and probably more, I gave up looking), too?

I kept the script to generate files *almost* identical. so this will be present
all 10 architecture.

>
> Apart from that, it seems to work fine on m68k.

I have three options here to fix this;
1. I can send v6 by fixing this one.
2. I can post a single patch which add \n in the script.
3. Could you able to add \n in the script.

Please choose one, I can act accordingly.

Thanks
Firoz

>
> > +) > "$out"
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds


[PATCH v5 1/3] m68k: add __NR_syscalls along with NR_syscalls

2018-11-12 Thread Firoz Khan
NR_syscalls macro holds the number of system call
exist in m68k architecture. We have to change the
value of NR_syscalls, if we add or delete a system
call.

One of the patch in this patch series has a script
which will generate a uapi header based on syscall-
.tbl file. The syscall.tbl file contains the total
number of system calls information. So we have two
option to update NR_syscalls value.

1. Update NR_syscalls in asm/unistd.h manually by
   counting the no.of system calls. No need to up-
   date NR_syscalls until we either add a new sys-
   tem call or delete existing system call.

2. We can keep this feature it above mentioned sc-
   ript, that will count the number of syscalls and
   keep it in a generated file. In this case we
   don't need to explicitly update NR_syscalls in
   asm/unistd.h file.

The 2nd option will be the recommended one. For that,
I added the __NR_syscalls macro in uapi/asm/unistd.h
along with NR_syscalls asm/unistd.h. The macro __NR-
_syscalls also added for making the name convention
same across all architecture. While __NR_syscalls
isn't strictly part of the uapi, having it as part
of the generated header to simplifies the implement-
ation. We also need to enclose this macro with #ifdef
__KERNEL__ to avoid side effects.

Signed-off-by: Firoz Khan 
---
 arch/m68k/include/asm/unistd.h  | 3 +--
 arch/m68k/include/uapi/asm/unistd.h | 4 
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index e680031..49d5de1 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -4,8 +4,7 @@
 
 #include 
 
-
-#define NR_syscalls380
+#define NR_syscalls__NR_syscalls
 
 #define __ARCH_WANT_NEW_STAT
 #define __ARCH_WANT_OLD_READDIR
diff --git a/arch/m68k/include/uapi/asm/unistd.h 
b/arch/m68k/include/uapi/asm/unistd.h
index de3054f..ba4176aa 100644
--- a/arch/m68k/include/uapi/asm/unistd.h
+++ b/arch/m68k/include/uapi/asm/unistd.h
@@ -387,4 +387,8 @@
 #define __NR_pwritev2  378
 #define __NR_statx 379
 
+#ifdef __KERNEL__
+#define __NR_syscalls  380
+#endif
+
 #endif /* _UAPI_ASM_M68K_UNISTD_H_ */
-- 
1.9.1



[PATCH v5 2/3] m68k: add system call table generation support

2018-11-12 Thread Firoz Khan
The system call tables are in different format in all
architecture and it will be difficult to manually add,
modify or delete the syscall table entries in the res-
pective files. To make it easy by keeping a script and
which will generate the uapi header and syscall table
file. This change will also help to unify the implemen-
tation across all architectures.

The system call table generation script is added in
kernel/syscalls directory which contain the scripts to
generate both uapi header file and system call table
files. The syscall.tbl will be input for the scripts.

syscall.tbl contains the list of available system calls
along with system call number and corresponding entry
point. Add a new system call in this architecture will
be possible by adding new entry in the syscall.tbl file.

Adding a new table entry consisting of:
- System call number.
- ABI.
- System call name.
- Entry point name.

syscallhdr.sh and syscalltbl.sh will generate uapi header
unistd_32.h and syscall_table.h files respectively. Both
.sh files will parse the content syscall.tbl to generate
the header and table files. unistd_32.h will be included
by uapi/asm/unistd.h and syscall_table.h is included by
kernel/syscall_table.S - the real system call table.

ARM, s390 and x86 architecuture does have similar support.
I leverage their implementation to come up with a generic
solution.

Signed-off-by: Firoz Khan 
---
 arch/m68k/kernel/syscalls/Makefile  |  38 
 arch/m68k/kernel/syscalls/syscall.tbl   | 389 
 arch/m68k/kernel/syscalls/syscallhdr.sh |  36 +++
 arch/m68k/kernel/syscalls/syscalltbl.sh |  32 +++
 4 files changed, 495 insertions(+)
 create mode 100644 arch/m68k/kernel/syscalls/Makefile
 create mode 100644 arch/m68k/kernel/syscalls/syscall.tbl
 create mode 100644 arch/m68k/kernel/syscalls/syscallhdr.sh
 create mode 100644 arch/m68k/kernel/syscalls/syscalltbl.sh

diff --git a/arch/m68k/kernel/syscalls/Makefile 
b/arch/m68k/kernel/syscalls/Makefile
new file mode 100644
index 000..659faef
--- /dev/null
+++ b/arch/m68k/kernel/syscalls/Makefile
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: GPL-2.0
+kapi := arch/$(SRCARCH)/include/generated/asm
+uapi := arch/$(SRCARCH)/include/generated/uapi/asm
+
+_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
+
+quiet_cmd_syshdr = SYSHDR  $@
+  cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@'   \
+  '$(syshdr_abis_$(basetarget))'   \
+  '$(syshdr_pfx_$(basetarget))'\
+  '$(syshdr_offset_$(basetarget))'
+
+quiet_cmd_systbl = SYSTBL  $@
+  cmd_systbl = $(CONFIG_SHELL) '$(systbl)' '$<' '$@'   \
+  '$(systbl_abis_$(basetarget))'   \
+  '$(systbl_abi_$(basetarget))'\
+  '$(systbl_offset_$(basetarget))'
+
+$(uapi)/unistd_32.h: $(syscall) $(syshdr)
+   $(call if_changed,syshdr)
+
+$(kapi)/syscall_table.h: $(syscall) $(systbl)
+   $(call if_changed,systbl)
+
+uapisyshdr-y   += unistd_32.h
+kapisyshdr-y   += syscall_table.h
+
+targets+= $(uapisyshdr-y) $(kapisyshdr-y)
+
+PHONY += all
+all: $(addprefix $(uapi)/,$(uapisyshdr-y))
+all: $(addprefix $(kapi)/,$(kapisyshdr-y))
+   @:
diff --git a/arch/m68k/kernel/syscalls/syscall.tbl 
b/arch/m68k/kernel/syscalls/syscall.tbl
new file mode 100644
index 000..1a95c4a
--- /dev/null
+++ b/arch/m68k/kernel/syscalls/syscall.tbl
@@ -0,0 +1,389 @@
+# SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
+#
+# system call numbers and entry vectors for m68k
+#
+# The format is:
+#
+#
+# The  is always "common" for this file
+#
+0  common  restart_syscall sys_restart_syscall
+1  common  exitsys_exit
+2  common  fork__sys_fork
+3  common  readsys_read
+4  common  write   sys_write
+5  common  opensys_open
+6  common  close   sys_close
+7  common  waitpid sys_waitpid
+8  common  creat   sys_creat
+9  common  linksys_link
+10 common  unlink  sys_unlink
+11 common  execve  sys_execve
+12 common  chdir   sys_chdir
+13 common  timesys_time
+14 common  mknod   sys_mknod
+15 common  chmod   sys_chmod
+16 common  chown   sys_chown16
+# 17 was break
+18 common  oldstat 

Re: [PATCH v4 0/4] m68k: system call table generation support

2018-10-28 Thread Firoz Khan
Hi Geert,

On Sat, 27 Oct 2018 at 20:17, Geert Uytterhoeven  wrote:
>
> Hi Firoz,
>
> On Fri, Oct 26, 2018 at 7:06 AM Firoz Khan  wrote:
> > The purpose of this patch series is, we can easily add/modify/delete
> > system call table support by changing entry in syscall.tbl file
> > instead of manually changing many files. The other goal is to unify
> > the system call table generation support implementation across all
> > the architectures.
> >
> > The system call tables are in different format in all architecture.
> > It will be difficult to manually add, modify or delete the system
> > calls in the respective files manually. To make it easy by keeping
> > a script and which'll generate uapi header file and syscall table
> > file.
> >
> > syscall.tbl contains the list of available system calls along with
> > system call number and corresponding entry point. Add a new system
> > call in this architecture will be possible by adding new entry in
> > the syscall.tbl file.
> >
> > Adding a new table entry consisting of:
> > - System call number.
> > - ABI.
> > - System call name.
> > - Entry point name.
> >
> > ARM, s390 and x86 architecuture does exist the similar support. I
> > leverage their implementation to come up with a generic solution.
> >
> > I have done the same support for work for alpha, ia64, microblaze,
> > mips, parisc, powerpc, sh, sparc, and xtensa. Below mentioned git
> > repository contains more details.
> > Git repo:- https://github.com/frzkhn/system_call_table_generator/
> >
> > Finally, this is the ground work to solve the Y2038 issue. We need
> > to add two dozen of system calls to solve Y2038 issue. So this patch
> > series will help to add new system calls easily by adding new entry
> > in the syscall.tbl.
>
> Thanks for the update!
>
> Can you please tell the audience what has been changed in v4?

Sure.
- I added the comments in syscall.tbl and solved mixed (space and tab)
  indentation.
- Modified the scripts (syscalltbl.sh and syscallhdr.sh) as per the feedback
  provided by Arnd, Finn Thain, Eugene Syromiatnikov and Rolf Eike Beer.

Eg:-
 - echo options are not portable; changed to printf
 - "let" is a bash extension; changed posix-conformant expression.
 - Finally I optimized the script and solved mixed indentation.

>
> When posting a new version of a patch or patch series, it is a good
> idea to include a changelog in the cover letter and/or patches.

Sure, will do!

Thanks
Firoz

>
> Thanks!
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds


[PATCH v4 4/4] m68k: generate uapi header and syscall table header files

2018-10-25 Thread Firoz Khan
System call table generation script must be run to gener-
ate 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
m68k/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_table.S file.

Signed-off-by: Firoz Khan 
---
 arch/m68k/Makefile  |   3 +
 arch/m68k/include/asm/Kbuild|   1 +
 arch/m68k/include/uapi/asm/Kbuild   |   1 +
 arch/m68k/include/uapi/asm/unistd.h | 389 +---
 arch/m68k/kernel/syscall_table.S| 387 +--
 5 files changed, 11 insertions(+), 770 deletions(-)

diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index 997c9f2..f00ca53 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -154,5 +154,8 @@ endif
 archclean:
rm -f vmlinux.gz vmlinux.bz2
 
+archheaders:
+   $(Q)$(MAKE) $(build)=arch/m68k/kernel/syscalls all
+
 install:
sh $(srctree)/arch/m68k/install.sh $(KERNELRELEASE) vmlinux.gz 
System.map "$(INSTALL_PATH)"
diff --git a/arch/m68k/include/asm/Kbuild b/arch/m68k/include/asm/Kbuild
index a4b8d33..147f89c 100644
--- a/arch/m68k/include/asm/Kbuild
+++ b/arch/m68k/include/asm/Kbuild
@@ -24,3 +24,4 @@ generic-y += topology.h
 generic-y += trace_clock.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+generic-y += syscall_table.h
diff --git a/arch/m68k/include/uapi/asm/Kbuild 
b/arch/m68k/include/uapi/asm/Kbuild
index c2e26a4..89776ec 100644
--- a/arch/m68k/include/uapi/asm/Kbuild
+++ b/arch/m68k/include/uapi/asm/Kbuild
@@ -21,3 +21,4 @@ generic-y += statfs.h
 generic-y += termbits.h
 generic-y += termios.h
 generic-y += types.h
+generic-y += unistd_32.h
diff --git a/arch/m68k/include/uapi/asm/unistd.h 
b/arch/m68k/include/uapi/asm/unistd.h
index ba4176aa..cdbd090 100644
--- a/arch/m68k/include/uapi/asm/unistd.h
+++ b/arch/m68k/include/uapi/asm/unistd.h
@@ -2,393 +2,6 @@
 #ifndef _UAPI_ASM_M68K_UNISTD_H_
 #define _UAPI_ASM_M68K_UNISTD_H_
 
-/*
- * This file contains the system call numbers.
- */
-
-#define __NR_restart_syscall 0
-#define __NR_exit1
-#define __NR_fork2
-#define __NR_read3
-#define __NR_write   4
-#define __NR_open5
-#define __NR_close   6
-#define __NR_waitpid 7
-#define __NR_creat   8
-#define __NR_link9
-#define __NR_unlink 10
-#define __NR_execve 11
-#define __NR_chdir  12
-#define __NR_time   13
-#define __NR_mknod  14
-#define __NR_chmod  15
-#define __NR_chown  16
-/*#define __NR_break17*/
-#define __NR_oldstat18
-#define __NR_lseek  19
-#define __NR_getpid 20
-#define __NR_mount  21
-#define __NR_umount 22
-#define __NR_setuid 23
-#define __NR_getuid 24
-#define __NR_stime  25
-#define __NR_ptrace 26
-#define __NR_alarm  27
-#define __NR_oldfstat   28
-#define __NR_pause  29
-#define __NR_utime  30
-/*#define __NR_stty 31*/
-/*#define __NR_gtty 32*/
-#define __NR_access 33
-#define __NR_nice   34
-/*#define __NR_ftime35*/
-#define __NR_sync   36
-#define __NR_kill   37
-#define __NR_rename 38
-#define __NR_mkdir  39
-#define __NR_rmdir  40
-#define __NR_dup41
-#define __NR_pipe   42
-#define __NR_times  43
-/*#define __NR_prof 44*/
-#define __NR_brk45
-#define __NR_setgid 46
-#define __NR_getgid 47
-#define __NR_signal 48
-#define __NR_geteuid49
-#define __NR_getegid50
-#define __NR_acct   51
-#define __NR_umount252
-/*#define __NR_lock 53*/
-#define __NR_ioctl  54
-#define __NR_fcntl  55
-/*#define __NR_mpx  56*/
-#define __NR_setpgid57
-/*#define __NR_ulimit   58*/
-/*#define __NR_oldolduname  59*/
-#define __NR_umask  60
-#define __NR_chroot 61
-#define __NR_ustat  62
-#define __NR_dup2   63
-#define __NR_getppid64
-#define __NR_getpgrp65
-#define __NR_setsid 66
-#define __NR_sigaction  67
-#define __NR_sgetmask   68
-#define __NR_ssetmask   69
-#define __NR_setreuid   70
-#define __NR_setregid   71
-#define __NR_sigsuspend 72
-#define __NR_

[PATCH v4 2/4] m68k: add __NR_syscalls along with NR_syscalls

2018-10-25 Thread Firoz Khan
NR_syscalls macro holds the number of system call exist
in m68k architecture. We have to change the value of NR-
_syscalls, if we add or delete a system call.

One of the patch in this patch series has a script which
will generate a uapi header based on syscall.tbl file.
The syscall.tbl file contains the total number of system
calls information. So we have two option to update NR_sy-
scalls value.

1. Update NR_syscalls in asm/unistd.h manually by count-
   ing the no.of system calls. No need to update NR_sys-
   calls until we either add a new system call or delete
   existing system call.

2. We can keep this feature it above mentioned script,
   that will count the number of syscalls and keep it in
   a generated file. In this case we don't need to expli-
   citly update NR_syscalls in asm/unistd.h file.

The 2nd option will be the recommended one. For that, I
added the __NR_syscalls macro in uapi/asm/unistd.h along
with NR_syscalls asm/unistd.h. The macro __NR_syscalls
also added for making the name convention same across all
architecture. While __NR_syscalls isn't strictly part of
the uapi, having it as part of the generated header to
simplifies the implementation. We also need to enclose
this macro with #ifdef __KERNEL__ to avoid side effects.

Signed-off-by: Firoz Khan 
---
 arch/m68k/include/asm/unistd.h  | 3 +--
 arch/m68k/include/uapi/asm/unistd.h | 4 
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index 30d0d3f..5072e94 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -4,8 +4,7 @@
 
 #include 
 
-
-#define NR_syscalls380
+#define NR_syscalls __NR_syscalls
 
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_OLD_STAT
diff --git a/arch/m68k/include/uapi/asm/unistd.h 
b/arch/m68k/include/uapi/asm/unistd.h
index de3054f..ba4176aa 100644
--- a/arch/m68k/include/uapi/asm/unistd.h
+++ b/arch/m68k/include/uapi/asm/unistd.h
@@ -387,4 +387,8 @@
 #define __NR_pwritev2  378
 #define __NR_statx 379
 
+#ifdef __KERNEL__
+#define __NR_syscalls  380
+#endif
+
 #endif /* _UAPI_ASM_M68K_UNISTD_H_ */
-- 
1.9.1



[PATCH v4 0/4] m68k: system call table generation support

2018-10-25 Thread Firoz Khan
The purpose of this patch series is, we can easily add/modify/delete
system call table support by changing entry in syscall.tbl file 
instead of manually changing many files. The other goal is to unify 
the system call table generation support implementation across all 
the architectures. 

The system call tables are in different format in all architecture. 
It will be difficult to manually add, modify or delete the system 
calls in the respective files manually. To make it easy by keeping
a script and which'll generate uapi header file and syscall table 
file.

syscall.tbl contains the list of available system calls along with 
system call number and corresponding entry point. Add a new system 
call in this architecture will be possible by adding new entry in 
the syscall.tbl file.

Adding a new table entry consisting of:
- System call number.
- ABI.
- System call name.
- Entry point name.

ARM, s390 and x86 architecuture does exist the similar support. I 
leverage their implementation to come up with a generic solution.

I have done the same support for work for alpha, ia64, microblaze,
mips, parisc, powerpc, sh, sparc, and xtensa. Below mentioned git
repository contains more details.
Git repo:- https://github.com/frzkhn/system_call_table_generator/

Finally, this is the ground work to solve the Y2038 issue. We need 
to add two dozen of system calls to solve Y2038 issue. So this patch
series will help to add new system calls easily by adding new entry 
in the syscall.tbl.

Firoz Khan (4):
  m68k: rename system call table file name
  m68k: add __NR_syscalls along with NR_syscalls
  m68k: add system call table generation support
  m68k: generate uapi header and syscall table header files

 arch/m68k/Makefile  |   3 +
 arch/m68k/include/asm/Kbuild|   1 +
 arch/m68k/include/asm/unistd.h  |   3 +-
 arch/m68k/include/uapi/asm/Kbuild   |   1 +
 arch/m68k/include/uapi/asm/unistd.h | 385 +-
 arch/m68k/kernel/Makefile   |   2 +-
 arch/m68k/kernel/syscall_table.S|  26 +++
 arch/m68k/kernel/syscalls/Makefile  |  38 +++
 arch/m68k/kernel/syscalls/syscall.tbl   | 389 ++
 arch/m68k/kernel/syscalls/syscallhdr.sh |  36 +++
 arch/m68k/kernel/syscalls/syscalltbl.sh |  32 +++
 arch/m68k/kernel/syscalltable.S | 403 
 12 files changed, 529 insertions(+), 790 deletions(-)
 create mode 100644 arch/m68k/kernel/syscall_table.S
 create mode 100644 arch/m68k/kernel/syscalls/Makefile
 create mode 100644 arch/m68k/kernel/syscalls/syscall.tbl
 create mode 100644 arch/m68k/kernel/syscalls/syscallhdr.sh
 create mode 100644 arch/m68k/kernel/syscalls/syscalltbl.sh
 delete mode 100644 arch/m68k/kernel/syscalltable.S

-- 
1.9.1



[PATCH v4 1/4] m68k: rename system call table file name

2018-10-25 Thread Firoz Khan
The system call table entries are present in syscalltable.S.
One of the patch in this patch series will generate the sys-
tem call table entries using the system call table generation
script and which will replace the existig table file.

In order to come up with a common naming convention across
all architecture, we need to change the file name to syscall-
_table.S. This change will unify the system call table gener-
tion implementation across all architecture.

Signed-off-by: Firoz Khan 
---
 arch/m68k/kernel/Makefile| 2 +-
 arch/m68k/kernel/{syscalltable.S => syscall_table.S} | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
 rename arch/m68k/kernel/{syscalltable.S => syscall_table.S} (99%)

diff --git a/arch/m68k/kernel/Makefile b/arch/m68k/kernel/Makefile
index dbac7f8..5f40ce6 100644
--- a/arch/m68k/kernel/Makefile
+++ b/arch/m68k/kernel/Makefile
@@ -15,7 +15,7 @@ extra-$(CONFIG_SUN3)  := sun3-head.o
 extra-y+= vmlinux.lds
 
 obj-y  := entry.o irq.o module.o process.o ptrace.o
-obj-y  += setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o
+obj-y  += setup.o signal.o sys_m68k.o syscall_table.o time.o traps.o
 
 obj-$(CONFIG_MMU_MOTOROLA) += ints.o vectors.o
 obj-$(CONFIG_MMU_SUN3) += ints.o vectors.o
diff --git a/arch/m68k/kernel/syscalltable.S b/arch/m68k/kernel/syscall_table.S
similarity index 99%
rename from arch/m68k/kernel/syscalltable.S
rename to arch/m68k/kernel/syscall_table.S
index 2c8402e..6145bc0 100644
--- a/arch/m68k/kernel/syscalltable.S
+++ b/arch/m68k/kernel/syscall_table.S
@@ -6,7 +6,7 @@
  *
  *  Copyright (C) 1998  D. Jeff Dionne ,
  *  Kenneth Albanowski ,
- *  Copyright (C) 2000  Lineo Inc. (www.lineo.com) 
+ *  Copyright (C) 2000  Lineo Inc. (www.lineo.com)
  *  Copyright (C) 1991, 1992  Linus Torvalds
  *
  *  Linux/m68k support by Hamish Macdonald
-- 
1.9.1



[PATCH v4 3/4] m68k: add system call table generation support

2018-10-25 Thread Firoz Khan
The system call tables are in different format in all
architecture and it will be difficult to manually add,
modify or delete the syscall table entries in the res-
pective files. To make it easy by keeping a script and
which will generate the uapi header and syscall table 
file. This change will also help to unify the implemen-
tation across all architectures.

The system call table generation script is added in
kernel/syscalls directory which contain the scripts to
generate both uapi header file and system call table
files. The syscall.tbl will be input for the scripts.

syscall.tbl contains the list of available system calls
along with system call number and corresponding entry
point. Add a new system call in this architecture will
be possible by adding new entry in the syscall.tbl file.

Adding a new table entry consisting of:
- System call number.
- ABI.
- System call name.
- Entry point name.

syscallhdr.sh and syscalltbl.sh will generate uapi header
unistd_32.h and syscall_table.h files respectively. Both
.sh files will parse the content syscall.tbl to generate
the header and table files. unistd_32.h will be included
by uapi/asm/unistd.h and syscall_table.h is included by
kernel/syscall_table.S - the real system call table.

ARM, s390 and x86 architecuture does have similar support.
I leverage their implementation to come up with a generic
solution.

Signed-off-by: Firoz Khan 
---
 arch/m68k/kernel/syscalls/Makefile  |  38 
 arch/m68k/kernel/syscalls/syscall.tbl   | 389 
 arch/m68k/kernel/syscalls/syscallhdr.sh |  36 +++
 arch/m68k/kernel/syscalls/syscalltbl.sh |  32 +++
 4 files changed, 495 insertions(+)
 create mode 100644 arch/m68k/kernel/syscalls/Makefile
 create mode 100644 arch/m68k/kernel/syscalls/syscall.tbl
 create mode 100644 arch/m68k/kernel/syscalls/syscallhdr.sh
 create mode 100644 arch/m68k/kernel/syscalls/syscalltbl.sh

diff --git a/arch/m68k/kernel/syscalls/Makefile 
b/arch/m68k/kernel/syscalls/Makefile
new file mode 100644
index 000..659faef
--- /dev/null
+++ b/arch/m68k/kernel/syscalls/Makefile
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: GPL-2.0
+kapi := arch/$(SRCARCH)/include/generated/asm
+uapi := arch/$(SRCARCH)/include/generated/uapi/asm
+
+_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
+
+quiet_cmd_syshdr = SYSHDR  $@
+  cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@'   \
+  '$(syshdr_abis_$(basetarget))'   \
+  '$(syshdr_pfx_$(basetarget))'\
+  '$(syshdr_offset_$(basetarget))'
+
+quiet_cmd_systbl = SYSTBL  $@
+  cmd_systbl = $(CONFIG_SHELL) '$(systbl)' '$<' '$@'   \
+  '$(systbl_abis_$(basetarget))'   \
+  '$(systbl_abi_$(basetarget))'\
+  '$(systbl_offset_$(basetarget))'
+
+$(uapi)/unistd_32.h: $(syscall) $(syshdr)
+   $(call if_changed,syshdr)
+
+$(kapi)/syscall_table.h: $(syscall) $(systbl)
+   $(call if_changed,systbl)
+
+uapisyshdr-y   += unistd_32.h
+kapisyshdr-y   += syscall_table.h
+
+targets+= $(uapisyshdr-y) $(kapisyshdr-y)
+
+PHONY += all
+all: $(addprefix $(uapi)/,$(uapisyshdr-y))
+all: $(addprefix $(kapi)/,$(kapisyshdr-y))
+   @:
diff --git a/arch/m68k/kernel/syscalls/syscall.tbl 
b/arch/m68k/kernel/syscalls/syscall.tbl
new file mode 100644
index 000..1a95c4a
--- /dev/null
+++ b/arch/m68k/kernel/syscalls/syscall.tbl
@@ -0,0 +1,389 @@
+# SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
+#
+# system call numbers and entry vectors for m68k
+#
+# The format is:
+#
+#
+# The  is always "common" for this file
+#
+0  common  restart_syscall sys_restart_syscall
+1  common  exitsys_exit
+2  common  fork__sys_fork
+3  common  readsys_read
+4  common  write   sys_write
+5  common  opensys_open
+6  common  close   sys_close
+7  common  waitpid sys_waitpid
+8  common  creat   sys_creat
+9  common  linksys_link
+10 common  unlink  sys_unlink
+11 common  execve  sys_execve
+12 common  chdir   sys_chdir
+13 common  timesys_time
+14 common  mknod   sys_mknod
+15 common  chmod   sys_chmod
+16 common  chown   sys_chown16
+# 17 was break
+18 common  oldstat 

[PATCH v3 4/5] m68k: uapi header and system call table file generation

2018-10-01 Thread Firoz Khan
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
arch/m68k/Makefile and the generated files against the
removed files will be identical.

The generated uapi header file will be included in
uapi/asm/unistd.h and generated system call table support
file will be included by arch/m68k/kernel/syscall_table.S
file.

Signed-off-by: Firoz Khan 
---
 arch/m68k/Makefile  |   3 +
 arch/m68k/include/asm/Kbuild|   1 +
 arch/m68k/include/uapi/asm/Kbuild   |   1 +
 arch/m68k/include/uapi/asm/unistd.h | 389 +--
 arch/m68k/kernel/syscall_table.S| 399 +---
 5 files changed, 11 insertions(+), 782 deletions(-)

diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index 997c9f2..f00ca53 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -154,5 +154,8 @@ endif
 archclean:
rm -f vmlinux.gz vmlinux.bz2
 
+archheaders:
+   $(Q)$(MAKE) $(build)=arch/m68k/kernel/syscalls all
+
 install:
sh $(srctree)/arch/m68k/install.sh $(KERNELRELEASE) vmlinux.gz 
System.map "$(INSTALL_PATH)"
diff --git a/arch/m68k/include/asm/Kbuild b/arch/m68k/include/asm/Kbuild
index a4b8d33..68501411 100644
--- a/arch/m68k/include/asm/Kbuild
+++ b/arch/m68k/include/asm/Kbuild
@@ -24,3 +24,4 @@ generic-y += topology.h
 generic-y += trace_clock.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+generic-y += syscall_table.h
\ No newline at end of file
diff --git a/arch/m68k/include/uapi/asm/Kbuild 
b/arch/m68k/include/uapi/asm/Kbuild
index c2e26a4..6d600e9 100644
--- a/arch/m68k/include/uapi/asm/Kbuild
+++ b/arch/m68k/include/uapi/asm/Kbuild
@@ -21,3 +21,4 @@ generic-y += statfs.h
 generic-y += termbits.h
 generic-y += termios.h
 generic-y += types.h
+generic-y += unistd_32.h
\ No newline at end of file
diff --git a/arch/m68k/include/uapi/asm/unistd.h 
b/arch/m68k/include/uapi/asm/unistd.h
index ba4176aa..cdbd090 100644
--- a/arch/m68k/include/uapi/asm/unistd.h
+++ b/arch/m68k/include/uapi/asm/unistd.h
@@ -2,393 +2,6 @@
 #ifndef _UAPI_ASM_M68K_UNISTD_H_
 #define _UAPI_ASM_M68K_UNISTD_H_
 
-/*
- * This file contains the system call numbers.
- */
-
-#define __NR_restart_syscall 0
-#define __NR_exit1
-#define __NR_fork2
-#define __NR_read3
-#define __NR_write   4
-#define __NR_open5
-#define __NR_close   6
-#define __NR_waitpid 7
-#define __NR_creat   8
-#define __NR_link9
-#define __NR_unlink 10
-#define __NR_execve 11
-#define __NR_chdir  12
-#define __NR_time   13
-#define __NR_mknod  14
-#define __NR_chmod  15
-#define __NR_chown  16
-/*#define __NR_break17*/
-#define __NR_oldstat18
-#define __NR_lseek  19
-#define __NR_getpid 20
-#define __NR_mount  21
-#define __NR_umount 22
-#define __NR_setuid 23
-#define __NR_getuid 24
-#define __NR_stime  25
-#define __NR_ptrace 26
-#define __NR_alarm  27
-#define __NR_oldfstat   28
-#define __NR_pause  29
-#define __NR_utime  30
-/*#define __NR_stty 31*/
-/*#define __NR_gtty 32*/
-#define __NR_access 33
-#define __NR_nice   34
-/*#define __NR_ftime35*/
-#define __NR_sync   36
-#define __NR_kill   37
-#define __NR_rename 38
-#define __NR_mkdir  39
-#define __NR_rmdir  40
-#define __NR_dup41
-#define __NR_pipe   42
-#define __NR_times  43
-/*#define __NR_prof 44*/
-#define __NR_brk45
-#define __NR_setgid 46
-#define __NR_getgid 47
-#define __NR_signal 48
-#define __NR_geteuid49
-#define __NR_getegid50
-#define __NR_acct   51
-#define __NR_umount252
-/*#define __NR_lock 53*/
-#define __NR_ioctl  54
-#define __NR_fcntl  55
-/*#define __NR_mpx  56*/
-#define __NR_setpgid57
-/*#define __NR_ulimit   58*/
-/*#define __NR_oldolduname  59*/
-#define __NR_umask  60
-#define __NR_chroot 61
-#define __NR_ustat  62
-#define __NR_dup2   63
-#define __NR_getppid64
-#define __NR_getpgrp65
-#define __NR_setsid 66
-#define __NR_sigaction  67
-#define __NR_sgetmask   68
-#define __NR_ssetmask   69
-#define __NR_setreuid   70
-#define __NR_setregid   7

[PATCH v3 3/5] m68k: add system call table generation support

2018-10-01 Thread Firoz Khan
The system call tables are in different format in all
architecture and it will be difficult to manually add or
modify the system calls in the respective files. To make
it easy by keeping a script and which'll generate the
header file and syscall table file so this change will
unify them across all architectures.

The system call table generation script is added in
syscalls directory which contain the script to generate
both uapi header file system call table generation file
and syscall.tbl file which'll be the input for the scripts.

syscall.tbl contains the list of available system calls
along with system call number and corresponding entry point.
Add a new system call in this architecture will be possible
by adding new entry in the syscall.tbl file.

Adding a new table entry consisting of:
- System call number.
- ABI.
- System call name.
- Entry point name.

syscallhdr.sh and syscalltbl.sh will generate uapi header-
unistd.h and syscall_table.h files respectively. File
syscall_table.h is included by syscall_table.S - the real
system call table. Both .sh files will parse the content
syscall.tbl to generate the header and table files.

ARM, s390 and x86 architecuture does have the similar support.
I leverage their implementation to come up with a generic
solution. And this is the ground work for y2038 issue. We need
to change two dozons of system call implementation and this
work will reduce the effort by simply modify two dozon entries
in syscall.tbl.

Signed-off-by: Firoz Khan 
---
 arch/m68k/kernel/syscalls/Makefile  |  38 
 arch/m68k/kernel/syscalls/syscall.tbl   | 369 
 arch/m68k/kernel/syscalls/syscallhdr.sh |  35 +++
 arch/m68k/kernel/syscalls/syscalltbl.sh |  34 +++
 4 files changed, 476 insertions(+)
 create mode 100644 arch/m68k/kernel/syscalls/Makefile
 create mode 100644 arch/m68k/kernel/syscalls/syscall.tbl
 create mode 100644 arch/m68k/kernel/syscalls/syscallhdr.sh
 create mode 100644 arch/m68k/kernel/syscalls/syscalltbl.sh

diff --git a/arch/m68k/kernel/syscalls/Makefile 
b/arch/m68k/kernel/syscalls/Makefile
new file mode 100644
index 000..d255d32
--- /dev/null
+++ b/arch/m68k/kernel/syscalls/Makefile
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: GPL-2.0
+out := arch/$(SRCARCH)/include/generated/asm
+uapi := arch/$(SRCARCH)/include/generated/uapi/asm
+
+_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \
+ $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
+
+syscall := $(srctree)/$(src)/syscall.tbl
+
+syshdr := $(srctree)/$(src)/syscallhdr.sh
+systbl := $(srctree)/$(src)/syscalltbl.sh
+
+quiet_cmd_syshdr = SYSHDR  $@
+  cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@'  \
+  '$(syshdr_abi_$(basetarget))'  \
+  '$(syshdr_pfx_$(basetarget))'  \
+  '$(syshdr_offset_$(basetarget))'
+
+quiet_cmd_systbl = SYSTBL  $@
+  cmd_systbl = $(CONFIG_SHELL) '$(systbl)' '$<' '$@'  \
+  '$(systbl_abi_$(basetarget))'  \
+  '$(systbl_offset_$(basetarget))'
+
+$(uapi)/unistd_32.h: $(syscall) $(syshdr)
+   $(call if_changed,syshdr)
+
+$(out)/syscall_table.h: $(syscall) $(systbl)
+   $(call if_changed,systbl)
+
+uapisyshdr-y   += unistd_32.h
+syshdr-y   += syscall_table.h
+
+targets+= $(uapisyshdr-y) $(syshdr-y)
+
+PHONY += all
+all: $(addprefix $(uapi)/,$(uapisyshdr-y))
+all: $(addprefix $(out)/,$(syshdr-y))
+   @:
diff --git a/arch/m68k/kernel/syscalls/syscall.tbl 
b/arch/m68k/kernel/syscalls/syscall.tbl
new file mode 100644
index 000..ab151cd
--- /dev/null
+++ b/arch/m68k/kernel/syscalls/syscall.tbl
@@ -0,0 +1,369 @@
+#
+# Linux system call numbers and entry vectors
+#
+# The format is:
+#
+#
+# The abi is always common for this file.
+#
+0   common   restart_syscall  sys_restart_syscall
+1   common   exit sys_exit
+2   common   fork __sys_fork
+3   common   read sys_read
+4   common   writesys_write
+5   common   open sys_open
+6   common   closesys_close
+7   common   waitpid  sys_waitpid
+8   common   creatsys_creat
+9   common   link sys_link
+10  common   unlink   sys_unlink
+11  common   execve   sys_execve
+12  common   chdirsys_chdir
+13  common   time sys_time
+14  common   mknodsys_mknod
+15  common   chmodsys_chmod
+16  common   chownsys_chown16
+18  common   oldstat  sys_stat
+19  common   lseeksys_lseek
+20  common   getpid   sys_getpid
+21  common   mountsys_mou

[PATCH v3 5/5] m68k: add __IGNORE* entries in asm/unistd.h

2018-10-01 Thread Firoz Khan
Add __IGNORE* entries for seccomp, pkey_mprotect, pkey_
alloc, pkey_free, io_pgetevents and rseq in the file
asm/unistd.h as it is correct to keep __IGNORE* entry in
non uapi header asm/unistd.h while uapi/asm/unistd.h must
hold information only useful for user space applications.

Signed-off-by: Firoz Khan 
---
 arch/m68k/include/asm/unistd.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index 5072e94..cc5f640 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -31,4 +31,11 @@
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 
+#define __IGNORE_seccomp
+#define __IGNORE_pkey_mprotect
+#define __IGNORE_pkey_alloc
+#define __IGNORE_pkey_free
+#define __IGNORE_io_pgetevents
+#define __IGNORE_rseq
+
 #endif /* _ASM_M68K_UNISTD_H_ */
-- 
1.9.1



[PATCH v3 1/5] m68k: rename system call table file name

2018-10-01 Thread Firoz Khan
The system call table entries are present in syscalltable.S. One of
the patch in this patch series will auto-generate the system call
table entries using the system call table generation script and
which'll replace the existig table file.

In order to come up with a common naming convention across all
architecture, we need to change the file name to syscall_table.S.
This change will unify the implementation across all architecture.

Signed-off-by: Firoz Khan 
---
 arch/m68k/kernel/Makefile| 2 +-
 arch/m68k/kernel/{syscalltable.S => syscall_table.S} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename arch/m68k/kernel/{syscalltable.S => syscall_table.S} (100%)

diff --git a/arch/m68k/kernel/Makefile b/arch/m68k/kernel/Makefile
index dbac7f8..5f40ce6 100644
--- a/arch/m68k/kernel/Makefile
+++ b/arch/m68k/kernel/Makefile
@@ -15,7 +15,7 @@ extra-$(CONFIG_SUN3)  := sun3-head.o
 extra-y+= vmlinux.lds
 
 obj-y  := entry.o irq.o module.o process.o ptrace.o
-obj-y  += setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o
+obj-y  += setup.o signal.o sys_m68k.o syscall_table.o time.o traps.o
 
 obj-$(CONFIG_MMU_MOTOROLA) += ints.o vectors.o
 obj-$(CONFIG_MMU_SUN3) += ints.o vectors.o
diff --git a/arch/m68k/kernel/syscalltable.S b/arch/m68k/kernel/syscall_table.S
similarity index 100%
rename from arch/m68k/kernel/syscalltable.S
rename to arch/m68k/kernel/syscall_table.S
-- 
1.9.1



[PATCH v3 2/5] m68k: replace NR_syscalls macro from asm/unistd.h

2018-10-01 Thread Firoz Khan
NR_syscalls macro holds the number of system call exist in m68k
architecture. This macro is currently the part of asm/unistd.h file.
We have to change the value of NR_syscalls, if we add or delete a
system call.

One of patch in this patch series has a script which will generate
a uapi header based on syscall.tbl file. The syscall.tbl file
contains the number of system call information. So we have two
option to update NR_syscalls value.

1. Update NR_syscalls in asm/unistd.h manually by counting the
   no.of system calls. No need to update NR_syscalls until
   we either add a new system call or delete an existing system
   call.

2. We can keep this feature it above mentioned script, that'll
   count the number of syscalls and keep it in a generated file.
   In this case we don't need to explicitly update NR_syscalls
   in asm/unistd.h file.

The 2nd option will be the recommended one. For that, I come up
with another macro - __NR_syscalls which will be updated by the
script and it will be present in api/asm/unistd.h. While __NR_syscalls
isn't strictly part of the uapi, having it as part of the generated
header to simplifies the implementation. So we need to enclose this
macro with #ifdef __KERNEL__ to avoid side effects.

Signed-off-by: Firoz Khan 
---
 arch/m68k/include/asm/unistd.h  | 3 +--
 arch/m68k/include/uapi/asm/unistd.h | 4 
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index 30d0d3f..5072e94 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -4,8 +4,7 @@
 
 #include 
 
-
-#define NR_syscalls380
+#define NR_syscalls __NR_syscalls
 
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_OLD_STAT
diff --git a/arch/m68k/include/uapi/asm/unistd.h 
b/arch/m68k/include/uapi/asm/unistd.h
index de3054f..ba4176aa 100644
--- a/arch/m68k/include/uapi/asm/unistd.h
+++ b/arch/m68k/include/uapi/asm/unistd.h
@@ -387,4 +387,8 @@
 #define __NR_pwritev2  378
 #define __NR_statx 379
 
+#ifdef __KERNEL__
+#define __NR_syscalls  380
+#endif
+
 #endif /* _UAPI_ASM_M68K_UNISTD_H_ */
-- 
1.9.1



[PATCH v3 0/5] System call table generation support

2018-10-01 Thread Firoz Khan
The purpose of this patch series is:
1. We can easily add/modify/delete system call by changing entry 
in syscall.tbl file. No need to manually edit many files.

2. It is easy to unify the system call implementation across all 
the architectures. 

The system call tables are in different format in all architecture 
and it will be difficult to manually add or modify the system calls
in the respective files manually. To make it easy by keeping a script 
and which'll generate the header file and syscall table file so this 
change will unify them across all architectures.

syscall.tbl contains the list of available system calls along with 
system call number and corresponding entry point. Add a new system 
call in this architecture will be possible by adding new entry in 
the syscall.tbl file.

Adding a new table entry consisting of:
- System call number.
- ABI.
- System call name.
- Entry point name.
- Compat entry name, if required.

ARM, s390 and x86 architecuture does exist the similar support. I 
leverage their implementation to come up with a generic solution.

I have done the same support for work for alpha, ia64, sparc, mips, 
parisc, powerpc, sh, sparc, and xtensa. But I started sending 
the patch for one architecuture for review. Below mentioned git
repository contains more details.
Git repo:- https://github.com/frzkhn/system_call_table_generator/

Finally, this is the ground work for solving the Y2038 issue. We 
need to add/change two dozen of system calls to solve Y2038 issue. 
So this patch series will help to easily modify from existing 
system call to Y2038 compatible system calls.

Firoz Khan (5):
  m68k: rename system call table file name
  m68k: replace NR_syscalls macro from asm/unistd.h
  m68k: add system call table generation support
  m68k: uapi header and system call table file generation
  m68k: add __IGNORE* entries in asm/unistd.h

 arch/m68k/Makefile  |   3 +
 arch/m68k/include/asm/Kbuild|   1 +
 arch/m68k/include/asm/unistd.h  |  10 +-
 arch/m68k/include/uapi/asm/Kbuild   |   1 +
 arch/m68k/include/uapi/asm/unistd.h | 385 +-
 arch/m68k/kernel/Makefile   |   2 +-
 arch/m68k/kernel/syscall_table.S|  14 ++
 arch/m68k/kernel/syscalls/Makefile  |  38 +++
 arch/m68k/kernel/syscalls/syscall.tbl   | 369 +
 arch/m68k/kernel/syscalls/syscallhdr.sh |  35 +++
 arch/m68k/kernel/syscalls/syscalltbl.sh |  34 +++
 arch/m68k/kernel/syscalltable.S | 403 
 12 files changed, 505 insertions(+), 790 deletions(-)
 create mode 100644 arch/m68k/kernel/syscall_table.S
 create mode 100644 arch/m68k/kernel/syscalls/Makefile
 create mode 100644 arch/m68k/kernel/syscalls/syscall.tbl
 create mode 100644 arch/m68k/kernel/syscalls/syscallhdr.sh
 create mode 100644 arch/m68k/kernel/syscalls/syscalltbl.sh
 delete mode 100644 arch/m68k/kernel/syscalltable.S

-- 
1.9.1



Re: [PATCH v2 4/5] m68k: uapi header and system call table file generation

2018-09-24 Thread Firoz Khan
On Mon, 24 Sep 2018 at 12:35, Geert Uytterhoeven  wrote:
>
> Hi Firoz,
>
> On Thu, Sep 20, 2018 at 5:07 PM Firoz Khan  wrote:
> > 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
> > arch/m68k/Makefile and the generated files against the
> > removed files will be identical.
> >
> > The generated uapi header file will be included in
> > uapi/asm/unistd.h and generated system call table support
> > file will be included by arch/m68k/kernel/syscall_table.S
> > file.
> >
> > Signed-off-by: Firoz Khan 
>
> Thanks for your patch!
>
> > --- a/arch/m68k/include/asm/Kbuild
> > +++ b/arch/m68k/include/asm/Kbuild
> > @@ -24,3 +24,4 @@ generic-y += topology.h
> >  generic-y += trace_clock.h
> >  generic-y += word-at-a-time.h
> >  generic-y += xor.h
> > +generic-y += syscall_table.h
> > \ No newline at end of file
>
> Please add the missing newline.

Sure. Will do. Thanks!

>
> > diff --git a/arch/m68k/include/uapi/asm/Kbuild 
> > b/arch/m68k/include/uapi/asm/Kbuild
> > index c2e26a4..6d600e9 100644
> > --- a/arch/m68k/include/uapi/asm/Kbuild
> > +++ b/arch/m68k/include/uapi/asm/Kbuild
> > @@ -21,3 +21,4 @@ generic-y += statfs.h
> >  generic-y += termbits.h
> >  generic-y += termios.h
> >  generic-y += types.h
> > +generic-y += unistd_32.h
> > \ No newline at end of file
>
> Likewise.
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds


Re: [PATCH v2 3/5] m68k: Added system call table generation support

2018-09-24 Thread Firoz Khan
Hi Geert,

On Mon, 24 Sep 2018 at 12:33, Geert Uytterhoeven  wrote:
>
> Hi Firoz,
>
> On Thu, Sep 20, 2018 at 5:07 PM Firoz Khan  wrote:
> > The system call tables are in different format in all
> > architecture and it will be difficult to manually add or
> > modify the system calls in the respective files. To make
> > it easy by keeping a script and which'll generate the
> > header file and syscall table file so this change will
> > unify them across all architectures.
> >
> > The system call table generation script is added in
> > syscalls directory which contain the script to generate
> > both uapi header file system call table generation file
> > and syscall.tbl file which'll be the input for the scripts.
> >
> > syscall.tbl contains the list of available system calls
> > along with system call number and corresponding entry point.
> > Add a new system call in this architecture will be possible
> > by adding new entry in the syscall.tbl file.
> >
> > Adding a new table entry consisting of:
> > - System call number.
> > - ABI.
> > - System call name.
> > - Entry point name.
> >
> > syscallhdr.sh and syscalltbl.sh will generate uapi header-
> > unistd.h and syscall_table.h files respectively. File
> > syscall_table.h is included by syscall_table.S - the real
> > system call table. Both .sh files will parse the content
> > syscall.tbl to generate the header and table files.
> >
> > ARM, s390 and x86 architecuture does have the similar support.
> > I leverage their implementation to come up with a generic
> > solution. And this is the ground work for y2038 issue. We need
> > to change two dozons of system call implementation and this
> > work will reduce the effort by simply modify two dozon entries
> > in syscall.tbl.
> >
> > Signed-off-by: Firoz Khan 
>
> Thanks for your patch!
>
> > --- /dev/null
> > +++ b/arch/m68k/kernel/syscalls/syscall.tbl
> > @@ -0,0 +1,369 @@
> > +#
> > +# Linux system call numbers and entry vectors
> > +#
> > +# The format is:
> > +#
> > +#
> > +# The abi is always common for this file.
> > +#
> > +0   common   restart_syscall  sys_restart_syscall
>
> Why the indentation by an "odd" number of spaces, instead of TABs?

I'll check and fix ASAP. Hopefully I can post a clean (almost) patch series
within couple of days!

- Firoz

>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds


Re: [PATCH v2 0/5] System call table generation support

2018-09-23 Thread Firoz Khan
Hi Greg,

On Mon, 24 Sep 2018 at 06:38, Greg Ungerer  wrote:
>
> Hi Firoz,
>
> On 21/09/18 01:06, Firoz Khan wrote:
> > The purpose of this patch series is:
> > 1. We can easily add/modify/delete system call by changing entry
> > in syscall.tbl file. No need to manually edit many files.
> >
> > 2. It is easy to unify the system call implementation across all
> > the architectures.
> >
> > The system call tables are in different format in all architecture
> > and it will be difficult to manually add or modify the system calls
> > in the respective files manually. To make it easy by keeping a script
> > and which'll generate the header file and syscall table file so this
> > change will unify them across all architectures.
> >
> > syscall.tbl contains the list of available system calls along with
> > system call number and corresponding entry point. Add a new system
> > call in this architecture will be possible by adding new entry in
> > the syscall.tbl file.
> >
> > Adding a new table entry consisting of:
> >  - System call number.
> >  - ABI.
> >  - System call name.
> >  - Entry point name.
> >  - Compat entry name, if required.
> >
> > ARM, s390 and x86 architecuture does exist the similar support. I
> > leverage their implementation to come up with a generic solution.
> >
> > I have done the same support for work for alpha, microblaze, sparc,
> > mips, parisc, powerpc, sh, sparc, and xtensa. But I started sending
> > the patch for one architecuture for review. Below mentioned git
> > repository contains more details.
> > Git repo:- https://github.com/frzkhn/system_call_table_generator/
> >
> > Added an extra patch to keep __IGNORE* entries in asm/unistd.h.
> >
> > Finally, this is the ground work for solving the Y2038 issue. We
> > need to add/change two dozen of system calls to solve Y2038 issue.
> > So this patch series will help to easily modify from existing
> > system call to Y2038 compatible system calls.
> >
> > Firoz Khan (5):
> >m68k: Rename system call table file name
> >m68k: Replace NR_syscalls macro from asm/unistd.h
> >m68k: Added system call table generation support
> >m68k: uapi header and system call table file generation
> >m68k: added __IGNORE* entries in asm/unistd.h
>
> Built and tested on a couple of m68k/ColdFire targets,
> m520x (no MMU) and m5475 (with MMU). Load and run on real hardware,
> no problems found. So for m68knommu/ColdFire:

Thanks for your support!

Philippe De Muyter shared one comment. I have to include that change in the
patch series. BTW I can post version 3 patch series within couple of days.

It would be great if someone can review this patches now and share
your comments.
So I can include it in the next version.

- Firoz

>
> Tested-by: Greg Ungerer 
>
> Regards
> Greg
>
>
> >   arch/m68k/Makefile  |   3 +
> >   arch/m68k/include/asm/Kbuild|   1 +
> >   arch/m68k/include/asm/unistd.h  |  10 +-
> >   arch/m68k/include/uapi/asm/Kbuild   |   1 +
> >   arch/m68k/include/uapi/asm/unistd.h | 385 
> > +-
> >   arch/m68k/kernel/Makefile   |   2 +-
> >   arch/m68k/kernel/syscall_table.S|  14 ++
> >   arch/m68k/kernel/syscalls/Makefile  |  37 +++
> >   arch/m68k/kernel/syscalls/syscall.tbl   | 369 
> > +
> >   arch/m68k/kernel/syscalls/syscallhdr.sh |  39 
> >   arch/m68k/kernel/syscalls/syscalltbl.sh |  28 +++
> >   arch/m68k/kernel/syscalltable.S | 403 
> > 
> >   12 files changed, 502 insertions(+), 790 deletions(-)
> >   create mode 100644 arch/m68k/kernel/syscall_table.S
> >   create mode 100644 arch/m68k/kernel/syscalls/Makefile
> >   create mode 100644 arch/m68k/kernel/syscalls/syscall.tbl
> >   create mode 100644 arch/m68k/kernel/syscalls/syscallhdr.sh
> >   create mode 100644 arch/m68k/kernel/syscalls/syscalltbl.sh
> >   delete mode 100644 arch/m68k/kernel/syscalltable.S
> >


Re: [PATCH v2 1/5] m68k: Rename system call table file name

2018-09-22 Thread Firoz Khan
Hi Phillippe,

On Fri, 21 Sep 2018 at 11:18, Philippe De Muyter  wrote:
>
> On Thu, Sep 20, 2018 at 08:36:09PM +0530, Firoz Khan wrote:
> > The system call table entries are present in syscalltable.S. One of
> > the patch in this patch series will auto-generate the system call
> > table entries using the system call table generation script and
> > which'll replace the existig table file.
> >
> > In order to come up with a common naming convention across all
> > architecture, we need to change the file name to syscall_table.S.
>
> That file was probably called that way to be able to distinguish it
> from syscalltable.s and syscalltable.o in a file system with a 14
> characters limit in file names (in sysV unix systems).
>
> > This change will unify the implementation across all architecture.
> >
> > Signed-off-by: Firoz Khan 
> > ---
> >  arch/m68k/kernel/Makefile|   2 +-
> >  arch/m68k/kernel/syscall_table.S | 403 
> > +++
> >  arch/m68k/kernel/syscalltable.S  | 403 
> > ---
>
> You should generate your patch with the '-M' or '--find-renames' option.

Sure. Thanks!
Firoz

>
> Philippe
>
> --
> Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles


Re: [PATCH 2/4] m68k: Replace NR_syscalls macro from asm/unistd.h

2018-09-22 Thread Firoz Khan
Hi Geert,

On Thu, 20 Sep 2018 at 14:54, Geert Uytterhoeven  wrote:
>
> Hi Firoz,
>
> On Thu, Sep 20, 2018 at 10:12 AM Firoz Khan  wrote:
> > On 18 September 2018 at 15:34, Geert Uytterhoeven  
> > wrote:
> > > On Tue, Sep 18, 2018 at 9:16 AM Firoz Khan  wrote:
> > >> On 9 August 2018 at 13:00, Geert Uytterhoeven  
> > >> wrote:
> > >> > One first comment below...
> > >> >
> > >> > On Thu, Aug 9, 2018 at 7:16 AM Firoz Khan  
> > >> > wrote:
> > >> >> NR_syscalls macro holds the number of system call exist in m68k
> > >> >> architecture. This macro is currently the part of asm/unistd.h file.
> > >> >> We have to change the value of NR_syscalls, if we add or delete a
> > >> >> system call.
> > >> >>
> > >> >> One of patch in this patch series has a script which will generate
> > >> >> a uapi header based on syscall.tbl file. The syscall.tbl file
> > >> >> contains the number of system call information. So we have two
> > >> >> option to update NR_syscalls value.
> > >> >>
> > >> >> 1. Update NR_syscalls in asm/unistd.h manually by counting the
> > >> >>no.of system calls. No need to update NR_syscalls untill
> > >> >>we either add a new system call or delete an existing system
> > >> >>call.
> > >> >>
> > >> >> 2. We can keep this feature it above mentioned script, that'll
> > >> >>count the number of syscalls and keep it in a generated file.
> > >> >>In this case we don't need to explicitly update NR_syscalls
> > >> >>in asm/unistd.h file.
> > >> >>
> > >> >> The 2nd option will be the recommended one. For that, I moved the
> > >> >> NR_syscalls macro from asm/unistd.h to uapi/asm/unistd.h. The macro
> > >> >> name also changed form NR_syscalls to __NR_syscalls for making the
> > >> >> name convention same across all architecture. While __NR_syscalls
> > >> >> isn't strictly part of the uapi, having it as part of the generated
> > >> >> header to simplifies the implementation.
> > >> >
> > >> > It can indeed not be part of the UAPI, as UAPI definitions can never 
> > >> > change,
> > >> > while new syscalls will be added in the future, increasing the number 
> > >> > ;-)
> > >>
> > >> Thanks for your reply :)
> > >> Sorry for the delayed response :(
> > >>
> > >> I would like to keep __NR_syscalls macro to uapi header in order to 
> > >> simplify
> > >> the system call table generation script. Otherwise the __NR_syscalls
> > >> macro need to update manually. That become a problem.
> > >>
> > >> Please check the below implementation in uapi file make sense?
> > >> It is an easy workaround to leave __NR_syscalls macro in 
> > >> uapi/asm/unistd.h
> > >> and enclose it in #ifdef __KERNEL__
> > >>
> > >> ...
> > >> ...
> > >> #define __NR_pwritev2  378
> > >> #define __NR_statx  379
> > >>
> > >> #ifdef __KERNEL__
> > >> #define __NR_syscalls   380
> > >> #endif
> > >> ...
> > >> ...
> > >
> > > #ifdef __KERNEL__ sounds fine to me.
> >
> > I posted similar script for 10 different architectures. I got few good 
> > review
> > from the maintainers and it will be applicable for all the
> > architectures including
> > m68k. There are few area which I identified need to improve. This will take
> > couple of days.
> >
> > But it will be very helpful if you can perform the boot test on the
> > actual platform
> > and share the result.
>
> Builds and boots fine on ARAnyM (virtual Atari).

Thanks for the support :)

>
> So for the full series:
> Tested-by: Geert Uytterhoeven 
>
> However, I noticed the following effective difference between the old
> arch/m68k/include/uapi/asm/unistd.h and the new generated
> arch/m68k/include/generated/uapi/asm/unistd_32.h:
>
> -/*#define __NR_break17*/
> -/*#define __NR_stty 31*/
> -/*#define __NR_gtty 32*/
> -/*#define __NR_ftime35*/
> -/*#define __NR_prof 44*/
> -/*#define __NR_lock 53*/
> -/*#define __NR_mpx

[PATCH v2 4/5] m68k: uapi header and system call table file generation

2018-09-20 Thread Firoz Khan
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
arch/m68k/Makefile and the generated files against the
removed files will be identical.

The generated uapi header file will be included in
uapi/asm/unistd.h and generated system call table support
file will be included by arch/m68k/kernel/syscall_table.S
file.

Signed-off-by: Firoz Khan 
---
 arch/m68k/Makefile  |   3 +
 arch/m68k/include/asm/Kbuild|   1 +
 arch/m68k/include/uapi/asm/Kbuild   |   1 +
 arch/m68k/include/uapi/asm/unistd.h | 389 +--
 arch/m68k/kernel/syscall_table.S| 399 +---
 5 files changed, 11 insertions(+), 782 deletions(-)

diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index 997c9f2..f00ca53 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -154,5 +154,8 @@ endif
 archclean:
rm -f vmlinux.gz vmlinux.bz2
 
+archheaders:
+   $(Q)$(MAKE) $(build)=arch/m68k/kernel/syscalls all
+
 install:
sh $(srctree)/arch/m68k/install.sh $(KERNELRELEASE) vmlinux.gz 
System.map "$(INSTALL_PATH)"
diff --git a/arch/m68k/include/asm/Kbuild b/arch/m68k/include/asm/Kbuild
index a4b8d33..68501411 100644
--- a/arch/m68k/include/asm/Kbuild
+++ b/arch/m68k/include/asm/Kbuild
@@ -24,3 +24,4 @@ generic-y += topology.h
 generic-y += trace_clock.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+generic-y += syscall_table.h
\ No newline at end of file
diff --git a/arch/m68k/include/uapi/asm/Kbuild 
b/arch/m68k/include/uapi/asm/Kbuild
index c2e26a4..6d600e9 100644
--- a/arch/m68k/include/uapi/asm/Kbuild
+++ b/arch/m68k/include/uapi/asm/Kbuild
@@ -21,3 +21,4 @@ generic-y += statfs.h
 generic-y += termbits.h
 generic-y += termios.h
 generic-y += types.h
+generic-y += unistd_32.h
\ No newline at end of file
diff --git a/arch/m68k/include/uapi/asm/unistd.h 
b/arch/m68k/include/uapi/asm/unistd.h
index ba4176aa..cdbd090 100644
--- a/arch/m68k/include/uapi/asm/unistd.h
+++ b/arch/m68k/include/uapi/asm/unistd.h
@@ -2,393 +2,6 @@
 #ifndef _UAPI_ASM_M68K_UNISTD_H_
 #define _UAPI_ASM_M68K_UNISTD_H_
 
-/*
- * This file contains the system call numbers.
- */
-
-#define __NR_restart_syscall 0
-#define __NR_exit1
-#define __NR_fork2
-#define __NR_read3
-#define __NR_write   4
-#define __NR_open5
-#define __NR_close   6
-#define __NR_waitpid 7
-#define __NR_creat   8
-#define __NR_link9
-#define __NR_unlink 10
-#define __NR_execve 11
-#define __NR_chdir  12
-#define __NR_time   13
-#define __NR_mknod  14
-#define __NR_chmod  15
-#define __NR_chown  16
-/*#define __NR_break17*/
-#define __NR_oldstat18
-#define __NR_lseek  19
-#define __NR_getpid 20
-#define __NR_mount  21
-#define __NR_umount 22
-#define __NR_setuid 23
-#define __NR_getuid 24
-#define __NR_stime  25
-#define __NR_ptrace 26
-#define __NR_alarm  27
-#define __NR_oldfstat   28
-#define __NR_pause  29
-#define __NR_utime  30
-/*#define __NR_stty 31*/
-/*#define __NR_gtty 32*/
-#define __NR_access 33
-#define __NR_nice   34
-/*#define __NR_ftime35*/
-#define __NR_sync   36
-#define __NR_kill   37
-#define __NR_rename 38
-#define __NR_mkdir  39
-#define __NR_rmdir  40
-#define __NR_dup41
-#define __NR_pipe   42
-#define __NR_times  43
-/*#define __NR_prof 44*/
-#define __NR_brk45
-#define __NR_setgid 46
-#define __NR_getgid 47
-#define __NR_signal 48
-#define __NR_geteuid49
-#define __NR_getegid50
-#define __NR_acct   51
-#define __NR_umount252
-/*#define __NR_lock 53*/
-#define __NR_ioctl  54
-#define __NR_fcntl  55
-/*#define __NR_mpx  56*/
-#define __NR_setpgid57
-/*#define __NR_ulimit   58*/
-/*#define __NR_oldolduname  59*/
-#define __NR_umask  60
-#define __NR_chroot 61
-#define __NR_ustat  62
-#define __NR_dup2   63
-#define __NR_getppid64
-#define __NR_getpgrp65
-#define __NR_setsid 66
-#define __NR_sigaction  67
-#define __NR_sgetmask   68
-#define __NR_ssetmask   69
-#define __NR_setreuid   70
-#define __NR_setregid   7

[PATCH v2 3/5] m68k: Added system call table generation support

2018-09-20 Thread Firoz Khan
The system call tables are in different format in all
architecture and it will be difficult to manually add or
modify the system calls in the respective files. To make
it easy by keeping a script and which'll generate the
header file and syscall table file so this change will
unify them across all architectures.

The system call table generation script is added in
syscalls directory which contain the script to generate
both uapi header file system call table generation file
and syscall.tbl file which'll be the input for the scripts.

syscall.tbl contains the list of available system calls
along with system call number and corresponding entry point.
Add a new system call in this architecture will be possible
by adding new entry in the syscall.tbl file.

Adding a new table entry consisting of:
- System call number.
- ABI.
- System call name.
- Entry point name.

syscallhdr.sh and syscalltbl.sh will generate uapi header-
unistd.h and syscall_table.h files respectively. File
syscall_table.h is included by syscall_table.S - the real
system call table. Both .sh files will parse the content
syscall.tbl to generate the header and table files.

ARM, s390 and x86 architecuture does have the similar support.
I leverage their implementation to come up with a generic
solution. And this is the ground work for y2038 issue. We need
to change two dozons of system call implementation and this
work will reduce the effort by simply modify two dozon entries
in syscall.tbl.

Signed-off-by: Firoz Khan 
---
 arch/m68k/kernel/syscalls/Makefile  |  37 
 arch/m68k/kernel/syscalls/syscall.tbl   | 369 
 arch/m68k/kernel/syscalls/syscallhdr.sh |  39 
 arch/m68k/kernel/syscalls/syscalltbl.sh |  28 +++
 4 files changed, 473 insertions(+)
 create mode 100644 arch/m68k/kernel/syscalls/Makefile
 create mode 100644 arch/m68k/kernel/syscalls/syscall.tbl
 create mode 100644 arch/m68k/kernel/syscalls/syscallhdr.sh
 create mode 100644 arch/m68k/kernel/syscalls/syscalltbl.sh

diff --git a/arch/m68k/kernel/syscalls/Makefile 
b/arch/m68k/kernel/syscalls/Makefile
new file mode 100644
index 000..7624044
--- /dev/null
+++ b/arch/m68k/kernel/syscalls/Makefile
@@ -0,0 +1,37 @@
+# SPDX-License-Identifier: GPL-2.0
+out := arch/$(SRCARCH)/include/generated/asm
+uapi := arch/$(SRCARCH)/include/generated/uapi/asm
+
+_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \
+ $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
+
+syscall := $(srctree)/$(src)/syscall.tbl
+
+syshdr := $(srctree)/$(src)/syscallhdr.sh
+systbl := $(srctree)/$(src)/syscalltbl.sh
+
+quiet_cmd_syshdr = SYSHDR  $@
+  cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@'  \
+  '$(syshdr_abi_$(basetarget))'  \
+  '$(syshdr_pfx_$(basetarget))'  \
+  '$(syshdr_offset_$(basetarget))'
+
+quiet_cmd_systbl = SYSTBL  $@
+  cmd_systbl = $(CONFIG_SHELL) '$(systbl)' '$<' '$@'  \
+  '$(systbl_abi_$(basetarget))'
+
+$(uapi)/unistd_32.h: $(syscall) $(syshdr)
+   $(call if_changed,syshdr)
+
+$(out)/syscall_table.h: $(syscall) $(systbl)
+   $(call if_changed,systbl)
+
+uapisyshdr-y   += unistd_32.h
+syshdr-y   += syscall_table.h
+
+targets+= $(uapisyshdr-y) $(syshdr-y)
+
+PHONY += all
+all: $(addprefix $(uapi)/,$(uapisyshdr-y))
+all: $(addprefix $(out)/,$(syshdr-y))
+   @:
diff --git a/arch/m68k/kernel/syscalls/syscall.tbl 
b/arch/m68k/kernel/syscalls/syscall.tbl
new file mode 100644
index 000..ab151cd
--- /dev/null
+++ b/arch/m68k/kernel/syscalls/syscall.tbl
@@ -0,0 +1,369 @@
+#
+# Linux system call numbers and entry vectors
+#
+# The format is:
+#
+#
+# The abi is always common for this file.
+#
+0   common   restart_syscall  sys_restart_syscall
+1   common   exit sys_exit
+2   common   fork __sys_fork
+3   common   read sys_read
+4   common   writesys_write
+5   common   open sys_open
+6   common   closesys_close
+7   common   waitpid  sys_waitpid
+8   common   creatsys_creat
+9   common   link sys_link
+10  common   unlink   sys_unlink
+11  common   execve   sys_execve
+12  common   chdirsys_chdir
+13  common   time sys_time
+14  common   mknodsys_mknod
+15  common   chmodsys_chmod
+16  common   chownsys_chown16
+18  common   oldstat  sys_stat
+19  common   lseeksys_lseek
+20  common   getpid   sys_getpid
+21  common   mountsys_mount
+22  common   umount   sys_oldumount
+23  

[PATCH v2 1/5] m68k: Rename system call table file name

2018-09-20 Thread Firoz Khan
The system call table entries are present in syscalltable.S. One of
the patch in this patch series will auto-generate the system call
table entries using the system call table generation script and
which'll replace the existig table file.

In order to come up with a common naming convention across all
architecture, we need to change the file name to syscall_table.S.
This change will unify the implementation across all architecture.

Signed-off-by: Firoz Khan 
---
 arch/m68k/kernel/Makefile|   2 +-
 arch/m68k/kernel/syscall_table.S | 403 +++
 arch/m68k/kernel/syscalltable.S  | 403 ---
 3 files changed, 404 insertions(+), 404 deletions(-)
 create mode 100644 arch/m68k/kernel/syscall_table.S
 delete mode 100644 arch/m68k/kernel/syscalltable.S

diff --git a/arch/m68k/kernel/Makefile b/arch/m68k/kernel/Makefile
index dbac7f8..5f40ce6 100644
--- a/arch/m68k/kernel/Makefile
+++ b/arch/m68k/kernel/Makefile
@@ -15,7 +15,7 @@ extra-$(CONFIG_SUN3)  := sun3-head.o
 extra-y+= vmlinux.lds
 
 obj-y  := entry.o irq.o module.o process.o ptrace.o
-obj-y  += setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o
+obj-y  += setup.o signal.o sys_m68k.o syscall_table.o time.o traps.o
 
 obj-$(CONFIG_MMU_MOTOROLA) += ints.o vectors.o
 obj-$(CONFIG_MMU_SUN3) += ints.o vectors.o
diff --git a/arch/m68k/kernel/syscall_table.S b/arch/m68k/kernel/syscall_table.S
new file mode 100644
index 000..2c8402e
--- /dev/null
+++ b/arch/m68k/kernel/syscall_table.S
@@ -0,0 +1,403 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ *  Copyright (C) 2002, Greg Ungerer (g...@snapgear.com)
+ *
+ *  Based on older entry.S files, the following copyrights apply:
+ *
+ *  Copyright (C) 1998  D. Jeff Dionne ,
+ *  Kenneth Albanowski ,
+ *  Copyright (C) 2000  Lineo Inc. (www.lineo.com) 
+ *  Copyright (C) 1991, 1992  Linus Torvalds
+ *
+ *  Linux/m68k support by Hamish Macdonald
+ */
+
+#include 
+
+#ifndef CONFIG_MMU
+#define sys_mmap2  sys_mmap_pgoff
+#endif
+
+.section .rodata
+ALIGN
+ENTRY(sys_call_table)
+   .long sys_restart_syscall   /* 0 - old "setup()" system call, used 
for restarting */
+   .long sys_exit
+   .long __sys_fork
+   .long sys_read
+   .long sys_write
+   .long sys_open  /* 5 */
+   .long sys_close
+   .long sys_waitpid
+   .long sys_creat
+   .long sys_link
+   .long sys_unlink/* 10 */
+   .long sys_execve
+   .long sys_chdir
+   .long sys_time
+   .long sys_mknod
+   .long sys_chmod /* 15 */
+   .long sys_chown16
+   .long sys_ni_syscall/* old break syscall holder */
+   .long sys_stat
+   .long sys_lseek
+   .long sys_getpid/* 20 */
+   .long sys_mount
+   .long sys_oldumount
+   .long sys_setuid16
+   .long sys_getuid16
+   .long sys_stime /* 25 */
+   .long sys_ptrace
+   .long sys_alarm
+   .long sys_fstat
+   .long sys_pause
+   .long sys_utime /* 30 */
+   .long sys_ni_syscall/* old stty syscall holder */
+   .long sys_ni_syscall/* old gtty syscall holder */
+   .long sys_access
+   .long sys_nice
+   .long sys_ni_syscall/* 35 - old ftime syscall holder */
+   .long sys_sync
+   .long sys_kill
+   .long sys_rename
+   .long sys_mkdir
+   .long sys_rmdir /* 40 */
+   .long sys_dup
+   .long sys_pipe
+   .long sys_times
+   .long sys_ni_syscall/* old prof syscall holder */
+   .long sys_brk   /* 45 */
+   .long sys_setgid16
+   .long sys_getgid16
+   .long sys_signal
+   .long sys_geteuid16
+   .long sys_getegid16 /* 50 */
+   .long sys_acct
+   .long sys_umount/* recycled never used phys() */
+   .long sys_ni_syscall/* old lock syscall holder */
+   .long sys_ioctl
+   .long sys_fcntl /* 55 */
+   .long sys_ni_syscall/* old mpx syscall holder */
+   .long sys_setpgid
+   .long sys_ni_syscall/* old ulimit syscall holder */
+   .long sys_ni_syscall
+   .long sys_umask /* 60 */
+   .long sys_chroot
+   .long sys_ustat
+   .long sys_dup2
+   .long sys_getppid
+   .long sys_getpgrp   /* 65 */
+   .long sys_setsid
+   .long sys_sigaction
+   .long sys_sgetmask
+   .long sys_ssetmask
+   .long sys_setreuid16/* 70 */
+   .long sys_setregid16
+   .long sys_sigsuspend
+   .long sys_sigpending
+   .long sys_sethostname
+   .long sys_setrlimit /* 75 */
+   .long sys_old_getrlimit
+   .long sys_getrusage
+   .long sys_gettimeofday
+   .long sys_se

[PATCH v2 5/5] m68k: added __IGNORE* entries in asm/unistd.h

2018-09-20 Thread Firoz Khan
Added few __IGNORE* entries for seccomp, pkey_mprotect,
pkey_alloc, pkey_free, io_pgetevents and rseq in the file
asm/unistd.h as it is correct to keep __IGNORE* entry in
non uapi header asm/unistd.h while uapi/asm/unistd.h must
hold information only useful for user space applications.

Signed-off-by: Firoz Khan 
---
 arch/m68k/include/asm/unistd.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index 5072e94..cc5f640 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -31,4 +31,11 @@
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_SYS_VFORK
 
+#define __IGNORE_seccomp
+#define __IGNORE_pkey_mprotect
+#define __IGNORE_pkey_alloc
+#define __IGNORE_pkey_free
+#define __IGNORE_io_pgetevents
+#define __IGNORE_rseq
+
 #endif /* _ASM_M68K_UNISTD_H_ */
-- 
1.9.1



Re: [PATCH 2/4] m68k: Replace NR_syscalls macro from asm/unistd.h

2018-09-20 Thread Firoz Khan
Hi Geert,

On 18 September 2018 at 15:34, Geert Uytterhoeven  wrote:
> Hi Firoz,
>
> On Tue, Sep 18, 2018 at 9:16 AM Firoz Khan  wrote:
>> On 9 August 2018 at 13:00, Geert Uytterhoeven  wrote:
>> > One first comment below...
>> >
>> > On Thu, Aug 9, 2018 at 7:16 AM Firoz Khan  wrote:
>> >> NR_syscalls macro holds the number of system call exist in m68k
>> >> architecture. This macro is currently the part of asm/unistd.h file.
>> >> We have to change the value of NR_syscalls, if we add or delete a
>> >> system call.
>> >>
>> >> One of patch in this patch series has a script which will generate
>> >> a uapi header based on syscall.tbl file. The syscall.tbl file
>> >> contains the number of system call information. So we have two
>> >> option to update NR_syscalls value.
>> >>
>> >> 1. Update NR_syscalls in asm/unistd.h manually by counting the
>> >>no.of system calls. No need to update NR_syscalls untill
>> >>we either add a new system call or delete an existing system
>> >>call.
>> >>
>> >> 2. We can keep this feature it above mentioned script, that'll
>> >>count the number of syscalls and keep it in a generated file.
>> >>In this case we don't need to explicitly update NR_syscalls
>> >>in asm/unistd.h file.
>> >>
>> >> The 2nd option will be the recommended one. For that, I moved the
>> >> NR_syscalls macro from asm/unistd.h to uapi/asm/unistd.h. The macro
>> >> name also changed form NR_syscalls to __NR_syscalls for making the
>> >> name convention same across all architecture. While __NR_syscalls
>> >> isn't strictly part of the uapi, having it as part of the generated
>> >> header to simplifies the implementation.
>> >
>> > It can indeed not be part of the UAPI, as UAPI definitions can never 
>> > change,
>> > while new syscalls will be added in the future, increasing the number ;-)
>>
>> Thanks for your reply :)
>> Sorry for the delayed response :(
>>
>> I would like to keep __NR_syscalls macro to uapi header in order to simplify
>> the system call table generation script. Otherwise the __NR_syscalls
>> macro need to update manually. That become a problem.
>>
>> Please check the below implementation in uapi file make sense?
>> It is an easy workaround to leave __NR_syscalls macro in uapi/asm/unistd.h
>> and enclose it in #ifdef __KERNEL__
>>
>> ...
>> ...
>> #define __NR_pwritev2  378
>> #define __NR_statx  379
>>
>> #ifdef __KERNEL__
>> #define __NR_syscalls   380
>> #endif
>> ...
>> ...
>
> #ifdef __KERNEL__ sounds fine to me.

I posted similar script for 10 different architectures. I got few good review
from the maintainers and it will be applicable for all the
architectures including
m68k. There are few area which I identified need to improve. This will take
couple of days.

But it will be very helpful if you can perform the boot test on the
actual platform
and share the result.

FYI, Keeping a single script is always our plan for long run. But I
have to keep a
separate versions for the start so each architecture can be handled  in one
series. Which would make easier to merge in the initial version. we
could probably
add it to scripts/*.sh first, but that requires more coordination between the
architectures.

- Firoz

>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds


Re: [PATCH 2/4] m68k: Replace NR_syscalls macro from asm/unistd.h

2018-09-18 Thread Firoz Khan
On 9 August 2018 at 13:00, Geert Uytterhoeven  wrote:
> Hi Firoz,
>
> One first comment below...
>
> On Thu, Aug 9, 2018 at 7:16 AM Firoz Khan  wrote:
>> NR_syscalls macro holds the number of system call exist in m68k
>> architecture. This macro is currently the part of asm/unistd.h file.
>> We have to change the value of NR_syscalls, if we add or delete a
>> system call.
>>
>> One of patch in this patch series has a script which will generate
>> a uapi header based on syscall.tbl file. The syscall.tbl file
>> contains the number of system call information. So we have two
>> option to update NR_syscalls value.
>>
>> 1. Update NR_syscalls in asm/unistd.h manually by counting the
>>no.of system calls. No need to update NR_syscalls untill
>>we either add a new system call or delete an existing system
>>call.
>>
>> 2. We can keep this feature it above mentioned script, that'll
>>count the number of syscalls and keep it in a generated file.
>>In this case we don't need to explicitly update NR_syscalls
>>in asm/unistd.h file.
>>
>> The 2nd option will be the recommended one. For that, I moved the
>> NR_syscalls macro from asm/unistd.h to uapi/asm/unistd.h. The macro
>> name also changed form NR_syscalls to __NR_syscalls for making the
>> name convention same across all architecture. While __NR_syscalls
>> isn't strictly part of the uapi, having it as part of the generated
>> header to simplifies the implementation.
>
> It can indeed not be part of the UAPI, as UAPI definitions can never change,
> while new syscalls will be added in the future, increasing the number ;-)

Thanks for your reply :)
Sorry for the delayed response :(

I would like to keep __NR_syscalls macro to uapi header in order to simplify
the system call table generation script. Otherwise the __NR_syscalls
macro need to update manually. That become a problem.

Please check the below implementation in uapi file make sense?
It is an easy workaround to leave __NR_syscalls macro in uapi/asm/unistd.h
and enclose it in #ifdef __KERNEL__

...
...
#define __NR_pwritev2  378
#define __NR_statx  379

#ifdef __KERNEL__
#define __NR_syscalls   380
#endif
...
...

>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds


[PATCH 4/4] m68k: uapi header and system call table file generation

2018-08-08 Thread Firoz Khan
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_64.h and syscall_table.h
files by the syscall table generation script invoked by
arch/m68k/Makefile and the generated files against the
removed files will be identical.

The generated uapi header file will be included in
uapi/asm/unistd.h and generated system call table support
file will be included by arch/m68k/kernel/syscall_table.S
file.

Signed-off-by: Firoz Khan 
---
 arch/m68k/Makefile  |   3 +
 arch/m68k/include/asm/Kbuild|   2 +
 arch/m68k/include/uapi/asm/Kbuild   |   2 +
 arch/m68k/include/uapi/asm/unistd.h | 387 +--
 arch/m68k/kernel/syscall_table.S| 397 +---
 5 files changed, 12 insertions(+), 779 deletions(-)

diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index f0dd9fc..8ee2f36 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -154,5 +154,8 @@ endif
 archclean:
rm -f vmlinux.gz vmlinux.bz2
 
+archheaders:
+   $(Q)$(MAKE) $(build)=arch/m68k/kernel/syscalls all
+
 install:
sh $(srctree)/arch/m68k/install.sh $(KERNELRELEASE) vmlinux.gz 
System.map "$(INSTALL_PATH)"
diff --git a/arch/m68k/include/asm/Kbuild b/arch/m68k/include/asm/Kbuild
index 4d8d68c..e3ff55d 100644
--- a/arch/m68k/include/asm/Kbuild
+++ b/arch/m68k/include/asm/Kbuild
@@ -23,3 +23,5 @@ generic-y += topology.h
 generic-y += trace_clock.h
 generic-y += word-at-a-time.h
 generic-y += xor.h
+
+generated-y += syscall_table.h
\ No newline at end of file
diff --git a/arch/m68k/include/uapi/asm/Kbuild 
b/arch/m68k/include/uapi/asm/Kbuild
index c2e26a4..baa7c4f 100644
--- a/arch/m68k/include/uapi/asm/Kbuild
+++ b/arch/m68k/include/uapi/asm/Kbuild
@@ -21,3 +21,5 @@ generic-y += statfs.h
 generic-y += termbits.h
 generic-y += termios.h
 generic-y += types.h
+
+generated-y += unistd_32.h
\ No newline at end of file
diff --git a/arch/m68k/include/uapi/asm/unistd.h 
b/arch/m68k/include/uapi/asm/unistd.h
index b17ae53..cdbd090 100644
--- a/arch/m68k/include/uapi/asm/unistd.h
+++ b/arch/m68k/include/uapi/asm/unistd.h
@@ -2,391 +2,6 @@
 #ifndef _UAPI_ASM_M68K_UNISTD_H_
 #define _UAPI_ASM_M68K_UNISTD_H_
 
-/*
- * This file contains the system call numbers.
- */
-
-#define __NR_restart_syscall 0
-#define __NR_exit1
-#define __NR_fork2
-#define __NR_read3
-#define __NR_write   4
-#define __NR_open5
-#define __NR_close   6
-#define __NR_waitpid 7
-#define __NR_creat   8
-#define __NR_link9
-#define __NR_unlink 10
-#define __NR_execve 11
-#define __NR_chdir  12
-#define __NR_time   13
-#define __NR_mknod  14
-#define __NR_chmod  15
-#define __NR_chown  16
-/*#define __NR_break17*/
-#define __NR_oldstat18
-#define __NR_lseek  19
-#define __NR_getpid 20
-#define __NR_mount  21
-#define __NR_umount 22
-#define __NR_setuid 23
-#define __NR_getuid 24
-#define __NR_stime  25
-#define __NR_ptrace 26
-#define __NR_alarm  27
-#define __NR_oldfstat   28
-#define __NR_pause  29
-#define __NR_utime  30
-/*#define __NR_stty 31*/
-/*#define __NR_gtty 32*/
-#define __NR_access 33
-#define __NR_nice   34
-/*#define __NR_ftime35*/
-#define __NR_sync   36
-#define __NR_kill   37
-#define __NR_rename 38
-#define __NR_mkdir  39
-#define __NR_rmdir  40
-#define __NR_dup41
-#define __NR_pipe   42
-#define __NR_times  43
-/*#define __NR_prof 44*/
-#define __NR_brk45
-#define __NR_setgid 46
-#define __NR_getgid 47
-#define __NR_signal 48
-#define __NR_geteuid49
-#define __NR_getegid50
-#define __NR_acct   51
-#define __NR_umount252
-/*#define __NR_lock 53*/
-#define __NR_ioctl  54
-#define __NR_fcntl  55
-/*#define __NR_mpx  56*/
-#define __NR_setpgid57
-/*#define __NR_ulimit   58*/
-/*#define __NR_oldolduname  59*/
-#define __NR_umask  60
-#define __NR_chroot 61
-#define __NR_ustat  62
-#define __NR_dup2   63
-#define __NR_getppid64
-#define __NR_getpgrp65
-#define __NR_setsid 66
-#define __NR_sigaction  67
-#define __NR_sgetmask   68
-#define __NR_ssetmask   69
-#define __NR_setreuid   70
-#define __NR_setregid   7

[PATCH 3/4] m68k: Added system call table generation support

2018-08-08 Thread Firoz Khan
The system call tables are in different format in all
architecture and it will be difficult to manually add or
modify the system calls in the respective files. To make
it easy by keeping a script and which'll generate the
header file and syscall table file so this change will
unify them across all architectures.

The system call table generation script is added in
syscalls directory which contain the script to generate
both uapi header file system call table generation file
and syscall.tbl file which'll be the input for the scripts.

syscall.tbl contains the list of available system calls
along with system call number and corresponding entry point.
Add a new system call in this architecture will be possible
by adding new entry in the syscall.tbl file.

Adding a new table entry consisting of:
- System call number.
- ABI.
- System call name.
- Entry point name.

syscallhdr.sh and syscalltbl.sh will generate uapi header-
unistd.h and syscall_table.h files respectively. File
syscall_table.h is included by syscall.S - the real system
call table. Both .sh files will parse the content syscall.tbl
to generate the header and table files.

ARM, s390 and x86 architecuture does have the similar support.
I leverage their implementation to come up with a generic
solution. And this is the ground work for y2038 issue. We need
to change 52 system call implementation and this work will
reduce the effort by simply modify 52 entries in syscall.tbl.

Signed-off-by: Firoz Khan 
---
 arch/m68k/kernel/syscalls/Makefile  |  37 +++
 arch/m68k/kernel/syscalls/syscall.tbl   | 386 
 arch/m68k/kernel/syscalls/syscallhdr.sh |  33 +++
 arch/m68k/kernel/syscalls/syscalltbl.sh |  28 +++
 4 files changed, 484 insertions(+)
 create mode 100644 arch/m68k/kernel/syscalls/Makefile
 create mode 100644 arch/m68k/kernel/syscalls/syscall.tbl
 create mode 100644 arch/m68k/kernel/syscalls/syscallhdr.sh
 create mode 100644 arch/m68k/kernel/syscalls/syscalltbl.sh

diff --git a/arch/m68k/kernel/syscalls/Makefile 
b/arch/m68k/kernel/syscalls/Makefile
new file mode 100644
index 000..7624044
--- /dev/null
+++ b/arch/m68k/kernel/syscalls/Makefile
@@ -0,0 +1,37 @@
+# SPDX-License-Identifier: GPL-2.0
+out := arch/$(SRCARCH)/include/generated/asm
+uapi := arch/$(SRCARCH)/include/generated/uapi/asm
+
+_dummy := $(shell [ -d '$(uapi)' ] || mkdir -p '$(uapi)') \
+ $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
+
+syscall := $(srctree)/$(src)/syscall.tbl
+
+syshdr := $(srctree)/$(src)/syscallhdr.sh
+systbl := $(srctree)/$(src)/syscalltbl.sh
+
+quiet_cmd_syshdr = SYSHDR  $@
+  cmd_syshdr = $(CONFIG_SHELL) '$(syshdr)' '$<' '$@'  \
+  '$(syshdr_abi_$(basetarget))'  \
+  '$(syshdr_pfx_$(basetarget))'  \
+  '$(syshdr_offset_$(basetarget))'
+
+quiet_cmd_systbl = SYSTBL  $@
+  cmd_systbl = $(CONFIG_SHELL) '$(systbl)' '$<' '$@'  \
+  '$(systbl_abi_$(basetarget))'
+
+$(uapi)/unistd_32.h: $(syscall) $(syshdr)
+   $(call if_changed,syshdr)
+
+$(out)/syscall_table.h: $(syscall) $(systbl)
+   $(call if_changed,systbl)
+
+uapisyshdr-y   += unistd_32.h
+syshdr-y   += syscall_table.h
+
+targets+= $(uapisyshdr-y) $(syshdr-y)
+
+PHONY += all
+all: $(addprefix $(uapi)/,$(uapisyshdr-y))
+all: $(addprefix $(out)/,$(syshdr-y))
+   @:
diff --git a/arch/m68k/kernel/syscalls/syscall.tbl 
b/arch/m68k/kernel/syscalls/syscall.tbl
new file mode 100644
index 000..00a44ba
--- /dev/null
+++ b/arch/m68k/kernel/syscalls/syscall.tbl
@@ -0,0 +1,386 @@
+#
+# Linux system call numbers and entry vectors
+#
+# The format is:
+#
+#
+# The abi is always common for this file.
+#
+0   common   restart_syscall  sys_restart_syscall
+1   common   exit sys_exit
+2   common   fork __sys_fork
+3   common   read sys_read
+4   common   writesys_write
+5   common   open sys_open
+6   common   closesys_close
+7   common   waitpid  sys_waitpid
+8   common   creatsys_creat
+9   common   link sys_link
+10  common   unlink   sys_unlink
+11  common   execve   sys_execve
+12  common   chdirsys_chdir
+13  common   time sys_time
+14  common   mknodsys_mknod
+15  common   chmodsys_chmod
+16  common   chownsys_chown16
+17 common   breaksys_ni_syscall
+18  common   oldstat  sys_stat
+19  common   lseeksys_lseek
+20  common   getpid   sys_getpid
+21  common   mountsys_mount
+22  common   

[PATCH 2/4] m68k: Replace NR_syscalls macro from asm/unistd.h

2018-08-08 Thread Firoz Khan
NR_syscalls macro holds the number of system call exist in m68k
architecture. This macro is currently the part of asm/unistd.h file.
We have to change the value of NR_syscalls, if we add or delete a
system call.

One of patch in this patch series has a script which will generate
a uapi header based on syscall.tbl file. The syscall.tbl file
contains the number of system call information. So we have two
option to update NR_syscalls value.

1. Update NR_syscalls in asm/unistd.h manually by counting the
   no.of system calls. No need to update NR_syscalls untill
   we either add a new system call or delete an existing system
   call.

2. We can keep this feature it above mentioned script, that'll
   count the number of syscalls and keep it in a generated file.
   In this case we don't need to explicitly update NR_syscalls
   in asm/unistd.h file.

The 2nd option will be the recommended one. For that, I moved the
NR_syscalls macro from asm/unistd.h to uapi/asm/unistd.h. The macro
name also changed form NR_syscalls to __NR_syscalls for making the
name convention same across all architecture. While __NR_syscalls
isn't strictly part of the uapi, having it as part of the generated
header to simplifies the implementation.

Signed-off-by: Firoz Khan 
---
 arch/m68k/68000/entry.S | 4 ++--
 arch/m68k/coldfire/entry.S  | 2 +-
 arch/m68k/include/asm/unistd.h  | 3 ---
 arch/m68k/include/uapi/asm/unistd.h | 2 ++
 arch/m68k/kernel/entry.S| 4 ++--
 5 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/m68k/68000/entry.S b/arch/m68k/68000/entry.S
index 259b366..91522e9 100644
--- a/arch/m68k/68000/entry.S
+++ b/arch/m68k/68000/entry.S
@@ -49,7 +49,7 @@ do_trace:
addql   #4,%sp
movel   %sp@(PT_OFF_ORIG_D0),%d1
movel   #-ENOSYS,%d0
-   cmpl#NR_syscalls,%d1
+   cmpl#__NR_syscalls,%d1
jcc 1f
lsl #2,%d1
lea sys_call_table, %a0
@@ -80,7 +80,7 @@ ENTRY(system_call)
movel   %d1,%a2
btst
#(TIF_SYSCALL_TRACE%8),%a2@(TINFO_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
jne do_trace
-   cmpl#NR_syscalls,%d0
+   cmpl#__NR_syscalls,%d0
jcc badsys
lsl #2,%d0
lea sys_call_table,%a0
diff --git a/arch/m68k/coldfire/entry.S b/arch/m68k/coldfire/entry.S
index 52d312d..efe777d 100644
--- a/arch/m68k/coldfire/entry.S
+++ b/arch/m68k/coldfire/entry.S
@@ -64,7 +64,7 @@ ENTRY(system_call)
move#0x2000,%sr /* enable intrs again */
GET_CURRENT(%d2)
 
-   cmpl#NR_syscalls,%d0
+   cmpl#__NR_syscalls,%d0
jcc enosys
lea sys_call_table,%a0
lsll#2,%d0  /* movel %a0@(%d0:l:4),%d3 */
diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index 30d0d3f..52111fb 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -4,9 +4,6 @@
 
 #include 
 
-
-#define NR_syscalls380
-
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_OLD_STAT
 #define __ARCH_WANT_STAT64
diff --git a/arch/m68k/include/uapi/asm/unistd.h 
b/arch/m68k/include/uapi/asm/unistd.h
index de3054f..b17ae53 100644
--- a/arch/m68k/include/uapi/asm/unistd.h
+++ b/arch/m68k/include/uapi/asm/unistd.h
@@ -387,4 +387,6 @@
 #define __NR_pwritev2  378
 #define __NR_statx 379
 
+#define __NR_syscalls  380
+
 #endif /* _UAPI_ASM_M68K_UNISTD_H_ */
diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S
index 97cd3ea..dab0cfd 100644
--- a/arch/m68k/kernel/entry.S
+++ b/arch/m68k/kernel/entry.S
@@ -161,7 +161,7 @@ do_trace_entry:
RESTORE_SWITCH_STACK
addql   #4,%sp
movel   %sp@(PT_OFF_ORIG_D0),%d0
-   cmpl#NR_syscalls,%d0
+   cmpl#__NR_syscalls,%d0
jcs syscall
 badsys:
movel   #-ENOSYS,%sp@(PT_OFF_D0)
@@ -206,7 +206,7 @@ ENTRY(system_call)
| syscall trace?
tstb%a1@(TINFO_FLAGS+2)
jmi do_trace_entry
-   cmpl#NR_syscalls,%d0
+   cmpl#__NR_syscalls,%d0
jcc badsys
 syscall:
jbsr@(sys_call_table,%d0:l:4)@(0)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] m68k: Rename system call table file name

2018-08-08 Thread Firoz Khan
The system call table entries are present in syscalltable.S. One of
the patch in this patch series will auto-generate the system call
table entries using the system call table generation script and
which'll replace the existig table file.

In order to come up with a common naming convention across all
architecture, we need to change the file name to syscall_table.S.
This change will unify the implementation across all architecture.

Signed-off-by: Firoz Khan 
---
 arch/m68k/kernel/Makefile|   2 +-
 arch/m68k/kernel/syscall_table.S | 403 +++
 arch/m68k/kernel/syscalltable.S  | 403 ---
 3 files changed, 404 insertions(+), 404 deletions(-)
 create mode 100644 arch/m68k/kernel/syscall_table.S
 delete mode 100644 arch/m68k/kernel/syscalltable.S

diff --git a/arch/m68k/kernel/Makefile b/arch/m68k/kernel/Makefile
index dbac7f8..5f40ce6 100644
--- a/arch/m68k/kernel/Makefile
+++ b/arch/m68k/kernel/Makefile
@@ -15,7 +15,7 @@ extra-$(CONFIG_SUN3)  := sun3-head.o
 extra-y+= vmlinux.lds
 
 obj-y  := entry.o irq.o module.o process.o ptrace.o
-obj-y  += setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o
+obj-y  += setup.o signal.o sys_m68k.o syscall_table.o time.o traps.o
 
 obj-$(CONFIG_MMU_MOTOROLA) += ints.o vectors.o
 obj-$(CONFIG_MMU_SUN3) += ints.o vectors.o
diff --git a/arch/m68k/kernel/syscall_table.S b/arch/m68k/kernel/syscall_table.S
new file mode 100644
index 000..2c8402e
--- /dev/null
+++ b/arch/m68k/kernel/syscall_table.S
@@ -0,0 +1,403 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ *  Copyright (C) 2002, Greg Ungerer (g...@snapgear.com)
+ *
+ *  Based on older entry.S files, the following copyrights apply:
+ *
+ *  Copyright (C) 1998  D. Jeff Dionne ,
+ *  Kenneth Albanowski ,
+ *  Copyright (C) 2000  Lineo Inc. (www.lineo.com) 
+ *  Copyright (C) 1991, 1992  Linus Torvalds
+ *
+ *  Linux/m68k support by Hamish Macdonald
+ */
+
+#include 
+
+#ifndef CONFIG_MMU
+#define sys_mmap2  sys_mmap_pgoff
+#endif
+
+.section .rodata
+ALIGN
+ENTRY(sys_call_table)
+   .long sys_restart_syscall   /* 0 - old "setup()" system call, used 
for restarting */
+   .long sys_exit
+   .long __sys_fork
+   .long sys_read
+   .long sys_write
+   .long sys_open  /* 5 */
+   .long sys_close
+   .long sys_waitpid
+   .long sys_creat
+   .long sys_link
+   .long sys_unlink/* 10 */
+   .long sys_execve
+   .long sys_chdir
+   .long sys_time
+   .long sys_mknod
+   .long sys_chmod /* 15 */
+   .long sys_chown16
+   .long sys_ni_syscall/* old break syscall holder */
+   .long sys_stat
+   .long sys_lseek
+   .long sys_getpid/* 20 */
+   .long sys_mount
+   .long sys_oldumount
+   .long sys_setuid16
+   .long sys_getuid16
+   .long sys_stime /* 25 */
+   .long sys_ptrace
+   .long sys_alarm
+   .long sys_fstat
+   .long sys_pause
+   .long sys_utime /* 30 */
+   .long sys_ni_syscall/* old stty syscall holder */
+   .long sys_ni_syscall/* old gtty syscall holder */
+   .long sys_access
+   .long sys_nice
+   .long sys_ni_syscall/* 35 - old ftime syscall holder */
+   .long sys_sync
+   .long sys_kill
+   .long sys_rename
+   .long sys_mkdir
+   .long sys_rmdir /* 40 */
+   .long sys_dup
+   .long sys_pipe
+   .long sys_times
+   .long sys_ni_syscall/* old prof syscall holder */
+   .long sys_brk   /* 45 */
+   .long sys_setgid16
+   .long sys_getgid16
+   .long sys_signal
+   .long sys_geteuid16
+   .long sys_getegid16 /* 50 */
+   .long sys_acct
+   .long sys_umount/* recycled never used phys() */
+   .long sys_ni_syscall/* old lock syscall holder */
+   .long sys_ioctl
+   .long sys_fcntl /* 55 */
+   .long sys_ni_syscall/* old mpx syscall holder */
+   .long sys_setpgid
+   .long sys_ni_syscall/* old ulimit syscall holder */
+   .long sys_ni_syscall
+   .long sys_umask /* 60 */
+   .long sys_chroot
+   .long sys_ustat
+   .long sys_dup2
+   .long sys_getppid
+   .long sys_getpgrp   /* 65 */
+   .long sys_setsid
+   .long sys_sigaction
+   .long sys_sgetmask
+   .long sys_ssetmask
+   .long sys_setreuid16/* 70 */
+   .long sys_setregid16
+   .long sys_sigsuspend
+   .long sys_sigpending
+   .long sys_sethostname
+   .long sys_setrlimit /* 75 */
+   .long sys_old_getrlimit
+   .long sys_getrusage
+   .long sys_gettimeofday
+   .long sys_se

[PATCH 0/4] System call table generation support

2018-08-08 Thread Firoz Khan
The purpose of this patch series is:
1. We can easily add/modify/delete system call by changing entry 
in syscall.tbl file. No need to manually edit many files.

2. It is easy to unify the system call implementation across all 
the architectures. 

The system call tables are in different format in all architecture 
and it will be difficult to manually add or modify the system calls
manually in the respective files. To make it easy by keeping a script 
and which'll generate the header file and syscall table file so this 
change will unify the implementation across all architectures.

syscall.tbl contains the list of available system calls along with 
system call number and corresponding entry point. Add a new system 
call in this architecture will be possible by adding new entry in 
the syscall.tbl file.

Adding a new table entry consisting of:
- System call number.
- ABI.
- System call name.
- Entry point name.

ARM, s390 and x86 architecuture does exist the similar support. I 
leverage their implementation to come up with a generic solution.

I have done the same support for work for alpha, microblaze, ia64, 
mips, parisc, powerpc, sh, sparc, and xtensa. But I started sending 
the patch for one architecuture for review. Below mentioned git
repository contains more details.
Git repo:- https://github.com/frzkhn/system_call_table_generator/

Finally, this is the ground work for solving the Y2038 issue. We 
need to add/change two dozen of system calls to solve Y2038 issue. 
So this patch series will help to easily modify from existing 
system call to Y2038 compatible system calls.

I started working system call table generation on 4.17-rc1. I used 
marcin's script - https://github.com/hrw/syscalls-table to generate 
the syscall.tbl file. And this will be the input to the system call 
table generation script. But there are couple system call got add 
in the latest rc release. If run Marcin's script on latest release,
it will generate a different syscall.tbl. But I still use the old 
file - syscall.tbl and once all review got over I'll update 
syscall.tbl alone w.r.to the tip of the kernel. The impact of this
is, few of the system call won't work.

Firoz Khan (4):
  m68k: Rename system call table file name
  m68k: Replace NR_syscalls macro from asm/unistd.h
  m68k: Added system call table generation support
  m68k: uapi header and system call table file generation

 arch/m68k/68000/entry.S |   4 +-
 arch/m68k/Makefile  |   3 +
 arch/m68k/coldfire/entry.S  |   2 +-
 arch/m68k/include/asm/Kbuild|   2 +
 arch/m68k/include/asm/unistd.h  |   3 -
 arch/m68k/include/uapi/asm/Kbuild   |   2 +
 arch/m68k/include/uapi/asm/unistd.h | 385 +-
 arch/m68k/kernel/Makefile   |   2 +-
 arch/m68k/kernel/entry.S|   4 +-
 arch/m68k/kernel/syscall_table.S|  14 ++
 arch/m68k/kernel/syscalls/Makefile  |  37 +++
 arch/m68k/kernel/syscalls/syscall.tbl   | 386 ++
 arch/m68k/kernel/syscalls/syscallhdr.sh |  33 +++
 arch/m68k/kernel/syscalls/syscalltbl.sh |  28 +++
 arch/m68k/kernel/syscalltable.S | 403 
 15 files changed, 512 insertions(+), 796 deletions(-)
 create mode 100644 arch/m68k/kernel/syscall_table.S
 create mode 100644 arch/m68k/kernel/syscalls/Makefile
 create mode 100644 arch/m68k/kernel/syscalls/syscall.tbl
 create mode 100644 arch/m68k/kernel/syscalls/syscallhdr.sh
 create mode 100644 arch/m68k/kernel/syscalls/syscalltbl.sh
 delete mode 100644 arch/m68k/kernel/syscalltable.S

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html