All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: ardb@kernel.org, bertrand.marquis@arm.com,
	boris.ostrovsky@oracle.com, broonie@kernel.org,
	catalin.marinas@arm.com, daniel.lezcano@linaro.org,
	james.morse@arm.com, jgross@suse.com, kristina.martsenko@arm.com,
	mark.rutland@arm.com, maz@kernel.org, oliver.upton@linux.dev,
	pcc@google.com, sstabellini@kernel.org, suzuki.poulose@arm.com,
	tglx@linutronix.de, vladimir.murzin@arm.com, will@kernel.org
Subject: [PATCH v2 11/38] arm64: Use build-time assertions for cpucap ordering
Date: Thu,  5 Oct 2023 10:49:58 +0100	[thread overview]
Message-ID: <20231005095025.1872048-13-mark.rutland@arm.com> (raw)
In-Reply-To: <20231005095025.1872048-1-mark.rutland@arm.com>

Both sme2_kernel_enable() and fa64_kernel_enable() need to run after
sme_kernel_enable(). This happens to be true today as ARM64_SME has a
lower index than either ARM64_SME2 or ARM64_SME_FA64, and both functions
have a comment to this effect.

It would be nicer to have a build-time assertion like we for for
can_use_gic_priorities() and has_gic_prio_relaxed_sync(), as that way
it will be harder to miss any potential breakage.

This patch replaces the comments with build-time assertions.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Will Deacon <will@kernel.org>
---
 arch/arm64/kernel/fpsimd.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index 601b973f90ad2..48338cf8f90bd 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -1310,23 +1310,21 @@ void sme_kernel_enable(const struct arm64_cpu_capabilities *__always_unused p)
 	isb();
 }
 
-/*
- * This must be called after sme_kernel_enable(), we rely on the
- * feature table being sorted to ensure this.
- */
 void sme2_kernel_enable(const struct arm64_cpu_capabilities *__always_unused p)
 {
+	/* This must be enabled after SME */
+	BUILD_BUG_ON(ARM64_SME2 <= ARM64_SME);
+
 	/* Allow use of ZT0 */
 	write_sysreg_s(read_sysreg_s(SYS_SMCR_EL1) | SMCR_ELx_EZT0_MASK,
 		       SYS_SMCR_EL1);
 }
 
-/*
- * This must be called after sme_kernel_enable(), we rely on the
- * feature table being sorted to ensure this.
- */
 void fa64_kernel_enable(const struct arm64_cpu_capabilities *__always_unused p)
 {
+	/* This must be enabled after SME */
+	BUILD_BUG_ON(ARM64_SME_FA64 <= ARM64_SME);
+
 	/* Allow use of FA64 */
 	write_sysreg_s(read_sysreg_s(SYS_SMCR_EL1) | SMCR_ELx_FA64_MASK,
 		       SYS_SMCR_EL1);
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-10-05  9:51 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-05  9:49 [PATCH v2 00/38] arm64: Remove cpus_have_const_cap() Mark Rutland
2023-10-05  9:49 ` [PATCH v2 01/38] clocksource/drivers/arm_arch_timer: Initialize evtstrm after finalizing cpucaps Mark Rutland
2023-10-05  9:49 ` [PATCH v2 02/38] arm64/arm: xen: enlighten: Fix KPTI checks Mark Rutland
2023-10-05  9:49 ` [PATCH v2 03/38] arm64: Factor out cpucap definitions Mark Rutland
2023-10-05 12:29   ` Mark Rutland
2023-10-05  9:49 ` [PATCH v2 04/38] arm64: Add cpucap_is_possible() Mark Rutland
2023-10-05  9:49 ` [PATCH v2 05/38] arm64: Add cpus_have_final_boot_cap() Mark Rutland
2023-10-05  9:49 ` [PATCH v2 06/38] arm64: Rework setup_cpu_features() Mark Rutland
2023-10-05  9:49 ` [PATCH v2 07/38] arm64: Fixup user features at boot time Mark Rutland
2023-10-05  9:49 ` [PATCH v2 08/38] arm64: Split kpti_install_ng_mappings() Mark Rutland
2023-10-05  9:49 ` [PATCH v2 09/38] arm64: kvm: Use cpus_have_final_cap() explicitly Mark Rutland
2023-10-05  9:49 ` [PATCH v2 10/38] arm64: Explicitly save/restore CPACR when probing SVE and SME Mark Rutland
2023-10-05  9:49 ` [PATCH v2 11/38] arm64: use build-time assertions for cpucap ordering Mark Rutland
2023-10-05  9:49 ` Mark Rutland [this message]
2023-10-05  9:49 ` [PATCH v2 12/38] arm64: Rename SVE/SME cpu_enable functions Mark Rutland
2023-10-05  9:50 ` [PATCH v2 13/38] arm64: Use a positive cpucap for FP/SIMD Mark Rutland
2023-10-05  9:50 ` [PATCH v2 14/38] arm64: Avoid cpus_have_const_cap() for ARM64_HAS_{ADDRESS,GENERIC}_AUTH Mark Rutland
2023-10-05  9:50 ` [PATCH v2 15/38] arm64: Avoid cpus_have_const_cap() for ARM64_HAS_ARMv8_4_TTL Mark Rutland
2023-10-05  9:50 ` [PATCH v2 16/38] arm64: Avoid cpus_have_const_cap() for ARM64_HAS_BTI Mark Rutland
2023-10-05  9:50 ` [PATCH v2 17/38] arm64: Avoid cpus_have_const_cap() for ARM64_HAS_CACHE_DIC Mark Rutland
2023-10-05  9:50 ` [PATCH v2 18/38] arm64: Avoid cpus_have_const_cap() for ARM64_HAS_CNP Mark Rutland
2023-10-05  9:50 ` [PATCH v2 19/38] arm64: Avoid cpus_have_const_cap() for ARM64_HAS_DIT Mark Rutland
2023-10-05  9:50 ` [PATCH v2 20/38] arm64: Avoid cpus_have_const_cap() for ARM64_HAS_GIC_PRIO_MASKING Mark Rutland
2023-10-05  9:50 ` [PATCH v2 21/38] arm64: Avoid cpus_have_const_cap() for ARM64_HAS_PAN Mark Rutland
2023-10-05  9:50 ` [PATCH v2 22/38] arm64: Avoid cpus_have_const_cap() for ARM64_HAS_EPAN Mark Rutland
2023-10-05  9:50 ` [PATCH v2 23/38] arm64: Avoid cpus_have_const_cap() for ARM64_HAS_RNG Mark Rutland
2023-10-05  9:50 ` [PATCH v2 24/38] arm64: Avoid cpus_have_const_cap() for ARM64_HAS_WFXT Mark Rutland
2023-10-05  9:50 ` [PATCH v2 25/38] arm64: Avoid cpus_have_const_cap() for ARM64_HAS_TLB_RANGE Mark Rutland
2023-10-05  9:50 ` [PATCH v2 26/38] arm64: Avoid cpus_have_const_cap() for ARM64_MTE Mark Rutland
2023-10-05  9:50 ` [PATCH v2 27/38] arm64: Avoid cpus_have_const_cap() for ARM64_SSBS Mark Rutland
2023-10-05  9:50 ` [PATCH v2 28/38] arm64: Avoid cpus_have_const_cap() for ARM64_SPECTRE_V2 Mark Rutland
2023-10-05  9:50 ` [PATCH v2 29/38] arm64: Avoid cpus_have_const_cap() for ARM64_{SVE,SME,SME2,FA64} Mark Rutland
2023-10-05  9:50 ` [PATCH v2 30/38] arm64: Avoid cpus_have_const_cap() for ARM64_UNMAP_KERNEL_AT_EL0 Mark Rutland
2023-10-05  9:50 ` [PATCH v2 31/38] arm64: Avoid cpus_have_const_cap() for ARM64_WORKAROUND_843419 Mark Rutland
2023-10-05  9:50 ` [PATCH v2 32/38] arm64: Avoid cpus_have_const_cap() for ARM64_WORKAROUND_1542419 Mark Rutland
2023-10-05  9:50 ` [PATCH v2 33/38] arm64: Avoid cpus_have_const_cap() for ARM64_WORKAROUND_1742098 Mark Rutland
2023-10-05  9:50 ` [PATCH v2 34/38] arm64: Avoid cpus_have_const_cap() for ARM64_WORKAROUND_2645198 Mark Rutland
2023-10-05  9:50 ` [PATCH v2 35/38] arm64: Avoid cpus_have_const_cap() for ARM64_WORKAROUND_CAVIUM_23154 Mark Rutland
2023-10-05  9:50 ` [PATCH v2 36/38] arm64: Avoid cpus_have_const_cap() for ARM64_WORKAROUND_NVIDIA_CARMEL_CNP Mark Rutland
2023-10-05  9:50 ` [PATCH v2 37/38] arm64: Avoid cpus_have_const_cap() for ARM64_WORKAROUND_REPEAT_TLBI Mark Rutland
2023-10-05  9:50 ` [PATCH v2 38/38] arm64: Remove cpus_have_const_cap() Mark Rutland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231005095025.1872048-13-mark.rutland@arm.com \
    --to=mark.rutland@arm.com \
    --cc=ardb@kernel.org \
    --cc=bertrand.marquis@arm.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=james.morse@arm.com \
    --cc=jgross@suse.com \
    --cc=kristina.martsenko@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=pcc@google.com \
    --cc=sstabellini@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=tglx@linutronix.de \
    --cc=vladimir.murzin@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.