From: Alex Williamson <alex.williamson@redhat.com>
To: Zhi Wang <zhi.a.wang@intel.com>
Cc: qemu-devel@nongnu.org, kevin.tian@intel.com,
daniel.vetter@ffwll.ch, joonas.lahtinen@linux.intel.com,
zhenyuw@linux.intel.com, zhiyuan.lv@intel.com,
chuanxiao.dong@intel.com, xiong.y.zhang@intel.com
Subject: Re: [Qemu-devel] [RFC 2/6] vfio: Setup IGD quirks earlier
Date: Thu, 1 Jun 2017 14:34:02 -0600 [thread overview]
Message-ID: <20170601143402.50ff86a5@w520.home> (raw)
In-Reply-To: <1496079043-26694-3-git-send-email-zhi.a.wang@intel.com>
On Tue, 30 May 2017 01:30:32 +0800
Zhi Wang <zhi.a.wang@intel.com> wrote:
> Initialize IGD quirks a bit earlier since we're going to support IGD
> stolen memory under both primary mode (legacy mode) and secondary mode
> and we need one extra memory region from IGD quirks.
>
> Suggested-by: Xiong Zhang <xiong.y.zhang@intel.com>
> Signed-off-by: Zhi Wang <zhi.a.wang@intel.com>
> ---
> hw/vfio/pci-quirks.c | 30 +++++++++++++++++-------------
> 1 file changed, 17 insertions(+), 13 deletions(-)
>
> diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
> index 71360ef..e0a0c13 100644
> --- a/hw/vfio/pci-quirks.c
> +++ b/hw/vfio/pci-quirks.c
> @@ -1395,6 +1395,14 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
>
> gen = info->gen;
>
> + /* Setup our quirk to munge GTT addresses to the VM allocated buffer */
> + quirk = g_malloc0(sizeof(*quirk));
> + igd = quirk->data = g_malloc0(sizeof(*igd));
> + igd->vdev = vdev;
> + igd->index = ~0;
> + igd->bdsm = vfio_pci_read_config(&vdev->pdev, IGD_BDSM, 4);
> + igd->bdsm &= ~((1 << 20) - 1); /* 1MB aligned */
> +
This patch does not stand on its own, we alloc memory and setup a few
things earlier, but there are numerous returns before we get to the
next chunk below. So the most obvious result of this patch alone is
that it introduces a memory leak. Thanks,
Alex
> /*
> * We need to create an LPC/ISA bridge at PCI bus address 00:1f.0 that we
> * can stuff host values into, so if there's already one there and it's not
> @@ -1502,23 +1510,19 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)
> goto out;
> }
>
> - /* Setup our quirk to munge GTT addresses to the VM allocated buffer */
> - quirk = g_malloc0(sizeof(*quirk));
> - quirk->mem = g_new0(MemoryRegion, 2);
> - quirk->nr_mem = 2;
> - igd = quirk->data = g_malloc0(sizeof(*igd));
> - igd->vdev = vdev;
> - igd->index = ~0;
> - igd->bdsm = vfio_pci_read_config(&vdev->pdev, IGD_BDSM, 4);
> - igd->bdsm &= ~((1 << 20) - 1); /* 1MB aligned */
> + quirk->mem = g_renew(MemoryRegion, quirk->mem, 2);
> +
> + memory_region_init_io(&quirk->mem[quirk->nr_mem++], OBJECT(vdev),
> + &vfio_igd_index_quirk, igd, "vfio-igd-index-quirk",
> + 4);
>
> - memory_region_init_io(&quirk->mem[0], OBJECT(vdev), &vfio_igd_index_quirk,
> - igd, "vfio-igd-index-quirk", 4);
> memory_region_add_subregion_overlap(vdev->bars[nr].region.mem,
> 0, &quirk->mem[0], 1);
>
> - memory_region_init_io(&quirk->mem[1], OBJECT(vdev), &vfio_igd_data_quirk,
> - igd, "vfio-igd-data-quirk", 4);
> + memory_region_init_io(&quirk->mem[quirk->nr_mem++], OBJECT(vdev),
> + &vfio_igd_data_quirk, igd, "vfio-igd-data-quirk",
> + 4);
> +
> memory_region_add_subregion_overlap(vdev->bars[nr].region.mem,
> 4, &quirk->mem[1], 1);
>
next prev parent reply other threads:[~2017-06-01 20:34 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-29 17:30 [Qemu-devel] [RFC 0/6] Refine IGD stolen memory support in VFIO Zhi Wang
2017-05-29 8:29 ` Zhi Wang
2017-05-31 22:13 ` Wang, Zhi A
2017-05-29 8:43 ` no-reply
2017-05-29 8:45 ` no-reply
2017-05-29 8:50 ` no-reply
2017-05-29 17:30 ` [Qemu-devel] [RFC 1/6] vfio: Add Intel platform definitions Zhi Wang
2017-05-29 17:30 ` [Qemu-devel] [RFC 2/6] vfio: Setup IGD quirks earlier Zhi Wang
2017-06-01 20:34 ` Alex Williamson [this message]
2017-05-29 17:30 ` [Qemu-devel] [RFC 3/6] vfio: Setup IGD stolen memory Zhi Wang
2017-06-01 21:10 ` Alex Williamson
2017-05-29 17:30 ` [Qemu-devel] [RFC 4/6] vfio: Refine GGTT clearing Zhi Wang
2017-05-29 17:30 ` [Qemu-devel] [RFC 5/6] vfio: Remove extra quirks and old definitions Zhi Wang
2017-05-29 17:30 ` [Qemu-devel] [RFC 6/6] vfio: Setup IGD stolen memory under secondary mode Zhi Wang
2017-05-29 17:30 ` [Qemu-devel] [RFC 0/6] Refine IGD stolen memory support in VFIO Zhi Wang
2017-06-01 2:52 ` Tian, Kevin
2017-05-29 17:30 ` [Qemu-devel] [RFC 1/6] vfio: Add Intel platform definitions Zhi Wang
2017-06-01 20:22 ` Alex Williamson
2017-05-29 17:30 ` [Qemu-devel] [RFC 2/6] vfio: Setup IGD quirks earlier Zhi Wang
2017-05-29 17:30 ` [Qemu-devel] [RFC 3/6] vfio: Setup IGD stolen memory Zhi Wang
2017-05-29 17:30 ` [Qemu-devel] [RFC 4/6] vfio: Refine GGTT clearing Zhi Wang
2017-05-29 17:30 ` [Qemu-devel] [RFC 5/6] vfio: Remove extra quirks and old definitions Zhi Wang
2017-05-29 17:30 ` [Qemu-devel] [RFC 6/6] vfio: Setup IGD stolen memory under secondary mode Zhi Wang
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=20170601143402.50ff86a5@w520.home \
--to=alex.williamson@redhat.com \
--cc=chuanxiao.dong@intel.com \
--cc=daniel.vetter@ffwll.ch \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kevin.tian@intel.com \
--cc=qemu-devel@nongnu.org \
--cc=xiong.y.zhang@intel.com \
--cc=zhenyuw@linux.intel.com \
--cc=zhi.a.wang@intel.com \
--cc=zhiyuan.lv@intel.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).