Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/2234209/?format=api
{ "id": 2234209, "url": "http://patchwork.ozlabs.org/api/1.2/patches/2234209/?format=api", "web_url": "http://patchwork.ozlabs.org/project/kvm-riscv/patch/20260507113706.11400-8-fangyu.yu@linux.alibaba.com/", "project": { "id": 70, "url": "http://patchwork.ozlabs.org/api/1.2/projects/70/?format=api", "name": "Linux KVM RISC-V", "link_name": "kvm-riscv", "list_id": "kvm-riscv.lists.infradead.org", "list_email": "kvm-riscv@lists.infradead.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "http://lists.infradead.org/pipermail/kvm-riscv/", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260507113706.11400-8-fangyu.yu@linux.alibaba.com>", "list_archive_url": null, "date": "2026-05-07T11:37:03", "name": "[RFC,v2,07/10] iommu/riscv: Add domain_alloc_paging_flags for second-stage domain", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "a07baa55e39c9873a4a8492ce8286480776974f8", "submitter": { "id": 91416, "url": "http://patchwork.ozlabs.org/api/1.2/people/91416/?format=api", "name": null, "email": "fangyu.yu@linux.alibaba.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/kvm-riscv/patch/20260507113706.11400-8-fangyu.yu@linux.alibaba.com/mbox/", "series": [ { "id": 503164, "url": "http://patchwork.ozlabs.org/api/1.2/series/503164/?format=api", "web_url": "http://patchwork.ozlabs.org/project/kvm-riscv/list/?series=503164", "date": "2026-05-07T11:36:57", "name": "iommu/riscv: Add hardware dirty tracking for second-stage domains", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/503164/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2234209/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2234209/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=lists.infradead.org header.i=@lists.infradead.org\n header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Cca1vHLP;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256\n header.s=desiato.20200630 header.b=UOPhfgNh;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com\n header.a=rsa-sha256 header.s=default header.b=LIp0wB84;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=none (no SPF record) smtp.mailfrom=lists.infradead.org\n (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org;\n envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from bombadil.infradead.org (bombadil.infradead.org\n [IPv6:2607:7c80:54:3::133])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4gB9Gb5dSZz1yKd\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 07 May 2026 21:37:43 +1000 (AEST)", "from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux))\n\tid 1wKx2z-00000003ex1-3Tcc;\n\tThu, 07 May 2026 11:37:41 +0000", "from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05])\n\tby bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux))\n\tid 1wKx2y-00000003euK-2bUi;\n\tThu, 07 May 2026 11:37:40 +0000", "from out30-133.freemail.mail.aliyun.com ([115.124.30.133])\n\tby desiato.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux))\n\tid 1wKx2t-00000003MzE-1DTZ;\n\tThu, 07 May 2026 11:37:39 +0000", "from localhost.localdomain(mailfrom:fangyu.yu@linux.alibaba.com\n fp:SMTPD_---0X2UVF1L_1778153840 cluster:ay36)\n by smtp.aliyun-inc.com;\n Thu, 07 May 2026 19:37:21 +0800" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20210309; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=ajcdFYiazD54pqTgFRBHJvfryzUUPATZYTtK/zJnI3M=; b=Cca1vHLPd/yfqB\n\t0/9OsEmIZOVRK9gccOG445ZIQr/mPLsG/qgg5XD7Sa1hSoE4LteI0wMHzLe/NmDT5HDCkaJYV8aRz\n\tksU/kphl8udWG/hDLEajaXrf68sNzh3315fLXObGaq1Jo2Bn9a3/zz+dK4qLxHAnkCZ7OmTZrETfd\n\tuOviOPcj8BjxXtJpyLgmmFPw0VdtA48PDXexB2lFlX4QhPkSXEEicfiz3NFx9HfGWOzTpa0TlfTcw\n\t0nBOBpEKvzIDmb+RumPsJ54L1tx5PKVc8FolHIlQ9K1REyGcLwMyNeN65kpZiUXY9x4zLHt7DdLDr\n\tEDMdqdbyv2899SznLMgQ==;", "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version\n\t:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:\n\tContent-Type:Content-ID:Content-Description;\n\tbh=E95HEUv+RbcOdtj9NlIbuNX1uhYBJ2+6cETCe8Jytbc=; b=UOPhfgNh/Zv4c/hSxN78r/mONL\n\tq1NXpidKVGim7LG0FaLZyvRkX9ONdpsR/9Vtnh72ysJW1t9qKYJ2/HmoU1toQy3C5r+vnzmSF1GPh\n\tfRQbIjhWWAl/SDz665vAzcyt45nqrjpdkdor3WsYkU7EwtXuW24T9gOIC2fHxlwIhgSPweJh8p4AH\n\t2R+0rhQw6ZgNSSQrQG0huo1rG0wD4fgsJApZYOkXF8Hboz4y/4fGZAV3ygzj0QXyA/8+ornXIeTBM\n\tFJmdnosRUZOjYgrSVjJuYQfSk3TvdpN7dTwgtKSHr+NbyyostkYHqWe9CUBsHR4PzH7DAtYiduo7M\n\tCImXXBvg==;", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linux.alibaba.com; s=default;\n\tt=1778153843; h=From:To:Subject:Date:Message-Id:MIME-Version;\n\tbh=E95HEUv+RbcOdtj9NlIbuNX1uhYBJ2+6cETCe8Jytbc=;\n\tb=LIp0wB842VwYXNykg3LzL+cSLtQFHJ/rPPmgLW6WdtO/C9mzVgzpaqHOfoq11IMfNXlYusEEUKuXo8mAFPZtuV8hcPpyML6jlKMYTeFiXQixG2hrmmuo85Pm4M0Hi/MjUjuy26nFDdRMNO5lXCXRHezQGRUSYaaklhOt9p0HmI0=" ], "X-Alimail-AntiSpam": "\n AC=PASS;BC=-1|-1;BR=01201311R261e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037026112;MF=fangyu.yu@linux.alibaba.com;NM=1;PH=DS;RN=24;SR=0;TI=SMTPD_---0X2UVF1L_1778153840;", "From": "fangyu.yu@linux.alibaba.com", "To": "joro@8bytes.org,\n\twill@kernel.org,\n\trobin.murphy@arm.com,\n\tpjw@kernel.org,\n\tpalmer@dabbelt.com,\n\taou@eecs.berkeley.edu,\n\talex@ghiti.fr,\n\ttjeznach@rivosinc.com,\n\tjgg@ziepe.ca,\n\tkevin.tian@intel.com,\n\tbaolu.lu@linux.intel.com,\n\tvasant.hegde@amd.com,\n\tanup@brainfault.org,\n\tatish.patra@linux.dev,\n\tskhawaja@google.com,\n\tjgg@nvidia.com", "Cc": "guoren@kernel.org,\n\tandrew.jones@oss.qualcomm.com,\n\tkvm@vger.kernel.org,\n\tiommu@lists.linux.dev,\n\tkvm-riscv@lists.infradead.org,\n\tlinux-riscv@lists.infradead.org,\n\tlinux-kernel@vger.kernel.org,\n\tFangyu Yu <fangyu.yu@linux.alibaba.com>", "Subject": "[RFC PATCH v2 07/10] iommu/riscv: Add domain_alloc_paging_flags for\n second-stage domain", "Date": "Thu, 7 May 2026 19:37:03 +0800", "Message-Id": "<20260507113706.11400-8-fangyu.yu@linux.alibaba.com>", "X-Mailer": "git-send-email 2.39.3 (Apple Git-146)", "In-Reply-To": "<20260507113706.11400-1-fangyu.yu@linux.alibaba.com>", "References": "<20260507113706.11400-1-fangyu.yu@linux.alibaba.com>", "MIME-Version": "1.0", "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 ", "X-CRM114-CacheID": "sfid-20260507_123736_312663_9ADFBD8E ", "X-CRM114-Status": "GOOD ( 13.93 )", "X-Spam-Score": "-15.7 (---------------)", "X-Spam-Report": "Spam detection software,\n running on the system \"desiato.infradead.org\",\n has NOT identified this incoming email as spam. The original\n message has been attached to this so you can view it or label\n similar future email. If you have any questions, see\n the administrator of that system for details.\n Content preview: From: Fangyu Yu <fangyu.yu@linux.alibaba.com> Replace\n .domain_alloc_paging\n with .domain_alloc_paging_flags so callers can pass allocation flags to\n select\n the appropriate page-table type. When IOMMU_HWPT_ALLOC_NEST_PARENT or\n IOMMU_HWPT_ALLOC_DIRTY_TRACKING\n is set in @flags, allocate a second-stage (iohgatp) domain.\n Content analysis details: (-15.7 points, 5.0 required)\n pts rule name description\n ---- ----------------------\n --------------------------------------------------\n -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no\n trust\n [115.124.30.133 listed in list.dnswl.org]\n 0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2)\n [115.124.30.133 listed in wl.mailspike.net]\n -7.5 USER_IN_DEF_SPF_WL From: address is in the default SPF welcome-list\n -0.0 SPF_PASS SPF: sender matches SPF record\n 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record\n -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM welcome-list\n -0.1 DKIM_VALID Message has at least one valid DKIM or DK\n signature\n -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n author's\n domain\n 0.1 DKIM_SIGNED Message has a DKIM or DK signature,\n not necessarily valid\n -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from\n envelope-from domain\n -0.5 ENV_AND_HDR_SPF_MATCH Env and Hdr From used in default SPF WL Match\n 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay\n lines\n -0.0 DMARC_PASS DMARC pass policy", "X-BeenThere": "kvm-riscv@lists.infradead.org", "X-Mailman-Version": "2.1.34", "Precedence": "list", "List-Id": "<kvm-riscv.lists.infradead.org>", "List-Unsubscribe": "<http://lists.infradead.org/mailman/options/kvm-riscv>,\n <mailto:kvm-riscv-request@lists.infradead.org?subject=unsubscribe>", "List-Archive": "<http://lists.infradead.org/pipermail/kvm-riscv/>", "List-Post": "<mailto:kvm-riscv@lists.infradead.org>", "List-Help": "<mailto:kvm-riscv-request@lists.infradead.org?subject=help>", "List-Subscribe": "<http://lists.infradead.org/mailman/listinfo/kvm-riscv>,\n <mailto:kvm-riscv-request@lists.infradead.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Sender": "\"kvm-riscv\" <kvm-riscv-bounces@lists.infradead.org>", "Errors-To": "kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org" }, "content": "From: Fangyu Yu <fangyu.yu@linux.alibaba.com>\n\nReplace .domain_alloc_paging with .domain_alloc_paging_flags so callers\ncan pass allocation flags to select the appropriate page-table type.\n\nWhen IOMMU_HWPT_ALLOC_NEST_PARENT or IOMMU_HWPT_ALLOC_DIRTY_TRACKING is\nset in @flags, allocate a second-stage (iohgatp) domain.\n\nWhen @flags is 0 the behaviour is identical to the previous\ndomain_alloc_paging: first-stage (iosatp) domain.\n\nSigned-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>\n---\n drivers/iommu/riscv/iommu.c | 90 +++++++++++++++++++++++++++----------\n 1 file changed, 67 insertions(+), 23 deletions(-)", "diff": "diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c\nindex e883ace2f4f1..ebf42f74e194 100644\n--- a/drivers/iommu/riscv/iommu.c\n+++ b/drivers/iommu/riscv/iommu.c\n@@ -1255,25 +1255,21 @@ static const struct iommu_domain_ops riscv_iommu_paging_domain_ops = {\n \t.flush_iotlb_all = riscv_iommu_iotlb_flush_all,\n };\n \n-static struct iommu_domain *riscv_iommu_alloc_paging_domain(struct device *dev)\n+static struct iommu_domain *riscv_iommu_domain_alloc_paging_flags(\n+\t\tstruct device *dev, u32 flags,\n+\t\tconst struct iommu_user_data *user_data)\n {\n \tstruct pt_iommu_riscv_64_cfg cfg = {};\n \tstruct riscv_iommu_domain *domain;\n \tstruct riscv_iommu_device *iommu;\n \tint ret;\n+\tconst u32 supported_flags = IOMMU_HWPT_ALLOC_DIRTY_TRACKING |\n+\t\t\t\t IOMMU_HWPT_ALLOC_NEST_PARENT;\n \n-\tiommu = dev_to_iommu(dev);\n-\tif (iommu->caps & RISCV_IOMMU_CAPABILITIES_SV57) {\n-\t\tcfg.common.hw_max_vasz_lg2 = 57;\n-\t} else if (iommu->caps & RISCV_IOMMU_CAPABILITIES_SV48) {\n-\t\tcfg.common.hw_max_vasz_lg2 = 48;\n-\t} else if (iommu->caps & RISCV_IOMMU_CAPABILITIES_SV39) {\n-\t\tcfg.common.hw_max_vasz_lg2 = 39;\n-\t} else {\n-\t\tdev_err(dev, \"cannot find supported page table mode\\n\");\n-\t\treturn ERR_PTR(-ENODEV);\n-\t}\n-\tcfg.common.hw_max_oasz_lg2 = 56;\n+\tif (flags & ~supported_flags)\n+\t\treturn ERR_PTR(-EOPNOTSUPP);\n+\tif (user_data)\n+\t\treturn ERR_PTR(-EOPNOTSUPP);\n \n \tdomain = kzalloc_obj(*domain);\n \tif (!domain)\n@@ -1281,6 +1277,8 @@ static struct iommu_domain *riscv_iommu_alloc_paging_domain(struct device *dev)\n \n \tINIT_LIST_HEAD_RCU(&domain->bonds);\n \tspin_lock_init(&domain->lock);\n+\tiommu = dev_to_iommu(dev);\n+\tcfg.common.hw_max_oasz_lg2 = 56;\n \t/*\n \t * 6.4 IOMMU capabilities [..] IOMMU implementations must support the\n \t * Svnapot standard extension for NAPOT Translation Contiguity.\n@@ -1291,19 +1289,65 @@ static struct iommu_domain *riscv_iommu_alloc_paging_domain(struct device *dev)\n \tdomain->riscvpt.iommu.nid = dev_to_node(iommu->dev);\n \tdomain->domain.ops = &riscv_iommu_paging_domain_ops;\n \n-\tdomain->pscid = ida_alloc_range(&riscv_iommu_pscids, 1,\n-\t\t\t\t\tRISCV_IOMMU_MAX_PSCID, GFP_KERNEL);\n-\tif (domain->pscid < 0) {\n-\t\triscv_iommu_free_paging_domain(&domain->domain);\n-\t\treturn ERR_PTR(-ENOMEM);\n+\tswitch (flags) {\n+\tcase 0:\n+\t\tif (iommu->caps & RISCV_IOMMU_CAPABILITIES_SV57) {\n+\t\t\tcfg.common.hw_max_vasz_lg2 = 57;\n+\t\t} else if (iommu->caps & RISCV_IOMMU_CAPABILITIES_SV48) {\n+\t\t\tcfg.common.hw_max_vasz_lg2 = 48;\n+\t\t} else if (iommu->caps & RISCV_IOMMU_CAPABILITIES_SV39) {\n+\t\t\tcfg.common.hw_max_vasz_lg2 = 39;\n+\t\t} else {\n+\t\t\tret = -ENODEV;\n+\t\t\tgoto err_free;\n+\t\t}\n+\t\tdomain->pscid = ida_alloc_range(&riscv_iommu_pscids, 1,\n+\t\t\t\t\t\tRISCV_IOMMU_MAX_PSCID, GFP_KERNEL);\n+\t\tif (domain->pscid < 0) {\n+\t\t\tret = -ENOMEM;\n+\t\t\tgoto err_free;\n+\t\t}\n+\t\tbreak;\n+\tcase IOMMU_HWPT_ALLOC_NEST_PARENT:\n+\tcase IOMMU_HWPT_ALLOC_DIRTY_TRACKING:\n+\tcase IOMMU_HWPT_ALLOC_DIRTY_TRACKING | IOMMU_HWPT_ALLOC_NEST_PARENT:\n+\t\t/*\n+\t\t * Second-stage (iohgatp) page table for KVM VFIO device\n+\t\t * pass-through and dirty tracking. The GPA space is 2 bits\n+\t\t * wider than the corresponding first-stage VA space (x4 root\n+\t\t * page table), so hw_max_vasz_lg2 values are 41/50/59.\n+\t\t */\n+\t\tif (iommu->caps & RISCV_IOMMU_CAPABILITIES_SV57X4) {\n+\t\t\tcfg.common.hw_max_vasz_lg2 = 59;\n+\t\t} else if (iommu->caps & RISCV_IOMMU_CAPABILITIES_SV48X4) {\n+\t\t\tcfg.common.hw_max_vasz_lg2 = 50;\n+\t\t} else if (iommu->caps & RISCV_IOMMU_CAPABILITIES_SV39X4) {\n+\t\t\tcfg.common.hw_max_vasz_lg2 = 41;\n+\t\t} else {\n+\t\t\tret = -ENODEV;\n+\t\t\tgoto err_free;\n+\t\t}\n+\t\tdomain->gscid = ida_alloc_range(&riscv_iommu_gscids, 1,\n+\t\t\t\t\t\tRISCV_IOMMU_MAX_GSCID, GFP_KERNEL);\n+\t\tif (domain->gscid < 0) {\n+\t\t\tret = -ENOMEM;\n+\t\t\tgoto err_free;\n+\t\t}\n+\t\tcfg.common.features |= BIT(PT_FEAT_RISCV_S2);\n+\t\tbreak;\n+\tdefault:\n+\t\tret = -EOPNOTSUPP;\n+\t\tgoto err_free;\n \t}\n \n \tret = pt_iommu_riscv_64_init(&domain->riscvpt, &cfg, GFP_KERNEL);\n-\tif (ret) {\n-\t\triscv_iommu_free_paging_domain(&domain->domain);\n-\t\treturn ERR_PTR(ret);\n-\t}\n+\tif (ret)\n+\t\tgoto err_free;\n \treturn &domain->domain;\n+\n+err_free:\n+\triscv_iommu_free_paging_domain(&domain->domain);\n+\treturn ERR_PTR(ret);\n }\n \n static int riscv_iommu_attach_blocking_domain(struct iommu_domain *iommu_domain,\n@@ -1438,7 +1482,7 @@ static const struct iommu_ops riscv_iommu_ops = {\n \t.identity_domain = &riscv_iommu_identity_domain,\n \t.blocked_domain = &riscv_iommu_blocking_domain,\n \t.release_domain = &riscv_iommu_blocking_domain,\n-\t.domain_alloc_paging = riscv_iommu_alloc_paging_domain,\n+\t.domain_alloc_paging_flags = riscv_iommu_domain_alloc_paging_flags,\n \t.device_group = riscv_iommu_device_group,\n \t.probe_device = riscv_iommu_probe_device,\n \t.release_device\t= riscv_iommu_release_device,\n", "prefixes": [ "RFC", "v2", "07/10" ] }