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=1796401634; b=DbMmSraoTLQ/h4gpuf99OkWZgjgf+IsLiDEd3z9DsqB9Jgzj5J5GdaSNZqWek43i3HgM U5Z6WjhmomsEvAy+X/HTxsvzTTziGvdzQSiqIgeBfUPdtFJGLh032kFRSmq1Pr6QYAXZy ma3J4UM0pNugCnaEzG5PZTMCDPKi/EzAwcuja+RT3eFF2PxNkz+UXUrKPOKP74KgsSXYB K67jRpXoTu86CxXKJmDzTaOA0+cy68WpXYK0QRM/QU0fiWUR8s8fflG6AufUeepVX0lAb z8EFUdnK06fVzdKWl6P9+gCiUpHVk2ewu5cWuIW15BJfQkgrvpjsc+iYjl9R3i6CEBw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796401634; 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=DjXJ3/qEEERMPMMoHNamA/MlHqd/eYLRLyVdZEI0CEw=; b=2GjaazJFSISKF6K4aj+cJyi1h3DORYFA7fTsG6PEKh4NchdQsvFCTCZmoVWr1pTcymGf 0A0uIYHMfFgwqj1l/bZxfypBBI0Mp1xVsSn/Ig7NWGAN9VR65f7ZiwsM06VsK4h5gEtaY A9KSLzAOaSIzQ9gywY0uWgb7BdMT5bPE7opW0KzN5qp/RgxEeyDfJumpSHupkWLNHOV+M Bl7xXijArz3iD+NdtrneG5Ps3fKhjqeVfMisdrMN3U/DGNjpTMZYn0AkmuE1owKXJ+3du /QplLsr55BlLrwy/hh5ZJSnM41C4Zvh+4f6Iwx8XLLayzaf17yZ27bNj4j9yLiq650Q== 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=WVMDpbK2; 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 C3CA1606A322; Fri, 4 Dec 2026 16:27:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C3CA1606A322 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=WVMDpbK2 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 C910614BF; Fri, 4 Dec 2026 08:27:09 -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 D6E443F632; Fri, 4 Dec 2026 08:27:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796401632; bh=2WIAmtMGnudIuR7/aICmZbndOp5ZCdtE1ltOF8aHMfk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=WVMDpbK2xFjfSth6Mg0/vnD7d+YmrimlD0FpBgsWoGcja0qYcdawsnPzNAednNHU2 bRHEL192qS4aeYfW1mz1qMyRUQ3UMNaGibEwy0MirpJ+skyi5xGR6azYUXv/nyw83q KJcRxVvoVUXGEtU/YxOpvedYJ7zKTKE2gQHO/X/Q= Message-ID: <43120ed4-55de-459d-b860-7e57ac0c3fd5@arm.com> Date: Fri, 4 Dec 2026 16:27:04 +0000 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 10/11] KVM: arm64: CCA: Support runtime faulting of memory To: Kohei Enju Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , 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 References: <20261204115725.45272-1-steven.price@arm.com> <20261204115725.45272-11-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: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