Split host arch headers for UML's benefit
RFC PATCH 1/1 Split host arch headers for UML's benefit
The patch below fixes the recent UML compilation failure in -rc5-mm1 without making the UML build reach further into the i386 headers. It splits the i386 ptrace.h and system.h into UML-usable and UML-unusable pieces.
The string "abi" is in there because I did ptrace.h first, and that involves separating the ptrace ABI stuff from everything else (if pt_regs is not considered part of the abi). However, the system.h split is between random stuff that UML can use and random stuff that it can't. So, perhaps better names would be -uml or -userspace or something.
This isolates UML somewhat from host header changes while allowing it to reuse host stuff. Build failures like the current one would be less frequent. It also allows UML headers to be cleaned up - see the deletions from ptrace-generic.h and system-generic.h which used to rename the stuff from the host headers which UML couldn't use.
ptrace.h and system.h are the two problem cases at the moment. There are others, but not a lot. These two are the messiest ones.
Any arch which runs UML would need similar treatment - right now, that's i386, x86_64, and s390.
Jeff
include/asm-i386/ptrace-abi.h +36 -0
@@ -0,0 +1,36 @@ +#ifndef __PTRACE_ABI__ +#define __PTRACE_ABI__ + +#define EBX 0 +#define ECX 1 +#define EDX 2 +#define ESI 3 +#define EDI 4 +#define EBP 5 +#define EAX 6 +#define DS 7 +#define ES 8 +#define FS 9 +#define GS 10 +#define ORIG_EAX 11 +#define EIP 12 +#define CS 13 +#define EFL 14 +#define UESP 15 +#define SS 16 +#define FRAME_SIZE 17 + +/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */ +#define PTRACE_GETREGS 12 +#define PTRACE_SETREGS 13 +#define PTRACE_GETFPREGS 14 +#define PTRACE_SETFPREGS 15 +#define PTRACE_GETFPXREGS 18 +#define PTRACE_SETFPXREGS 19 + +#define PTRACE_OLDSETOPTIONS 21 + +#define PTRACE_GET_THREAD_AREA 25 +#define PTRACE_SET_THREAD_AREA 26 + +#endif
include/asm-i386/ptrace.h +1 -31
@@ -1,24 +1,7 @@#ifndef _I386_PTRACE_H#define _I386_PTRACE_H -#define EBX 0 -#define ECX 1 -#define EDX 2 -#define ESI 3 -#define EDI 4 -#define EBP 5 -#define EAX 6 -#define DS 7 -#define ES 8 -#define FS 9 -#define GS 10 -#define ORIG_EAX 11 -#define EIP 12 -#define CS 13 -#define EFL 14 -#define UESP 15 -#define SS 16 -#define FRAME_SIZE 17 +#include <asm/ptrace-abi.h> /* this struct defines the way the registers are stored on the stack during a system call. */
@@ -41,19 +24,6 @@int xss; }; -/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */ -#define PTRACE_GETREGS 12 -#define PTRACE_SETREGS 13 -#define PTRACE_GETFPREGS 14 -#define PTRACE_SETFPREGS 15 -#define PTRACE_GETFPXREGS 18 -#define PTRACE_SETFPXREGS 19 - -#define PTRACE_OLDSETOPTIONS 21 - -#define PTRACE_GET_THREAD_AREA 25 -#define PTRACE_SET_THREAD_AREA 26 -#ifdef __KERNEL__#include <asm/vm86.h>
include/asm-i386/system-abi.h +190 -0
190 lines not on this page · raw message
include/asm-i386/system.h +2 -185
221 lines not on this page · raw message
include/asm-um/ptrace-generic.h +1 -13
@@ -9,19 +9,7 @@#ifndef __ASSEMBLY__#include "linux/config.h" - -#define pt_regs pt_regs_subarch -#define show_regs show_regs_subarch -#define send_sigtrap send_sigtrap_subarch - -#include "asm/arch/ptrace.h" - -#undef pt_regs -#undef show_regs -#undef send_sigtrap -#undef user_mode -#undef instruction_pointer - +#include "asm/arch/ptrace-abi.h" #include "sysdep/ptrace.h" struct pt_regs {
include/asm-um/system-generic.h +1 -13
@@ -1,19 +1,7 @@#ifndef __UM_SYSTEM_GENERIC_H#define __UM_SYSTEM_GENERIC_H -#include "asm/arch/system.h" - -#undef switch_to -#undef local_irq_save -#undef local_irq_restore -#undef local_irq_disable -#undef local_irq_enable -#undef local_save_flags -#undef local_irq_restore -#undef local_irq_enable -#undef local_irq_disable -#undef local_irq_save -#undef irqs_disabled +#include "asm/arch/system-abi.h" extern void *switch_to (void *prev,void *next,void *last);
Quoted 5 lines · Jeff Dike
The patch below fixes the recent UML compilation failure in -rc5-mm1 without making the UML build reach further into the i386 headers. It splits the i386
ptrace.handsystem.hinto UML-usable and UML-unusable pieces.
Quoted 7 lines
The string "abi" is in there because I did
ptrace.hfirst, and that involves separating the ptrace ABI stuff from everything else (ifpt_regsis not considered part of the abi). However, thesystem.hsplit is between random stuff that UML can use and random stuff that it can't. So, perhaps better names would be -uml or -userspace or something.
I like this approach. In general, it seems beneficial to split these into ABI and kernel implementation. Also, this stuff eventually works its way into userspace headers. It is not really clear which asm-xxx kernel headers are valid to include in userspace. There are definitely multiple classes of things in the kernel header files : ABI definitions, user-useful macros and inlines, and things that are privately useful the kernel. The ptrace split seems quite well defined here; the system split is a little less obvious, but I don't object to the way you have done it.
I've always wondered why we didn't have memory barriers in either asm/atomic.h or asm/barrier.h; system.h seems to just have a mixed bag of goodies.
Two things about the system.h split - do you use arch_align_stack()?. Also, do you use the alternative instruction replacement functionality, or do you just need the macro? If you don't actually implement instruction replacement, it seems you could more easily redefine these to be
#define alternative(oldinstr, newinstr, feature) \
asm volatile(oldinstr) ::: "memory")
Zach
Quoted 9 lines · Zachary Amsden
I like this approach. In general, it seems beneficial to split these into ABI and kernel implementation. Also, this stuff eventually works its way into userspace headers. It is not really clear which asm-xxx kernel headers are valid to include in userspace. There are definitely multiple classes of things in the kernel header files : ABI definitions, user-useful macros and inlines, and things that are privately useful the kernel. The ptrace split seems quite well defined here; the system split is a little less obvious, but I don't object to the way you have done it.
Yeah, the ptrace split is nice and ABI-like - the system split is more of a mess.
Quoted 3 lines
I've always wondered why we didn't have memory barriers in either
asm/atomic.horasm/barrier.h;system.hseems to just have a mixed bag of goodies.
That may make sense.
Quoted 2 lines
Two things about the
system.hsplit - do you usearch_align_stack()?.
Something does, UML doesn't build without one.
Quoted 6 lines
Also, do you use the alternative instruction replacement functionality, or do you just need the macro? If you don't actually implement instruction replacement, it seems you could more easily redefine these to be
#define
alternative(oldinstr, newinstr, feature)\
asm volatile(oldinstr) ::: "memory")
Possibly, I don't knowingly use it, but given my borrowing of host arch headers, and most asm works just as well in UML as on the host, there could be some use in UML.
Jeff