xref: /openbmc/linux/arch/x86/include/asm/user_32.h (revision 0c9dceb9)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21965aae3SH. Peter Anvin #ifndef _ASM_X86_USER_32_H
31965aae3SH. Peter Anvin #define _ASM_X86_USER_32_H
4bb898558SAl Viro 
5bb898558SAl Viro #include <asm/page.h>
6bb898558SAl Viro /* Core file format: The core file is written in such a way that gdb
7bb898558SAl Viro    can understand it and provide useful information to the user (under
8bb898558SAl Viro    linux we use the 'trad-core' bfd).  There are quite a number of
9bb898558SAl Viro    obstacles to being able to view the contents of the floating point
10bb898558SAl Viro    registers, and until these are solved you will not be able to view the
11bb898558SAl Viro    contents of them.  Actually, you can read in the core file and look at
12bb898558SAl Viro    the contents of the user struct to find out what the floating point
13bb898558SAl Viro    registers contain.
14bb898558SAl Viro    The actual file contents are as follows:
15bb898558SAl Viro    UPAGE: 1 page consisting of a user struct that tells gdb what is present
16bb898558SAl Viro    in the file.  Directly after this is a copy of the task_struct, which
17bb898558SAl Viro    is currently not used by gdb, but it may come in useful at some point.
18bb898558SAl Viro    All of the registers are stored as part of the upage.  The upage should
19bb898558SAl Viro    always be only one page.
20bb898558SAl Viro    DATA: The data area is stored.  We use current->end_text to
21bb898558SAl Viro    current->brk to pick up all of the user variables, plus any memory
22bb898558SAl Viro    that may have been malloced.  No attempt is made to determine if a page
23bb898558SAl Viro    is demand-zero or if a page is totally unused, we just cover the entire
24bb898558SAl Viro    range.  All of the addresses are rounded in such a way that an integral
25bb898558SAl Viro    number of pages is written.
26bb898558SAl Viro    STACK: We need the stack information in order to get a meaningful
27bb898558SAl Viro    backtrace.  We need to write the data from (esp) to
28bb898558SAl Viro    current->start_stack, so we round each of these off in order to be able
29bb898558SAl Viro    to write an integer number of pages.
30bb898558SAl Viro    The minimum core file size is 3 pages, or 12288 bytes.
31bb898558SAl Viro */
32bb898558SAl Viro 
33bb898558SAl Viro /*
34bb898558SAl Viro  * Pentium III FXSR, SSE support
35bb898558SAl Viro  *	Gareth Hughes <gareth@valinux.com>, May 2000
36bb898558SAl Viro  *
37bb898558SAl Viro  * Provide support for the GDB 5.0+ PTRACE_{GET|SET}FPXREGS requests for
38bb898558SAl Viro  * interacting with the FXSR-format floating point environment.  Floating
39bb898558SAl Viro  * point data can be accessed in the regular format in the usual manner,
40bb898558SAl Viro  * and both the standard and SIMD floating point data can be accessed via
41bb898558SAl Viro  * the new ptrace requests.  In either case, changes to the FPU environment
42bb898558SAl Viro  * will be reflected in the task's state as expected.
43bb898558SAl Viro  */
44bb898558SAl Viro 
45bb898558SAl Viro struct user_i387_struct {
46bb898558SAl Viro 	long	cwd;
47bb898558SAl Viro 	long	swd;
48bb898558SAl Viro 	long	twd;
49bb898558SAl Viro 	long	fip;
50bb898558SAl Viro 	long	fcs;
51bb898558SAl Viro 	long	foo;
52bb898558SAl Viro 	long	fos;
53bb898558SAl Viro 	long	st_space[20];	/* 8*10 bytes for each FP-reg = 80 bytes */
54bb898558SAl Viro };
55bb898558SAl Viro 
56bb898558SAl Viro struct user_fxsr_struct {
57bb898558SAl Viro 	unsigned short	cwd;
58bb898558SAl Viro 	unsigned short	swd;
59bb898558SAl Viro 	unsigned short	twd;
60bb898558SAl Viro 	unsigned short	fop;
61bb898558SAl Viro 	long	fip;
62bb898558SAl Viro 	long	fcs;
63bb898558SAl Viro 	long	foo;
64bb898558SAl Viro 	long	fos;
65bb898558SAl Viro 	long	mxcsr;
66bb898558SAl Viro 	long	reserved;
67bb898558SAl Viro 	long	st_space[32];	/* 8*16 bytes for each FP-reg = 128 bytes */
68bb898558SAl Viro 	long	xmm_space[32];	/* 8*16 bytes for each XMM-reg = 128 bytes */
69bb898558SAl Viro 	long	padding[56];
70bb898558SAl Viro };
71bb898558SAl Viro 
72bb898558SAl Viro /*
73bb898558SAl Viro  * This is the old layout of "struct pt_regs", and
74bb898558SAl Viro  * is still the layout used by user mode (the new
75bb898558SAl Viro  * pt_regs doesn't have all registers as the kernel
76bb898558SAl Viro  * doesn't use the extra segment registers)
77bb898558SAl Viro  */
78bb898558SAl Viro struct user_regs_struct {
79bb898558SAl Viro 	unsigned long	bx;
80bb898558SAl Viro 	unsigned long	cx;
81bb898558SAl Viro 	unsigned long	dx;
82bb898558SAl Viro 	unsigned long	si;
83bb898558SAl Viro 	unsigned long	di;
84bb898558SAl Viro 	unsigned long	bp;
85bb898558SAl Viro 	unsigned long	ax;
86bb898558SAl Viro 	unsigned long	ds;
87bb898558SAl Viro 	unsigned long	es;
88bb898558SAl Viro 	unsigned long	fs;
89bb898558SAl Viro 	unsigned long	gs;
90bb898558SAl Viro 	unsigned long	orig_ax;
91bb898558SAl Viro 	unsigned long	ip;
92bb898558SAl Viro 	unsigned long	cs;
93bb898558SAl Viro 	unsigned long	flags;
94bb898558SAl Viro 	unsigned long	sp;
95bb898558SAl Viro 	unsigned long	ss;
96bb898558SAl Viro };
97bb898558SAl Viro 
98bb898558SAl Viro /* When the kernel dumps core, it starts by dumping the user struct -
99bb898558SAl Viro    this will be used by gdb to figure out where the data and stack segments
100bb898558SAl Viro    are within the file, and what virtual addresses to use. */
101bb898558SAl Viro struct user{
102bb898558SAl Viro /* We start with the registers, to mimic the way that "memory" is returned
103bb898558SAl Viro    from the ptrace(3,...) function.  */
104bb898558SAl Viro   struct user_regs_struct regs;	/* Where the registers are actually stored */
105bb898558SAl Viro /* ptrace does not yet supply these.  Someday.... */
106bb898558SAl Viro   int u_fpvalid;		/* True if math co-processor being used. */
107bb898558SAl Viro 				/* for this mess. Not yet used. */
108bb898558SAl Viro   struct user_i387_struct i387;	/* Math Co-processor registers. */
109bb898558SAl Viro /* The rest of this junk is to help gdb figure out what goes where */
110bb898558SAl Viro   unsigned long int u_tsize;	/* Text segment size (pages). */
111bb898558SAl Viro   unsigned long int u_dsize;	/* Data segment size (pages). */
112bb898558SAl Viro   unsigned long int u_ssize;	/* Stack segment size (pages). */
113bb898558SAl Viro   unsigned long start_code;     /* Starting virtual address of text. */
114bb898558SAl Viro   unsigned long start_stack;	/* Starting virtual address of stack area.
115bb898558SAl Viro 				   This is actually the bottom of the stack,
116bb898558SAl Viro 				   the top of the stack is always found in the
117bb898558SAl Viro 				   esp register.  */
118bb898558SAl Viro   long int signal;     		/* Signal that caused the core dump. */
119bb898558SAl Viro   int reserved;			/* No longer used */
120bb898558SAl Viro   unsigned long u_ar0;		/* Used by gdb to help find the values for */
121bb898558SAl Viro 				/* the registers. */
122bb898558SAl Viro   struct user_i387_struct *u_fpstate;	/* Math Co-processor pointer. */
123bb898558SAl Viro   unsigned long magic;		/* To uniquely identify a core file */
124bb898558SAl Viro   char u_comm[32];		/* User command that was responsible */
125bb898558SAl Viro   int u_debugreg[8];
126bb898558SAl Viro };
127bb898558SAl Viro 
1281965aae3SH. Peter Anvin #endif /* _ASM_X86_USER_32_H */
129