Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796301041; b=ghto5mcOy//u7Pw71LcfWr6XqmCAcCJWs2gFtVVi7Niu4y7vmKzVZf4EV/7FOhHmioVG FSkX3qJ2rY+ecOfibjjHbwEvvarAy53a8J0pt1RlDVramnh2XQCejTejzvC6qs+sn7bJh mmZPfxZXV29aqYVlGI03uatkK7MAebOMTmxfc9eu7tlbBQ/G6Bu1/XxlBm4D+Rn4QuJUH ji8yJ5oxil8+1ocSOszn8fTxgDaYIJIuwY3J3NuAsW/Q4e6UvYTT4DwYGv8v5pxziGuAW KeWp9aOcu3+jt7NYrjbGXNsbBZV/Rpysn5fIu8oTtnOeXsPWYs/led4CwlwgetyKfUw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796301041; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=y6hKXngYKrCKVNYvPjXk70YdXzoE4eg7xOUvlTeox7Q=; b=nUO2eCvFV0WWpNIXeofpfveII00Bi+B0/FPDRPER9GynlGHszUUoYNeWAEJz79CqUT8Z BZOmj96jTrJx1pqqX93bTP6YiBiQ5U/2elc97eTpP+hxvphf2tRuhtac+vkKT3fi0XPNw LjDrcg7eTslqrIL4yNzBaTdhw26Q0mQip1KqwM5TmbjnpLo8dVe0g9cg1t8zru03Lcupa FNyOraEFAfwQxJ/CiGhI3pjAZeUdsFeiDSrYgINjstgwNtSDeInvkB3bXQuXKPSXOGndh JwsZbE14EpRCfNW5A3DxSZW7cCok7I5wkHXmJIU0I8FSUyTKkB8uzwUjJ3wV/PLq3Aw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=LLYuREO5; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B53EC606A332 for ; Thu, 3 Dec 2026 12:30:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=LLYuREO5 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 215251F00896; Thu, 3 Dec 2026 12:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796301041; bh=y6hKXngYKrCKVNYvPjXk70YdXzoE4eg7xOUvlTeox7Q=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=LLYuREO5s4dbNWrjcMkfVpC4uU+eIP+LqqL5xP1Hc3HFVq9zNWpCjuaceOhBr5WME Jz87haNAeK4NMMUBGJhxQ5CQwaotEe6x1p7o2Tv0uRAFvANDFrPgVuYoKyrXvaAcFt Nj3dLpG1Nu+oMgYfdPzg1xBXgJfYcc+Nahr913bvbocrS/ouHdKh3Wx463a42zmMcU gGOU04m2cghcwLIpTsUz6jG+z2yb8Y9x6I/J+jOjdaZkHn8soC8orNGiNV4oFqE5Gf m9My+2oA4Pe/E4tTUEmo575s78F1qLTbsT5m9OkqHUb59bS1V66DpjfmtzcWR3HS1Z Fq3X7TGVvfvOQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v6 02/24] KVM: arm64: Preserve idmap stage-2 entries on block split Reply-To: sashiko-reviews@lists.linux.dev To: "Vincent Donnefort" , kvmarm@lists.linux.dev Cc: "Oliver Upton" , "Marc Zyngier" In-Reply-To: <20261203115209.1690207-3-vdonnefort@google.com> References: <20261203115209.1690207-1-vdonnefort@google.com> <20261203115209.1690207-3-vdonnefort@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 12:30:40 +0000 X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] KVM: arm64: stage2_map_walk_leaf() prefaults overwritten range on block split - [Low] KVM: arm64: avoid full table walk on empty page in stage2_map_walk_leaf() -- commit eb0747ddd24665d91e3c9f56d57d2dfe7e0e9532 Author: Vincent Donnefort KVM: arm64: Preserve idmap stage-2 entries on block split When splitting a block entry in an idmap stage-2 page table, this commit populates the new child table with the existing block's mappings or annotations via stage2_create_unlinked() instead of leaving it zeroed. It also adds a trailing dsb(ishst) to kvm_pgtable_stage2_annotate(). > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > index 954ce008d1305..a50bcfe72c8ef 100644 > --- a/arch/arm64/kvm/hyp/pgtable.c > +++ b/arch/arm64/kvm/hyp/pgtable.c [ ... ] > @@ -1068,18 +1073,24 @@ static int stage2_map_walk_leaf(const struct kvm_= pgtable_visit_ctx *ctx, > if (!data->memcache) > return -ENOMEM; > =20 > - childp =3D mm_ops->zalloc_page(data->memcache); > - if (!childp) > - return -ENOMEM; > - > /* > * If we've run into an existing block mapping then replace it with > * a table. Accesses beyond 'end' that fall within the new table > - * will be mapped lazily. > + * will be mapped lazily. For an idmap stage-2, preserve existing > + * block mappings and annotations in the new table instead. > */ > + if ((pgt->flags & KVM_PGTABLE_S2_IDMAP) && ctx->old) > + childp =3D stage2_create_unlinked(pgt, ctx->old, ctx->level, > + data->memcache, false); > + else > + childp =3D mm_ops->zalloc_page(data->memcache) ?: ERR_PTR(-ENOMEM); [Severity: Medium] Does prefaulting the entire child table when ctx->old is a valid block mapping amplify TLB shootdowns for the subrange being overwritten? When splitting a valid host_mmu.pgt block, stage2_create_unlinked() fills all child entries with valid PTEs, including [ctx->addr, ctx->end). Descending into that range triggers __kvm_tlb_flush_vmid_ipa() (ipas2e1is and vmalle1is) for each overwritten entry under host_mmu.lock. Previously, breaking the parent block issued one shootdown and descending into the zeroed child table issued none. For an N-page sub-2MB donation in __pkvm_host_donate_hyp() (e.g. from __pkvm_init_vm()), this turns 1 shootdown into 1 + N from a 2MB block (or 2 + N from a 1GB block). Leaving entries within [ctx->addr, ctx->end) zeroed when splitting a valid block would preserve sibling mappings while avoiding the redundant shootdowns, since valid host mappings can be rebuilt on fault. > =20 > + if (IS_ERR(childp)) > + return PTR_ERR(childp); > + > ret =3D stage2_table_install(ctx, data->mmu, childp); > if (ret) > - mm_ops->put_page(childp); > + kvm_pgtable_stage2_free_unlinked(mm_ops, childp, ctx->level); [Severity: Low] Can this avoid calling kvm_pgtable_stage2_free_unlinked() when childp is an empty page from mm_ops->zalloc_page()? For non-idmap guest stage-2 tables, concurrent faults in kvm_s2_fault_map() walk with KVM_PGTABLE_WALK_SHARED under read_lock(&kvm->mmu_lock) and can hit -EAGAIN in stage2_table_install(). Unconditionally calling kvm_pgtable_stage2_free_unlinked() makes each losing vCPU walk all PTRS_PER_PTE zero entries via stage2_free_walker() while holding mmu_lock, where mm_ops->put_page(childp) would suffice. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203115209.1690= 207-1-vdonnefort@google.com?part=3D2