[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] xen/arm: p2m: Prevent deadlock when using memaccess



*** New tip has no discernable common ancestor with previous history ***
    Previously reported histories end at:
        e01fa4e223fc077e18936d890dbd4813c3e7c9b1
        3a28f760508fb35c430edac17a9efde5aff6d1d5
        123c7793797502b222300eb710cd3873dcca41ee
        c40317f11b3f05e7c06a2213560c8471081f2662
        a6f2cdb633bf519244a16674031b8034b581ba7f
        8e4b2676685f50bc26f03b5f62d8b7aea8e69dbf
        2f5af2c962c05b789bdd65b46c74711e903f86d0
        695bb5f504ab48c1d546446f104c1b6c0ead126d
        9053a74c08fd6abf43bb45ff932b4386de7e8510
        16b1414de91b5a82a0996c67f6db3af7d7e32873
        572a78190403e5f2acbd01fa72c35fafe9700169
        e871e80c38547d9faefc6604532ba3e985e65873
        a823a5280f25ad19a751dd9a41044f556471e61a

commit 0012ae8afb4a6e76f2847119f2c6850fbf41d9b7
Author:     Julien Grall <julien.grall@xxxxxxx>
AuthorDate: Mon Mar 12 15:34:52 2018 +0000
Commit:     Stefano Stabellini <sstabellini@xxxxxxxxxx>
CommitDate: Fri Mar 16 13:58:28 2018 -0700

    xen/arm: p2m: Prevent deadlock when using memaccess
    
    Commit 7d623b358a4 "arm/mem_access: Add long-descriptor based gpt"
    assumed the read-write lock can be taken recursively. However, this
    assumption is wrong and will lead to deadlock when the lock is
    contended.
    
    The read lock is taken recursively in the following case:
        1) get_page_from_gva
            => Take the read lock (first read lock)
            => Call p2m_mem_access_check_and_get_page on failure when
            memaccess is enabled
        2) p2m_mem_access_check_and_get_page
            => If hardware translation failed fallback to software lookup
            => Call guest_walk_tables
        3) guest_walk_tables
            => Will use access_guest_memory_by_ipa to access stage-1 page-table
        4) access_guest_memory_by_ipa
            => Because Arm does not have hardware instruction to only do
            stage-2 page-table, this is done in software.
            => Take the read lock (second read lock)
    
    To avoid the nested lock, rework the locking in get_page_from_gva and
    p2m_mem_access_check_and_get_page. The latter will now be called without
    the p2m lock. The new locking in p2m_mem_accces_check_and_get_page will
    not cover the translation of the VA to an IPA.
    
    This is fine because we can't promise that the stage-1 page-table have
    changed behind our back (they are under guest control). Modification in
    the stage-2 page-table can now happen, but I can't issue any potential
    issue here except with the break-before-make sequence used when updating
    page-table. gva_to_ipa may fail if the sequence is executed at the same
    on another CPU. In that case we would fallback in the software lookup
    path.
    
    Signed-off-by: Julien Grall <julien.grall@xxxxxxx>
    Reviewed-by: Sergej Proskurin <proskurin@xxxxxxxxxxxxx>
    Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.