From patchwork Tue Aug 13 10:05:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13761727 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 7E445C52D7C for ; Tue, 13 Aug 2024 10:14:27 +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:References:In-Reply-To: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:List-Owner; bh=BR8XjVxQJMt7HI3zHrJctfF2y7gan+sMlU5fhZWby8Q=; b=IDGPGHbFlXBfyFRSphwaPJf4/F rNl0v6+4+E2zDb6Lno09h2JVNQP8LqOqRHcNJ3SJU+J6PPSVnkVCQPyj4wH3mRx0xM4Pgvjpun7l0 POPxVYDtbZbPmP2OP+1eD/P9oz1nX40Zj2eIOOe0ngZxPLKb8Qpyoe2DYhqci5q+qy7GU2rjzaRKF JF4tWsXbHmw3kQPe/HaLWmjZOTPLf2uyKmw+gEydRok2Hdp1/+yRp/dOUnqkISDdnca58szaasbd3 NfWYZD2yqxLgeZKfJaAgiIz1kbhW6gnr3MdkHj57C2kmyKAn11kX+tyVUkxLNaoKLlnI01pDFOJTG pu0LIxFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdoXg-00000003IcK-2aaK; Tue, 13 Aug 2024 10:14:16 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdoQ6-00000003GOz-3xSp for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 10:06:28 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B90A661517; Tue, 13 Aug 2024 10:06:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B6ABC4AF0B; Tue, 13 Aug 2024 10:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723543586; bh=k5pYh1Yp0jxWFeMrnF7ay2rjkHNJ1NpYhUlOrVS5zOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VRC/4bmTLyuwuolk24h8yGyazcih61qk3FA3U81mB3P4P6iCtXl7pc877i74eExNQ lwsAMXihYCyGN2NYFJJJ81g8Y8cCq0PF6FXaeSFoYu+9Z1WadfUnahvgcjLKHjNXCD SxaQr6oEBkEh4nOTKpyFhltmAaWOAgHzJKHLnaMBLkdR0kw0fFOVGKERAKlbw9HKly MH9QMkiBrMk+EI9+q578Y3qtJX1c7HXJHzIy0wxJhcwObTUEwMjch00CGuygVDdkTA YFXFCDQ00K2RdRBKkexmPoSyb1cV7PEz2IKy1ye4X+M9t2I0zpHsB5ZSGxdxRZAa8K HD6fd9KLJAnqw== 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 1sdoQ4-003INM-GQ; Tue, 13 Aug 2024 11:06:24 +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 15/18] KVM: arm64: nv: Sanitise SCTLR_EL1.EPAN according to VM configuration Date: Tue, 13 Aug 2024 11:05:37 +0100 Message-Id: <20240813100540.1955263-16-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240813100540.1955263-1-maz@kernel.org> References: <20240813100540.1955263-1-maz@kernel.org> 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_030627_144008_6AAF9FB9 X-CRM114-Status: UNSURE ( 9.36 ) X-CRM114-Notice: Please train this message. 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 Ensure that SCTLR_EL1.EPAN is RES0 when FEAT_PAN3 isn't supported. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/nested.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c index 9c8573493d80..133cc2f9530d 100644 --- a/arch/arm64/kvm/nested.c +++ b/arch/arm64/kvm/nested.c @@ -1178,6 +1178,14 @@ int kvm_init_nv_sysregs(struct kvm *kvm) if (!kvm_has_feat(kvm, ID_AA64PFR0_EL1, AMU, V1P1)) res0 |= ~(res0 | res1); set_sysreg_masks(kvm, HAFGRTR_EL2, res0, res1); + + /* SCTLR_EL1 */ + res0 = SCTLR_EL1_RES0; + res1 = SCTLR_EL1_RES1; + if (!kvm_has_feat(kvm, ID_AA64MMFR1_EL1, PAN, PAN3)) + res0 |= SCTLR_EL1_EPAN; + set_sysreg_masks(kvm, SCTLR_EL1, res0, res1); + out: mutex_unlock(&kvm->arch.config_lock);