Skip to content

Commit 92d5dd8

Browse files
Chung-Ling TangLey Foon Tan
authored andcommitted
nios2: update pt_regs
Remove struct pt_regs from user header and use generic ucontext.h. Signed-off-by: Chung-Ling Tang <cltang@codesourcery.com> Acked-by: Ley Foon Tan <lftan@altera.com>
1 parent 9eccca0 commit 92d5dd8

7 files changed

Lines changed: 62 additions & 89 deletions

File tree

‎arch/nios2/include/asm/ptrace.h‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,54 @@
1515

1616
#include <uapi/asm/ptrace.h>
1717

18+
/* This struct defines the way the registers are stored on the
19+
stack during a system call. */
20+
1821
#ifndef __ASSEMBLY__
22+
struct pt_regs {
23+
unsigned long r8; /* r8-r15 Caller-saved GP registers */
24+
unsigned long r9;
25+
unsigned long r10;
26+
unsigned long r11;
27+
unsigned long r12;
28+
unsigned long r13;
29+
unsigned long r14;
30+
unsigned long r15;
31+
unsigned long r1; /* Assembler temporary */
32+
unsigned long r2; /* Retval LS 32bits */
33+
unsigned long r3; /* Retval MS 32bits */
34+
unsigned long r4; /* r4-r7 Register arguments */
35+
unsigned long r5;
36+
unsigned long r6;
37+
unsigned long r7;
38+
unsigned long orig_r2; /* Copy of r2 ?? */
39+
unsigned long ra; /* Return address */
40+
unsigned long fp; /* Frame pointer */
41+
unsigned long sp; /* Stack pointer */
42+
unsigned long gp; /* Global pointer */
43+
unsigned long estatus;
44+
unsigned long ea; /* Exception return address (pc) */
45+
unsigned long orig_r7;
46+
};
47+
48+
/*
49+
* This is the extended stack used by signal handlers and the context
50+
* switcher: it's pushed after the normal "struct pt_regs".
51+
*/
52+
struct switch_stack {
53+
unsigned long r16; /* r16-r23 Callee-saved GP registers */
54+
unsigned long r17;
55+
unsigned long r18;
56+
unsigned long r19;
57+
unsigned long r20;
58+
unsigned long r21;
59+
unsigned long r22;
60+
unsigned long r23;
61+
unsigned long fp;
62+
unsigned long gp;
63+
unsigned long ra;
64+
};
65+
1966
#define user_mode(regs) (((regs)->estatus & ESTATUS_EU))
2067

2168
#define instruction_pointer(regs) ((regs)->ra)

‎arch/nios2/include/asm/ucontext.h‎

Lines changed: 0 additions & 32 deletions
This file was deleted.

‎arch/nios2/include/uapi/asm/Kbuild‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ include include/uapi/asm-generic/Kbuild.asm
22

33
header-y += elf.h
44
header-y += ucontext.h
5+
6+
generic-y += ucontext.h

‎arch/nios2/include/uapi/asm/elf.h‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@
5050

5151
typedef unsigned long elf_greg_t;
5252

53-
#define ELF_NGREG \
54-
((sizeof(struct pt_regs) + sizeof(struct switch_stack)) / \
55-
sizeof(elf_greg_t))
53+
#define ELF_NGREG 49
5654
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
5755

5856
typedef unsigned long elf_fpregset_t;

‎arch/nios2/include/uapi/asm/ptrace.h‎

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -67,53 +67,9 @@
6767

6868
#define NUM_PTRACE_REG (PTR_TLBMISC + 1)
6969

70-
/* this struct defines the way the registers are stored on the
71-
stack during a system call.
72-
73-
There is a fake_regs in setup.c that has to match pt_regs.*/
74-
75-
struct pt_regs {
76-
unsigned long r8; /* r8-r15 Caller-saved GP registers */
77-
unsigned long r9;
78-
unsigned long r10;
79-
unsigned long r11;
80-
unsigned long r12;
81-
unsigned long r13;
82-
unsigned long r14;
83-
unsigned long r15;
84-
unsigned long r1; /* Assembler temporary */
85-
unsigned long r2; /* Retval LS 32bits */
86-
unsigned long r3; /* Retval MS 32bits */
87-
unsigned long r4; /* r4-r7 Register arguments */
88-
unsigned long r5;
89-
unsigned long r6;
90-
unsigned long r7;
91-
unsigned long orig_r2; /* Copy of r2 ?? */
92-
unsigned long ra; /* Return address */
93-
unsigned long fp; /* Frame pointer */
94-
unsigned long sp; /* Stack pointer */
95-
unsigned long gp; /* Global pointer */
96-
unsigned long estatus;
97-
unsigned long ea; /* Exception return address (pc) */
98-
unsigned long orig_r7;
99-
};
100-
101-
/*
102-
* This is the extended stack used by signal handlers and the context
103-
* switcher: it's pushed after the normal "struct pt_regs".
104-
*/
105-
struct switch_stack {
106-
unsigned long r16; /* r16-r23 Callee-saved GP registers */
107-
unsigned long r17;
108-
unsigned long r18;
109-
unsigned long r19;
110-
unsigned long r20;
111-
unsigned long r21;
112-
unsigned long r22;
113-
unsigned long r23;
114-
unsigned long fp;
115-
unsigned long gp;
116-
unsigned long ra;
70+
/* User structures for general purpose registers. */
71+
struct user_pt_regs {
72+
__u32 regs[49];
11773
};
11874

11975
#endif /* __ASSEMBLY__ */

‎arch/nios2/include/uapi/asm/sigcontext.h‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
* details.
1616
*/
1717

18-
#ifndef _ASM_NIOS2_SIGCONTEXT_H
19-
#define _ASM_NIOS2_SIGCONTEXT_H
18+
#ifndef _UAPI__ASM_SIGCONTEXT_H
19+
#define _UAPI__ASM_SIGCONTEXT_H
2020

21-
#include <asm/ptrace.h>
21+
#include <linux/types.h>
22+
23+
#define MCONTEXT_VERSION 2
2224

2325
struct sigcontext {
24-
struct pt_regs regs;
25-
unsigned long sc_mask; /* old sigmask */
26+
int version;
27+
unsigned long gregs[32];
2628
};
2729

2830
#endif

‎arch/nios2/kernel/signal.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static inline int rt_restore_ucontext(struct pt_regs *regs,
3939
struct ucontext *uc, int *pr2)
4040
{
4141
int temp;
42-
greg_t *gregs = uc->uc_mcontext.gregs;
42+
unsigned long *gregs = uc->uc_mcontext.gregs;
4343
int err;
4444

4545
/* Always make any pending restarted system calls return -EINTR */
@@ -127,7 +127,7 @@ asmlinkage int do_rt_sigreturn(struct switch_stack *sw)
127127
static inline int rt_setup_ucontext(struct ucontext *uc, struct pt_regs *regs)
128128
{
129129
struct switch_stack *sw = (struct switch_stack *)regs - 1;
130-
greg_t *gregs = uc->uc_mcontext.gregs;
130+
unsigned long *gregs = uc->uc_mcontext.gregs;
131131
int err = 0;
132132

133133
err |= __put_user(MCONTEXT_VERSION, &uc->uc_mcontext.version);

0 commit comments

Comments
 (0)