Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=207.54.90.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796399314; b=Gszdy30WgXqjTtsJvp4Yw2jf/KoRK7Zyv5kSMpT2CQb4u7oMaa3xo919Z+6soCDmeSK7 +xT5gAYQEibWvwLRvGhIGVo5PeqYdMkY6BiFkTon6z/qzjYvB3s0jOXXLpBLPDdA/AieW iUsvkRj5uiuxhaH0mliS54ttpOIb9J9eK6/6ZPDvjiNmuoMHJn2SAxlXP0oU1inVyyQX9 1oqAcwrEnSw+JQUw4oHKTfG1hgPkRgdVoPqlhP7CtFgN34xTQPSc1gRqrUTECZWMH3JRS NbHatiKR4TWgb54enoTGw4ggGSGHm7MU5Ok6/hrWYZkUKVVEF/ccJT4A1EGbXe437FQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796399314; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:Received:Received:Received:Date: From:To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=uBj7eCGjGn4//xa74lcHI8qOMbRpdBp8T15iAtz9J1Q=; b=FPfSGVEFZSJv9nntJ1Nt5bMiDlksjSnfqPCJv7VCv4zo1VdY9L2zjjJspEZVvALz2qv3 3Pe5gEUYL9/Jif07Uhjoi/3oZCFSn3T8gEnZbMZGovWSu0nhgcK+kE8pwIJC+BqjrmTmf GIPIDm/FIkqOifxS8Tc646+VVvyfgp+uSoIcHjTgPDvOKKI7C8o97ChM24xRZxZx1fKAQ yonyeKYhbleDq34sz9+AWLW8DuApXYRVf9BHh9Vx026zWDbxWxJGBZLdc6LigJ1uAH2DI 0Csg52iT5HH/Seu4esVTAtKQWIu8c6W5gcsrcZ5z6eUN7NKxeoqGDKx9a2pEuMYettA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass header.d=fujitsu.com header.i=@fujitsu.com header.a=rsa-sha256 header.s=fj2 header.b=bVDuWreM; arc=none smtp.remote-ip=207.54.90.48 Received: from esa2.hc1455-7.c3s2.iphmx.com (esa2.hc1455-7.c3s2.iphmx.com [207.54.90.48]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2ED48606A32D; Fri, 4 Dec 2026 15:48:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2ED48606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.a=rsa-sha256 header.s=fj2 header.b=bVDuWreM DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1796399314; x=1827935314; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=x/mbMM4zy9J3i/xOWcX1iY/yojhmM5HRT8QuRTUG21U=; b=bVDuWreMuQS/DFqmCG6dj3+t1GHOLWIa8Gt6uo/MIrqhp2jMwCC0HTOK GzpeOVaSVypb/3U5StHFMvgjlLF+tP/D6NImVU+FPH17HuYo0fAcHG5hH w3v9FhXRFvc5DK43tXJC9SPDRgQY9tkon/gUxq6VBxl+EMMyuvGRZh0sl +KoE9q4T2YhbgYxBJRRBTuZ2ns41xtSYw/EC3uyXor8qqE5cploMARGSQ lSPeLDQRBPopl16AmU5y/8BLXkeBEYNrf4QfMIST1RVpKmG5d4V1Ief89 oIJeyYa32i7Ip3IAE1nFCMkt64JbpPg6nbUo7zmfWwYoBxQeEfibjuVcZ Q==; X-CSE-ConnectionGUID: tRciJxqvTGSQlOsZBLn0ew== X-CSE-MsgGUID: Hc8PdwbeTuKiJDHcijoPMA== X-IronPort-AV: E=McAfee;i="6800,10657,11986"; a="264262138" X-IronPort-AV: E=Sophos;i="6.29,78,1794841200"; d="scan'208";a="264262138" Received: from gmgwnl01.global.fujitsu.com ([52.143.17.124]) by esa2.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2026 00:48:32 +0900 Received: from az2nlsmgm2.o.css.fujitsu.com (unknown [10.150.26.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by gmgwnl01.global.fujitsu.com (Postfix) with ESMTPS id 6553F42A303; Fri, 4 Dec 2026 15:48:31 +0000 (UTC) Received: from az2nlsmom4.fujitsu.com (unknown [10.150.26.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by az2nlsmgm2.o.css.fujitsu.com (Postfix) with ESMTPS id 2088D1C00950; Fri, 4 Dec 2026 15:48:31 +0000 (UTC) Received: from FCCLS0092175.localdomain (unknown [10.9.23.61]) by az2nlsmom4.fujitsu.com (Postfix) with SMTP id DD31A202D4C8; Fri, 4 Dec 2026 15:48:22 +0000 (UTC) Date: Sat, 5 Dec 2026 00:48:13 +0900 From: Kohei Enju To: Steven Price Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, Suzuki K Poulose , Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Gavin Shan , Shanker Donthineni , Alper Gun , "Aneesh Kumar K . V" , Emi Kisanuki , Vishal Annapurve , WeiLin.Chang@arm.com, Lorenzo Pieralisi , Fuad Tabba Subject: Re: [PATCH v6 07/11] KVM: arm64: CCA: Restrict Realm memslots to the lower IPA half Message-ID: References: <20261204115725.45272-1-steven.price@arm.com> <20261204115725.45272-8-steven.price@arm.com> X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20261204115725.45272-8-steven.price@arm.com> On 12/04 11:57, Steven Price wrote: > From: Suzuki K Poulose > > The upper half of a Realm's IPA space aliases its lower, protected > half. Restrict memslots to the lower half so a memslot cannot be > created in the shared alias. > > Keep the existing post-creation move/delete restriction scoped to > pKVM. Protected VMs, including Realms, continue to reject dirty > logging and read-only memslots. > > Signed-off-by: Suzuki K Poulose > Signed-off-by: Steven Price > Reviewed-by: Fuad Tabba > > --- > Changes since v4: > - Remove the Realm guest_memfd memslot change restriction; private > Realm faults now validate guest_memfd backing and attributes. > - Split out private-memory support and drop the unused early > memslot validation hook. > > Changes since v3: > - Explain the arm64-wide in-place conversion effect and keep the > general IPA limit comment. > > Changes since v1: > - Preserve private mappings if KVM invalidates a Realm guest_memfd > slot before the prepare hook rejects its deletion. > --- > arch/arm64/kvm/mmu.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index 37adc20f0042..ce7cea447f58 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -2860,11 +2860,13 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, > enum kvm_mr_change change) > { > hva_t hva, reg_end; > + gfn_t ipa_limit; > int ret = 0; > > if (kvm_vm_is_protected(kvm)) { > /* Cannot modify memslots once a pVM has run. */ > - if (pkvm_hyp_vm_is_created(kvm) && > + if (kvm->arch.vm_flavor == VM_PROTECTED_PKVM && > + pkvm_hyp_vm_is_created(kvm) && > (change == KVM_MR_DELETE || change == KVM_MR_MOVE)) { > return -EPERM; > } > @@ -2881,9 +2883,14 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, > > /* > * Prevent userspace from creating a memory region outside of the IPA > - * space addressable by the KVM guest IPA space. > + * space addressable by the KVM guest IPA space. Realm shared IPAs alias > + * the corresponding private IPAs, so Realm memslots must reside entirely > + * in the lower half of that space. > */ > - if ((new->base_gfn + new->npages) > (kvm_phys_size(&kvm->arch.mmu) >> PAGE_SHIFT)) > + ipa_limit = kvm_phys_size(&kvm->arch.mmu) >> PAGE_SHIFT; Not a big deal, but if you resend this series, how about renaming ipa_limit to gfn_limit? The current name is a bit confusing to me because the value is GFNs rather than bytes. Thanks, Kohei > + if (kvm_vm_is_realm(kvm)) > + ipa_limit >>= 1; > + if (new->base_gfn + new->npages > ipa_limit) > return -EFAULT; > > /* > -- > 2.43.0 >