From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4102CC282DE for ; Sun, 16 Mar 2025 11:10:07 +0000 (UTC) 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:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EI8hyfHoGvsIizjHFUHXzVM2V1/gp8KxaNGoe7qrOOE=; b=MTj+4dhvRu+cAoIXikF2haOfwB gCeezaaDp7pdgVWJDdiHO0i/czpvx3dksPOv4g3WVcmTXcN448hMCgnA6oVcefcID2EmT0VmdBoiq r91Zp3N9w4+NOxn+gAbkaDpsWCU19SHXy9oBCwKI9eF1FpaSkTCCEXOsBatKao91+VZtgi6B/88s/ 68k/E8OsNPDVloCGKETrUq8qAbF0vVBhxOemmcXF5G/R1BQUGhY6896UJ0ZaV1OoCcxr7zcgBt+/G Oyzmc0QbVm8Zq6mZKxdO+9mDv/97RhQK7D0GGDF80X+Bh+hY0Mc4Ei/PRQBTLyspLH8VLx02K2sQd DLYGXBvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1ttlsR-0000000068g-40Du; Sun, 16 Mar 2025 11:09:55 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1ttlql-0000000062v-0YRr for linux-arm-kernel@lists.infradead.org; Sun, 16 Mar 2025 11:08:12 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id A0E1CA48A5B; Sun, 16 Mar 2025 11:02:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01F91C4CEDD; Sun, 16 Mar 2025 11:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742123290; bh=NBzY1wPmskDl9cnCIedvm7cu6kUE8imKPYGTjUERKcE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ULXG1b7TIrcR2/kS1cAnQcp2cr+CTaakEWygYDzP0MoDR5pWybAMDvMrLKnX12gNi JHRB+l4XPhcfvAYMBBZUBJwLEyS3F7zY9YHObZOa21M04kJTbpOhisbLQ8kRyoABqt QMudRWLKALfzfoicm0wGfleRXUGugW+RIoIXiLtSY3oDh6rj6LmRcI5zUig5VFAI7n egyzTvBocHDhpki6AbZh1jCxd7MRRPR6mpCNAo3xTL+5eDU4naD9US41Aw3hRQ+3gE oyj7v12vels3V9EqmtaSwlkMkqmdtC82XviHesiB7E6mXkz2IFCm6FGHokRJDCQXUw 4SAMa4Ujurfog== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ttlqh-00DyQJ-Sm; Sun, 16 Mar 2025 11:08:07 +0000 Date: Sun, 16 Mar 2025 11:08:06 +0000 Message-ID: <865xk9nsh5.wl-maz@kernel.org> From: Marc Zyngier To: Quentin Perret Cc: Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Vincent Donnefort , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/6] KVM: arm64: Move hyp state to hyp_vmemmap In-Reply-To: References: <20250227003310.367350-1-qperret@google.com> <20250227003310.367350-5-qperret@google.com> <86bju3onl3.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: qperret@google.com, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, vdonnefort@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250316_040811_314188_9A43FFC1 X-CRM114-Status: GOOD ( 23.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 14 Mar 2025 14:06:48 +0000, Quentin Perret wrote: > > On Friday 14 Mar 2025 at 11:31:36 (+0000), Marc Zyngier wrote: > > On Thu, 27 Feb 2025 00:33:08 +0000, > > Quentin Perret wrote: > > > @@ -698,13 +697,13 @@ int __pkvm_host_share_hyp(u64 pfn) > > > if (ret) > > > goto unlock; > > > if (IS_ENABLED(CONFIG_NVHE_EL2_DEBUG)) { > > > - ret = __hyp_check_page_state_range((u64)virt, size, PKVM_NOPAGE); > > > + ret = __hyp_check_page_state_range(phys, size, PKVM_NOPAGE); > > > > OK, I think I finally clicked here. Does it mean that all the tracking > > is now done in terms of PAs instead of VAs? > > Yep, that's exactly that. The hyp_vmemmap is indexed by pfn, so I felt > that the conversion to a PA-based tracking made sense. That also make it > clear that the 'hyp state' is not a property of a mapping, but really of > the underlying physical page. It indeed makes sense. It is just that it took me some time to realise the extent of the change. > > > > if (ret) > > > goto unlock; > > > } > > > > > > - prot = pkvm_mkstate(PAGE_HYP, PKVM_PAGE_SHARED_BORROWED); > > > - WARN_ON(pkvm_create_mappings_locked(virt, virt + size, prot)); > > > + __hyp_set_page_state_range(phys, size, PKVM_PAGE_SHARED_BORROWED); > > > + WARN_ON(pkvm_create_mappings_locked(virt, virt + size, PAGE_HYP)); > > > > And this is the split between the state now being kept in the on a PA > > base and the actual mapping that is now only takes the page attributes > > and no SW bits? > > Precisely, and the next patch in this series takes advantage of the > fact that we're now de-correlating the hyp state from the presence of a > hyp s1 mapping in the linear map range. In the future there'll be more > use-cases for this I think (e.g. the hyp allocator where we'll have > pages owned by the hypervisor but only mapped in the 'private' range, > things like that). Yup, that's probably the correct direction of travel. The hypervisor shouldn't need to map everything -- quite the opposite actually. Thanks, M. -- Without deviation from the norm, progress is not possible.