diff options
author | Jiajia Zheng <jiajia.zheng@intel.com> | 2009-12-02 13:11:54 +0100 |
---|---|---|
committer | Andi Kleen <ak@linux.intel.com> | 2009-12-02 13:11:54 +0100 |
commit | b94dd41a597d1bf367bf019143e271f116143696 (patch) | |
tree | 1b42402a0112b0733c5d85b74c0920651e9d8a0e | |
parent | 7065e3da86955110e185bc436f067c69abd72f7f (diff) | |
download | mce-test-b94dd41a597d1bf367bf019143e271f116143696.tar.gz |
APEI injection support for mce-test
Signed-off-by: Andi Kleen <ak@linux.intel.com>
-rw-r--r-- | cases/apei-inj/README | 33 | ||||
-rw-r--r-- | cases/apei-inj/ucr/cases.sh | 63 | ||||
-rw-r--r-- | cases/apei-inj/ucr/data/mem_uncorrected | 1 | ||||
-rw-r--r-- | cases/apei-inj/ucr/refer/mem_uncorrected | 10 | ||||
-rw-r--r-- | doc/howto.txt | 33 | ||||
-rw-r--r-- | lib/apei-inject.sh | 170 | ||||
-rw-r--r-- | lib/dirs.sh | 2 | ||||
-rw-r--r-- | tools/simple_process/Makefile | 7 | ||||
-rw-r--r-- | tools/simple_process/simple_process.c | 16 |
9 files changed, 324 insertions, 11 deletions
diff --git a/cases/apei-inj/README b/cases/apei-inj/README new file mode 100644 index 0000000..3ae91b4 --- /dev/null +++ b/cases/apei-inj/README @@ -0,0 +1,33 @@ +MCE APEI INJ testing cases +========================= + +Nov 6th, 2009 + +Jiajia Zheng + +Start +------------ +This test suite is based on apei-inj APEI haredware injection tool. +It's structure and usage are the same with soft-inj test suite. +To be root and invoke simple test driver on test configuration file as follow + drivers/simple/driver.sh config/simple_apei_ucr.conf + +Test Dependencies +----------------- +MCE APEI INJ test suite has following dependencies on kernel and other tools: + +* Make sure following configuration options are enabled in linux kernel: + CONFIG_FTRACE=y + CONFIG_FUNCTION_TRACER=y + +* page-types: + A tool to query page types, which is accompanied with Linux kernel + source (2.6.32 or newer, $KERNEL_SRC/Documentation/vm/page-types.c). + For detail, please see 3.4 in doc/howto.txt. + +* simple-process: + APEI hardware injection will inject an error to a page used by this simple-process. Intall simple-process. + cd mce-test/tools/simple_process + make + + diff --git a/cases/apei-inj/ucr/cases.sh b/cases/apei-inj/ucr/cases.sh new file mode 100644 index 0000000..ff4d92c --- /dev/null +++ b/cases/apei-inj/ucr/cases.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# +# APEI injection based test cases : memory patrol scrub cases: test cases +# are triggered via the apei-inject, and they will not trigger kernel panic. +# +# Copyright (C) 2008, Intel Corp. +# Author: Huang Ying <ying.huang@intel.com> +# Zheng Jiajia <jiajia.zheng@intel.com> +# +# This file is released under the GPLv2. +# + +. $ROOT/lib/functions.sh +. $ROOT/lib/dirs.sh +. $ROOT/lib/mce.sh +. $ROOT/lib/apei-inject.sh + +enumerate() +{ + apei_inject_enumerate +} + +trigger() +{ + case "$bcase" in + mem_uncorrected) + start_tracing "do_machine_check" + ;; + *) + echo '!!! Unknown case: $this_case !!!' + esac + apei_inject_trigger + stop_tracing +} + +get_result() +{ + apei_inject_get_klog + get_gcov drivers/acpi/apei/einj.c + + case "$bcase" in + mem_uncorrected) + get_mcelog_from_dev $mcelog_result + ;; + *) + echo '!!! Unknown case: $this_case !!!' + esac +} + +verify() +{ + case "$bcase" in + mem_uncorrected) + apei_inject_verify_mcelog + verify_klog $klog + apei_inject_verify_trace "do_machine_check" + ;; + *) + echo "!!! Unknown case: $this_case !!!" + esac +} + +apei_inject_main "$@" diff --git a/cases/apei-inj/ucr/data/mem_uncorrected b/cases/apei-inj/ucr/data/mem_uncorrected new file mode 100644 index 0000000..a6601e9 --- /dev/null +++ b/cases/apei-inj/ucr/data/mem_uncorrected @@ -0,0 +1 @@ +TYPE 0x10 diff --git a/cases/apei-inj/ucr/refer/mem_uncorrected b/cases/apei-inj/ucr/refer/mem_uncorrected new file mode 100644 index 0000000..43889f1 --- /dev/null +++ b/cases/apei-inj/ucr/refer/mem_uncorrected @@ -0,0 +1,10 @@ +CPU 0 BANK 2 +STATUS UNCORRECTED SRAO 0xcf +MCGSTATUS RIPV MCIP +MISC 0x8c +ADDR 0x1234 +RIP 0x73:0x2eadbabe + + + + diff --git a/doc/howto.txt b/doc/howto.txt index 7854377..d7de73c 100644 --- a/doc/howto.txt +++ b/doc/howto.txt @@ -45,6 +45,13 @@ guide and how to add new test cases into test suite. make sudo make install +- Install page-types tool (sec 3.4), which is accompanied with Linux kernel + source (2.6.32 or newer). + + cd $KERNEL_SRC/Documentation/vm/ + gcc -o page-types page-types.c + cp page-types /usr/bin/ + - Run make test-simple This will do the basic tests, but not the more complicated kdump ones. For more information on those read below. @@ -101,14 +108,13 @@ reboot (for kdump) indicate there is a reboot between test case trigger and test case verify, some context has been gone. -Several test case classes are provided with the test suite. They are -all based on mce-inject MCE software injection tool, and follows same -structure. +Several test case classes are provided with the test suite. +cases/soft-inj/* is based on mce-inject MCE software injection tool. +cases/apei-inj/* is based on apei-inj APEI haredware injection tool. -cases/soft-inj/<class name>/cases.sh Interface of the test case class -cases/soft-inj/<class name>/data/ Directory contains data file for - mce-inject tool. -cases/soft-inj/<class name>/refer/ Directory contains data file for +cases/<injection tool>/<class name>/cases.sh Interface of the test case class +cases/<injection tool>/<class name>/data/ Directory contains data file +cases/<injection tool>/<class name>/refer/ Directory contains data file for reference MCE records if necessary. For document of various test cases, please refer to doc/cases/*. @@ -169,13 +175,13 @@ Additional test result for various test cases will go "results/<driver_name>/<case_name>/<xxx>. For in-package test case class, additional test results include: -results/<driver_name>/soft-inject/<case_name>/klog +results/<driver_name>/<injection_tool>/<case_name>/klog Kernel log during testing -results/<driver_name>/soft-inject/<case_name>/mcelog +results/<driver_name>/<injection_tool>/<case_name>/mcelog mcelog output during testing -results/<driver_name>/soft-inject/<case_name>/mcelog_refer +results/<driver_name>/<injection_tool>/<case_name>/mcelog_refer mcelog output reference -results/<driver_name>/soft-inject/<case_name>/mce_64.c.gcov (for gcov) +results/<driver_name>/<injection_tool>/<case_name>/mce_64.c.gcov (for gcov) gcov output file @@ -214,6 +220,10 @@ been merged by LTP cvs. For more information please refer to gcovdump document. The latest gcovdump can be gotten from cvs: http://ltp.cvs.sourceforge.net/viewvc/ltp/utils/analysis/gcov-kdump/. +3.4 page-types +A tool to query page types, which is accompanied with Linux kernel +source (2.6.32 or newer, $KERNEL_SRC/Documentation/vm/page-types.c). +It is required for MCE apei-inj testing. 4. Usage Guide -------------- @@ -241,6 +251,7 @@ a. Linux kernel and user space tools as follow should be installed - A Linux kernel with full MCE injection support (see 0) - mce-inject tool (see 3.1) - mcelog with proper version (see 3.2) + - page-types (see 3.4) b. Modify config/simple.conf or create a new test configuration file. Refer to section 2.3 for more instruction about test diff --git a/lib/apei-inject.sh b/lib/apei-inject.sh new file mode 100644 index 0000000..bbea328 --- /dev/null +++ b/lib/apei-inject.sh @@ -0,0 +1,170 @@ +# +# APEI library: APEI specific functions +# +# Copyright (C) 2008, Intel Corp. +# Author: Huang Ying <ying.huang@intel.com> +# Zheng Jiajia <jiajia.zheng@intel.com> +# This file is released under the GPLv2. +# + +. $ROOT/lib/soft-inject.sh + +if [ -n "$this_case" ]; then + bcase=$(basename $this_case) +fi +mcelog_result=$RDIR/$this_case/mcelog +klog=$RDIR/$this_case/klog + + +apei_mce_reformat() +{ + local inf="$1" + local outf="$2" + local tmpf=$WDIR/mce_reformat_for_cmp + sed "s/0x//g" $inf | grep -v 'STATUS 0x0' | \ + grep -v 'STATUS 0x800000000000000' | sort > "$tmpf" + awk '/^STATUS/ {print $2}' $tmpf | cut -b 1-3 > $outf + awk '/MCGSTATUS/ {if ($4=="") print $2; else print $4;}' $tmpf >> $outf +} + +apei_mce_cmp() +{ + [ $# -eq 2 ] || die "missing parameter for mce_cmp" + local m1="$1" + local m2="$2" + local tmpf1=$WDIR/mce_cmp_1 + local tmpf2=$WDIR/mce_cmp_2 + + apei_mce_reformat "$m1" $tmpf1 + apei_mce_reformat "$m2" $tmpf2 + diff $tmpf1 $tmpf2 > /dev/null +} + +apei_inject_verify_mcelog() +{ + if [ -f $RDIR/$this_case/mcelog ]; then + mcelog_refer=$SDIR/refer/$bcase + mce-inject --dump $mcelog_refer > $RDIR/$this_case/mcelog_refer + if apei_mce_cmp $RDIR/$this_case/mcelog $RDIR/$this_case/mcelog_refer; then + echo " Passed: MCE log is ok" + else + echo " Failed: MCE log is different from input" + fi + else + echo " Failed: no MCE log result" + fi +} + + +apei_inject_get_klog() +{ + soft_inject_get_klog +} + +apei_inject_get_mcelog() +{ + soft_inject_get_mcelog +} + +# verify return value +apei_inject_verify_return_val() +{ + soft_inject_verify_return_val +} + +apei_inject_verify_kill() +{ + soft_inject_verify_kill +} + +apei_inject_enumerate() +{ + soft_inject_enumerate +} + +apei_inject_trigger() +{ + mcelog &> /dev/null + TYPE=`awk '/^TYPE/{print $2}' $SDIR/data/$bcase` + echo $TYPE > $APEI_IF/error_type + killall simple_process + $TDIR/simple_process/simple_process > /dev/null & + + page-types -p `pidof simple_process` -LN -b ano > $RDIR/$this_case/page + + ADDR=`awk '$2 != "offset" {print "0x"$2"000"}' $RDIR/$this_case/page | sed -n -e '1p'` + echo $ADDR > $APEI_IF/param1 + + echo "1" > $APEI_IF/error_inject + + ret=$? + echo $ret > $RDIR/$this_case/return + sleep 1 +} + +start_tracing() +{ + [ $# -eq 1 ] || die "missing parameter for get_panic_from_mcelog: please set filter for ftrace" + [ -d /sys/kernel/debug/tracing ] || die "no tracing" + echo "function_graph" > /sys/kernel/debug/tracing/current_tracer + echo $1 > /sys/kernel/debug/tracing/set_ftrace_filter + echo "1" > /sys/kernel/debug/tracing/tracing_enabled +} + +stop_tracing() +{ + [ -d /sys/kernel/debug/tracing ] || die "no tracing" + echo "0" > /sys/kernel/debug/tracing/tracing_enabled + cp /sys/kernel/debug/tracing/trace $RDIR/$this_case/ + echo "nop" > /sys/kernel/debug/tracing/current_tracer +} + +apei_inject_verify_trace() +{ + [ $# -eq 1 ] || die "missing parameter for apei_inject_verify_trace" + if grep "$1" $RDIR/$this_case/trace; then + echo "Passed: trace is correct" + else + echo "Failed: Nothing is traced" + fi +} + +apei_inject_verify_panic() +{ + local mce_panic="$1" + verify_panic_via_klog $klog "$mce_panic" +} + +apei_inject_verify_exp() +{ + verify_exp_via_klog $klog "$@" +} + +apei_inject_verify_fail() +{ + verify_fail_via_klog $klog "$@" +} + +apei_inject_main() +{ + op="$1" + shift + + case "$op" in + enumerate) + enumerate + ;; + trigger) + trigger "$@" + ;; + get_result) + get_result + ;; + verify) + verify + ;; + *) + die "Usage: $0 enumerate|trigger|get_result|verify" + esac + exit 0 +} diff --git a/lib/dirs.sh b/lib/dirs.sh index 5228f16..ee14aa2 100644 --- a/lib/dirs.sh +++ b/lib/dirs.sh @@ -12,6 +12,7 @@ RCONF_DIR=config RRDIR=results RWDIR=work RLDIR=lib +APEI_IF=/debug/apei/einj SDIR=$(script_dir) CDIR=$ROOT/cases @@ -19,3 +20,4 @@ CONF_DIR=$ROOT/config RDIR=$ROOT/results/$driver WDIR=$ROOT/work/$driver LDIR=$ROOT/lib +TDIR=$ROOT/tools diff --git a/tools/simple_process/Makefile b/tools/simple_process/Makefile new file mode 100644 index 0000000..e2a4116 --- /dev/null +++ b/tools/simple_process/Makefile @@ -0,0 +1,7 @@ +all: + gcc -Wall -g simple_process.c -o simple_process + + cp simple_process ../../bin + +clean: + rm -f simple_process *.o diff --git a/tools/simple_process/simple_process.c b/tools/simple_process/simple_process.c new file mode 100644 index 0000000..f69566a --- /dev/null +++ b/tools/simple_process/simple_process.c @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <stdlib.h> + +void main(void) +{ + void *p = malloc(128); + memset(p, 0, 128); + printf("alloc 128 mem\n"); + while (1) + { + sleep(1); + } +} + + + |