From: sashiko-bot@kernel.org
To: "Tan Chi" <tanchi25@mails.ucas.ac.cn>
Cc: kvm@vger.kernel.org, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com
Subject: Re: [PATCH] RISC-V: KVM: Account G-stage page table memory
Date: Wed, 25 Nov 2026 13:10:49 +0000 [thread overview]
Message-ID: <sashiko-outbox-233465@kernel.org> (raw)
In-Reply-To: <20261125125024.1983082-1-tanchi25@mails.ucas.ac.cn>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] KVM: riscv: missing write memory barrier in
kvm_riscv_gstage_set_pte() [1]
--
commit 00af1817efd260bd8b07164e38fe69598a62a280
Author: Tan Chi <tanchi25@mails.ucas.ac.cn>
RISC-V: KVM: Account G-stage page table memory
This commit uses kvm_account_pgtable_pages() to account for the allocation
and freeing of RISC-V KVM G-stage root and lower-level page tables in
NR_SECONDARY_PAGETABLE.
Link: https://lore.kernel.org/r/20220426053904.3684293-6-yosryahmed@google.com
> diff --git a/arch/riscv/kvm/gstage.c b/arch/riscv/kvm/gstage.c
> index 0aace3215d3e8..f8841136d8526 100644
> --- a/arch/riscv/kvm/gstage.c
> +++ b/arch/riscv/kvm/gstage.c
> @@ -162,6 +162,7 @@ int kvm_riscv_gstage_set_pte(struct kvm_gstage *gstage,
> return -ENOMEM;
> set_pte(ptep, pfn_pte(PFN_DOWN(__pa(next_ptep)),
> __pgprot(_PAGE_TABLE)));
> + kvm_account_pgtable_pages(next_ptep, 1);
[Severity: Critical]
This problem wasn't introduced by this patch, but shouldn't there be an
smp_wmb() before set_pte() links next_ptep into ptep [1], as in
kvm_riscv_gstage_split_huge()?
set_pte() is a plain WRITE_ONCE() on RISC-V. Without a write memory
barrier after kvm_mmu_memory_cache_alloc() zeroes next_ptep, the store to
ptep can become visible to a concurrent hardware page table walker before
the zero-initialization of next_ptep completes, exposing uninitialized
entries as child PTEs.
[1] https://sashiko.dev/#/bug/linux-9339e577-5f31-42a2-a5ea-9844d30b43f8
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125125024.1983082-1-tanchi25@mails.ucas.ac.cn?part=1
prev parent reply other threads:[~2026-11-25 13:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 12:50 [PATCH] RISC-V: KVM: Account G-stage page table memory Tan Chi
2026-11-25 13:10 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-233465@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kvm@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tanchi25@mails.ucas.ac.cn \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox