Message ID | 20230201125328.2186498-1-jean-philippe@linaro.org (mailing list archive) |
---|---|
Headers | show |
Series | KVM: Arm SMMUv3 driver for pKVM | expand |
> From: Jean-Philippe Brucker <jean-philippe@linaro.org> > Sent: Wednesday, February 1, 2023 8:53 PM > > 3. Private I/O page tables > > A flexible alternative uses private page tables in the SMMU, entirely > disconnected from the CPU page tables. With this the SMMU can implement > a > reduced set of features, even shed a stage of translation. This also > provides a virtual I/O address space to the host, which allows more > efficient memory allocation for large buffers, and for devices with > limited addressing abilities. > > This is the solution implemented in this series. The host creates > IOVA->HPA mappings with two hypercalls map_pages() and unmap_pages(), > and > the hypervisor populates the page tables. Page tables are abstracted into > IOMMU domains, which allow multiple devices to share the same address > space. Another four hypercalls, alloc_domain(), attach_dev(), detach_dev() > and free_domain(), manage the domains. > Out of curiosity. Does virtio-iommu fit in this usage? If yes then there is no need to add specific enlightenment in existing iommu drivers. If no probably because as mentioned in the start a full-fledged iommu driver doesn't fit nVHE so lots of smmu driver logic has to be kept in the host? anyway just want to check your thoughts on the possibility. btw some of my colleagues are porting pKVM to Intel platform. I believe they will post their work shortly and there might require some common framework in pKVM hypervisor like iommu domain, hypercalls, etc. like what we have in the host iommu subsystem. CC them in case of any early thought they want to throw in.
On Thu, Feb 02, 2023 at 07:07:55AM +0000, Tian, Kevin wrote: > > From: Jean-Philippe Brucker <jean-philippe@linaro.org> > > Sent: Wednesday, February 1, 2023 8:53 PM > > > > 3. Private I/O page tables > > > > A flexible alternative uses private page tables in the SMMU, entirely > > disconnected from the CPU page tables. With this the SMMU can implement > > a > > reduced set of features, even shed a stage of translation. This also > > provides a virtual I/O address space to the host, which allows more > > efficient memory allocation for large buffers, and for devices with > > limited addressing abilities. > > > > This is the solution implemented in this series. The host creates > > IOVA->HPA mappings with two hypercalls map_pages() and unmap_pages(), > > and > > the hypervisor populates the page tables. Page tables are abstracted into > > IOMMU domains, which allow multiple devices to share the same address > > space. Another four hypercalls, alloc_domain(), attach_dev(), detach_dev() > > and free_domain(), manage the domains. > > > > Out of curiosity. Does virtio-iommu fit in this usage? I don't think so, because you still need a driver for the physical IOMMU in the hypervisor. virtio-iommu would only replace the hypercall interface with queues, and I don't think that buys us anything. Maybe virtio on the guest side could be advantageous, because that interface has to be stable and virtio comes with stable APIs for several classes of devices. But implementing virtio in pkvm means a lot of extra code so it needs to be considered carefully. > If yes then there is > no need to add specific enlightenment in existing iommu drivers. If no > probably because as mentioned in the start a full-fledged iommu driver > doesn't fit nVHE so lots of smmu driver logic has to be kept in the host? To minimize the attack surface of the hypervisor, we don't want to load any superfluous code, so the hypervisor part of the SMMUv3 driver only contains code to populate tables and send commands (which is still too much for my taste but seems unavoidable to isolate host DMA). Left in the host are things like ACPI/DT parser, interrupts, possibly the event queue (which informs of DMA errors), extra features and complex optimizations. The host also has to implement IOMMU ops to liaise between the DMA API and the hypervisor. > anyway just want to check your thoughts on the possibility. > > btw some of my colleagues are porting pKVM to Intel platform. I believe > they will post their work shortly and there might require some common > framework in pKVM hypervisor like iommu domain, hypercalls, etc. like > what we have in the host iommu subsystem. CC them in case of any early > thought they want to throw in.
> From: Jean-Philippe Brucker <jean-philippe@linaro.org> > Sent: Thursday, February 2, 2023 6:05 PM > > On Thu, Feb 02, 2023 at 07:07:55AM +0000, Tian, Kevin wrote: > > > From: Jean-Philippe Brucker <jean-philippe@linaro.org> > > > Sent: Wednesday, February 1, 2023 8:53 PM > > > > > > 3. Private I/O page tables > > > > > > A flexible alternative uses private page tables in the SMMU, entirely > > > disconnected from the CPU page tables. With this the SMMU can > implement > > > a > > > reduced set of features, even shed a stage of translation. This also > > > provides a virtual I/O address space to the host, which allows more > > > efficient memory allocation for large buffers, and for devices with > > > limited addressing abilities. > > > > > > This is the solution implemented in this series. The host creates > > > IOVA->HPA mappings with two hypercalls map_pages() and > unmap_pages(), > > > and > > > the hypervisor populates the page tables. Page tables are abstracted into > > > IOMMU domains, which allow multiple devices to share the same > address > > > space. Another four hypercalls, alloc_domain(), attach_dev(), > detach_dev() > > > and free_domain(), manage the domains. > > > > > > > Out of curiosity. Does virtio-iommu fit in this usage? > > I don't think so, because you still need a driver for the physical IOMMU > in the hypervisor. virtio-iommu would only replace the hypercall interface > with queues, and I don't think that buys us anything. > > Maybe virtio on the guest side could be advantageous, because that > interface has to be stable and virtio comes with stable APIs for several > classes of devices. But implementing virtio in pkvm means a lot of extra > code so it needs to be considered carefully. > this makes sense. > > If yes then there is > > no need to add specific enlightenment in existing iommu drivers. If no > > probably because as mentioned in the start a full-fledged iommu driver > > doesn't fit nVHE so lots of smmu driver logic has to be kept in the host? > > To minimize the attack surface of the hypervisor, we don't want to load > any superfluous code, so the hypervisor part of the SMMUv3 driver only > contains code to populate tables and send commands (which is still too > much for my taste but seems unavoidable to isolate host DMA). Left in the > host are things like ACPI/DT parser, interrupts, possibly the event queue > (which informs of DMA errors), extra features and complex optimizations. > The host also has to implement IOMMU ops to liaise between the DMA API > and > the hypervisor. > > > anyway just want to check your thoughts on the possibility. > > > > btw some of my colleagues are porting pKVM to Intel platform. I believe > > they will post their work shortly and there might require some common > > framework in pKVM hypervisor like iommu domain, hypercalls, etc. like > > what we have in the host iommu subsystem. CC them in case of any early > > thought they want to throw in.
> -----Original Message----- > From: Tian, Kevin <kevin.tian@intel.com> > Sent: Friday, February 3, 2023 10:05 AM > To: Jean-Philippe Brucker <jean-philippe@linaro.org> > Cc: maz@kernel.org; catalin.marinas@arm.com; will@kernel.org; > joro@8bytes.org; robin.murphy@arm.com; james.morse@arm.com; > suzuki.poulose@arm.com; oliver.upton@linux.dev; yuzenghui@huawei.com; > smostafa@google.com; dbrazdil@google.com; ryan.roberts@arm.com; linux- > arm-kernel@lists.infradead.org; kvmarm@lists.linux.dev; > iommu@lists.linux.dev; Chen, Jason CJ <jason.cj.chen@intel.com>; Zhang, > Tina <tina.zhang@intel.com> > Subject: RE: [RFC PATCH 00/45] KVM: Arm SMMUv3 driver for pKVM > > > From: Jean-Philippe Brucker <jean-philippe@linaro.org> > > Sent: Thursday, February 2, 2023 6:05 PM > > > > On Thu, Feb 02, 2023 at 07:07:55AM +0000, Tian, Kevin wrote: > > > > From: Jean-Philippe Brucker <jean-philippe@linaro.org> > > > > Sent: Wednesday, February 1, 2023 8:53 PM > > > > > > > > 3. Private I/O page tables > > > > > > > > A flexible alternative uses private page tables in the SMMU, > > > > entirely disconnected from the CPU page tables. With this the SMMU > > > > can > > implement > > > > a > > > > reduced set of features, even shed a stage of translation. This > > > > also provides a virtual I/O address space to the host, which > > > > allows more efficient memory allocation for large buffers, and for > > > > devices with limited addressing abilities. > > > > > > > > This is the solution implemented in this series. The host creates > > > > IOVA->HPA mappings with two hypercalls map_pages() and > > unmap_pages(), > > > > and > > > > the hypervisor populates the page tables. Page tables are > > > > abstracted into IOMMU domains, which allow multiple devices to > > > > share the same > > address > > > > space. Another four hypercalls, alloc_domain(), attach_dev(), > > detach_dev() > > > > and free_domain(), manage the domains. > > > > > > > > > > Out of curiosity. Does virtio-iommu fit in this usage? > > > > I don't think so, because you still need a driver for the physical > > IOMMU in the hypervisor. virtio-iommu would only replace the hypercall > > interface with queues, and I don't think that buys us anything. > > > > Maybe virtio on the guest side could be advantageous, because that > > interface has to be stable and virtio comes with stable APIs for > > several classes of devices. But implementing virtio in pkvm means a > > lot of extra code so it needs to be considered carefully. > > > > this makes sense. > > > > If yes then there is > > > no need to add specific enlightenment in existing iommu drivers. If > > > no probably because as mentioned in the start a full-fledged iommu > > > driver doesn't fit nVHE so lots of smmu driver logic has to be kept in the > host? > > > > To minimize the attack surface of the hypervisor, we don't want to > > load any superfluous code, so the hypervisor part of the SMMUv3 driver > > only contains code to populate tables and send commands (which is > > still too much for my taste but seems unavoidable to isolate host > > DMA). Left in the host are things like ACPI/DT parser, interrupts, > > possibly the event queue (which informs of DMA errors), extra features > and complex optimizations. > > The host also has to implement IOMMU ops to liaise between the DMA API > > and the hypervisor. > > > > > anyway just want to check your thoughts on the possibility. > > > > > > btw some of my colleagues are porting pKVM to Intel platform. I > > > believe they will post their work shortly and there might require > > > some common framework in pKVM hypervisor like iommu domain, > > > hypercalls, etc. like what we have in the host iommu subsystem. CC > > > them in case of any early thought they want to throw in.
Hi Jason, On Fri, Feb 03, 2023 at 08:39:41AM +0000, Chen, Jason CJ wrote: > > > > btw some of my colleagues are porting pKVM to Intel platform. I > > > > believe they will post their work shortly and there might require > > > > some common framework in pKVM hypervisor like iommu domain, > > > > hypercalls, etc. like what we have in the host iommu subsystem. CC > > > > them in case of any early thought they want to throw in.
Hi, Jean, Thanks for the information! Let's do more investigation. Yes, if using enlighten method, we may skip nested translation. Meantime we shall ensure host not touch this capability. We may also need trade-off to support SVM kind features. Thanks Jason > -----Original Message----- > From: Jean-Philippe Brucker <jean-philippe@linaro.org> > Sent: Friday, February 3, 2023 7:24 PM > To: Chen, Jason CJ <jason.cj.chen@intel.com> > Cc: Tian, Kevin <kevin.tian@intel.com>; maz@kernel.org; > catalin.marinas@arm.com; will@kernel.org; joro@8bytes.org; > robin.murphy@arm.com; james.morse@arm.com; > suzuki.poulose@arm.com; oliver.upton@linux.dev; yuzenghui@huawei.com; > smostafa@google.com; dbrazdil@google.com; ryan.roberts@arm.com; > linux-arm-kernel@lists.infradead.org; kvmarm@lists.linux.dev; > iommu@lists.linux.dev; Zhang, Tina <tina.zhang@intel.com> > Subject: Re: [RFC PATCH 00/45] KVM: Arm SMMUv3 driver for pKVM > > Hi Jason, > > On Fri, Feb 03, 2023 at 08:39:41AM +0000, Chen, Jason CJ wrote: > > > > > btw some of my colleagues are porting pKVM to Intel platform. I > > > > > believe they will post their work shortly and there might > > > > > require some common framework in pKVM hypervisor like iommu > > > > > domain, hypercalls, etc. like what we have in the host iommu > > > > > subsystem. CC them in case of any early thought they want to > > > > > throw in.
On 2/4/23 16:19, Chen, Jason CJ wrote: > Hi, Jean, > > Thanks for the information! Let's do more investigation. > > Yes, if using enlighten method, we may skip nested translation. Meantime we > shall ensure host not touch this capability. We may also need trade-off to support > SVM kind features. Hi Jason, Nested translation is also optional to vt-d. Not all IA platforms could have vt-d with nested translation support. For those legacy platforms (e.g. on which vt-d doesn't support scalable mode), providing an enlightened way for pKVM to isolate DMA seems reasonable. Otherwise, pKVM may need to shadow io-page table which could introduce performance overhead. Regards, -Tina > > Thanks > > Jason > >> -----Original Message----- >> From: Jean-Philippe Brucker <jean-philippe@linaro.org> >> Sent: Friday, February 3, 2023 7:24 PM >> To: Chen, Jason CJ <jason.cj.chen@intel.com> >> Cc: Tian, Kevin <kevin.tian@intel.com>; maz@kernel.org; >> catalin.marinas@arm.com; will@kernel.org; joro@8bytes.org; >> robin.murphy@arm.com; james.morse@arm.com; >> suzuki.poulose@arm.com; oliver.upton@linux.dev; yuzenghui@huawei.com; >> smostafa@google.com; dbrazdil@google.com; ryan.roberts@arm.com; >> linux-arm-kernel@lists.infradead.org; kvmarm@lists.linux.dev; >> iommu@lists.linux.dev; Zhang, Tina <tina.zhang@intel.com> >> Subject: Re: [RFC PATCH 00/45] KVM: Arm SMMUv3 driver for pKVM >> >> Hi Jason, >> >> On Fri, Feb 03, 2023 at 08:39:41AM +0000, Chen, Jason CJ wrote: >>>>>> btw some of my colleagues are porting pKVM to Intel platform. I >>>>>> believe they will post their work shortly and there might >>>>>> require some common framework in pKVM hypervisor like iommu >>>>>> domain, hypercalls, etc. like what we have in the host iommu >>>>>> subsystem. CC them in case of any early thought they want to >>>>>> throw in.