From: Vincent Donnefort <vdonnefort@google.com>
To: Fuad Tabba <fuad.tabba@linux.dev>
Cc: maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com,
suzuki.poulose@arm.com, yuzenghui@huawei.com,
catalin.marinas@arm.com, will@kernel.org,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
kernel-team@android.com, qperret@google.com
Subject: Re: [PATCH v2 14/18] KVM: arm64: Use noclear for PGD in __pkvm_init_vm error path
Date: Mon, 20 Jul 2026 14:41:11 +0100 [thread overview]
Message-ID: <al4ldxSPH2MJKJcD@google.com> (raw)
In-Reply-To: <CA+EHjTyFavaVQ=bmo=1s9LgDVQftdsCELUudSza1ARZCJo+dqw@mail.gmail.com>
On Wed, Jul 15, 2026 at 01:09:12PM +0100, Fuad Tabba wrote:
> On Mon, 6 Jul 2026 at 18:54, Vincent Donnefort <vdonnefort@google.com> wrote:
> >
> > In the error path of __pkvm_init_vm(), use unmap_donated_memory_noclear()
> > instead of the clearing variant to release the donated stage-2 PGD back
> > to the host.
> >
> > This intends to eliminate the clearing variant of
> > unmap_donated_memory(), as zeroing the PGD memory before returning it to
> > the host is unnecessary in this failure path.
> >
> > Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
> >
> > diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c
> > index d9ab58226889..0c82f1ddb93d 100644
> > --- a/arch/arm64/kvm/hyp/nvhe/pkvm.c
> > +++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c
> > @@ -861,7 +861,7 @@ int __pkvm_init_vm(struct kvm *host_kvm, unsigned long vm_hva,
> > kvm_guest_destroy_stage2(hyp_vm);
> > err_remove_mappings:
> > unmap_donated_memory(hyp_vm, vm_size);
> > - unmap_donated_memory(pgd, pgd_size);
> > + unmap_donated_memory_noclear(pgd, pgd_size);
>
>
> We spoke about this in person before you sent the series and I thought
> it was ok. Sashiko's review made me doubt at first, since the freed
> blocks carry EL2 list_head pointers that the noclear variant hands
> back to the host.
>
> You mentioned that the mapping isn't secret (later when we discussed
> Sashiko's review in person), and I checked: kvm_compute_layout() runs
> at EL1 on the host and rolls the tag itself. The host already knows
> the PA of every page it donated, so it can compute those VAs anyway.
> So I don't think this is a real leak.
>
> However, this relies on the pool and hyp_vm both being donated
> linear-map memory here. Once hyp_vm moves to hyp_alloc() in the
> private range, the free_area anchor becomes a private-range VA, and I
> haven't checked whether that's host-derivable.
>
> Given it's the init error path and not hot, clearing costs basically
> nothing, so I'd lean towards just keeping unmap_donated_memory()
> rather than reasoning about derivability.
>
> What do you think?
Happy to not take any risk and to drop it. It was just an attempt to simplify
the code anyway.
>
>
>
> /fuad
>
> > err_unpin_kvm:
> > hyp_unpin_shared_mem(host_kvm, host_kvm + 1);
> > return ret;
> > --
> > 2.55.0.rc2.803.g1fd1e6609c-goog
> >
next prev parent reply other threads:[~2026-07-20 14:47 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 17:53 [PATCH v2 00/18] KVM: arm64: Introduce pKVM hypervisor heap allocator Vincent Donnefort
2026-07-06 17:53 ` [PATCH v2 01/18] KVM: arm64: Add __pkvm_private_range_pa Vincent Donnefort
2026-07-14 16:59 ` Fuad Tabba
2026-07-06 17:53 ` [PATCH v2 02/18] KVM: arm64: Add pkvm_remove_mappings Vincent Donnefort
2026-07-14 17:48 ` Fuad Tabba
2026-07-06 17:54 ` [PATCH v2 03/18] KVM: arm64: Add __hyp_allocator_map for the pKVM hyp Vincent Donnefort
2026-07-14 17:53 ` Fuad Tabba
2026-07-15 8:58 ` Vincent Donnefort
2026-07-15 9:24 ` Fuad Tabba
2026-07-06 17:54 ` [PATCH v2 04/18] KVM: arm64: Add a heap allocator " Vincent Donnefort
2026-07-14 18:35 ` Fuad Tabba
2026-07-15 10:59 ` Fuad Tabba
2026-07-20 12:30 ` Vincent Donnefort
2026-07-06 17:54 ` [PATCH v2 05/18] KVM: arm64: Allow kvm_hyp_memcache usage outside of stage-2 Vincent Donnefort
2026-07-14 19:00 ` Fuad Tabba
2026-07-06 17:54 ` [PATCH v2 06/18] KVM: arm64: Add topup interface for the pKVM heap allocator Vincent Donnefort
2026-07-14 19:28 ` Fuad Tabba
2026-07-06 17:54 ` [PATCH v2 07/18] KVM: arm64: Add pkvm_hyp_req infrastructure Vincent Donnefort
2026-07-14 19:45 ` Fuad Tabba
2026-07-06 17:54 ` [PATCH v2 08/18] KVM: arm64: Handle PKVM_HYP_REQ_HYP_ALLOC request Vincent Donnefort
2026-07-15 6:28 ` Fuad Tabba
2026-07-06 17:54 ` [PATCH v2 09/18] KVM: arm64: Add reclaim interface for the pKVM heap alloc Vincent Donnefort
2026-07-14 20:10 ` Fuad Tabba
2026-07-06 17:54 ` [PATCH v2 10/18] KVM: arm64: Add selftests for the pKVM heap allocator Vincent Donnefort
2026-07-15 11:07 ` Fuad Tabba
2026-07-06 17:54 ` [PATCH v2 11/18] KVM: arm64: Add a shrinker for pKVM Vincent Donnefort
2026-07-15 11:20 ` Fuad Tabba
2026-07-15 11:35 ` Vincent Donnefort
2026-07-06 17:54 ` [PATCH v2 12/18] KVM: arm64: Filter out non-kernel addresses in kern_hyp_va Vincent Donnefort
2026-07-15 11:30 ` Fuad Tabba
2026-07-06 17:54 ` [PATCH v2 13/18] KVM: arm64: Move hyp_vm refcount into the structure Vincent Donnefort
2026-07-15 11:35 ` Fuad Tabba
2026-07-06 17:54 ` [PATCH v2 14/18] KVM: arm64: Use noclear for PGD in __pkvm_init_vm error path Vincent Donnefort
2026-07-15 12:09 ` Fuad Tabba
2026-07-20 13:41 ` Vincent Donnefort [this message]
2026-07-06 17:54 ` [PATCH v2 15/18] KVM: arm64: Alloc pkvm_hyp_vm using pKVM heap allocator Vincent Donnefort
2026-07-15 12:33 ` Fuad Tabba
2026-07-15 12:55 ` Vincent Donnefort
2026-07-15 12:58 ` Fuad Tabba
2026-07-06 17:54 ` [PATCH v2 16/18] KVM: arm64: Alloc pkvm_hyp_vcpu " Vincent Donnefort
2026-07-15 13:12 ` Fuad Tabba
2026-07-06 17:54 ` [PATCH v2 17/18] KVM: arm64: Reject hyp trace descriptors with fewer CPUs than hyp_nr_cpus Vincent Donnefort
2026-07-15 13:54 ` Fuad Tabba
2026-07-06 17:54 ` [PATCH v2 18/18] KVM: arm64: Alloc simple_buffer_page using pKVM hyp allocator Vincent Donnefort
2026-07-15 15:07 ` Fuad Tabba
2026-07-20 14:04 ` Vincent Donnefort
2026-07-20 14:10 ` Vincent Donnefort
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=al4ldxSPH2MJKJcD@google.com \
--to=vdonnefort@google.com \
--cc=catalin.marinas@arm.com \
--cc=fuad.tabba@linux.dev \
--cc=joey.gouly@arm.com \
--cc=kernel-team@android.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=qperret@google.com \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/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