Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2566759rwb; Fri, 2 Dec 2022 11:33:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf4L6RNYyHBkyW7vHjmDZ5XyNCe/0NAe1SOjoy6DVw5rwtkuxu5DoVIn7oCvCl4THhF8IjFg X-Received: by 2002:aa7:cb07:0:b0:463:ca19:6cdf with SMTP id s7-20020aa7cb07000000b00463ca196cdfmr20889203edt.379.1670009585975; Fri, 02 Dec 2022 11:33:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670009585; cv=none; d=google.com; s=arc-20160816; b=dhhB2vU5/cyl3YNhACiGj1cJefQbCLxmVLL5DarkuPRb2MwcP3ffyKS6vXm/lADfYk d0hIwRq20wc2j4enbsFCKugGld//c8qW8XR30dSjx0SYt9c7YySpYg1CE4AH5OfW/uqS uhoS8Rg6UxK9D/9cAfWn2CjmPHn40fCsbBX8vwU6eMfWK6v7z9FHpMh11X6EHot6FK+R +49oYyiwbqK1dvWHAE79UD4tSpuVEXfxtlNetNJj+TZwDqYZc+tQlrbmfteXkPKp1dMJ XCFOHdZNRsq464zzAu6XmK3GqyKjj43axCfDBRAdUaqtvDO17tM5Bu3BpgTb18q7GdFB 3ajQ== 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=36q34GkAdZNcp02VfFJ/fMceb+GlTAxgwL6t8UJ/nCU=; b=NPbKBrfMcTvr5HReyilSUVcPrts7QqTi366HBcNlMNKVX+NDy373usSEhMjb2Lkhl7 3m8bww8mQ+nia5B2F8w4ZvQQ5+hNNuivjMR3kGeiSV0bpS1UA0jgfVBc2LQCVC3nzfAA HjXZc2Bb+MMcvcTl/YfsaFs7C2TcBCvZTAcV4rsIrj4DAS/eLuaPIDeTAMSSQJPJc3h6 qwCion/VTCzrPpSYjWSTazHTfWXaxRNJxBIfXJXnt5bpdYdtS1ijK5ap+f6CYB5PG0Ef 0I8bpOikuq5rypcIVpAMeuQf9r22rGYZuQnjg92dUXaHT3B/wrgXDvxhglAr44I18Mt2 rE4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=LAPfFRXk; 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 bt9-20020a0564020a4900b0045d27c0ba90si6232438edb.577.2022.12.02.11.32.46; Fri, 02 Dec 2022 11:33:05 -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=LAPfFRXk; 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 S234740AbiLBSwp (ORCPT + 82 others); Fri, 2 Dec 2022 13:52:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234699AbiLBSwg (ORCPT ); Fri, 2 Dec 2022 13:52:36 -0500 Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48461EAB52 for ; Fri, 2 Dec 2022 10:52:28 -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=1670007146; 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=36q34GkAdZNcp02VfFJ/fMceb+GlTAxgwL6t8UJ/nCU=; b=LAPfFRXkfCOfssjRADm7/jdYZ7LQl2uW9dy14PfWeo2914srk2DSSW7OAI1GrB7JEscgbY DxllYbdQAX26FIFaFFLzCntc4Uhua5fSy2WeUOjvTWcv81z6joZgp064csO8ICW67kHF+9 cSAdicod8mmQR59+MNnYmUOZe79b8Wc= 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 5/6] KVM: arm64: Handle access faults behind the read lock Date: Fri, 2 Dec 2022 18:51:55 +0000 Message-Id: <20221202185156.696189-6-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 Content-Transfer-Encoding: 8bit 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=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 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 --- arch/arm64/kvm/hyp/pgtable.c | 3 ++- arch/arm64/kvm/mmu.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index aa36d896bd8c..30575b5f5dcd 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -1120,7 +1120,8 @@ kvm_pte_t kvm_pgtable_stage2_mkyoung(struct kvm_pgtable *pgt, u64 addr) ret = stage2_update_leaf_attrs(pgt, addr, 1, KVM_PTE_LEAF_ATTR_LO_S2_AF, 0, &pte, NULL, - KVM_PGTABLE_WALK_HANDLE_FAULT); + KVM_PGTABLE_WALK_HANDLE_FAULT | + KVM_PGTABLE_WALK_SHARED); if (!ret) dsb(ishst); diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index dd8c715f0775..25e18e1d9a15 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1406,10 +1406,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)); -- 2.39.0.rc0.267.gcb52ba06e7-goog