From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFD4317EF for ; Wed, 11 Jan 2023 08:53:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BA65C433F1; Wed, 11 Jan 2023 08:53:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673427218; bh=IXxJG9ipM42iBUZnVRNV18q69R6WGwfRGQvbXoWI510=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ahvzAyvtPhLPvkCFhVmQMywf75xYDOv13guUAfPbuvzOtQWOGrzuXdqr8289HjS5u QCLo3fvD+GgfR2mdBHbH3RaiDsaYpvHLN9pWdhDV9U2cvbeXVsjrcI2lhITJBTg18A bCulW0QQgv2bEPnO9GP2ttq0Z7ppLRnHEGspVNw/9XUVfGE+w26OhBHJ+jPPa/H3iJ QYlAqc4FHBVK4cnR5Q0PKJIAnY1T4FachcA86AWNPCcBvjhqPc8hTgwJxOn5QSInbY 4atLXqNF3gr3uPQD96zCBVm1Hu4kKjYtUbedAMmnvZG3AjAt3BjTA8BQ6IJm2h+BeF z1+CO6iX0M7TA== Received: from ip-185-104-136-29.ptr.icomera.net ([185.104.136.29] helo=wait-a-minute.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 1pFWrY-000oRY-1c; Wed, 11 Jan 2023 08:53:36 +0000 Date: Wed, 11 Jan 2023 08:52:25 +0000 Message-ID: <87ilhde9me.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: James Morse , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Quentin Perret , Will Deacon , Reiji Watanabe , Suzuki K Poulose , Zenghui Yu Subject: Re: [PATCH 3/5] KVM: arm64: Only return attributes from stage2_update_leaf_attrs() In-Reply-To: <20230111000300.2034799-4-oliver.upton@linux.dev> References: <20230111000300.2034799-1-oliver.upton@linux.dev> <20230111000300.2034799-4-oliver.upton@linux.dev> 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/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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.104.136.29 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, james.morse@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, qperret@google.com, will@kernel.org, reijiw@google.com, suzuki.poulose@arm.com, yuzenghui@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false [+ Suzuki and Zenghui who are missing from the Cc list] On Wed, 11 Jan 2023 00:02:58 +0000, Oliver Upton wrote: > > Returning a single PTE from stage2_update_leaf_attrs() doesn't make a > great deal of sense given that the function could be used to apply a > change to a range of PTEs. Instead, return a bitwise OR of attributes > from all the visited PTEs. I find this amalgamation of attributes quite confusing, and I have a hard time attaching semantics to the resulting collection of bits. It also means that you cannot reason about a particular attribute being 0 if any of the neighbour PTEs has this bit set. > > As the walker is no longer returning the full PTE, drop the check for a > valid PTE in kvm_age_gfn(). But then what does it mean to check for a potentially invalid PTE? The helpers explicitly say: /* * The following only work if pte_present(). Undefined behaviour otherwise. */ #define pte_present(pte) (!!(pte_val(pte) & (PTE_VALID | PTE_PROT_NONE))) #define pte_young(pte) (!!(pte_val(pte) & PTE_AF)) and you seem to be violating this requirement. Thanks, M. -- Without deviation from the norm, progress is not possible.