<div dir="ltr">Now in my staging branch, sorry.<div><br></div><div>Ross</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 21 December 2016 at 07:01, He Zhe <span dir="ltr"><<a href="mailto:zhe.he@windriver.com" target="_blank">zhe.he@windriver.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ping.<br>
<span class="HOEnZb"><font color="#888888"><br>
Zhe<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On 11/29/2016 05:56 PM, <a href="mailto:zhe.he@windriver.com">zhe.he@windriver.com</a> wrote:<br>
> From: He Zhe <<a href="mailto:zhe.he@windriver.com">zhe.he@windriver.com</a>><br>
><br>
> Fix iommu pci device assignment failure.<br>
><br>
> "qemu-system-x86_64: -device pci-assign,host=02:00.0: No IOMMU found.<br>
> Unable to assign device "(null)""<br>
><br>
> Signed-off-by: He Zhe <<a href="mailto:zhe.he@windriver.com">zhe.he@windriver.com</a>><br>
> ---<br>
> ...sync-MSI-MSI-X-cap-and-<wbr>table-with-PCIDevi.patch | 71 ++++++++++++++++++++++<br>
> meta/recipes-devtools/qemu/<a href="http://qemu_2.7.0.bb" rel="noreferrer" target="_blank">qem<wbr>u_2.7.0.bb</a> | 1 +<br>
> 2 files changed, 72 insertions(+)<br>
> create mode 100644 meta/recipes-devtools/qemu/<wbr>qemu/0001-pci-assign-sync-MSI-<wbr>MSI-X-cap-and-table-with-<wbr>PCIDevi.patch<br>
><br>
> diff --git a/meta/recipes-devtools/qemu/<wbr>qemu/0001-pci-assign-sync-MSI-<wbr>MSI-X-cap-and-table-with-<wbr>PCIDevi.patch b/meta/recipes-devtools/qemu/<wbr>qemu/0001-pci-assign-sync-MSI-<wbr>MSI-X-cap-and-table-with-<wbr>PCIDevi.patch<br>
> new file mode 100644<br>
> index 0000000..03472dd<br>
> --- /dev/null<br>
> +++ b/meta/recipes-devtools/qemu/<wbr>qemu/0001-pci-assign-sync-MSI-<wbr>MSI-X-cap-and-table-with-<wbr>PCIDevi.patch<br>
> @@ -0,0 +1,71 @@<br>
> +From 6baa545df93253fced4fc0d52b14b9<wbr>8447e00473 Mon Sep 17 00:00:00 2001<br>
> +From: Peter Xu <<a href="mailto:peterx@redhat.com">peterx@redhat.com</a>><br>
> +Date: Mon, 28 Nov 2016 15:02:44 +0800<br>
> +Subject: [PATCH] pci-assign: sync MSI/MSI-X cap and table with PCIDevice<br>
> +<br>
> +Since commit e1d4fb2d ("kvm-irqchip: x86: add msi route notify fn"),<br>
> +kvm_irqchip_add_msi_route() starts to use pci_get_msi_message() to fetch<br>
> +MSI info. This requires that we setup MSI related fields in PCIDevice.<br>
> +For most devices, that won't be a problem, as long as we are using<br>
> +general interfaces like msi_init()/msix_init().<br>
> +<br>
> +However, for pci-assign devices, MSI/MSI-X is treated differently - PCI<br>
> +assign devices are maintaining its own MSI table and cap information in<br>
> +AssignedDevice struct. however that's not synced up with PCIDevice's<br>
> +fields. That will leads to pci_get_msi_message() failed to find correct<br>
> +MSI capability, even with an NULL msix_table.<br>
> +<br>
> +A quick fix is to sync up the two places: both the capability bits and<br>
> +table address for MSI/MSI-X.<br>
> +<br>
> +Upstream-Status: Backport [<a href="https://lists.gnu.org/archive/html/qemu-devel/2016-11/msg04649.html" rel="noreferrer" target="_blank">https://lists.gnu.org/<wbr>archive/html/qemu-devel/2016-<wbr>11/msg04649.html</a>]<br>
> +<br>
> +Reported-by: Changlimin <address@hidden><br>
> +Tested-by: Changlimin <address@hidden><br>
> +Cc: address@hidden<br>
> +Fixes: e1d4fb2d ("kvm-irqchip: x86: add msi route notify fn")<br>
> +Signed-off-by: Peter Xu <address@hidden><br>
> +Signed-off-by: He Zhe <<a href="mailto:zhe.he@windriver.com">zhe.he@windriver.com</a>><br>
> +---<br>
> + hw/i386/kvm/pci-assign.c | 4 ++++<br>
> + 1 file changed, 4 insertions(+)<br>
> +<br>
> +diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c<br>
> +index 8238fbc..87dcbdd 100644<br>
> +--- a/hw/i386/kvm/pci-assign.c<br>
> ++++ b/hw/i386/kvm/pci-assign.c<br>
> +@@ -1251,6 +1251,7 @@ static int assigned_device_pci_cap_init(<wbr>PCIDevice *pci_dev, Error **errp)<br>
> + error_propagate(errp, local_err);<br>
> + return -ENOTSUP;<br>
> + }<br>
> ++ dev->dev.cap_present |= QEMU_PCI_CAP_MSI;<br>
> + dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI;<br>
> + /* Only 32-bit/no-mask currently supported */<br>
> + ret = pci_add_capability2(pci_dev, PCI_CAP_ID_MSI, pos, 10,<br>
> +@@ -1285,6 +1286,7 @@ static int assigned_device_pci_cap_init(<wbr>PCIDevice *pci_dev, Error **errp)<br>
> + error_propagate(errp, local_err);<br>
> + return -ENOTSUP;<br>
> + }<br>
> ++ dev->dev.cap_present |= QEMU_PCI_CAP_MSIX;<br>
> + dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX;<br>
> + ret = pci_add_capability2(pci_dev, PCI_CAP_ID_MSIX, pos, 12,<br>
> + &local_err);<br>
> +@@ -1648,6 +1650,7 @@ static void assigned_dev_register_msix_<wbr>mmio(AssignedDevice *dev, Error **errp)<br>
> + dev->msix_table = NULL;<br>
> + return;<br>
> + }<br>
> ++ dev->dev.msix_table = (uint8_t *)dev->msix_table;<br>
> +<br>
> + assigned_dev_msix_reset(dev);<br>
> +<br>
> +@@ -1665,6 +1668,7 @@ static void assigned_dev_unregister_msix_<wbr>mmio(AssignedDevice *dev)<br>
> + error_report("error unmapping msix_table! %s", strerror(errno));<br>
> + }<br>
> + dev->msix_table = NULL;<br>
> ++ dev->dev.msix_table = NULL;<br>
> + }<br>
> +<br>
> + static const VMStateDescription vmstate_assigned_device = {<br>
> +--<br>
> +2.8.3<br>
> +<br>
> diff --git a/meta/recipes-devtools/qemu/<a href="http://qemu_2.7.0.bb" rel="noreferrer" target="_blank">q<wbr>emu_2.7.0.bb</a> b/meta/recipes-devtools/qemu/<a href="http://qemu_2.7.0.bb" rel="noreferrer" target="_blank">q<wbr>emu_2.7.0.bb</a><br>
> index cef181d..9da5134 100644<br>
> --- a/meta/recipes-devtools/qemu/<a href="http://qemu_2.7.0.bb" rel="noreferrer" target="_blank">q<wbr>emu_2.7.0.bb</a><br>
> +++ b/meta/recipes-devtools/qemu/<a href="http://qemu_2.7.0.bb" rel="noreferrer" target="_blank">q<wbr>emu_2.7.0.bb</a><br>
> @@ -13,6 +13,7 @@ SRC_URI += "file://configure-fix-Darwin-<wbr>target-detection.patch \<br>
> file://0002-fix-CVE-2016-7423.<wbr>patch \<br>
> file://0003-fix-CVE-2016-7908.<wbr>patch \<br>
> file://0004-fix-CVE-2016-7909.<wbr>patch \<br>
> + file://0001-pci-assign-sync-<wbr>MSI-MSI-X-cap-and-table-with-<wbr>PCIDevi.patch \<br>
> "<br>
><br>
> SRC_URI_prepend = "<a href="http://wiki.qemu-project.org/download/${BP}.tar.bz2" rel="noreferrer" target="_blank">http://wiki.qemu-project.org/<wbr>download/${BP}.tar.bz2</a>"<br>
<br>
--<br>
</div></div><div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
Openembedded-core mailing list<br>
<a href="mailto:Openembedded-core@lists.openembedded.org">Openembedded-core@lists.<wbr>openembedded.org</a><br>
<a href="http://lists.openembedded.org/mailman/listinfo/openembedded-core" rel="noreferrer" target="_blank">http://lists.openembedded.org/<wbr>mailman/listinfo/openembedded-<wbr>core</a><br>
</div></div></blockquote></div><br></div>