Re: Host-PCI-Device mapping

2021-10-15 Thread Ajay Garg
Never mind, found the answers in kvm_set_user_memory :)

On Fri, Oct 15, 2021 at 9:36 PM Ajay Garg  wrote:
>
> Hello everyone.
>
> I have a x86_64 L1 guest, running on a x86_64 host, with a
> host-pci-device attached to the guest.
> The host runs with IOMMU enabled, and passthrough enabled.
>
> Following are the addresses of the bar0-region of the pci-device, as
> per the output of lspci -v :
>
> * On host (hpa) => e2c2
> * On guest (gpa) => fc078000
>
>
> Now, if /proc//maps is dumped on the host, following line of
> interest is seen :
>
> #
> 7f0b5c5f4000-7f0b5c5f5000 rw-s e2c2 00:0e 13653
>   anon_inode:[vfio-device]
> #
>
> Above indicates that the hva for the pci-device starts from 0x7f0b5c5f4000.
>
>
> Also, upon attaching gdb to the qemu process, and using a slightly
> modified qemugdb/mtree.py (that prints only the information for
> :0a:00.0 name) to dump the memory-regions, following is obtained :
>
> #
> (gdb) source qemu-gdb.py
> (gdb) qemu mtree
> fc078000-fc07c095 :0a:00.0 base BAR 0 (I/O) (@
> 0x56540d8c8da0)
>   fc078000-fc07c095 :0a:00.0 BAR 0 (I/O) (@
> 0x56540d8c76b0)
> fc078000-fc07c095 :0a:00.0 BAR 0 mmaps[0]
> (I/O) (@ 0x56540d8c7c30)
> (gdb)
> #
>
> Above indicates that the hva for the pci-device starts from 0x56540d8c7c30.
>
> As seen, there is a discrepancy in the two results.
>
>
> What am I missing?
> Looking for pointers, will be grateful.
>
>
> Thanks and Regards,
> Ajay
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu


Host-PCI-Device mapping

2021-10-15 Thread Ajay Garg
Hello everyone.

I have a x86_64 L1 guest, running on a x86_64 host, with a
host-pci-device attached to the guest.
The host runs with IOMMU enabled, and passthrough enabled.

Following are the addresses of the bar0-region of the pci-device, as
per the output of lspci -v :

* On host (hpa) => e2c2
* On guest (gpa) => fc078000


Now, if /proc//maps is dumped on the host, following line of
interest is seen :

#
7f0b5c5f4000-7f0b5c5f5000 rw-s e2c2 00:0e 13653
  anon_inode:[vfio-device]
#

Above indicates that the hva for the pci-device starts from 0x7f0b5c5f4000.


Also, upon attaching gdb to the qemu process, and using a slightly
modified qemugdb/mtree.py (that prints only the information for
:0a:00.0 name) to dump the memory-regions, following is obtained :

#
(gdb) source qemu-gdb.py
(gdb) qemu mtree
fc078000-fc07c095 :0a:00.0 base BAR 0 (I/O) (@
0x56540d8c8da0)
  fc078000-fc07c095 :0a:00.0 BAR 0 (I/O) (@
0x56540d8c76b0)
fc078000-fc07c095 :0a:00.0 BAR 0 mmaps[0]
(I/O) (@ 0x56540d8c7c30)
(gdb)
#

Above indicates that the hva for the pci-device starts from 0x56540d8c7c30.

As seen, there is a discrepancy in the two results.


What am I missing?
Looking for pointers, will be grateful.


Thanks and Regards,
Ajay
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu