Skip to contentSkip to conversation

RFC x86: Generate system calls from a simple table

PATCH In review H. Peter Anvin 5 participants 23 messages Nov 17, 2011 – Nov 22, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover RFC x86: Generate system calls from a simple table

From: "H. Peter Anvin" <[email protected]>

This patch series generates all the files that depend on the x86 system call numbers -- specifically unistd_*.h and the system call tables themselves -- from a simple text file table. Furthermore, it unifies the multiple different ways that the system call tables are generated. Although this is an x86-specific patch, the scripts are intended to be generic enough that it should be easy for other architectures to use them as well.

The "ABI" column in the text file is currently unused, however, it is intended to support the new x32 ABI, and may be helpful for other architectures that have multiple system call ABI ranges as well.

Special thanks to David Woodhouse, Michal Marek and Sam Ravnborg for helping me straight out the maze of Kbuild dependencies.

 Documentation/kbuild/makefiles.txt |   50 ++-
 Makefile                           |    9 +-
 arch/x86/Makefile                  |    6 +
 arch/x86/ia32/Makefile             |    1 +
 arch/x86/ia32/ia32entry.S          |  359 ------------------
 arch/x86/ia32/nosyscall.c          |    7 +
 arch/x86/ia32/syscall_ia32.c       |   25 ++
 arch/x86/include/asm/Kbuild        |    5 +-
 arch/x86/include/asm/ia32_unistd.h |   13 +-
 arch/x86/include/asm/unistd.h      |   54 +++-
 arch/x86/include/asm/unistd_32.h   |  401 --------------------
 arch/x86/include/asm/unistd_64.h   |  732 ------------------------------------
 arch/x86/kernel/Makefile           |    3 +-
 arch/x86/kernel/asm-offsets_32.c   |    8 +
 arch/x86/kernel/asm-offsets_64.c   |   19 +-
 arch/x86/kernel/entry_32.S         |   37 +--
 arch/x86/kernel/syscall_32.c       |   25 ++
 arch/x86/kernel/syscall_64.c       |   20 +-
 arch/x86/kernel/syscall_table_32.S |  350 -----------------
 arch/x86/syscalls/Makefile         |   43 +++
 arch/x86/syscalls/syscall_32.tbl   |  357 ++++++++++++++++++
 arch/x86/syscalls/syscall_64.tbl   |  320 ++++++++++++++++
 arch/x86/syscalls/syscallhdr.sh    |   36 ++
 arch/x86/syscalls/syscalltbl.sh    |   15 +
 kernel/trace/trace_syscalls.c      |    1 +
 scripts/Makefile.headersinst       |   10 +-
 scripts/checksyscalls.sh           |   15 +-
 scripts/headers.sh                 |    1 +
 28 files changed, 993 insertions(+), 1929 deletions(-)
#1 lore raw

PATCH 1/8 kbuild: Add support for installing generated asm headers

From: "H. Peter Anvin" <[email protected]>

Generated asm headers are supposed to live in arch/*/include/generated/asm, but objhdr-y expect them to live in the same directory they are generated in. Instead of trying to cut that particular Gordian knot, introduce genhdr-y that takes this into account; the sole user of objhdr-y, linux/version.h, should be migrated over at some later date.

---
 scripts/Makefile.headersinst |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
scripts/Makefile.headersinst +8 -2
index a57f5bd..d3bae5e 100644
@@ -4,12 +4,16 @@
 # header-y  - list files to be installed. They are preprocessed
 #             to remove __KERNEL__ section of the file
 # objhdr-y  - Same as header-y but for generated files
+# genhdr-y  - Same as objhdr-y but in a generated/ directory
 #
 # ==========================================================================
 
 # called may set destination dir (when installing to asm/)
 _dst := $(if $(dst),$(dst),$(obj))
 
+# generated header directory
+gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj)))
+
 kbuild-file := $(srctree)/$(obj)/Kbuild
 include $(kbuild-file)
 
@@ -33,9 +37,10 @@ wrapper-files := $(filter $(header-y), $(generic-y))
 
 # all headers files for this dir
 header-y      := $(filter-out $(generic-y), $(header-y))
-all-files     := $(header-y) $(objhdr-y) $(wrapper-files)
+all-files     := $(header-y) $(objhdr-y) $(genhdr-y) $(wrapper-files)
 input-files   := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
-                 $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
+                 $(addprefix $(objtree)/$(obj)/,$(objhdr-y)) \
+                 $(addprefix $(objtree)/$(gen)/,$(genhdr-y))
 output-files  := $(addprefix $(install)/, $(all-files))
 
 # Work out what needs to be removed
@@ -52,6 +57,7 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
       cmd_install = \
         $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
         $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
+        $(PERL) $< $(objtree)/$(gen) $(install) $(SRCARCH) $(genhdr-y); \
         for F in $(wrapper-files); do                                   \
                 echo "\#include <asm-generic/$$F>" > $(install)/$$F;    \
         done;                                                           \
Signature · 1 line
1.7.6.4
Acked-by on v1 1/8
#2 lore raw

Re: [PATCH 1/8] kbuild: Add support for installing generated asm headers

Dne 17.11.2011 23:37, H. Peter Anvin napsal(a):

Quoted 9 lines

From: "H. Peter Anvin" <[email protected]>

Generated asm headers are supposed to live in arch/*/include/generated/asm, but objhdr-y expect them to live in the same directory they are generated in. Instead of trying to cut that particular Gordian knot, introduce genhdr-y that takes this into account; the sole user of objhdr-y, linux/version.h, should be migrated over at some later date.

Quoted 5 lines
#3 lore raw

PATCH 2/8 kbuild: Add support for an "archheaders" target

In reply to H. Peter Anvin

From: "H. Peter Anvin" <[email protected]>

Add support for an "archheaders" target. This target can generate files that need to be installed for user space by "make headers_install" or "make headers_install_all".

In order to support "make headers_install_all", it must be able to run without the tree having to be configured first.

Cc David Woodhouse <[email protected]>
Cc Sam Ravnborg <[email protected]>
Cc Michal Marek <[email protected]>
---
 Documentation/kbuild/makefiles.txt |   50 +++++++++++++++++++++++-------------
 Makefile                           |    9 ++++--
 scripts/headers.sh                 |    1 +
 3 files changed, 39 insertions(+), 21 deletions(-)
Documentation/kbuild/makefiles.txt +32 -18
index f47cdef..ab0a984 100644
@@ -33,14 +33,15 @@ This document describes the Linux kernel Makefiles.
 
 	=== 6 Architecture Makefiles
 	   --- 6.1 Set variables to tweak the build to the architecture
-	   --- 6.2 Add prerequisites to archprepare:
-	   --- 6.3 List directories to visit when descending
-	   --- 6.4 Architecture-specific boot images
-	   --- 6.5 Building non-kbuild targets
-	   --- 6.6 Commands useful for building a boot image
-	   --- 6.7 Custom kbuild commands
-	   --- 6.8 Preprocessing linker scripts
-	   --- 6.9 Generic header files
+	   --- 6.2 Add prerequisites to archheaders:
+	   --- 6.3 Add prerequisites to archprepare:
+	   --- 6.4 List directories to visit when descending
+	   --- 6.5 Architecture-specific boot images
+	   --- 6.6 Building non-kbuild targets
+	   --- 6.7 Commands useful for building a boot image
+	   --- 6.8 Custom kbuild commands
+	   --- 6.9 Preprocessing linker scripts
+	   --- 6.10 Generic header files
 
 	=== 7 Kbuild syntax for exported headers
 		--- 7.1 header-y
@@ -252,7 +253,7 @@ more details, with real examples.
 	This will create a library lib.a based on delay.o. For kbuild to
 	actually recognize that there is a lib.a being built, the directory
 	shall be listed in libs-y.
-	See also "6.3 List directories to visit when descending".
+	See also "6.4 List directories to visit when descending".
 
 	Use of lib-y is normally restricted to lib/ and arch/*/lib.
 
@@ -974,7 +975,20 @@ When kbuild executes, the following steps are followed (roughly):
 	$(KBUILD_ARFLAGS) set by the top level Makefile to "D" (deterministic
 	mode) if this option is supported by $(AR).
 
---- 6.2 Add prerequisites to archprepare:
+--- 6.2 Add prerequisites to archheaders:
+
+	The archheaders: rule is used to generate header files that
+	may be installed into user space by "make header_install" or
+	"make headers_install_all".  In order to support
+	"make headers_install_all", this target has to be able to run
+	on an unconfigured tree, or a tree configured for another
+	architecture.
+
+	It is run before "make archprepare" when run on the
+	architecture itself.
+
+
+--- 6.3 Add prerequisites to archprepare:
 
 	The archprepare: rule is used to list prerequisites that need to be
 	built before starting to descend down in the subdirectories.
@@ -990,7 +1004,7 @@ When kbuild executes, the following steps are followed (roughly):
 	generating offset header files.
 
 
---- 6.3 List directories to visit when descending
+--- 6.4 List directories to visit when descending
 
 	An arch Makefile cooperates with the top Makefile to define variables
 	which specify how to build the vmlinux file.  Note that there is no
@@ -1019,7 +1033,7 @@ When kbuild executes, the following steps are followed (roughly):
 		drivers-$(CONFIG_OPROFILE)  += arch/sparc64/oprofile/
 
 
---- 6.4 Architecture-specific boot images
+--- 6.5 Architecture-specific boot images
 
 	An arch Makefile specifies goals that take the vmlinux file, compress
 	it, wrap it in bootstrapping code, and copy the resulting files
@@ -1070,7 +1084,7 @@ When kbuild executes, the following steps are followed (roughly):
 
 	When "make" is executed without arguments, bzImage will be built.
 
---- 6.5 Building non-kbuild targets
+--- 6.6 Building non-kbuild targets
 
     extra-y
 
@@ -1090,7 +1104,7 @@ When kbuild executes, the following steps are followed (roughly):
 	shall be built, but shall not be linked as part of built-in.o.
 
 
---- 6.6 Commands useful for building a boot image
+--- 6.7 Commands useful for building a boot image
 
 	Kbuild provides a few macros that are useful when building a
 	boot image.
@@ -1112,7 +1126,7 @@ When kbuild executes, the following steps are followed (roughly):
 	always be built.
 	Assignments to $(targets) are without $(obj)/ prefix.
 	if_changed may be used in conjunction with custom commands as
-	defined in 6.7 "Custom kbuild commands".
+	defined in 6.8 "Custom kbuild commands".
 
 	Note: It is a typical mistake to forget the FORCE prerequisite.
 	Another common pitfall is that whitespace is sometimes
@@ -1171,7 +1185,7 @@ When kbuild executes, the following steps are followed (roughly):
 		$(obj)/%.dtb: $(src)/%.dts
 			$(call cmd,dtc)
 
---- 6.7 Custom kbuild commands
+--- 6.8 Custom kbuild commands
 
 	When kbuild is executing with KBUILD_VERBOSE=0, then only a shorthand
 	of a command is normally displayed.
@@ -1198,7 +1212,7 @@ When kbuild executes, the following steps are followed (roughly):
 	will be displayed with "make KBUILD_VERBOSE=0".
 
 
---- 6.8 Preprocessing linker scripts
+--- 6.9 Preprocessing linker scripts
 
 	When the vmlinux image is built, the linker script
 	arch/$(ARCH)/kernel/vmlinux.lds is used.
@@ -1228,7 +1242,7 @@ When kbuild executes, the following steps are followed (roughly):
 	The kbuild infrastructure for *lds file are used in several
 	architecture-specific files.
 
---- 6.9 Generic header files
+--- 6.10 Generic header files
 
 	The directory include/asm-generic contains the header files
 	that may be shared between individual architectures.
Makefile +6 -3
index dab8610..e5e0e07 100644
@@ -442,7 +442,7 @@ asm-generic:
 
 no-dot-config-targets := clean mrproper distclean \
 			 cscope gtags TAGS tags help %docs check% coccicheck \
-			 include/linux/version.h headers_% \
+			 include/linux/version.h headers_% archheaders \
 			 kernelversion %src-pkg
 
 config-targets := 0
@@ -979,7 +979,7 @@ prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
                    include/config/auto.conf
 	$(cmd_crmodverdir)
 
-archprepare: prepare1 scripts_basic
+archprepare: archheaders prepare1 scripts_basic
 
 prepare0: archprepare FORCE
 	$(Q)$(MAKE) $(build)=.
@@ -1046,8 +1046,11 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
 # If we do an all arch process set dst to asm-$(hdr-arch)
 hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
 
+PHONY += archheaders
+archheaders:
+
 PHONY += __headers
-__headers: include/linux/version.h scripts_basic asm-generic FORCE
+__headers: include/linux/version.h scripts_basic asm-generic archheaders FORCE
 	$(Q)$(MAKE) $(build)=scripts build_unifdef
 
 PHONY += headers_install_all
scripts/headers.sh +1 -0
index 978b42b..af1ed88 100755
@@ -7,6 +7,7 @@ set -e
 do_command()
 {
 	if [ -f ${srctree}/arch/$2/include/asm/Kbuild ]; then
+		make ARCH=$2 KBUILD_HEADERS=$1 archheaders
 		make ARCH=$2 KBUILD_HEADERS=$1 headers_$1
 	else
 		printf "Ignoring arch: %s\n" ${arch}
Signature · 1 line
1.7.6.4
#4 lore raw

Re: [PATCH 2/8] kbuild: Add support for an "archheaders" target

Dne 17.11.2011 23:37, H. Peter Anvin napsal(a):

Quoted 10 lines
Makefile +1 -1
-__headers: include/linux/version.h scripts_basic asm-generic FORCE
+__headers: include/linux/version.h scripts_basic asm-generic archheaders FORCE
 	$(Q)$(MAKE) $(build)=scripts build_unifdef
 
 PHONY += headers_install_all
scripts/headers.sh +0 -0
index 978b42b..af1ed88 100755

scripts/headers.sh set -e · line 11

Quoted 5 lines
scripts/headers.sh +1 -0
@@ -7,6 +7,7 @@ set -e
 do_command()
 {
 	if [ -f ${srctree}/arch/$2/include/asm/Kbuild ]; then
+		make ARCH=$2 KBUILD_HEADERS=$1 archheaders
 		make ARCH=$2 KBUILD_HEADERS=$1 headers_$1

I don't think we need the explicit make archheaders call here, it's handled by the __headers dependency above.

Michal

#5 lore raw

Re: [PATCH 2/8] kbuild: Add support for an "archheaders" target

Quoted 8 lines · Michal Marek

scripts/headers.sh set -e · line 11

Quoted 4 lines

{

scripts/headers.sh +1 -0
 	if [ -f ${srctree}/arch/$2/include/asm/Kbuild ]; then
+		make ARCH=$2 KBUILD_HEADERS=$1 archheaders
 		make ARCH=$2 KBUILD_HEADERS=$1 headers_$1

I don't think we need the explicit make archheaders call here, it's handled by the __headers dependency above.

OK, let me test that out. I might have missed that combination of the many, many I tried...

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#6 lore raw

Re: [PATCH 2/8] kbuild: Add support for an "archheaders" target

Dne 21.11.2011 18:33, H. Peter Anvin napsal(a):

Quoted 10 lines · Michal Marek
Quoted 8 lines

scripts/headers.sh set -e · line 11

Quoted 4 lines

{

scripts/headers.sh +1 -0
 	if [ -f ${srctree}/arch/$2/include/asm/Kbuild ]; then
+		make ARCH=$2 KBUILD_HEADERS=$1 archheaders
 		make ARCH=$2 KBUILD_HEADERS=$1 headers_$1

I don't think we need the explicit make archheaders call here, it's handled by the __headers dependency above.

Quoted 2 lines

OK, let me test that out. I might have missed that combination of the many, many I tried...

I tried make headers_install_all on a ppc64 box with that line removed and it worked.

Michal

#7 lore raw

[tip:x86/syscall] kbuild, headers.sh: Don't make archheaders explicitly

In reply to Michal Marek
Commit-ID:  9147621c771c8b6a5c8985373af3a8200e8b4a41
Gitweb:     http://git.kernel.org/tip/9147621c771c8b6a5c8985373af3a8200e8b4a41
Author:     H. Peter Anvin <[email protected]>
AuthorDate: Tue, 22 Nov 2011 14:47:50 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 22 Nov 2011 14:47:50 -0800

kbuild, headers.sh: Don't make archheaders explicitly

We don't need to explicitly invoke the archheaders target because of the dependency on __headers in the Makefile.

---
 scripts/headers.sh |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
scripts/headers.sh +0 -1
index af1ed88..978b42b 100755
@@ -7,7 +7,6 @@ set -e
 do_command()
 {
 	if [ -f ${srctree}/arch/$2/include/asm/Kbuild ]; then
-		make ARCH=$2 KBUILD_HEADERS=$1 archheaders
 		make ARCH=$2 KBUILD_HEADERS=$1 headers_$1
 	else
 		printf "Ignoring arch: %s\n" ${arch}
#8 lore raw

PATCH 3/8 x86-64, syscall: Adjust comment spacing and remove typo

In reply to H. Peter Anvin

From: "H. Peter Anvin" <[email protected]>

Adjust spacing for comment so that it matches the multiline comment style used in the rest of the kernel, and remove word duplication.

It is not really clear what version of gcc this refers to, but the extra & doesn't cause any harm, so there is no reason to remove it.

---
 arch/x86/kernel/syscall_64.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/syscall_64.c +3 -3
index de87d60..0edfafa 100644
@@ -21,9 +21,9 @@ extern void sys_ni_syscall(void);
 
 const sys_call_ptr_t sys_call_table[__NR_syscall_max+1] = {
 	/*
-	*Smells like a like a compiler bug -- it doesn't work
-	*when the & below is removed.
-	*/
+	 * Smells like a compiler bug -- it doesn't work
+	 * when the & below is removed.
+	 */
 	[0 ... __NR_syscall_max] = &sys_ni_syscall,
 #include <asm/unistd_64.h>
 };
Signature · 1 line
1.7.6.4
#9 lore raw

[tip:x86/syscall] x86, syscall: Re-fix typo in comment

Commit-ID:  61f1e7e20874e8f11dab69b6a4bf7616badd4fe8
Gitweb:     http://git.kernel.org/tip/61f1e7e20874e8f11dab69b6a4bf7616badd4fe8
Author:     H. Peter Anvin <[email protected]>
AuthorDate: Fri, 18 Nov 2011 16:25:07 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Fri, 18 Nov 2011 16:25:07 -0800

x86, syscall: Re-fix typo in comment

Fix the same typo as was fixed in:

b7641d2c x86-64, syscall: Adjust comment spacing and remove typo

... for the new versions of this file (32-bit and IA32 compat).

---
 arch/x86/ia32/syscall_ia32.c |    2 +-
 arch/x86/kernel/syscall_32.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/ia32/syscall_ia32.c +1 -1
index d04d3db..4754ba0 100644
@@ -17,7 +17,7 @@ extern void compat_ni_syscall(void);
 
 const sys_call_ptr_t ia32_sys_call_table[__NR_ia32_syscall_max+1] = {
 	/*
-	 * Smells like a like a compiler bug -- it doesn't work
+	 * Smells like a compiler bug -- it doesn't work
 	 * when the & below is removed.
 	 */
 	[0 ... __NR_ia32_syscall_max] = &compat_ni_syscall,
arch/x86/kernel/syscall_32.c +1 -1
index b37a573..147fcd4 100644
@@ -17,7 +17,7 @@ extern asmlinkage void sys_ni_syscall(void);
 
 const sys_call_ptr_t sys_call_table[__NR_syscall_max+1] = {
 	/*
-	 * Smells like a like a compiler bug -- it doesn't work
+	 * Smells like a compiler bug -- it doesn't work
 	 * when the & below is removed.
 	 */
 	[0 ... __NR_syscall_max] = &sys_ni_syscall,
#10 lore raw

PATCH 4/8 x86-64, ia32: Move compat_ni_syscall into C and its own file

In reply to H. Peter Anvin

From: "H. Peter Anvin" <[email protected]>

Move compat_ni_syscall out of ia32entry.S and into its own .c file. Although this is a trivial function, it is not performance-critical, and this will simplify further cleanups.

---
 arch/x86/ia32/Makefile    |    1 +
 arch/x86/ia32/ia32entry.S |    3 ---
 arch/x86/ia32/nosyscall.c |    7 +++++++
 3 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 arch/x86/ia32/nosyscall.c
arch/x86/ia32/Makefile +1 -0
index 52d0ccf..eea9a1c 100644
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_IA32_EMULATION) := ia32entry.o sys_ia32.o ia32_signal.o
+obj-$(CONFIG_IA32_EMULATION) += nosyscall.o
 
 sysv-$(CONFIG_SYSVIPC) := ipc32.o
 obj-$(CONFIG_IA32_EMULATION) += $(sysv-y)
arch/x86/ia32/ia32entry.S +0 -3
index a6253ec..59538a7 100644
@@ -453,9 +453,6 @@ ia32_badsys:
 	movq $-ENOSYS,%rax
 	jmp ia32_sysret
 
-quiet_ni_syscall:
-	movq $-ENOSYS,%rax
-	ret
 	CFI_ENDPROC
 	
 	.macro PTREGSCALL label, func, arg
arch/x86/ia32/nosyscall.c new file +7 -0
new file mode 100644
index 0000000..51ecd5b
@@ -0,0 +1,7 @@
+#include <linux/kernel.h>
+#include <linux/errno.h>
+
+long compat_ni_syscall(void)
+{
+	return -ENOSYS;
+}
Signature · 1 line
1.7.6.4
#11 lore raw

PATCH 5/8 trace: Include <asm/asm-offsets.h> in trace_syscalls.c

In reply to H. Peter Anvin

From: "H. Peter Anvin" <[email protected]>

Include <asm/asm-offsets.h> into trace_syscalls.c, to allow for NR_syscalls to be automatically generated.

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/trace/trace_syscalls.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/trace/trace_syscalls.c +1 -0
index cb65454..5f35f6f 100644
@@ -6,6 +6,7 @@
 #include <linux/ftrace.h>
 #include <linux/perf_event.h>
 #include <asm/syscall.h>
+#include <asm/asm-offsets.h>
 
 #include "trace_output.h"
 #include "trace.h"
Signature · 1 line
1.7.6.4
maintainer
#12 lore raw

Re: [PATCH 5/8] trace: Include <asm/asm-offsets.h> in trace_syscalls.c

Quoted 4 lines · H. Peter Anvin

From: "H. Peter Anvin" <[email protected]>

Include <asm/asm-offsets.h> into trace_syscalls.c, to allow for NR_syscalls to be automatically generated.

Did this cause some sort of bug before? What was the issue before this patch?

-- Steve

Quoted 21 lines
Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 kernel/trace/trace_syscalls.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/trace/trace_syscalls.c +1 -0
index cb65454..5f35f6f 100644
@@ -6,6 +6,7 @@
 #include <linux/ftrace.h>
 #include <linux/perf_event.h>
 #include <asm/syscall.h>
+#include <asm/asm-offsets.h>
 
 #include "trace_output.h"
 #include "trace.h"
#13 lore raw

Re: [PATCH 5/8] trace: Include <asm/asm-offsets.h> in trace_syscalls.c

Quoted 11 lines · Steven Rostedt
Quoted 4 lines · H. Peter Anvin

From: "H. Peter Anvin" <[email protected]>

Include <asm/asm-offsets.h> into trace_syscalls.c, to allow for NR_syscalls to be automatically generated.

Did this cause some sort of bug before? What was the issue before this patch?

-- Steve

It didn't, but the subsequent patch moves NR_syscalls generation in asm-offsets*.c.

-hpa

#14 lore raw

Re: [PATCH 5/8] trace: Include <asm/asm-offsets.h> in trace_syscalls.c

In reply to Steven Rostedt
Quoted 9 lines · Steven Rostedt
Quoted 4 lines · H. Peter Anvin

From: "H. Peter Anvin" <[email protected]>

Include <asm/asm-offsets.h> into trace_syscalls.c, to allow for NR_syscalls to be automatically generated.

Did this cause some sort of bug before? What was the issue before this patch?

(Of course, there are architectures on which the syscall set isn't a dense set of numbers in the range [0, NR_syscalls), but that's another issue entirely.)

-hpa

#15 lore raw

PATCH 6/8 x86: Machine-readable syscall tables and scripts to process them

In reply to H. Peter Anvin

From: "H. Peter Anvin" <[email protected]>

Create a simple set of syscall tables and scripts to turn them into both header files (unistd_*.h) and macros for generating the system call tables.

---
 arch/x86/syscalls/Makefile       |   43 +++++
 arch/x86/syscalls/syscall_32.tbl |  357 ++++++++++++++++++++++++++++++++++++++
 arch/x86/syscalls/syscall_64.tbl |  320 ++++++++++++++++++++++++++++++++++
 arch/x86/syscalls/syscallhdr.sh  |   36 ++++
 arch/x86/syscalls/syscalltbl.sh  |   15 ++
 5 files changed, 771 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/syscalls/Makefile
 create mode 100644 arch/x86/syscalls/syscall_32.tbl
 create mode 100644 arch/x86/syscalls/syscall_64.tbl
 create mode 100644 arch/x86/syscalls/syscallhdr.sh
 create mode 100644 arch/x86/syscalls/syscalltbl.sh
arch/x86/syscalls/Makefile new file +43 -0
new file mode 100644
index 0000000..564b247
@@ -0,0 +1,43 @@
+out := $(obj)/../include/generated/asm
+
+# Create output directory if not already present
+_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
+
+syscall32 := $(srctree)/$(src)/syscall_32.tbl
+syscall64 := $(srctree)/$(src)/syscall_64.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))
+quiet_cmd_systbl = SYSTBL  $@
+      cmd_systbl = $(CONFIG_SHELL) '$(systbl)' $< $@
+
+syshdr_abi_unistd_32 := i386
+$(out)/unistd_32.h: $(syscall32) $(syshdr)
+	$(call if_changed,syshdr)
+
+syshdr_abi_unistd_32_ia32 := i386
+syshdr_pfx_unistd_32_ia32 := ia32_
+$(out)/unistd_32_ia32.h: $(syscall32) $(syshdr)
+	$(call if_changed,syshdr)
+
+syshdr_abi_unistd_64 := 64
+$(out)/unistd_64.h: $(syscall64) $(syshdr)
+	$(call if_changed,syshdr)
+
+$(out)/syscalls_32.h: $(syscall32) $(systbl)
+	$(call if_changed,systbl)
+$(out)/syscalls_64.h: $(syscall64) $(systbl)
+	$(call if_changed,systbl)
+
+syshdr-y			+= unistd_32.h unistd_64.h
+syshdr-y			+= syscalls_32.h
+syshdr-$(CONFIG_X86_64)		+= unistd_32_ia32.h
+syshdr-$(CONFIG_X86_64)		+= syscalls_64.h
+
+targets	+= $(syshdr-y)
+
+all: $(addprefix $(out)/,$(targets))
arch/x86/syscalls/syscall_32.tbl new file +357 -0

357 lines not on this page · raw message

arch/x86/syscalls/syscall_64.tbl new file +320 -0

320 lines not on this page · raw message

arch/x86/syscalls/syscallhdr.sh new file +36 -0
new file mode 100644
index 0000000..0d473ff
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+in="$1"
+out="$2"
+my_abis=`echo "$3" | tr ',' ' '`
+prefix="$4"
+offset="$5"
+
+fileguard=_ASM_X86_`basename "$out" | sed \
+    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
+    -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'`
+
+in_list () {
+    local x
+    for x in $1; do
+	if [ x"$x" = x"$2" ]; then
+	    return 0
+	fi
+    done
+    return 1
+}
+
+grep '^[0-9]' "$in" | sort -n | (
+    echo "#ifndef ${fileguard}"
+    echo "#define ${fileguard} 1"
+    echo ""
+
+    while read nr abi name entry ; do
+	if in_list "$my_abis" "$abi"; then
+	    echo "#define __NR_${prefix}${name}" $((nr+offset))
+        fi
+    done
+
+    echo ""
+    echo "#endif /* ${fileguard} */"
+) > "$out"
arch/x86/syscalls/syscalltbl.sh new file +15 -0
new file mode 100644
index 0000000..0e7f8ec
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+in="$1"
+out="$2"
+
+grep '^[0-9]' "$in" | sort -n | (
+    while read nr abi name entry compat; do
+	abi=`echo "$abi" | tr '[a-z]' '[A-Z]'`
+	if [ -n "$compat" ]; then
+	    echo "__SYSCALL_${abi}($nr, $entry, $compat)"
+	elif [ -n "$entry" ]; then
+	    echo "__SYSCALL_${abi}($nr, $entry, $entry)"
+	fi
+    done
+) > "$out"
Signature · 1 line
1.7.6.4
#16 lore raw

Re: [PATCH 6/8] x86: Machine-readable syscall tables and scripts to process them

On Thu, Nov 17, 2011 at 02:37:24PM -0800, H. Peter Anvin wrote:

<snip>

arch/x86/syscalls/syscallhdr.sh line 5

Quoted 11 lines
arch/x86/syscalls/syscallhdr.sh new file +5 -0
new file mode 100644
index 0000000..0d473ff
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+in="$1"
+out="$2"
+my_abis=`echo "$3" | tr ',' ' '`

I think you can remove in_list() and just use grep to get your selected abis:

my_abis=echo "($3)" | tr ',' '|'

Quoted 8 lines
arch/x86/syscalls/syscallhdr.sh new file +8 -0
+prefix="$4"
+offset="$5"
+
+fileguard=_ASM_X86_`basename "$out" | sed \
+    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
+    -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'`
+
+in_list () {

arch/x86/syscalls/syscallhdr.sh line 23

Quoted 10 lines
arch/x86/syscalls/syscallhdr.sh new file +10 -0
+    local x
+    for x in $1; do
+	if [ x"$x" = x"$2" ]; then
+	    return 0
+	fi
+    done
+    return 1
+}
+
+grep '^[0-9]' "$in" | sort -n | (

grep "^[0-9]$my_abis" "$in" | sort -n | (

arch/x86/syscalls/syscallhdr.sh line 31

Quoted 8 lines
arch/x86/syscalls/syscallhdr.sh new file +8 -0
+    echo "#ifndef ${fileguard}"
+    echo "#define ${fileguard} 1"
+    echo ""
+
+    while read nr abi name entry ; do
+	if in_list "$my_abis" "$abi"; then
+	    echo "#define __NR_${prefix}${name}" $((nr+offset))
+        fi

nanoscale nit: whitespace

arch/x86/syscalls/syscallhdr.sh line 32

Quoted 1 line
arch/x86/syscalls/syscallhdr.sh new file +1 -0
+    done

And finally this becomes:

while read nr abi name entry ; do

    echo "#define __NR_${prefix}${name}" $((nr+offset))

done

#17 lore raw

Re: [PATCH 6/8] x86: Machine-readable syscall tables and scripts to process them

Quoted 1 line · Matt Helsley

grep "^[0-9]$my_abis" "$in" | sort -n | (

You mean:

grep -E "^[0-9xX]+[[:space:]]+$my_abis" ...

... I presume?

-hpa

#18 lore raw

[tip:x86/syscall] x86: Simplify syscallhdr.sh

In reply to Matt Helsley
Commit-ID:  f14525f9e033f344996905744f41680ea2b877ce
Gitweb:     http://git.kernel.org/tip/f14525f9e033f344996905744f41680ea2b877ce
Author:     H. Peter Anvin <[email protected]>
AuthorDate: Fri, 18 Nov 2011 16:03:27 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Fri, 18 Nov 2011 16:03:27 -0800

x86: Simplify syscallhdr.sh

Simplify syscallhdr.sh by letting grep sort out the ABIs that we want, rather than relying on manual list matching. This is safe since the ABI strings already have to consist only of characters which are valid in C macro names.

---
 arch/x86/syscalls/syscallhdr.sh |   19 +++----------------
 1 files changed, 3 insertions(+), 16 deletions(-)
arch/x86/syscalls/syscallhdr.sh +3 -16
index 0d473ff..b3c5930 100644
@@ -2,33 +2,20 @@
 
 in="$1"
 out="$2"
-my_abis=`echo "$3" | tr ',' ' '`
+my_abis=`echo "($3)" | tr ',' '|'`
 prefix="$4"
 offset="$5"
 
 fileguard=_ASM_X86_`basename "$out" | sed \
     -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
     -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'`
-
-in_list () {
-    local x
-    for x in $1; do
-	if [ x"$x" = x"$2" ]; then
-	    return 0
-	fi
-    done
-    return 1
-}
-
-grep '^[0-9]' "$in" | sort -n | (
+grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
     echo "#ifndef ${fileguard}"
     echo "#define ${fileguard} 1"
     echo ""
 
     while read nr abi name entry ; do
-	if in_list "$my_abis" "$abi"; then
-	    echo "#define __NR_${prefix}${name}" $((nr+offset))
-        fi
+	echo "#define __NR_${prefix}${name}" $((nr+offset))
     done
 
     echo ""
#19 lore raw

[tip:x86/syscall] x86, syscall: Allow syscall offset to be symbolic

In reply to H. Peter Anvin
Commit-ID:  3f86886c72fb68088162c7e08cc7f85282f1860c
Gitweb:     http://git.kernel.org/tip/3f86886c72fb68088162c7e08cc7f85282f1860c
Author:     H. Peter Anvin <[email protected]>
AuthorDate: Fri, 18 Nov 2011 17:01:19 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Fri, 18 Nov 2011 17:01:19 -0800

x86, syscall: Allow syscall offset to be symbolic

Allow the specified syscall offset to be symbolic, e.g. a macro. For offset system calls, this if nothing else makes the generated code easier to read.

---
 arch/x86/syscalls/syscallhdr.sh |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
arch/x86/syscalls/syscallhdr.sh +5 -1
index b3c5930..31fd5f1 100644
@@ -15,7 +15,11 @@ grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | (
     echo ""
 
     while read nr abi name entry ; do
-	echo "#define __NR_${prefix}${name}" $((nr+offset))
+	if [ -z "$offset" ]; then
+	    echo "#define __NR_${prefix}${name} $nr"
+	else
+	    echo "#define __NR_${prefix}${name} ($offset + $nr)"
+        fi
     done
 
     echo ""
#20 lore raw

PATCH 7/8 checksyscalls: Use arch/x86/syscalls/syscall_32.tbl as source

In reply to H. Peter Anvin

From: "H. Peter Anvin" <[email protected]>

Use the new arch/x86/syscalls/syscall_32.tbl file as source instead of arch/x86/include/asm/unistd_32.h.

Cc Michal Marek <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Sam Ravnborg <[email protected]>
---
 scripts/checksyscalls.sh |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
scripts/checksyscalls.sh +10 -5
index 3ab316e..d24810f 100755
@@ -198,11 +198,16 @@ EOF
 }
 
 syscall_list() {
-sed -n -e '/^\#define/ s/[^_]*__NR_\([^[:space:]]*\).*/\
-\#if !defined \(__NR_\1\) \&\& !defined \(__IGNORE_\1\)\
-\#warning syscall \1 not implemented\
-\#endif/p' $1
+    grep '^[0-9]' "$1" | sort -n | (
+	while read nr abi name entry ; do
+	    echo <<EOF
+#if !defined(__NR_${name}) && !defined(__IGNORE_${name})
+#warning syscall ${name} not implemented
+#endif
+EOF
+	done
+    )
 }
 
-(ignore_list && syscall_list $(dirname $0)/../arch/x86/include/asm/unistd_32.h) | \
+(ignore_list && syscall_list $(dirname $0)/../arch/x86/syscalls/syscall_32.tbl) | \
 $* -E -x c - > /dev/null
Signature · 1 line
1.7.6.4
Acked-by on v1 7/8
#21 lore raw

Re: [PATCH 7/8] checksyscalls: Use arch/x86/syscalls/syscall_32.tbl as source

Dne 17.11.2011 23:37, H. Peter Anvin napsal(a):

Quoted 9 lines

From: "H. Peter Anvin" <[email protected]>

Use the new arch/x86/syscalls/syscall_32.tbl file as source instead of arch/x86/include/asm/unistd_32.h.

Cc Michal Marek <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Sam Ravnborg <[email protected]>
#22 lore raw

PATCH 8/8 x86: Generate system call tables and unistd_*.h from tables

In reply to H. Peter Anvin

From: "H. Peter Anvin" <[email protected]>

Generate system call tables and unistd_*.h automatically from the tables in arch/x86/syscalls. All other information, like NR_syscalls, is auto-generated, some of which is in asm-offsets_*.c.

This allows us to keep all the system call information in one place, and allows for kernel space and user space to see different information; this is currently used for the ia32 system call numbers when building the 64-bit kernel, but will be used by the x32 ABI in the near future.

This also removes some gratuitious differences between i386, x86-64 and ia32; in particular, now all system call tables are generated with the same mechanism.

Cc H. J. Lu <[email protected]>
Cc Sam Ravnborg <[email protected]>
Cc Michal Marek <[email protected]>
---
 arch/x86/Makefile                  |    6 +
 arch/x86/ia32/Makefile             |    2 +-
 arch/x86/ia32/ia32entry.S          |  356 -----------------
 arch/x86/ia32/syscall_ia32.c       |   25 ++
 arch/x86/include/asm/Kbuild        |    5 +-
 arch/x86/include/asm/ia32_unistd.h |   13 +-
 arch/x86/include/asm/unistd.h      |   54 +++-
 arch/x86/include/asm/unistd_32.h   |  401 --------------------
 arch/x86/include/asm/unistd_64.h   |  732 ------------------------------------
 arch/x86/kernel/Makefile           |    3 +-
 arch/x86/kernel/asm-offsets_32.c   |    8 +
 arch/x86/kernel/asm-offsets_64.c   |   19 +-
 arch/x86/kernel/entry_32.S         |   37 +--
 arch/x86/kernel/syscall_32.c       |   25 ++
 arch/x86/kernel/syscall_64.c       |   14 +-
 arch/x86/kernel/syscall_table_32.S |  350 -----------------
 16 files changed, 154 insertions(+), 1896 deletions(-)
 create mode 100644 arch/x86/ia32/syscall_ia32.c
 delete mode 100644 arch/x86/include/asm/unistd_32.h
 delete mode 100644 arch/x86/include/asm/unistd_64.h
 create mode 100644 arch/x86/kernel/syscall_32.c
 delete mode 100644 arch/x86/kernel/syscall_table_32.S
arch/x86/Makefile +6 -0
index b02e509..209ba12 100644
@@ -118,6 +118,12 @@ KBUILD_CFLAGS += $(mflags-y)
 KBUILD_AFLAGS += $(mflags-y)
 
 ###
+# Syscall table generation
+
+archheaders:
+	$(Q)$(MAKE) $(build)=arch/x86/syscalls all
+
+###
 # Kernel objects
 
 head-y := arch/x86/kernel/head_$(BITS).o
arch/x86/ia32/Makefile +1 -1
index eea9a1c..455646e 100644
@@ -3,7 +3,7 @@
 #
 
 obj-$(CONFIG_IA32_EMULATION) := ia32entry.o sys_ia32.o ia32_signal.o
-obj-$(CONFIG_IA32_EMULATION) += nosyscall.o
+obj-$(CONFIG_IA32_EMULATION) += nosyscall.o syscall_ia32.o
 
 sysv-$(CONFIG_SYSVIPC) := ipc32.o
 obj-$(CONFIG_IA32_EMULATION) += $(sysv-y)
arch/x86/ia32/ia32entry.S +0 -356

365 lines not on this page · raw message

arch/x86/ia32/syscall_ia32.c new file +25 -0
new file mode 100644
index 0000000..d04d3db
@@ -0,0 +1,25 @@
+/* System call table for ia32 emulation. */
+
+#include <linux/linkage.h>
+#include <linux/sys.h>
+#include <linux/cache.h>
+#include <asm/asm-offsets.h>
+
+#define __SYSCALL_I386(nr, sym, compat) extern asmlinkage void compat(void) ;
+#include <asm/syscalls_32.h>
+#undef __SYSCALL_I386
+
+#define __SYSCALL_I386(nr, sym, compat) [nr] = compat,
+
+typedef void (*sys_call_ptr_t)(void);
+
+extern void compat_ni_syscall(void);
+
+const sys_call_ptr_t ia32_sys_call_table[__NR_ia32_syscall_max+1] = {
+	/*
+	 * Smells like a like a compiler bug -- it doesn't work
+	 * when the & below is removed.
+	 */
+	[0 ... __NR_ia32_syscall_max] = &compat_ni_syscall,
+#include <asm/syscalls_32.h>
+};
arch/x86/include/asm/Kbuild +3 -2
index 6fa90a8..b57e6a4 100644
@@ -19,7 +19,8 @@ header-y += processor-flags.h
 header-y += ptrace-abi.h
 header-y += sigcontext32.h
 header-y += ucontext.h
-header-y += unistd_32.h
-header-y += unistd_64.h
 header-y += vm86.h
 header-y += vsyscall.h
+
+genhdr-y += unistd_32.h
+genhdr-y += unistd_64.h
arch/x86/include/asm/ia32_unistd.h +3 -10
index 976f6ec..b0d5716 100644
@@ -2,17 +2,10 @@
 #define _ASM_X86_IA32_UNISTD_H
 
 /*
- * This file contains the system call numbers of the ia32 port,
+ * This file contains the system call numbers of the ia32 compat ABI,
  * this is for the kernel only.
- * Only add syscalls here where some part of the kernel needs to know
- * the number. This should be otherwise in sync with asm-x86/unistd_32.h. -AK
  */
-
-#define __NR_ia32_restart_syscall 0
-#define __NR_ia32_exit		  1
-#define __NR_ia32_read		  3
-#define __NR_ia32_write		  4
-#define __NR_ia32_sigreturn	119
-#define __NR_ia32_rt_sigreturn	173
+#define __SYSCALL_ia32_NR(x) (x)
+#include <asm/unistd_32_ia32.h>
 
 #endif /* _ASM_X86_IA32_UNISTD_H */
arch/x86/include/asm/unistd.h +50 -4

63 lines not on this page · raw message

arch/x86/include/asm/unistd_32.h deleted +0 -401

401 lines not on this page · raw message

arch/x86/include/asm/unistd_64.h deleted +0 -732

732 lines not on this page · raw message

arch/x86/kernel/Makefile +2 -1
index 8baca3c..8c473d9 100644
@@ -25,7 +25,8 @@ obj-$(CONFIG_IRQ_WORK)  += irq_work.o
 obj-y			+= probe_roms.o
 obj-$(CONFIG_X86_32)	+= sys_i386_32.o i386_ksyms_32.o
 obj-$(CONFIG_X86_64)	+= sys_x86_64.o x8664_ksyms_64.o
-obj-$(CONFIG_X86_64)	+= syscall_64.o vsyscall_64.o
+obj-y			+= syscall_$(BITS).o
+obj-$(CONFIG_X86_64)	+= vsyscall_64.o
 obj-$(CONFIG_X86_64)	+= vsyscall_emu_64.o
 obj-y			+= bootflag.o e820.o
 obj-y			+= pci-dma.o quirks.o topology.o kdebugfs.o
arch/x86/kernel/asm-offsets_32.c +8 -0
index 395a10e..85d98ab 100644
@@ -3,6 +3,11 @@
 #include <linux/lguest.h>
 #include "../../../drivers/lguest/lg.h"
 
+#define __SYSCALL_I386(nr, sym, compat) [nr] = 1,
+static char syscalls[] = {
+#include <asm/syscalls_32.h>
+};
+
 /* workaround for a warning with -Wmissing-prototypes */
 void foo(void);
 
@@ -76,4 +81,7 @@ void foo(void)
 	OFFSET(LGUEST_PAGES_regs_errcode, lguest_pages, regs.errcode);
 	OFFSET(LGUEST_PAGES_regs, lguest_pages, regs);
 #endif
+	BLANK();
+	DEFINE(__NR_syscall_max, sizeof(syscalls) - 1);
+	DEFINE(NR_syscalls, sizeof(syscalls));
 }
arch/x86/kernel/asm-offsets_64.c +12 -7
index e72a119..834e897 100644
@@ -1,11 +1,12 @@
 #include <asm/ia32.h>
 
-#define __NO_STUBS 1
-#undef __SYSCALL
-#undef _ASM_X86_UNISTD_64_H
-#define __SYSCALL(nr, sym) [nr] = 1,
-static char syscalls[] = {
-#include <asm/unistd.h>
+#define __SYSCALL_64(nr, sym, compat) [nr] = 1,
+static char syscalls_64[] = {
+#include <asm/syscalls_64.h>
+};
+#define __SYSCALL_I386(nr, sym, compat) [nr] = 1,
+static char syscalls_ia32[] = {
+#include <asm/syscalls_32.h>
 };
 
 int main(void)
@@ -72,7 +73,11 @@ int main(void)
 	OFFSET(TSS_ist, tss_struct, x86_tss.ist);
 	BLANK();
 
-	DEFINE(__NR_syscall_max, sizeof(syscalls) - 1);
+	DEFINE(__NR_syscall_max, sizeof(syscalls_64) - 1);
+	DEFINE(NR_syscalls, sizeof(syscalls_64));
+
+	DEFINE(__NR_ia32_syscall_max, sizeof(syscalls_ia32) - 1);
+	DEFINE(IA32_NR_syscalls, sizeof(syscalls_ia32));
 
 	return 0;
 }
arch/x86/kernel/entry_32.S +14 -23
index f3f6f53..1ffcda2 100644
@@ -81,8 +81,6 @@
  * enough to patch inline, increasing performance.
  */
 
-#define nr_syscalls ((syscall_table_size)/4)
-
 #ifdef CONFIG_PREEMPT
 #define preempt_stop(clobbers)	DISABLE_INTERRUPTS(clobbers); TRACE_IRQS_OFF
 #else
@@ -423,7 +421,7 @@ sysenter_past_esp:
 	testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
 	jnz sysenter_audit
 sysenter_do_call:
-	cmpl $(nr_syscalls), %eax
+	cmpl $(NR_syscalls), %eax
 	jae syscall_badsys
 	call *sys_call_table(,%eax,4)
 	movl %eax,PT_EAX(%esp)
@@ -504,7 +502,7 @@ ENTRY(system_call)
 					# system call tracing in operation / emulation
 	testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
 	jnz syscall_trace_entry
-	cmpl $(nr_syscalls), %eax
+	cmpl $(NR_syscalls), %eax
 	jae syscall_badsys
 syscall_call:
 	call *sys_call_table(,%eax,4)
@@ -650,7 +648,7 @@ syscall_trace_entry:
 	movl %esp, %eax
 	call syscall_trace_enter
 	/* What it returned is what we'll actually use.  */
-	cmpl $(nr_syscalls), %eax
+	cmpl $(NR_syscalls), %eax
 	jnae syscall_call
 	jmp syscall_exit
 END(syscall_trace_entry)
@@ -690,29 +688,28 @@ END(syscall_badsys)
  * System calls that need a pt_regs pointer.
  */
 #define PTREGSCALL0(name) \
-	ALIGN; \
-ptregs_##name: \
+ENTRY(ptregs_##name) ;  \
 	leal 4(%esp),%eax; \
-	jmp sys_##name;
+	jmp sys_##name; \
+ENDPROC(ptregs_##name)
 
 #define PTREGSCALL1(name) \
-	ALIGN; \
-ptregs_##name: \
+ENTRY(ptregs_##name) ; \
 	leal 4(%esp),%edx; \
 	movl (PT_EBX+4)(%esp),%eax; \
-	jmp sys_##name;
+	jmp sys_##name; \
+ENDPROC(ptregs_##name)
 
 #define PTREGSCALL2(name) \
-	ALIGN; \
-ptregs_##name: \
+ENTRY(ptregs_##name) ; \
 	leal 4(%esp),%ecx; \
 	movl (PT_ECX+4)(%esp),%edx; \
 	movl (PT_EBX+4)(%esp),%eax; \
-	jmp sys_##name;
+	jmp sys_##name; \
+ENDPROC(ptregs_##name)
 
 #define PTREGSCALL3(name) \
-	ALIGN; \
-ptregs_##name: \
+ENTRY(ptregs_##name) ; \
 	CFI_STARTPROC; \
 	leal 4(%esp),%eax; \
 	pushl_cfi %eax; \
@@ -737,8 +734,7 @@ PTREGSCALL2(vm86)
 PTREGSCALL1(vm86old)
 
 /* Clone is an oddball.  The 4th arg is in %edi */
-	ALIGN;
-ptregs_clone:
+ENTRY(ptregs_clone)
 	CFI_STARTPROC
 	leal 4(%esp),%eax
 	pushl_cfi %eax
@@ -1209,11 +1205,6 @@ return_to_handler:
 	jmp *%ecx
 #endif
 
-.section .rodata,"a"
-#include "syscall_table_32.S"
-
-syscall_table_size=(.-sys_call_table)
-
 /*
  * Some functions should be protected against kprobes
  */
arch/x86/kernel/syscall_32.c new file +25 -0
new file mode 100644
index 0000000..b37a573
@@ -0,0 +1,25 @@
+/* System call table for i386. */
+
+#include <linux/linkage.h>
+#include <linux/sys.h>
+#include <linux/cache.h>
+#include <asm/asm-offsets.h>
+
+#define __SYSCALL_I386(nr, sym, compat) extern asmlinkage void sym(void) ;
+#include <asm/syscalls_32.h>
+#undef __SYSCALL_I386
+
+#define __SYSCALL_I386(nr, sym, compat) [nr] = sym,
+
+typedef asmlinkage void (*sys_call_ptr_t)(void);
+
+extern asmlinkage void sys_ni_syscall(void);
+
+const sys_call_ptr_t sys_call_table[__NR_syscall_max+1] = {
+	/*
+	 * Smells like a like a compiler bug -- it doesn't work
+	 * when the & below is removed.
+	 */
+	[0 ... __NR_syscall_max] = &sys_ni_syscall,
+#include <asm/syscalls_32.h>
+};
arch/x86/kernel/syscall_64.c +5 -9
index 0edfafa..7ac7943 100644
@@ -5,15 +5,11 @@
 #include <linux/cache.h>
 #include <asm/asm-offsets.h>
 
-#define __NO_STUBS
+#define __SYSCALL_64(nr, sym, compat) extern asmlinkage void sym(void) ;
+#include <asm/syscalls_64.h>
+#undef __SYSCALL_64
 
-#define __SYSCALL(nr, sym) extern asmlinkage void sym(void) ;
-#undef _ASM_X86_UNISTD_64_H
-#include <asm/unistd_64.h>
-
-#undef __SYSCALL
-#define __SYSCALL(nr, sym) [nr] = sym,
-#undef _ASM_X86_UNISTD_64_H
+#define __SYSCALL_64(nr, sym, compat) [nr] = sym,
 
 typedef void (*sys_call_ptr_t)(void);
 
@@ -25,5 +21,5 @@ const sys_call_ptr_t sys_call_table[__NR_syscall_max+1] = {
 	 * when the & below is removed.
 	 */
 	[0 ... __NR_syscall_max] = &sys_ni_syscall,
-#include <asm/unistd_64.h>
+#include <asm/syscalls_64.h>
 };
arch/x86/kernel/syscall_table_32.S deleted +0 -350

350 lines not on this page · raw message

Signature · 1 line
1.7.6.4