Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] 8xx: avoid "dcbst" misbehaviour with unpopulated TLB

The proposed _tlbie call at update_mmu_cache() is safe because:

Addresses for which update_mmu_cache() gets invocated are never inside the
static kernel virtual mapping, meaning that there is no risk for the
_tlbie() here to be thrashing the pinned entry, as Dan suspected.

The intermediate TLB state in which this bug can be triggered is not
visible by userspace or any other contexts, except the page fault handling
path. So there is no need to worry about userspace dcbxxx users.

The other solution to this is to avoid dcbst misbehaviour in the first
place, which involves changing in-kernel "dcbst" callers to use 8xx
specific SPR's.

Summary:

On 8xx, cache control instructions (particularly "dcbst" from
flush_dcache_icache) fault as write operation if there is an unpopulated
TLB entry for the address in question. To workaround that, we invalidate
the TLB here, thus avoiding dcbst misbehaviour.

Signed-off-by: Marcelo Tosatti <marcelo.tosatti@cyclades.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Marcelo Tosatti and committed by
Linus Torvalds
bb165746 d4b3a80e

+12 -2
+12 -2
arch/ppc/mm/init.c
··· 606 606 struct page *page = pfn_to_page(pfn); 607 607 if (!PageReserved(page) 608 608 && !test_bit(PG_arch_1, &page->flags)) { 609 - if (vma->vm_mm == current->active_mm) 609 + if (vma->vm_mm == current->active_mm) { 610 + #ifdef CONFIG_8xx 611 + /* On 8xx, cache control instructions (particularly 612 + * "dcbst" from flush_dcache_icache) fault as write 613 + * operation if there is an unpopulated TLB entry 614 + * for the address in question. To workaround that, 615 + * we invalidate the TLB here, thus avoiding dcbst 616 + * misbehaviour. 617 + */ 618 + _tlbie(address); 619 + #endif 610 620 __flush_dcache_icache((void *) address); 611 - else 621 + } else 612 622 flush_dcache_icache_page(page); 613 623 set_bit(PG_arch_1, &page->flags); 614 624 }