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 27BF7C282DE for ; Sun, 16 Mar 2025 11:05:06 +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=YRIXi+DnOwE2LkY6C7uyMxOLjG3vIDNB+z6zmc6zNqI=; b=0IJKIEt680dc1cSh4jslMisIXB qf2BlqqIG+1kvLjx8haRFq54PelDKfqMcvaixuPdPBFfJ5FqqjxhMCWLmJ3Bi5rXzxHFs4t4lTxMk 9o8KsFtFyiO31nPf80vYYMeDh7PY8f/638IF99jhtbQg/5uRcGN/w0H1RuVWfOki4q4cvn5y6DGpq yFNeeW6BswZwXK2PsJJcOxs9LVHcAENIF2LhaDPi0NinglmIXTe5t8Hu7luAFT77r55nZ6B2RNnat vMbDxdVc9Y1knhpzfxXfWlWSC8I/cs+ZXZankMBXlsgIG3hf0JbZi4qbuYi1Ly7jGwOFV0PMW3ljD tMiXznjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1ttlnY-000000005lG-3sWY; Sun, 16 Mar 2025 11:04:52 +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 1ttlls-000000005ZH-2aUf for linux-arm-kernel@lists.infradead.org; Sun, 16 Mar 2025 11:03:09 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 36712A48A67; Sun, 16 Mar 2025 10:57:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9109BC4CEDD; Sun, 16 Mar 2025 11:03:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742122987; bh=sVHjaUDH8uCiBrDHHW/8jZXGlx5rWV9vWdbICLdRKLM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=tZPCW/zIgzZ56V0kbeNbO+VF17LIyVFRZ6eda4wdDcnJ4djG2xIvzY5ygpX2sfq7Q Ri4/iI2B6W8Iz7MWtRuaERoJbh/CBI/kXmBitKAGiEJzODK8sFuRfumAx/kZdRXfSD UvotfrIeGfRsd/BHsfyYMWkn0DdA3wH5eZGVcgdvXsLlmu2chosRNZe3Q4ZaoFO4h5 /NU46HWYUqH9JHQFonwHbZcGIjDuwQJNxfWLt+g7nkaoX87r+RPplMOleeOImEsSmU BDZngPD4+rAzKKQSPCvt+CckY8mJLgGoRkkDH6Pr7Bc4MFfgAgO2IGLPH03zr3obsq 2x225PDxG8KBA== 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 1ttllp-00DyMQ-Ag; Sun, 16 Mar 2025 11:03:05 +0000 Date: Sun, 16 Mar 2025 11:03:05 +0000 Message-ID: <867c4pnspi.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 2/6] KVM: arm64: Use 0b11 for encoding PKVM_NOPAGE In-Reply-To: References: <20250227003310.367350-1-qperret@google.com> <20250227003310.367350-3-qperret@google.com> <86cyejooq2.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_040308_789630_1DF402AD X-CRM114-Status: GOOD ( 34.35 ) 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:13:39 +0000, Quentin Perret wrote: > > On Friday 14 Mar 2025 at 11:07:01 (+0000), Marc Zyngier wrote: > > On Thu, 27 Feb 2025 00:33:06 +0000, > > Quentin Perret wrote: > > > > > > The page ownership state encoded as 0b11 is currently considered > > > reserved for future use, and PKVM_NOPAGE uses bit 2. In order to > > > simplify the relocation of the hyp ownership state into the > > > vmemmap in later patches, let's use the 'reserved' encoding for > > > the PKVM_NOPAGE state. The struct hyp_page layout isn't guaranteed > > > stable at all, so there is no real reason to have 'reserved' encodings. > > > > > > No functional changes intended. > > > > > > Signed-off-by: Quentin Perret > > > --- > > > arch/arm64/kvm/hyp/include/nvhe/memory.h | 5 +---- > > > 1 file changed, 1 insertion(+), 4 deletions(-) > > > > > > diff --git a/arch/arm64/kvm/hyp/include/nvhe/memory.h b/arch/arm64/kvm/hyp/include/nvhe/memory.h > > > index 34233d586060..642b5e05fe77 100644 > > > --- a/arch/arm64/kvm/hyp/include/nvhe/memory.h > > > +++ b/arch/arm64/kvm/hyp/include/nvhe/memory.h > > > @@ -13,18 +13,15 @@ > > > * 01: The page is owned by the page-table owner, but is shared > > > * with another entity. > > > * 10: The page is shared with, but not owned by the page-table owner. > > > - * 11: Reserved for future use (lending). > > > */ > > > enum pkvm_page_state { > > > PKVM_PAGE_OWNED = 0ULL, > > > PKVM_PAGE_SHARED_OWNED = BIT(0), > > > PKVM_PAGE_SHARED_BORROWED = BIT(1), > > > - __PKVM_PAGE_RESERVED = BIT(0) | BIT(1), > > > > > > /* Meta-states which aren't encoded directly in the PTE's SW bits */ > > > - PKVM_NOPAGE = BIT(2), > > > + PKVM_NOPAGE = BIT(0) | BIT(1), > > > > Isn't this comment stale now? > > I believe it still applies to guest stage-2 page-tables as the three > other states above are still stored into PTE SW bits (well, sort of, > only SHARED_BORROWED is at the moment as we don't supported protected > VMs, but OWNED and SHARED_OWNED will be a thing for protected). NOPAGE > is still the only one that is a bit different and doesn't go there. > > With that said, the comment could be made more explicit about that and > explain this is now guest s2 only. Happy to spin another version of the > series with that changed if that helps. Right. It is slightly misleading that we end-up with two notions of state: - the per-mapping state encoded in the PTs - the per-page state encoded in the vmemmap The two are obviously related, but it is all a bit confusing for the unsuspecting reader. There is no urgency to address this, but maybe it'd be good to clarify this aspect in the future (no need to respin on that account). M. -- Without deviation from the norm, progress is not possible.