Extend and apply the errata framework
Subsystems (3)
cover Extend and apply the errata framework
We've had an errata framework merged in for a while, but it hasn't been getting used (at least not upstream). This series extends it to allow run script environment provided and host kernel version based generated errata variables to be automatically provided to unit tests. It then changes a couple arm unit tests to use the errata framework, now that it's more useful.
The benefit of this over always using the 'nodefault' group is that once a host has been patched the unit test will automatically start running as a regression test - no need to manually run it, meaning no concern that it will likely never actually be run...
Andrew Jones (8):
arch-run: introduce initrd_create
arch-run: provide errata from run env
x86/run: source config.mak
arch-run: generate errata when no environ is provided
errata: add ERRATA_FORCE
README: add section on guarding unsafe tests
AArch32: apply errata framework to unsafe pmccntr64 test arm/arm64: apply errata framework to unsafe cpu-on test
README.md | 34 ++++++++++++++++++++++ arm/pmu.c | 26 +++++++++++------ arm/psci.c | 7 ++++- arm/run | 5 ++-- arm/unittests.cfg | 2 +- configure | 11 ++++++++ errata.txt | 7 +++++ lib/errata.h | 21 ++++++++++++-- powerpc/run | 5 ++-- run_tests.sh | 2 ++ scripts/arch-run.bash | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++ x86/run | 14 +++++++-- 12 files changed, 193 insertions(+), 19 deletions(-) create mode 100644 errata.txt
Signature · 1 line
2.9.4
PATCH 1/8 arch-run: introduce initrd_create
Encapsulate the preparation of the optional initrd command line option.
--- arm/run | 5 +++-- powerpc/run | 5 +++-- scripts/arch-run.bash | 5 +++++ x86/run | 5 +++-- 4 files changed, 14 insertions(+), 6 deletions(-)
arm/run +3 -2
@@ -71,10 +71,11 @@ if $qemu $M -device '?' 2>&1 | grep pci-testdev > /dev/null; then pci_testdev="-device pci-testdev" fi +initrd_create + M+=",accel=$ACCEL" command="$qemu -nodefaults $M -cpu $processor $chr_testdev $pci_testdev" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -display none -serial stdio -kernel" +command+=" -display none -serial stdio $INITRD -kernel" command="$(timeout_cmd) $command" echo $command "$@"
powerpc/run +3 -2
@@ -35,11 +35,12 @@ if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then exit 2 fi +initrd_create + M='-machine pseries' M+=",accel=$ACCEL" command="$qemu -nodefaults $M -bios $FIRMWARE" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -display none -serial stdio -kernel" +command+=" -display none -serial stdio $INITRD -kernel" command="$(migration_cmd) $(timeout_cmd) $command" echo $command "$@"
scripts/arch-run.bash +5 -0
@@ -155,3 +155,8 @@ search_qemu_binary () command -v $qemu export PATH=$save_path } + +initrd_create () +{ + [ -f "$ENV" ] && export INITRD="-initrd $ENV" +}
x86/run +3 -2
@@ -26,9 +26,10 @@ else pc_testdev="-device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out" fi +initrd_create + command="${qemu} -nodefaults -enable-kvm $pc_testdev -vnc none -serial stdio $pci_testdev $hyperv_testdev" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -kernel" +command+=" $INITRD -kernel" command="$(timeout_cmd) $command" echo ${command} "$@"
Signature · 1 line
2.9.4
Re: [PATCH kvm-unit-tests 1/8] arch-run: introduce initrd_create
Quoted 53 lines · Andrew Jones
Encapsulate the preparation of the optional initrd command line option.
Signed-off-by Andrew Jones <[email protected]>--- arm/run | 5 +++-- powerpc/run | 5 +++-- scripts/arch-run.bash | 5 +++++ x86/run | 5 +++-- 4 files changed, 14 insertions(+), 6 deletions(-)arm/run +3
-2@@ -71,10 +71,11 @@ if $qemu $M -device '?' 2>&1 | grep pci-testdev > /dev/null; then pci_testdev="-device pci-testdev" fi +initrd_create + M+=",accel=$ACCEL" command="$qemu -nodefaults $M -cpu $processor $chr_testdev $pci_testdev" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -display none -serial stdio -kernel" +command+=" -display none -serial stdio $INITRD -kernel" command="$(timeout_cmd) $command" echo $command "$@"powerpc/run +3
-2@@ -35,11 +35,12 @@ if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then exit 2 fi +initrd_create + M='-machine pseries' M+=",accel=$ACCEL" command="$qemu -nodefaults $M -bios $FIRMWARE" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -display none -serial stdio -kernel" +command+=" -display none -serial stdio $INITRD -kernel" command="$(migration_cmd) $(timeout_cmd) $command" echo $command "$@"scripts/arch-run.bash +0
-0
scripts/arch-run.bash search_qemu_binary () · line 161
Quoted 7 lines
scripts/arch-run.bash +4
-0@@ -155,3 +155,8 @@ search_qemu_binary () command -v $qemu export PATH=$save_path } + +initrd_create () +{ + [ -f "$ENV" ] && export INITRD="-initrd $ENV"
Why do you need the export?
Thanks,
Laurent
Re: [PATCH kvm-unit-tests 1/8] arch-run: introduce initrd_create
Quoted 49 lines · Laurent Vivier
Quoted 48 lines · Andrew Jones
Encapsulate the preparation of the optional initrd command line option.
Signed-off-by Andrew Jones <[email protected]>--- arm/run | 5 +++-- powerpc/run | 5 +++-- scripts/arch-run.bash | 5 +++++ x86/run | 5 +++-- 4 files changed, 14 insertions(+), 6 deletions(-)arm/run +3
-2@@ -71,10 +71,11 @@ if $qemu $M -device '?' 2>&1 | grep pci-testdev > /dev/null; then pci_testdev="-device pci-testdev" fi +initrd_create + M+=",accel=$ACCEL" command="$qemu -nodefaults $M -cpu $processor $chr_testdev $pci_testdev" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -display none -serial stdio -kernel" +command+=" -display none -serial stdio $INITRD -kernel" command="$(timeout_cmd) $command" echo $command "$@"powerpc/run +3
-2@@ -35,11 +35,12 @@ if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then exit 2 fi +initrd_create + M='-machine pseries' M+=",accel=$ACCEL" command="$qemu -nodefaults $M -bios $FIRMWARE" -[ -f "$ENV" ] && command+=" -initrd $ENV" -command+=" -display none -serial stdio -kernel" +command+=" -display none -serial stdio $INITRD -kernel" command="$(migration_cmd) $(timeout_cmd) $command" echo $command "$@"
Quoted 14 lines
scripts/arch-run.bash search_qemu_binary () · line 161
Quoted 12 lines
scripts/arch-run.bash +4
-0@@ -155,3 +155,8 @@ search_qemu_binary () command -v $qemu export PATH=$save_path } + +initrd_create () +{ + [ -f "$ENV" ] && export INITRD="-initrd $ENV"Why do you need the export?
I guess it's not necessary.
Thanks,
drew
Quoted 3 lines
Thanks,
Laurent
PATCH 2/8 arch-run: provide errata from run env
In reply to Andrew JonesAllow the run script environment to provide ERRATA_* variables to the unit tests. These variables will augment/override variables in any provided unit test environ (the file specified with $ENV) or trigger the creation of a temporary environ file, which contains them.
Now something like
ERRATA_abcd01234567=y ./run_tests.sh
may be run in order to inform all unit tests that they may execute all subtests guarded by ERRATA_abcd01234567.
--- scripts/arch-run.bash | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
scripts/arch-run.bash +28 -0
@@ -158,5 +158,33 @@ search_qemu_binary () initrd_create () { + env_add_errata [ -f "$ENV" ] && export INITRD="-initrd $ENV" } + +env_add_errata () +{ + local line errata + + if [ -f "$ENV" ] && grep -q '^ERRATA_' <(env); then + for line in $(grep '^ERRATA_' "$ENV"); do + errata=$(echo "$line" | cut -d= -f1) + grep -q $errata <(env) && continue + eval export "$line" + done + fi + + if grep -q '^ERRATA_' <(env); then + export ENV_OLD="$ENV" + export ENV=$(mktemp) + trap_exit_push 'rm -f $ENV; [ "$ENV_OLD" ] && export ENV="$ENV_OLD" || unset ENV; unset ENV_OLD' + [ -f "$ENV_OLD" ] && grep -v '^ERRATA_' "$ENV_OLD" > $ENV + grep '^ERRATA_' <(env) >> $ENV + fi +} + +trap_exit_push () +{ + local old_exit=$(trap -p EXIT | sed "s/^[^']*'//;s/'[^']*$//") + trap -- "$1; $old_exit" EXIT +}
Signature · 1 line
2.9.4
Re: [PATCH kvm-unit-tests 2/8] arch-run: provide errata from run env
Quoted 31 lines · Andrew Jones
Allow the run script environment to provide ERRATA_* variables to the unit tests. These variables will augment/override variables in any provided unit test environ (the file specified with $ENV) or trigger the creation of a temporary environ file, which contains them.
Now something like
ERRATA_abcd01234567=y ./run_tests.sh
may be run in order to inform all unit tests that they may execute all subtests guarded by
ERRATA_abcd01234567.Signed-off-by Andrew Jones <[email protected]>--- scripts/arch-run.bash | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)scripts/arch-run.bash +3
-0@@ -158,5 +158,33 @@ search_qemu_binary () initrd_create () { + env_add_errata [ -f "$ENV" ] && export INITRD="-initrd $ENV" } + +env_add_errata ()
scripts/arch-run.bash search_qemu_binary () · line 175
Quoted 10 lines
scripts/arch-run.bash +10
-0+{ + local line errata + + if [ -f "$ENV" ] && grep -q '^ERRATA_' <(env); then + for line in $(grep '^ERRATA_' "$ENV"); do + errata=$(echo "$line" | cut -d= -f1) + grep -q $errata <(env) && continue + eval export "$line" + done + fi
If you want fun, you can get this with:
[ -f "$ENV" ] && for errata in \
$(grep -vF "$(tr ' ' '\n' <<<${!ERRATA_@})" "$ENV"); do
eval export $errata
done
Laurent
PATCH 3/8 x86/run: source config.mak
In reply to Andrew Jonesx86/run will need to start looking at config vars with the next patch.
--- x86/run | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
x86/run +8 -1
@@ -1,6 +1,13 @@ #!/usr/bin/env bash -[ -z "$STANDALONE" ] && source scripts/arch-run.bash +if [ -z "$STANDALONE" ]; then + if [ ! -f config.mak ]; then + echo "run ./configure && make first. See ./configure -h" + exit 2 + fi + source config.mak + source scripts/arch-run.bash +fi qemu=$(search_qemu_binary)
Signature · 1 line
2.9.4
PATCH 4/8 arch-run: generate errata when no environ is provided
In reply to Andrew JonesProvide a table mapping errata to minimum kernel versions and a function that will use the host's kernel version to determine the values for each errata variable. These errata variables, with values based on the host kernel, are now provided to all unit tests by default, if no environ is provided. Errata variables passed from the run script environment still take precedence.
--- configure | 11 +++++++++++ errata.txt | 5 +++++ scripts/arch-run.bash | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 errata.txt
configure +11 -0
@@ -14,6 +14,7 @@ host=$arch cross_prefix= endian="" pretty_print_stacks=yes +environ_default=yes u32_long= usage() {
@@ -31,6 +32,9 @@ usage() { --endian=ENDIAN endianness to compile for (little or big, ppc64 only) --[enable|disable]-pretty-print-stacks enable or disable pretty stack printing (enabled by default) + --[enable|disable]-default-environ + enable or disable the generation of a default environ when + no environ is provided by the user (enabled by default) EOF exit 1 }
@@ -73,6 +77,12 @@ while [[ "$1" = -* ]]; do --disable-pretty-print-stacks) pretty_print_stacks=no ;; + --enable-default-environ) + environ_default=yes + ;; + --disable-default-environ) + environ_default=no + ;; --help) usage ;;
@@ -183,5 +193,6 @@ TEST_DIR=$testdir FIRMWARE=$firmware ENDIAN=$endian PRETTY_PRINT_STACKS=$pretty_print_stacks +ENVIRON_DEFAULT=$environ_default U32_LONG_FMT=$u32_long EOF
errata.txt new file +5 -0
@@ -0,0 +1,5 @@ +#---------------:-----------------------:-------------------------------------- +# commit : minimum kernel : summary +# 12 hex digits : version : +#---------------:-----------------------:-------------------------------------- +#---------------:-----------------------:--------------------------------------
scripts/arch-run.bash +45 -0
57 lines not on this page · raw message
Signature · 1 line
2.9.4
Re: [PATCH kvm-unit-tests 4/8] arch-run: generate errata when no environ is provided
Quoted 92 lines · Andrew Jones
Provide a table mapping errata to minimum kernel versions and a function that will use the host's kernel version to determine the values for each errata variable. These errata variables, with values based on the host kernel, are now provided to all unit tests by default, if no environ is provided. Errata variables passed from the run script environment still take precedence.
Signed-off-by Andrew Jones <[email protected]>--- configure | 11 +++++++++++ errata.txt | 5 +++++ scripts/arch-run.bash | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 errata.txtconfigure +11
-0@@ -14,6 +14,7 @@ host=$arch cross_prefix= endian="" pretty_print_stacks=yes +environ_default=yes u32_long= usage() {@@ -31,6 +32,9 @@ usage() { --endian=ENDIAN endianness to compile for (little or big, ppc64 only) --[enable|disable]-pretty-print-stacks enable or disable pretty stack printing (enabled by default) + --[enable|disable]-default-environ + enable or disable the generation of a default environ when + no environ is provided by the user (enabled by default) EOF exit 1 }@@ -73,6 +77,12 @@ while [[ "$1" = -* ]]; do --disable-pretty-print-stacks) pretty_print_stacks=no ;; + --enable-default-environ) + environ_default=yes + ;; + --disable-default-environ) + environ_default=no + ;; --help) usage ;;@@ -183,5 +193,6 @@ TEST_DIR=$testdir FIRMWARE=$firmware ENDIAN=$endian PRETTY_PRINT_STACKS=$pretty_print_stacks +ENVIRON_DEFAULT=$environ_default U32_LONG_FMT=$u32_long EOFerrata.txt new file +5
-0@@ -0,0 +1,5 @@ +#---------------:-----------------------:-------------------------------------- +# commit : minimum kernel : summary +# 12 hex digits : version : +#---------------:-----------------------:-------------------------------------- +#---------------:-----------------------:--------------------------------------scripts/arch-run.bash +9
-0@@ -172,6 +172,8 @@ env_add_errata () grep -q $errata <(env) && continue eval export "$line" done + elif [ ! -f "$ENV" ]; then + env_generate_errata fi if grep -q '^ERRATA_' <(env); then@@ -183,6 +185,49 @@ env_add_errata () fi } +env_generate_errata () +{ + local kernel_version_string=$(uname -r) + local kernel_version=$(echo "$kernel_version_string" | cut -d. -f1) + local kernel_patchlevel=$(echo "$kernel_version_string" | cut -d. -f2 | sed 's/[^0-9].*//') + local kernel_sublevel=$(echo "$kernel_version_string" | cut -d. -f3- | sed 's/[^0-9].*//') + local line commit minver errata v p s have
scripts/arch-run.bash env_add_errata () · line 204
Quoted 10 lines
scripts/arch-run.bash +10
-0+ + [ "$ENVIRON_DEFAULT" != "yes" ] && return + [ ! -f errata.txt ] && return + + for line in $(grep -v '^#' errata.txt | tr -d '[:blank:]' | cut -d: -f1,2); do + commit=$(echo $line | cut -d: -f1) + minver=$(echo $line | cut -d: -f2) + + errata="ERRATA_$commit" + grep -q $errata <(env) && continue
you can use:
test -v $errata && continue
scripts/arch-run.bash env_add_errata () · line 208
Quoted 4 lines
scripts/arch-run.bash +4
-0+ + v=$(echo "$minver" | cut -d. -f1) + p=$(echo "$minver" | cut -d. -f2) + s=$(echo "$minver" | cut -d. -f3)
you can use:
IFS=. read v p s <<<$minver
Laurent
Re: [PATCH kvm-unit-tests 4/8] arch-run: generate errata when no environ is provided
Quoted 108 lines · Laurent Vivier
Quoted 92 lines · Andrew Jones
Provide a table mapping errata to minimum kernel versions and a function that will use the host's kernel version to determine the values for each errata variable. These errata variables, with values based on the host kernel, are now provided to all unit tests by default, if no environ is provided. Errata variables passed from the run script environment still take precedence.
Signed-off-by Andrew Jones <[email protected]>--- configure | 11 +++++++++++ errata.txt | 5 +++++ scripts/arch-run.bash | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 errata.txtconfigure +11
-0@@ -14,6 +14,7 @@ host=$arch cross_prefix= endian="" pretty_print_stacks=yes +environ_default=yes u32_long= usage() {@@ -31,6 +32,9 @@ usage() { --endian=ENDIAN endianness to compile for (little or big, ppc64 only) --[enable|disable]-pretty-print-stacks enable or disable pretty stack printing (enabled by default) + --[enable|disable]-default-environ + enable or disable the generation of a default environ when + no environ is provided by the user (enabled by default) EOF exit 1 }@@ -73,6 +77,12 @@ while [[ "$1" = -* ]]; do --disable-pretty-print-stacks) pretty_print_stacks=no ;; + --enable-default-environ) + environ_default=yes + ;; + --disable-default-environ) + environ_default=no + ;; --help) usage ;;@@ -183,5 +193,6 @@ TEST_DIR=$testdir FIRMWARE=$firmware ENDIAN=$endian PRETTY_PRINT_STACKS=$pretty_print_stacks +ENVIRON_DEFAULT=$environ_default U32_LONG_FMT=$u32_long EOFerrata.txt new file +5
-0@@ -0,0 +1,5 @@ +#---------------:-----------------------:-------------------------------------- +# commit : minimum kernel : summary +# 12 hex digits : version : +#---------------:-----------------------:-------------------------------------- +#---------------:-----------------------:--------------------------------------scripts/arch-run.bash +9
-0@@ -172,6 +172,8 @@ env_add_errata () grep -q $errata <(env) && continue eval export "$line" done + elif [ ! -f "$ENV" ]; then + env_generate_errata fi if grep -q '^ERRATA_' <(env); then@@ -183,6 +185,49 @@ env_add_errata () fi } +env_generate_errata () +{ + local kernel_version_string=$(uname -r) + local kernel_version=$(echo "$kernel_version_string" | cut -d. -f1) + local kernel_patchlevel=$(echo "$kernel_version_string" | cut -d. -f2 | sed 's/[^0-9].*//') + local kernel_sublevel=$(echo "$kernel_version_string" | cut -d. -f3- | sed 's/[^0-9].*//') + local line commit minver errata v p s havescripts/arch-run.bash env_add_errata () · line 204
Quoted 10 lines
scripts/arch-run.bash +10
-0+ + [ "$ENVIRON_DEFAULT" != "yes" ] && return + [ ! -f errata.txt ] && return + + for line in $(grep -v '^#' errata.txt | tr -d '[:blank:]' | cut -d: -f1,2); do + commit=$(echo $line | cut -d: -f1) + minver=$(echo $line | cut -d: -f2) + + errata="ERRATA_$commit" + grep -q $errata <(env) && continueyou can use:
test -v $errata && continue
Quoted 8 lines
scripts/arch-run.bash env_add_errata () · line 208
Quoted 4 lines
scripts/arch-run.bash +4
-0+ + v=$(echo "$minver" | cut -d. -f1) + p=$(echo "$minver" | cut -d. -f2) + s=$(echo "$minver" | cut -d. -f3)you can use:
IFS=. read v p s <<<$minver
Nice suggestions. Will do.
Thanks,
drew
PATCH 5/8 errata: add ERRATA_FORCE
In reply to Andrew JonesProvide an easy way for test runners to run all tests, even those guarded by an erratum. Setting ERRATA_FORCE forces errata() and errata_relaxed() to always return true. ./run_tests.sh -a is also updated to set it.
--- lib/errata.h | 21 +++++++++++++++++++-- run_tests.sh | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-)
lib/errata.h +19 -2
@@ -13,16 +13,33 @@#define _ERRATA_RELAXED (erratum) errata_relaxed("ERRATA_" # erratum)#define ERRATA_RELAXED (erratum) _ERRATA_RELAXED(erratum) +static inline bool errata_force (void ) +{ +char *s =getenv ("ERRATA_FORCE" ); + +return s && (*s =='1' || *s =='y' || *s =='Y' ); +} +static inline bool errata (const char *erratum) { -char *s =getenv (erratum); +char *s; + +if (errata_force ()) +return true; + + s =getenv (erratum);return s && (*s =='1' || *s =='y' || *s =='Y' ); }static inline bool errata_relaxed (const char *erratum) { -char *s =getenv (erratum); +char *s; + +if (errata_force ()) +return true; + + s =getenv (erratum);return !(s && (*s =='0' || *s =='n' || *s =='N' )); }
run_tests.sh +2 -0
@@ -19,6 +19,7 @@ Usage: $0 [-h] [-v] [-a] [-g group] [-j NUM-TASKS] -h: Output this help text -v: Enables verbose mode -a: Run all tests, including those flagged as 'nodefault' + and those guarded by errata. -g: Only execute tests in the given group -j: Execute tests in parallel
@@ -35,6 +36,7 @@ while getopts "ag:hj:v" opt; do case $opt in a) run_all_tests="yes" + export ERRATA_FORCE=y ;; g) only_group=$OPTARG
Signature · 1 line
2.9.4
PATCH 6/8 README: add section on guarding unsafe tests
In reply to Andrew Jones--- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
README.md +34 -0
@@ -71,6 +71,40 @@ Additionally these self-explanatory variables are reserved QEMU_MAJOR, QEMU_MINOR, QEMU_MICRO, KERNEL_VERSION, KERNEL_PATCHLEVEL, KERNEL_SUBLEVEL, KERNEL_EXTRAVERSION +# Guarding unsafe tests + +Some tests are not safe to run by default, as they may crash the +host. kvm-unit-tests provides two ways to handle tests like those. + + 1) Adding 'nodefault' to the groups field for the unit test in the + unittests.cfg file. When a unit test is in the nodefault group + it is only run when invoked + + a) independently, arch-run arch/test + b) by specifying any other non-nodefault group it is in, + groups = nodefault,mygroup : ./run_tests.sh -g mygroup + c) by specifying all tests should be run, ./run_tests.sh -a + + 2) Making the test conditional on errata in the code, + if (ERRATA(abcdef012345)) { + do_unsafe_test(); + } + + With the errata condition the unsafe unit test is only run + when + + a) the ERRATA_abcdef012345 environ variable is provided and 'y' + b) the ERRATA_FORCE environ variable is provided and 'y' + c) by specifying all tests should be run, ./run_tests.sh -a + (The -a switch ensures the ERRATA_FORCE is provided and set + to 'y'.) + +The errata.txt file provides a mapping of the commits needed by errata +conditionals to their respective minimum kernel versions. By default, +when the user does not provide an environ, then an environ generated +from the errata.txt file and the host's kernel version is provided to +all unit tests. + # Contributing ## Directory structure
Signature · 1 line
2.9.4
PATCH 7/8 AArch32: apply errata framework to unsafe pmccntr64 test
In reply to Andrew Jones--- arm/pmu.c | 26 ++++++++++++++++++-------- errata.txt | 1 + 2 files changed, 19 insertions(+), 8 deletions(-)
arm/pmu.c +18 -8
@@ -14,6 +14,7 @@* for more details. */ #include "libcflat.h" +#include "errata.h" #include "asm/barrier.h" #include "asm/sysreg.h" #include "asm/processor.h"
@@ -57,18 +58,12 @@ static inline uint8_t get_pmu_version(void)static inline uint64_t get_pmccntr (void ) { -if (pmu_version ==0x3 ) -return read_sysreg (PMCCNTR64 ); -else -return read_sysreg (PMCCNTR32 ); +return read_sysreg (PMCCNTR32 ); }static inline void set_pmccntr (uint64_t value) { -if (pmu_version ==0x3 ) -write_sysreg (value,PMCCNTR64 ); -else -write_sysreg (value &0xffffffff ,PMCCNTR32 ); +write_sysreg (value &0xffffffff ,PMCCNTR32 ); }/* PMCCFILTR is an obsolete name for PMXEVTYPER31 in ARMv7 */
@@ -267,6 +262,19 @@ static bool check_cpi(int cpi)return true; } +static void pmccntr64_test (void ) +{ +#ifdef __arm__ +if (pmu_version ==0x3 ) { +if (ERRATA (9e3f7a296940 )) { +write_sysreg (0xdead ,PMCCNTR64 ); +report ("pmccntr64" , true); + }else +report_skip ("Skipping unsafe pmccntr64 test. Set ERRATA_9e3f7a296940=y to enable." ); + } +#endif +} +/* Return FALSE if no PMU found, otherwise return TRUE */ bool pmu_probe (void ) {
@@ -293,5 +301,7 @@ int main(int argc, char *argv[])report ("Monotonically increasing cycle count" ,check_cycles_increase ());report ("Cycle/instruction ratio" ,check_cpi (cpi)); +pmccntr64_test (); +return report_summary (); }
errata.txt +1 -0
@@ -2,4 +2,5 @@ # commit : minimum kernel : summary # 12 hex digits : version : #---------------:-----------------------:-------------------------------------- +9e3f7a296940 : 4.9 : arm64: KVM: pmu: Fix AArch32 cycle counter access #---------------:-----------------------:--------------------------------------
Signature · 1 line
2.9.4
PATCH 8/8 arm/arm64: apply errata framework to unsafe cpu-on test
In reply to Andrew JonesWith the unsafe subtest guarded by an erratum we no longer need nodefault.
--- arm/psci.c | 7 ++++++- arm/unittests.cfg | 2 +- errata.txt | 1 + 3 files changed, 8 insertions(+), 2 deletions(-)
arm/psci.c +6 -1
@@ -8,6 +8,7 @@* This work is licensed under the terms of the GNU LGPL, version 2. */ #include <libcflat.h> +#include <errata.h> #include <asm/processor.h> #include <asm/smp.h> #include <asm/psci.h>
@@ -136,7 +137,11 @@ int main(void)report ("invalid-function" ,psci_invalid_function ());report ("affinity-info-on" ,psci_affinity_info_on ());report ("affinity-info-off" ,psci_affinity_info_off ()); -report ("cpu-on" ,psci_cpu_on_test ()); + + if (ERRATA(6c7a5dce22b3)) +report ("cpu-on" ,psci_cpu_on_test ()); +else +report_skip ("Skipping unsafe cpu-on test. Set ERRATA_6c7a5dce22b3=y to enable." ); done: #if 0
arm/unittests.cfg +1 -1
@@ -108,4 +108,4 @@ groups = gic [psci] file = psci.flat smp = $MAX_SMP -groups = nodefault,psci +groups = psci
errata.txt +1 -0
@@ -3,4 +3,5 @@ # 12 hex digits : version : #---------------:-----------------------:-------------------------------------- 9e3f7a296940 : 4.9 : arm64: KVM: pmu: Fix AArch32 cycle counter access +6c7a5dce22b3 : 4.12 : KVM: arm/arm64: fix races in kvm_psci_vcpu_on #---------------:-----------------------:--------------------------------------
Signature · 1 line
2.9.4
[PATCH kvm-unit-tests 9/8] mkstandalone: provide errata to tests
In reply to Andrew Jones--- configure | 1 + scripts/arch-run.bash | 4 ++-- scripts/mkstandalone.sh | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-)
configure +1 -0
@@ -194,5 +194,6 @@ FIRMWARE=$firmware ENDIAN=$endian PRETTY_PRINT_STACKS=$pretty_print_stacks ENVIRON_DEFAULT=$environ_default +ERRATATXT=errata.txt U32_LONG_FMT=$u32_long EOF
scripts/arch-run.bash +2 -2
@@ -194,9 +194,9 @@ env_generate_errata () local line commit minver errata v p s have [ "$ENVIRON_DEFAULT" != "yes" ] && return - [ ! -f errata.txt ] && return + [ ! -f "$ERRATATXT" ] && return - for line in $(grep -v '^#' errata.txt | tr -d '[:blank:]' | cut -d: -f1,2); do + for line in $(grep -v '^#' "$ERRATATXT" | tr -d '[:blank:]' | cut -d: -f1,2); do commit=$(echo $line | cut -d: -f1) minver=$(echo $line | cut -d: -f2)
scripts/mkstandalone.sh +6 -0
@@ -40,6 +40,7 @@ generate_test () echo "#!/usr/bin/env bash" echo "export STANDALONE=yes" + echo "export ENVIRON_DEFAULT=yes" echo "export HOST=\$(uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/')" echo "export PRETTY_PRINT_STACKS=no"
@@ -62,6 +63,11 @@ generate_test () echo 'export FIRMWARE' fi + if [ "$ERRATATXT" ]; then + temp_file ERRATATXT "$ERRATATXT" + echo 'export ERRATATXT' + fi + temp_file bin "$kernel" args[3]='$bin'
Signature · 1 line
2.9.4