Commit 5d01e6ce785884a5db5792cd2e5bb36fa82fe23c

Authored by Mikael Starvik
Committed by Linus Torvalds
1 parent dcf1310b72

[PATCH] CRIS update: updates for 2.6.12

Patches to make CRIS work with 2.6.12.

Signed-off-by: Mikael Starvik <starvik@axis.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 15 changed files with 88 additions and 119 deletions Side-by-side Diff

arch/cris/arch-v10/kernel/ptrace.c
... ... @@ -11,6 +11,7 @@
11 11 #include <linux/ptrace.h>
12 12 #include <linux/user.h>
13 13 #include <linux/signal.h>
  14 +#include <linux/security.h>
14 15  
15 16 #include <asm/uaccess.h>
16 17 #include <asm/page.h>
17 18  
... ... @@ -86,9 +87,13 @@
86 87 ret = -EPERM;
87 88  
88 89 if (request == PTRACE_TRACEME) {
  90 + /* are we already being traced? */
89 91 if (current->ptrace & PT_PTRACED)
90 92 goto out;
91   -
  93 + ret = security_ptrace(current->parent, current);
  94 + if (ret)
  95 + goto out;
  96 + /* set the ptrace bit in the process flags. */
92 97 current->ptrace |= PT_PTRACED;
93 98 ret = 0;
94 99 goto out;
... ... @@ -207,7 +212,7 @@
207 212 case PTRACE_KILL:
208 213 ret = 0;
209 214  
210   - if (child->state == TASK_ZOMBIE)
  215 + if (child->exit_state == EXIT_ZOMBIE)
211 216 break;
212 217  
213 218 child->exit_code = SIGKILL;
arch/cris/kernel/module.c
... ... @@ -32,7 +32,7 @@
32 32 {
33 33 if (size == 0)
34 34 return NULL;
35   - return vmalloc(size);
  35 + return vmalloc_exec(size);
36 36 }
37 37  
38 38  
... ... @@ -59,26 +59,8 @@
59 59 unsigned int relsec,
60 60 struct module *me)
61 61 {
62   - unsigned int i;
63   - Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
64   - Elf32_Sym *sym;
65   - uint32_t *location;
66   -
67   - DEBUGP("Applying relocate section %u to %u\n", relsec,
68   - sechdrs[relsec].sh_info);
69   - for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
70   - /* This is where to make the change */
71   - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_offset
72   - + rel[i].r_offset;
73   - /* This is the symbol it is referring to. Note that all
74   - undefined symbols have been resolved. */
75   - sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
76   - + ELF32_R_SYM(rel[i].r_info);
77   -
78   - /* We add the value into the location given */
79   - *location += sym->st_value;
80   - }
81   - return 0;
  62 + printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
  63 + return -ENOEXEC;
82 64 }
83 65  
84 66 int apply_relocate_add(Elf32_Shdr *sechdrs,
... ... @@ -90,7 +72,7 @@
90 72 unsigned int i;
91 73 Elf32_Rela *rela = (void *)sechdrs[relsec].sh_addr;
92 74  
93   - DEBUGP ("Applying relocate section %u to %u\n", relsec,
  75 + DEBUGP ("Applying add relocate section %u to %u\n", relsec,
94 76 sechdrs[relsec].sh_info);
95 77  
96 78 for (i = 0; i < sechdrs[relsec].sh_size / sizeof (*rela); i++) {
... ... @@ -103,7 +85,18 @@
103 85 Elf32_Sym *sym
104 86 = ((Elf32_Sym *)sechdrs[symindex].sh_addr
105 87 + ELF32_R_SYM (rela[i].r_info));
106   - *loc = sym->st_value + rela[i].r_addend;
  88 + switch (ELF32_R_TYPE(rela[i].r_info)) {
  89 + case R_CRIS_32:
  90 + *loc = sym->st_value + rela[i].r_addend;
  91 + break;
  92 + case R_CRIS_32_PCREL:
  93 + *loc = sym->st_value - (unsigned)loc + rela[i].r_addend - 4;
  94 + break;
  95 + default:
  96 + printk(KERN_ERR "module %s: Unknown relocation: %u\n",
  97 + me->name, ELF32_R_TYPE(rela[i].r_info));
  98 + return -ENOEXEC;
  99 + }
107 100 }
108 101  
109 102 return 0;
arch/cris/kernel/process.c
1   -/* $Id: process.c,v 1.17 2004/04/05 13:53:48 starvik Exp $
  1 +/* $Id: process.c,v 1.21 2005/03/04 08:16:17 starvik Exp $
2 2 *
3 3 * linux/arch/cris/kernel/process.c
4 4 *
... ... @@ -8,6 +8,18 @@
8 8 * Authors: Bjorn Wesen (bjornw@axis.com)
9 9 *
10 10 * $Log: process.c,v $
  11 + * Revision 1.21 2005/03/04 08:16:17 starvik
  12 + * Merge of Linux 2.6.11.
  13 + *
  14 + * Revision 1.20 2005/01/18 05:57:22 starvik
  15 + * Renamed hlt_counter to cris_hlt_counter and made it global.
  16 + *
  17 + * Revision 1.19 2004/10/19 13:07:43 starvik
  18 + * Merge of Linux 2.6.9
  19 + *
  20 + * Revision 1.18 2004/08/16 12:37:23 starvik
  21 + * Merge of Linux 2.6.8
  22 + *
11 23 * Revision 1.17 2004/04/05 13:53:48 starvik
12 24 * Merge of Linux 2.6.5
13 25 *
14 26  
15 27  
... ... @@ -161,18 +173,18 @@
161 173 * region by enable_hlt/disable_hlt.
162 174 */
163 175  
164   -static int hlt_counter=0;
  176 +int cris_hlt_counter=0;
165 177  
166 178 void disable_hlt(void)
167 179 {
168   - hlt_counter++;
  180 + cris_hlt_counter++;
169 181 }
170 182  
171 183 EXPORT_SYMBOL(disable_hlt);
172 184  
173 185 void enable_hlt(void)
174 186 {
175   - hlt_counter--;
  187 + cris_hlt_counter--;
176 188 }
177 189  
178 190 EXPORT_SYMBOL(enable_hlt);
179 191  
180 192  
... ... @@ -195,16 +207,19 @@
195 207 /* endless idle loop with no priority at all */
196 208 while (1) {
197 209 while (!need_resched()) {
198   - void (*idle)(void) = pm_idle;
199   -
  210 + void (*idle)(void);
  211 + /*
  212 + * Mark this as an RCU critical section so that
  213 + * synchronize_kernel() in the unload path waits
  214 + * for our completion.
  215 + */
  216 + idle = pm_idle;
200 217 if (!idle)
201 218 idle = default_idle;
202   -
203 219 idle();
204 220 }
205 221 schedule();
206 222 }
207   -
208 223 }
209 224  
210 225 void hard_reset_now (void);
include/asm-cris/arch-v10/bitops.h
... ... @@ -51,7 +51,7 @@
51 51 *
52 52 * Undefined if no bit exists, so code should check against 0 first.
53 53 */
54   -extern __inline__ unsigned long __ffs(unsigned long word)
  54 +extern inline unsigned long __ffs(unsigned long word)
55 55 {
56 56 return cris_swapnwbrlz(~word);
57 57 }
include/asm-cris/arch-v10/offset.h
... ... @@ -25,7 +25,7 @@
25 25 #define THREAD_usp 4 /* offsetof(struct thread_struct, usp) */
26 26 #define THREAD_dccr 8 /* offsetof(struct thread_struct, dccr) */
27 27  
28   -#define TASK_pid 133 /* offsetof(struct task_struct, pid) */
  28 +#define TASK_pid 141 /* offsetof(struct task_struct, pid) */
29 29  
30 30 #define LCLONE_VM 256 /* CLONE_VM */
31 31 #define LCLONE_UNTRACED 8388608 /* CLONE_UNTRACED */
include/asm-cris/bitops.h
... ... @@ -16,6 +16,7 @@
16 16  
17 17 #include <asm/arch/bitops.h>
18 18 #include <asm/system.h>
  19 +#include <asm/atomic.h>
19 20 #include <linux/compiler.h>
20 21  
21 22 /*
... ... @@ -88,7 +89,7 @@
88 89 * It also implies a memory barrier.
89 90 */
90 91  
91   -extern inline int test_and_set_bit(int nr, void *addr)
  92 +extern inline int test_and_set_bit(int nr, volatile unsigned long *addr)
92 93 {
93 94 unsigned int mask, retval;
94 95 unsigned long flags;
95 96  
96 97  
... ... @@ -96,15 +97,15 @@
96 97  
97 98 adr += nr >> 5;
98 99 mask = 1 << (nr & 0x1f);
99   - local_save_flags(flags);
100   - local_irq_disable();
  100 + cris_atomic_save(addr, flags);
101 101 retval = (mask & *adr) != 0;
102 102 *adr |= mask;
  103 + cris_atomic_restore(addr, flags);
103 104 local_irq_restore(flags);
104 105 return retval;
105 106 }
106 107  
107   -extern inline int __test_and_set_bit(int nr, void *addr)
  108 +extern inline int __test_and_set_bit(int nr, volatile unsigned long *addr)
108 109 {
109 110 unsigned int mask, retval;
110 111 unsigned int *adr = (unsigned int *)addr;
... ... @@ -131,7 +132,7 @@
131 132 * It also implies a memory barrier.
132 133 */
133 134  
134   -extern inline int test_and_clear_bit(int nr, void *addr)
  135 +extern inline int test_and_clear_bit(int nr, volatile unsigned long *addr)
135 136 {
136 137 unsigned int mask, retval;
137 138 unsigned long flags;
138 139  
... ... @@ -139,11 +140,10 @@
139 140  
140 141 adr += nr >> 5;
141 142 mask = 1 << (nr & 0x1f);
142   - local_save_flags(flags);
143   - local_irq_disable();
  143 + cris_atomic_save(addr, flags);
144 144 retval = (mask & *adr) != 0;
145 145 *adr &= ~mask;
146   - local_irq_restore(flags);
  146 + cris_atomic_restore(addr, flags);
147 147 return retval;
148 148 }
149 149  
... ... @@ -157,7 +157,7 @@
157 157 * but actually fail. You must protect multiple accesses with a lock.
158 158 */
159 159  
160   -extern inline int __test_and_clear_bit(int nr, void *addr)
  160 +extern inline int __test_and_clear_bit(int nr, volatile unsigned long *addr)
161 161 {
162 162 unsigned int mask, retval;
163 163 unsigned int *adr = (unsigned int *)addr;
164 164  
165 165  
166 166  
... ... @@ -177,24 +177,23 @@
177 177 * It also implies a memory barrier.
178 178 */
179 179  
180   -extern inline int test_and_change_bit(int nr, void *addr)
  180 +extern inline int test_and_change_bit(int nr, volatile unsigned long *addr)
181 181 {
182 182 unsigned int mask, retval;
183 183 unsigned long flags;
184 184 unsigned int *adr = (unsigned int *)addr;
185 185 adr += nr >> 5;
186 186 mask = 1 << (nr & 0x1f);
187   - local_save_flags(flags);
188   - local_irq_disable();
  187 + cris_atomic_save(addr, flags);
189 188 retval = (mask & *adr) != 0;
190 189 *adr ^= mask;
191   - local_irq_restore(flags);
  190 + cris_atomic_restore(addr, flags);
192 191 return retval;
193 192 }
194 193  
195 194 /* WARNING: non atomic and it can be reordered! */
196 195  
197   -extern inline int __test_and_change_bit(int nr, void *addr)
  196 +extern inline int __test_and_change_bit(int nr, volatile unsigned long *addr)
198 197 {
199 198 unsigned int mask, retval;
200 199 unsigned int *adr = (unsigned int *)addr;
... ... @@ -215,7 +214,7 @@
215 214 * This routine doesn't need to be atomic.
216 215 */
217 216  
218   -extern inline int test_bit(int nr, const void *addr)
  217 +extern inline int test_bit(int nr, const volatile unsigned long *addr)
219 218 {
220 219 unsigned int mask;
221 220 unsigned int *adr = (unsigned int *)addr;
... ... @@ -259,7 +258,7 @@
259 258 * @offset: The bitnumber to start searching at
260 259 * @size: The maximum size to search
261 260 */
262   -extern inline int find_next_zero_bit (void * addr, int size, int offset)
  261 +extern inline int find_next_zero_bit (const unsigned long * addr, int size, int offset)
263 262 {
264 263 unsigned long *p = ((unsigned long *) addr) + (offset >> 5);
265 264 unsigned long result = offset & ~31UL;
... ... @@ -301,7 +300,7 @@
301 300 * @offset: The bitnumber to start searching at
302 301 * @size: The maximum size to search
303 302 */
304   -static __inline__ int find_next_bit(void *addr, int size, int offset)
  303 +static __inline__ int find_next_bit(const unsigned long *addr, int size, int offset)
305 304 {
306 305 unsigned long *p = ((unsigned long *) addr) + (offset >> 5);
307 306 unsigned long result = offset & ~31UL;
... ... @@ -367,7 +366,7 @@
367 366 #define minix_test_bit(nr,addr) test_bit(nr,addr)
368 367 #define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size)
369 368  
370   -extern inline int sched_find_first_bit(unsigned long *b)
  369 +extern inline int sched_find_first_bit(const unsigned long *b)
371 370 {
372 371 if (unlikely(b[0]))
373 372 return __ffs(b[0]);
include/asm-cris/kmap_types.h
... ... @@ -17,8 +17,8 @@
17 17 KM_PTE1,
18 18 KM_IRQ0,
19 19 KM_IRQ1,
20   - KM_CRYPTO_USER,
21   - KM_CRYPTO_SOFTIRQ,
  20 + KM_SOFTIRQ0,
  21 + KM_SOFTIRQ1,
22 22 KM_TYPE_NR
23 23 };
24 24  
include/asm-cris/page.h
... ... @@ -29,18 +29,15 @@
29 29 */
30 30 #ifndef __ASSEMBLY__
31 31 typedef struct { unsigned long pte; } pte_t;
32   -typedef struct { unsigned long pmd; } pmd_t;
33 32 typedef struct { unsigned long pgd; } pgd_t;
34 33 typedef struct { unsigned long pgprot; } pgprot_t;
35 34 #endif
36 35  
37 36 #define pte_val(x) ((x).pte)
38   -#define pmd_val(x) ((x).pmd)
39 37 #define pgd_val(x) ((x).pgd)
40 38 #define pgprot_val(x) ((x).pgprot)
41 39  
42 40 #define __pte(x) ((pte_t) { (x) } )
43   -#define __pmd(x) ((pmd_t) { (x) } )
44 41 #define __pgd(x) ((pgd_t) { (x) } )
45 42 #define __pgprot(x) ((pgprot_t) { (x) } )
46 43  
... ... @@ -72,10 +69,6 @@
72 69 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
73 70  
74 71 #ifndef __ASSEMBLY__
75   -
76   -#define BUG() do { \
77   - printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
78   -} while (0)
79 72  
80 73 /* Pure 2^n version of get_order */
81 74 static inline int get_order(unsigned long size)
include/asm-cris/pgalloc.h
... ... @@ -47,16 +47,6 @@
47 47  
48 48 #define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
49 49  
50   -/*
51   - * We don't have any real pmd's, and this code never triggers because
52   - * the pgd will always be present..
53   - */
54   -
55   -#define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
56   -#define pmd_free(x) do { } while (0)
57   -#define __pmd_free_tlb(tlb,x) do { } while (0)
58   -#define pgd_populate(mm, pmd, pte) BUG()
59   -
60 50 #define check_pgt_cache() do { } while (0)
61 51  
62 52 #endif
include/asm-cris/pgtable.h
... ... @@ -5,7 +5,8 @@
5 5 #ifndef _CRIS_PGTABLE_H
6 6 #define _CRIS_PGTABLE_H
7 7  
8   -#include <asm-generic/4level-fixup.h>
  8 +#include <asm/page.h>
  9 +#include <asm-generic/pgtable-nopmd.h>
9 10  
10 11 #ifndef __ASSEMBLY__
11 12 #include <linux/config.h>
12 13  
13 14  
... ... @@ -41,22 +42,14 @@
41 42 * but the define is needed for a generic inline function.)
42 43 */
43 44 #define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
44   -#define set_pgd(pgdptr, pgdval) (*(pgdptr) = pgdval)
  45 +#define set_pgu(pudptr, pudval) (*(pudptr) = pudval)
45 46  
46   -/* PMD_SHIFT determines the size of the area a second-level page table can
  47 +/* PGDIR_SHIFT determines the size of the area a second-level page table can
47 48 * map. It is equal to the page size times the number of PTE's that fit in
48 49 * a PMD page. A PTE is 4-bytes in CRIS. Hence the following number.
49 50 */
50 51  
51   -#define PMD_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-2))
52   -#define PMD_SIZE (1UL << PMD_SHIFT)
53   -#define PMD_MASK (~(PMD_SIZE-1))
54   -
55   -/* PGDIR_SHIFT determines what a third-level page table entry can map.
56   - * Since we fold into a two-level structure, this is the same as PMD_SHIFT.
57   - */
58   -
59   -#define PGDIR_SHIFT PMD_SHIFT
  52 +#define PGDIR_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-2))
60 53 #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
61 54 #define PGDIR_MASK (~(PGDIR_SIZE-1))
62 55  
... ... @@ -67,7 +60,6 @@
67 60 * divide it by 4 (shift by 2).
68 61 */
69 62 #define PTRS_PER_PTE (1UL << (PAGE_SHIFT-2))
70   -#define PTRS_PER_PMD 1
71 63 #define PTRS_PER_PGD (1UL << (PAGE_SHIFT-2))
72 64  
73 65 /* calculate how many PGD entries a user-level program can use
... ... @@ -105,7 +97,7 @@
105 97 #define pte_present(x) (pte_val(x) & _PAGE_PRESENT)
106 98 #define pte_clear(mm,addr,xp) do { pte_val(*(xp)) = 0; } while (0)
107 99  
108   -#define pmd_none(x) (!pmd_val(x))
  100 +#define pmd_none(x) (!pmd_val(x))
109 101 /* by removing the _PAGE_KERNEL bit from the comparision, the same pmd_bad
110 102 * works for both _PAGE_TABLE and _KERNPG_TABLE pmd entries.
111 103 */
... ... @@ -116,16 +108,6 @@
116 108 #ifndef __ASSEMBLY__
117 109  
118 110 /*
119   - * The "pgd_xxx()" functions here are trivial for a folded two-level
120   - * setup: the pgd is never bad, and a pmd always exists (as it's folded
121   - * into the pgd entry)
122   - */
123   -extern inline int pgd_none(pgd_t pgd) { return 0; }
124   -extern inline int pgd_bad(pgd_t pgd) { return 0; }
125   -extern inline int pgd_present(pgd_t pgd) { return 1; }
126   -extern inline void pgd_clear(pgd_t * pgdp) { }
127   -
128   -/*
129 111 * The following only work if pte_present() is true.
130 112 * Undefined behaviour if not..
131 113 */
... ... @@ -275,7 +257,7 @@
275 257 #define pmd_page_kernel(pmd) ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
276 258  
277 259 /* to find an entry in a page-table-directory. */
278   -#define pgd_index(address) ((address >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
  260 +#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
279 261  
280 262 /* to find an entry in a page-table-directory */
281 263 extern inline pgd_t * pgd_offset(struct mm_struct * mm, unsigned long address)
... ... @@ -286,12 +268,6 @@
286 268 /* to find an entry in a kernel page-table-directory */
287 269 #define pgd_offset_k(address) pgd_offset(&init_mm, address)
288 270  
289   -/* Find an entry in the second-level page table.. */
290   -extern inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
291   -{
292   - return (pmd_t *) dir;
293   -}
294   -
295 271 /* Find an entry in the third-level page table.. */
296 272 #define __pte_offset(address) \
297 273 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
... ... @@ -308,8 +284,6 @@
308 284  
309 285 #define pte_ERROR(e) \
310 286 printk("%s:%d: bad pte %p(%08lx).\n", __FILE__, __LINE__, &(e), pte_val(e))
311   -#define pmd_ERROR(e) \
312   - printk("%s:%d: bad pmd %p(%08lx).\n", __FILE__, __LINE__, &(e), pmd_val(e))
313 287 #define pgd_ERROR(e) \
314 288 printk("%s:%d: bad pgd %p(%08lx).\n", __FILE__, __LINE__, &(e), pgd_val(e))
315 289  
... ... @@ -347,6 +321,8 @@
347 321  
348 322 #define pte_to_pgoff(x) (pte_val(x) >> 6)
349 323 #define pgoff_to_pte(x) __pte(((x) << 6) | _PAGE_FILE)
  324 +
  325 +typedef pte_t *pte_addr_t;
350 326  
351 327 #endif /* __ASSEMBLY__ */
352 328 #endif /* _CRIS_PGTABLE_H */
include/asm-cris/processor.h
... ... @@ -55,15 +55,6 @@
55 55  
56 56 #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
57 57  
58   -/*
59   - * Free current thread data structures etc..
60   - */
61   -
62   -extern inline void exit_thread(void)
63   -{
64   - /* Nothing needs to be done. */
65   -}
66   -
67 58 extern unsigned long thread_saved_pc(struct task_struct *tsk);
68 59  
69 60 /* Free all resources held by a thread. */
include/asm-cris/thread_info.h
... ... @@ -43,7 +43,7 @@
43 43  
44 44 #endif
45 45  
46   -#define PREEMPT_ACTIVE 0x4000000
  46 +#define PREEMPT_ACTIVE 0x10000000
47 47  
48 48 /*
49 49 * macros/functions for gaining access to the thread information structure
include/asm-cris/timex.h
... ... @@ -14,7 +14,7 @@
14 14 * used so it does not matter.
15 15 */
16 16  
17   -typedef unsigned int cycles_t;
  17 +typedef unsigned long long cycles_t;
18 18  
19 19 extern inline cycles_t get_cycles(void)
20 20 {
include/asm-cris/types.h
... ... @@ -52,7 +52,7 @@
52 52 typedef u32 dma_addr_t;
53 53 typedef u32 dma64_addr_t;
54 54  
55   -typedef unsigned int kmem_bufctl_t;
  55 +typedef unsigned short kmem_bufctl_t;
56 56  
57 57 #endif /* __ASSEMBLY__ */
58 58  
include/asm-cris/unistd.h
... ... @@ -288,8 +288,15 @@
288 288 #define __NR_mq_timedreceive (__NR_mq_open+3)
289 289 #define __NR_mq_notify (__NR_mq_open+4)
290 290 #define __NR_mq_getsetattr (__NR_mq_open+5)
291   -
292   -#define NR_syscalls 283
  291 +#define __NR_sys_kexec_load 283
  292 +#define __NR_waitid 284
  293 +/* #define __NR_sys_setaltroot 285 */
  294 +#define __NR_add_key 286
  295 +#define __NR_request_key 287
  296 +#define __NR_keyctl 288
  297 +
  298 +#define NR_syscalls 289
  299 +
293 300  
294 301  
295 302 #ifdef __KERNEL__