selftests/powerpc: Add uaccess flush test
PATCH 1/1 selftests/powerpc: Add uaccess flush test
From: Thadeu Lima de Souza Cascardo <[email protected]>
Also based on the RFI and entry flush tests, it counts the L1D misses by doing a syscall that does user access: uname, in this case.
Signed-off-by Thadeu Lima de Souza Cascardo <[email protected]>
[dja: forward port, rename function]
Signed-off-by Daniel Axtens <[email protected]>
---
This applies on top of Russell's change to use better constants:
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/
It's possible that we could share some more code between the tests, but it hardly seems worth it.
--- .../selftests/powerpc/security/Makefile | 3 +- .../selftests/powerpc/security/flush_utils.c | 13 ++ .../selftests/powerpc/security/flush_utils.h | 3 + .../powerpc/security/uaccess_flush.c | 158 ++++++++++++++++++ 4 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/security/uaccess_flush.c
tools/testing/selftests/powerpc/security/Makefile +2 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0+ -TEST_GEN_PROGS := rfi_flush entry_flush spectre_v2 +TEST_GEN_PROGS := rfi_flush entry_flush uaccess_flush spectre_v2 top_srcdir = ../../../../.. CFLAGS += -I../../../../../usr/include
@@ -13,3 +13,4 @@ $(OUTPUT)/spectre_v2: CFLAGS += -m64 $(OUTPUT)/spectre_v2: ../pmu/event.c branch_loops.S $(OUTPUT)/rfi_flush: flush_utils.c $(OUTPUT)/entry_flush: flush_utils.c +$(OUTPUT)/uaccess_flush: flush_utils.c
tools/testing/selftests/powerpc/security/flush_utils.c +13 -0
@@ -13,6 +13,7 @@#include <stdlib.h> #include <string.h> #include <stdio.h> +#include <sys/utsname.h> #include "utils.h" #include "flush_utils.h"
@@ -35,6 +36,18 @@ void syscall_loop(char *p, unsigned long iterations, } } +void syscall_loop_uaccess (char *p,unsigned long iterations, +unsigned long zero_size) +{ +struct utsname utsname; + +for (unsigned long i =0 ; i < iterations; i++) { +for (unsigned long j =0 ; j < zero_size; j +=CACHELINE_SIZE ) +load (p + j); +uname (&utsname); + } +} +static void sigill_handler (int signr,siginfo_t *info,void *unused) {static int warned;
tools/testing/selftests/powerpc/security/flush_utils.h +3 -0
@@ -16,6 +16,9 @@void syscall_loop (char *p,unsigned long iterations,unsigned long zero_size); +void syscall_loop_uaccess (char *p,unsigned long iterations, +unsigned long zero_size); +void set_dscr (unsigned long val);#endif /* _SELFTESTS_POWERPC_SECURITY_FLUSH_UTILS_H */
tools/testing/selftests/powerpc/security/uaccess_flush.c new file +158 -0
158 lines not on this page · raw message
Signature · 1 line
2.27.0
Michael Ellerman
AppliedQuoted 2 lines · Daniel Axtens
Also based on the RFI and entry flush tests, it counts the L1D misses by doing a syscall that does user access: uname, in this case.
Applied to powerpc/next.
[1/1] selftests/powerpc: Add uaccess flush test
https://git.kernel.org/powerpc/c/da650ada100956b0f00aa4fe9ce33103378ce9ca
cheers