From patchwork Tue Aug 13 10:05:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13761720 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 074EAC52D7C for ; Tue, 13 Aug 2024 10:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=PG5zo3jK+snJIwQfy2t2IdCs4QyJPz6Ok4TryqgSgJ0=; b=cQCqanhi9bFt9lRlx0nm6hYTkd 1WgA6vkj5BZIQR5EkgB2UHU+EurJcSjZkPH/4ZbEniQup9fZEIFvvwj/MnpWvkTlRQ3BFSwarR3Pr 8XJVzL0acFqVS6Tcr22dTiTUy/Y/pKT5WPGccJ52xaAFKrEFL5P6KjTY8YzPmL1UMWOBrxlfV3GB1 7FB10kP/XPDNHg58ARySrlYmy7gYQYL8BAlUvSVpp6zNogbJXWVtnG7eyMlcV2TuTaIHMug7sIWOp QkrL2Vqed/fcHoWop4y+XrmwOfoOo0Z94gUgiYg5EocIMUSZPtdF4AMYSO7a0T8lu8w+ihwfuzfQL HeEgtOWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdoTb-00000003Hab-2aCp; Tue, 13 Aug 2024 10:10:03 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdoQ2-00000003GNe-2WzE for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 10:06:25 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 01052CE122F; Tue, 13 Aug 2024 10:06:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E0DFC4AF0B; Tue, 13 Aug 2024 10:06:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723543580; bh=v/WFY2PsBYnRktkH3GEMaO5LRP0wVQZKrpi3TzcVUkc=; h=From:To:Cc:Subject:Date:From; b=HWqSpkWrryMEx0xAuWvwA4ROoJdE0G1dowAP7Ybg+iljVMNhqKKqr8Mi/B/APvD9k vK/RIu6lpTzkVq2dcY6ZscL+X1idcHltZzi/+44YP2gDTFQanVhacvncUFzqcJV22E tcbo7pZsreFZOTC3oSNTi0HcjSHWThG/dwn/+W0ld3EnEZiGZC00+ExGBFldYNgPsH YIvLVzRDlCQxZYEjgFSni+3ldDBix7RhD/6Le7AgOVeuTSIpCq9XYjxR6mMUBtXdfl geKT5s3KQxtdDNWYJjcJQjf1r839LH9XnfnawLdI9W/f305HzgN49mh6yC8ch1Ztvp w+L3DPABQivpg== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sdoPx-003INM-NW; Tue, 13 Aug 2024 11:06:18 +0100 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Joey Gouly , Alexandru Elisei , Anshuman Khandual , Przemyslaw Gaj Subject: [PATCH v3 00/18] KVM: arm64: nv: Add support for address translation instructions Date: Tue, 13 Aug 2024 11:05:22 +0100 Message-Id: <20240813100540.1955263-1-maz@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, joey.gouly@arm.com, alexandru.elisei@arm.com, anshuman.khandual@arm.com, pgaj@cadence.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240813_030623_160478_D2959728 X-CRM114-Status: GOOD ( 12.25 ) 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 This is the third revision of the address translation emulation for NV support on arm64 previously posted at [1]. Thanks again to Alex for his continuous (contiguous? ;-) scrutiny on this series. * From v2: - Correct handling of the alignment implied by the contiguous bit in both S1 and S2 walkers - Correct handling of EL1&0 translation being disabled when HCR_EL2.{E2H,TGE} = {0,1} - Force S2 being enabled when HCR_EL2.DC = 1 - Handle PAR_EL1.NSE as RES1 - Report the full PA on a successful translation - Various cleanups I've added the usual reviewers on Cc, plus people who explicitly asked to be on it, and people who seem to be super keen on NV. Patches on top of 6.11-rc1, tested on my usual M2 (so VHE only). FWIW, I plan to take this into 6.12. [1] https://lore.kernel.org/r/20240731194030.1991237-1-maz@kernel.org Joey Gouly (1): KVM: arm64: Make kvm_at() take an OP_AT_* Marc Zyngier (17): arm64: Add missing APTable and TCR_ELx.HPD masks arm64: Add PAR_EL1 field description arm64: Add system register encoding for PSTATE.PAN arm64: Add ESR_ELx_FSC_ADDRSZ_L() helper KVM: arm64: nv: Enforce S2 alignment when contiguous bit is set KVM: arm64: nv: Turn upper_attr for S2 walk into the full descriptor KVM: arm64: nv: Honor absence of FEAT_PAN2 KVM: arm64: nv: Add basic emulation of AT S1E{0,1}{R,W} KVM: arm64: nv: Add basic emulation of AT S1E1{R,W}P KVM: arm64: nv: Add basic emulation of AT S1E2{R,W} KVM: arm64: nv: Add emulation of AT S12E{0,1}{R,W} KVM: arm64: nv: Make ps_to_output_size() generally available KVM: arm64: nv: Add SW walker for AT S1 emulation KVM: arm64: nv: Sanitise SCTLR_EL1.EPAN according to VM configuration KVM: arm64: nv: Make AT+PAN instructions aware of FEAT_PAN3 KVM: arm64: nv: Plumb handling of AT S1* traps from EL2 KVM: arm64: nv: Add support for FEAT_ATS1A arch/arm64/include/asm/esr.h | 5 +- arch/arm64/include/asm/kvm_arm.h | 1 + arch/arm64/include/asm/kvm_asm.h | 6 +- arch/arm64/include/asm/kvm_nested.h | 40 +- arch/arm64/include/asm/pgtable-hwdef.h | 9 + arch/arm64/include/asm/sysreg.h | 22 + arch/arm64/kvm/Makefile | 2 +- arch/arm64/kvm/at.c | 1098 ++++++++++++++++++++++++ arch/arm64/kvm/emulate-nested.c | 2 + arch/arm64/kvm/hyp/include/hyp/fault.h | 2 +- arch/arm64/kvm/nested.c | 41 +- arch/arm64/kvm/sys_regs.c | 60 ++ 12 files changed, 1256 insertions(+), 32 deletions(-) create mode 100644 arch/arm64/kvm/at.c