From patchwork Tue Nov 29 19:19:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 27439 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp525008wrr; Tue, 29 Nov 2022 11:23:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf4yGBInrK6gQgGY+ivZuFKuA4OD4REL6l8FVi80v89GCN+n41QD++goJ/AW1qBr9B93TFES X-Received: by 2002:a05:6402:1802:b0:461:72cb:e5d with SMTP id g2-20020a056402180200b0046172cb0e5dmr44659444edy.410.1669749792089; Tue, 29 Nov 2022 11:23:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669749792; cv=none; d=google.com; s=arc-20160816; b=GJamiKCY03PM5x9kFExIEV5RgkwoTxupJX7w9VTVBHJyYD1aPeS+jCGSvwY2LnCDFR tjipyDlk/bVPFiQhh5oKDEZtMl6NT8DVF4C1C0onSeQr/Stk2RvgiIouHXNXc5/zxAyH g63oYv8Vr5PbQP5h2lSwlfSEkBh9CTglI9CptDyPYjhRN6iQho9DbK/iaWBtQK8irhtr cEkpVwimQ1/SE+bWGD+QBVT2skpOWIvp0HPsXsyVZpv76f5V4ARxG4FZlCosrzXHsWqf NB+WntrZu/j/kUQNL0Bp6XlTeJDny3l8TJ6BpMr+3DlMK1UrxjeyzHv3Niu3H2XL0tFp SxKg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr12-20020a170907720c00b007c093acadb0si895999ejc.508.2022.11.29.11.22.47; Tue, 29 Nov 2022 11:23:12 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750859558048241282?= X-GMAIL-MSGID: =?utf-8?q?1750859558048241282?= 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; }