320
|
1 #define const
|
|
2
|
|
3 typedef unsigned short __u16;
|
|
4 typedef unsigned int __u32;
|
|
5
|
|
6 struct task_struct {
|
|
7 volatile long state;
|
|
8 int usage;
|
|
9 unsigned long flags;
|
|
10 unsigned long ptrace;
|
|
11 } c0;
|
|
12
|
649
|
13 register struct task_struct *current asm ("r2");
|
320
|
14 typedef struct { volatile int counter; } atomic_t;
|
|
15
|
|
16 struct thread_info {
|
|
17 struct task_struct *task;
|
|
18 /*
|
|
19 struct exec_domain *exec_domain;
|
|
20 unsigned long flags;
|
|
21 unsigned long local_flags;
|
|
22 int cpu;
|
|
23 int preempt_count;
|
|
24 struct restart_block restart_block;
|
|
25 */
|
|
26 };
|
|
27
|
|
28 struct page {
|
|
29 int flags;
|
|
30 atomic_t count;
|
|
31 };
|
|
32
|
|
33 struct dentry {
|
|
34 atomic_t *d_count;
|
|
35 unsigned long d_vfs_flags;
|
|
36 int d_lock;
|
|
37 };
|
|
38
|
|
39 int t;
|
|
40 __u16 result;
|
|
41 __u32 result32;
|
|
42 unsigned long old;
|
|
43 unsigned long mask;
|
|
44 unsigned long *p ;
|
|
45 const unsigned long *b;
|
|
46 unsigned long msr;
|
|
47 unsigned val;
|
|
48 unsigned short *addr;
|
|
49 __u16 value;
|
|
50 atomic_t *v;
|
|
51 int a;
|
|
52 int lz;
|
|
53 int owner;
|
|
54 unsigned long x;
|
|
55 struct thread_info *ti;
|
|
56 unsigned long prev;
|
|
57 int old1; int new;
|
|
58 unsigned long ret;
|
|
59 unsigned long size;
|
|
60 struct dentry *dentry;
|
|
61 unsigned long flags;
|
|
62 unsigned long tmp;
|
|
63 unsigned long clr;
|
|
64 unsigned long set;
|
|
65 unsigned int sum;
|
|
66 struct page *page;
|
|
67 unsigned int offset;
|
|
68 int *sk_owner ;
|
|
69 unsigned long saddr;
|
|
70 unsigned long daddr;
|
|
71 unsigned short len;
|
|
72 unsigned short proto;
|
|
73 unsigned int rval;
|
|
74
|
|
75
|
|
76
|
|
77
|
|
78
|
|
79
|
|
80 main()
|
|
81 {
|
|
82
|
|
83
|
|
84
|
|
85 __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
|
|
86
|
|
87 __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
|
|
88
|
|
89
|
|
90 __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
|
|
91
|
|
92 __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
|
|
93
|
|
94
|
|
95 __asm__("rlwimi %0,%2,8,16,23" : "=&r" (result) : "0" (value >> 8), "r" (value));
|
|
96
|
|
97
|
|
98 __asm__("rlwimi %0,%2,24,16,23" : "=&r" (result) : "0" (value>>24), "r" (value));
|
|
99 __asm__("rlwimi %0,%2,8,8,15" : "=&r" (result) : "0" (result), "r" (value));
|
|
100 __asm__("rlwimi %0,%2,24,0,7" : "=&r" (result) : "0" (result), "r" (value));
|
|
101
|
|
102
|
|
103 __asm__ __volatile__(
|
880
|
104 "1: lwarx %0,0,%3 \n add %0,%2,%0\n"
|
320
|
105
|
|
106
|
880
|
107 " stwcx. %0,0,%3 \n bne- 1b"
|
320
|
108
|
|
109 : "=&r" (t), "=m" (v->counter)
|
|
110 : "r" (a), "r" (&v->counter), "m" (v->counter)
|
|
111 : "cc");
|
|
112
|
|
113
|
|
114 __asm__ __volatile__(
|
880
|
115 "1: lwarx %0,0,%2 \n add %0,%1,%0\n"
|
320
|
116
|
|
117
|
880
|
118 " stwcx. %0,0,%2 \n bne- 1b"
|
320
|
119
|
|
120
|
|
121 : "=&r" (t)
|
|
122 : "r" (a), "r" (&v->counter)
|
|
123 : "cc", "memory");
|
|
124
|
|
125
|
|
126
|
|
127
|
|
128 __asm__ __volatile__(
|
880
|
129 "1: lwarx %0,0,%3 \n subf %0,%2,%0\n"
|
320
|
130
|
|
131
|
880
|
132 " stwcx. %0,0,%3 \n bne- 1b"
|
320
|
133
|
|
134 : "=&r" (t), "=m" (v->counter)
|
|
135 : "r" (a), "r" (&v->counter), "m" (v->counter)
|
|
136 : "cc");
|
|
137
|
|
138
|
|
139 __asm__ __volatile__(
|
880
|
140 "1: lwarx %0,0,%2 \n subf %0,%1,%0\n"
|
320
|
141
|
|
142
|
880
|
143 " stwcx. %0,0,%2 \n bne- 1b"
|
320
|
144
|
|
145
|
|
146 : "=&r" (t)
|
|
147 : "r" (a), "r" (&v->counter)
|
|
148 : "cc", "memory");
|
|
149
|
|
150
|
|
151
|
|
152 __asm__ __volatile__(
|
880
|
153 "1: lwarx %0,0,%2 \n addic %0,%0,1\n"
|
320
|
154
|
|
155
|
880
|
156 " stwcx. %0,0,%2 \n bne- 1b"
|
320
|
157
|
|
158 : "=&r" (t), "=m" (v->counter)
|
|
159 : "r" (&v->counter), "m" (v->counter)
|
|
160 : "cc");
|
|
161
|
|
162
|
|
163 __asm__ __volatile__(
|
880
|
164 "1: lwarx %0,0,%1 \n addic %0,%0,1\n"
|
320
|
165
|
|
166
|
880
|
167 " stwcx. %0,0,%1 \n bne- 1b"
|
320
|
168
|
|
169
|
|
170 : "=&r" (t)
|
|
171 : "r" (&v->counter)
|
|
172 : "cc", "memory");
|
|
173
|
|
174
|
|
175
|
|
176 __asm__ __volatile__(
|
880
|
177 "1: lwarx %0,0,%2 \n addic %0,%0,-1\n"
|
320
|
178
|
880
|
179 " stwcx. %0,0,%2\n bne- 1b"
|
320
|
180
|
|
181
|
|
182 : "=&r" (t), "=m" (v->counter)
|
|
183 : "r" (&v->counter), "m" (v->counter)
|
|
184 : "cc");
|
|
185
|
|
186
|
|
187 __asm__ __volatile__(
|
880
|
188 "1: lwarx %0,0,%1 \n addic %0,%0,-1\n"
|
320
|
189
|
|
190
|
880
|
191 " stwcx. %0,0,%1\n bne- 1b"
|
320
|
192
|
|
193
|
|
194 : "=&r" (t)
|
|
195 : "r" (&v->counter)
|
|
196 : "cc", "memory");
|
|
197
|
|
198
|
|
199 __asm__ __volatile__(
|
880
|
200 "1: lwarx %0,0,%1 \n addic. %0,%0,-1\n blt- 2f\n"
|
320
|
201
|
|
202
|
|
203
|
880
|
204 " stwcx. %0,0,%1\n bne- 1b"
|
320
|
205
|
|
206
|
|
207 "\n2:" : "=&r" (t)
|
|
208
|
|
209 : "r" (&v->counter)
|
|
210 : "cc", "memory");
|
|
211
|
|
212
|
880
|
213 __asm__ __volatile__("\n1: lwarx %0,0,%3 \n or %0,%0,%2 \n"
|
320
|
214
|
|
215
|
|
216
|
880
|
217 " stwcx. %0,0,%3 \n bne- 1b"
|
320
|
218
|
|
219 : "=&r" (old), "=m" (*p)
|
|
220 : "r" (mask), "r" (p), "m" (*p)
|
|
221 : "cc" );
|
|
222
|
|
223
|
880
|
224 __asm__ __volatile__("\n1: lwarx %0,0,%3 \n andc %0,%0,%2 \n"
|
320
|
225
|
|
226
|
|
227
|
880
|
228 " stwcx. %0,0,%3 \n bne- 1b"
|
320
|
229
|
|
230 : "=&r" (old), "=m" (*p)
|
|
231 : "r" (mask), "r" (p), "m" (*p)
|
|
232 : "cc");
|
|
233
|
|
234
|
|
235
|
880
|
236 __asm__ __volatile__("\n1: lwarx %0,0,%3 \n xor %0,%0,%2 \n"
|
320
|
237
|
|
238
|
|
239
|
880
|
240 " stwcx. %0,0,%3 \n bne- 1b"
|
320
|
241
|
|
242 : "=&r" (old), "=m" (*p)
|
|
243 : "r" (mask), "r" (p), "m" (*p)
|
|
244 : "cc");
|
|
245
|
|
246
|
|
247
|
|
248
|
880
|
249 __asm__ __volatile__( "\n1: lwarx %0,0,%4 \n or %1,%0,%3 \n"
|
320
|
250
|
|
251
|
|
252
|
880
|
253 " stwcx. %1,0,%4 \n bne 1b"
|
320
|
254
|
|
255
|
|
256 : "=&r" (old), "=&r" (t), "=m" (*p)
|
|
257 : "r" (mask), "r" (p), "m" (*p)
|
|
258 : "cc", "memory");
|
|
259
|
|
260
|
|
261
|
|
262
|
880
|
263 __asm__ __volatile__( "\n1: lwarx %0,0,%4 \n andc %1,%0,%3 \n"
|
320
|
264
|
|
265
|
|
266
|
880
|
267 " stwcx. %1,0,%4 \n bne 1b"
|
320
|
268
|
|
269
|
|
270 : "=&r" (old), "=&r" (t), "=m" (*p)
|
|
271 : "r" (mask), "r" (p), "m" (*p)
|
|
272 : "cc", "memory");
|
|
273
|
|
274
|
880
|
275 __asm__ __volatile__( "\n1: lwarx %0,0,%4 \n xor %1,%0,%3 \n"
|
320
|
276
|
|
277
|
|
278
|
880
|
279 " stwcx. %1,0,%4 \n bne 1b"
|
320
|
280
|
|
281
|
|
282 : "=&r" (old), "=&r" (t), "=m" (*p)
|
|
283 : "r" (mask), "r" (p), "m" (*p)
|
|
284 : "cc", "memory");
|
|
285
|
|
286 asm ("cntlzw %0,%1" : "=r" (lz) : "r" (x));
|
|
287 asm ("cntlzw %0,%1" : "=r" (lz) : "r" (x));
|
|
288 #if 0
|
|
289 if (__builtin_expect(!!(b[0]), 0))
|
|
290 return 0;
|
|
291 #endif
|
|
292
|
|
293 // __asm__("rlwinm %0,1,0,0,18" : "=r"(ti));
|
|
294
|
|
295
|
|
296
|
|
297
|
|
298 __asm__ __volatile__ ("dcbt 0,%0" : : "r" (x));
|
|
299 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x));
|
|
300 msr = ({ asm volatile("mfmsr %0" : "=r" (rval)); rval;});
|
|
301 asm volatile("mtmsr %0" : : "r" (msr & ~(1<<15)));
|
|
302 __asm__ __volatile__("": : :"memory");
|
|
303
|
|
304 __asm__ __volatile__("": : :"memory");
|
|
305 msr = ({ asm volatile("mfmsr %0" : "=r" (rval)); rval;});
|
|
306 asm volatile("mtmsr %0" : : "r" (msr | (1<<15)));
|
|
307
|
|
308 msr = ({ asm volatile("mfmsr %0" : "=r" (rval)); rval;});
|
|
309 asm volatile("mtmsr %0" : : "r" (msr & ~(1<<15)));
|
|
310 __asm__ __volatile__("": : :"memory");
|
|
311
|
880
|
312 __asm__ __volatile__ ("\n1: lwarx %0,0,%2 \n"
|
320
|
313
|
|
314
|
880
|
315 " stwcx. %3,0,%2 \n bne- 1b"
|
320
|
316
|
|
317 : "=&r" (prev), "=m" (*(volatile unsigned long *)p)
|
|
318 : "r" (p), "r" (val), "m" (*(volatile unsigned long *)p)
|
|
319 : "cc", "memory");
|
|
320
|
880
|
321 __asm__ __volatile__ ("\n1: lwarx %0,0,%2 \n cmpw 0,%0,%3 \n bne 2f \n"
|
320
|
322
|
|
323
|
|
324
|
|
325
|
880
|
326 " stwcx. %4,0,%2 \n bne- 1b\n"
|
320
|
327
|
|
328
|
|
329
|
|
330
|
|
331 "2:"
|
|
332 : "=&r" (prev), "=m" (*p)
|
|
333 : "r" (p), "r" (old1), "r" (new), "m" (*p)
|
|
334 : "cc", "memory");
|
|
335
|
|
336
|
|
337 __asm__ __volatile__(
|
880
|
338 "2: mftb %0\n"
|
320
|
339 "3:\n"
|
|
340 ".section __ftr_fixup,\"a\"\n"
|
880
|
341 " .long %1\n"
|
|
342 " .long 0\n"
|
|
343 " .long 2b\n"
|
|
344 " .long 3b\n"
|
320
|
345 ".text"
|
|
346 : "=r" (ret) : "i" (0x00000100));
|
|
347 __asm__ __volatile__("": : :"memory");
|
|
348 asm ("cntlzw %0,%1" : "=r" (lz) : "r" (size));
|
|
349
|
|
350
|
|
351
|
|
352 do { asm volatile("mtmsr %0" : : "r" (flags)); do { } while (0); } while (0);
|
|
353
|
|
354 do { __asm__ __volatile__(
|
880
|
355 "1: twnei %0,0\n"
|
|
356 ".section __bug_table,\"a\"\n\t"
|
|
357 " .long 1b,%1,%2,%3\n" ".text" : :
|
|
358 "r" (!((dentry->d_count)
|
|
359 ->counter)),
|
|
360 "i" (273),
|
|
361 "i" ("../../include/linux/dcache.h"),
|
|
362 "i" ((__func__))); } while (0);
|
|
363 __asm__ __volatile__("1: lwarx %0,0,%3\n andc %1,%0,%4\n or %1,%1,%5\n"
|
320
|
364
|
|
365
|
|
366
|
|
367
|
880
|
368 " stwcx. %1,0,%3\n bne- 1b"
|
320
|
369
|
|
370 : "=&r" (old1), "=&r" (tmp), "=m" (*p)
|
|
371 : "r" ((unsigned long)(p+1) - 4), "r" (clr), "r" (set), "m" (*p)
|
|
372 : "cc" );
|
|
373
|
880
|
374 if (({ do { __asm__ __volatile__( "1: twnei %0,0\n" ".section __bug_table,\"a\"\n\t" " .long 1b,%1,%2,%3\n" ".text" : : "r" (((&(page)->count)->counter) == 0), "i" (284), "i" ("../../include/linux/mm.h"), "i" ((__func__))); } while (0); (atomic_dec_return((&(page)->count)) == 0); }))
|
320
|
375 return 0;
|
|
376
|
880
|
377 do { __asm__ __volatile__( "1: twnei %0,0\n" ".section __bug_table,\"a\"\n\t" " .long 1b,%1,%2,%3\n" ".text" : : "r" (offset + size > (1UL << 12)), "i" (59), "i" ("../../include/linux/highmem.h"), "i" ((__func__))); } while (0);
|
320
|
378
|
880
|
379 asm volatile("mtmsr %0" : : "r" (flags));
|
320
|
380
|
|
381 asm volatile("mtmsr %0" : : "r" (flags));
|
|
382
|
|
383 if (((({ asm volatile("mfmsr %0" : "=r" (rval)); rval;}) & (1<<15)) == 0))
|
880
|
384 return 0;
|
320
|
385
|
|
386 __asm__ __volatile__("": : :"memory");
|
|
387
|
|
388
|
880
|
389 do { __asm__ __volatile__( "1: twnei %0,0\n" ".section __bug_table,\"a\"\n\t" " .long 1b,%1,%2,%3\n" ".text" : : "r" ((v->counter) == 1), "i" (333 + 0x1000000), "i" ("../../include/net/sock.h"), "i" ((__func__))); } while (0);
|
320
|
390
|
880
|
391 do { __asm__ __volatile__( "1: twnei %0,0\n" ".section __bug_table,\"a\"\n\t" " .long 1b,%1,%2,%3\n" ".text" : : "r" (sk_owner != ((void *)0)), "i" (476), "i" ("../../include/net/sock.h"), "i" ((__func__))); } while (0);
|
320
|
392
|
880
|
393 do { __asm__ __volatile__( "1: twnei %0,0\n" ".section __bug_table,\"a\"\n\t" " .long 1b,%1,%2,%3\n" ".text" : : "r" (sizeof(struct page) > (24 * sizeof(long))), "i" (523), "i" ("../../include/net/sock.h"), "i" ((__func__))); } while (0);
|
320
|
394
|
|
395
|
|
396
|
|
397 __asm__("rlwinm %0,%1,16,0,31" : "=r" (tmp) : "r" (sum));
|
|
398
|
880
|
399 __asm__("\n addc %0,%0,%1 \n adde %0,%0,%2 \n adde %0,%0,%3 \n addze %0,%0 \n "
|
320
|
400
|
|
401
|
|
402
|
|
403
|
|
404
|
|
405 : "=r" (sum)
|
|
406 : "r" (daddr), "r"(saddr), "r"((proto<<16)+len), "0"(sum));
|
|
407
|
|
408
|
880
|
409 do { __asm__ __volatile__( "1: twnei %0,0\n" ".section __bug_table,\"a\"\n\t" " .long 1b,%1,%2,%3\n" ".text" : : "r" ((tmp) != 0x00000001), "i" (231), "i" ("../../include/linux/crypto.h"), "i" ((__func__))); } while (0);
|
320
|
410
|
|
411
|
|
412 }
|