• Avi Kivity's avatar
    KVM: Make locked operations truly atomic · daea3e73
    Avi Kivity authored
    Once upon a time, locked operations were emulated while holding the mmu mutex.
    Since mmu pages were write protected, it was safe to emulate the writes in
    a non-atomic manner, since there could be no other writer, either in the
    guest or in the kernel.
    
    These days emulation takes place without holding the mmu spinlock, so the
    write could be preempted by an unshadowing event, which exposes the page
    to writes by the guest.  This may cause corruption of guest page tables.
    
    Fix by using an atomic cmpxchg for these operations.
    Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
    Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
    daea3e73
x86.c 144 KB