Skip to contentSkip to conversation

Generating unistd_*.h

DISCUSSION H. Peter Anvin 3 participants 9 messages Aug 27, 2011 – Nov 4, 2011

Subsystems (3)
lore
Share & tools
lore

H. Peter Anvin

author reviewer
#0 lore raw

I am working on a patchset after which unistd_*.h in the x86 tree will be autogenerated by scripts. This is a substantial cleanup and a preparation for the x32 setup.

However, one consequence of this is that <asm/unistd.h> will now include a number of autogenerated fragments, some of which will be needed by "make headers-install". Furthermore, since <asm/asm-offsets.h> depends on <asm/unistd.h> this creates a new dependency which I'm not sure what the best way to handle is from a kbuild perspective.

1. Is there a better place than others to put these generated files (i.e. other than $(obj)/arch/x86/include/asm)?

2. Is there a better place than others to put the rules for generate these files?

3. There needs to be an arch-specific way to encode the dependency before asm-offsets.h is generated. Preferences here?

-hpa

#1 lore raw
Quoted 4 lines · H. Peter Anvin

I am working on a patchset after which unistd_*.h in the x86 tree will be autogenerated by scripts. This is a substantial cleanup and a preparation for the x32 setup.

Quoted 8 lines

However, one consequence of this is that <asm/unistd.h> will now include a number of autogenerated fragments, some of which will be needed by "make headers-install". Furthermore, since <asm/asm-offsets.h> depends on <asm/unistd.h> this creates a new dependency which I'm not sure what the best way to handle is from a kbuild perspective.

1. Is there a better place than others to put these generated files (i.e. other than $(obj)/arch/x86/include/asm)?

$(obj)/arch/x86/include/generated

This is what generic-y supports uses.

Quoted 6 lines

2. Is there a better place than others to put the rules for generate these files?

3. There needs to be an arch-specific way to encode the dependency before asm-offsets.h is generated. Preferences here?

Use "archprepare".

Something like this in arch/x86/Makefile:

archprepare: arch/x86/tools/syscall-magic.sh

	$(CONFIG_SHELL) $<

It should IIRC be execute before we try to create asm-offsets.h. So there is no dependency issues.

Sam

author reviewer
#2 lore raw
Quoted 16 lines · Sam Ravnborg
Quoted 3 lines

1. Is there a better place than others to put these generated files (i.e. other than $(obj)/arch/x86/include/asm)?

$(obj)/arch/x86/include/generated

This is what generic-y supports uses.

Quoted 6 lines

2. Is there a better place than others to put the rules for generate these files?

3. There needs to be an arch-specific way to encode the dependency before asm-offsets.h is generated. Preferences here?

Use "archprepare".

Quoted 8 lines

Something like this in arch/x86/Makefile:

archprepare: arch/x86/tools/syscall-magic.sh

	$(CONFIG_SHELL) $<

It should IIRC be execute before we try to create asm-offsets.h. So there is no dependency issues.

I'll try this and see how it works out. Sounds quite clean.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
author reviewer
#3 lore raw
Quoted 8 lines · H. Peter Anvin
Quoted 7 lines · Sam Ravnborg
Quoted 3 lines

1. Is there a better place than others to put these generated files (i.e. other than $(obj)/arch/x86/include/asm)?

$(obj)/arch/x86/include/generated

This is what generic-y supports uses.

OK, got things mostly working, but I'm a bit stuck on how to make headers-install do the right thing. objhdr-y doesn't seem to deal with the generated subdirectory very well, and we don't really want the files *installed* into the generated subdirectory for user space.

Any suggestions for how to best handle it?

-hpa

author reviewer
#4 lore raw
Quoted 10 lines · H. Peter Anvin
Quoted 8 lines · H. Peter Anvin
Quoted 7 lines · Sam Ravnborg
Quoted 3 lines

1. Is there a better place than others to put these generated files (i.e. other than $(obj)/arch/x86/include/asm)?

$(obj)/arch/x86/include/generated

This is what generic-y supports uses.

Quoted 7 lines

OK, got things mostly working, but I'm a bit stuck on how to make headers-install do the right thing. objhdr-y doesn't seem to deal with the generated subdirectory very well, and we don't really want the files *installed* into the generated subdirectory for user space.

Any suggestions for how to best handle it?

For reference, putting the following in arch/x86/include/asm/Kbuild does *not* work, because $(objtree)/arch/x86/include/asm doesn't exist, and so Kbuild generates an invalid path:

objhdr-y += ../generated/asm/unistd_32.h
objhdr-y += ../generated/asm/unistd_64.h

-hpa

author reviewer
#5 lore raw

[Cc: dwmw2]

Quoted 19 lines · H. Peter Anvin
Quoted 10 lines · H. Peter Anvin
Quoted 8 lines · H. Peter Anvin
Quoted 7 lines · Sam Ravnborg
Quoted 3 lines

1. Is there a better place than others to put these generated files (i.e. other than $(obj)/arch/x86/include/asm)?

$(obj)/arch/x86/include/generated

This is what generic-y supports uses.

Quoted 7 lines

OK, got things mostly working, but I'm a bit stuck on how to make headers-install do the right thing. objhdr-y doesn't seem to deal with the generated subdirectory very well, and we don't really want the files *installed* into the generated subdirectory for user space.

Any suggestions for how to best handle it?

Quoted 7 lines

For reference, putting the following in arch/x86/include/asm/Kbuild does *not* work, because $(objtree)/arch/x86/include/asm doesn't exist, and so Kbuild generates an invalid path:

objhdr-y += ../generated/asm/unistd_32.h
objhdr-y += ../generated/asm/unistd_64.h

Similarly, overriding obj in the same file does not work, because scripts/Makefile.headersinst uses $(srctree)/$(obj) not $(srctree)/$(src) ... is that normal/expected?

-hpa

#6 lore raw
Quoted 16 lines · H. Peter Anvin

[Cc: dwmw2]

Quoted 13 lines · H. Peter Anvin
Quoted 7 lines · H. Peter Anvin

On 08/27/2011 04:48 AM, H. Peter Anvin wrote:
OK, got things mostly working, but I'm a bit stuck on how to make headers-install do the right thing. objhdr-y doesn't seem to deal with the generated subdirectory very well, and we don't really want the files *installed* into the generated subdirectory for user space.

Any suggestions for how to best handle it?

For reference, putting the following in arch/x86/include/asm/Kbuild does *not* work, because $(objtree)/arch/x86/include/asm doesn't exist, and so Kbuild generates an invalid path:

Quoted 6 lines
Quoted 2 lines

objhdr-y += ../generated/asm/unistd_32.h
objhdr-y += ../generated/asm/unistd_64.h

Similarly, overriding obj in the same file does not work, because scripts/Makefile.headersinst uses $(srctree)/$(obj) not $(srctree)/$(src) ... is that normal/expected?

Can you either post a patch or a link to a git tree with your current status?

Thanks,
Michal

author reviewer
#7 lore raw
Quoted 8 lines · Michal Marek
Quoted 8 lines
Quoted 7 lines

For reference, putting the following in arch/x86/include/asm/Kbuild does *not* work, because $(objtree)/arch/x86/include/asm doesn't exist, and so Kbuild generates an invalid path:

objhdr-y += ../generated/asm/unistd_32.h
objhdr-y += ../generated/asm/unistd_64.h

Quoted 7 lines
Quoted 3 lines

Similarly, overriding obj in the same file does not work, because scripts/Makefile.headersinst uses $(srctree)/$(obj) not $(srctree)/$(src) ... is that normal/expected?

Can you either post a patch or a link to a git tree with your current status?

git://git.zytor.com/users/hpa/kernel/autogen.git

Patch attached.

-hpa

From 39ef08d6464758794f0d7024f13c239ef26d46a1 Mon Sep 17 00:00:00 2001
From: "H. Peter Anvin" <[email protected]>
Date: Wed, 31 Aug 2011 09:09:33 -0700
Subject: [PATCH] x86: generate the system call table from a pattern file

Have a single source for all system call information, eliminating duplicate tables. This generates both the dispatch table and headers from a single table file.

This will also make x32 a lot easier to implement.

---
 arch/x86/Makefile                  |    8 +
 arch/x86/ia32/Makefile             |    1 +
 arch/x86/ia32/ia32entry.S          |  357 ------------------
 arch/x86/ia32/syscall_ia32.c       |   25 ++
 arch/x86/include/asm/Kbuild        |    5 +-
 arch/x86/include/asm/ia32_unistd.h |    8 +-
 arch/x86/include/asm/unistd.h      |   54 +++-
 arch/x86/include/asm/unistd_32.h   |  399 --------------------
 arch/x86/include/asm/unistd_64.h   |  729 ------------------------------------
 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 |  348 -----------------
 arch/x86/syscalls/Makefile         |   43 +++
 arch/x86/syscalls/syscall_32.tbl   |  355 ++++++++++++++++++
 arch/x86/syscalls/syscall_64.tbl   |  318 ++++++++++++++++
 arch/x86/syscalls/syscallhdr.sh    |   36 ++
 arch/x86/syscalls/syscalltbl.sh    |   15 +
 kernel/trace/trace_syscalls.c      |    1 +
 scripts/checksyscalls.sh           |   15 +-
 23 files changed, 933 insertions(+), 1890 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
 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/Makefile +8 -0
index b02e509..2757ead 100644
@@ -41,6 +41,8 @@ ifeq ($(CONFIG_X86_32),y)
 
         # temporary until string.h is fixed
         KBUILD_CFLAGS += -ffreestanding
+
+        # Create 32-bit headers
 else
         BITS := 64
         UTS_MACHINE := x86_64
@@ -118,6 +120,12 @@ KBUILD_CFLAGS += $(mflags-y)
 KBUILD_AFLAGS += $(mflags-y)
 
 ###
+# Syscall table generation
+
+archprepare:
+	$(Q)$(MAKE) $(build)=arch/x86/syscalls all
+
+###
 # Kernel objects
 
 head-y := arch/x86/kernel/head_$(BITS).o
arch/x86/ia32/Makefile +1 -0
index 52d0ccf..4f2ad1e 100644
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_IA32_EMULATION) := ia32entry.o sys_ia32.o ia32_signal.o
+obj-$(CONFIG_IA32_EMULATION) += syscall_ia32.o nosyscall.o
 
 sysv-$(CONFIG_SYSVIPC) := ipc32.o
 obj-$(CONFIG_IA32_EMULATION) += $(sysv-y)
arch/x86/ia32/ia32entry.S +0 -357

372 lines not on this page · raw message

arch/x86/ia32/syscall_ia32.c new file +25 -0
new file mode 100644
index 0000000..42263ec
@@ -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..950f99f 100644
@@ -18,8 +18,9 @@ header-y += prctl.h
 header-y += processor-flags.h
 header-y += ptrace-abi.h
 header-y += sigcontext32.h
+header-y += unistd.h
 header-y += ucontext.h
-header-y += unistd_32.h
-header-y += unistd_64.h
 header-y += vm86.h
 header-y += vsyscall.h
+
+objhdr-y += unistd_$(BITS).h
arch/x86/include/asm/ia32_unistd.h +2 -6
index 976f6ec..477bc16 100644
@@ -8,11 +8,7 @@
  * 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 -399

399 lines not on this page · raw message

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

729 lines not on this page · raw message

arch/x86/kernel/Makefile +2 -1
index 82f2912..e39fdd5 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 5c1a9197..b2c4c81 100644
@@ -80,8 +80,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
@@ -422,7 +420,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)
@@ -503,7 +501,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)
@@ -649,7 +647,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)
@@ -689,29 +687,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; \
@@ -736,8 +733,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
@@ -1213,11 +1209,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..36aa91c
@@ -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 de87d60..1d211a1 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 -348

348 lines not on this page · raw message

arch/x86/syscalls/Makefile new file +43 -0

43 lines not on this page · raw message

arch/x86/syscalls/syscall_32.tbl new file +355 -0

355 lines not on this page · raw message

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

318 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"
kernel/trace/trace_syscalls.c +1 -0
index ee7b5a0..652809f 100644
@@ -5,6 +5,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"
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
author reviewer
#8 lore raw
Quoted 17 lines · H. Peter Anvin
Quoted 8 lines · Michal Marek
Quoted 8 lines
Quoted 7 lines

For reference, putting the following in arch/x86/include/asm/Kbuild does *not* work, because $(objtree)/arch/x86/include/asm doesn't exist, and so Kbuild generates an invalid path:

objhdr-y += ../generated/asm/unistd_32.h
objhdr-y += ../generated/asm/unistd_64.h

Quoted 7 lines
Quoted 3 lines

Similarly, overriding obj in the same file does not work, because scripts/Makefile.headersinst uses $(srctree)/$(obj) not $(srctree)/$(src) ... is that normal/expected?

Can you either post a patch or a link to a git tree with your current status?

Quoted 5 lines

git://git.zytor.com/users/hpa/kernel/autogen.git

Patch attached.

-hpa

OK, trying to crawl back out of my exile into kernel.org cleanup land... this problem still remains!

-hpa