selftests/powerpc: Skip security tests on older CPUs
authorMichael Ellerman <mpe@ellerman.id.au>
Wed, 19 Aug 2020 01:57:24 +0000 (11:57 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 8 Sep 2020 12:24:05 +0000 (22:24 +1000)
Both these tests use PMU events that only work on newer CPUs, so skip
them on older CPUs.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200819015727.1977134-6-mpe@ellerman.id.au
tools/testing/selftests/powerpc/security/rfi_flush.c
tools/testing/selftests/powerpc/security/spectre_v2.c

index fd37ff9b1c458a488d6d975e272280edc777623b..93a65bd1f231b9b13d07d5ea086ebbe43f93f405 100644 (file)
@@ -89,6 +89,9 @@ int rfi_flush_test(void)
 
        SKIP_IF(geteuid() != 0);
 
+       // The PMU event we use only works on Power7 or later
+       SKIP_IF(!have_hwcap(PPC_FEATURE_ARCH_2_06));
+
        if (read_debugfs_file("powerpc/rfi_flush", &rfi_flush_org)) {
                perror("Unable to read powerpc/rfi_flush debugfs file");
                SKIP_IF(1);
index c8d82b78410239e2a011660c6c8a6d600d292c5e..adc2b7294e5fddb54150bd797b04efc5825b3c3d 100644 (file)
@@ -134,6 +134,9 @@ int spectre_v2_test(void)
        s64 miss_percent;
        bool is_p9;
 
+       // The PMU events we use only work on Power8 or later
+       SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
+
        state = get_sysfs_state();
        if (state == UNKNOWN) {
                printf("Error: couldn't determine spectre_v2 mitigation state?\n");