[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [Qemu-devel] [RFC PATCH 02/10] vfio: Generalize vfio_list
From: |
Thomas Huth |
Subject: |
Re: [Qemu-ppc] [Qemu-devel] [RFC PATCH 02/10] vfio: Generalize vfio_listener_region_add failure path |
Date: |
Wed, 23 Sep 2015 11:13:21 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 17/09/15 15:09, David Gibson wrote:
> If a DMA mapping operation fails in vfio_listener_region_add() it
> checks to see if we've already completed initial setup of the
> container. If so it reports an error so the setup code can fail
> gracefully, otherwise throws a hw_error().
>
> There are other potential failure cases in vfio_listener_region_add()
> which could benefit from the same logic, so move it to its own
> fail: block. Later patches can use this to extend other failure cases
> to fail as gracefully as possible under the circumstances.
>
> Signed-off-by: David Gibson <address@hidden>
> ---
> hw/vfio/common.c | 26 +++++++++++++++-----------
> 1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index e3152f6..9953b9c 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -400,19 +400,23 @@ static void vfio_listener_region_add(MemoryListener
> *listener,
> error_report("vfio_dma_map(%p, 0x%"HWADDR_PRIx", "
> "0x%"HWADDR_PRIx", %p) = %d (%m)",
> container, iova, end - iova, vaddr, ret);
> + goto fail;
> + }
>
> - /*
> - * On the initfn path, store the first error in the container so we
> - * can gracefully fail. Runtime, there's not much we can do other
> - * than throw a hardware error.
> - */
> - if (!container->iommu_data.initialized) {
> - if (!container->iommu_data.error) {
> - container->iommu_data.error = ret;
> - }
> - } else {
> - hw_error("vfio: DMA mapping failed, unable to continue");
> + return;
> +
> +fail:
> + /*
> + * On the initfn path, store the first error in the container so we
> + * can gracefully fail. Runtime, there's not much we can do other
> + * than throw a hardware error.
> + */
> + if (!container->iommu_data.initialized) {
> + if (!container->iommu_data.error) {
> + container->iommu_data.error = ret;
> }
> + } else {
> + hw_error("vfio: DMA mapping failed, unable to continue");
> }
> }
Reviewed-by: Thomas Huth <address@hidden>
- Re: [Qemu-ppc] [Qemu-devel] [RFC PATCH 07/10] spapr_pci: Allow PCI host bridge DMA window to be configured, (continued)
[Qemu-ppc] [RFC PATCH 09/10] spapr_iommu: Provide a function to switch a TCE table to allowing VFIO, David Gibson, 2015/09/17
[Qemu-ppc] [RFC PATCH 02/10] vfio: Generalize vfio_listener_region_add failure path, David Gibson, 2015/09/17
[Qemu-ppc] [RFC PATCH 05/10] memory: Allow replay of IOMMU mapping notifications, David Gibson, 2015/09/17
[Qemu-ppc] [RFC PATCH 06/10] vfio: Allow hotplug of containers onto existing guest IOMMU mappings, David Gibson, 2015/09/17