exec: Fix MAP_RAM for cached access
commita99761d3c85679da380c0f597468acd3dc1b53b3
authorEric Auger <eric.auger@redhat.com>
Wed, 13 Jun 2018 13:19:06 +0000 (13 15:19 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 28 Jun 2018 17:05:30 +0000 (28 19:05 +0200)
tree2487eac2ae7fb67662de7208435afd380ce8cc7e
parent4a83bf2f339d4b63ecd5ef48b9816c3b7ee24553
exec: Fix MAP_RAM for cached access

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: 48564041a73a (exec: reintroduce MemoryRegion caching)
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Message-Id: <1528895946-28677-1-git-send-email-eric.auger@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
exec.c
memory_ldst.inc.c