Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Steven Price" <steven.price@arm.com>,
	kvm@vger.kernel.org, kvmarm@lists.linux.dev
Cc: "Oliver Upton" <oupton@kernel.org>, "Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v4 10/11] KVM: arm64: CCA: Support runtime faulting of memory
Date: Mon, 23 Nov 2026 11:14:44 +0000	[thread overview]
Message-ID: <sashiko-outbox-229104@kernel.org> (raw)
In-Reply-To: <20261123104233.95710-11-steven.price@arm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] KVM: arm64: RMI_BLOCKED and start_level mishandled in
  realm_map_unprotected()
--

commit ad7be4b62d117614b38172987f33095d60197e1c
Author: Steven Price <steven.price@arm.com>

KVM: arm64: CCA: Support runtime faulting of memory

This commit adds stage-2 page fault handling for Arm CCA Realm guests,
delegating private guest_memfd pages to the RMM and mapping shared
pages at unprotected IPAs.

> diff --git a/arch/arm64/kvm/rmi.c b/arch/arm64/kvm/rmi.c
> index b34f5320b50b6..ab606a2dc2f57 100644
> --- a/arch/arm64/kvm/rmi.c
> +++ b/arch/arm64/kvm/rmi.c
> @@ -593,6 +593,274 @@ void kvm_realm_unmap_range_filter(struct kvm *kvm, unsigned long start,

[ ... ]

> +static int realm_map_unprotected(struct kvm *kvm,
> +				 unsigned long ipa,
> +				 kvm_pfn_t pfn,
> +				 unsigned long size,
> +				 enum kvm_pgtable_prot prot,
> +				 struct kvm_mmu_memory_cache *memcache)
> +{

[ ... ]

> +	while (ipa < ipa_top) {
> +		unsigned long range_desc = addr_range_desc(realm, ipa, phys,
> +							   ipa_top - ipa,
> +							   RMI_OP_MEM_UNDELEGATED);
> +		unsigned long call_top = ipa + RMI_ADDR_RANGE_COUNT(range_desc) *
> +			rmi_addr_block_size_to_bytes(RMI_ADDR_RANGE_BLOCK_SIZE(range_desc));
> +		unsigned long out_top;
> +
> +		ret = rmi_rtt_unprot_map(rd, ipa, call_top, flags, range_desc,
> +					 &out_top);
> +		if (ret < 0)
> +			goto err_unmap;
> +
> +		if (ret) {
> +			/* Create missing RTTs and retry */
> +			int level = RMI_RESULT_DATA_LEVEL(ret);
> +			int req_level = KVM_PGTABLE_LAST_LEVEL -
> +				RMI_ADDR_RANGE_BLOCK_SIZE(range_desc);
> +
> +			if (RMI_RESULT_STATUS(ret) != RMI_ERROR_RTT ||
> +			    ++retries > KVM_PGTABLE_LAST_LEVEL + 2) {
> +				ret = -ENXIO;
> +				goto err_unmap;
> +			}
> +
> +			/* Replace an existing mapping to update its permissions. */
> +			if (level >= req_level) {
> +				realm_unmap_shared_range(kvm, ipa, ipa_top, false,
> +							 memcache);
> +				continue;
> +			}
> +
> +			ret = realm_create_rtt_levels(realm, ipa, level,
> +						      req_level,
> +						      memcache);

[Severity: Medium]
Should realm_map_unprotected() translate RMI_BLOCKED into -EAGAIN and
check level < realm->start_level, matching realm_map_protected()?

When rmi_rtt_unprot_map() returns RMI_BLOCKED under RMM lock contention,
RMI_RESULT_STATUS(ret) != RMI_ERROR_RTT turns it into -ENXIO, causing
realm_gmem_abort() or realm_s2_fault_map() to fail KVM_RUN instead of
dropping mmu_lock and retrying the fault.  Also, on RMI_ERROR_RTT with
level < req_level, level is not checked against realm->start_level before
calling realm_create_rtt_levels().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123104233.95710-1-steven.price@arm.com?part=10

  reply	other threads:[~2026-11-23 11:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 10:42 [PATCH v4 00/11] KVM: arm64: CCA: Prepare Realm memory management Steven Price
2026-11-23 10:42 ` [PATCH v4 01/11] KVM: arm64: guest_memfd: Check mmap support when preparing memslot Steven Price
2026-11-23 11:04   ` sashiko-bot
2026-11-23 10:42 ` [PATCH v4 02/11] KVM: arm64: CCA: Introduce Realms Steven Price
2026-11-23 10:42 ` [PATCH v4 03/11] KVM: arm64: Pass range filter to stage2_unmap_range Steven Price
2026-11-23 10:42 ` [PATCH v4 04/11] KVM: arm64: Dispatch stage-2 destruction by VM flavor Steven Price
2026-11-23 11:23   ` Suzuki K Poulose
2026-11-23 10:42 ` [PATCH v4 05/11] KVM: arm64: CCA: Add basic infrastructure for creating a realm Steven Price
2026-11-23 10:42 ` [PATCH v4 06/11] KVM: arm64: CCA: Destroy RTTs Steven Price
2026-11-23 11:00   ` sashiko-bot
2026-11-23 10:42 ` [PATCH v4 07/11] KVM: arm64: CCA: Add Realm RTT mapping and invalidation helpers Steven Price
2026-11-23 11:12   ` sashiko-bot
2026-11-23 10:42 ` [PATCH v4 08/11] KVM: Allow architectures to reject memslot changes before invalidation Steven Price
2026-11-23 10:42 ` [PATCH v4 09/11] KVM: arm64: CCA: Prevent memslot modifications after Realm creation Steven Price
2026-11-23 10:42 ` [PATCH v4 10/11] KVM: arm64: CCA: Support runtime faulting of memory Steven Price
2026-11-23 11:14   ` sashiko-bot [this message]
2026-11-23 10:42 ` [PATCH v4 11/11] KVM: arm64: CCA: Add Realm stage-2 MMU operations Steven Price

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=sashiko-outbox-229104@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=steven.price@arm.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