From: Eric Farman <farman@linux.ibm.com>
To: Matthew Rosato <mjrosato@linux.ibm.com>, qemu-s390x@nongnu.org
Cc: pmorel@linux.ibm.com, schnelle@linux.ibm.com, cohuck@redhat.com,
thuth@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com,
richard.henderson@linaro.org, david@redhat.com,
qemu-devel@nongnu.org
Subject: Re: [PATCH 3/3] s390x/pci: shrink DMA aperture to be bound by vfio DMA limit
Date: Fri, 04 Nov 2022 12:08:33 -0400 [thread overview]
Message-ID: <72949a8eae1a19c1a4023d47678e59ba815d16c4.camel@linux.ibm.com> (raw)
In-Reply-To: <20221028194758.204007-4-mjrosato@linux.ibm.com>
On Fri, 2022-10-28 at 15:47 -0400, Matthew Rosato wrote:
> Currently, s390x-pci performs accounting against the vfio DMA
> limit and triggers the guest to clean up mappings when the limit
> is reached. Let's go a step further and also limit the size of
> the supported DMA aperture reported to the guest based upon the
> initial vfio DMA limit reported for the container (if less than
> than the size reported by the firmware/host zPCI layer). This
> avoids processing sections of the guest DMA table during global
> refresh that, for common use cases, will never be used anway, and
> makes exhausting the vfio DMA limit due to mismatch between guest
> aperture size and host limit far less likely and more indicitive
> of an error.
>
> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
> ---
> hw/s390x/s390-pci-vfio.c | 11 +++++++++++
> include/hw/s390x/s390-pci-bus.h | 1 +
> 2 files changed, 12 insertions(+)
>
> diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c
> index 2aefa508a0..99806e2a84 100644
> --- a/hw/s390x/s390-pci-vfio.c
> +++ b/hw/s390x/s390-pci-vfio.c
> @@ -84,6 +84,7 @@ S390PCIDMACount
> *s390_pci_start_dma_count(S390pciState *s,
> cnt->users = 1;
> cnt->avail = avail;
> QTAILQ_INSERT_TAIL(&s->zpci_dma_limit, cnt, link);
> + pbdev->iommu->max_dma_limit = avail;
> return cnt;
> }
>
> @@ -103,6 +104,7 @@ static void s390_pci_read_base(S390PCIBusDevice
> *pbdev,
> struct vfio_info_cap_header *hdr;
> struct vfio_device_info_cap_zpci_base *cap;
> VFIOPCIDevice *vpci = container_of(pbdev->pdev, VFIOPCIDevice,
> pdev);
> + uint64_t vfio_size;
>
> hdr = vfio_get_device_info_cap(info,
> VFIO_DEVICE_INFO_CAP_ZPCI_BASE);
>
> @@ -122,6 +124,15 @@ static void s390_pci_read_base(S390PCIBusDevice
> *pbdev,
> /* The following values remain 0 until we support other FMB
> formats */
> pbdev->zpci_fn.fmbl = 0;
> pbdev->zpci_fn.pft = 0;
> +
> + /*
> + * If appropriate, reduce the size of the supported DMA aperture
> reported
> + * to the guest based upon the vfio DMA limit.
> + */
> + vfio_size = pbdev->iommu->max_dma_limit << TARGET_PAGE_BITS;
> + if (vfio_size < (cap->end_dma - cap->start_dma + 1)) {
> + pbdev->zpci_fn.edma = cap->start_dma + vfio_size - 1;
> + }
> }
>
> static bool get_host_fh(S390PCIBusDevice *pbdev, struct
> vfio_device_info *info,
> diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-
> pci-bus.h
> index 0605fcea24..1c46e3a269 100644
> --- a/include/hw/s390x/s390-pci-bus.h
> +++ b/include/hw/s390x/s390-pci-bus.h
> @@ -278,6 +278,7 @@ struct S390PCIIOMMU {
> uint64_t g_iota;
> uint64_t pba;
> uint64_t pal;
> + uint64_t max_dma_limit;
> GHashTable *iotlb;
> S390PCIDMACount *dma_limit;
> };
next prev parent reply other threads:[~2022-11-04 16:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-28 19:47 [PATCH 0/3] s390x/pci: rpcit fixes and enhancements Matthew Rosato
2022-10-28 19:47 ` [PATCH 1/3] s390x/pci: RPCIT second pass when mappings exhausted Matthew Rosato
2022-11-04 15:50 ` Eric Farman
2022-10-28 19:47 ` [PATCH 2/3] s390x/pci: coalesce unmap operations Matthew Rosato
2022-11-04 16:01 ` Eric Farman
2022-10-28 19:47 ` [PATCH 3/3] s390x/pci: shrink DMA aperture to be bound by vfio DMA limit Matthew Rosato
2022-11-04 16:08 ` Eric Farman [this message]
2022-12-12 8:37 ` [PATCH 0/3] s390x/pci: rpcit fixes and enhancements Thomas Huth
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=72949a8eae1a19c1a4023d47678e59ba815d16c4.camel@linux.ibm.com \
--to=farman@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=mjrosato@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=pmorel@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=schnelle@linux.ibm.com \
--cc=thuth@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).