1
0
Fork 0
alistair23-linux/tools/testing/selftests/arm64/fp
Andre Przywara 7011d72588 kselftest/arm64: sve: Do not use non-canonical FFR register value
The "First Fault Register" (FFR) is an SVE register that mimics a
predicate register, but clears bits when a load or store fails to handle
an element of a vector. The supposed usage scenario is to initialise
this register (using SETFFR), then *read* it later on to learn about
elements that failed to load or store. Explicit writes to this register
using the WRFFR instruction are only supposed to *restore* values
previously read from the register (for context-switching only).
As the manual describes, this register holds only certain values, it:
"... contains a monotonic predicate value, in which starting from bit 0
there are zero or more 1 bits, followed only by 0 bits in any remaining
bit positions."
Any other value is UNPREDICTABLE and is not supposed to be "restored"
into the register.

The SVE test currently tries to write a signature pattern into the
register, which is *not* a canonical FFR value. Apparently the existing
setups treat UNPREDICTABLE as "read-as-written", but a new
implementation actually only stores canonical values. As a consequence,
the sve-test fails immediately when comparing the FFR value:
-----------
 # ./sve-test
Vector length:  128 bits
PID:    207
Mismatch: PID=207, iteration=0, reg=48
        Expected [cf00]
        Got      [0f00]
Aborted
-----------

Fix this by only populating the FFR with proper canonical values.
Effectively the requirement described above limits us to 17 unique
values over 16 bits worth of FFR, so we condense our signature down to 4
bits (2 bits from the PID, 2 bits from the generation) and generate the
canonical pattern from it. Any bits describing elements above the
minimum 128 bit are set to 0.

This aligns the FFR usage to the architecture and fixes the test on
microarchitectures implementing FFR in a more restricted way.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviwed-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210319120128.29452-1-andre.przywara@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
2021-03-22 12:49:57 +00:00
..
.gitignore selftests: arm64: Add build and documentation for FP tests 2020-09-18 14:19:20 +01:00
Makefile selftests: arm64: Add build and documentation for FP tests 2020-09-18 14:19:20 +01:00
README selftests: arm64: Add build and documentation for FP tests 2020-09-18 14:19:20 +01:00
asm-offsets.h selftests: arm64: Add stress tests for FPSMID and SVE context switching 2020-09-18 14:17:58 +01:00
assembler.h selftests: arm64: Add stress tests for FPSMID and SVE context switching 2020-09-18 14:17:58 +01:00
fpsimd-stress selftests: arm64: Add wrapper scripts for stress tests 2020-09-18 14:17:58 +01:00
fpsimd-test.S arm64: selftests: Fix spelling of 'Mismatch' 2021-01-15 10:05:27 +00:00
sve-probe-vls.c
sve-ptrace-asm.S selftests: arm64: Add test for the SVE ptrace interface 2020-09-18 14:17:58 +01:00
sve-ptrace.c kselftest: arm64: Fix exit code of sve-ptrace 2021-03-10 10:58:11 +00:00
sve-stress selftests: arm64: Add wrapper scripts for stress tests 2020-09-18 14:17:58 +01:00
sve-test.S kselftest/arm64: sve: Do not use non-canonical FFR register value 2021-03-22 12:49:57 +00:00
vlset.c selftests: arm64: Add utility to set SVE vector lengths 2020-09-18 14:17:58 +01:00

README

This directory contains a mix of tests integrated with kselftest and
standalone stress tests.

kselftest tests
===============

sve-probe-vls - Checks the SVE vector length enumeration interface
sve-ptrace - Checks the SVE ptrace interface

Running the non-kselftest tests
===============================

sve-stress performs an SVE context switch stress test, as described
below.

(The fpsimd-stress test works the same way; just substitute "fpsimd" for
"sve" in the following commands.)


The test runs until killed by the user.

If no context switch error was detected, you will see output such as
the following:

$ ./sve-stress
(wait for some time)
^C
Vector length:        512 bits
PID:    1573
Terminated by signal 15, no error, iterations=9467, signals=1014
Vector length:  512 bits
PID:    1575
Terminated by signal 15, no error, iterations=9448, signals=1028
Vector length:  512 bits
PID:    1577
Terminated by signal 15, no error, iterations=9436, signals=1039
Vector length:  512 bits
PID:    1579
Terminated by signal 15, no error, iterations=9421, signals=1039
Vector length:  512 bits
PID:    1581
Terminated by signal 15, no error, iterations=9403, signals=1039
Vector length:  512 bits
PID:    1583
Terminated by signal 15, no error, iterations=9385, signals=1036
Vector length:  512 bits
PID:    1585
Terminated by signal 15, no error, iterations=9376, signals=1039
Vector length:  512 bits
PID:    1587
Terminated by signal 15, no error, iterations=9361, signals=1039
Vector length:  512 bits
PID:    1589
Terminated by signal 15, no error, iterations=9350, signals=1039


If an error was detected, details of the mismatch will be printed
instead of "no error".

Ideally, the test should be allowed to run for many minutes or hours
to maximise test coverage.


KVM stress testing
==================

To try to reproduce the bugs that we have been observing, sve-stress
should be run in parallel in two KVM guests, while simultaneously
running on the host.

1) Start 2 guests, using the following command for each:

$ lkvm run --console=virtio -pconsole=hvc0 --sve Image

(Depending on the hardware GIC implementation, you may also need
--irqchip=gicv3.  New kvmtool defaults to that if appropriate, but I
can't remember whether my branch is new enough for that.  Try without
the option first.)

Kvmtool occupies the terminal until you kill it (Ctrl+A x),
or until the guest terminates.  It is therefore recommended to run
each instance in separate terminal (use screen or ssh etc.)  This
allows multiple guests to be run in parallel while running other
commands on the host.

Within the guest, the host filesystem is accessible, mounted on /host.

2) Run the sve-stress on *each* guest with the Vector-Length set to 32:
guest$ ./vlset --inherit 32 ./sve-stress

3) Run the sve-stress on the host with the maximum Vector-Length:
host$ ./vlset --inherit --max ./sve-stress


Again, the test should be allowed to run for many minutes or hours to
maximise test coverage.

If no error is detected, you will see output from each sve-stress
instance similar to that illustrated above; otherwise details of the
observed mismatches will be printed.