• David Gibson's avatar
    Correct hash flushing from huge_ptep_set_wrprotect() · 86df8642
    David Gibson authored
    As Andy Whitcroft recently pointed out, the current powerpc version of
    huge_ptep_set_wrprotect() has a bug.  It just calls ptep_set_wrprotect()
    which in turn calls pte_update() then hpte_need_flush() with the 'huge'
    argument set to 0.  This will cause hpte_need_flush() to flush the wrong
    hash entries (of any).  Andy's fix for this is already in the powerpc
    tree as commit 016b33c4.
    
    I have confirmed this is a real bug, not masked by some other
    synchronization, with a new testcase for libhugetlbfs.  A process write
    a (MAP_PRIVATE) hugepage mapping, fork(), then alter the mapping and
    have the child incorrectly see the second write.
    
    Therefore, this should be fixed for 2.6.26, and for the stable tree.
    Here is a suitable patch for 2.6.26, which I think will also be suitable
    for the stable tree (neither of the headers in question has been changed
    much recently).
    
    It is cut down slighlty from Andy's original version, in that it does
    not include a 32-bit version of huge_ptep_set_wrprotect().  Currently,
    hugepages are not supported on any 32-bit powerpc platform.  When they
    are, a suitable 32-bit version can be added - the only 32-bit hardware
    which supports hugepages does not use the conventional hashtable MMU and
    so will have different needs anyway.
    Signed-off-by: default avatarAndy Whitcroft <apw@shadowen.org>
    Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
    Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    86df8642
hugetlb.h 1.6 KB