From patchwork Tue Nov 29 19:19:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 27440 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp525136wrr; Tue, 29 Nov 2022 11:23:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf6CZ9Z1ne8CMarJs7Rnj8Cx6jLW0I1MFuPaMHoMsiPNSKQYHaYQthq8L5+Knw3Ziiicj7L5 X-Received: by 2002:a17:907:908d:b0:7be:fbc9:df5 with SMTP id ge13-20020a170907908d00b007befbc90df5mr11659891ejb.316.1669749809045; Tue, 29 Nov 2022 11:23:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669749809; cv=none; d=google.com; s=arc-20160816; b=X+ZcgNVO9reV/Gohu8Bsh3VztpeeqySVPBW85B2zqfUxJSZWk4tdXL6aIxRaYNwpIW MoWAQS3I8TmaSvHkJQHONjzdunVXiSDiHhWqFTNZGms6RX8mWCTbhOLPfTFqN61X6+lP yr3JQbYoR0uIKplidpErhoZ2OD+R/+P6AmfBsdB1jla5twKPZKGfH88mAPeVgp6WDcE9 1pWL2trMPLVC+RyjT0X3xQ8P7bPxpwYC0KmRZgOrPfh1xKF0sNUstKVB4DE3f70ghY0m uBxr7AR3LW8nzFqBb4+WGD13kFFm1gs4C3vK0FoCJXs5G+DlQxCTqbfUUPm7He6qdaVp NwnA== 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=kcCcdEvvwNGIdQ75NLzM3W5ItGtWtDkpHRzsetWKNGE=; b=iFSesaAdHhC77u160TDOVCV9QC9L99jAi2D3cSCHUTZ15+phBtjYZkbmD9IFmwI+VU hkZRwY/q8Y9Awh5jlHOgOekHYw872So8y5H5GrayspZpWl1gL5TeDHGTT8aHCqd2XOUk MYR1MvjZ4MITmljuthpbOkTgQC4mIo0M0O/Y25P7uWJSv8YCXiz0l4GvxIkG+0FR+Pc2 UTyNfAjk0M22ycpHYhacS54TxWXWP4hU/CLRLV9gqPHiTelTnXmZZzYFZ21PNiLDhhFp APlnvrZz1jKHw+7FDiHd3Ur7oyQZ1zrMwWlk4t4UXib+1LD+8Pvc1hl1qa17l5x21qDR EpQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=hxIfAAIn; 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 hq29-20020a1709073f1d00b007adef1dceffsi3713847ejc.677.2022.11.29.11.23.05; Tue, 29 Nov 2022 11:23:29 -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=hxIfAAIn; 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 S236904AbiK2TVh (ORCPT + 99 others); Tue, 29 Nov 2022 14:21:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236737AbiK2TUw (ORCPT ); Tue, 29 Nov 2022 14:20:52 -0500 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12AFF6B3BF; Tue, 29 Nov 2022 11:20:04 -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=1669749602; 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=kcCcdEvvwNGIdQ75NLzM3W5ItGtWtDkpHRzsetWKNGE=; b=hxIfAAInTnpV80RJl1MOplU9B+F7wko1aZ0kXwoNfPeIZ7mLgQMPu/2k0UoJcp40WP/Rbd 2bDrV8+x6MOHHN9BWWHQ5tkBOIM2kbW4M6a6SKLfqI8MCQ80kj47HEfkIrGFCirYKQP9u7 OmDozB0QEQ52eFKqV6Kq+CasS6AhCOg= 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 3/4] KVM: arm64: Handle access faults behind the read lock Date: Tue, 29 Nov 2022 19:19:45 +0000 Message-Id: <20221129191946.1735662-4-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?1750859575624417518?= X-GMAIL-MSGID: =?utf-8?q?1750859575624417518?= As the underlying software walkers are able to traverse and update stage-2 in parallel there is no need to serialize access faults. Only take the read lock when handling an access fault. Signed-off-by: Oliver Upton Reviewed-by: Ricardo Koller --- arch/arm64/kvm/hyp/pgtable.c | 2 +- arch/arm64/kvm/mmu.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 9626f615d9b8..1a3dd9774707 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -1097,7 +1097,7 @@ kvm_pte_t kvm_pgtable_stage2_mkyoung(struct kvm_pgtable *pgt, u64 addr) int ret; ret = stage2_update_leaf_attrs(pgt, addr, 1, KVM_PTE_LEAF_ATTR_LO_S2_AF, 0, - &pte, NULL, 0); + &pte, NULL, KVM_PGTABLE_WALK_SHARED); if (!ret) dsb(ishst); diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 886ad5ee767a..347985a56414 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1404,10 +1404,10 @@ static void handle_access_fault(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa) trace_kvm_access_fault(fault_ipa); - write_lock(&vcpu->kvm->mmu_lock); + read_lock(&vcpu->kvm->mmu_lock); mmu = vcpu->arch.hw_mmu; pte = kvm_pgtable_stage2_mkyoung(mmu->pgt, fault_ipa); - write_unlock(&vcpu->kvm->mmu_lock); + read_unlock(&vcpu->kvm->mmu_lock); if (kvm_pte_valid(pte)) kvm_set_pfn_accessed(kvm_pte_to_pfn(pte));