From patchwork Wed Jul 31 19:40:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13749138 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 C2863C3DA64 for ; Wed, 31 Jul 2024 19:46:35 +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=qBnumZflVqv3PqO2T3RQbSfFR7egmWccwFSwzxcl2D4=; b=YA2+EaLsYzyVYpZ1zqc0PBSt37 q++MtOPaeXX0yrKrccs15QIa+oP7Lq0zgbH62ydqqep8t7/1iNZtuTFUFKRSaiVwQH8xXHxUAx20r JZWyp429H7fvMZMuLycUUyp2IuQZqtKyMnwE8UR3qtUtzlhYw8vR4RZ19sqZbVd3EAWeqM/+Jp601 Vwxvj2abf4NwdvPxNgJarLXW4OMIuSfIHXOfEy/jQeL8UNbPu/KnkegsmcbbPK33mc8Fjggxl6oB6 HRwLbDb2hTHeOyy5uz067b5hROfRiH/cwD/KxhDivuDPSRpacVLkw0CEq7rXsxjLkdGiEgfzu2L+l /fRKVO8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZFHH-00000002LSq-1INL; Wed, 31 Jul 2024 19:46:27 +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 1sZFBy-00000002Ji9-3Uym for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2024 19:41:01 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0F89B6260D; Wed, 31 Jul 2024 19:40:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D60FBC4AF0C; Wed, 31 Jul 2024 19:40:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722454857; bh=uc/Qe35gZW02M6/sXnL0DztYlbiBUpvo0PQh5rguJxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sVxlmT2VuQHXliEJP3UfQazQ7yt7tpLRgKTkPAJNIVHzsdCaz2lfrwflS+habEhkm fp7xz9DPexmrzuXPT49IDi8z2qlJPVRW1zSgM89gTao2XSiSXnCQoBuEegsv4gllVj 9ZA9U8Gyo/uSlCN+YKk5oFibYMuzUEFKAs9gc03jZ3ihcUC2OEvSDOt05+fVzpSwUF wM9Su7egNVZ9+bSCOBY2J+75w3JE8uKE8sjZ0Vm8g+9I4A4sOIdpO3JgzptoTlzWMd GaQB1qU1TvIqZXz3IXAZFPyzAXrwON9qHC+6UI7prbYm3AZsO7Ll+g0iRaEQ/22wck Mo8grdcS5Js4w== 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 1sZFBv-00H6Gh-Vz; Wed, 31 Jul 2024 20:40:56 +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 14/17] KVM: arm64: nv: Sanitise SCTLR_EL1.EPAN according to VM configuration Date: Wed, 31 Jul 2024 20:40:27 +0100 Message-Id: <20240731194030.1991237-15-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240731194030.1991237-1-maz@kernel.org> References: <20240731194030.1991237-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-20240731_124059_145092_B9F486EB X-CRM114-Status: UNSURE ( 9.42 ) 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 695a1b774250..0c70104c0d1a 100644 --- a/arch/arm64/kvm/nested.c +++ b/arch/arm64/kvm/nested.c @@ -1181,6 +1181,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);