mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-02-25 09:16:49 +00:00
exec: introduce address_space_get_iotlb_entry()
This patch introduces a helper to query the iotlb entry for a possible iova. This will be used by later device IOTLB API to enable the capability for a dataplane (e.g vhost) to query the IOTLB. Backports commit 052c8fa9983f553fdfa0d61034774070dd639c2b from qemu
This commit is contained in:
parent
efad2631d2
commit
fdca6292a1
|
@ -59,6 +59,7 @@
|
|||
#define address_space_init address_space_init_aarch64
|
||||
#define address_space_init_dispatch address_space_init_dispatch_aarch64
|
||||
#define address_space_init_shareable address_space_init_shareable_aarch64
|
||||
#define address_space_get_iotlb_entry address_space_get_iotlb_entry_aarch64
|
||||
#define address_space_ldl address_space_ldl_aarch64
|
||||
#define address_space_ldl_be address_space_ldl_be_aarch64
|
||||
#define address_space_ldl_be_cached address_space_ldl_be_cached_aarch64
|
||||
|
@ -2858,8 +2859,8 @@
|
|||
#define strpadcpy strpadcpy_aarch64
|
||||
#define strstart strstart_aarch64
|
||||
#define stw_be_p stw_be_p_aarch64
|
||||
#define stw_be_phys_cached stw_be_phys_cached_aarch64
|
||||
#define stw_be_phys stw_be_phys_aarch64
|
||||
#define stw_be_phys_cached stw_be_phys_cached_aarch64
|
||||
#define stw_he_p stw_he_p_aarch64
|
||||
#define stw_le_p stw_le_p_aarch64
|
||||
#define stw_le_phys stw_le_phys_aarch64
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#define address_space_init address_space_init_aarch64eb
|
||||
#define address_space_init_dispatch address_space_init_dispatch_aarch64eb
|
||||
#define address_space_init_shareable address_space_init_shareable_aarch64eb
|
||||
#define address_space_get_iotlb_entry address_space_get_iotlb_entry_aarch64eb
|
||||
#define address_space_ldl address_space_ldl_aarch64eb
|
||||
#define address_space_ldl_be address_space_ldl_be_aarch64eb
|
||||
#define address_space_ldl_be_cached address_space_ldl_be_cached_aarch64eb
|
||||
|
@ -2858,8 +2859,8 @@
|
|||
#define strpadcpy strpadcpy_aarch64eb
|
||||
#define strstart strstart_aarch64eb
|
||||
#define stw_be_p stw_be_p_aarch64eb
|
||||
#define stw_be_phys_cached stw_be_phys_cached_aarch64eb
|
||||
#define stw_be_phys stw_be_phys_aarch64eb
|
||||
#define stw_be_phys_cached stw_be_phys_cached_aarch64eb
|
||||
#define stw_he_p stw_he_p_aarch64eb
|
||||
#define stw_le_p stw_le_p_aarch64eb
|
||||
#define stw_le_phys stw_le_phys_aarch64eb
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#define address_space_init address_space_init_arm
|
||||
#define address_space_init_dispatch address_space_init_dispatch_arm
|
||||
#define address_space_init_shareable address_space_init_shareable_arm
|
||||
#define address_space_get_iotlb_entry address_space_get_iotlb_entry_arm
|
||||
#define address_space_ldl address_space_ldl_arm
|
||||
#define address_space_ldl_be address_space_ldl_be_arm
|
||||
#define address_space_ldl_be_cached address_space_ldl_be_cached_arm
|
||||
|
@ -2858,8 +2859,8 @@
|
|||
#define strpadcpy strpadcpy_arm
|
||||
#define strstart strstart_arm
|
||||
#define stw_be_p stw_be_p_arm
|
||||
#define stw_be_phys_cached stw_be_phys_cached_arm
|
||||
#define stw_be_phys stw_be_phys_arm
|
||||
#define stw_be_phys_cached stw_be_phys_cached_arm
|
||||
#define stw_he_p stw_he_p_arm
|
||||
#define stw_le_p stw_le_p_arm
|
||||
#define stw_le_phys stw_le_phys_arm
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#define address_space_init address_space_init_armeb
|
||||
#define address_space_init_dispatch address_space_init_dispatch_armeb
|
||||
#define address_space_init_shareable address_space_init_shareable_armeb
|
||||
#define address_space_get_iotlb_entry address_space_get_iotlb_entry_armeb
|
||||
#define address_space_ldl address_space_ldl_armeb
|
||||
#define address_space_ldl_be address_space_ldl_be_armeb
|
||||
#define address_space_ldl_be_cached address_space_ldl_be_cached_armeb
|
||||
|
@ -2858,8 +2859,8 @@
|
|||
#define strpadcpy strpadcpy_armeb
|
||||
#define strstart strstart_armeb
|
||||
#define stw_be_p stw_be_p_armeb
|
||||
#define stw_be_phys_cached stw_be_phys_cached_armeb
|
||||
#define stw_be_phys stw_be_phys_armeb
|
||||
#define stw_be_phys_cached stw_be_phys_cached_armeb
|
||||
#define stw_he_p stw_he_p_armeb
|
||||
#define stw_le_p stw_le_p_armeb
|
||||
#define stw_le_phys stw_le_phys_armeb
|
||||
|
|
35
qemu/exec.c
35
qemu/exec.c
|
@ -393,6 +393,41 @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x
|
|||
return section;
|
||||
}
|
||||
|
||||
/* Called from RCU critical section */
|
||||
IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
|
||||
bool is_write)
|
||||
{
|
||||
IOMMUTLBEntry iotlb = {0};
|
||||
MemoryRegionSection *section;
|
||||
MemoryRegion *mr;
|
||||
|
||||
for (;;) {
|
||||
// Unicorn: atomic_read used instead of atomic_rcu_read
|
||||
AddressSpaceDispatch *d = atomic_read(&as->dispatch);
|
||||
section = address_space_lookup_region(d, addr, false);
|
||||
addr = addr - section->offset_within_address_space
|
||||
+ section->offset_within_region;
|
||||
mr = section->mr;
|
||||
|
||||
if (!mr->iommu_ops) {
|
||||
break;
|
||||
}
|
||||
|
||||
iotlb = mr->iommu_ops->translate(mr, addr, is_write);
|
||||
if (!(iotlb.perm & (1 << is_write))) {
|
||||
iotlb.target_as = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
addr = ((iotlb.translated_addr & ~iotlb.addr_mask)
|
||||
| (addr & iotlb.addr_mask));
|
||||
as = iotlb.target_as;
|
||||
}
|
||||
|
||||
return iotlb;
|
||||
}
|
||||
|
||||
/* Called from RCU critical section */
|
||||
MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr,
|
||||
hwaddr *xlat, hwaddr *plen,
|
||||
bool is_write)
|
||||
|
|
|
@ -65,6 +65,7 @@ symbols = (
|
|||
'address_space_init',
|
||||
'address_space_init_dispatch',
|
||||
'address_space_init_shareable',
|
||||
'address_space_get_iotlb_entry',
|
||||
'address_space_ldl',
|
||||
'address_space_ldl_be',
|
||||
'address_space_ldl_be_cached',
|
||||
|
|
|
@ -1213,6 +1213,11 @@ void stl_le_phys_cached(MemoryRegionCache *cache, hwaddr addr, uint32_t val);
|
|||
void stl_be_phys_cached(MemoryRegionCache *cache, hwaddr addr, uint32_t val);
|
||||
void stq_le_phys_cached(MemoryRegionCache *cache, hwaddr addr, uint64_t val);
|
||||
void stq_be_phys_cached(MemoryRegionCache *cache, hwaddr addr, uint64_t val);
|
||||
/* address_space_get_iotlb_entry: translate an address into an IOTLB
|
||||
* entry. Should be called from an RCU critical section.
|
||||
*/
|
||||
IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
|
||||
bool is_write);
|
||||
|
||||
/* address_space_translate: translate an address range into an address space
|
||||
* into a MemoryRegion and an address range into that section
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#define address_space_init address_space_init_m68k
|
||||
#define address_space_init_dispatch address_space_init_dispatch_m68k
|
||||
#define address_space_init_shareable address_space_init_shareable_m68k
|
||||
#define address_space_get_iotlb_entry address_space_get_iotlb_entry_m68k
|
||||
#define address_space_ldl address_space_ldl_m68k
|
||||
#define address_space_ldl_be address_space_ldl_be_m68k
|
||||
#define address_space_ldl_be_cached address_space_ldl_be_cached_m68k
|
||||
|
@ -2858,8 +2859,8 @@
|
|||
#define strpadcpy strpadcpy_m68k
|
||||
#define strstart strstart_m68k
|
||||
#define stw_be_p stw_be_p_m68k
|
||||
#define stw_be_phys_cached stw_be_phys_cached_m68k
|
||||
#define stw_be_phys stw_be_phys_m68k
|
||||
#define stw_be_phys_cached stw_be_phys_cached_m68k
|
||||
#define stw_he_p stw_he_p_m68k
|
||||
#define stw_le_p stw_le_p_m68k
|
||||
#define stw_le_phys stw_le_phys_m68k
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#define address_space_init address_space_init_mips
|
||||
#define address_space_init_dispatch address_space_init_dispatch_mips
|
||||
#define address_space_init_shareable address_space_init_shareable_mips
|
||||
#define address_space_get_iotlb_entry address_space_get_iotlb_entry_mips
|
||||
#define address_space_ldl address_space_ldl_mips
|
||||
#define address_space_ldl_be address_space_ldl_be_mips
|
||||
#define address_space_ldl_be_cached address_space_ldl_be_cached_mips
|
||||
|
@ -2858,8 +2859,8 @@
|
|||
#define strpadcpy strpadcpy_mips
|
||||
#define strstart strstart_mips
|
||||
#define stw_be_p stw_be_p_mips
|
||||
#define stw_be_phys_cached stw_be_phys_cached_mips
|
||||
#define stw_be_phys stw_be_phys_mips
|
||||
#define stw_be_phys_cached stw_be_phys_cached_mips
|
||||
#define stw_he_p stw_he_p_mips
|
||||
#define stw_le_p stw_le_p_mips
|
||||
#define stw_le_phys stw_le_phys_mips
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#define address_space_init address_space_init_mips64
|
||||
#define address_space_init_dispatch address_space_init_dispatch_mips64
|
||||
#define address_space_init_shareable address_space_init_shareable_mips64
|
||||
#define address_space_get_iotlb_entry address_space_get_iotlb_entry_mips64
|
||||
#define address_space_ldl address_space_ldl_mips64
|
||||
#define address_space_ldl_be address_space_ldl_be_mips64
|
||||
#define address_space_ldl_be_cached address_space_ldl_be_cached_mips64
|
||||
|
@ -2858,8 +2859,8 @@
|
|||
#define strpadcpy strpadcpy_mips64
|
||||
#define strstart strstart_mips64
|
||||
#define stw_be_p stw_be_p_mips64
|
||||
#define stw_be_phys_cached stw_be_phys_cached_mips64
|
||||
#define stw_be_phys stw_be_phys_mips64
|
||||
#define stw_be_phys_cached stw_be_phys_cached_mips64
|
||||
#define stw_he_p stw_he_p_mips64
|
||||
#define stw_le_p stw_le_p_mips64
|
||||
#define stw_le_phys stw_le_phys_mips64
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#define address_space_init address_space_init_mips64el
|
||||
#define address_space_init_dispatch address_space_init_dispatch_mips64el
|
||||
#define address_space_init_shareable address_space_init_shareable_mips64el
|
||||
#define address_space_get_iotlb_entry address_space_get_iotlb_entry_mips64el
|
||||
#define address_space_ldl address_space_ldl_mips64el
|
||||
#define address_space_ldl_be address_space_ldl_be_mips64el
|
||||
#define address_space_ldl_be_cached address_space_ldl_be_cached_mips64el
|
||||
|
@ -2858,8 +2859,8 @@
|
|||
#define strpadcpy strpadcpy_mips64el
|
||||
#define strstart strstart_mips64el
|
||||
#define stw_be_p stw_be_p_mips64el
|
||||
#define stw_be_phys_cached stw_be_phys_cached_mips64el
|
||||
#define stw_be_phys stw_be_phys_mips64el
|
||||
#define stw_be_phys_cached stw_be_phys_cached_mips64el
|
||||
#define stw_he_p stw_he_p_mips64el
|
||||
#define stw_le_p stw_le_p_mips64el
|
||||
#define stw_le_phys stw_le_phys_mips64el
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#define address_space_init address_space_init_mipsel
|
||||
#define address_space_init_dispatch address_space_init_dispatch_mipsel
|
||||
#define address_space_init_shareable address_space_init_shareable_mipsel
|
||||
#define address_space_get_iotlb_entry address_space_get_iotlb_entry_mipsel
|
||||
#define address_space_ldl address_space_ldl_mipsel
|
||||
#define address_space_ldl_be address_space_ldl_be_mipsel
|
||||
#define address_space_ldl_be_cached address_space_ldl_be_cached_mipsel
|
||||
|
@ -2858,8 +2859,8 @@
|
|||
#define strpadcpy strpadcpy_mipsel
|
||||
#define strstart strstart_mipsel
|
||||
#define stw_be_p stw_be_p_mipsel
|
||||
#define stw_be_phys_cached stw_be_phys_cached_mipsel
|
||||
#define stw_be_phys stw_be_phys_mipsel
|
||||
#define stw_be_phys_cached stw_be_phys_cached_mipsel
|
||||
#define stw_he_p stw_he_p_mipsel
|
||||
#define stw_le_p stw_le_p_mipsel
|
||||
#define stw_le_phys stw_le_phys_mipsel
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#define address_space_init address_space_init_powerpc
|
||||
#define address_space_init_dispatch address_space_init_dispatch_powerpc
|
||||
#define address_space_init_shareable address_space_init_shareable_powerpc
|
||||
#define address_space_get_iotlb_entry address_space_get_iotlb_entry_powerpc
|
||||
#define address_space_ldl address_space_ldl_powerpc
|
||||
#define address_space_ldl_be address_space_ldl_be_powerpc
|
||||
#define address_space_ldl_be_cached address_space_ldl_be_cached_powerpc
|
||||
|
@ -2858,8 +2859,8 @@
|
|||
#define strpadcpy strpadcpy_powerpc
|
||||
#define strstart strstart_powerpc
|
||||
#define stw_be_p stw_be_p_powerpc
|
||||
#define stw_be_phys_cached stw_be_phys_cached_powerpc
|
||||
#define stw_be_phys stw_be_phys_powerpc
|
||||
#define stw_be_phys_cached stw_be_phys_cached_powerpc
|
||||
#define stw_he_p stw_he_p_powerpc
|
||||
#define stw_le_p stw_le_p_powerpc
|
||||
#define stw_le_phys stw_le_phys_powerpc
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#define address_space_init address_space_init_sparc
|
||||
#define address_space_init_dispatch address_space_init_dispatch_sparc
|
||||
#define address_space_init_shareable address_space_init_shareable_sparc
|
||||
#define address_space_get_iotlb_entry address_space_get_iotlb_entry_sparc
|
||||
#define address_space_ldl address_space_ldl_sparc
|
||||
#define address_space_ldl_be address_space_ldl_be_sparc
|
||||
#define address_space_ldl_be_cached address_space_ldl_be_cached_sparc
|
||||
|
@ -2858,8 +2859,8 @@
|
|||
#define strpadcpy strpadcpy_sparc
|
||||
#define strstart strstart_sparc
|
||||
#define stw_be_p stw_be_p_sparc
|
||||
#define stw_be_phys_cached stw_be_phys_cached_sparc
|
||||
#define stw_be_phys stw_be_phys_sparc
|
||||
#define stw_be_phys_cached stw_be_phys_cached_sparc
|
||||
#define stw_he_p stw_he_p_sparc
|
||||
#define stw_le_p stw_le_p_sparc
|
||||
#define stw_le_phys stw_le_phys_sparc
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#define address_space_init address_space_init_sparc64
|
||||
#define address_space_init_dispatch address_space_init_dispatch_sparc64
|
||||
#define address_space_init_shareable address_space_init_shareable_sparc64
|
||||
#define address_space_get_iotlb_entry address_space_get_iotlb_entry_sparc64
|
||||
#define address_space_ldl address_space_ldl_sparc64
|
||||
#define address_space_ldl_be address_space_ldl_be_sparc64
|
||||
#define address_space_ldl_be_cached address_space_ldl_be_cached_sparc64
|
||||
|
@ -2858,8 +2859,8 @@
|
|||
#define strpadcpy strpadcpy_sparc64
|
||||
#define strstart strstart_sparc64
|
||||
#define stw_be_p stw_be_p_sparc64
|
||||
#define stw_be_phys_cached stw_be_phys_cached_sparc64
|
||||
#define stw_be_phys stw_be_phys_sparc64
|
||||
#define stw_be_phys_cached stw_be_phys_cached_sparc64
|
||||
#define stw_he_p stw_he_p_sparc64
|
||||
#define stw_le_p stw_le_p_sparc64
|
||||
#define stw_le_phys stw_le_phys_sparc64
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#define address_space_init address_space_init_x86_64
|
||||
#define address_space_init_dispatch address_space_init_dispatch_x86_64
|
||||
#define address_space_init_shareable address_space_init_shareable_x86_64
|
||||
#define address_space_get_iotlb_entry address_space_get_iotlb_entry_x86_64
|
||||
#define address_space_ldl address_space_ldl_x86_64
|
||||
#define address_space_ldl_be address_space_ldl_be_x86_64
|
||||
#define address_space_ldl_be_cached address_space_ldl_be_cached_x86_64
|
||||
|
@ -2858,8 +2859,8 @@
|
|||
#define strpadcpy strpadcpy_x86_64
|
||||
#define strstart strstart_x86_64
|
||||
#define stw_be_p stw_be_p_x86_64
|
||||
#define stw_be_phys_cached stw_be_phys_cached_x86_64
|
||||
#define stw_be_phys stw_be_phys_x86_64
|
||||
#define stw_be_phys_cached stw_be_phys_cached_x86_64
|
||||
#define stw_he_p stw_he_p_x86_64
|
||||
#define stw_le_p stw_le_p_x86_64
|
||||
#define stw_le_phys stw_le_phys_x86_64
|
||||
|
|
Loading…
Reference in a new issue