]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
kselftest/arm64: Verify the GCS hwcap
authorMark Brown <broonie@kernel.org>
Tue, 1 Oct 2024 22:59:08 +0000 (23:59 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 4 Oct 2024 11:04:42 +0000 (12:04 +0100)
Add coverage of the GCS hwcap to the hwcap selftest, using a read of
GCSPR_EL0 to generate SIGILL without having to worry about enabling GCS.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Tested-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20241001-arm64-gcs-v13-29-222b78d87eee@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
tools/testing/selftests/arm64/abi/hwcap.c

index f2d6007a2b983eba77a880ec7e614396a6cb1377..1f07772ae5781c8bb8229001fc220a44c4c3bae5 100644 (file)
@@ -98,6 +98,17 @@ static void fpmr_sigill(void)
        asm volatile("mrs x0, S3_3_C4_C4_2" : : : "x0");
 }
 
+static void gcs_sigill(void)
+{
+       unsigned long *gcspr;
+
+       asm volatile(
+               "mrs    %0, S3_3_C2_C5_1"
+       : "=r" (gcspr)
+       :
+       : "cc");
+}
+
 static void ilrcpc_sigill(void)
 {
        /* LDAPUR W0, [SP, #8] */
@@ -534,6 +545,14 @@ static const struct hwcap_data {
                .sigill_fn = fpmr_sigill,
                .sigill_reliable = true,
        },
+       {
+               .name = "GCS",
+               .at_hwcap = AT_HWCAP,
+               .hwcap_bit = HWCAP_GCS,
+               .cpuinfo = "gcs",
+               .sigill_fn = gcs_sigill,
+               .sigill_reliable = true,
+       },
        {
                .name = "JSCVT",
                .at_hwcap = AT_HWCAP,