]> git.itanic.dy.fi Git - linux-stable/commitdiff
ARC: Brown paper bag bug in macro for checking cache color
authorVineet Gupta <vgupta@synopsys.com>
Wed, 22 May 2013 13:08:10 +0000 (18:38 +0530)
committerVineet Gupta <vgupta@synopsys.com>
Thu, 23 May 2013 08:54:52 +0000 (14:24 +0530)
The VM_EXEC check in update_mmu_cache() was getting optimized away
because of a stupid error in definition of macro addr_not_cache_congruent()

The intention was to have the equivalent of following:

if (a || (1 ? b : 0))

but we ended up with following:

if (a || 1 ? b : 0)

And because precedence of '||' is more that that of '?', gcc was optimizing
away evaluation of <a>

Nasty Repercussions:
1. For non-aliasing configs it would mean some extraneous dcache flushes
   for non-code pages if U/K mappings were not congruent.
2. For aliasing config, some needed dcache flush for code pages might
   be missed if U/K mappings were congruent.

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
arch/arc/include/asm/cacheflush.h
arch/arc/mm/tlb.c

index 9f841af41092f059a604c0631984bb3c6ef067d7..7d819749478cf21cbfe1ba9947e2cdee7f124442 100644 (file)
@@ -99,8 +99,10 @@ static inline int cache_is_vipt_aliasing(void)
  * checks if two addresses (after page aligning) index into same cache set
  */
 #define addr_not_cache_congruent(addr1, addr2)                         \
+({                                                                     \
        cache_is_vipt_aliasing() ?                                      \
-               (CACHE_COLOR(addr1) != CACHE_COLOR(addr2)) : 0          \
+               (CACHE_COLOR(addr1) != CACHE_COLOR(addr2)) : 0;         \
+})
 
 #define copy_to_user_page(vma, page, vaddr, dst, src, len)             \
 do {                                                                   \
index 066145b5f3488bcaa515769728d0389a00fc7ed7..fe1c5a073afe4cf996d28b6486c6b296fbd94344 100644 (file)
@@ -444,7 +444,8 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long vaddr_unaligned,
         *             so userspace sees the right data.
         *  (Avoids the flush for Non-exec + congruent mapping case)
         */
-       if (vma->vm_flags & VM_EXEC || addr_not_cache_congruent(paddr, vaddr)) {
+       if ((vma->vm_flags & VM_EXEC) ||
+            addr_not_cache_congruent(paddr, vaddr)) {
                struct page *page = pfn_to_page(pte_pfn(*ptep));
 
                int dirty = test_and_clear_bit(PG_arch_1, &page->flags);