All of lore.kernel.org
 help / color / mirror / Atom feed
From: Auger Eric <eric.auger@redhat.com>
To: Bharat Bhushan <bharat.bhushan@nxp.com>,
	Jean-Philippe Brucker <jean-philippe.brucker@arm.com>,
	"eric.auger.pro@gmail.com" <eric.auger.pro@gmail.com>,
	"peter.maydell@linaro.org" <peter.maydell@linaro.org>,
	"alex.williamson@redhat.com" <alex.williamson@redhat.com>,
	"mst@redhat.com" <mst@redhat.com>,
	"qemu-arm@nongnu.org" <qemu-arm@nongnu.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "wei@redhat.com" <wei@redhat.com>,
	"kevin.tian@intel.com" <kevin.tian@intel.com>,
	"marc.zyngier@arm.com" <marc.zyngier@arm.com>,
	"tn@semihalf.com" <tn@semihalf.com>,
	"will.deacon@arm.com" <will.deacon@arm.com>,
	"drjones@redhat.com" <drjones@redhat.com>,
	"robin.murphy@arm.com" <robin.murphy@arm.com>,
	"christoffer.dall@linaro.org" <christoffer.dall@linaro.org>
Subject: Re: [Qemu-devel] [RFC v2 0/8] VIRTIO-IOMMU device
Date: Fri, 7 Jul 2017 09:25:54 +0200	[thread overview]
Message-ID: <a67cb139-e1b6-02fc-d451-4001bcbfceb3@redhat.com> (raw)
In-Reply-To: <AM5PR0401MB2545C23F66D6D0E096DCB0369AAA0@AM5PR0401MB2545.eurprd04.prod.outlook.com>



On 07/07/2017 08:25, Bharat Bhushan wrote:
> Hi Eric,
> 
>> -----Original Message-----
>> From: Auger Eric [mailto:eric.auger@redhat.com]
>> Sent: Friday, July 07, 2017 2:47 AM
>> To: Bharat Bhushan <bharat.bhushan@nxp.com>; Jean-Philippe Brucker
>> <jean-philippe.brucker@arm.com>; eric.auger.pro@gmail.com;
>> peter.maydell@linaro.org; alex.williamson@redhat.com; mst@redhat.com;
>> qemu-arm@nongnu.org; qemu-devel@nongnu.org
>> Cc: wei@redhat.com; kevin.tian@intel.com; marc.zyngier@arm.com;
>> tn@semihalf.com; will.deacon@arm.com; drjones@redhat.com;
>> robin.murphy@arm.com; christoffer.dall@linaro.org
>> Subject: Re: [Qemu-devel] [RFC v2 0/8] VIRTIO-IOMMU device
>>
>> Hi Bharat,
>>
>> On 06/07/2017 13:24, Bharat Bhushan wrote:
>>>
>>>
>>>> -----Original Message-----
>>>> From: Jean-Philippe Brucker [mailto:jean-philippe.brucker@arm.com]
>>>> Sent: Thursday, July 06, 2017 3:33 PM
>>>> To: Bharat Bhushan <bharat.bhushan@nxp.com>; Auger Eric
>>>> <eric.auger@redhat.com>; eric.auger.pro@gmail.com;
>>>> peter.maydell@linaro.org; alex.williamson@redhat.com;
>> mst@redhat.com;
>>>> qemu-arm@nongnu.org; qemu-devel@nongnu.org
>>>> Cc: wei@redhat.com; kevin.tian@intel.com; marc.zyngier@arm.com;
>>>> tn@semihalf.com; will.deacon@arm.com; drjones@redhat.com;
>>>> robin.murphy@arm.com; christoffer.dall@linaro.org
>>>> Subject: Re: [Qemu-devel] [RFC v2 0/8] VIRTIO-IOMMU device
>>>>
>>>> On 05/07/17 09:49, Bharat Bhushan wrote:>>> Also when setup msi-route
>>>> kvm_irqchip_add_msi_route() we needed to
>>>>>> provide the translated address.
>>>>>>> According to my understanding this is required because kernel does
>>>>>>> no go
>>>>>> through viommu translation when generating interrupt, no?
>>>>>>
>>>>>> yes this is needed when KVM MSI routes are set up, ie. along with
>>>>>> GICV3
>>>> ITS.
>>>>>> With GICv2M, qemu direct gsi mapping is used and this is not needed.
>>>>>>
>>>>>> So I do not understand your previous sentence saying "MSI
>>>>>> interrupts works without any change".
>>>>>
>>>>> I have almost completed vfio integration with virtio-iommu and now
>>>>> testing the changes by assigning e1000 device to VM. For this I have
>>>>> changed virtio-iommu driver to use IOMMU_RESV_MSI rather than sw-
>> msi
>>>>> and this does not need changed in vfio_get_addr()  and
>>>>> kvm_irqchip_add_msi_route()
>>>>
>>>> I understand you're reserving region 0x08000000-0x08100000 as
>>>> IOMMU_RESV_MSI instead of IOMMU_RESV_SW_MSI? I think this only
>> works
>>>> because Qemu places the vgic in that area as well (in hw/arm/virt.c).
>>>> It's not a coincidence if the addresses are the same, because Eric
>>>> chose them for the Linux SMMU drivers and I copied them.
>>>>
>>>> We can't rely on that behavior, though, it will break MSIs in
>>>> emulated devices. And if Qemu happens to move the MSI doorbell in
>>>> future machine revisions, then it would also break VFIO.
>>>
>>> Yes, make sense to me
>>>
>>>>
>>>> Just for my own understanding -- what happens, I think, is that in
>>>> Linux iova_reserve_iommu_regions initially reserves the
>>>> guest-physical doorbell 0x08000000-0x08100000. Then much later, when
>>>> the device driver requests an MSI, the irqchip driver calls
>>>> iommu_dma_map_msi_msg with the guest- physical gicv2m address
>>>> 0x08020000. The function finds the right page in msi_page_list, which
>>>> was added by cookie_init_hw_msi_region, therefore bypassing the
>> viommu and the GPA gets written in the MSI-X table.
>>>
>>> This means in case tomorrow when qemu changes virt machine address
>> map and vgic-its (its-translator register address) address range does not fall
>> in the msi_page_list then it will allocate a new iova, create mapping in
>> iommu. So this will no longer be identity mapped and fail to work with new
>> qemu?
>>>
>> Yes that's correct.
>>>>
>>>> If an emulated device such as virtio-net-pci were to generate an MSI,
>>>> then Qemu would attempt to access the doorbell written by Linux into
>>>> the MSI-X table, 0x08020000, and fault because that address wasn't
>>>> mapped in the viommu.
>>>>
>>>> So for VFIO, you either need to translate the MSI-X entry using the
>>>> viommu, or just assume that the vaddr corresponds to the only MSI
>>>> doorbell accessible by this device (because how can we be certain
>>>> that the guest already mapped the doorbell before writing the entry?)
>>>>
>>>> For ARM machines it's probably best to stick with
>> IOMMU_RESV_SW_MSI.
>>>> However, a nice way to use IOMMU_RESV_MSI would be for the virtio-
>>>> iommu device to advertise identity-mapped/reserved regions, and
>>>> bypass translation on these regions. Then the driver could reserve
>>>> those with IOMMU_RESV_MSI.
>>>
>>> Correct me if I did not understood you correctly, today iommu-driver
>> decides msi-reserved region, what if we change this and virtio-iommu device
>> will provide the reserved msi region as per the emulated machine (virt/intel).
>> So virtio-iommu driver will use the address advertised by virtio-iommu device
>> as IOMMU_RESV_MSI. In this case msi-page-list will always have the
>> reserved region for MSI.
>>> On qemu side, for emulated devices we will let virtio-iommu return same
>> address as translated address as it falls in MSI-reserved page already known
>> to it.
>>
>> I think what you're proposing here corresponds to the 1st approach that was
>> followed for PCIe passthrough/MSI on ARM, ie. the userspace was providing
>> the reserved region base address & size.
>>  This was ruled out and now this
>> region is arbitrarily set by the smmu-driver. At the moment this means this
>> region cannot contain guest RAM.
> 
> In rejected proposal, user-space used to choose a reserve region and provide that to Host Linux. Host Linux uses that MSI mapping. Just for my understanding if tomorrow QEMU changes its address space then it may not work without changing SMMU msi-reserved-iova in host driver, right? For example if emulated machine have RAM at this address then it will not work?
Yes that's correct. Note MSI reserved regions are now exposed to
userspace through /sys/kernel/iommu_groups/<>/reserved_regions
> 
> In this proposal, QEMU reserves a iova-range for guest (not host) and guest kernel will use this as msi-iova untranslated (IOMMU_RESV_MSI). While this does not change host interface and it will continue to use host reserved mapping for actual interrupt generation, no?
But then userspace needs to provide IOMMU_RESV_MSI range to guest
kernel, right? What would be the proposed manner? Looks weird to me to
have different MSI handling on host and guest. Also I still don't get
how you handle the case where virtio-net-pci emits accesses to the MSI
doorbell while this latter is not mapped.

Thanks

Eric
> 
> Thanks
> -Bharat
> 
>>
>>>
>>>
>>>> For x86 we will need such a system, with an added IRQ remapping
>>>> feature.
>>>
>>> I do not understand x86 MSI interrupt generation, but If above understand
>> is correct, then why we need IRQ remapping for x86?
>> To me x86 IR corresponds simply corresponds to the ITS MSI controller
>> modality on ARM. So as you still need vITS along with virtio-iommu on ARM,
>> you need vIRQ alongs with virtio-iommu on Intel. Does that make sense?
>>
>> So in any case we need to make sure the guest uses a vITS or vIR to make
>> sure MSIs are correctly isolated.
>>
>>
>>> Will the x86 machine emulated in QEMU provides a big address range for
>> MSIs and when actually generating MSI it needed some extra processing
>> (IRQ-remapping processing) before actually generating write transaction for
>> MSI interrupt ?
>> My understanding is on x86, the MSI window is fixed and matches
>> [FEE0_0000h – FEF0_000h]. MSIs are conveyed on a separate address space
>> than usual DMA accesses. And yes they end up in IR if supported in the HW.
>>
>> Thanks
>>
>> Eric
>>>
>>> Thanks
>>> -Bharat
>>>
>>>>
>>>> Thanks,
>>>> Jean

  reply	other threads:[~2017-07-07  7:26 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-07 16:01 [Qemu-devel] [RFC v2 0/8] VIRTIO-IOMMU device Eric Auger
2017-06-07 16:01 ` [Qemu-devel] [RFC v2 1/8] update-linux-headers: import virtio_iommu.h Eric Auger
2017-06-07 16:01 ` [Qemu-devel] [RFC v2 2/8] linux-headers: Update for virtio-iommu Eric Auger
2017-06-07 16:01 ` [Qemu-devel] [RFC v2 3/8] virtio_iommu: add skeleton Eric Auger
2017-06-08 11:09   ` Bharat Bhushan
2017-06-23 16:08     ` Jean-Philippe Brucker
2017-06-07 16:01 ` [Qemu-devel] [RFC v2 4/8] virtio-iommu: Decode the command payload Eric Auger
2017-06-07 16:01 ` [Qemu-devel] [RFC v2 5/8] virtio_iommu: Add the iommu regions Eric Auger
2017-06-12  5:59   ` Bharat Bhushan
2017-06-07 16:01 ` [Qemu-devel] [RFC v2 6/8] virtio-iommu: Implement the translation and commands Eric Auger
2017-06-23 16:09   ` Jean-Philippe Brucker
2017-07-04  9:13   ` Bharat Bhushan
2017-07-05  6:40     ` Auger Eric
2017-07-14  2:17   ` Peter Xu
2017-07-14  6:40     ` Bharat Bhushan
2017-07-17  1:28       ` Peter Xu
2017-07-31 13:08         ` Auger Eric
2017-08-03 10:48           ` Bharat Bhushan
2017-07-14 11:25     ` Jean-Philippe Brucker
2017-07-17  1:37       ` Peter Xu
2017-06-07 16:01 ` [Qemu-devel] [RFC v2 7/8] hw/arm/virt: Add 2.10 machine type Eric Auger
2017-06-07 16:01 ` [Qemu-devel] [RFC v2 8/8] hw/arm/virt: Add virtio-iommu the virt board Eric Auger
2017-06-09  6:16 ` [Qemu-devel] [RFC v2 0/8] VIRTIO-IOMMU device Bharat Bhushan
2017-06-09  6:43   ` Auger Eric
2017-06-09 11:30     ` Bharat Bhushan
2017-06-09 11:53       ` Auger Eric
2017-06-19  7:54         ` Bharat Bhushan
2017-06-19 10:15           ` Jean-Philippe Brucker
2017-06-26  8:22             ` Auger Eric
2017-06-26 16:13               ` Jean-Philippe Brucker
2017-06-27  6:38                 ` Auger Eric
2017-06-27  8:46                   ` Will Deacon
2017-06-27  8:59                     ` Auger Eric
2017-07-05  7:25                 ` Tian, Kevin
2017-07-05 12:44                   ` Jean-Philippe Brucker
2017-07-05  7:14             ` Tian, Kevin
2017-07-05 12:44               ` Jean-Philippe Brucker
2017-07-07  6:21                 ` Tian, Kevin
2017-07-07 15:15                   ` Jean-Philippe Brucker
2017-07-14  7:20                     ` Tian, Kevin
2017-07-14 11:25                       ` Jean-Philippe Brucker
2017-07-17  2:20                         ` Tian, Kevin
2017-07-05  7:15             ` Bharat Bhushan
2017-06-26  7:54           ` Auger Eric
2017-07-05  8:23             ` Bharat Bhushan
2017-07-05  8:44               ` Auger Eric
2017-07-05  8:49                 ` Bharat Bhushan
2017-07-06 10:02                   ` Jean-Philippe Brucker
2017-07-06 11:24                     ` Bharat Bhushan
2017-07-06 11:55                       ` Jean-Philippe Brucker
2017-07-06 21:16                       ` Auger Eric
2017-07-06 23:23                         ` [Qemu-devel] [Qemu-arm] " Kalra, Ashish
2017-07-06 23:29                           ` Michael S. Tsirkin
2017-07-06 23:33                           ` Tian, Kevin
2017-07-07 15:14                             ` Jean-Philippe Brucker
2017-07-07 22:11                               ` Kalra, Ashish
2017-07-11 11:31                                 ` Jean-Philippe Brucker
2017-07-14  6:58                               ` Tian, Kevin
2017-07-07  6:25                         ` [Qemu-devel] " Bharat Bhushan
2017-07-07  7:25                           ` Auger Eric [this message]
2017-07-07 11:36                             ` Bharat Bhushan
2017-07-07 15:19                               ` Jean-Philippe Brucker
2017-07-11  5:54                                 ` Bharat Bhushan
2017-07-11 12:51                                   ` Jean-Philippe Brucker
2017-07-12  3:50                                     ` Bharat Bhushan
2017-07-12 10:18                                       ` Jean-Philippe Brucker
2017-07-12 10:27                                         ` Bharat Bhushan
2017-07-12 10:58                                           ` Jean-Philippe Brucker
2017-07-12 11:12                                             ` Bharat Bhushan
2017-07-06 21:11                     ` Auger Eric
2017-07-07  7:31                       ` Auger Eric
2017-07-07 15:20                       ` Jean-Philippe Brucker
2017-06-09 12:15       ` Auger Eric

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a67cb139-e1b6-02fc-d451-4001bcbfceb3@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=bharat.bhushan@nxp.com \
    --cc=christoffer.dall@linaro.org \
    --cc=drjones@redhat.com \
    --cc=eric.auger.pro@gmail.com \
    --cc=jean-philippe.brucker@arm.com \
    --cc=kevin.tian@intel.com \
    --cc=marc.zyngier@arm.com \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=robin.murphy@arm.com \
    --cc=tn@semihalf.com \
    --cc=wei@redhat.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.