Revision a8170e5e hw/vfio_pci.c
b/hw/vfio_pci.c | ||
---|---|---|
678 | 678 |
/* |
679 | 679 |
* IO Port/MMIO - Beware of the endians, VFIO is always little endian |
680 | 680 |
*/ |
681 |
static void vfio_bar_write(void *opaque, target_phys_addr_t addr,
|
|
681 |
static void vfio_bar_write(void *opaque, hwaddr addr,
|
|
682 | 682 |
uint64_t data, unsigned size) |
683 | 683 |
{ |
684 | 684 |
VFIOBAR *bar = opaque; |
... | ... | |
705 | 705 |
} |
706 | 706 |
|
707 | 707 |
if (pwrite(bar->fd, &buf, size, bar->fd_offset + addr) != size) { |
708 |
error_report("%s(,0x%"TARGET_PRIxPHYS", 0x%"PRIx64", %d) failed: %m\n",
|
|
708 |
error_report("%s(,0x%"HWADDR_PRIx", 0x%"PRIx64", %d) failed: %m\n",
|
|
709 | 709 |
__func__, addr, data, size); |
710 | 710 |
} |
711 | 711 |
|
712 |
DPRINTF("%s(BAR%d+0x%"TARGET_PRIxPHYS", 0x%"PRIx64", %d)\n",
|
|
712 |
DPRINTF("%s(BAR%d+0x%"HWADDR_PRIx", 0x%"PRIx64", %d)\n",
|
|
713 | 713 |
__func__, bar->nr, addr, data, size); |
714 | 714 |
|
715 | 715 |
/* |
... | ... | |
724 | 724 |
} |
725 | 725 |
|
726 | 726 |
static uint64_t vfio_bar_read(void *opaque, |
727 |
target_phys_addr_t addr, unsigned size)
|
|
727 |
hwaddr addr, unsigned size)
|
|
728 | 728 |
{ |
729 | 729 |
VFIOBAR *bar = opaque; |
730 | 730 |
union { |
... | ... | |
736 | 736 |
uint64_t data = 0; |
737 | 737 |
|
738 | 738 |
if (pread(bar->fd, &buf, size, bar->fd_offset + addr) != size) { |
739 |
error_report("%s(,0x%"TARGET_PRIxPHYS", %d) failed: %m\n",
|
|
739 |
error_report("%s(,0x%"HWADDR_PRIx", %d) failed: %m\n",
|
|
740 | 740 |
__func__, addr, size); |
741 | 741 |
return (uint64_t)-1; |
742 | 742 |
} |
... | ... | |
756 | 756 |
break; |
757 | 757 |
} |
758 | 758 |
|
759 |
DPRINTF("%s(BAR%d+0x%"TARGET_PRIxPHYS", %d) = 0x%"PRIx64"\n",
|
|
759 |
DPRINTF("%s(BAR%d+0x%"HWADDR_PRIx", %d) = 0x%"PRIx64"\n",
|
|
760 | 760 |
__func__, bar->nr, addr, size, data); |
761 | 761 |
|
762 | 762 |
/* Same as write above */ |
... | ... | |
882 | 882 |
* DMA - Mapping and unmapping for the "type1" IOMMU interface used on x86 |
883 | 883 |
*/ |
884 | 884 |
static int vfio_dma_unmap(VFIOContainer *container, |
885 |
target_phys_addr_t iova, ram_addr_t size)
|
|
885 |
hwaddr iova, ram_addr_t size)
|
|
886 | 886 |
{ |
887 | 887 |
struct vfio_iommu_type1_dma_unmap unmap = { |
888 | 888 |
.argsz = sizeof(unmap), |
... | ... | |
899 | 899 |
return 0; |
900 | 900 |
} |
901 | 901 |
|
902 |
static int vfio_dma_map(VFIOContainer *container, target_phys_addr_t iova,
|
|
902 |
static int vfio_dma_map(VFIOContainer *container, hwaddr iova,
|
|
903 | 903 |
ram_addr_t size, void *vaddr, bool readonly) |
904 | 904 |
{ |
905 | 905 |
struct vfio_iommu_type1_dma_map map = { |
... | ... | |
939 | 939 |
{ |
940 | 940 |
VFIOContainer *container = container_of(listener, VFIOContainer, |
941 | 941 |
iommu_data.listener); |
942 |
target_phys_addr_t iova, end;
|
|
942 |
hwaddr iova, end;
|
|
943 | 943 |
void *vaddr; |
944 | 944 |
int ret; |
945 | 945 |
|
946 | 946 |
if (vfio_listener_skipped_section(section)) { |
947 |
DPRINTF("vfio: SKIPPING region_add %"TARGET_PRIxPHYS" - %"PRIx64"\n",
|
|
947 |
DPRINTF("vfio: SKIPPING region_add %"HWADDR_PRIx" - %"PRIx64"\n",
|
|
948 | 948 |
section->offset_within_address_space, |
949 | 949 |
section->offset_within_address_space + section->size - 1); |
950 | 950 |
return; |
... | ... | |
968 | 968 |
section->offset_within_region + |
969 | 969 |
(iova - section->offset_within_address_space); |
970 | 970 |
|
971 |
DPRINTF("vfio: region_add %"TARGET_PRIxPHYS" - %"TARGET_PRIxPHYS" [%p]\n",
|
|
971 |
DPRINTF("vfio: region_add %"HWADDR_PRIx" - %"HWADDR_PRIx" [%p]\n",
|
|
972 | 972 |
iova, end - 1, vaddr); |
973 | 973 |
|
974 | 974 |
ret = vfio_dma_map(container, iova, end - iova, vaddr, section->readonly); |
975 | 975 |
if (ret) { |
976 |
error_report("vfio_dma_map(%p, 0x%"TARGET_PRIxPHYS", "
|
|
977 |
"0x%"TARGET_PRIxPHYS", %p) = %d (%m)\n",
|
|
976 |
error_report("vfio_dma_map(%p, 0x%"HWADDR_PRIx", "
|
|
977 |
"0x%"HWADDR_PRIx", %p) = %d (%m)\n",
|
|
978 | 978 |
container, iova, end - iova, vaddr, ret); |
979 | 979 |
} |
980 | 980 |
} |
... | ... | |
984 | 984 |
{ |
985 | 985 |
VFIOContainer *container = container_of(listener, VFIOContainer, |
986 | 986 |
iommu_data.listener); |
987 |
target_phys_addr_t iova, end;
|
|
987 |
hwaddr iova, end;
|
|
988 | 988 |
int ret; |
989 | 989 |
|
990 | 990 |
if (vfio_listener_skipped_section(section)) { |
991 |
DPRINTF("vfio: SKIPPING region_del %"TARGET_PRIxPHYS" - %"PRIx64"\n",
|
|
991 |
DPRINTF("vfio: SKIPPING region_del %"HWADDR_PRIx" - %"PRIx64"\n",
|
|
992 | 992 |
section->offset_within_address_space, |
993 | 993 |
section->offset_within_address_space + section->size - 1); |
994 | 994 |
return; |
... | ... | |
1008 | 1008 |
return; |
1009 | 1009 |
} |
1010 | 1010 |
|
1011 |
DPRINTF("vfio: region_del %"TARGET_PRIxPHYS" - %"TARGET_PRIxPHYS"\n",
|
|
1011 |
DPRINTF("vfio: region_del %"HWADDR_PRIx" - %"HWADDR_PRIx"\n",
|
|
1012 | 1012 |
iova, end - 1); |
1013 | 1013 |
|
1014 | 1014 |
ret = vfio_dma_unmap(container, iova, end - iova); |
1015 | 1015 |
if (ret) { |
1016 |
error_report("vfio_dma_unmap(%p, 0x%"TARGET_PRIxPHYS", "
|
|
1017 |
"0x%"TARGET_PRIxPHYS") = %d (%m)\n",
|
|
1016 |
error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
|
|
1017 |
"0x%"HWADDR_PRIx") = %d (%m)\n",
|
|
1018 | 1018 |
container, iova, end - iova, ret); |
1019 | 1019 |
} |
1020 | 1020 |
} |
Also available in: Unified diff