From patchwork Tue Sep 3 15:38:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13788972 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 6AD0ECD3443 for ; Tue, 3 Sep 2024 15:42:04 +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=ihMOu3G1Q4W5E2X7cnMgB+RdZ08G3GnXCImonPs+OSg=; b=ve0pzGkb96ZzeBBPjYAr/mYvKu 935cKOzGdVUKDNp5sSRKSgl7XcW3It7xFWbpwq7h6hDxzTNSV1yofEwqx099HxHe1rT7NNbJe+8Do nFHXrS1H/Lbg6kNuYZOvZE4TcXa/7d0vKEHzTZqtG32YsX6tFwuJaO1X+ModFP4EIsnB3jcWxwFdz QGU2l17MkjbPdzta0EDyaJA3tGnzk57p7o8I/FLC8znCvP5TIQgDGaOnrd8KUmp2F724lwhERXkc7 ZOrcD95g6D3GlC17JHZMjkTeOAzVqTQWVWZxfZf2SIGlM08W0LkcJwfdZTbVBizpMl4SUkPBP8RKZ 6j5SiHmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slVfH-00000000vbP-1WXs; Tue, 03 Sep 2024 15:41:55 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slVcA-00000000uFM-1Qxi for linux-arm-kernel@lists.infradead.org; Tue, 03 Sep 2024 15:38:44 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id D6BFAA43C38; Tue, 3 Sep 2024 15:38:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB79EC4AF0C; Tue, 3 Sep 2024 15:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725377920; bh=sXJfA8yocIirH64sdVHVPy+2Rap5C+AsvH487B5sjXU=; h=From:To:Cc:Subject:Date:From; b=NDRUJ73nNbA+fDvnPwHrallvW66hmfkrnEylnywTOdN8iSM62caLt5VMYE93/DAms AmJoDr+/qBJYaROT0H0nIzRwukgKzN9rsjutR2xVd7Cj5gO6VNs+HngULrgpF3mgYp JtWqlUWFi6vd+vYzwyF0tQYXurTzzES6z8EugdVCHEo4J8QVR04BDiEpbGXvSR/9E/ qAD2XrXhZnrZlcNSR7DZlFHZhdnnF/WL4qj0ChruSzHpdc2aGHzzzeTfVAQH01EMnr aC3KoQcdsNGltLZYlcB2/vzFyeGp1dTM6XXRQNhCy1uZ17mUCSDg6tYHbo0Z6ELOvb kjcpff3n9HWJg== 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 1slVc6-009Hr9-Db; Tue, 03 Sep 2024 16:38:38 +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 , Mark Brown Subject: [PATCH v2 00/16] KVM: arm64: Add EL2 support to FEAT_S1PIE Date: Tue, 3 Sep 2024 16:38:18 +0100 Message-Id: <20240903153834.1909472-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, broonie@kernel.org 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-20240903_083842_539821_1E415649 X-CRM114-Status: GOOD ( 13.38 ) 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 series serves a few purposes: - Complete the S1PIE support to include EL2 - Sneak in the EL2 system register world switch As mentioned in few of the patches, this implementation relies on a very recent fix to the architecture (D22677 in [0]). This series has seen a few changes since the initial posting [1]: - Rebased on top of the AT support branch, which is currently sitting in kvmarm/next - Add handling for S1 indirect permission in AT, which I'm sure will give Alexandru another king-sized headache - Picked Mark Brown's series [2] dealing with TCRX and S1PIE visibility, and slapped an extra fix on top for good measure - Picked up RBs from Joey, with thanks. [0] https://developer.arm.com/documentation/102105/ka-04/ [1] https://lore.kernel.org/r/20240813144738.2048302-1-maz@kernel.org [2] https://lore.kernel.org/r/20240822-kvm-arm64-hide-pie-regs-v2-0-376624fa829c@kernel.org Marc Zyngier (13): KVM: arm64: nv: Handle CNTHCTL_EL2 specially KVM: arm64: nv: Save/Restore vEL2 sysregs KVM: arm64: Add TCR2_EL2 to the sysreg arrays KVM: arm64: Add save/restore for TCR2_EL2 arm64: Add encoding for PIRE0_EL2 arm64: Remove VNCR definition for PIRE0_EL2 KVM: arm64: Add PIR{,E0}_EL2 to the sysreg arrays KVM: arm64: Add save/restore for PIR{,E0}_EL2 KVM: arm64: Handle PIR{,E0}_EL2 traps KVM: arm64: Sanitise ID_AA64MMFR3_EL1 KVM: arm64: Split S1 permission evaluation into direct and hierarchical parts KVM: arm64: Implement AT S1PIE support KVM: arm64: Rely on visibility to let PIR*_ELx/TCR2_ELx UNDEF Mark Brown (3): KVM: arm64: Define helper for EL2 registers with custom visibility KVM: arm64: Hide TCR2_EL1 from userspace when disabled for guests KVM: arm64: Hide S1PIE registers from userspace when disabled for guests arch/arm64/include/asm/kvm_host.h | 9 + arch/arm64/include/asm/vncr_mapping.h | 1 - arch/arm64/kvm/at.c | 296 ++++++++++++++++----- arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 5 +- arch/arm64/kvm/hyp/nvhe/sysreg-sr.c | 2 +- arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 155 ++++++++++- arch/arm64/kvm/sys_regs.c | 114 +++++++- arch/arm64/tools/sysreg | 4 + include/kvm/arm_arch_timer.h | 3 + 9 files changed, 505 insertions(+), 84 deletions(-)