This will be an automated scripts to provide easy support
for add/modify/delete the system call entry by add entry
in respective syscall.tbl file.
System call table generation support for asm-generic is
provide for c6x architecture which will use the common
scripts resides in scripts directory and use syscall.tbl
as inputs. This implementation will replace asm-generic-
/unistd.h.
This patch depends on:
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/
Firoz Khan (3):
c6x: add Makefile to invoke syscall table generation script
c6x: add __ARCH_NOMMU as a bugfix
c6x: generate uapi and kapi headers
arch/c6x/Makefile | 3 +++
arch/c6x/include/asm/Kbuild | 1 +
arch/c6x/include/uapi/asm/Kbuild | 1 +
arch/c6x/include/uapi/asm/unistd.h | 15 +++++++++-----
arch/c6x/kernel/sys_c6x.c | 3 ++-
arch/c6x/kernel/syscalls/Makefile | 41 ++++++++++++++++++++++++++++++++++++++
6 files changed, 58 insertions(+), 6 deletions(-)
create mode 100644 arch/c6x/kernel/syscalls/Makefile
--
1.9.1
Add __ARCH_NOMMU in uapi/asm/unistd.h file as a bugfix.
Signed-off-by: Firoz Khan <[email protected]>
---
arch/c6x/include/uapi/asm/unistd.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/c6x/include/uapi/asm/unistd.h b/arch/c6x/include/uapi/asm/unistd.h
index 6b2fe79..9e9ffe5 100644
--- a/arch/c6x/include/uapi/asm/unistd.h
+++ b/arch/c6x/include/uapi/asm/unistd.h
@@ -18,6 +18,7 @@
#define __ARCH_WANT_RENAMEAT
#define __ARCH_WANT_STAT64
#define __ARCH_WANT_SYS_CLONE
+#define __ARCH_NOMMU
/* Use the standard ABI for syscalls. */
#include <asm-generic/unistd.h>
--
1.9.1
Unified system call table generation script need to be invoked
to generated the uapi and kapi headers. The Makefile changes
present in this patch will invoke the scripts and generate uapi
and kapi header files.
The generated files - unistd_*.h and syscall_table_*.h files
will be included by unistd.h and sys_c6x.c files by replacing
asm-generic/unistd.h file.
Signed-off-by: Firoz Khan <[email protected]>
---
arch/c6x/Makefile | 3 +++
arch/c6x/include/asm/Kbuild | 1 +
arch/c6x/include/uapi/asm/Kbuild | 1 +
arch/c6x/include/uapi/asm/unistd.h | 14 +++++++++-----
arch/c6x/kernel/sys_c6x.c | 3 ++-
5 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/arch/c6x/Makefile b/arch/c6x/Makefile
index b7aa854..acc9c91 100644
--- a/arch/c6x/Makefile
+++ b/arch/c6x/Makefile
@@ -53,6 +53,9 @@ dtbImage.%: vmlinux
archclean:
$(Q)$(MAKE) $(clean)=$(boot)
+archheaders:
+ $(Q)$(MAKE) $(build)=arch/c6x/kernel/syscalls all
+
define archhelp
@echo ' vmlinux.bin - Binary kernel image (arch/$(ARCH)/boot/vmlinux.bin)'
@echo ' dtbImage.<dt> - ELF image with $(arch)/boot/dts/<dt>.dts linked in'
diff --git a/arch/c6x/include/asm/Kbuild b/arch/c6x/include/asm/Kbuild
index 33a2c94..3d551e6 100644
--- a/arch/c6x/include/asm/Kbuild
+++ b/arch/c6x/include/asm/Kbuild
@@ -1,3 +1,4 @@
+generated-y += syscall_table.h
generic-y += atomic.h
generic-y += barrier.h
generic-y += bugs.h
diff --git a/arch/c6x/include/uapi/asm/Kbuild b/arch/c6x/include/uapi/asm/Kbuild
index 6c6f630..28823e3 100644
--- a/arch/c6x/include/uapi/asm/Kbuild
+++ b/arch/c6x/include/uapi/asm/Kbuild
@@ -1,5 +1,6 @@
include include/uapi/asm-generic/Kbuild.asm
+generated-y += unistd_32.h
generic-y += kvm_para.h
generic-y += shmparam.h
generic-y += ucontext.h
diff --git a/arch/c6x/include/uapi/asm/unistd.h b/arch/c6x/include/uapi/asm/unistd.h
index 9e9ffe5..4633005 100644
--- a/arch/c6x/include/uapi/asm/unistd.h
+++ b/arch/c6x/include/uapi/asm/unistd.h
@@ -20,9 +20,13 @@
#define __ARCH_WANT_SYS_CLONE
#define __ARCH_NOMMU
-/* Use the standard ABI for syscalls. */
-#include <asm-generic/unistd.h>
+#include <asm/bitsperlong.h>
-/* C6X-specific syscalls. */
-#define __NR_cache_sync (__NR_arch_specific_syscall + 0)
-__SYSCALL(__NR_cache_sync, sys_cache_sync)
+#ifndef __SYSCALL
+#define __SYSCALL(x, y)
+#endif
+
+#if __BITS_PER_LONG == 32
+#define __NR_cache_sync __NR_arch_specific_syscall0
+#include <asm/unistd_32.h>
+#endif
diff --git a/arch/c6x/kernel/sys_c6x.c b/arch/c6x/kernel/sys_c6x.c
index a742ae25..3e4b4e4 100644
--- a/arch/c6x/kernel/sys_c6x.c
+++ b/arch/c6x/kernel/sys_c6x.c
@@ -70,5 +70,6 @@ asmlinkage int sys_cache_sync(unsigned long s, unsigned long e)
*/
void *sys_call_table[__NR_syscalls] = {
[0 ... __NR_syscalls-1] = sys_ni_syscall,
-#include <asm/unistd.h>
+#define sys_arch_specific_syscall0 sys_cache_sync
+#include <asm/syscall_table.h>
};
--
1.9.1
Add Makefile to invoke the system call table generation script
which is placed in scripts directory as a common location acc-
essible for all the architectures.
scripts/syscallhdr.sh will generate uapi header and scripts-
/syscalltbl.sh will generate kapi header respectively. There
is another scripts scripts/syscallnr.sh can generate total
number of syscall which doesn't invoke from this Makefile.
Signed-off-by: Firoz Khan <[email protected]>
---
arch/c6x/kernel/syscalls/Makefile | 41 +++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100644 arch/c6x/kernel/syscalls/Makefile
diff --git a/arch/c6x/kernel/syscalls/Makefile b/arch/c6x/kernel/syscalls/Makefile
new file mode 100644
index 0000000..1865a80
--- /dev/null
+++ b/arch/c6x/kernel/syscalls/Makefile
@@ -0,0 +1,41 @@
+# 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)/scripts/syscalls/syscall.tbl
+syshdr := $(srctree)/scripts/syscallhdr.sh
+systbl := $(srctree)/scripts/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))'
+
+syshdr_abis_unistd_32 := common,32,rename,stat64,archs0
+$(uapi)/unistd_32.h: $(syscall) $(syshdr)
+ $(call if_changed,syshdr)
+
+systbl_abis_syscall_table := common,32,rename,stat64,archs0
+systbl_abi_syscall_table := 32
+$(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))
+ @:
--
1.9.1
Hi Firoz,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.0-rc1]
[cannot apply to next-20190107]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Firoz-Khan/c6x-system-call-table-generation-for-asm-generic/20190108-100353
config: c6x-evmc6678_defconfig (attached as .config)
compiler: c6x-elf-gcc (GCC) 8.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=8.1.0 make.cross ARCH=c6x
All errors (new ones prefixed by >>):
>> make[2]: *** No rule to make target 'scripts/syscalls/syscall.tbl', needed by 'arch/c6x/include/generated/asm/syscall_table.h'.
>> make[2]: *** No rule to make target 'scripts/syscalltbl.sh', needed by 'arch/c6x/include/generated/asm/syscall_table.h'.
>> make[2]: *** No rule to make target 'scripts/syscallhdr.sh', needed by 'arch/c6x/include/generated/uapi/asm/unistd_32.h'.
make[2]: Target 'all' not remade because of errors.
make[1]: *** [archheaders] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [sub-make] Error 2
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation