From patchwork Wed Jul 31 19:40:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13749128 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 E197DC3DA7F for ; Wed, 31 Jul 2024 19:42:17 +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=ubPzhQTKUrOfWXbekZXhT7qmItqHJPp/S/pgBiU6eqg=; b=GQqaLrmfHrokJEwNGznfu1UVgW wlpkKeyESAPm1Re7b2F0sR5ZWvnsgm/FhMCVc+W/5MLTBFA/erCNmQn1Jx1dAp/eiQkoQ/xm+n1+u oEQntQdOBx2Hx3CD6l6V720My9ofmkqM1+tPbdN9/E16lxWem+PuixxA2hy2yCu6Z1XuC5QnNdTi+ dwuova5h6N1JJvzlT49p2ADSkyps7OHaO+SBtrAxEnwWDMIfrhv43c0e9ma+zmzy9kUfn9gi46oc1 QvXg7XGmX/kv4mpMNRG3VhSnRipo7Hucn7ccy2R61Vp1/WvUt/39qPQz3KH/0xRRhsM9A9CR34Nxz WvDNCazg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZFCS-00000002JyZ-2UBP; Wed, 31 Jul 2024 19:41:28 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZFBw-00000002Jg6-0Z89 for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2024 19:40:57 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 50CA862604; Wed, 31 Jul 2024 19:40:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02D05C4AF0C; Wed, 31 Jul 2024 19:40:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722454855; bh=nZsTfRkPRsBDTl7KWkqYsSA/btlrP7383aII6HM3n8A=; h=From:To:Cc:Subject:Date:From; b=Jirpesr8hL0Saat3zFCWd82wVd9xlaiYSjjEt4PXnxNews/E66FXNGAXW4/rhqRI1 +SKwK9CU4UOFatLuZodIc9h/ZX1hCSxFNS/WeFi/FAMN/dVhI8mTihgLe3gu7YUg10 JAttELO5VpzlUJizWP45nE4nmyY9ydtkIqwdB2q687Rci+HL9aYMIX/ln8k2u04OzS fQdCvcl7ccXf3gwrmL9r1NH51GRjSRORWzEniRm36b5wNRBHGpVjTAO2GVZsYPl13q ADVhYnqe6saqNH6l7Hl1ShCTR1857iSir3CmGlNy/9V55dXrmeyLvV8TCXDJKcDhfM PsO54X91NPNrg== 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 1sZFBs-00H6Gh-U0; Wed, 31 Jul 2024 20:40:52 +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 v2 00/17] KVM: arm64: nv: Add support for address translation instructions Date: Wed, 31 Jul 2024 20:40:13 +0100 Message-Id: <20240731194030.1991237-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-20240731_124056_281624_7B25BD76 X-CRM114-Status: GOOD ( 18.63 ) 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 second revision of the address translation emulation for NV support on arm64 initially posted at [1]. I haven't kept an detailed change log of what happened since, but here are the highlights: * A fair amount has changed in the series, starting with a lot of bugs being fixed thanks to Alex's hard work comparing the implementation and the pseudocode. All credits to him, this is a lot harder than writing code. * At Alex's request, the code structure is now a bit closer to the pseudocode in a number of aspects, so that people can eyeball it more easily. * Whenever I could, I added references to ARM ARM rules to help with cross-referencing the implementation and the requirements. * FEAT_PAN2 support is now implemented using the... FEAT_PAN2 instructions (surprise!) instead of the previous version that was using three different AT instructions. * The code now has the notion of translation regime, which makes it somehow clearer what is going on. I was pretty sceptical about it initially, but it turned out rather OK. * The series has been resplit to make it more digestable. Patch 13 is still on a mission to make you puke. 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). [1] https://lore.kernel.org/r/20240625133508.259829-1-maz@kernel.org Joey Gouly (1): KVM: arm64: Make kvm_at() take an OP_AT_* Marc Zyngier (16): 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: 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 | 18 +- 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 | 1058 ++++++++++++++++++++++++ arch/arm64/kvm/emulate-nested.c | 2 + arch/arm64/kvm/hyp/include/hyp/fault.h | 2 +- arch/arm64/kvm/nested.c | 34 +- arch/arm64/kvm/sys_regs.c | 60 ++ 12 files changed, 1192 insertions(+), 27 deletions(-) create mode 100644 arch/arm64/kvm/at.c