• Martin Schwidefsky's avatar
    s390/mm: fix race on mm->context.flush_mm · 60f07c8e
    Martin Schwidefsky authored
    The order in __tlb_flush_mm_lazy is to flush TLB first and then clear
    the mm->context.flush_mm bit. This can lead to missed flushes as the
    bit can be set anytime, the order needs to be the other way aronud.
    
    But this leads to a different race, __tlb_flush_mm_lazy may be called
    on two CPUs concurrently. If mm->context.flush_mm is cleared first then
    another CPU can bypass __tlb_flush_mm_lazy although the first CPU has
    not done the flush yet. In a virtualized environment the time until the
    flush is finally completed can be arbitrarily long.
    
    Add a spinlock to serialize __tlb_flush_mm_lazy and use the function
    in finish_arch_post_lock_switch as well.
    
    Cc: <stable@vger.kernel.org>
    Reviewed-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
    Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
    60f07c8e
tlbflush.h 3.48 KB