Skip to content
  • David Vrabel's avatar
    xen/gntdev: mark userspace PTEs as special on x86 PV guests · 923b2919
    David Vrabel authored
    
    
    In an x86 PV guest, get_user_pages_fast() on a userspace address range
    containing foreign mappings does not work correctly because the M2P
    lookup of the MFN from a userspace PTE may return the wrong page.
    
    Force get_user_pages_fast() to fail on such addresses by marking the PTEs
    as special.
    
    If Xen has XENFEAT_gnttab_map_avail_bits (available since at least
    4.0), we can do so efficiently in the grant map hypercall.  Otherwise,
    it needs to be done afterwards.  This is both inefficient and racy
    (the mapping is visible to the task before we fixup the PTEs), but
    will be fine for well-behaved applications that do not use the mapping
    until after the mmap() system call returns.
    
    Guests with XENFEAT_auto_translated_physmap (ARM and x86 HVM or PVH)
    do not need this since get_user_pages() has always worked correctly
    for them.
    
    Signed-off-by: default avatarDavid Vrabel <david.vrabel@citrix.com>
    Reviewed-by: default avatarStefano Stabellini <stefano.stabellini@eu.citrix.com>
    923b2919