Make address_space_translate{, _cached}() take a MemTxAttrs argument

As part of plumbing MemTxAttrs down to the IOMMU translate method,
add MemTxAttrs as an argument to address_space_translate()
and address_space_translate_cached(). Callers either have an
attrs value to hand, or don't care and can use MEMTXATTRS_UNSPECIFIED.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20180521140402.23318-4-peter.maydell@linaro.org
This commit is contained in:
Peter Maydell 2018-05-31 14:50:52 +01:00
parent c874dc4f5e
commit bc6b1cec84
7 changed files with 27 additions and 19 deletions

View File

@ -1676,7 +1676,7 @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs)
hwaddr l = 1; hwaddr l = 1;
rcu_read_lock(); rcu_read_lock();
mr = address_space_translate(as, addr, &addr, &l, false); mr = address_space_translate(as, addr, &addr, &l, false, attrs);
if (!(memory_region_is_ram(mr) if (!(memory_region_is_ram(mr)
|| memory_region_is_romd(mr))) { || memory_region_is_romd(mr))) {
rcu_read_unlock(); rcu_read_unlock();

14
exec.c
View File

@ -3322,7 +3322,8 @@ static inline void cpu_physical_memory_write_rom_internal(AddressSpace *as,
rcu_read_lock(); rcu_read_lock();
while (len > 0) { while (len > 0) {
l = len; l = len;
mr = address_space_translate(as, addr, &addr1, &l, true); mr = address_space_translate(as, addr, &addr1, &l, true,
MEMTXATTRS_UNSPECIFIED);
if (!(memory_region_is_ram(mr) || if (!(memory_region_is_ram(mr) ||
memory_region_is_romd(mr))) { memory_region_is_romd(mr))) {
@ -3699,7 +3700,7 @@ void address_space_cache_destroy(MemoryRegionCache *cache)
*/ */
static inline MemoryRegion *address_space_translate_cached( static inline MemoryRegion *address_space_translate_cached(
MemoryRegionCache *cache, hwaddr addr, hwaddr *xlat, MemoryRegionCache *cache, hwaddr addr, hwaddr *xlat,
hwaddr *plen, bool is_write) hwaddr *plen, bool is_write, MemTxAttrs attrs)
{ {
MemoryRegionSection section; MemoryRegionSection section;
MemoryRegion *mr; MemoryRegion *mr;
@ -3733,7 +3734,8 @@ address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr,
MemoryRegion *mr; MemoryRegion *mr;
l = len; l = len;
mr = address_space_translate_cached(cache, addr, &addr1, &l, false); mr = address_space_translate_cached(cache, addr, &addr1, &l, false,
MEMTXATTRS_UNSPECIFIED);
flatview_read_continue(cache->fv, flatview_read_continue(cache->fv,
addr, MEMTXATTRS_UNSPECIFIED, buf, len, addr, MEMTXATTRS_UNSPECIFIED, buf, len,
addr1, l, mr); addr1, l, mr);
@ -3750,7 +3752,8 @@ address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr,
MemoryRegion *mr; MemoryRegion *mr;
l = len; l = len;
mr = address_space_translate_cached(cache, addr, &addr1, &l, true); mr = address_space_translate_cached(cache, addr, &addr1, &l, true,
MEMTXATTRS_UNSPECIFIED);
flatview_write_continue(cache->fv, flatview_write_continue(cache->fv,
addr, MEMTXATTRS_UNSPECIFIED, buf, len, addr, MEMTXATTRS_UNSPECIFIED, buf, len,
addr1, l, mr); addr1, l, mr);
@ -3848,7 +3851,8 @@ bool cpu_physical_memory_is_io(hwaddr phys_addr)
rcu_read_lock(); rcu_read_lock();
mr = address_space_translate(&address_space_memory, mr = address_space_translate(&address_space_memory,
phys_addr, &phys_addr, &l, false); phys_addr, &phys_addr, &l, false,
MEMTXATTRS_UNSPECIFIED);
res = !(memory_region_is_ram(mr) || memory_region_is_romd(mr)); res = !(memory_region_is_ram(mr) || memory_region_is_romd(mr));
rcu_read_unlock(); rcu_read_unlock();

View File

@ -324,7 +324,8 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr,
*/ */
mr = address_space_translate(&address_space_memory, mr = address_space_translate(&address_space_memory,
iotlb->translated_addr, iotlb->translated_addr,
&xlat, &len, writable); &xlat, &len, writable,
MEMTXATTRS_UNSPECIFIED);
if (!memory_region_is_ram(mr)) { if (!memory_region_is_ram(mr)) {
error_report("iommu map to non memory area %"HWADDR_PRIx"", error_report("iommu map to non memory area %"HWADDR_PRIx"",
xlat); xlat);

View File

@ -1908,6 +1908,7 @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
* #MemoryRegion. * #MemoryRegion.
* @len: pointer to length * @len: pointer to length
* @is_write: indicates the transfer direction * @is_write: indicates the transfer direction
* @attrs: memory attributes
*/ */
MemoryRegion *flatview_translate(FlatView *fv, MemoryRegion *flatview_translate(FlatView *fv,
hwaddr addr, hwaddr *xlat, hwaddr addr, hwaddr *xlat,
@ -1915,7 +1916,8 @@ MemoryRegion *flatview_translate(FlatView *fv,
static inline MemoryRegion *address_space_translate(AddressSpace *as, static inline MemoryRegion *address_space_translate(AddressSpace *as,
hwaddr addr, hwaddr *xlat, hwaddr addr, hwaddr *xlat,
hwaddr *len, bool is_write) hwaddr *len, bool is_write,
MemTxAttrs attrs)
{ {
return flatview_translate(address_space_to_flatview(as), return flatview_translate(address_space_to_flatview(as),
addr, xlat, len, is_write); addr, xlat, len, is_write);

View File

@ -33,7 +33,7 @@ static inline uint32_t glue(address_space_ldl_internal, SUFFIX)(ARG1_DECL,
bool release_lock = false; bool release_lock = false;
RCU_READ_LOCK(); RCU_READ_LOCK();
mr = TRANSLATE(addr, &addr1, &l, false); mr = TRANSLATE(addr, &addr1, &l, false, attrs);
if (l < 4 || !IS_DIRECT(mr, false)) { if (l < 4 || !IS_DIRECT(mr, false)) {
release_lock |= prepare_mmio_access(mr); release_lock |= prepare_mmio_access(mr);
@ -109,7 +109,7 @@ static inline uint64_t glue(address_space_ldq_internal, SUFFIX)(ARG1_DECL,
bool release_lock = false; bool release_lock = false;
RCU_READ_LOCK(); RCU_READ_LOCK();
mr = TRANSLATE(addr, &addr1, &l, false); mr = TRANSLATE(addr, &addr1, &l, false, attrs);
if (l < 8 || !IS_DIRECT(mr, false)) { if (l < 8 || !IS_DIRECT(mr, false)) {
release_lock |= prepare_mmio_access(mr); release_lock |= prepare_mmio_access(mr);
@ -183,7 +183,7 @@ uint32_t glue(address_space_ldub, SUFFIX)(ARG1_DECL,
bool release_lock = false; bool release_lock = false;
RCU_READ_LOCK(); RCU_READ_LOCK();
mr = TRANSLATE(addr, &addr1, &l, false); mr = TRANSLATE(addr, &addr1, &l, false, attrs);
if (!IS_DIRECT(mr, false)) { if (!IS_DIRECT(mr, false)) {
release_lock |= prepare_mmio_access(mr); release_lock |= prepare_mmio_access(mr);
@ -219,7 +219,7 @@ static inline uint32_t glue(address_space_lduw_internal, SUFFIX)(ARG1_DECL,
bool release_lock = false; bool release_lock = false;
RCU_READ_LOCK(); RCU_READ_LOCK();
mr = TRANSLATE(addr, &addr1, &l, false); mr = TRANSLATE(addr, &addr1, &l, false, attrs);
if (l < 2 || !IS_DIRECT(mr, false)) { if (l < 2 || !IS_DIRECT(mr, false)) {
release_lock |= prepare_mmio_access(mr); release_lock |= prepare_mmio_access(mr);
@ -296,7 +296,7 @@ void glue(address_space_stl_notdirty, SUFFIX)(ARG1_DECL,
bool release_lock = false; bool release_lock = false;
RCU_READ_LOCK(); RCU_READ_LOCK();
mr = TRANSLATE(addr, &addr1, &l, true); mr = TRANSLATE(addr, &addr1, &l, true, attrs);
if (l < 4 || !IS_DIRECT(mr, true)) { if (l < 4 || !IS_DIRECT(mr, true)) {
release_lock |= prepare_mmio_access(mr); release_lock |= prepare_mmio_access(mr);
@ -333,7 +333,7 @@ static inline void glue(address_space_stl_internal, SUFFIX)(ARG1_DECL,
bool release_lock = false; bool release_lock = false;
RCU_READ_LOCK(); RCU_READ_LOCK();
mr = TRANSLATE(addr, &addr1, &l, true); mr = TRANSLATE(addr, &addr1, &l, true, attrs);
if (l < 4 || !IS_DIRECT(mr, true)) { if (l < 4 || !IS_DIRECT(mr, true)) {
release_lock |= prepare_mmio_access(mr); release_lock |= prepare_mmio_access(mr);
@ -405,7 +405,7 @@ void glue(address_space_stb, SUFFIX)(ARG1_DECL,
bool release_lock = false; bool release_lock = false;
RCU_READ_LOCK(); RCU_READ_LOCK();
mr = TRANSLATE(addr, &addr1, &l, true); mr = TRANSLATE(addr, &addr1, &l, true, attrs);
if (!IS_DIRECT(mr, true)) { if (!IS_DIRECT(mr, true)) {
release_lock |= prepare_mmio_access(mr); release_lock |= prepare_mmio_access(mr);
r = memory_region_dispatch_write(mr, addr1, val, 1, attrs); r = memory_region_dispatch_write(mr, addr1, val, 1, attrs);
@ -438,7 +438,7 @@ static inline void glue(address_space_stw_internal, SUFFIX)(ARG1_DECL,
bool release_lock = false; bool release_lock = false;
RCU_READ_LOCK(); RCU_READ_LOCK();
mr = TRANSLATE(addr, &addr1, &l, true); mr = TRANSLATE(addr, &addr1, &l, true, attrs);
if (l < 2 || !IS_DIRECT(mr, true)) { if (l < 2 || !IS_DIRECT(mr, true)) {
release_lock |= prepare_mmio_access(mr); release_lock |= prepare_mmio_access(mr);
@ -511,7 +511,7 @@ static void glue(address_space_stq_internal, SUFFIX)(ARG1_DECL,
bool release_lock = false; bool release_lock = false;
RCU_READ_LOCK(); RCU_READ_LOCK();
mr = TRANSLATE(addr, &addr1, &l, true); mr = TRANSLATE(addr, &addr1, &l, true, attrs);
if (l < 8 || !IS_DIRECT(mr, true)) { if (l < 8 || !IS_DIRECT(mr, true)) {
release_lock |= prepare_mmio_access(mr); release_lock |= prepare_mmio_access(mr);

View File

@ -664,7 +664,8 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
/* MSI doorbell address is translated by an IOMMU */ /* MSI doorbell address is translated by an IOMMU */
rcu_read_lock(); rcu_read_lock();
mr = address_space_translate(as, address, &xlat, &len, true); mr = address_space_translate(as, address, &xlat, &len, true,
MEMTXATTRS_UNSPECIFIED);
if (!mr) { if (!mr) {
goto unlock; goto unlock;
} }

View File

@ -210,7 +210,7 @@ restart:
MemoryRegion *mr; MemoryRegion *mr;
hwaddr l = sizeof(target_ulong), addr1; hwaddr l = sizeof(target_ulong), addr1;
mr = address_space_translate(cs->as, pte_addr, mr = address_space_translate(cs->as, pte_addr,
&addr1, &l, false); &addr1, &l, false, MEMTXATTRS_UNSPECIFIED);
if (memory_access_is_direct(mr, true)) { if (memory_access_is_direct(mr, true)) {
target_ulong *pte_pa = target_ulong *pte_pa =
qemu_map_ram_ptr(mr->ram_block, addr1); qemu_map_ram_ptr(mr->ram_block, addr1);