Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/908460/?format=api
{ "id": 908460, "url": "http://patchwork.ozlabs.org/api/patches/908460/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20180504030811.28111-2-peterx@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20180504030811.28111-2-peterx@redhat.com>", "list_archive_url": null, "date": "2018-05-04T03:08:02", "name": "[v2,01/10] intel-iommu: send PSI always even if across PDEs", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "f2d8101a80039daad4c3b5c9e089473cf688d488", "submitter": { "id": 67717, "url": "http://patchwork.ozlabs.org/api/people/67717/?format=api", "name": "Peter Xu", "email": "peterx@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20180504030811.28111-2-peterx@redhat.com/mbox/", "series": [ { "id": 42502, "url": "http://patchwork.ozlabs.org/api/series/42502/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=42502", "date": "2018-05-04T03:08:01", "name": "intel-iommu: nested vIOMMU, cleanups, bug fixes", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/42502/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/908460/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/908460/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=redhat.com" ], "Received": [ "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 40ccS41YBbz9s35\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 4 May 2018 13:09:24 +1000 (AEST)", "from localhost ([::1]:60163 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1fER61-0001Ww-MT\n\tfor incoming@patchwork.ozlabs.org; Thu, 03 May 2018 23:09:21 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:33160)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <peterx@redhat.com>) id 1fER5E-0001VX-Ln\n\tfor qemu-devel@nongnu.org; Thu, 03 May 2018 23:08:33 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <peterx@redhat.com>) id 1fER5D-0005In-Kg\n\tfor qemu-devel@nongnu.org; Thu, 03 May 2018 23:08:32 -0400", "from mx3-rdu2.redhat.com ([66.187.233.73]:48244\n\thelo=mx1.redhat.com)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <peterx@redhat.com>) id 1fER5D-0005IY-F7\n\tfor qemu-devel@nongnu.org; Thu, 03 May 2018 23:08:31 -0400", "from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 25C6140858CD;\n\tFri, 4 May 2018 03:08:31 +0000 (UTC)", "from xz-mi.redhat.com (ovpn-12-46.pek2.redhat.com [10.72.12.46])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 1E1B9111762B;\n\tFri, 4 May 2018 03:08:27 +0000 (UTC)" ], "From": "Peter Xu <peterx@redhat.com>", "To": "qemu-devel@nongnu.org", "Date": "Fri, 4 May 2018 11:08:02 +0800", "Message-Id": "<20180504030811.28111-2-peterx@redhat.com>", "In-Reply-To": "<20180504030811.28111-1-peterx@redhat.com>", "References": "<20180504030811.28111-1-peterx@redhat.com>", "X-Scanned-By": "MIMEDefang 2.78 on 10.11.54.3", "X-Greylist": [ "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.5]);\n\tFri, 04 May 2018 03:08:31 +0000 (UTC)", "inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.5]); \n\tFri, 04 May 2018 03:08:31 +0000 (UTC) for IP:'10.11.54.3'\n\tDOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com'\n\tHELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:''" ], "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]", "X-Received-From": "66.187.233.73", "Subject": "[Qemu-devel] [PATCH v2 01/10] intel-iommu: send PSI always even if\n\tacross PDEs", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.21", "Precedence": "list", "List-Id": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Cc": "Tian Kevin <kevin.tian@intel.com>, \"Michael S . Tsirkin\" <mst@redhat.com>,\n\tJason Wang <jasowang@redhat.com>, peterx@redhat.com,\n\tAlex Williamson <alex.williamson@redhat.com>,\n\tJintack Lim <jintack@cs.columbia.edu>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "During IOVA page table walking, there is a special case when the PSI\ncovers one whole PDE (Page Directory Entry, which contains 512 Page\nTable Entries) or more. In the past, we skip that entry and we don't\nnotify the IOMMU notifiers. This is not correct. We should send UNMAP\nnotification to registered UNMAP notifiers in this case.\n\nFor UNMAP only notifiers, this might cause IOTLBs cached in the devices\neven if they were already invalid. For MAP/UNMAP notifiers like\nvfio-pci, this will cause stale page mappings.\n\nThis special case doesn't trigger often, but it is very easy to be\ntriggered by nested device assignments, since in that case we'll\npossibly map the whole L2 guest RAM region into the device's IOVA\naddress space (several GBs at least), which is far bigger than normal\nkernel driver usages of the device (tens of MBs normally).\n\nWithout this patch applied to L1 QEMU, nested device assignment to L2\nguests will dump some errors like:\n\nqemu-system-x86_64: VFIO_MAP_DMA: -17\nqemu-system-x86_64: vfio_dma_map(0x557305420c30, 0xad000, 0x1000,\n 0x7f89a920d000) = -17 (File exists)\n\nAcked-by: Jason Wang <jasowang@redhat.com>\n[peterx: rewrite the commit message]\nSigned-off-by: Peter Xu <peterx@redhat.com>\n---\n hw/i386/intel_iommu.c | 42 ++++++++++++++++++++++++++++++------------\n 1 file changed, 30 insertions(+), 12 deletions(-)", "diff": "diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c\nindex fb31de9416..b359efd6f9 100644\n--- a/hw/i386/intel_iommu.c\n+++ b/hw/i386/intel_iommu.c\n@@ -722,6 +722,15 @@ static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write,\n \n typedef int (*vtd_page_walk_hook)(IOMMUTLBEntry *entry, void *private);\n \n+static int vtd_page_walk_one(IOMMUTLBEntry *entry, int level,\n+ vtd_page_walk_hook hook_fn, void *private)\n+{\n+ assert(hook_fn);\n+ trace_vtd_page_walk_one(level, entry->iova, entry->translated_addr,\n+ entry->addr_mask, entry->perm);\n+ return hook_fn(entry, private);\n+}\n+\n /**\n * vtd_page_walk_level - walk over specific level for IOVA range\n *\n@@ -781,28 +790,37 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,\n */\n entry_valid = read_cur | write_cur;\n \n+ entry.target_as = &address_space_memory;\n+ entry.iova = iova & subpage_mask;\n+ entry.perm = IOMMU_ACCESS_FLAG(read_cur, write_cur);\n+ entry.addr_mask = ~subpage_mask;\n+\n if (vtd_is_last_slpte(slpte, level)) {\n- entry.target_as = &address_space_memory;\n- entry.iova = iova & subpage_mask;\n /* NOTE: this is only meaningful if entry_valid == true */\n entry.translated_addr = vtd_get_slpte_addr(slpte, aw);\n- entry.addr_mask = ~subpage_mask;\n- entry.perm = IOMMU_ACCESS_FLAG(read_cur, write_cur);\n if (!entry_valid && !notify_unmap) {\n trace_vtd_page_walk_skip_perm(iova, iova_next);\n goto next;\n }\n- trace_vtd_page_walk_one(level, entry.iova, entry.translated_addr,\n- entry.addr_mask, entry.perm);\n- if (hook_fn) {\n- ret = hook_fn(&entry, private);\n- if (ret < 0) {\n- return ret;\n- }\n+ ret = vtd_page_walk_one(&entry, level, hook_fn, private);\n+ if (ret < 0) {\n+ return ret;\n }\n } else {\n if (!entry_valid) {\n- trace_vtd_page_walk_skip_perm(iova, iova_next);\n+ if (notify_unmap) {\n+ /*\n+ * The whole entry is invalid; unmap it all.\n+ * Translated address is meaningless, zero it.\n+ */\n+ entry.translated_addr = 0x0;\n+ ret = vtd_page_walk_one(&entry, level, hook_fn, private);\n+ if (ret < 0) {\n+ return ret;\n+ }\n+ } else {\n+ trace_vtd_page_walk_skip_perm(iova, iova_next);\n+ }\n goto next;\n }\n ret = vtd_page_walk_level(vtd_get_slpte_addr(slpte, aw), iova,\n", "prefixes": [ "v2", "01/10" ] }