diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-03-28 17:27:00 -0400 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2008-04-09 13:33:36 -0400 |
commit | 96ded9dadde397a9e372a650534a9ffbba97194a (patch) | |
tree | 9aaa92034e87218d3ab7ba7e33fad0661899a0ad /arch/ia64 | |
parent | d167cb85150bd473a27df71e3116a9cc0008f5dd (diff) |
[IA64] fix getpid and set_tid_address fast system calls for pid namespaces
The sys_getpid() and sys_set_tid_address() behavior changed from
return current->tgid
to
struct pid *pid;
pid = current->pids[PIDTYPE_PID].pid;
return pid->numbers[pid->level].nr;
But the fast system calls on ia64 still operate the old way. Patch them
appropriately to let ia64 work with pid namespaces. Besides, this is one more
step in deprecating of pid and tgid on task_struct.
The fsys_getppid() is to be patched as well, but its logic is much
more complex now, so I will make it later.
One thing I'm not 100% sure is the trick with the IA64_UPID_SHIFT. On order
to access the pid->level's element of an array I have to perform the following
calculations
pid + sizeof(struct upid) * pid->level
The problem is that ia64 can only multiply float point registers, while all
the offsets I have in code are in rXX ones. Fortunately, the sizeof(struct
upid) is 32 bytes on ia64 (and is very unlikely to ever change), so the
calculations get simpler:
pid + pid->level << 5
So, I introduce the IA64_UPID_SHIFT and use the shl instruction. I also
looked at how gcc compiles the similar place and found that it makes it with
shift as well. Is this OK to do so?
Tested with ski emulator with 2.6.24 kernel, but fits 2.6.25-rc4 and
2.6.25-rc4-mm1 as well.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Cc: David Mosberger-Tang <davidm@hpl.hp.com>
Cc: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Amy Griffis <amy.griffis@hp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'arch/ia64')
-rw-r--r-- | arch/ia64/kernel/asm-offsets.c | 7 | ||||
-rw-r--r-- | arch/ia64/kernel/fsys.S | 34 |
2 files changed, 37 insertions, 4 deletions
diff --git a/arch/ia64/kernel/asm-offsets.c b/arch/ia64/kernel/asm-offsets.c index 0aebc6f79e95..f7bc40dee43d 100644 --- a/arch/ia64/kernel/asm-offsets.c +++ b/arch/ia64/kernel/asm-offsets.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #define ASM_OFFSETS_C 1 | 7 | #define ASM_OFFSETS_C 1 |
8 | 8 | ||
9 | #include <linux/sched.h> | 9 | #include <linux/sched.h> |
10 | #include <linux/pid.h> | ||
10 | #include <linux/clocksource.h> | 11 | #include <linux/clocksource.h> |
11 | 12 | ||
12 | #include <asm-ia64/processor.h> | 13 | #include <asm-ia64/processor.h> |
@@ -34,6 +35,9 @@ void foo(void) | |||
34 | DEFINE(SIGFRAME_SIZE, sizeof (struct sigframe)); | 35 | DEFINE(SIGFRAME_SIZE, sizeof (struct sigframe)); |
35 | DEFINE(UNW_FRAME_INFO_SIZE, sizeof (struct unw_frame_info)); | 36 | DEFINE(UNW_FRAME_INFO_SIZE, sizeof (struct unw_frame_info)); |
36 | 37 | ||
38 | BUILD_BUG_ON(sizeof(struct upid) != 32); | ||
39 | DEFINE(IA64_UPID_SHIFT, 5); | ||
40 | |||
37 | BLANK(); | 41 | BLANK(); |
38 | 42 | ||
39 | DEFINE(TI_FLAGS, offsetof(struct thread_info, flags)); | 43 | DEFINE(TI_FLAGS, offsetof(struct thread_info, flags)); |
@@ -45,6 +49,9 @@ void foo(void) | |||
45 | DEFINE(IA64_TASK_BLOCKED_OFFSET,offsetof (struct task_struct, blocked)); | 49 | DEFINE(IA64_TASK_BLOCKED_OFFSET,offsetof (struct task_struct, blocked)); |
46 | DEFINE(IA64_TASK_CLEAR_CHILD_TID_OFFSET,offsetof (struct task_struct, clear_child_tid)); | 50 | DEFINE(IA64_TASK_CLEAR_CHILD_TID_OFFSET,offsetof (struct task_struct, clear_child_tid)); |
47 | DEFINE(IA64_TASK_GROUP_LEADER_OFFSET, offsetof (struct task_struct, group_leader)); | 51 | DEFINE(IA64_TASK_GROUP_LEADER_OFFSET, offsetof (struct task_struct, group_leader)); |
52 | DEFINE(IA64_TASK_TGIDLINK_OFFSET, offsetof (struct task_struct, pids[PIDTYPE_PID].pid)); | ||
53 | DEFINE(IA64_PID_LEVEL_OFFSET, offsetof (struct pid, level)); | ||
54 | DEFINE(IA64_PID_UPID_OFFSET, offsetof (struct pid, numbers[0])); | ||
48 | DEFINE(IA64_TASK_PENDING_OFFSET,offsetof (struct task_struct, pending)); | 55 | DEFINE(IA64_TASK_PENDING_OFFSET,offsetof (struct task_struct, pending)); |
49 | DEFINE(IA64_TASK_PID_OFFSET, offsetof (struct task_struct, pid)); | 56 | DEFINE(IA64_TASK_PID_OFFSET, offsetof (struct task_struct, pid)); |
50 | DEFINE(IA64_TASK_REAL_PARENT_OFFSET, offsetof (struct task_struct, real_parent)); | 57 | DEFINE(IA64_TASK_REAL_PARENT_OFFSET, offsetof (struct task_struct, real_parent)); |
diff --git a/arch/ia64/kernel/fsys.S b/arch/ia64/kernel/fsys.S index 44841971f077..3f570e6fcd9c 100644 --- a/arch/ia64/kernel/fsys.S +++ b/arch/ia64/kernel/fsys.S | |||
@@ -61,13 +61,29 @@ ENTRY(fsys_getpid) | |||
61 | .prologue | 61 | .prologue |
62 | .altrp b6 | 62 | .altrp b6 |
63 | .body | 63 | .body |
64 | add r17=IA64_TASK_GROUP_LEADER_OFFSET,r16 | ||
65 | ;; | ||
66 | ld8 r17=[r17] // r17 = current->group_leader | ||
64 | add r9=TI_FLAGS+IA64_TASK_SIZE,r16 | 67 | add r9=TI_FLAGS+IA64_TASK_SIZE,r16 |
65 | ;; | 68 | ;; |
66 | ld4 r9=[r9] | 69 | ld4 r9=[r9] |
67 | add r8=IA64_TASK_TGID_OFFSET,r16 | 70 | add r17=IA64_TASK_TGIDLINK_OFFSET,r17 |
68 | ;; | 71 | ;; |
69 | and r9=TIF_ALLWORK_MASK,r9 | 72 | and r9=TIF_ALLWORK_MASK,r9 |
70 | ld4 r8=[r8] // r8 = current->tgid | 73 | ld8 r17=[r17] // r17 = current->group_leader->pids[PIDTYPE_PID].pid |
74 | ;; | ||
75 | add r8=IA64_PID_LEVEL_OFFSET,r17 | ||
76 | ;; | ||
77 | ld4 r8=[r8] // r8 = pid->level | ||
78 | add r17=IA64_PID_UPID_OFFSET,r17 // r17 = &pid->numbers[0] | ||
79 | ;; | ||
80 | shl r8=r8,IA64_UPID_SHIFT | ||
81 | ;; | ||
82 | add r17=r17,r8 // r17 = &pid->numbers[pid->level] | ||
83 | ;; | ||
84 | ld4 r8=[r17] // r8 = pid->numbers[pid->level].nr | ||
85 | ;; | ||
86 | mov r17=0 | ||
71 | ;; | 87 | ;; |
72 | cmp.ne p8,p0=0,r9 | 88 | cmp.ne p8,p0=0,r9 |
73 | (p8) br.spnt.many fsys_fallback_syscall | 89 | (p8) br.spnt.many fsys_fallback_syscall |
@@ -126,15 +142,25 @@ ENTRY(fsys_set_tid_address) | |||
126 | .altrp b6 | 142 | .altrp b6 |
127 | .body | 143 | .body |
128 | add r9=TI_FLAGS+IA64_TASK_SIZE,r16 | 144 | add r9=TI_FLAGS+IA64_TASK_SIZE,r16 |
145 | add r17=IA64_TASK_TGIDLINK_OFFSET,r16 | ||
129 | ;; | 146 | ;; |
130 | ld4 r9=[r9] | 147 | ld4 r9=[r9] |
131 | tnat.z p6,p7=r32 // check argument register for being NaT | 148 | tnat.z p6,p7=r32 // check argument register for being NaT |
149 | ld8 r17=[r17] // r17 = current->pids[PIDTYPE_PID].pid | ||
132 | ;; | 150 | ;; |
133 | and r9=TIF_ALLWORK_MASK,r9 | 151 | and r9=TIF_ALLWORK_MASK,r9 |
134 | add r8=IA64_TASK_PID_OFFSET,r16 | 152 | add r8=IA64_PID_LEVEL_OFFSET,r17 |
135 | add r18=IA64_TASK_CLEAR_CHILD_TID_OFFSET,r16 | 153 | add r18=IA64_TASK_CLEAR_CHILD_TID_OFFSET,r16 |
136 | ;; | 154 | ;; |
137 | ld4 r8=[r8] | 155 | ld4 r8=[r8] // r8 = pid->level |
156 | add r17=IA64_PID_UPID_OFFSET,r17 // r17 = &pid->numbers[0] | ||
157 | ;; | ||
158 | shl r8=r8,IA64_UPID_SHIFT | ||
159 | ;; | ||
160 | add r17=r17,r8 // r17 = &pid->numbers[pid->level] | ||
161 | ;; | ||
162 | ld4 r8=[r17] // r8 = pid->numbers[pid->level].nr | ||
163 | ;; | ||
138 | cmp.ne p8,p0=0,r9 | 164 | cmp.ne p8,p0=0,r9 |
139 | mov r17=-1 | 165 | mov r17=-1 |
140 | ;; | 166 | ;; |