Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2217723/?format=api
{ "id": 2217723, "url": "http://patchwork.ozlabs.org/api/patches/2217723/?format=api", "web_url": "http://patchwork.ozlabs.org/project/kvm-riscv/patch/20260330122601.22140-5-fangyu.yu@linux.alibaba.com/", "project": { "id": 70, "url": "http://patchwork.ozlabs.org/api/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": "<20260330122601.22140-5-fangyu.yu@linux.alibaba.com>", "list_archive_url": null, "date": "2026-03-30T12:26:01", "name": "[v6,4/4] RISC-V: KVM: add KVM_CAP_RISCV_SET_HGATP_MODE", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "4d346ab7b4d958c23911b22f74597c840e9bdaee", "submitter": { "id": 91416, "url": "http://patchwork.ozlabs.org/api/people/91416/?format=api", "name": null, "email": "fangyu.yu@linux.alibaba.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/kvm-riscv/patch/20260330122601.22140-5-fangyu.yu@linux.alibaba.com/mbox/", "series": [ { "id": 498017, "url": "http://patchwork.ozlabs.org/api/series/498017/?format=api", "web_url": "http://patchwork.ozlabs.org/project/kvm-riscv/list/?series=498017", "date": "2026-03-30T12:25:57", "name": "Support runtime configuration for per-VM's HGATP mode", "version": 6, "mbox": "http://patchwork.ozlabs.org/series/498017/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2217723/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2217723/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=dEr/qXIA;\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=RQ4NShaa;\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 4fkr8m0lp6z1yG8\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 30 Mar 2026 23:26:48 +1100 (AEDT)", "from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1w7Bhe-0000000BFnB-0glN;\n\tMon, 30 Mar 2026 12:26:46 +0000", "from out30-118.freemail.mail.aliyun.com ([115.124.30.118])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1w7BhY-0000000BFjj-3tPR;\n\tMon, 30 Mar 2026 12:26:43 +0000", "from localhost.localdomain(mailfrom:fangyu.yu@linux.alibaba.com\n fp:SMTPD_---0X.zfcJd_1774873592 cluster:ay36)\n by smtp.aliyun-inc.com;\n Mon, 30 Mar 2026 20:26:33 +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=tcc5exAPDW7fxURGKFMrBn6e/iBLYG4S0Nxg+a9X1Ig=; b=dEr/qXIA2d2YkJ\n\t0ArhubsZCYqc8r43/rdq+drWGXTK9maYCa3kaKayTPBLWNO4P8rOCFDDOBkhuoKf8V0XofLe1Fni2\n\t28wJDHxVYaIC+wvqYgI5H5rqyZ9m0GFf90lmceOfu83ExUSrYIqlJlSuXrkKRgVlVvg8HN7LzNYSP\n\tqOl2A+iPnYfOTdUUJr2kPNlC7n3/iR+SvzmyvLefK9i82hpsdJNfLe4eny36qK6IX9nVXFSJrHFsM\n\thcbUH+ybSq/74Yd7RKb+umEFVxtU+23WAhIQySFj22+SfqSfnAt6DPrRu3f0RBKHMFnldxm685dF4\n\tZCHaYRCA1mdZeqgNgQ5w==;", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linux.alibaba.com; s=default;\n\tt=1774873594; h=From:To:Subject:Date:Message-Id:MIME-Version;\n\tbh=hFPV9OZsT6eJowdta/xFZt6DIyl+vW5qGVBuswXMeAQ=;\n\tb=RQ4NShaaFF6YWBT8WReqoqRHaXoEIIFRIUCxenVvXr3Eb1qmRxEtoxvqE7GCS96Xt8VQVpKomNwgwJAuTpNvkFZ+QfMyr4f/DR0VHDyPBGSCg9C9liaDbuUFLFQRrh+xuHeKamCm3MQdN4CJCclysQSy5uxx/enQDYs10Ts6tsY=" ], "X-Alimail-AntiSpam": "\n AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037033178;MF=fangyu.yu@linux.alibaba.com;NM=1;PH=DS;RN=18;SR=0;TI=SMTPD_---0X.zfcJd_1774873592;", "From": "fangyu.yu@linux.alibaba.com", "To": "pbonzini@redhat.com,\n\tcorbet@lwn.net,\n\tanup@brainfault.org,\n\tatish.patra@linux.dev,\n\tpjw@kernel.org,\n\tpalmer@dabbelt.com,\n\taou@eecs.berkeley.edu,\n\talex@ghiti.fr,\n\tskhan@linuxfoundation.org", "Cc": "guoren@kernel.org,\n\tradim.krcmar@oss.qualcomm.com,\n\tandrew.jones@oss.qualcomm.com,\n\tlinux-doc@vger.kernel.org,\n\tkvm@vger.kernel.org,\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": "[PATCH v6 4/4] RISC-V: KVM: add KVM_CAP_RISCV_SET_HGATP_MODE", "Date": "Mon, 30 Mar 2026 20:26:01 +0800", "Message-Id": "<20260330122601.22140-5-fangyu.yu@linux.alibaba.com>", "X-Mailer": "git-send-email 2.39.3 (Apple Git-146)", "In-Reply-To": "<20260330122601.22140-1-fangyu.yu@linux.alibaba.com>", "References": "<20260330122601.22140-1-fangyu.yu@linux.alibaba.com>", "MIME-Version": "1.0", "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ", "X-CRM114-CacheID": "sfid-20260330_052641_509022_53042CBE ", "X-CRM114-Status": "GOOD ( 15.85 )", "X-Spam-Score": "-14.6 (--------------)", "X-Spam-Report": "Spam detection software,\n running on the system \"bombadil.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> Add a VM\n capability\n that allows userspace to select the G-stage page table format by setting\n HGATP.MODE on a per-VM basis. Userspace enables the capability via\n KVM_ENABLE_CAP,\n passing the requested HGATP.MODE in args[0]. The request is rejected with\n -EINVAL if the mode is not supported by the host, and with -EBUSY if the\n [...]\n Content analysis details: (-14.6 points, 5.0 required)\n pts rule name description\n ---- ----------------------\n --------------------------------------------------\n -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM welcome-list\n -7.5 USER_IN_DEF_SPF_WL From: address is in the default SPF welcome-list\n 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record\n -0.0 SPF_PASS SPF: sender matches SPF record\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.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n author's\n domain\n -0.1 DKIM_VALID Message has at least one valid DKIM or DK\n signature\n -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%\n [score: 0.0000]\n 1.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The\n query to Validity was blocked. See\n https://knowledge.validity.com/hc/en-us/articles/20961730681243\n for more information.\n [115.124.30.118 listed in\n sa-trusted.bondedsender.org]\n 1.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to\n Validity was blocked. See\n https://knowledge.validity.com/hc/en-us/articles/20961730681243\n for more information.\n [115.124.30.118 listed in sa-accredit.habeas.com]\n -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no\n trust\n [115.124.30.118 listed in list.dnswl.org]\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 1.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to\n Validity was blocked. See\n https://knowledge.validity.com/hc/en-us/articles/20961730681243\n for more information.\n [115.124.30.118 listed in\n bl.score.senderscore.com]", "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\nAdd a VM capability that allows userspace to select the G-stage page table\nformat by setting HGATP.MODE on a per-VM basis.\n\nUserspace enables the capability via KVM_ENABLE_CAP, passing the requested\nHGATP.MODE in args[0]. The request is rejected with -EINVAL if the mode is\nnot supported by the host, and with -EBUSY if the VM has already been\ncommitted (e.g. vCPUs have been created or any memslot is populated).\n\nKVM_CHECK_EXTENSION(KVM_CAP_RISCV_SET_HGATP_MODE) returns a bitmask of the\nHGATP.MODE formats supported by the host.\n\nSigned-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>\nReviewed-by: Andrew Jones <andrew.jones@oss.qualcomm.com>\n---\n Documentation/virt/kvm/api.rst | 27 +++++++++++++++++++++++++++\n arch/riscv/kvm/vm.c | 18 ++++++++++++++++--\n include/uapi/linux/kvm.h | 1 +\n 3 files changed, 44 insertions(+), 2 deletions(-)", "diff": "diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst\nindex 032516783e96..9d7f6958fa81 100644\n--- a/Documentation/virt/kvm/api.rst\n+++ b/Documentation/virt/kvm/api.rst\n@@ -8902,6 +8902,33 @@ helpful if user space wants to emulate instructions which are not\n This capability can be enabled dynamically even if VCPUs were already\n created and are running.\n \n+7.47 KVM_CAP_RISCV_SET_HGATP_MODE\n+---------------------------------\n+\n+:Architectures: riscv\n+:Type: VM\n+:Parameters: args[0] contains the requested HGATP mode\n+:Returns:\n+ - 0 on success.\n+ - -EINVAL if args[0] is outside the range of HGATP modes supported by the\n+ hardware.\n+ - -EBUSY if vCPUs have already been created for the VM, if the VM has any\n+ non-empty memslots.\n+\n+This capability allows userspace to explicitly select the HGATP mode for\n+the VM. The selected mode must be supported by both KVM and hardware. This\n+capability must be enabled before creating any vCPUs or memslots.\n+\n+If this capability is not enabled, KVM will select the default HGATP mode\n+automatically. The default is the highest HGATP.MODE value supported by\n+hardware.\n+\n+``KVM_CHECK_EXTENSION(KVM_CAP_RISCV_SET_HGATP_MODE)`` returns a bitmask of\n+HGATP.MODE values supported by the host. A return value of 0 indicates that\n+the capability is not supported. Supported-mode bitmask use HGATP.MODE\n+encodings as defined by the RISC-V privileged specification, such as Sv39x4\n+corresponds to HGATP.MODE=8, so userspace should test bitmask & BIT(8).\n+\n 8. Other capabilities.\n ======================\n \ndiff --git a/arch/riscv/kvm/vm.c b/arch/riscv/kvm/vm.c\nindex 4d82a886102c..5e82a3ad3ad0 100644\n--- a/arch/riscv/kvm/vm.c\n+++ b/arch/riscv/kvm/vm.c\n@@ -201,6 +201,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)\n \tcase KVM_CAP_VM_GPA_BITS:\n \t\tr = kvm_riscv_gstage_gpa_bits(kvm->arch.pgd_levels);\n \t\tbreak;\n+\tcase KVM_CAP_RISCV_SET_HGATP_MODE:\n+\t\tr = kvm_riscv_get_hgatp_mode_mask();\n+\t\tbreak;\n \tdefault:\n \t\tr = 0;\n \t\tbreak;\n@@ -211,12 +214,23 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)\n \n int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)\n {\n+\tif (cap->flags)\n+\t\treturn -EINVAL;\n+\n \tswitch (cap->cap) {\n \tcase KVM_CAP_RISCV_MP_STATE_RESET:\n-\t\tif (cap->flags)\n-\t\t\treturn -EINVAL;\n \t\tkvm->arch.mp_state_reset = true;\n \t\treturn 0;\n+\tcase KVM_CAP_RISCV_SET_HGATP_MODE:\n+\t\tif (!kvm_riscv_hgatp_mode_is_valid(cap->args[0]))\n+\t\t\treturn -EINVAL;\n+\n+\t\tif (kvm->created_vcpus || !kvm_are_all_memslots_empty(kvm))\n+\t\t\treturn -EBUSY;\n+#ifdef CONFIG_64BIT\n+\t\tkvm->arch.pgd_levels = 3 + cap->args[0] - HGATP_MODE_SV39X4;\n+#endif\n+\t\treturn 0;\n \tdefault:\n \t\treturn -EINVAL;\n \t}\ndiff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h\nindex 80364d4dbebb..a74a80fd4046 100644\n--- a/include/uapi/linux/kvm.h\n+++ b/include/uapi/linux/kvm.h\n@@ -989,6 +989,7 @@ struct kvm_enable_cap {\n #define KVM_CAP_ARM_SEA_TO_USER 245\n #define KVM_CAP_S390_USER_OPEREXEC 246\n #define KVM_CAP_S390_KEYOP 247\n+#define KVM_CAP_RISCV_SET_HGATP_MODE 248\n \n struct kvm_irq_routing_irqchip {\n \t__u32 irqchip;\n", "prefixes": [ "v6", "4/4" ] }