diff options
author | Paul Mundt <lethal@linux-sh.org> | 2006-09-27 01:38:02 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2006-09-27 01:38:02 -0400 |
commit | 8b395265f81817385f12e62f03f795efb732a445 (patch) | |
tree | 17f6b1f4f0e09330f108f0a9ffc5b30aa9166da1 /arch/sh | |
parent | 75c92acdd5b19a5e3536ed670e1122d73c635b4a (diff) |
sh: Fix fatal oops in copy_user_page() on sh4a (SH7780).
We had a pretty interesting oops happening, where copy_user_page()
was down()'ing p3map_sem[] with a bogus offset (particularly, an
offset that hadn't been initialized with sema_init(), due to the
mismatch between cpu_data->dcache.n_aliases and what was assumed
based off of the old CACHE_ALIAS value).
Luckily, spinlock debugging caught this for us, and so we drop
the old hardcoded CACHE_ALIAS for sh4 completely and rely on the
run-time probed cpu_data->dcache.alias_mask. This in turn gets
the p3map_sem[] index right, and everything works again.
While we're at it, also convert to 4-level page tables..
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh')
-rw-r--r-- | arch/sh/mm/pg-sh4.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/arch/sh/mm/pg-sh4.c b/arch/sh/mm/pg-sh4.c index c776b60fc250..07371ed7a313 100644 --- a/arch/sh/mm/pg-sh4.c +++ b/arch/sh/mm/pg-sh4.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * arch/sh/mm/pg-sh4.c | 2 | * arch/sh/mm/pg-sh4.c |
3 | * | 3 | * |
4 | * Copyright (C) 1999, 2000, 2002 Niibe Yutaka | 4 | * Copyright (C) 1999, 2000, 2002 Niibe Yutaka |
5 | * Copyright (C) 2002 Paul Mundt | 5 | * Copyright (C) 2002 - 2005 Paul Mundt |
6 | * | 6 | * |
7 | * Released under the terms of the GNU GPL v2.0. | 7 | * Released under the terms of the GNU GPL v2.0. |
8 | */ | 8 | */ |
@@ -23,6 +23,8 @@ | |||
23 | 23 | ||
24 | extern struct semaphore p3map_sem[]; | 24 | extern struct semaphore p3map_sem[]; |
25 | 25 | ||
26 | #define CACHE_ALIAS (cpu_data->dcache.alias_mask) | ||
27 | |||
26 | /* | 28 | /* |
27 | * clear_user_page | 29 | * clear_user_page |
28 | * @to: P1 address | 30 | * @to: P1 address |
@@ -35,14 +37,15 @@ void clear_user_page(void *to, unsigned long address, struct page *page) | |||
35 | if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) | 37 | if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) |
36 | clear_page(to); | 38 | clear_page(to); |
37 | else { | 39 | else { |
38 | pgprot_t pgprot = __pgprot(_PAGE_PRESENT | | 40 | pgprot_t pgprot = __pgprot(_PAGE_PRESENT | |
39 | _PAGE_RW | _PAGE_CACHABLE | | 41 | _PAGE_RW | _PAGE_CACHABLE | |
40 | _PAGE_DIRTY | _PAGE_ACCESSED | | 42 | _PAGE_DIRTY | _PAGE_ACCESSED | |
41 | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD); | 43 | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD); |
42 | unsigned long phys_addr = PHYSADDR(to); | 44 | unsigned long phys_addr = PHYSADDR(to); |
43 | unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS); | 45 | unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS); |
44 | pgd_t *dir = pgd_offset_k(p3_addr); | 46 | pgd_t *pgd = pgd_offset_k(p3_addr); |
45 | pmd_t *pmd = pmd_offset(dir, p3_addr); | 47 | pud_t *pud = pud_offset(pgd, p3_addr); |
48 | pmd_t *pmd = pmd_offset(pud, p3_addr); | ||
46 | pte_t *pte = pte_offset_kernel(pmd, p3_addr); | 49 | pte_t *pte = pte_offset_kernel(pmd, p3_addr); |
47 | pte_t entry; | 50 | pte_t entry; |
48 | unsigned long flags; | 51 | unsigned long flags; |
@@ -67,21 +70,22 @@ void clear_user_page(void *to, unsigned long address, struct page *page) | |||
67 | * @address: U0 address to be mapped | 70 | * @address: U0 address to be mapped |
68 | * @page: page (virt_to_page(to)) | 71 | * @page: page (virt_to_page(to)) |
69 | */ | 72 | */ |
70 | void copy_user_page(void *to, void *from, unsigned long address, | 73 | void copy_user_page(void *to, void *from, unsigned long address, |
71 | struct page *page) | 74 | struct page *page) |
72 | { | 75 | { |
73 | __set_bit(PG_mapped, &page->flags); | 76 | __set_bit(PG_mapped, &page->flags); |
74 | if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) | 77 | if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) |
75 | copy_page(to, from); | 78 | copy_page(to, from); |
76 | else { | 79 | else { |
77 | pgprot_t pgprot = __pgprot(_PAGE_PRESENT | | 80 | pgprot_t pgprot = __pgprot(_PAGE_PRESENT | |
78 | _PAGE_RW | _PAGE_CACHABLE | | 81 | _PAGE_RW | _PAGE_CACHABLE | |
79 | _PAGE_DIRTY | _PAGE_ACCESSED | | 82 | _PAGE_DIRTY | _PAGE_ACCESSED | |
80 | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD); | 83 | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD); |
81 | unsigned long phys_addr = PHYSADDR(to); | 84 | unsigned long phys_addr = PHYSADDR(to); |
82 | unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS); | 85 | unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS); |
83 | pgd_t *dir = pgd_offset_k(p3_addr); | 86 | pgd_t *pgd = pgd_offset_k(p3_addr); |
84 | pmd_t *pmd = pmd_offset(dir, p3_addr); | 87 | pud_t *pud = pud_offset(pgd, p3_addr); |
88 | pmd_t *pmd = pmd_offset(pud, p3_addr); | ||
85 | pte_t *pte = pte_offset_kernel(pmd, p3_addr); | 89 | pte_t *pte = pte_offset_kernel(pmd, p3_addr); |
86 | pte_t entry; | 90 | pte_t entry; |
87 | unsigned long flags; | 91 | unsigned long flags; |