2727#include <asm/pgalloc.h>
2828#include <asm/processor.h>
2929#include <asm/sections.h>
30+ #include <asm/shmparam.h>
3031
3132int split_tlb __read_mostly ;
3233int dcache_stride __read_mostly ;
3334int icache_stride __read_mostly ;
3435EXPORT_SYMBOL (dcache_stride );
3536
37+ void flush_dcache_page_asm (unsigned long phys_addr , unsigned long vaddr );
38+ EXPORT_SYMBOL (flush_dcache_page_asm );
39+ void flush_icache_page_asm (unsigned long phys_addr , unsigned long vaddr );
40+
3641
3742/* On some machines (e.g. ones with the Merced bus), there can be
3843 * only a single PxTLB broadcast at a time; this must be guaranteed
@@ -259,81 +264,13 @@ void disable_sr_hashing(void)
259264 panic ("SpaceID hashing is still on!\n" );
260265}
261266
262- /* Simple function to work out if we have an existing address translation
263- * for a user space vma. */
264- static inline int translation_exists (struct vm_area_struct * vma ,
265- unsigned long addr , unsigned long pfn )
266- {
267- pgd_t * pgd = pgd_offset (vma -> vm_mm , addr );
268- pmd_t * pmd ;
269- pte_t pte ;
270-
271- if (pgd_none (* pgd ))
272- return 0 ;
273-
274- pmd = pmd_offset (pgd , addr );
275- if (pmd_none (* pmd ) || pmd_bad (* pmd ))
276- return 0 ;
277-
278- /* We cannot take the pte lock here: flush_cache_page is usually
279- * called with pte lock already held. Whereas flush_dcache_page
280- * takes flush_dcache_mmap_lock, which is lower in the hierarchy:
281- * the vma itself is secure, but the pte might come or go racily.
282- */
283- pte = * pte_offset_map (pmd , addr );
284- /* But pte_unmap() does nothing on this architecture */
285-
286- /* Filter out coincidental file entries and swap entries */
287- if (!(pte_val (pte ) & (_PAGE_FLUSH |_PAGE_PRESENT )))
288- return 0 ;
289-
290- return pte_pfn (pte ) == pfn ;
291- }
292-
293- /* Private function to flush a page from the cache of a non-current
294- * process. cr25 contains the Page Directory of the current user
295- * process; we're going to hijack both it and the user space %sr3 to
296- * temporarily make the non-current process current. We have to do
297- * this because cache flushing may cause a non-access tlb miss which
298- * the handlers have to fill in from the pgd of the non-current
299- * process. */
300267static inline void
301- flush_user_cache_page_non_current (struct vm_area_struct * vma ,
302- unsigned long vmaddr )
268+ __flush_cache_page (struct vm_area_struct * vma , unsigned long vmaddr ,
269+ unsigned long physaddr )
303270{
304- /* save the current process space and pgd */
305- unsigned long space = mfsp (3 ), pgd = mfctl (25 );
306-
307- /* we don't mind taking interrupts since they may not
308- * do anything with user space, but we can't
309- * be preempted here */
310- preempt_disable ();
311-
312- /* make us current */
313- mtctl (__pa (vma -> vm_mm -> pgd ), 25 );
314- mtsp (vma -> vm_mm -> context , 3 );
315-
316- flush_user_dcache_page (vmaddr );
317- if (vma -> vm_flags & VM_EXEC )
318- flush_user_icache_page (vmaddr );
319-
320- /* put the old current process back */
321- mtsp (space , 3 );
322- mtctl (pgd , 25 );
323- preempt_enable ();
324- }
325-
326-
327- static inline void
328- __flush_cache_page (struct vm_area_struct * vma , unsigned long vmaddr )
329- {
330- if (likely (vma -> vm_mm -> context == mfsp (3 ))) {
331- flush_user_dcache_page (vmaddr );
332- if (vma -> vm_flags & VM_EXEC )
333- flush_user_icache_page (vmaddr );
334- } else {
335- flush_user_cache_page_non_current (vma , vmaddr );
336- }
271+ flush_dcache_page_asm (physaddr , vmaddr );
272+ if (vma -> vm_flags & VM_EXEC )
273+ flush_icache_page_asm (physaddr , vmaddr );
337274}
338275
339276void flush_dcache_page (struct page * page )
@@ -342,10 +279,8 @@ void flush_dcache_page(struct page *page)
342279 struct vm_area_struct * mpnt ;
343280 struct prio_tree_iter iter ;
344281 unsigned long offset ;
345- unsigned long addr ;
282+ unsigned long addr , old_addr = 0 ;
346283 pgoff_t pgoff ;
347- unsigned long pfn = page_to_pfn (page );
348-
349284
350285 if (mapping && !mapping_mapped (mapping )) {
351286 set_bit (PG_dcache_dirty , & page -> flags );
@@ -369,20 +304,11 @@ void flush_dcache_page(struct page *page)
369304 offset = (pgoff - mpnt -> vm_pgoff ) << PAGE_SHIFT ;
370305 addr = mpnt -> vm_start + offset ;
371306
372- /* Flush instructions produce non access tlb misses.
373- * On PA, we nullify these instructions rather than
374- * taking a page fault if the pte doesn't exist.
375- * This is just for speed. If the page translation
376- * isn't there, there's no point exciting the
377- * nadtlb handler into a nullification frenzy.
378- *
379- * Make sure we really have this page: the private
380- * mappings may cover this area but have COW'd this
381- * particular page.
382- */
383- if (translation_exists (mpnt , addr , pfn )) {
384- __flush_cache_page (mpnt , addr );
385- break ;
307+ if (old_addr == 0 || (old_addr & (SHMLBA - 1 )) != (addr & (SHMLBA - 1 ))) {
308+ __flush_cache_page (mpnt , addr , page_to_phys (page ));
309+ if (old_addr )
310+ printk (KERN_ERR "INEQUIVALENT ALIASES 0x%lx and 0x%lx in file %s\n" , old_addr , addr , mpnt -> vm_file ? mpnt -> vm_file -> f_path .dentry -> d_name .name : "(null)" );
311+ old_addr = addr ;
386312 }
387313 }
388314 flush_dcache_mmap_unlock (mapping );
@@ -573,7 +499,6 @@ flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long
573499{
574500 BUG_ON (!vma -> vm_mm -> context );
575501
576- if (likely (translation_exists (vma , vmaddr , pfn )))
577- __flush_cache_page (vma , vmaddr );
502+ __flush_cache_page (vma , vmaddr , page_to_phys (pfn_to_page (pfn )));
578503
579504}
0 commit comments