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 04/18] KVM: arm64: Add a heap allocator for the pKVM hyp
Date: Mon, 20 Jul 2026 13:30:39 +0100 [thread overview]
Message-ID: <al4U7xB4ySWVAQT_@google.com> (raw)
In-Reply-To: <CA+EHjTwSupmgbjbeUap4EEwy8DP7y8euZRHd2tXc=FSDGzrghA@mail.gmail.com>
On Wed, Jul 15, 2026 at 11:59:26AM +0100, Fuad Tabba wrote:
> On Tue, 14 Jul 2026 at 19:35, Fuad Tabba <fuad.tabba@linux.dev> wrote:
> >
> > On Mon, 6 Jul 2026 at 18:54, Vincent Donnefort <vdonnefort@google.com> wrote:
> >
> > ...
> >
> > > +static u32 chunk_hash_compute(const struct chunk_hdr *chunk)
> > > +{
> > > + u32 hash = 0;
> > > +
> > > + BUILD_BUG_ON(sizeof(*chunk) != 16);
> > > +
> > > + hash ^= hash_64(*(const u64 *)chunk, 32);
> > > + hash ^= hash_32(chunk->__unmapped, 32);
> >
> > Could you state the threat model in the commit msg? The VA range is
> > hyp-private and the hash is unkeyed (anything that can write EL2
> > memory recomputes it), so this only catches _accidental_ corruption,
> > i.e. a debug aid.
> >
> > Since that's the goal, should it be gated on CONFIG_NVHE_EL2_DEBUG
> > like the other checks here? As written it's O(n) hashing per
> > hyp_alloc(), in production, for a check that only fires on a hyp bug.
> > And a plain XOR/additive checksum would be cheaper and just as good
> > for accidental corruption.
>
> Thinking about it, I was wrong to say that it would be just as good,
> slightly cheaper, but it would detect things like swaps.
>
> Still, I think this should be gated.
After a longer offline discussion, we concluded this doesn't cost anything while
the weak protection can still be effective against attackers who may not always
control the entire bit-width.
I'll add some details in the commit message.
>
> Cheers,
> /fuad
>
> >
> > > + return hash;
> > > +}
> > > +
> >
> > ...
> >
> >
> > > diff --git a/arch/arm64/kvm/hyp/nvhe/setup.c b/arch/arm64/kvm/hyp/nvhe/setup.c
> > > index 75b00c323310..1c10cf78c869 100644
> > > --- a/arch/arm64/kvm/hyp/nvhe/setup.c
> > > +++ b/arch/arm64/kvm/hyp/nvhe/setup.c
> > > @@ -10,6 +10,7 @@
> > > #include <asm/kvm_pgtable.h>
> > > #include <asm/kvm_pkvm.h>
> > >
> > > +#include <nvhe/alloc.h>
> > > #include <nvhe/early_alloc.h>
> > > #include <nvhe/ffa.h>
> > > #include <nvhe/gfp.h>
> > > @@ -363,6 +364,10 @@ int __pkvm_init(phys_addr_t phys, unsigned long size, unsigned long *per_cpu_bas
> > > if (ret)
> > > return ret;
> > >
> > > + ret = hyp_alloc_init(SZ_128M);
> >
> > Where does 128M come from? A comment would help.
This is arbitrary, big enough to allow us to allocate plenty of VMs with tracing
enable. But I will add something.
> >
> > Cheers,
> > /fuad
> >
> >
> >
> > > + if (ret)
> > > + return ret;
> > > +
> > > update_nvhe_init_params();
> > >
> > > /* Jump in the idmap page to switch to the new page-tables */
> > > --
> > > 2.55.0.rc2.803.g1fd1e6609c-goog
> > >
next prev parent reply other threads:[~2026-07-20 12:30 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 [this message]
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
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=al4U7xB4ySWVAQT_@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