Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1306003rwb; Tue, 29 Nov 2022 11:38:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf73A6pSLMLkS8tWLisTulAxvG3jeWuzQc5VEr5qlZg6FgjAxMU4hQx/X21WS4KgiIWbNaHt X-Received: by 2002:a63:5b47:0:b0:437:e9f3:8add with SMTP id l7-20020a635b47000000b00437e9f38addmr34286902pgm.438.1669750714106; Tue, 29 Nov 2022 11:38:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669750714; cv=none; d=google.com; s=arc-20160816; b=pqeBU5FIzGsjhPCwhq47jVBzJv7kLS1Qv3In0F7igCfqjjIuCI7LldcNv20Jjcrgx4 GdFoElPbfRYX5ft47UYyfyKaAIpkS1M5p2hPYlzAvnCPKDBW5uMWoQ5TDLocVdJiz70r dj+K6YZCS0npsKPZBffZC1Mgaq1jfD/XMmrcgdUvERhsyvWokUUUXho1UwY33u/7zw2D +KwhbvKn8Ud/UHp1DP8rqZJvkASNBvn7VSYGA6VG7VM5c8Q89f6oMW8P1grjFefYweKi sabhKtmWeBcJ/ZTKm/HZln+2kjXzmSssdLaSkzTYKe+Ga6HCVduu6Bs+jhjGfxANVQnM pqZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gZ4zOeCGbv1gvItGbIIGPQNuQz+qC/NQiSdoYbMqOcA=; b=YUbr2rTIfknlGxcoyP3r0f//SVbqMyHFDdQV4Dle+BFjOkY27aWJcr3wIhrWxFzHZ4 XsNqEYqNiXDapatCr9SAUzVxGZd5kSG+vwG5Hw/ejEhkErjJs+wMnR/26hyoLUGSLQQf UGQdGzjyhbNq4He2+TsohqRKwxcgXGjilw3LestvvTnMdT8CZtVGBJ5Iu/NSn9kWQqir TxjKGIvrENMc2XDxMuvjTMO3EtVaEeFSo/QIjeKVoDml4se+TniCeuQu6LEjt/zWRLiz srzjuk6HnXZO+5Prr//d6btft9KyPKFHYYWhugzMd+CI6ynTlPXUen71zWPYm7ZjC/g5 eAXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ivgJME64; 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=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f20-20020a056a00239400b0056d7cc80e34si16225493pfc.102.2022.11.29.11.38.22; Tue, 29 Nov 2022 11:38:34 -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=@linux.dev header.s=key1 header.b=ivgJME64; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236902AbiK2TVc (ORCPT + 84 others); Tue, 29 Nov 2022 14:21:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236815AbiK2TUv (ORCPT ); Tue, 29 Nov 2022 14:20:51 -0500 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 486FD6D48C; Tue, 29 Nov 2022 11:20:01 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1669749599; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gZ4zOeCGbv1gvItGbIIGPQNuQz+qC/NQiSdoYbMqOcA=; b=ivgJME643G8i5ESEr5NCoBRxVONgW7xNcfo9eS52aTmAiibYNqYar1tSVUGNHBZlpVpKsW fZVLO+TVjMk1oxRvpreTbTajXlBarEJAum8hCMBQG4qntEG7Y43uEXKfviUFRYDfwDIrMV rRTPphdF0qeiMRSwSaQinxn6tNZH9jk= From: Oliver Upton To: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Catalin Marinas , Will Deacon Cc: 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: [PATCH 2/4] KVM: arm64: Don't serialize if the access flag isn't set Date: Tue, 29 Nov 2022 19:19:44 +0000 Message-Id: <20221129191946.1735662-3-oliver.upton@linux.dev> In-Reply-To: <20221129191946.1735662-1-oliver.upton@linux.dev> References: <20221129191946.1735662-1-oliver.upton@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, 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 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); + return pte; } -- 2.38.1.584.g0f3c55d4c2-goog