@@ -3,7 +3,13 @@
# A proper top_srcdir is needed by KSFT(lib.mk)
top_srcdir = $(realpath ../../../../../)
-CFLAGS += $(KHDR_INCLUDES)
+ARCH_TOOLS_INCLUDES=\
+ -I${top_srcdir}/tools/include \
+ -I${top_srcdir}/tools/arch/arm64/include \
+ -I${top_srcdir}/tools/arch/arm64/include/generated
+
+CFLAGS += $(KHDR_INCLUDES) $(ARCH_TOOLS_INCLUDES)
+ASFLAGS += -D__ASSEMBLY__ $(ARCH_TOOLS_INCLUDES)
TEST_GEN_PROGS := \
fp-ptrace \
@@ -26,18 +32,18 @@ EXTRA_CLEAN += $(OUTPUT)/asm-utils.o $(OUTPUT)/rdvl.o $(OUTPUT)/za-fork-asm.o
# Build with nolibc to avoid effects due to libc's clone() support
$(OUTPUT)/fp-pidbench: fp-pidbench.S $(OUTPUT)/asm-utils.o
- $(CC) -nostdlib $^ -o $@
+ $(CC) $(ASFLAGS) -nostdlib $^ -o $@
$(OUTPUT)/fp-ptrace: fp-ptrace.c fp-ptrace-asm.S
$(OUTPUT)/fpsimd-test: fpsimd-test.S $(OUTPUT)/asm-utils.o
- $(CC) -nostdlib $^ -o $@
+ $(CC) $(ASFLAGS) -nostdlib $^ -o $@
$(OUTPUT)/rdvl-sve: rdvl-sve.c $(OUTPUT)/rdvl.o
$(OUTPUT)/rdvl-sme: rdvl-sme.c $(OUTPUT)/rdvl.o
$(OUTPUT)/sve-ptrace: sve-ptrace.c
$(OUTPUT)/sve-probe-vls: sve-probe-vls.c $(OUTPUT)/rdvl.o
$(OUTPUT)/sve-test: sve-test.S $(OUTPUT)/asm-utils.o
- $(CC) -nostdlib $^ -o $@
+ $(CC) $(ASFLAGS) -nostdlib $^ -o $@
$(OUTPUT)/ssve-test: sve-test.S $(OUTPUT)/asm-utils.o
- $(CC) -DSSVE -nostdlib $^ -o $@
+ $(CC) -DSSVE $(ASFLAGS) -nostdlib $^ -o $@
$(OUTPUT)/vec-syscfg: vec-syscfg.c $(OUTPUT)/rdvl.o
$(OUTPUT)/vlset: vlset.c
$(OUTPUT)/za-fork: za-fork.c $(OUTPUT)/za-fork-asm.o
@@ -46,9 +52,9 @@ $(OUTPUT)/za-fork: za-fork.c $(OUTPUT)/za-fork-asm.o
-static -ffreestanding -Wall $^ -o $@
$(OUTPUT)/za-ptrace: za-ptrace.c
$(OUTPUT)/za-test: za-test.S $(OUTPUT)/asm-utils.o
- $(CC) -nostdlib $^ -o $@
+ $(CC) $(ASFLAGS) -nostdlib $^ -o $@
$(OUTPUT)/zt-ptrace: zt-ptrace.c
$(OUTPUT)/zt-test: zt-test.S $(OUTPUT)/asm-utils.o
- $(CC) -nostdlib $^ -o $@
+ $(CC) $(ASFLAGS) -nostdlib $^ -o $@
include ../../lib.mk
@@ -8,6 +8,11 @@
// break on a further breakpoint
//
+/* The build system is dumb and doesn't do this for us */
+#define __ASSEMBLY__
+
+#include <asm/sysreg.h>
+
#include "fp-ptrace.h"
#include "sme-inst.h"
@@ -47,7 +52,7 @@ load_and_save:
ldr x7, [x7, :lo12:svcr_in]
// SVCR is 0 by default, avoid triggering SME if not in use
cbz x7, check_sve_in
- msr S3_3_C4_C2_2, x7
+ msr REG_SVCR, x7
// ZA?
tbz x7, #SVCR_ZA_SHIFT, check_sm_in
@@ -172,7 +177,7 @@ wait_for_writes:
adrp x6, sme_vl_out
str x11, [x6, :lo12:sme_vl_out]
- mrs x7, S3_3_C4_C2_2
+ mrs x7, REG_SVCR
adrp x6, svcr_out
str x7, [x6, :lo12:svcr_out]
@@ -276,7 +281,7 @@ wait_for_reads:
// Ensure we don't leave ourselves in streaming mode
tbz x0, #HAVE_SME_SHIFT, out
- msr S3_3_C4_C2_2, xzr
+ msr REG_SVCR, xzr
out:
ldp x11, x12, [sp, #-0x10]
@@ -27,6 +27,8 @@
#include <asm/sve_context.h>
#include <asm/ptrace.h>
+#include <asm/sysreg.h>
+
#include "../../kselftest.h"
#include "fp-ptrace.h"
@@ -4,11 +4,7 @@
#ifndef FP_PTRACE_H
#define FP_PTRACE_H
-#define SVCR_SM_SHIFT 0
-#define SVCR_ZA_SHIFT 1
-
-#define SVCR_SM (1 << SVCR_SM_SHIFT)
-#define SVCR_ZA (1 << SVCR_ZA_SHIFT)
+#include <asm/sysreg.h>
#define HAVE_SVE_SHIFT 0
#define HAVE_SME_SHIFT 1
@@ -10,6 +10,7 @@
// (leave it running for as long as you want...)
// kill $pids
+#include <asm/sysreg.h>
#include <asm/unistd.h>
#include "assembler.h"
#include "asm-offsets.h"
@@ -474,7 +475,7 @@ function _start
// svc #0
#ifdef SSVE
- mrs x0, S3_3_C4_C2_2 // SVCR should have ZA=0,SM=1
+ mrs x0, REG_SVCR // SVCR should have ZA=0,SM=1
and x1, x0, #3
cmp x1, #1
b.ne svcr_barf
@@ -516,7 +517,7 @@ function barf
mov x12, x2 // data size
#ifdef SSVE
- mrs x13, S3_3_C4_C2_2
+ mrs x13, REG_SVCR
#endif
puts "Mismatch: PID="
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
// Copyright (C) 2021 ARM Limited.
+#include <asm/sysreg.h>
#include "sme-inst.h"
.arch_extension sve
@@ -35,7 +36,7 @@ fork_test:
.globl verify_fork
verify_fork:
// SVCR should have ZA=1, SM=0
- mrs x0, S3_3_C4_C2_2
+ mrs x0, REG_SVCR
and x1, x0, #3
cmp x1, #2
beq 1f
@@ -10,6 +10,8 @@
// (leave it running for as long as you want...)
// kill $pids
+
+#include <asm/sysreg.h>
#include <asm/unistd.h>
#include "assembler.h"
#include "asm-offsets.h"
@@ -305,7 +307,7 @@ function _start
1:
svc #0
- mrs x0, S3_3_C4_C2_2 // SVCR should have ZA=1,SM=0
+ mrs x0, REG_SVCR // SVCR should have ZA=1,SM=0
and x1, x0, #3
cmp x1, #2
b.ne svcr_barf
@@ -334,7 +336,7 @@ function barf
// svc #0
// end hack
- mrs x13, S3_3_C4_C2_2
+ mrs x13, REG_SVCR
smstop
mov x10, x0 // expected data
@@ -6,6 +6,7 @@
// Repeatedly writes unique test patterns into ZT0
// and reads them back to verify integrity.
+#include <asm/sysreg.h>
#include <asm/unistd.h>
#include "assembler.h"
#include "asm-offsets.h"
@@ -244,7 +245,7 @@ function _start
mov x8, #__NR_sched_yield // Encourage preemption
svc #0
- mrs x0, S3_3_C4_C2_2 // SVCR should have ZA=1,SM=0
+ mrs x0, REG_SVCR // SVCR should have ZA=1,SM=0
and x1, x0, #3
cmp x1, #2
b.ne svcr_barf
@@ -268,7 +269,7 @@ function barf
// svc #0
// end hack
- mrs x13, S3_3_C4_C2_2
+ mrs x13, REG_SVCR
smstop
mov x10, x0 // expected data
mov x11, x1 // actual data
For some reason when we're accessing SVCR in the FP tests we use the raw numerical version of the register name rather than hiding that behind a preprocessor macro for readability. Since we already use the generated defines for sysreg bitfields in other the KVM selftests let's do the same thing here, also replacing the defines for the SVCR bitfields which we have. The build setup for fp-ptrace is a little fun so we have to manually define __ASSEMBLY__ in the source code for that. Signed-off-by: Mark Brown <broonie@kernel.org> --- tools/testing/selftests/arm64/fp/Makefile | 20 +++++++++++++------- tools/testing/selftests/arm64/fp/fp-ptrace-asm.S | 11 ++++++++--- tools/testing/selftests/arm64/fp/fp-ptrace.c | 2 ++ tools/testing/selftests/arm64/fp/fp-ptrace.h | 6 +----- tools/testing/selftests/arm64/fp/sve-test.S | 5 +++-- tools/testing/selftests/arm64/fp/za-fork-asm.S | 3 ++- tools/testing/selftests/arm64/fp/za-test.S | 6 ++++-- tools/testing/selftests/arm64/fp/zt-test.S | 5 +++-- 8 files changed, 36 insertions(+), 22 deletions(-)