Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset e943ecf in mainline


Ignore:
Timestamp:
2012-07-03T19:12:41Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
master
Children:
72e1d6eb, de73242
Parents:
7d68da80
Message:

Add read_barrier()'s to pt_mapping_find().

This is to prevent a rather hypothetical scenario in which the
architecture uses a PTE format with the present bit in a different cache
line than that of the frame address field, and reorders the load of the
present bit after the load of the frame address despite the control
dependency between the two loads.

Most of the architectures are known not to reorder control-dependent
loads, but some newer variants of arm32 do this.

Note that a read memory barrier would have to be used also in every
lock-free caller of page_mapping_find() to order reading of the present
bit and the rest of the PTE content. These are fortunately limited to
architecture-dependent TLB-miss handlers as generic code always uses
the locked variant. Since arm32 has hardware-walked page tables, it does
not call page_mapping_find() and thus nothing has to be changed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/mm/page_pt.c

    r7d68da80 re943ecf  
    288288        if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT)
    289289                return NULL;
     290
     291        read_barrier();
    290292       
    291293        pte_t *ptl1 = (pte_t *) PA2KA(GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page)));
    292294        if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT)
    293295                return NULL;
     296
     297#if (PTL1_ENTRIES != 0)
     298        read_barrier();
     299#endif
    294300       
    295301        pte_t *ptl2 = (pte_t *) PA2KA(GET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page)));
    296302        if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT)
    297303                return NULL;
     304
     305#if (PTL2_ENTRIES != 0)
     306        read_barrier();
     307#endif
    298308       
    299309        pte_t *ptl3 = (pte_t *) PA2KA(GET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page)));
Note: See TracChangeset for help on using the changeset viewer.