From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796401640; b=UyvaAR/GwmRVW5AfQUfzQAIUkqTNwkMu8SN/GVnFjL+AY4Kwp98gnTpSYhGITExBEcJG tWfk6zdR9EryEpRmAxDYrD672ki2jw9MZuFemxzBJWgGRNtLrWTnKN+Yg7u0/4XEBYiMB B3RJIYc2W+Gv/sj/A+kK5QnbeXrHBkcKFOTNhtn+cup+AhtxAYXwMS3P9mYpvLxm/6Gcp 6EFRtOtMeM2YSla3uqAPbxD0fyvfdts/xqJvnrNcYOo0P77OrocZeecuNq4JFwqyR4uFq bfEwojboClgMJ8smAcseLILCMX7baD1eSDNZm4dfZes9k3t0MOmyMgspyAMM1ko33gQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796401640; h=DMARC-Filter:Received:Received:DKIM-Signature:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:From: Content-Language:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=i/9YEwST45KQ05CZZ+BLweR5RihfZcu2sozw+aMPwpc=; b=3aTGZHl9RrO+5MqVkMb58pEnmnIPbUC7Th+3l1kR0c8p7SPw2avHL50kR24sfPEsncDl RIU4Vd0KUHIBclIK4U8CRnz3AgSPmRgBbBRq3CBC0fkFtTJxMc37u74ObLbiOs+BGxyi6 fiwtT23qbO6/oUE6CBsgYlRMJZC7I41XfDisnHl9YRZBa0YfjkBtrGCJQ4T9Kaa3sxJi3 LX2SYYoJDzQN2OuMuAsCBYSSBxB3ueA+bggfTyfkoSThlYacwHzSFX18PJzy9rHzibbAm tMSWsNp5Pd4pST725Y9Tdqzkz0EeR30zCHjuyss4jjCY0b4dwMLO1c0eCIZZMb4MLSA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=ulIgPPQK; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12C60606A330; Fri, 4 Dec 2026 16:27:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 12C60606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=ulIgPPQK Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9A26D1655; Fri, 4 Dec 2026 08:27:15 -0800 (PST) Received: from [10.0.128.193] (e122027.cambridge.arm.com [10.0.128.193]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 054103F632; Fri, 4 Dec 2026 08:27:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796401638; bh=x/WwFhKGLt9StA7BXi+eB0kzYkqBLFnTN3Gs9WJwgaU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ulIgPPQKy6IlapkdPQW6uy5A7P9xRdGga+pwhv3ZXSOp2+sujf2cWGFisEz5IQweX TTJ3SwQdaAeW/9sHZ1l68zYCIzwdlnyodmRRHS+M6/jJdNRhpyEynVLwdd8LgEx5Gu R8C9JIGo7wbHyI8aBOR6caWQmiO4GLVOAY9N628M= Message-ID: Date: Fri, 4 Dec 2026 16:27:07 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 07/11] KVM: arm64: CCA: Restrict Realm memslots to the lower IPA half To: Kohei Enju 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 References: <20261204115725.45272-1-steven.price@arm.com> <20261204115725.45272-8-steven.price@arm.com> From: Steven Price Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 04/12/2026 15:48, Kohei Enju wrote: > 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. Yes sure - that makes sense. Thanks, Steve > Thanks, > Kohei > >> + if (kvm_vm_is_realm(kvm)) >> + ipa_limit >>= 1; >> + if (new->base_gfn + new->npages > ipa_limit) >> return -EFAULT; >> >> /* >> -- >> 2.43.0 >>