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 6FB52C4332F for ; Tue, 29 Nov 2022 20:52:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236558AbiK2UwY (ORCPT ); Tue, 29 Nov 2022 15:52:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236568AbiK2UwR (ORCPT ); Tue, 29 Nov 2022 15:52:17 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C10F13DD7 for ; Tue, 29 Nov 2022 12:52:16 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id t17so13797679pjo.3 for ; Tue, 29 Nov 2022 12:52:16 -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=52SMROLRGWbt9mwpSBUjPx/3msXb6vFt7ItVy/cqB1k=; b=VhKagD+9381ydRAyKPEL5EsmY+AM67HAZZ/33h8VvA8l2VXlMlKxq+fM5BueYSKXKt MlYUlT1r2orjroDtbBdQLFNwyfElcb4r+5lE0sxkugaizGLV5rqQhubBgdx5ttpa3za0 oliMzzN9b4nvEx2UounppSrAbCEbsdm/nmGfxJve0S1hIp8oK/34PAiQq2P0gRHNpQON Hed36jy70ZutuQ+XKz5nU9QmAvnQT6CmU+OyL+RjADMzi1jdYipeoPsS5VzO7M2oqh+q oUjXehpCZSlKTc1/n9q+Fw+1tkSNk+0rW8qA5VeEmwAbYZihapsyiUMqxDw9ljYAQ/PU SMqA== 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=52SMROLRGWbt9mwpSBUjPx/3msXb6vFt7ItVy/cqB1k=; b=qNH1brPy18yPD6Ne6xT1wseLV6LaURpJnrG8P9uwPXbyMBqZPULqSv+XYjpLQJLJMW zKJDXi6Su9+a81R/qsv4VBj8QJ4w/WA6bcdrU99UJHoUQX/a/VGjfrv/lngUfYTcmt2e 3KG5cEaqnxOOaEr8FGtNWNSpBODKR+50HUvCeoImJEHirAH8Ug9wlNZy0ViPXPCy3ARe Co3SzNG2yiP2Nb/WT8ZtLrIGNlXnwiQzUV2+opkb30R/+3u0xcqyd/S5c4tUo/Dh1Y0J HJB2EpI8q1xgSit3ysZCzWatzFyU+9+2ghohlMvq44IPUaC2igDVSvrb3QauLBXxCODC I91g== X-Gm-Message-State: ANoB5pkhBLiRP1bgE5UQJGLFRhUvobY/ropVO/YUfQfqk35OgHhpoYGQ SUJfBnUR+KlJHfqJp55VYuJeKA== X-Google-Smtp-Source: AA0mqf5zWdkH3xH2EphKKbDCqWzEBIeWxi3op3Of+IS1hUt3Omy1pEG69elJYrpi56m64lfNCX6qYA== X-Received: by 2002:a17:902:7790:b0:189:9973:fb58 with SMTP id o16-20020a170902779000b001899973fb58mr5888074pll.59.1669755135786; Tue, 29 Nov 2022 12:52:15 -0800 (PST) Received: from google.com (220.181.82.34.bc.googleusercontent.com. [34.82.181.220]) by smtp.gmail.com with ESMTPSA id c31-20020a17090a492200b00218b32f6a9esm1784905pjh.18.2022.11.29.12.52.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 12:52:15 -0800 (PST) Date: Tue, 29 Nov 2022 12:52:12 -0800 From: Ricardo Koller To: Oliver Upton Cc: Marc Zyngier , 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221129191946.1735662-3-oliver.upton@linux.dev> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 29, 2022 at 07:19:44PM +0000, Oliver Upton wrote: > Of course, if the PTE wasn't changed then there are absolutely no > serialization requirements. Skip the DSB for an unsuccessful update to > the access flag. > > Signed-off-by: Oliver Upton > --- > arch/arm64/kvm/hyp/pgtable.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > index b11cf2c618a6..9626f615d9b8 100644 > --- a/arch/arm64/kvm/hyp/pgtable.c > +++ b/arch/arm64/kvm/hyp/pgtable.c > @@ -1094,9 +1094,13 @@ int kvm_pgtable_stage2_wrprotect(struct kvm_pgtable *pgt, u64 addr, u64 size) > kvm_pte_t kvm_pgtable_stage2_mkyoung(struct kvm_pgtable *pgt, u64 addr) > { > kvm_pte_t pte = 0; > - stage2_update_leaf_attrs(pgt, addr, 1, KVM_PTE_LEAF_ATTR_LO_S2_AF, 0, > - &pte, NULL, 0); > - dsb(ishst); > + int ret; > + > + 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); > + > return pte; > } > > -- > 2.38.1.584.g0f3c55d4c2-goog > >