On 07/16/2012 06:07 PM, Adam Hraska wrote:
> We could add one more barrier to pt_mapping_make_global()
> in order to be extra safe:
> 
> void pt_mapping_make_global(uintptr_t base, size_t size)
> {
>       // snip
> 
>       for (addr = ALIGN_DOWN(base, ptl0_step); addr - 1 < base + size - 1;
>           addr += ptl0_step) {
>               uintptr_t l1;
> 
>               l1 = (uintptr_t) frame_alloc(order, FRAME_KA | FRAME_LOWMEM);
>               memsetb((void *) l1, FRAME_SIZE << order, 0);
>               SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(addr), KA2PA(l1));
>               
>               /* Make memsetb() visible before setting the PAGE_PRESENT flag. 
> */
>               write_barrier(); // <---- THIS IS NEW
>               
>               SET_PTL1_FLAGS(ptl0, PTL0_INDEX(addr),
>                   PAGE_PRESENT | PAGE_USER | PAGE_CACHEABLE |
>                   PAGE_EXEC | PAGE_WRITE | PAGE_READ);
>       }
> }

This case is purely theoretical because this piece of code always runs
single-threaded before the other CPUs are even detected.

Jakub

_______________________________________________
HelenOS-devel mailing list
[email protected]
http://lists.modry.cz/cgi-bin/listinfo/helenos-devel

Reply via email to