Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3124619rwb; Wed, 30 Nov 2022 15:58:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf7QVUCLb9yJg+dSYAUEpbnxE2fzk88qNyH16H3eVd3x3NITcr2DQxOhYPJnavTYbUowoblz X-Received: by 2002:a17:906:f2c8:b0:7bc:1506:f42a with SMTP id gz8-20020a170906f2c800b007bc1506f42amr26568616ejb.188.1669852689638; Wed, 30 Nov 2022 15:58:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669852689; cv=none; d=google.com; s=arc-20160816; b=Fg7ALqXxQBu/Tf18DjfBTDoo7tEPNXEEaw7/HUs/mbQHRr+/xFDQPvQ299TyLT/Z63 mkxoE7OibTctQqQspVqK5wyrRSorCBkG4tFbgTek7twjYYDM7rlrxxvukN24pww6BXxU bnEHNEE5wfPIWF8qvksHLT53AXyMbKUh8Zj9t16+WHtssNI0nqNMxrIr6cwMsCLEKPCZ ADEuGBYaNKc7RDEr1BfIUkXzuUdkEGB458eaPG1e3D4qAWOG95DGl2lBRDwT4XayKIxM r9F9z4gM5qssDUrT1f6vAR5A5TjnEP3xc7lcb9rjnX0VFiSa/pA6ntnywyV2HI3KsMVq Y3Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=oOrPD6CB7rqzyj1SaEV3kuD/IhDMhOZPI51nCiB/NGg=; b=J9EYtCHC+rnbmuXGqmGtHEDAZXyiq0dhBYOv4gO2+JvI3Fa6QM1qkP7th3RSmGSY5k tqTh/ncpArUq0QN3wf4EVJoZJZbR6CnzCePgwsV9SxEOGSiE5cARZYEzyF8rSgMl9LkW JdbG6GW8jwsue6ApfBCnKSqa2LT7Wb/qD0ANKF5z+doUvZBH1qXE/Wd8RN4IpKvZYo8d YZjl+rfGLfHchwM5Dc3lp+OsySbyqPy9Hzx7aeYnEDpYAke8NBKl5Nr2nC9jqCrIEqZG 9hqgqM0fsj8QNfDCvkyXR8qwTqOyTcZLal6+SXZGjqxgW8c8M68bB1MKs96NUETkFedd sJzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ZRW2ZUTv; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp9-20020a1709073e0900b007ae4f8de35esi2442457ejc.860.2022.11.30.15.57.50; Wed, 30 Nov 2022 15:58:09 -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=@google.com header.s=20210112 header.b=ZRW2ZUTv; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230163AbiK3XbL (ORCPT + 83 others); Wed, 30 Nov 2022 18:31:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229767AbiK3Xav (ORCPT ); Wed, 30 Nov 2022 18:30:51 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A0819838F for ; Wed, 30 Nov 2022 15:21:21 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso3540815pjt.0 for ; Wed, 30 Nov 2022 15:21:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=oOrPD6CB7rqzyj1SaEV3kuD/IhDMhOZPI51nCiB/NGg=; b=ZRW2ZUTv1n147KoQiZQIoZW74j4A7EtjIYOcRFO0rF0DPUCmy6VUy2g0JuJ1nS/0PG bPSRbTqLAdAfhndt51DMfOPkb6sHyNfjGeyL8kdbar+k+xIpBX4SiQnfKVs3jxbhY30i fE+0B93J3f1zH3nafXrLqY7rdRuq0maSuVI9QpeW8enceqQk351ZWU6NHH/BazdCHb+E L5o+TvbdnPsX9MioomkdsvtUqYHZQq6KqAvnuPAuThxGPwZ++G4eWoki6stkyg4QcWza 6l0SCQXCBclmuJYQ9VytxAYkOvwHCR0J4TrW1rGbFwPNrD/IzVnCsAgUxIa0vHOndA6A NTuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=oOrPD6CB7rqzyj1SaEV3kuD/IhDMhOZPI51nCiB/NGg=; b=d//oocrvod5PAjSzXMdX9wLMOOs/NxINK/9NyGCYH5Gm7l/g/PCrDioLUNIXS8MGw1 HiqD/QyGWaCGGAS06aDJav/rmpt47BZIAR+3v2SRSa7f1xcIsc+Bhwmlk0AW/MF4mpvU IteuekQtFqt780E7gJHDVnn54OonK00gtLlchbUpIf4KNu5Nxzh673xu8Sig7UaG6jP5 bdXsSrhkQNb4oi9O5iChwMXaU5O/iDwRW9CUBpioUgzuc6v/2rG5bHpUQJIeljzgqSQ0 H/vpjT3uilrKMimG7tus+o8Ouz4B4zsNllL1bouyDos+HkjOOjXRJBvKGsTUOUAfsSbJ t9fw== X-Gm-Message-State: ANoB5pmfV77RwdWfzA34adfqjHTK4eBtsPikXznRU1CXCBKFVbTTpoZT C9YkaRfhrrkCSEQY84jBL28wPHWuKNvcnA== X-Received: by 2002:a17:90a:d24e:b0:218:b478:f44f with SMTP id o14-20020a17090ad24e00b00218b478f44fmr46173649pjw.232.1669850480496; Wed, 30 Nov 2022 15:21:20 -0800 (PST) Received: from google.com (220.181.82.34.bc.googleusercontent.com. [34.82.181.220]) by smtp.gmail.com with ESMTPSA id o13-20020a17090a0a0d00b0021896fa945asm3637054pjo.15.2022.11.30.15.21.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 15:21:20 -0800 (PST) Date: Wed, 30 Nov 2022 15:21:16 -0800 From: Ricardo Koller To: Marc Zyngier 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 Message-ID: References: <20221129191946.1735662-1-oliver.upton@linux.dev> <20221129191946.1735662-3-oliver.upton@linux.dev> <87pmd4ua2q.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87pmd4ua2q.wl-maz@kernel.org> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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, Nov 30, 2022 at 08:21:17AM +0000, Marc Zyngier wrote: > 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). I see, I agree, what you describe not look like a failure. > > 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. >