diff options
author | John David Anglin <dave.anglin@bell.net> | 2013-01-14 19:45:00 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2013-01-19 05:54:45 -0500 |
commit | 7139bc1579901b53db7e898789e916ee2fb52d78 (patch) | |
tree | c5030cb7afe83a347de96757c2a3b5490a9782e8 /arch/parisc | |
parent | 5da1f88b8b727dc3a66c52d4513e871be6d43d19 (diff) |
[PARISC] Purge existing TLB entries in set_pte_at and ptep_set_wrprotect
This patch goes a long way toward fixing the minifail bug, and
it significantly improves the stability of SMP machines such as
the rp3440. When write protecting a page for COW, we need to
purge the existing translation. Otherwise, the COW break
doesn't occur as expected because the TLB may still have a stale entry
which allows writes.
[jejb: fix up checkpatch errors]
Signed-off-by: John David Anglin <dave.anglin@bell.net>
Cc: stable@vger.kernel.org
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'arch/parisc')
-rw-r--r-- | arch/parisc/include/asm/pgtable.h | 13 | ||||
-rw-r--r-- | arch/parisc/kernel/cache.c | 18 |
2 files changed, 28 insertions, 3 deletions
diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h index ee99f2339356..7df49fad29f9 100644 --- a/arch/parisc/include/asm/pgtable.h +++ b/arch/parisc/include/asm/pgtable.h | |||
@@ -12,11 +12,10 @@ | |||
12 | 12 | ||
13 | #include <linux/bitops.h> | 13 | #include <linux/bitops.h> |
14 | #include <linux/spinlock.h> | 14 | #include <linux/spinlock.h> |
15 | #include <linux/mm_types.h> | ||
15 | #include <asm/processor.h> | 16 | #include <asm/processor.h> |
16 | #include <asm/cache.h> | 17 | #include <asm/cache.h> |
17 | 18 | ||
18 | struct vm_area_struct; | ||
19 | |||
20 | /* | 19 | /* |
21 | * kern_addr_valid(ADDR) tests if ADDR is pointing to valid kernel | 20 | * kern_addr_valid(ADDR) tests if ADDR is pointing to valid kernel |
22 | * memory. For the return value to be meaningful, ADDR must be >= | 21 | * memory. For the return value to be meaningful, ADDR must be >= |
@@ -40,7 +39,14 @@ struct vm_area_struct; | |||
40 | do{ \ | 39 | do{ \ |
41 | *(pteptr) = (pteval); \ | 40 | *(pteptr) = (pteval); \ |
42 | } while(0) | 41 | } while(0) |
43 | #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) | 42 | |
43 | extern void purge_tlb_entries(struct mm_struct *, unsigned long); | ||
44 | |||
45 | #define set_pte_at(mm, addr, ptep, pteval) \ | ||
46 | do { \ | ||
47 | set_pte(ptep, pteval); \ | ||
48 | purge_tlb_entries(mm, addr); \ | ||
49 | } while (0) | ||
44 | 50 | ||
45 | #endif /* !__ASSEMBLY__ */ | 51 | #endif /* !__ASSEMBLY__ */ |
46 | 52 | ||
@@ -466,6 +472,7 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, | |||
466 | old = pte_val(*ptep); | 472 | old = pte_val(*ptep); |
467 | new = pte_val(pte_wrprotect(__pte (old))); | 473 | new = pte_val(pte_wrprotect(__pte (old))); |
468 | } while (cmpxchg((unsigned long *) ptep, old, new) != old); | 474 | } while (cmpxchg((unsigned long *) ptep, old, new) != old); |
475 | purge_tlb_entries(mm, addr); | ||
469 | #else | 476 | #else |
470 | pte_t old_pte = *ptep; | 477 | pte_t old_pte = *ptep; |
471 | set_pte_at(mm, addr, ptep, pte_wrprotect(old_pte)); | 478 | set_pte_at(mm, addr, ptep, pte_wrprotect(old_pte)); |
diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c index 48e16dc20102..b89a85ab945e 100644 --- a/arch/parisc/kernel/cache.c +++ b/arch/parisc/kernel/cache.c | |||
@@ -419,6 +419,24 @@ void kunmap_parisc(void *addr) | |||
419 | EXPORT_SYMBOL(kunmap_parisc); | 419 | EXPORT_SYMBOL(kunmap_parisc); |
420 | #endif | 420 | #endif |
421 | 421 | ||
422 | void purge_tlb_entries(struct mm_struct *mm, unsigned long addr) | ||
423 | { | ||
424 | unsigned long flags; | ||
425 | |||
426 | /* Note: purge_tlb_entries can be called at startup with | ||
427 | no context. */ | ||
428 | |||
429 | /* Disable preemption while we play with %sr1. */ | ||
430 | preempt_disable(); | ||
431 | mtsp(mm->context, 1); | ||
432 | purge_tlb_start(flags); | ||
433 | pdtlb(addr); | ||
434 | pitlb(addr); | ||
435 | purge_tlb_end(flags); | ||
436 | preempt_enable(); | ||
437 | } | ||
438 | EXPORT_SYMBOL(purge_tlb_entries); | ||
439 | |||
422 | void __flush_tlb_range(unsigned long sid, unsigned long start, | 440 | void __flush_tlb_range(unsigned long sid, unsigned long start, |
423 | unsigned long end) | 441 | unsigned long end) |
424 | { | 442 | { |