Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Price <steven.price@arm.com>
To: Kohei Enju <enju.kohei@fujitsu.com>
Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev,
	Catalin Marinas <catalin.marinas@arm.com>,
	Marc Zyngier <maz@kernel.org>, Will Deacon <will@kernel.org>,
	James Morse <james.morse@arm.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Joey Gouly <joey.gouly@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Christoffer Dall <christoffer.dall@arm.com>,
	Fuad Tabba <tabba@google.com>,
	linux-coco@lists.linux.dev,
	Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>,
	Gavin Shan <gshan@redhat.com>,
	Shanker Donthineni <sdonthineni@nvidia.com>,
	Alper Gun <alpergun@google.com>,
	"Aneesh Kumar K . V" <aneesh.kumar@kernel.org>,
	Emi Kisanuki <fj0570is@fujitsu.com>,
	Vishal Annapurve <vannapurve@google.com>,
	WeiLin.Chang@arm.com, Lorenzo Pieralisi <lpieralisi@kernel.org>
Subject: Re: [PATCH v6 10/11] KVM: arm64: CCA: Support runtime faulting of memory
Date: Fri, 4 Dec 2026 16:27:04 +0000	[thread overview]
Message-ID: <43120ed4-55de-459d-b860-7e57ac0c3fd5@arm.com> (raw)
In-Reply-To: <axLa231LNq3xPN1Z@FCCLS0092175.localdomain>

On 04/12/2026 15:32, Kohei Enju wrote:
> On 12/04 11:57, Steven Price wrote:
>> At runtime, if the realm guest accesses an IPA without a stage-2
>> mapping, then KVM fixes up the stage-2 mapping for the backing memory.
>>
>> For memory in the lower (protected) region of IPA, verify that the
>> corresponding guest_memfd page is private before delegating to the RMM.
>> The RMM then maps the delegated page into the Realm.
>>
>> For memory in the upper (shared) IPA region, map the backing page as
>> non-secure memory. Check that a guest_memfd page is shared when the
>> fault uses guest_memfd; ordinary userspace-backed memslots can only be
>> mapped at unprotected IPAs and follow the normal user memory fault path.
>>
>> If the fault IPA and guest_memfd attributes disagree then exit to
>> userspace with KVM_EXIT_MEMORY_FAULT so the VMM can perform the required
>> conversion. If a shared IPA has no memslot, KVM follows the existing
>> MMIO or abort-injection path. The latter can result in injecting a SEA
>> to the guest.
>>
>> Realm faults may need to create RTTs, including when updating a
>> mapping after a permission fault. Take the write side of mmu_lock
>> and top up the MMU cache for these faults. Do not pre-fault Realm
>> memory.
> 
> Hello Steve,
> 
> Not a review comment, but just a question for clarification.
> 
> My understanding is that this series and the following ones aim to
> provide basic CCA/KVM functionality, leaving out optional features for
> the initial upstream support.
> 
> I've been looking into supporting pre-faulting for CCA/KVM in the
> future, and I'm not aware of any architectural blockers.
> 
> Are you aware of any potential blockers or limitations that might
> prevent us from supporting pre-faulting in the future, or is it simply
> being left out for now as an *optional* feature, as I assume?

(I assume you mean stage-2 pre-faulting - i.e. populating the guest's
IPA-to-PA translations with KVM_PRE_FAULT_MEMORY, pre-faulting the
guest_memfd itself isn't specific to CCA.)

There's nothing architectural preventing pre-faulting. The host is free
to proactively map the protected memory into the guest before the first
fault.

My reasons for leaving it out now are:

 * It's obviously an "optional" feature - and I'm trying to focus on
getting enough support to boot a guest before looking at more features.

 * As a feature it could hide bugs - faulting is the more complex path,
so I've wanted to focus testing on that path rather than the pre-fault
path which is naturally less racy.

 * It's a performance feature and I'm currently doing most of my testing
on a model. So I've no way of meaningfully telling whether it's actually
useful in reality. Although my suspicion is that it could turn out to be
important.

Note that KVM_PRE_FAULT_MEMORY is a VCPU ioctl, but the RMI API executes
it on the realm descriptor - so I'm not sure how much benefit there
would be to running multiple in parallel.

My assumption is that KVM_PRE_FAULT_MEMORY would be treated as a "first
VCPU run" and would trigger the realm setup (kvm_activate_realm()), but
that's certainly an area of uAPI that needs nailing down.

Let me know if you do come up with an implementation - hopefully it
won't be too long before we move on past the basic functionality.

Thanks,
Steve



  reply	other threads:[~2026-12-04 16:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 11:57 [PATCH v6 00/11] KVM: arm64: CCA: Prepare Realm memory management Steven Price
2026-12-04 11:57 ` [PATCH v6 01/11] KVM: arm64: CCA: Introduce Realms Steven Price
2026-12-04 16:07   ` Kohei Enju
2026-12-04 17:05     ` Steven Price
2026-12-04 11:57 ` [PATCH v6 02/11] KVM: arm64: Pass range filter to stage2_unmap_range Steven Price
2026-12-04 11:57 ` [PATCH v6 03/11] KVM: arm64: Dispatch stage-2 destruction by VM flavor Steven Price
2026-12-04 11:57 ` [PATCH v6 04/11] KVM: arm64: CCA: Add basic infrastructure for creating a realm Steven Price
2026-12-04 11:57 ` [PATCH v6 05/11] KVM: arm64: CCA: Add Realm RTT mapping and invalidation helpers Steven Price
2026-12-04 11:57 ` [PATCH v6 06/11] KVM: arm64: CCA: Destroy RTTs Steven Price
2026-12-04 11:57 ` [PATCH v6 07/11] KVM: arm64: CCA: Restrict Realm memslots to the lower IPA half Steven Price
2026-12-04 15:48   ` Kohei Enju
2026-12-04 16:27     ` Steven Price
2026-12-04 11:57 ` [PATCH v6 08/11] KVM: arm64: CCA: Advertise private memory support for Realms Steven Price
2026-12-04 11:57 ` [PATCH v6 09/11] KVM: arm64: Select protected VM behaviour by VM flavour Steven Price
2026-12-04 13:21   ` Fuad Tabba
2026-12-04 11:57 ` [PATCH v6 10/11] KVM: arm64: CCA: Support runtime faulting of memory Steven Price
2026-12-04 15:32   ` Kohei Enju
2026-12-04 16:27     ` Steven Price [this message]
2026-12-04 11:57 ` [PATCH v6 11/11] KVM: arm64: CCA: Add Realm stage-2 MMU operations Steven Price
2026-12-04 16:30 ` [PATCH v6 00/11] KVM: arm64: CCA: Prepare Realm memory management Kohei Enju

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=43120ed4-55de-459d-b860-7e57ac0c3fd5@arm.com \
    --to=steven.price@arm.com \
    --cc=WeiLin.Chang@arm.com \
    --cc=alexandru.elisei@arm.com \
    --cc=alpergun@google.com \
    --cc=aneesh.kumar@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=christoffer.dall@arm.com \
    --cc=enju.kohei@fujitsu.com \
    --cc=fj0570is@fujitsu.com \
    --cc=gankulkarni@os.amperecomputing.com \
    --cc=gshan@redhat.com \
    --cc=james.morse@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=sdonthineni@nvidia.com \
    --cc=suzuki.poulose@arm.com \
    --cc=tabba@google.com \
    --cc=vannapurve@google.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