{"id":2230118,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2230118/?format=json","web_url":"http://patchwork.ozlabs.org/project/kvm-riscv/patch/20260429173529259zFOx-ZsqSl_DS82KLXv0S@zte.com.cn/","project":{"id":70,"url":"http://patchwork.ozlabs.org/api/1.1/projects/70/?format=json","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":""},"msgid":"<20260429173529259zFOx-ZsqSl_DS82KLXv0S@zte.com.cn>","date":"2026-04-29T09:35:29","name":"[v2,1/3] RISC-V: KVM: Refactor kvm_arch_commit_memory_region()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"bca3f06e77ccfe19e22781fd76c3899d0415c0a3","submitter":{"id":91800,"url":"http://patchwork.ozlabs.org/api/1.1/people/91800/?format=json","name":"","email":"wang.yechao255@zte.com.cn"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/kvm-riscv/patch/20260429173529259zFOx-ZsqSl_DS82KLXv0S@zte.com.cn/mbox/","series":[{"id":502023,"url":"http://patchwork.ozlabs.org/api/1.1/series/502023/?format=json","web_url":"http://patchwork.ozlabs.org/project/kvm-riscv/list/?series=502023","date":"2026-04-29T09:30:02","name":"RISC-V: KVM: Huge page recovery during disable-dirty-log","version":2,"mbox":"http://patchwork.ozlabs.org/series/502023/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2230118/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2230118/checks/","tags":{},"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=1JKQ0xpz;\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 4g5BxV0bjRz1xqf\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 19:35:42 +1000 (AEST)","from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1wI1KW-00000003Lwo-27e4;\n\tWed, 29 Apr 2026 09:35:40 +0000","from mxct.zte.com.cn ([183.62.165.209])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1wI1KU-00000003LwM-2G5C;\n\tWed, 29 Apr 2026 09:35:39 +0000","from mse-fl1.zte.com.cn (unknown [10.5.228.132])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby mxct.zte.com.cn (FangMail) with ESMTPS id 4g5BxK0Pmgz510Y1;\n\tWed, 29 Apr 2026 17:35:33 +0800 (CST)","from szxl2zmapp05.zte.com.cn ([10.1.32.37])\n\tby mse-fl1.zte.com.cn with SMTP id 63T9ZQKw066185;\n\tWed, 29 Apr 2026 17:35:26 +0800 (+08)\n\t(envelope-from wang.yechao255@zte.com.cn)","from mapi (szxlzmapp03[null])\n\tby mapi (Zmail) with MAPI id mid12;\n\tWed, 29 Apr 2026 17:35:29 +0800 (CST)"],"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:Subject:Cc:To:From:Mime-Version:Date:\n\tReferences:In-Reply-To:Message-ID:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=KkhkiGnD06ddZ9a+GQKwD3JK/nbd1wWY1IyPf7mFQmQ=; b=1JKQ0xpzDvLDeX\n\tl/6AvJc5wNa3QH6Aa2y8uPVKw8/GO7hKPMyMh/NsdA2C8rx+ZUWyhJABdJEmiRXt/hPspEmLJG847\n\tS7n9+HkvJiRP28S9wDjwPVXP25lFCK3/C+Q1/+N4/BpCVQQ+MwZUo5a7CaWO9Nd6gWj94qD/e+ldS\n\tb3Hlo6zfWJoJBjGrov2fd+b/7p3ijh28ruusGwY9judrYR8Rzqw4+kTf2nBAWwJWc3p0xU5C5pbRa\n\tkPZKpRPougzE0KRlppOm7YUPWD87UAeoV8K5ogx8Ze0KL02EvFYyGP3L5W2K0+mFQdBBdIvXeipIQ\n\tLS2wWdrQS47ikITNkRvA==;","X-Zmail-TransId":"2b0569f1d0e15e3-a2163","X-Mailer":"Zmail v1.0","Message-ID":"<20260429173529259zFOx-ZsqSl_DS82KLXv0S@zte.com.cn>","In-Reply-To":"<20260429173002565bdp1o7P0bvOs6yTz64yNx@zte.com.cn>","References":"20260429173002565bdp1o7P0bvOs6yTz64yNx@zte.com.cn","Date":"Wed, 29 Apr 2026 17:35:29 +0800 (CST)","Mime-Version":"1.0","From":"<wang.yechao255@zte.com.cn>","To":"<anup@brainfault.org>, <atish.patra@linux.dev>, <pjw@kernel.org>,\n        <palmer@dabbelt.com>, <aou@eecs.berkeley.edu>, <alex@ghiti.fr>","Cc":"<kvm@vger.kernel.org>, <kvm-riscv@lists.infradead.org>,\n        <linux-riscv@lists.infradead.org>, <linux-kernel@vger.kernel.org>","Subject":"=?utf-8?q?=5BPATCH_v2_1/3=5D_RISC-V=3A_KVM=3A_Refactor_kvm=5Farch?=\n\t=?utf-8?q?=5Fcommit=5Fmemory=5Fregion=28=29?=","X-MAIL":"mse-fl1.zte.com.cn 63T9ZQKw066185","X-TLS":"YES","X-SPF-DOMAIN":"zte.com.cn","X-ENVELOPE-SENDER":"wang.yechao255@zte.com.cn","X-SPF":"None","X-SOURCE-IP":"10.5.228.132 unknown Wed, 29 Apr 2026 17:35:33 +0800","X-Fangmail-Anti-Spam-Filtered":"true","X-Fangmail-MID-QID":"69F1D0E5.000/4g5BxK0Pmgz510Y1","X-Bad-Reply":"References and In-Reply-To but no 'Re:' in Subject.","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20260429_023538_766483_1483A07D ","X-CRM114-Status":"GOOD (  10.28  )","X-Spam-Score":"-4.2 (----)","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: Wang Yechao <wang.yechao255@zte.com.cn> Refactor\n kvm_arch_commit_memory_region()\n    as a preparation for a future commit to look cleaner and more\n understandable.\n    Also, it looks more like its arm64 and x86 counterparts.\n Content analysis details:   (-4.2 points, 5.0 required)\n  pts rule name              description\n ---- ----------------------\n --------------------------------------------------\n -2.3 RCVD_IN_DNSWL_MED      RBL: Sender listed at https://www.dnswl.org/,\n                             medium trust\n                             [183.62.165.209 listed in list.dnswl.org]\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 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n                             [score: 0.0000]\n  0.0 UNPARSEABLE_RELAY      Informational: message has unparseable relay\n lines","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: Wang Yechao <wang.yechao255@zte.com.cn>\n\nRefactor kvm_arch_commit_memory_region() as a preparation for a future\ncommit to look cleaner and more understandable. Also, it looks more\nlike its arm64 and x86 counterparts.\n\nSigned-off-by: Wang Yechao <wang.yechao255@zte.com.cn>\n---\n arch/riscv/kvm/mmu.c | 12 +++++++++++-\n 1 file changed, 11 insertions(+), 1 deletion(-)","diff":"diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c\nindex 2d3def024270..dc6a8efde99e 100644\n--- a/arch/riscv/kvm/mmu.c\n+++ b/arch/riscv/kvm/mmu.c\n@@ -141,12 +141,22 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,\n \t\t\t\tconst struct kvm_memory_slot *new,\n \t\t\t\tenum kvm_mr_change change)\n {\n+\tbool log_dirty_pages = new && new->flags & KVM_MEM_LOG_DIRTY_PAGES;\n+\tbool read_only = new && new->flags & KVM_MEM_READONLY;\n+\n+\t/*\n+\t * Nothing more to do for RO slots (which can't be dirtied and can't be\n+\t * made writable) or CREATE/MOVE/DELETE of a slot.\n+\t */\n+\tif ((change != KVM_MR_FLAGS_ONLY) || read_only)\n+\t\treturn;\n+\n \t/*\n \t * At this point memslot has been committed and there is an\n \t * allocated dirty_bitmap[], dirty pages will be tracked while\n \t * the memory slot is write protected.\n \t */\n-\tif (change != KVM_MR_DELETE && new->flags & KVM_MEM_LOG_DIRTY_PAGES) {\n+\tif (log_dirty_pages) {\n \t\tif (kvm_dirty_log_manual_protect_and_init_set(kvm))\n \t\t\treturn;\n \t\tmmu_wp_memory_region(kvm, new->id);\n","prefixes":["v2","1/3"]}