From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AA8F606A330 for ; Fri, 4 Dec 2026 15:48:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=hmAkrFyx; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=djgI8aJl; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.a=rsa-sha256 header.s=fj2 header.b=AHUfW9/6 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=uBj7eCGjGn4//xa74lcHI8qOMbRpdBp8T15iAtz9J1Q=; b=hmAkrFyxtFTbmE/ZAdQxzWfd0X PQvDTHus1eJjwgvsfwhGaFdnhg5V0UQgzNZCYJoR+XeQ8iSqssmHY2CmCpNSW3A8cTQsSGSUUVoeO Obl7QI/g13s/lSGsQFJmZ2K+1gp9AYGlnBpWAl7B0rVK2RfHNeHTpnhdBOleQbnMitloFsIWLsuqv fO1+6kMBJYBvg7GN/6B3jO8VCYcBserhpLOv40dUiBrc6my8T7Gi6UgkBLuFHyZQbVsbIFqr4MRJo X76tQb6BkMC70d1qGzqBryhnCRDo8C4hVCzXVYjk6F2b4gFvXL4NhhdhdfF74qEpLRuQxHUtHtyJl 292hPAuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZVWj-00000000p5P-1giW; Fri, 04 Dec 2026 15:48:49 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZVWW-00000000p1C-2PYB for linux-arm-kernel@bombadil.infradead.org; Fri, 04 Dec 2026 15:48:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=uBj7eCGjGn4//xa74lcHI8qOMbRpdBp8T15iAtz9J1Q=; b=djgI8aJlsmd2UqwQK6uFvTpck6 SxcJQDLmFW9/FSjk3ptHrMTTfScsDf7Su3UQizW1gHNkGTfAv6dBj8ABTaq5BrKpjiKD77iagxLxd vIGCpa6Ceeberz2pfEK3V6S4FMSO1+nZQp9VBIzv3ZAN4u7Q4JHjpEgZz21KGaWJvNyG4ZnnarGn9 3JC2YbbMmcXQcvTUvPQvP9UWeiHtggBRpAdaNbjyXiNvatUoHU9qZ9B0xBgNaVm3UcUAflEvXTOFa T1eDlNU6kVPp0c4DP8lJZUKjQW69+iVLRl02AUtDs9d6nM4XRKCTHL9msCXzOMWCKE3b6DM4Rn/yT LZrGrI0g==; Received: from esa1.hc1455-7.c3s2.iphmx.com ([207.54.90.47]) by desiato.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZVWT-0000000EXvI-0qtc for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2026 15:48:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1796399322; x=1827935322; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=x/mbMM4zy9J3i/xOWcX1iY/yojhmM5HRT8QuRTUG21U=; b=AHUfW9/6fydiq4bNfFxysy+gxUh4qj1sO6eGDBH21Jcsvymu3f/T20Hu TSVjmONeChsaN4hw9Su5LdTSHgGH5hw3ksDM09Q0IRndOZZbHtvvtxXOf ymKQV5M61MZ8qBa363zrh8Mr2aTXx4MuElcI0VQcmy6pFE7PSyE7UgXcl NScqw1XxqKcVE19xH0nLhNcSxjzKsHPBgFDKtKMDvag5mvSh64GYtAqWQ xmUKG73ApMYESqdFGoiJQc2gEPam8Oa/RuZ4d67mOxmiJW8J/y7M64tLN b/J5QbLbC6sheEH/m5aG/2w2RbYfIwiLEw58/ryHG9TyObtYLmTAPQ4fd g==; X-CSE-ConnectionGUID: aGHeKDWRQ0qjpX7lejtE5Q== X-CSE-MsgGUID: SxpHAQPlQnqBhcMNHfIzsA== X-IronPort-AV: E=McAfee;i="6800,10657,11986"; a="264273848" X-IronPort-AV: E=Sophos;i="6.29,78,1794841200"; d="scan'208";a="264273848" Received: from gmgwnl01.global.fujitsu.com ([52.143.17.124]) by esa1.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2026 00:48:40 +0900 Received: from az2nlsmgm4.fujitsu.com (unknown [10.150.26.204]) (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 50EB01C00083 for ; 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 az2nlsmgm4.fujitsu.com (Postfix) with ESMTPS id 099141005962 for ; 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-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20261204115725.45272-8-steven.price@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_154833_819326_93925967 X-CRM114-Status: GOOD ( 24.16 ) X-Spam-Score: -2.5 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-16.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 >