From patchwork Thu Oct 27 20:52:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13022800 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 2D44DECAAA1 for ; Thu, 27 Oct 2022 20:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=X5341vxoDWnKASmWI21Xia574oe7aAH1zJon7YzhGRk=; b=yx0IIoI4VOMZ20 H4VLek+3pj7X1PrHw0TcHN0vKdHhORX/T84bqBmFG6+QDlbiEtETxw7goDkV+7qRufE1CcrcTA4gl cbTxa0AjnRaHFD8LA3/ZPNHmGBJA1DdgMzIQW7ZscmRKzxh0ItAYxwmH6j0MBx9/+AQiUXnVInXjR 3fW4QuxIu9ikHb+ZQwD+QqJn/QgB3TEdoAHd7pRQ2aGGeiStHCOXNLFPUC7VgxpdmXKb0YZwOuCzp g3Hb9UEPy2FUqCtIuzUwlrTEEGnLYk2MctcmvNSkz6JzVDm5hYSr0OJ9GmjB2MWh3nCxyFRg88xBF XEnCzSdyGFu5jB31aYnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oo9u0-00EpRC-Dv; Thu, 27 Oct 2022 20:55:00 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oo9tp-00EpL6-E3 for linux-arm-kernel@lists.infradead.org; Thu, 27 Oct 2022 20:54:50 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F1CDC62354; Thu, 27 Oct 2022 20:54:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2A32C4347C; Thu, 27 Oct 2022 20:54:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666904088; bh=/AKwgKBPS34TJN9xSbPvH4wu8dyp6VYAWHZyFzMFBnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dpVheP2fqZFjtrKGL1aJjo7xXiAV2MuOHnu1RiBvo8XcG6hntz/kBH/weenAzDuxU OmS8OU2u9iZtQIi7wCdWCj7PqIPI1g81E7BU6S7fiU1hqQb5a/QZ88qlA4uwjyasoV Qvda5BKHXFe/jdyXTMC6SNvCBeMnm+kW1O1pXA4yhH8A0B6NFKwkzdVCJDzwkNWuLl MPLF71F9+oyjYcY93wGCzskEZ52NUWBPKaqZoHIdYCyGe2y9yKf6QBLpKUgR/P1td4 J0jBKwee97HdxcgmJN/gIZ+/syRPx3JSHatVynP3ETD/Emlanyg///VM81DqFL4Kr2 lD0cEHiu4e1+g== From: Mark Brown To: Catalin Marinas , Will Deacon , Marc Zyngier Cc: Peter Maydell , Richard Henderson , Vincent Donnefort , James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Mark Brown Subject: [PATCH v1 1/2] arm64/cpufeature: Add feature detection for fine grained traps Date: Thu, 27 Oct 2022 21:52:45 +0100 Message-Id: <20221027205246.812586-2-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221027205246.812586-1-broonie@kernel.org> References: <20221027205246.812586-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1628; i=broonie@kernel.org; h=from:subject; bh=/AKwgKBPS34TJN9xSbPvH4wu8dyp6VYAWHZyFzMFBnQ=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjWu+dcWQPnyvrmOR/gKkknxog/b3aiZIuoy/0eD/8 6SZ1pCmJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY1rvnQAKCRAk1otyXVSH0Bq7B/ 0XDvJXAeTTVFp75Ogtab9ldE7yB0M4JhkrH7Jtf5aFtnIIZQ8cC8M0P85LH0mPs4baIXkbHsm3XV60 9MgzuW2DjWjShxJDDb3JmdLvdCpDZKIDC8GtHg9+mTleu6hhppaRuomchW/OHTKRwbzceAum3xmRbt oreobvdS1qlTNw8hBxYcvAmlIdqbMMAzntXrDaN9mT365GR9mrsv7czL3haFHk1zcLCBz9Mx/5/maY VpFlczMLyKBrui6QnQENiMDsN77FB3ZXWpGnjw5bzCZNWPsLixK6326KysmnWQOed8mIwR3lr8pxkz p+DZoPysXY9ag+FBHHeq69qTJzfpvd X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221027_135449_563395_3715B0F6 X-CRM114-Status: GOOD ( 13.10 ) 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 Virtualisation support for SME depends on FEAT_FGT since it uses fine grained traps to control access to SMPRI_EL1 and (for nVHE) TPIDR2_EL0 but systems have been encountered which implement SME without VHE. In order to work around such systems we need to detect the absence of FEAT_FGT, add detection in the cpufeature code. Signed-off-by: Mark Brown --- arch/arm64/kernel/cpufeature.c | 11 +++++++++++ arch/arm64/tools/cpucaps | 1 + 2 files changed, 12 insertions(+) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 6062454a9067..8ded72a8ccee 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -2590,6 +2590,17 @@ static const struct arm64_cpu_capabilities arm64_features[] = { .matches = has_cpuid_feature, .min_field_value = 1, }, + { + .desc = "Fine Grained Traps", + .type = ARM64_CPUCAP_SYSTEM_FEATURE, + .capability = ARM64_HAS_FGT, + .sys_reg = SYS_ID_AA64MMFR0_EL1, + .sign = FTR_UNSIGNED, + .field_pos = ID_AA64MMFR0_EL1_FGT_SHIFT, + .field_width = ID_AA64MMFR0_EL1_FGT_WIDTH, + .min_field_value = ID_AA64MMFR0_EL1_FGT_IMP, + .matches = has_cpuid_feature, + }, #ifdef CONFIG_ARM64_SME { .desc = "Scalable Matrix Extension", diff --git a/arch/arm64/tools/cpucaps b/arch/arm64/tools/cpucaps index f1c0347ec31a..2553c7559412 100644 --- a/arch/arm64/tools/cpucaps +++ b/arch/arm64/tools/cpucaps @@ -23,6 +23,7 @@ HAS_DCPOP HAS_E0PD HAS_ECV HAS_EPAN +HAS_FGT HAS_GENERIC_AUTH HAS_GENERIC_AUTH_ARCH_QARMA3 HAS_GENERIC_AUTH_ARCH_QARMA5