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=1796110488; b=qLzzpyWuZG9DF5pbjWDxqUf7g0yIwsoFmiRX2N8bLA2COEISb/rcfiGDyIFNpkdSIfDy KC/ZLSs4wFXEtPk+EbJwA1ZiSOFJuAUAdcT3MCt0ZeQP3k36xBnbE75gTdLNcx75zMjvn 40DLytmmtADs2Hmz5cWhH5iQsUXm+644qyLBP+NlCYt2x6IDAHhzd0vzPaY/6TSFz5BbV zqYQc/gMuTjgKb2AQrUuG6OMWqTbi0xiiwE7W53wLubG0yx/Cz5ia+eLCaREdw+CDzqor uww6uXcjE2w8jKW7FJYUG51UQnbbjKiUZ0yx8bJRIkPk/7xtWzCwUX3bea+Es9WHE/w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796110488; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=qZho7vng3l59dJ0RGHE3Szzfo9bmUq2aQrt+szliiLk=; b=od4aNw+wkgNb3+gUv4rx/+boodCilGs6eBr+RzN9zxl++hz8npySz8Iulv+iM/YOSGfg ggDyfWt8ml3Gn+dD9RRHS2thYj+oy+1E5EEefLXJ0489Cu854Pc0Dq6teocxD95yADqJw rEJs2iNClgZMMZh/5i4opQ0eu6VZYdJycdqDl0Wt0l6oWew6AzdwC8Y/3KGtZf7Rcr1fP v+Jy2bVl4enrc4D8hAzJpVezIYyLwDpn1G8OJf3u1ZI966WyXx5Tk2t7XKsOh4LMrKZUN MW90c/BFokue2psWH/rwgU2CNuW6wJfrOW5mQYAmiqHYG+AFXtqly7ohNdYQ+fMLAnw== 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="e/OQOP9y"; 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 9C402606A337 for ; Tue, 1 Dec 2026 07:34:48 +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=e/OQOP9y Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2ECD1F0093B; Tue, 1 Dec 2026 07:34:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796110488; bh=qZho7vng3l59dJ0RGHE3Szzfo9bmUq2aQrt+szliiLk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=e/OQOP9yJ09ktSjhVbxr6mHY1tUxMqlcifrgE1FLJPx4WGcVaPHQYuPj3BuVSViSQ sQaWWY0KvQT9WgMbtLfED9yTuJbq5lvsrKyVE487YhpmhnxLf8m6qffolZoZfC7LGQ GdFKK2yRn3+LtwWYwjuGD0Qwt0IgQo/PoPc2YTJbuNMWoQC49SNTWnhHeTM0ITlzA6 k45t5vdbh6eORr626kEfc9v6YeuKvjlvuoNzn1bgIL/EJZOmFTEEVk7SglH45Gukju o0jgeG8eTUiqyNwVybmj/xMHwae1A1y0Tz4jZ6ZBM/LiKEbP6U3MMp8Nd3DjxeumuV Q0H+pxN3akcMQ== Date: Mon, 30 Nov 2026 23:34:46 -0800 From: Oliver Upton To: Vincent Donnefort Cc: maz@kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, kernel-team@android.com, fuad.tabba@linux.dev, qperret@google.com, weilin.chang@arm.com, Keir Fraser Subject: Re: [PATCH v5 01/25] KVM: arm64: Prefault host stage-2 entries on block split Message-ID: References: <20261130155710.2371874-1-vdonnefort@google.com> <20261130155710.2371874-2-vdonnefort@google.com> X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261130155710.2371874-2-vdonnefort@google.com> Hi Vincent, On Mon, Nov 30, 2026 at 03:56:45PM +0000, Vincent Donnefort wrote: > + pa = ALIGN_DOWN(ctx->addr, kvm_granule_size(ctx->level)); > + for (i = 0; i < PTRS_PER_PTE; ++i, ++ptep, pa += kvm_granule_size(ctx->level + 1)) { > + kvm_pte_t pte = kvm_init_valid_leaf_pte(pa, block_pte, ctx->level + 1); > + > + /* > + * Skip ptes in the range being modified by the caller if we're > + * installing last level entries. Otherwise, we need to > + * temporarily put in a valid mapping to make sure the > + * prefaulting logic is triggered on the next > + * stage2_map_walk_leaf(). This adds an unnecessary TLBI as > + * we'll presumably re-break the freshly installed block, but > + * that should happen very infrequently. > + */ > + if ((ctx->level < (KVM_PGTABLE_LAST_LEVEL - 1)) || > + (pa < ctx->addr) || (pa >= ctx->end)) { > + *ptep = pte; > + if (counted) > + ctx->mm_ops->get_page(ptep); > + } So the aim of doing a custom split function rather than reusing kvm_pgtable_stage2_split() is eliding the temporary mappings? I'd rather we have a single implementation of "replace block with fully mapped table". Thanks, Oliver > + } > +} > + > static int stage2_map_walk_leaf(const struct kvm_pgtable_visit_ctx *ctx, > struct stage2_map_data *data) > { > struct kvm_pgtable_mm_ops *mm_ops = ctx->mm_ops; > + struct kvm_pgtable *pgt = data->mmu->pgt; > kvm_pte_t *childp, new; > int ret; > > @@ -1053,6 +1095,9 @@ static int stage2_map_walk_leaf(const struct kvm_pgtable_visit_ctx *ctx, > if (!childp) > return -ENOMEM; > > + if (pgt->flags & KVM_PGTABLE_S2_IDMAP) > + stage2_map_prefault_idmap(ctx, childp); > + > if (!stage2_try_break_pte(ctx, data->mmu)) { > mm_ops->put_page(childp); > return -EAGAIN; > @@ -1151,6 +1196,7 @@ int kvm_pgtable_stage2_annotate(struct kvm_pgtable *pgt, u64 addr, u64 size, > return -EINVAL; > > ret = kvm_pgtable_walk(pgt, addr, size, &walker); > + dsb(ishst); > return ret; > } > > -- > 2.56.1.839.g22a8290db9-goog > >