From patchwork Fri Dec 2 18:51:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 13063127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0F93FC4321E for ; Fri, 2 Dec 2022 18:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=rgytUGZPhkkUw6Ae8wnOyPLGhO8/Fz5Ad/98weuj1E8=; b=z6qGfbLftR+GPN iEBgYrLh5IzejghMm9aeGI0R1fF6cyHr7Kpcf0nYg9an7Hwr97N97ymatzr0og9Y49O686+CwORDw ejrF0IUDqYcEuhwXxSAlio6Ids8upLOv04vML3IX5fHkAm2SQhfK81SwjY1Bq9TvGoGzycOuM1/yw a36uM3IfSSjU8HW4MNsf4E2PZBIvPJxRiqmjEpyeXTAJpH3zInauRCuTZu7kM+DAehUqOwRfzM5wU DY75eKXPMG0WqhI1tGfsp6nYQWK6PVpHUJNDqVIrfcwGgnMChkKaRpAtv+FljwUKT4tTZJxMbZbKI kHNcgi+shgW4yWxXMQtA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p1B9E-000ltC-Bz; Fri, 02 Dec 2022 18:52:32 +0000 Received: from out-4.mta0.migadu.com ([2001:41d0:1004:224b::4]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p1B91-000lkp-Lw for linux-arm-kernel@lists.infradead.org; Fri, 02 Dec 2022 18:52:21 +0000 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=1670007131; 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; bh=MpKufAjAF/g+30wBdMSCH1h9pcp+y/qwWl4scHSVwd4=; b=wcSk4Oflw5w66Zb3y27I3DVuLOMQIEX76IgGexKJezpSQlE5vmVXPET/3ip7LhrWnDFOd+ FJ0GAe3PLG97aPbXwdKnt6bIMgiiNw5tjqCGKWTKKg09t/29Ba6u4EEr5oajOsQPc0BxHS 7T/8dWxxJcOIM1fPgY3A8AXwuBTWajI= From: Oliver Upton To: Marc Zyngier , James Morse , Alexandru Elisei Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kvmarm@lists.linux.dev, Ricardo Koller , Oliver Upton Subject: [PATCH v2 0/6] KVM: arm64: Parallel access faults Date: Fri, 2 Dec 2022 18:51:50 +0000 Message-Id: <20221202185156.696189-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221202_105220_171238_7D7F4032 X-CRM114-Status: GOOD ( 13.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When I implemented the parallel faults series I was mostly focused on improving the performance of 8.1+ implementations which bring us FEAT_HAFDBS. In so doing, I failed to put access faults on the read side of the MMU lock. Anyhow, this small series adds support for handling access faults in parallel, piling on top of the infrastructure from the first parallel faults series. Patch 1 is a nit I had when working on this series. Patches 2-4 improve the retry logic to avoid unnecessarily serializing and/or invalidating when an attr walker has no effect on the page tables due to a race. I added a flag to indicate whether or not a table walk takes place within a fault handler to decide whether or not an early return is necessary for EAGAIN. We could probably pile even more onto this in the future with lock contention and need_resched() detection. Patch 5 rolls over access faults to the read lock. Finally, patch 6 guards KVM's use of VTCR_EL2.HA with the corresponding kernel config option for FEAT_HAFDBS. FWIW, it is rather useful for testing access faults on systems that implement FEAT_HAFDBS. Applies to kvmarm/next. Tested on Ampere Altra w/ VTCR_EL2.HA=0 and lockdep enabled. v1 -> v2: - Don't serialize if attr walker fails due to an invalid PTE (Ricardo) - Rejig the error handling path in the table walker to suppress EAGAIN in non-fault handling paths v1: https://lore.kernel.org/kvmarm/20221129191946.1735662-1-oliver.upton@linux.dev Oliver Upton (6): KVM: arm64: Use KVM's pte type/helpers in handle_access_fault() KVM: arm64: Ignore EAGAIN for walks outside of a fault KVM: arm64: Return EAGAIN for invalid PTE in attr walker KVM: arm64: Don't serialize if the access flag isn't set KVM: arm64: Handle access faults behind the read lock KVM: arm64: Condition HW AF updates on config option arch/arm64/include/asm/kvm_pgtable.h | 8 ++++++ arch/arm64/kvm/hyp/pgtable.c | 43 ++++++++++++++++++++++++---- arch/arm64/kvm/mmu.c | 18 ++++++------ 3 files changed, 54 insertions(+), 15 deletions(-) base-commit: edf3e6d30db78cc37bb57944b2255225aa73bbe8