From patchwork Fri Dec 2 18:51:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 29081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1023861wrr; Fri, 2 Dec 2022 11:04:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf57wwu5MqF+5BarHJagKLxvoU2ixh19tK1NNcioTjBTDkHVVeVCmxYjpbIzNwR8nhgOKya1 X-Received: by 2002:a17:906:c0c:b0:78d:77b1:a433 with SMTP id s12-20020a1709060c0c00b0078d77b1a433mr60924811ejf.486.1670007850764; Fri, 02 Dec 2022 11:04:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670007850; cv=none; d=google.com; s=arc-20160816; b=G7PBqZK1EAQNFscF+WPf52kAKSWUQn3WKjcnuoDE6OvLoutucRm1KBNhzFzgWC1P6+ rJYyXqi/MQ022U8vqcz4JfGTNvAmFKvOhiSljDvZbeCLreKzb7+kSGLvjB+fvO1BICq1 KgUTWyyFUD1jGJHa+a0czGRi6grzySj0SSI/vKrEhtszmaPPmEfV/tCRPWTLmqIe35FB KTyd9dT9mfVFnZPqelCpGcAcRmNi3Vk9Rt4Lx3UPp6VY1rHgmD4kyhuBl2k+DR+gB2Bu 9kXmgQ2TCdEQanBE9AKy3xz9Sq7n1JrQ2b24ewJEqEPyMxxootQlebCOAcKrjXfS62Xm SvXw== 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=9ZCh4EK+ILrdNiTkDxgoQos8GcG756fNB3ErlzEuT8I=; b=AdhB7MB2c7/gNhE22TK/QOGgXuUCbwR/bAy3hW7Sf4ztXR7kawHbtgGx/PTUG3q7Ns yWrIlEEADq6WF1I3FIKbR8GUiaaVWzUqSVy7YzzeGC57H2cdWi/RgKWP2DfxypwtiVAb pYaceUsAfA1LZiv50JvzPKtQUELTl1eY34DghfL8KYOL7OvXeDDcW4GB2R0/Nt3RFKp4 qqHBIrLnhF84mOJJQ+LHnbkWaCZOGa9oNmNjsh2VaWF0gXhZrT3L7z75lgPT7ETef/h6 suWammCY/65BA+eIeQ+uCbhhQK3agJ6jR8F10A0mHtUvHVIiHSXSqhP+bWBwRdf1JaZi aJTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="oIRtW/qt"; 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 e6-20020a056402190600b00468cd2ab847si6943231edz.172.2022.12.02.11.03.39; Fri, 02 Dec 2022 11:04:10 -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="oIRtW/qt"; 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 S234705AbiLBSwm (ORCPT + 99 others); Fri, 2 Dec 2022 13:52:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234655AbiLBSw0 (ORCPT ); Fri, 2 Dec 2022 13:52:26 -0500 Received: from out-137.mta0.migadu.com (out-137.mta0.migadu.com [IPv6:2001:41d0:1004:224b::89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6901EE344D for ; Fri, 2 Dec 2022 10:52:25 -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=1670007143; 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=9ZCh4EK+ILrdNiTkDxgoQos8GcG756fNB3ErlzEuT8I=; b=oIRtW/qtFE+f4BRGQbkhz9LDxzzx4jHeyI9Kr0i7Q8X237Bcpai7BotPaX/3hUG5tesQIk cEyEUI31AfdEY2A3AHbp0YGJ75fHka73HJXRL0JgsS4pFl9SRkWSiwXdZxTV0TuRmHmuEf YhFScCjKQgwpM8fNDDxvtEDM8wq+Q8E= 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, Ricardo Koller , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] KVM: arm64: Don't serialize if the access flag isn't set Date: Fri, 2 Dec 2022 18:51:54 +0000 Message-Id: <20221202185156.696189-5-oliver.upton@linux.dev> In-Reply-To: <20221202185156.696189-1-oliver.upton@linux.dev> References: <20221202185156.696189-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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?1751130152123231916?= X-GMAIL-MSGID: =?utf-8?q?1751130152123231916?= 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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 204e59e05674..aa36d896bd8c 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -1116,10 +1116,14 @@ 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, - KVM_PGTABLE_WALK_HANDLE_FAULT); - dsb(ishst); + int ret; + + ret = stage2_update_leaf_attrs(pgt, addr, 1, KVM_PTE_LEAF_ATTR_LO_S2_AF, 0, + &pte, NULL, + KVM_PGTABLE_WALK_HANDLE_FAULT); + if (!ret) + dsb(ishst); + return pte; }