• Paul Mackerras's avatar
    KVM: PPC: Book3S HV: Take the SRCU read lock before looking up memslots · 2c9097e4
    Paul Mackerras authored
    The generic KVM code uses SRCU (sleeping RCU) to protect accesses
    to the memslots data structures against updates due to userspace
    adding, modifying or removing memory slots.  We need to do that too,
    both to avoid accessing stale copies of the memslots and to avoid
    lockdep warnings.  This therefore adds srcu_read_lock/unlock pairs
    around code that accesses and uses memslots.
    
    Since the real-mode handlers for H_ENTER, H_REMOVE and H_BULK_REMOVE
    need to access the memslots, and we don't want to call the SRCU code
    in real mode (since we have no assurance that it would only access
    the linear mapping), we hold the SRCU read lock for the VM while
    in the guest.  This does mean that adding or removing memory slots
    while some vcpus are executing in the guest will block for up to
    two jiffies.  This tradeoff is acceptable since adding/removing
    memory slots only happens rarely, while H_ENTER/H_REMOVE/H_BULK_REMOVE
    are performance-critical hot paths.
    Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
    Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
    2c9097e4
book3s_hv.c 39 KB