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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78865C4321E for ; Wed, 30 Nov 2022 08:21:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234530AbiK3IVj (ORCPT ); Wed, 30 Nov 2022 03:21:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234441AbiK3IVh (ORCPT ); Wed, 30 Nov 2022 03:21:37 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1797855CA0; Wed, 30 Nov 2022 00:21:35 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A97EAB8199D; Wed, 30 Nov 2022 08:21:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D5D6C433D6; Wed, 30 Nov 2022 08:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669796492; bh=YVwFW8ukFc+IWgIXWj/9MV56uKwQlCK2O51RttnjsSU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=XYccEQE2rG2H1YWBiPcP0nHSASIeJGHz3yVc3OT1lb/hZxxmiK7Z0783XIRtx+rLK uqJ8E7Cu8+fNMFdCHqiFJfLLywmxTSC9sdTLxA1y9tFrrSHu7IIgWOSBxL3A/QFEXs 3VBkhbGnWuxNeyyLsJ4aga7pANlntiFNWyx/JhSs1YKTYWt0EozKM4h4ClP7Pz9udz 7lffzkqLx2NjLkqB7TQkJ3bXVvk7iYqEzKnKgqV+nja7GQZOrGjqXP0f8OwJU4L+Hv EKIwgmYu8ngvdlKj1HvhnEWBgU6GY/B2w5SsgOc8fL2CdmgDpOfPnsx/9oIcSMSd72 S0EhDDZ31eF2A== 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 1p0ILR-009X1T-Rc; Wed, 30 Nov 2022 08:21:30 +0000 Date: Wed, 30 Nov 2022 08:21:17 +0000 Message-ID: <87pmd4ua2q.wl-maz@kernel.org> From: Marc Zyngier To: Ricardo Koller Cc: Oliver Upton , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/4] KVM: arm64: Don't serialize if the access flag isn't set In-Reply-To: References: <20221129191946.1735662-1-oliver.upton@linux.dev> <20221129191946.1735662-3-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) 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: ricarkol@google.com, oliver.upton@linux.dev, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.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 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Wed, 30 Nov 2022 01:23:20 +0000, Ricardo Koller wrote: > > On Tue, Nov 29, 2022 at 09:15:21PM +0000, Oliver Upton wrote: > > Hi Ricardo, > > > > Thanks for having a look. > > > > On Tue, Nov 29, 2022 at 12:52:12PM -0800, Ricardo Koller wrote: > > > On Tue, Nov 29, 2022 at 07:19:44PM +0000, Oliver Upton wrote: > > > > [...] > > > > > > + ret = stage2_update_leaf_attrs(pgt, addr, 1, KVM_PTE_LEAF_ATTR_LO_S2_AF, 0, > > > > + &pte, NULL, 0); > > > > + if (!ret) > > > > + dsb(ishst); > > > > > > At the moment, the only reason for stage2_update_leaf_attrs() to not > > > update the PTE is if it's not valid: > > > > > > if (!kvm_pte_valid(pte)) > > > return 0; > > > > > > I guess you could check that as well: > > > > > > + if (!ret || kvm_pte_valid(pte)) > > > + dsb(ishst); > > > > Thanks for catching this. > > > > Instead of pivoting on the returned PTE value, how about we return > > -EAGAIN from the early return in stage2_attr_walker()? It would better > > match the pattern used elsewhere in the pgtable code. > > That works, although I would use another return code (e.g., EINVAL)? as > that's not exactly a "try again" type of error. EINVAL usually is an indication of something that went horribly wrong. But is that really a failure mode? Here, failing to update the PTE should not be considered a failure, but just a benign race: access fault being taken on a CPU and the page being evicted on another (not unlikely, as the page was marked old before). And if I'm correct above, this is definitely a "try again" situation: you probably won't take the same type of fault the second time though. Thanks, M. -- Without deviation from the norm, progress is not possible.