• Eric Auger's avatar
    exec: Fix MAP_RAM for cached access · a99761d3
    Eric Auger authored
    When an IOMMUMemoryRegion is in front of a virtio device,
    address_space_cache_init does not set cache->ptr as the memory
    region is not RAM. However when the device performs an access,
    we end up in glue() which performs the translation and then uses
    MAP_RAM. This latter uses the unset ptr and returns a wrong value
    which leads to a SIGSEV in address_space_lduw_internal_cached_slow,
    for instance.
    
    In slow path cache->ptr is NULL and MAP_RAM must redirect to
    qemu_map_ram_ptr((mr)->ram_block, ofs).
    
    As MAP_RAM, IS_DIRECT and INVALIDATE are the same in _cached_slow
    and non cached mode, let's remove those macros.
    
    This fixes the use cases featuring vIOMMU (Intel and ARM SMMU)
    which lead to a SIGSEV.
    
    Fixes: 48564041 (exec: reintroduce MemoryRegion caching)
    Signed-off-by: 's avatarEric Auger <eric.auger@redhat.com>
    
    Message-Id: <1528895946-28677-1-git-send-email-eric.auger@redhat.com>
    Signed-off-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
    a99761d3