Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2048472rwb; Wed, 30 Nov 2022 01:22:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf55W4r9ylC4N9SgsG+XbZFkBnSfHR+wLIoa/BIbehrcwJWd3gXyesg9rXYOptwheRsyy2pF X-Received: by 2002:a17:906:f2c8:b0:7bc:1506:f42a with SMTP id gz8-20020a170906f2c800b007bc1506f42amr23851493ejb.188.1669800159077; Wed, 30 Nov 2022 01:22:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669800159; cv=none; d=google.com; s=arc-20160816; b=ilZBz4kurKOse+hjwyhkOaYvTps8UR/bh7cEKY7qyiQtbQdYTWI03pwB9txf3PJvCP bLPhYPEwqZpavxWVOux93FIzjrdRWaU0DwyD5Kv5SAjct8o5EwHCbahfYFoHOpePF6p+ +DGljMUDbJj4y/a3NZGjwINCuqeWbrMWcaUNlPAO/y4vr4kNEuPnxxzrz5ESIBVatnGY 1APNY6DOCSs2LY7kzN3L4oM+0ug6vTI2r89qh4YCCo4hJiIGZJuLUYta9jVCB+GoMmOt SfDAK2ljkM51ZQo5BmdHo+fpwZJfv6SbkLPmRpRBaKdodNsBUg5BsUxvZk48gj7Q2wKI pmaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=7wb3+cvcshymtGoFVD4H77lRziwfdEE8/3qBLOx3Ojo=; b=DvBuDIszJ0MIlLxy+whERAd5REaJs7jBusyzyKBCRZ/J24/mf67HQ0bYQ3oZRlfD1Y Hvhmg4P4b2HNWfSgkhXJPeoiMsccwmcP/MugbktC/XjlLzULcm9hifWuXz0doOb6ZQLH OVL5nlGBIxnFDBzAnLR483mI7h9/KCp3w76xS+DEGmd4Mqvf+HQWsjR0YxJDYNFJ2fvF QuvJ548FBoOkzF4BtU8kInPJ2l9MEV+aDq0+65qUYl9ljosmJeWpuNbhDAVAVnTKfjPR joRe2m37bKSgZip9Zj52gHd/OpmUOY/HOEFEfjWE639u1JYY6jk1XTkVHl9Gg8smqAAz jZDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XYccEQE2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t19-20020a1709067c1300b007adacdfd08asi720047ejo.295.2022.11.30.01.22.17; Wed, 30 Nov 2022 01:22:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XYccEQE2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234531AbiK3IVj (ORCPT + 84 others); 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 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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.