├── COPYING ├── Makefile ├── README ├── bin └── .gitignore ├── cases ├── Makefile ├── coverage │ └── soft-inj │ │ ├── config │ │ ├── kdump.conf │ │ ├── kdump_noser.conf │ │ ├── kdump_panic.conf │ │ ├── kdump_panic_noser.conf │ │ ├── kdump_panic_npcc.conf │ │ ├── kdump_panic_ucr.conf │ │ ├── kdump_ser.conf │ │ ├── simple.conf │ │ ├── simple_non_panic.conf │ │ ├── simple_nopanic_noser.conf │ │ ├── simple_nopanic_ser.conf │ │ ├── simple_noser.conf │ │ ├── simple_panic.conf │ │ ├── simple_panic_noser.conf │ │ ├── simple_panic_npcc.conf │ │ ├── simple_panic_ucr.conf │ │ ├── simple_poll_noser.conf │ │ ├── simple_poll_ucr.conf │ │ ├── simple_recoverable_ucr.conf │ │ └── simple_ser.conf │ │ ├── driver_kdump.sh │ │ ├── driver_simple.sh │ │ ├── non-panic │ │ ├── cases.sh │ │ └── data │ │ │ ├── corrected │ │ │ ├── corrected_hold │ │ │ ├── corrected_no_en │ │ │ └── corrected_over │ │ ├── panic │ │ ├── cases.sh │ │ ├── data │ │ │ ├── fatal │ │ │ ├── fatal_eipv │ │ │ ├── fatal_irq │ │ │ ├── fatal_no_en │ │ │ ├── fatal_over │ │ │ ├── fatal_ripv │ │ │ ├── fatal_timeout │ │ │ ├── fatal_timeout_ripv │ │ │ └── fatal_userspace │ │ └── refer │ │ │ └── fatal_no_en │ │ ├── panic_noser │ │ ├── cases.sh │ │ └── data │ │ │ ├── uc_over │ │ │ ├── uc_over_corrected │ │ │ └── uc_over_timeout │ │ ├── panic_npcc │ │ ├── cases.sh │ │ └── data │ │ │ ├── fatal_severity │ │ │ ├── uc_no_eripv │ │ │ ├── uc_no_eripv_timeout │ │ │ ├── uc_no_mcip │ │ │ ├── uc_no_mcip_timeout │ │ │ ├── uncorrected │ │ │ ├── uncorrected_timeout │ │ │ └── unknown │ │ ├── panic_ucr │ │ ├── cases.sh │ │ ├── data │ │ │ ├── s0_ar1 │ │ │ ├── srao_ewb_noripv │ │ │ ├── srao_mem_scrub_noripv │ │ │ ├── srar_no_en │ │ │ ├── srar_over │ │ │ └── srar_unkown │ │ └── refer │ │ │ └── srar_no_en │ │ ├── poll_noser │ │ ├── cases.sh │ │ ├── data │ │ │ └── uc_poll │ │ └── refer │ │ │ └── uc_poll │ │ ├── poll_ucr │ │ ├── cases.sh │ │ ├── data │ │ │ ├── fatal_poll │ │ │ ├── srar_poll │ │ │ ├── ucna │ │ │ └── ucna_over │ │ └── refer │ │ │ ├── fatal_poll │ │ │ ├── srar_poll │ │ │ ├── ucna │ │ │ └── ucna_over │ │ ├── recoverable_ucr │ │ ├── cases.sh │ │ ├── data │ │ │ ├── srao_corrected │ │ │ ├── srao_ewb │ │ │ ├── srao_mem_scrub │ │ │ ├── srao_no_en │ │ │ ├── srao_over │ │ │ ├── srao_ucna │ │ │ ├── srao_unknown │ │ │ ├── srar_usr_dcu │ │ │ ├── srar_usr_dcu_irq │ │ │ └── srar_usr_dcu_nmi │ │ └── refer │ │ │ ├── srao_corrected │ │ │ ├── srao_no_en │ │ │ └── srao_ucna │ │ ├── run_driver.sh │ │ ├── run_simple.sh │ │ └── setup.sh ├── function │ ├── Makefile │ ├── apei-inj │ │ ├── apei-inject.sh │ │ └── runtest.sh │ ├── bsp │ │ ├── bsp-test.sh │ │ └── runtest.sh │ ├── core_recovery │ │ ├── runtest_dcu.sh │ │ ├── runtest_ifu.sh │ │ └── srar_recovery.sh │ ├── edac │ │ ├── edac.sh │ │ └── runtest.sh │ ├── einj-ext │ │ ├── einj-ext.sh │ │ └── runtest.sh │ ├── emca-inj │ │ ├── emca-inject.sh │ │ └── runtest.sh │ ├── erst-inject │ │ ├── Makefile │ │ ├── cper.h │ │ ├── erst-inject.c │ │ ├── runtest.sh │ │ └── uuid.h │ ├── hwpoison │ │ ├── Makefile │ │ ├── README │ │ ├── helpers.sh │ │ ├── hugepage.h │ │ ├── random_offline │ │ ├── run_hard.sh │ │ ├── run_hugepage.sh │ │ ├── run_hugepage_overcommit.sh │ │ ├── run_soft.sh │ │ ├── run_thp.sh │ │ ├── thugetlb.c │ │ ├── thugetlb_overcommit.c │ │ ├── tinjpage.c │ │ ├── tkillpoison.c │ │ ├── tprctl.c │ │ ├── tsimpleinj.c │ │ ├── tsoft.c │ │ ├── tsoftinj.c │ │ ├── ttranshuge.c │ │ └── utils.h │ ├── kvm │ │ ├── README │ │ ├── guest │ │ │ └── guest_run_victim.sh │ │ ├── host │ │ │ ├── SRAO │ │ │ ├── guest_init │ │ │ └── host_run.sh │ │ └── patches │ │ │ └── fake_ser_p.patch │ └── pfa │ │ ├── Makefile │ │ ├── busy.c │ │ ├── load.sh │ │ ├── run_pfa.sh │ │ └── runtest.sh └── stress │ ├── Makefile │ └── hwpoison │ ├── Makefile │ ├── README │ ├── hwpoison.sh │ ├── run_hard.sh │ ├── run_soft.sh │ └── tools │ ├── Makefile │ ├── fs-metadata │ ├── Makefile │ ├── README │ ├── fs-metadata.sh │ ├── k-thread.sh │ ├── k-tree-gen.c │ └── k-tree-trav.c │ └── page-poisoning │ ├── Makefile │ ├── README │ └── page-poisoning.c ├── doc ├── casefile-howto.txt ├── cases │ ├── soft-inj_non-panic.txt │ ├── soft-inj_panic.txt │ ├── soft-inj_panic_noser.txt │ ├── soft-inj_panic_npcc.txt │ ├── soft-inj_panic_ucr.txt │ ├── soft-inj_poll_ucr.txt │ └── soft-inj_recoverable_ucr.txt ├── howto.txt ├── kvm ├── stress-howto.txt └── verify.txt ├── groups ├── coverage ├── function └── stress ├── lib ├── dirs.sh ├── functions.sh ├── mce.sh └── soft-inject.sh ├── mcemenu ├── results └── .gitignore ├── runmcetest ├── summary └── .gitignore ├── tools ├── Makefile ├── ltp-pan │ ├── Makefile │ ├── ltp-pan.c │ ├── splitstr.c │ ├── splitstr.h │ ├── zoolib.c │ └── zoolib.h ├── page-types │ ├── Makefile │ ├── debugfs.h │ ├── findfs.h │ ├── kernel-page-flags.h │ ├── magic.h │ └── page-types.c ├── scripts │ ├── gcov_merge.py │ ├── grep_result.sh │ ├── loop-mce-test.sh │ ├── mce_shell.sh │ └── scov_merge.py └── victim │ ├── Makefile │ └── victim.c └── work └── .gitignore /Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | $(MAKE) -C tools 3 | $(MAKE) -C cases 4 | 5 | clean: 6 | $(MAKE) -C tools clean 7 | $(MAKE) -C cases clean 8 | $(MAKE) reset 9 | 10 | install: 11 | $(MAKE) -C tools install 12 | $(MAKE) -C cases install 13 | 14 | reset: 15 | rm -rf bin/* 16 | rm -rf work/* 17 | 18 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | MCE test suite 2 | --------------- 3 | 4 | The MCE test suite is a collection of tools and test scripts for 5 | testing the Linux RAS related features, including CPU/Memory error 6 | containment and recovery, ACPI/APEI support etc. 7 | 8 | For some more details on machine checks see http://www.mcelog.org 9 | 10 | The goal is as follows: 11 | 1. cover most Linux kernel MCE processing code paths and features 12 | 2. cover functional test cases for all RAS related features 13 | 3. provide stress test cases for some RAS features, especially for 14 | memory part 15 | 16 | In the Package 17 | -------------- 18 | 19 | Here is a short description of what is included in the package 20 | 21 | README 22 | This document 23 | 24 | COPYING 25 | GNU General Public License 26 | 27 | Makefile 28 | Top level make file for MCE test suite 29 | 30 | bin/ 31 | Some tools used by test drivers or test cases will be 32 | installed into this directory. 33 | 34 | cases/* 35 | Contains all test cases, which may be organized in 36 | sub-directories, the interface of a class of test cases is a 37 | shell script under cases/, such as: 38 | -- cases/soft-inj/panic/cases.sh 39 | is for test cases triggered by soft-inject and may cause system 40 | panic during testing. 41 | -- cases/apei-inj/ucr/cases.sh 42 | is for test cases triggered by apei-inject. 43 | 44 | doc/* 45 | Documentation for MCE test suites include howto and 46 | descriptions of every test case. 47 | 48 | lib/* 49 | Contains some shell scripts, in which some common shell 50 | functions and variable definitions are defined to be used by 51 | multiple test drivers or test cases. 52 | 53 | tools/* 54 | Some tools used by MCE test suites. 55 | 56 | work/ 57 | During test, some temporary file will be put in work directory. 58 | 59 | groups/ 60 | Where all scenarios files such as coverage/function/stress are placed 61 | 62 | results/ 63 | When test is done, the test log will be placed in this directory. 64 | Some test results such as coverage test result will be 65 | placed in sub-directory under results directory. 66 | 67 | summary 68 | When test is done, a summary file in *date* format is placed here. 69 | 70 | Test Instruction 71 | ---------------- 72 | 73 | Please refer to corresponding section in doc/howto.txt. 74 | 75 | Very quick way to test this: 76 | 1. be root 77 | 2. make sure you have a kernel with CONFIG_X86_MCE_INJECT 78 | and CONFIG_HWPOISON_INJECT and soft-offlining support 79 | 3. run "mcemenu" 80 | 81 | Futher Information 82 | ------------------ 83 | 84 | For futher information about MCE test suite, please refer to documents 85 | in doc sub-directory. 86 | 87 | doc/howto.txt: a more detailed HOWTO document. This doc is a little 88 | bit out of date. 89 | 90 | doc/stress-howto.txt: Detailed HOWTO document for MCE stress test suite 91 | 92 | doc/cases/*.txt: Description of every test case, including test 93 | objective, code patch tested, reference and 94 | expected results 95 | -------------------------------------------------------------------------------- /bin/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /cases/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | $(MAKE) -C function 3 | $(MAKE) -C stress 4 | 5 | install: 6 | $(MAKE) -C function install 7 | $(MAKE) -C stress install 8 | 9 | clean: 10 | $(MAKE) -C function clean 11 | $(MAKE) -C stress clean 12 | 13 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/kdump.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="panic/cases.sh panic_npcc/cases.sh" 3 | COREDIR="/var/crash" 4 | GCOV=1 5 | KSRC_DIR=/lib/modules/$(uname -r)/build 6 | VMLINUX=$KSRC_DIR/vmlinux 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/kdump_noser.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="panic/cases.sh panic_npcc/cases.sh panic_noser/cases.sh" 3 | COREDIR="/var/crash" 4 | GCOV=1 5 | KSRC_DIR=/lib/modules/$(uname -r)/build 6 | VMLINUX=$KSRC_DIR/vmlinux 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/kdump_panic.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="panic/cases.sh" 3 | COREDIR="/var/crash" 4 | GCOV=1 5 | KSRC_DIR=/lib/modules/$(uname -r)/build 6 | VMLINUX=$KSRC_DIR/vmlinux 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/kdump_panic_noser.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="panic_noser/cases.sh" 3 | COREDIR="/var/crash" 4 | GCOV=1 5 | KSRC_DIR=/lib/modules/$(uname -r)/build 6 | VMLINUX=$KSRC_DIR/vmlinux 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/kdump_panic_npcc.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="panic_npcc/cases.sh" 3 | COREDIR="/var/crash" 4 | GCOV=1 5 | KSRC_DIR=/lib/modules/$(uname -r)/build 6 | VMLINUX=$KSRC_DIR/vmlinux 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/kdump_panic_ucr.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="panic_ucr/cases.sh" 3 | COREDIR="/var/crash" 4 | GCOV=1 5 | KSRC_DIR=/lib/modules/$(uname -r)/build 6 | VMLINUX=$KSRC_DIR/vmlinux 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/kdump_ser.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="panic/cases.sh panic_npcc/cases.sh panic_ucr/cases.sh" 3 | COREDIR="/var/crash" 4 | GCOV=1 5 | KSRC_DIR=/lib/modules/$(uname -r)/build 6 | VMLINUX=$KSRC_DIR/vmlinux 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/simple.conf: -------------------------------------------------------------------------------- 1 | CASES=" panic_noser/cases.sh panic_npcc/cases.sh panic/cases.sh recoverable_ucr/cases.sh poll_noser/cases.sh poll_ucr/cases.sh non-panic/cases.sh" 2 | GCOV=1 3 | KSRC_DIR=/lib/modules/$(uname -r)/build 4 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/simple_non_panic.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="non-panic/cases.sh" 3 | GCOV=1 4 | KSRC_DIR=/lib/modules/$(uname -r)/build 5 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/simple_nopanic_noser.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="non-panic/cases.sh poll_noser/cases.sh" 3 | GCOV=1 4 | KSRC_DIR=/lib/modules/$(uname -r)/build 5 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/simple_nopanic_ser.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="non-panic/cases.sh poll_ucr/cases.sh recoverable_ucr/cases.sh" 3 | GCOV=1 4 | KSRC_DIR=/lib/modules/$(uname -r)/build 5 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/simple_noser.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="non-panic/cases.sh panic/cases.sh panic_npcc/cases.sh panic_noser/cases.sh poll_noser/cases.sh" 3 | GCOV=1 4 | KSRC_DIR=/lib/modules/$(uname -r)/build 5 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/simple_panic.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="panic/cases.sh" 3 | GCOV=1 4 | KSRC_DIR=/lib/modules/$(uname -r)/build 5 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/simple_panic_noser.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="panic_noser/cases.sh" 3 | GCOV=1 4 | KSRC_DIR=/lib/modules/$(uname -r)/build 5 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/simple_panic_npcc.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="panic_npcc/cases.sh" 3 | GCOV=1 4 | KSRC_DIR=/lib/modules/$(uname -r)/build 5 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/simple_panic_ucr.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="panic_ucr/cases.sh" 3 | GCOV=1 4 | KSRC_DIR=/lib/modules/$(uname -r)/build 5 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/simple_poll_noser.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="poll_noser/cases.sh" 3 | GCOV=1 4 | KSRC_DIR=/lib/modules/$(uname -r)/build 5 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/simple_poll_ucr.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="poll_ucr/cases.sh" 3 | GCOV=1 4 | KSRC_DIR=/lib/modules/$(uname -r)/build 5 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/simple_recoverable_ucr.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="recoverable_ucr/cases.sh" 3 | GCOV=1 4 | KSRC_DIR=/lib/modules/$(uname -r)/build 5 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/config/simple_ser.conf: -------------------------------------------------------------------------------- 1 | 2 | CASES="non-panic/cases.sh panic/cases.sh panic_npcc/cases.sh poll_ucr/cases.sh panic_ucr/cases.sh recoverable_ucr/cases.sh" 3 | GCOV=1 4 | KSRC_DIR=/lib/modules/$(uname -r)/build 5 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/driver_simple.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Simple test driver: run test cases one by one, assuming test case 4 | # will not trigger panic or reboot. 5 | # 6 | # Copyright (C) 2008, Intel Corp. 7 | # Author: Huang Ying 8 | # 9 | # This file is released under the GPLv2. 10 | # 11 | 12 | sd=$(dirname "$0") 13 | export ROOT=`(cd $sd/../../..; pwd)` 14 | 15 | export driver=simple 16 | 17 | . $ROOT/lib/functions.sh 18 | setup_path 19 | . $ROOT/lib/dirs.sh 20 | . $ROOT/lib/mce.sh 21 | 22 | tmp_klog=$WDIR/simple_klog_tmp 23 | 24 | chk_err() 25 | { 26 | if [ \( -n "$DEBUG_MCE_TEST" \) -a \( -s $err_log \) ]; then 27 | cat $err_log 28 | fi 29 | } 30 | 31 | klog_begin() 32 | { 33 | dmesg > $tmp_klog.1 34 | } 35 | 36 | klog_end() 37 | { 38 | dmesg | sed -e '1d' > $tmp_klog.2 39 | diff $tmp_klog.1 $tmp_klog.2 | grep '^> ' | sed 's/> \(.*\)/\1/' > $klog 40 | } 41 | 42 | trigger() 43 | { 44 | reset_gcov 45 | 46 | $CDIR/$case_sh trigger 47 | } 48 | 49 | get_result() 50 | { 51 | $CDIR/$case_sh get_result 52 | } 53 | 54 | test_all() 55 | { 56 | if [ -n "$GCOV" ]; then 57 | if chk_gcov; then 58 | export GCOV=copy 59 | export KSRC_DIR 60 | else 61 | echo "gcov is not supported by kernel or there is no " \ 62 | "gcov utility installed" 63 | echo "disabling gcov support." 64 | unset GCOV 65 | fi 66 | fi 67 | 68 | #if mce_inject is a module, it is ensured to have been loaded 69 | modinfo mce_inject > /dev/null 2>&1 70 | if [ $? -eq 0 ]; then 71 | lsmod | grep mce_inject > /dev/null 2>&1 72 | [ $? -eq 0 ] || modprobe mce_inject 73 | [ $? -eq 0 ] || die "module mce_inject isn't supported ?" 74 | fi 75 | 76 | for case_sh in $CASES; do 77 | for this_case in $($case_sh enumerate); do 78 | set_fake_panic 1 79 | 80 | export this_case 81 | mkdir -p $RDIR/$this_case 82 | rm -rf $RDIR/$this_case/* 83 | echo -e "\n$this_case:" | tee -a $RDIR/result 84 | klog=$RDIR/$this_case/klog 85 | 86 | mkdir -p $WDIR/$this_case 87 | rm -rf $WDIR/$this_case/* 88 | local err_log=$WDIR/$this_case/err_log 89 | 90 | klog_begin 91 | trigger 2>$err_log | tee -a $RDIR/result 92 | chk_err 93 | random_sleep 94 | klog_end 95 | get_result 2>$err_log | tee -a $RDIR/result 96 | chk_err 97 | $CDIR/$case_sh verify 2>$err_log | tee -a $RDIR/result 98 | chk_err 99 | 100 | set_fake_panic 0 101 | done 102 | done 103 | } 104 | 105 | if [ $# -lt 1 ]; then 106 | die "Usage: $0 " 107 | fi 108 | 109 | #$1 is config name 110 | . $1 111 | 112 | driver_prepare 113 | set_panic_on_oops 0 114 | 115 | if [ -n "$START_BACKGROUND" ]; then 116 | eval $START_BACKGROUND 117 | else 118 | start_background 119 | fi 120 | 121 | [ -d $RDIR ] && mv $RDIR --backup=numbered -T $RDIR.old 122 | [ -d $WDIR ] && mv $WDIR --backup=numbered -T $WDIR.old 123 | 124 | test_all 125 | 126 | if [ -n "$STOP_BACKGROUND" ]; then 127 | eval $STOP_BACKGROUND 128 | else 129 | stop_background 130 | fi 131 | 132 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/non-panic/cases.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Software injection based test cases - non-panic cases: test cases 4 | # are triggered via the mce-inject tool, and they will not trigger kernel 5 | # panic. 6 | # 7 | # Copyright (C) 2008, Intel Corp. 8 | # Author: Huang Ying 9 | # 10 | # This file is released under the GPLv2. 11 | # 12 | 13 | . $ROOT/lib/functions.sh 14 | . $ROOT/lib/dirs.sh 15 | . $ROOT/lib/mce.sh 16 | . $ROOT/lib/soft-inject.sh 17 | 18 | enumerate() 19 | { 20 | soft_inject_enumerate 21 | } 22 | 23 | trigger() 24 | { 25 | soft_inject_trigger 26 | } 27 | 28 | get_result() 29 | { 30 | soft_inject_get_klog 31 | get_gcov arch/x86/kernel/cpu/mcheck/mce.c 32 | 33 | case "$bcase" in 34 | corrected|corrected_hold|corrected_over|corrected_no_en) 35 | get_mcelog_from_dev $mcelog_result 36 | ;; 37 | *) 38 | echo '!!! Unknown case: $this_case !!!' 39 | esac 40 | } 41 | 42 | verify() 43 | { 44 | local removes="TSC TIME PROCESSOR" 45 | case "$bcase" in 46 | corrected|corrected_hold|corrected_over|corrected_no_en) 47 | soft_inject_verify_mcelog 48 | verify_klog $klog 49 | ;; 50 | *) 51 | echo "!!! Unknown case: $this_case !!!" 52 | esac 53 | } 54 | 55 | soft_inject_main "$@" 56 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/non-panic/data/corrected: -------------------------------------------------------------------------------- 1 | # 2 | # log corrected machine checks 3 | CPU 0 BANK 1 4 | STATUS CORRECTED 5 | ADDR 0xabcd 6 | HOLD 7 | CPU 1 BANK 0 8 | # 9 | CPU 1 BANK 2 10 | STATUS CORRECTED 11 | MISC 0xabcd 12 | ADDR 0x1234 13 | HOLD 14 | CPU 0 BANK 0 15 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/non-panic/data/corrected_hold: -------------------------------------------------------------------------------- 1 | # 2 | # log two corrected machine checks 3 | CPU 0 BANK 1 4 | STATUS CORRECTED 5 | ADDR 0xabcd 6 | HOLD 7 | # 8 | CPU 1 BANK 2 9 | STATUS CORRECTED 10 | ADDR 0x1234 11 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/non-panic/data/corrected_no_en: -------------------------------------------------------------------------------- 1 | # 2 | CPU 0 BANK 3 3 | STATUS VAL 4 | HOLD 5 | CPU 1 BANK 0 -------------------------------------------------------------------------------- /cases/coverage/soft-inj/non-panic/data/corrected_over: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS VAL OVER EN 3 | HOLD 4 | CPU 1 BANK 0 5 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic/cases.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Software injection based test cases - panic cases: test cases are 4 | # triggered via the mce-inject tool, and they will trigger kernel panic. 5 | # 6 | # Copyright (C) 2008, Intel Corp. 7 | # Author: Huang Ying 8 | # 9 | # This file is released under the GPLv2. 10 | # 11 | 12 | . $ROOT/lib/functions.sh 13 | . $ROOT/lib/dirs.sh 14 | . $ROOT/lib/mce.sh 15 | . $ROOT/lib/soft-inject.sh 16 | 17 | enumerate() 18 | { 19 | soft_inject_enumerate 20 | } 21 | 22 | trigger() 23 | { 24 | reset_severity_cov 25 | soft_inject_trigger 26 | } 27 | 28 | get_result() 29 | { 30 | soft_inject_get_klog 31 | get_gcov arch/x86/kernel/cpu/mcheck/mce.c 32 | get_severity_cov 33 | 34 | case "$bcase" in 35 | fatal*) 36 | soft_inject_get_mcelog 37 | ;; 38 | *) 39 | echo '!!! Unknown case: $this_case !!!' 40 | esac 41 | } 42 | 43 | verify() 44 | { 45 | local removes="TSC TIME PROCESSOR" 46 | local curr_cpu_panic=": Fatal machine check on current CPU" 47 | local fatal_panic="Fatal Machine check" 48 | local pcc_exp="Processor context corrupt" 49 | case "$bcase" in 50 | fatal|fatal_irq|fatal_over) 51 | removes="$removes RIP" 52 | soft_inject_verify_mcelog 53 | verify_klog $klog 54 | soft_inject_verify_panic "$fatal_panic" 55 | soft_inject_verify_exp "$pcc_exp" 56 | ;; 57 | fatal_ripv|fatal_eipv|fatal_userspace) 58 | soft_inject_verify_mcelog 59 | verify_klog $klog 60 | soft_inject_verify_panic "$fatal_panic" 61 | soft_inject_verify_exp "$pcc_exp" 62 | ;; 63 | fatal_no_en) 64 | removes="$removes RIP" 65 | soft_inject_verify_mcelog 66 | verify_klog $klog 67 | soft_inject_verify_panic "Machine check from unknown source" 68 | ;; 69 | fatal_timeout) 70 | removes="$removes RIP" 71 | soft_inject_verify_mcelog 72 | verify_klog $klog 73 | soft_inject_verify_panic "$curr_cpu_panic" 74 | soft_inject_verify_timeout 75 | soft_inject_verify_exp "$pcc_exp" 76 | ;; 77 | fatal_timeout_ripv) 78 | soft_inject_verify_mcelog 79 | verify_klog $klog 80 | soft_inject_verify_panic "$curr_cpu_panic" 81 | soft_inject_verify_timeout 82 | soft_inject_verify_exp "$pcc_exp" 83 | ;; 84 | *) 85 | echo "!!! Unknown case: $this_case !!!" 86 | esac 87 | } 88 | 89 | soft_inject_main "$@" 90 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic/data/fatal: -------------------------------------------------------------------------------- 1 | # WARNING 2 | # this will panic your machine! 3 | # don't try casually 4 | CPU 0 BANK 4 5 | MCGSTATUS MCIP 6 | STATUS FATAL S 7 | RIP 12343434 8 | MISC 11 9 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic/data/fatal_eipv: -------------------------------------------------------------------------------- 1 | # WARNING 2 | # this will panic your machine! 3 | # don't try casually 4 | CPU 1 BANK 4 5 | MCGSTATUS MCIP EIPV 6 | STATUS FATAL S 7 | RIP 0x10:0x12343434 8 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic/data/fatal_irq: -------------------------------------------------------------------------------- 1 | # WARNING 2 | # this will panic your machine! 3 | # don't try casually 4 | CPU 0 BANK 4 5 | MCGSTATUS MCIP 6 | STATUS FATAL S 7 | RIP 12343434 8 | MISC 11 9 | IN_IRQ 10 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic/data/fatal_no_en: -------------------------------------------------------------------------------- 1 | # WARNING 2 | # this will panic your machine! 3 | # don't try casually 4 | CPU 0 BANK 4 5 | MCGSTATUS MCIP 6 | STATUS UC VAL PCC S 7 | RIP 0x10:12343434 8 | MISC 11 9 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic/data/fatal_over: -------------------------------------------------------------------------------- 1 | # WARNING 2 | # this will panic your machine! 3 | # don't try casually 4 | CPU 0 BANK 4 5 | MCGSTATUS MCIP 6 | STATUS FATAL OVER S 7 | RIP 12343434 8 | MISC 11 9 | 10 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic/data/fatal_ripv: -------------------------------------------------------------------------------- 1 | # WARNING 2 | # this will panic your machine! 3 | # don't try casually 4 | CPU 1 BANK 4 5 | MCGSTATUS MCIP RIPV 6 | STATUS FATAL S 7 | RIP 0x10:0x12343434 8 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic/data/fatal_timeout: -------------------------------------------------------------------------------- 1 | # WARNING 2 | # this will panic your machine! 3 | # don't try casually 4 | CPU 0 BANK 4 5 | MCGSTATUS MCIP 6 | STATUS FATAL S 7 | RIP 0x10:0x12343434 8 | MISC 0xb 9 | NOBROADCAST 10 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic/data/fatal_timeout_ripv: -------------------------------------------------------------------------------- 1 | # WARNING 2 | # this will panic your machine! 3 | # don't try casually 4 | CPU 0 BANK 4 5 | MCGSTATUS MCIP RIPV 6 | STATUS FATAL S 7 | RIP 0x10:0x12343434 8 | MISC 0xb 9 | NOBROADCAST 10 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic/data/fatal_userspace: -------------------------------------------------------------------------------- 1 | # WARNING 2 | # this will panic your machine! 3 | # don't try casually 4 | CPU 1 BANK 4 5 | MCGSTATUS MCIP EIPV 6 | STATUS FATAL S 7 | RIP 0x73:0x12343434 8 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic/refer/fatal_no_en: -------------------------------------------------------------------------------- 1 | # empty mcelog 2 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_noser/cases.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Software injection based test cases: test cases are triggered via 4 | # the mce-inject tool. 5 | # 6 | # Copyright (C) 2009, Intel Corp. 7 | # Author: Huang Ying 8 | # 9 | # This file is released under the GPLv2. 10 | # 11 | 12 | . $ROOT/lib/functions.sh 13 | . $ROOT/lib/dirs.sh 14 | . $ROOT/lib/mce.sh 15 | . $ROOT/lib/soft-inject.sh 16 | 17 | enumerate() 18 | { 19 | soft_inject_enumerate 20 | } 21 | 22 | trigger() 23 | { 24 | reset_severity_cov 25 | soft_inject_trigger 26 | } 27 | 28 | get_result() 29 | { 30 | soft_inject_get_klog 31 | get_gcov arch/x86/kernel/cpu/mcheck/mce.c 32 | soft_inject_get_mcelog 33 | get_severity_cov 34 | } 35 | 36 | verify() 37 | { 38 | local removes="TSC TIME PROCESSOR" 39 | local over_exp="Overflowed uncorrected" 40 | local fatal_panic=": Fatal Machine check" 41 | local curr_cpu_panic=": Fatal machine check on current CPU" 42 | case "$bcase" in 43 | uc_over|uc_over_corrected) 44 | soft_inject_verify_mcelog 45 | verify_klog $klog 46 | soft_inject_verify_panic "$fatal_panic" 47 | soft_inject_verify_exp "$over_exp" 48 | ;; 49 | uc_over_timeout) 50 | soft_inject_verify_mcelog 51 | verify_klog $klog 52 | soft_inject_verify_panic "$curr_cpu_panic" 53 | soft_inject_verify_exp "$over_exp" 54 | soft_inject_verify_timeout 55 | ;; 56 | *) 57 | echo "!!! Unknown case: $this_case !!!" 58 | esac 59 | } 60 | 61 | soft_inject_main "$@" 62 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_noser/data/uc_over: -------------------------------------------------------------------------------- 1 | # this should just kill the process 2 | CPU 0 BANK 2 3 | STATUS UNCORRECTED OVER 4 | MCGSTATUS RIPV EIPV MCIP 5 | ADDR 0x1234 6 | RIP 0x10:0xdeadbabe 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_noser/data/uc_over_corrected: -------------------------------------------------------------------------------- 1 | CPU 1 BANK 1 2 | MCGSTATUS RIPV MCIP 3 | STATUS CORRECTED 4 | RIP 0x13:0x12345678 5 | IN_PROC 6 | EXCP 7 | HOLD 8 | 9 | CPU 0 BANK 2 10 | STATUS UNCORRECTED OVER 11 | MCGSTATUS RIPV EIPV MCIP 12 | ADDR 0x1234 13 | RIP 0x10:0xdeadbabe 14 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_noser/data/uc_over_timeout: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED OVER 3 | MCGSTATUS RIPV EIPV MCIP 4 | ADDR 0x1234 5 | RIP 0x10:0xdeadbabe 6 | NOBROADCAST 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_npcc/cases.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Software injection based test cases: test cases are triggered via 4 | # the mce-inject tool. 5 | # 6 | # Copyright (C) 2008, Intel Corp. 7 | # Author: Huang Ying 8 | # 9 | # This file is released under the GPLv2. 10 | # 11 | 12 | . $ROOT/lib/functions.sh 13 | . $ROOT/lib/dirs.sh 14 | . $ROOT/lib/mce.sh 15 | . $ROOT/lib/soft-inject.sh 16 | 17 | enumerate() 18 | { 19 | soft_inject_enumerate 20 | } 21 | 22 | trigger() 23 | { 24 | reset_severity_cov 25 | soft_inject_trigger 26 | } 27 | 28 | get_result() 29 | { 30 | soft_inject_get_klog 31 | get_gcov arch/x86/kernel/cpu/mcheck/mce.c 32 | soft_inject_get_mcelog 33 | get_severity_cov 34 | } 35 | 36 | verify() 37 | { 38 | local mce_panic 39 | local removes="TSC TIME PROCESSOR" 40 | local pcc_exp="Processor context corrupt" 41 | local knoripv_exp="In kernel and no restart IP" 42 | local no_mcip_exp="MCIP not set in MCA handler" 43 | local no_eripv_exp="Neither restart nor error IP" 44 | local over_exp="Overflowed uncorrected" 45 | local fatal_panic=": Fatal Machine check" 46 | local curr_cpu_panic=": Fatal machine check on current CPU" 47 | local unknown_src_panic=": Machine check from unknown source" 48 | case "$bcase" in 49 | fatal_severity) 50 | removes="$removes RIP" 51 | soft_inject_verify_mcelog 52 | verify_klog $klog 53 | soft_inject_verify_panic "$fatal_panic" 54 | soft_inject_verify_exp "$pcc_exp" 55 | ;; 56 | uncorrected) 57 | soft_inject_verify_mcelog 58 | verify_klog $klog 59 | soft_inject_verify_panic "$fatal_panic" 60 | soft_inject_verify_exp "$knoripv_exp" 61 | ;; 62 | uncorrected_timeout*) 63 | soft_inject_verify_mcelog 64 | verify_klog $klog 65 | soft_inject_verify_panic "$curr_cpu_panic" 66 | soft_inject_verify_timeout 67 | soft_inject_verify_exp "$knoripv_exp" 68 | ;; 69 | uc_no_mcip) 70 | removes="$removes RIP" 71 | soft_inject_verify_mcelog 72 | verify_klog $klog 73 | soft_inject_verify_panic "$fatal_panic" 74 | soft_inject_verify_exp "$no_mcip_exp" 75 | ;; 76 | uc_no_mcip_timeout) 77 | removes="$removes RIP" 78 | soft_inject_verify_mcelog 79 | verify_klog $klog 80 | soft_inject_verify_panic "$curr_cpu_panic" 81 | soft_inject_verify_exp "$no_mcip_exp" 82 | soft_inject_verify_timeout 83 | ;; 84 | uc_no_eripv) 85 | removes="$removes RIP" 86 | soft_inject_verify_mcelog 87 | verify_klog $klog 88 | soft_inject_verify_panic "$fatal_panic" 89 | soft_inject_verify_exp "$no_eripv_exp" 90 | ;; 91 | uc_no_eripv_timeout) 92 | removes="$removes RIP" 93 | soft_inject_verify_mcelog 94 | verify_klog $klog 95 | soft_inject_verify_panic "$curr_cpu_panic" 96 | soft_inject_verify_exp "$no_eripv_exp" 97 | soft_inject_verify_timeout 98 | ;; 99 | unknown) 100 | verify_klog $klog 101 | soft_inject_verify_panic "$unknown_src_panic" 102 | ;; 103 | *) 104 | echo "!!! Unknown case: $this_case !!!" 105 | esac 106 | } 107 | 108 | soft_inject_main "$@" 109 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_npcc/data/fatal_severity: -------------------------------------------------------------------------------- 1 | # WARNING 2 | # this will panic your machine! 3 | # don't try casually 4 | CPU 0 BANK 3 5 | MCGSTATUS RIPV EIPV MCIP 6 | # S is regarded as SRAO for SER_P = 1 and ignored otherwise 7 | STATUS UNCORRECTED S 8 | RIP 0x10:0x12343434 9 | MISC 0x2314 10 | ADDR 0xabcd1234 11 | HOLD 12 | 13 | CPU 1 BANK 1 14 | MCGSTATUS MCIP 15 | STATUS FATAL S 16 | RIP 0x10:0xabcdcdcd 17 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_npcc/data/uc_no_eripv: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 1 2 | STATUS UNCORRECTED S 3 | MCGSTATUS MCIP 4 | ADDR 0x1234 5 | RIP 0x10:0xdeadbabe 6 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_npcc/data/uc_no_eripv_timeout: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 1 2 | STATUS UNCORRECTED S 3 | MCGSTATUS MCIP 4 | ADDR 0x1234 5 | RIP 0x10:0xdeadbabe 6 | NOBROADCAST 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_npcc/data/uc_no_mcip: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 1 2 | STATUS UNCORRECTED S 3 | ADDR 0x1234 4 | RIP 0x10:0xdeadbabe 5 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_npcc/data/uc_no_mcip_timeout: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 1 2 | STATUS UNCORRECTED S 3 | ADDR 0x1234 4 | RIP 0x10:0xdeadbabe 5 | NOBROADCAST 6 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_npcc/data/uncorrected: -------------------------------------------------------------------------------- 1 | # this should just kill the process 2 | CPU 0 BANK 2 3 | STATUS UNCORRECTED S 4 | MCGSTATUS EIPV MCIP 5 | ADDR 0x1234 6 | RIP 0x10:0xdeadbabe 7 | IN_PROC -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_npcc/data/uncorrected_timeout: -------------------------------------------------------------------------------- 1 | # this should just kill the process 2 | CPU 0 BANK 2 3 | STATUS UNCORRECTED S 4 | MCGSTATUS EIPV MCIP 5 | ADDR 0x1234 6 | RIP 0x10:0xdeadbabe 7 | IN_PROC 8 | NOBROADCAST 9 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_npcc/data/unknown: -------------------------------------------------------------------------------- 1 | # this should just kill the process 2 | CPU 0 BANK 2 3 | STATUS UC S 4 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_ucr/cases.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Software injection based test cases: test cases are triggered via 4 | # mce-inject tool. 5 | # 6 | # Copyright (C) 2009, Intel Corp. 7 | # Author: Huang Ying 8 | # 9 | # This file is released under the GPLv2. 10 | # 11 | 12 | . $ROOT/lib/functions.sh 13 | . $ROOT/lib/dirs.sh 14 | . $ROOT/lib/mce.sh 15 | . $ROOT/lib/soft-inject.sh 16 | 17 | enumerate() 18 | { 19 | soft_inject_enumerate 20 | } 21 | 22 | trigger() 23 | { 24 | reset_severity_cov 25 | soft_inject_trigger 26 | } 27 | 28 | get_result() 29 | { 30 | soft_inject_get_klog 31 | get_gcov arch/x86/kernel/cpu/mcheck/mce.c 32 | soft_inject_get_mcelog 33 | get_severity_cov 34 | } 35 | 36 | verify() 37 | { 38 | local removes="TSC TIME PROCESSOR" 39 | local fatal_panic=": Fatal Machine check" 40 | local curr_cpu_panic=": Fatal machine check on current CPU" 41 | local unknown_src_panic=": Machine check from unknown source" 42 | local no_eripv_exp="Neither restart nor error IP" 43 | case "$bcase" in 44 | s0_ar1) 45 | soft_inject_verify_mcelog 46 | verify_klog $klog 47 | soft_inject_verify_panic "$fatal_panic" 48 | soft_inject_verify_exp "Illegal combination (UCNA with AR=1)" 49 | ;; 50 | srar_over) 51 | soft_inject_verify_mcelog 52 | verify_klog $klog 53 | soft_inject_verify_panic "$fatal_panic" 54 | soft_inject_verify_exp "Action required with lost events" 55 | ;; 56 | srar_unkown) 57 | soft_inject_verify_mcelog 58 | verify_klog $klog 59 | soft_inject_verify_panic "$fatal_panic" 60 | soft_inject_verify_exp "Action required; unknown MCACOD" 61 | ;; 62 | srar_no_en) 63 | soft_inject_verify_mcelog 64 | verify_klog $klog 65 | soft_inject_verify_panic "Machine check from unknown source" 66 | ;; 67 | srao_mem_scrub_noripv|srao_ewb_noripv) 68 | soft_inject_verify_mcelog 69 | verify_klog $klog 70 | soft_inject_verify_panic "$fatal_panic" 71 | soft_inject_verify_exp "$no_eripv_exp" 72 | ;; 73 | *) 74 | echo "!!! Unknown case: $this_case !!!" 75 | esac 76 | } 77 | 78 | soft_inject_main "$@" 79 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_ucr/data/s0_ar1: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED AR 3 | MCGSTATUS RIPV EIPV MCIP 4 | ADDR 0x1234 5 | RIP 0x10:0xdeadbabe 6 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_ucr/data/srao_ewb_noripv: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED SRAO 0x17a 3 | MCGSTATUS MCIP 4 | ADDR 0x1234 5 | MISC 0x8c 6 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_ucr/data/srao_mem_scrub_noripv: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED SRAO 0xc0 3 | MCGSTATUS MCIP 4 | ADDR 0x1234 5 | MISC 0x8c 6 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_ucr/data/srar_no_en: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS VAL UC SRAR 3 | MCGSTATUS EIPV MCIP 4 | ADDR 0x1234 5 | RIP 0x73:0x2eadbabe 6 | 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_ucr/data/srar_over: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED SRAR OVER 3 | MCGSTATUS EIPV MCIP 4 | ADDR 0x1234 5 | RIP 0x73:0x1eadbabe 6 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_ucr/data/srar_unkown: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED SRAR 3 | MCGSTATUS EIPV MCIP 4 | ADDR 0x1234 5 | RIP 0x73:0x2eadbabe 6 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/panic_ucr/refer/srar_no_en: -------------------------------------------------------------------------------- 1 | #empty 2 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/poll_noser/cases.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Software injection based test cases: test cases are triggered via 4 | # the mce-inject tool. 5 | # 6 | # Copyright (C) 2009, Intel Corp. 7 | # Author: Jiajia Zheng 8 | # 9 | # This file is released under the GPLv2. 10 | # 11 | 12 | . $ROOT/lib/functions.sh 13 | . $ROOT/lib/dirs.sh 14 | . $ROOT/lib/mce.sh 15 | . $ROOT/lib/soft-inject.sh 16 | 17 | enumerate() 18 | { 19 | soft_inject_enumerate 20 | } 21 | 22 | trigger() 23 | { 24 | reset_severity_cov 25 | soft_inject_trigger 26 | } 27 | 28 | get_result() 29 | { 30 | soft_inject_get_klog 31 | get_gcov arch/x86/kernel/cpu/mcheck/mce.c 32 | soft_inject_get_mcelog 33 | get_severity_cov 34 | } 35 | 36 | verify() 37 | { 38 | local removes="TSC TIME PROCESSOR" 39 | case "$bcase" in 40 | uc_poll) 41 | soft_inject_verify_mcelog 42 | verify_klog $klog 43 | ;; 44 | *) 45 | echo "!!! Unknown case: $this_case !!!" 46 | esac 47 | } 48 | 49 | soft_inject_main "$@" 50 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/poll_noser/data/uc_poll: -------------------------------------------------------------------------------- 1 | CPU 1 BANK 4 2 | MCGSTATUS MCIP 3 | STATUS UNCORRECTED 4 | RIP 12343434 5 | MISC 11 6 | POLL 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/poll_noser/refer/uc_poll: -------------------------------------------------------------------------------- 1 | #empty 2 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/poll_ucr/cases.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Software injection based test cases: test cases are triggered via 4 | # mce-inject tool. 5 | # 6 | # Copyright (C) 2009, Intel Corp. 7 | # Author: Huang Ying 8 | # 9 | # This file is released under the GPLv2. 10 | # 11 | 12 | . $ROOT/lib/functions.sh 13 | . $ROOT/lib/dirs.sh 14 | . $ROOT/lib/mce.sh 15 | . $ROOT/lib/soft-inject.sh 16 | 17 | enumerate() 18 | { 19 | soft_inject_enumerate 20 | } 21 | 22 | trigger() 23 | { 24 | reset_severity_cov 25 | soft_inject_trigger 26 | } 27 | 28 | get_result() 29 | { 30 | soft_inject_get_klog 31 | get_gcov arch/x86/kernel/cpu/mcheck/mce.c 32 | soft_inject_get_mcelog 33 | get_severity_cov 34 | } 35 | 36 | verify() 37 | { 38 | local removes="TSC TIME PROCESSOR" 39 | case "$bcase" in 40 | ucna|ucna_over|srar_poll) 41 | soft_inject_verify_mcelog 42 | verify_klog $klog 43 | ;; 44 | fatal_poll) 45 | removes="$removes RIP" 46 | soft_inject_verify_mcelog 47 | verify_klog $klog 48 | ;; 49 | *) 50 | echo "!!! Unknown case: $this_case !!!" 51 | esac 52 | } 53 | 54 | soft_inject_main "$@" 55 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/poll_ucr/data/fatal_poll: -------------------------------------------------------------------------------- 1 | CPU 1 BANK 4 2 | MCGSTATUS MCIP 3 | STATUS FATAL 4 | RIP 12343434 5 | MISC 11 6 | POLL 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/poll_ucr/data/srar_poll: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED SRAR 3 | MCGSTATUS EIPV MCIP 4 | ADDR 0x1234 5 | RIP 0x73:0x2eadbabe 6 | POLL 7 | HOLD 8 | CPU 1 BANK 0 9 | 10 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/poll_ucr/data/ucna: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED UCNA 3 | ADDR 0x1234 4 | MISC 0x8c 5 | POLL 6 | HOLD 7 | CPU 1 BANK 0 -------------------------------------------------------------------------------- /cases/coverage/soft-inj/poll_ucr/data/ucna_over: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED UCNA OVER 3 | ADDR 0x1234 4 | MISC 0x8c 5 | POLL 6 | 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/poll_ucr/refer/fatal_poll: -------------------------------------------------------------------------------- 1 | #empty 2 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/poll_ucr/refer/srar_poll: -------------------------------------------------------------------------------- 1 | #empty 2 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/poll_ucr/refer/ucna: -------------------------------------------------------------------------------- 1 | #empty 2 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/poll_ucr/refer/ucna_over: -------------------------------------------------------------------------------- 1 | #empty 2 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/recoverable_ucr/cases.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Software injection based test cases: test cases are triggered via 4 | # mce-inject tool. 5 | # 6 | # Copyright (C) 2009, Intel Corp. 7 | # Author: Huang Ying 8 | # 9 | # This file is released under the GPLv2. 10 | # 11 | 12 | . $ROOT/lib/functions.sh 13 | . $ROOT/lib/dirs.sh 14 | . $ROOT/lib/mce.sh 15 | . $ROOT/lib/soft-inject.sh 16 | 17 | enumerate() 18 | { 19 | soft_inject_enumerate 20 | } 21 | 22 | trigger() 23 | { 24 | reset_severity_cov 25 | soft_inject_trigger 26 | } 27 | 28 | get_result() 29 | { 30 | soft_inject_get_klog 31 | soft_inject_get_mcelog 32 | get_gcov arch/x86/kernel/cpu/mcheck/mce.c 33 | get_severity_cov 34 | } 35 | 36 | verify() 37 | { 38 | local removes="TSC TIME PROCESSOR" 39 | if [ "$bcase" = "srao_ucna" ] 40 | then 41 | removes="$removes RIP" 42 | fi 43 | 44 | case "$bcase" in 45 | srao_*|srar_*) 46 | soft_inject_verify_mcelog 47 | verify_klog $klog 48 | soft_inject_verify_return_val 49 | ;; 50 | *) 51 | echo "!!! Unknown case: $this_case !!!" 52 | esac 53 | } 54 | 55 | soft_inject_main "$@" 56 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/recoverable_ucr/data/srao_corrected: -------------------------------------------------------------------------------- 1 | CPU 1 BANK 1 2 | MCGSTATUS RIPV MCIP 3 | STATUS CORRECTED 4 | EXCP 5 | HOLD 6 | 7 | CPU 0 BANK 2 8 | STATUS UNCORRECTED SRAO 9 | MCGSTATUS RIPV MCIP 10 | ADDR 0x1234 11 | RIP 0x73:0x1eadbabe 12 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/recoverable_ucr/data/srao_ewb: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED SRAO 0x17a 3 | MCGSTATUS RIPV MCIP 4 | ADDR 0x1234 5 | MISC 0x8c 6 | RIP 0x73:0x1eadbabe 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/recoverable_ucr/data/srao_mem_scrub: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED SRAO 0xc0 3 | MCGSTATUS RIPV MCIP 4 | ADDR 0x1234 5 | MISC 0x8c 6 | RIP 0x73:0x1eadbabe 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/recoverable_ucr/data/srao_no_en: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS VAL UC SRAO 3 | MCGSTATUS RIPV MCIP 4 | ADDR 0x1234 5 | RIP 0x73:0x1eadbabe 6 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/recoverable_ucr/data/srao_over: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED SRAO OVER 3 | MCGSTATUS RIPV MCIP 4 | ADDR 0x1234 5 | RIP 0x73:0x1eadbabe 6 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/recoverable_ucr/data/srao_ucna: -------------------------------------------------------------------------------- 1 | CPU 1 BANK 1 2 | MCGSTATUS RIPV MCIP 3 | STATUS UNCORRECTED UCNA 4 | EXCP 5 | HOLD 6 | 7 | CPU 0 BANK 2 8 | STATUS UNCORRECTED SRAO 9 | MCGSTATUS RIPV MCIP 10 | ADDR 0x1234 11 | RIP 0x73:0x1eadbabe 12 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/recoverable_ucr/data/srao_unknown: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED SRAO 3 | MCGSTATUS RIPV MCIP 4 | ADDR 0x1234 5 | RIP 0x73:0x1eadbabe 6 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/recoverable_ucr/data/srar_usr_dcu: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED SRAR 0x134 3 | MCGSTATUS RIPV MCIP EIPV 4 | ADDR 0x12345000 5 | MISC 0x8c 6 | RIP 0x73:0x1eadbabe 7 | NOBROADCAST 8 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/recoverable_ucr/data/srar_usr_dcu_irq: -------------------------------------------------------------------------------- 1 | CPU 3 BANK 2 2 | STATUS UNCORRECTED SRAR 0x134 3 | MCGSTATUS RIPV MCIP EIPV 4 | ADDR 0x12345000 5 | MISC 0x8c 6 | RIP 0x73:0x1eadbabe 7 | IRQBROADCAST 8 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/recoverable_ucr/data/srar_usr_dcu_nmi: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED SRAR 0x134 3 | MCGSTATUS RIPV MCIP EIPV 4 | ADDR 0x12345000 5 | MISC 0x8c 6 | RIP 0x73:0x1eadbabe 7 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/recoverable_ucr/refer/srao_corrected: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED SRAO 3 | MCGSTATUS RIPV MCIP 4 | ADDR 0x1234 5 | RIP 0x73:0x1eadbabe 6 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/recoverable_ucr/refer/srao_no_en: -------------------------------------------------------------------------------- 1 | #empty 2 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/recoverable_ucr/refer/srao_ucna: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED SRAO 3 | MCGSTATUS RIPV MCIP 4 | ADDR 0x1234 5 | RIP 0x73:0x1eadbabe 6 | 7 | CPU 1 BANK 1 8 | STATUS UNCORRECTED UCNA 9 | MCGSTATUS RIPV MCIP 10 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/run_driver.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo 0 > $TMP_DIR/error.$$ 4 | 5 | pushd `dirname $0` > /dev/null 6 | ./driver_kdump.sh config/kdump.conf 7 | [ $? -eq 0 ] || echo 1 > $TMP_DIR/error.$$ 8 | popd > /dev/null 9 | 10 | grep -q "1" $TMP_DIR/error.$$ 11 | if [ $? -eq 0 ] 12 | then 13 | exit 1 14 | else 15 | exit 0 16 | fi 17 | 18 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/run_simple.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo 0 > $TMP_DIR/error.$$ 4 | 5 | pushd `dirname $0` > /dev/null 6 | ./driver_simple.sh config/simple.conf 7 | [ $? -eq 0 ] || echo 1 > $TMP_DIR/error.$$ 8 | popd > /dev/null 9 | 10 | grep -q "1" $TMP_DIR/error.$$ 11 | if [ $? -eq 0 ] 12 | then 13 | exit 1 14 | else 15 | exit 0 16 | fi 17 | 18 | -------------------------------------------------------------------------------- /cases/coverage/soft-inj/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | # 3 | # Setup for kdump test driver. 4 | # 5 | # This file is copied from kdump test case of LTP. 6 | # 7 | # This file is released under the GPLv2. 8 | # 9 | 10 | conf=${1} 11 | arch=$(uname -m) 12 | kver=$(uname -r) 13 | 14 | . "${conf}" 15 | 16 | echo "Verify Kernel version >= 2.6.16." 17 | # Kernel might in the following format. 18 | # x.y.z-1.el 19 | # x.y.z.1.el 20 | kx=${kver%%.*} 21 | tmp=${kver#*.} 22 | ky=${tmp%%.*} 23 | tmp=${tmp#*.} 24 | tmp=${tmp%%.*} 25 | kz=${tmp%%-*} 26 | 27 | if [ "${kx}" -lt 2 ]; then 28 | error=1 29 | 30 | elif [ "${kx}" -eq 2 ]; then 31 | if [ "${ky}" -lt 6 ]; then 32 | error=1 33 | 34 | elif [ "${ky}" -eq 6 ]; then 35 | if [ "${kz}" -lt 16 ]; then 36 | error=1 37 | fi 38 | fi 39 | fi 40 | 41 | if [ "${error}" ]; then 42 | echo "Fail: kernel version ${kver} is less than 2.6.16." 43 | fi 44 | 45 | 46 | echo "Verify user is root." 47 | if [ $(id -u) != 0 ]; then 48 | echo "Fail: root is required." 49 | error=1 50 | fi 51 | 52 | 53 | echo "Verify prerequisite." 54 | if [ ! -x "/sbin/kexec" ]; then 55 | echo "Fail: kexec-tools not found." 56 | error=1 57 | fi 58 | 59 | if [ ! -d "/lib/modules/${kver}/build" ]; then 60 | echo "Fail: kernel-devel not found." 61 | error=1 62 | fi 63 | 64 | if [ "${CRASH}" ] && [ "${CRASH}" -eq 1 ]; then 65 | if [ ! -x "/usr/bin/crash" ]; then 66 | echo "Fail: crash not found." 67 | error=1 68 | fi 69 | 70 | if [ ! -f "${VMLINUX}" ]; then 71 | echo "Fail: kernel-debuginfo not found." 72 | error=1 73 | fi 74 | fi 75 | 76 | # Final result. 77 | if [ "${error}" ]; then 78 | echo "Please fixed the above failures before continuing." 79 | exit 1 80 | fi 81 | 82 | echo "Modify Boot Loader." 83 | if [ "${arch}" = "ppc64" ]; then 84 | args="crashkernel=256M@32M xmon=off" 85 | elif [ "${arch}" = "i686" ]; then 86 | args="crashkernel=128M@16M nmi_watchdog=1" 87 | elif [ "${arch}" = "ia64" ]; then 88 | args="crashkernel=512M@256M" 89 | else 90 | args="crashkernel=128M@16M" 91 | fi 92 | 93 | if [ -x "/sbin/grubby" ]; then 94 | /sbin/grubby --default-kernel | 95 | xargs /sbin/grubby --args="${args}" --update-kernel 96 | 97 | else 98 | echo "Warn: please make sure the following arguments are in Boot\ 99 | Loader:" 100 | echo "$args" 101 | echo "Hit any key when ready." 102 | read 103 | fi 104 | 105 | exit 0 106 | -------------------------------------------------------------------------------- /cases/function/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | $(MAKE) -C erst-inject 3 | $(MAKE) -C pfa 4 | $(MAKE) -C hwpoison 5 | # $(MAKE) -C kvm 6 | 7 | clean: 8 | $(MAKE) -C erst-inject clean 9 | $(MAKE) -C pfa clean 10 | $(MAKE) -C hwpoison clean 11 | # $(MAKE) -C kvm clean 12 | 13 | install: 14 | $(MAKE) -C erst-inject install 15 | $(MAKE) -C pfa install 16 | $(MAKE) -C hwpoison install 17 | # $(MAKE) -C kvm install 18 | 19 | -------------------------------------------------------------------------------- /cases/function/apei-inj/apei-inject.sh: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012, Intel Corp. 2 | # This file is released under the GPLv2. 3 | # 4 | # 5 | export ROOT=`(cd ../../../; pwd)` 6 | 7 | . $ROOT/lib/functions.sh 8 | setup_path 9 | . $ROOT/lib/mce.sh 10 | 11 | APEI_IF="" 12 | GHES_REC="Hardware error from APEI Generic Hardware Error Source" 13 | LOG_DIR=$ROOT/cases/function/apei-inj/log 14 | LOG=$LOG_DIR/$(date +%Y-%m-%d.%H.%M.%S)-`uname -r`.log 15 | 16 | check_err_type() 17 | { 18 | local type=`printf 0x%08x $1` 19 | 20 | cat $APEI_IF/available_error_type 2>/dev/null | cut -f1 | grep -q $type 21 | [ $? -eq 0 ] || 22 | { 23 | echo "The error type \"$1\" is not supported on this platform" 24 | return 1 25 | } 26 | } 27 | 28 | # On some machines the trigger will be happend after 15 ~ 20 seconds, so 29 | # when no proper log is read out, just executing wait-retry loop until 30 | # timeout. 31 | check_result() 32 | { 33 | local timeout=25 34 | local sleep=5 35 | local time=0 36 | 37 | echo -e "<<< OS/kernel version is as follows >>>\n" >> $LOG 38 | uname -a >> $LOG 39 | cat /etc/os-release >> $LOG 40 | echo -e "\n<<< dmesg information is as follows >>>\n" >> $LOG 41 | while [ $time -lt $timeout ] 42 | do 43 | dmesg -c >> $LOG 2>&1 44 | grep -q "$GHES_REC" $LOG 45 | if [ $? -eq 0 ] 46 | then 47 | echo -e "\nGHES record is OK\n" |tee -a $LOG 48 | echo 0 >> $TMP_DIR/error.$$ 49 | return 50 | fi 51 | sleep $sleep 52 | time=`expr $time + $sleep` 53 | done 54 | echo -e "\nGHES record is not expected\n" |tee -a $LOG 55 | echo 1 > $TMP_DIR/error.$$ 56 | return 1 57 | } 58 | 59 | main() 60 | { 61 | echo 0 > $TMP_DIR/error.$$ 62 | mkdir -p $LOG_DIR 63 | dmesg -c > /dev/null 64 | #inject error type 65 | local type=$1 66 | 67 | check_debugfs 68 | #if einj is a module, it is ensured to have been loaded 69 | modinfo einj &> /dev/null 70 | if [ $? -eq 0 ]; then 71 | modprobe einj param_extension=1 72 | [ $? -eq 0 ] || 73 | die "module einj isn't supported or EINJ Table doesn't exist?" 74 | fi 75 | #APEI_IF should be defined after debugfs is mounted 76 | APEI_IF=`cat /proc/mounts | grep debugfs | cut -d ' ' -f2 | head -1`/apei/einj 77 | [ -d $APEI_IF ] || 78 | die "einj isn't supported in the kernel or EINJ Table doesn't exist." 79 | 80 | check_err_type $type 81 | [ $? -ne 0 ] && return 1 82 | 83 | echo $type > $APEI_IF/error_type 84 | 85 | killall victim &> /dev/null 86 | touch trigger 87 | tail -f trigger --pid=$$ | victim -d > $TMP_DIR/pagelist.$$ & 88 | sleep 1 89 | ADDR=`cat $TMP_DIR/pagelist.$$ | awk '{print $NF}' | head -n 1` 90 | if [ -f $APEI_IF/param1 ] 91 | then 92 | echo $ADDR > $APEI_IF/param1 93 | echo 0xfffffffffffff000 > $APEI_IF/param2 94 | echo 1 > $APEI_IF/notrigger 95 | else 96 | killall victim &> /dev/null 97 | rm -f trigger 98 | die "$APEI_IF/param'1-2' are missed! Ensure your BIOS supporting it and enabled." 99 | fi 100 | 101 | echo "1" > $APEI_IF/error_inject 102 | [ $? -ne 0 ] && 103 | { 104 | cat <<-EOF 105 | 106 | Error injection fails. It maybe happens on some bogus BIOS. For example, 107 | some iomem region can't be acquired when requesting some resources. 108 | For detail information please refer to the following file: 109 | $LOG 110 | 111 | EOF 112 | killall victim &> /dev/null 113 | rm -f trigger 114 | echo 1 > $TMP_DIR/error.$$ 115 | echo -e "\nTest FAILED\n" 116 | exit 1 117 | } 118 | sleep 1 119 | echo go > trigger 120 | sleep 3 121 | 122 | check_result 123 | killall victim &> /dev/null 124 | rm -f trigger 125 | grep -q "1" $TMP_DIR/error.$$ 126 | if [ $? -eq 0 ] 127 | then 128 | echo -e "\nTest FAILED\n" 129 | exit 1 130 | else 131 | echo -e "\nTest PASSED\n" 132 | exit 0 133 | fi 134 | } 135 | 136 | usage() 137 | { 138 | cat <<-EOF 139 | usage: ${0##*/} [ available_error_type ] 140 | example: ${0##*/} [ 0x8 | 0x10 | 0x20 | ... ] 141 | 142 | EOF 143 | 144 | exit 0 145 | } 146 | 147 | [ $# -eq 0 ] && usage 148 | 149 | main $1 150 | -------------------------------------------------------------------------------- /cases/function/apei-inj/runtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This test is the basic EINJ functional test. Only Memory Correctable Error 3 | # is touched because other tests are possible to cause system hang/crash. 4 | # 5 | #0x00000008 Memory Correctable 6 | #0x00000010 Memory Uncorrectable non-fatal 7 | #0x00000020 Memory Uncorrectable fatal 8 | 9 | cat <<-EOF 10 | 11 | *************************************************************************** 12 | Pay attention: 13 | 14 | This test is basic APEI/EINJ functional test. Because other error injections 15 | are possible to cause system hang/crash, only Memory Correctable Error is 16 | injected to test the availiability of APEI/EINJ. 17 | *************************************************************************** 18 | 19 | EOF 20 | 21 | TMP="../../../work" 22 | TMP_DIR=${TMP_DIR:-$TMP} 23 | if [ ! -d $TMP_DIR ]; then 24 | TMP_DIR=$TMP 25 | fi 26 | export TMP_DIR 27 | 28 | echo 0 > $TMP_DIR/error.$$ 29 | 30 | pushd `dirname $0` > /dev/null 31 | ./apei-inject.sh 0x8 32 | [ $? -eq 0 ] || echo 1 > $TMP_DIR/error.$$ 33 | popd > /dev/null 34 | 35 | grep -q "1" $TMP_DIR/error.$$ 36 | if [ $? -eq 0 ] 37 | then 38 | exit 1 39 | else 40 | exit 0 41 | fi 42 | 43 | -------------------------------------------------------------------------------- /cases/function/bsp/runtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat <<-EOF 4 | 5 | ************************************************************************* 6 | Pay attention: 7 | 8 | This is basic BSP test, including onlining/offlining CPU0 and other 9 | regular CPUs for 10 times by default and checking if operations for S3/S4 10 | as expected whenever CPU0 is onlined or offlined. 11 | ************************************************************************* 12 | 13 | ************************************************************************* 14 | execution sequence is as follows: 15 | 16 | 1. execute per cpu (CPU0,...CPUx) offline & online operation in sequence. 17 | 2. execute cpu offline & online operation in group mode. 18 | 3. execute S3/S4 test along with CPU0 onlined and offlined, respectively. 19 | 20 | In addition, in order to avoid losing ssh connection once S3/S4 test is 21 | not as expected accidentally, use screen tool to keep the session always 22 | connected. 23 | 24 | Note: "DO NOT do any operation when S3/S4 test is running." 25 | ************************************************************************* 26 | 27 | ************************************************************************* 28 | log checking: 29 | 30 | For detail log information please refer to following files: 31 | 32 | mce-test/cases/function/bsp/log/*.output 33 | mce-test/cases/function/bsp/log/*.bsplog 34 | ************************************************************************* 35 | 36 | EOF 37 | 38 | TMP="../../../work" 39 | TMP_DIR=${TMP_DIR:-$TMP} 40 | if [ ! -d $TMP_DIR ]; then 41 | TMP_DIR=$TMP 42 | fi 43 | export TMP_DIR 44 | 45 | #$TMP_DIR can be absolute/relative path. Utilize it to locate BSP directory 46 | export BSP_DIR=`(cd $TMP_DIR; cd ../cases/function/bsp; pwd)` 47 | export BSP_LOG_DIR=$BSP_DIR/log 48 | export BSP_LOG=$BSP_LOG_DIR/$(date +%Y-%m-%d.%H.%M.%S)-`uname -r`.bsplog 49 | export OUTPUT_LOG=$BSP_LOG_DIR/$(date +%Y-%m-%d.%H.%M.%S)-`uname -r`.output 50 | 51 | export NUM_CPU=`ls -d /sys/devices/system/cpu/cpu[0-9]* | wc -l` 52 | export MAX_CPU=`expr $NUM_CPU - 1` 53 | export FAILST=$TMP_DIR/fail.list 54 | 55 | mkdir -p $BSP_LOG_DIR 56 | touch $FAILST 57 | 58 | pushd `dirname $0` > /dev/null 59 | #check if installed screen tool 60 | which screen &> /dev/null 61 | if [ $? -ne 0 ] 62 | then 63 | echo "Sorry, Please install screen first. Exiting..." 64 | exit 1 65 | else 66 | #check bsp support 67 | if [ -f /sys/devices/system/cpu/cpu0/online ] 68 | then 69 | echo "BSP is supported by current kernel!" 70 | else 71 | echo "BSP is not supported by current kernel, please rebuild kernel \ 72 | and test again. Exiting..." 73 | exit 1 74 | fi 75 | 76 | #screen command will terminate if stdin is not terminal. 77 | if [ -t 0 ]; then 78 | screen ./bsp-test.sh 79 | else 80 | ./bsp-test.sh 81 | fi 82 | 83 | NUM_FAIL_CPU=`grep "CPU" $FAILST |wc -l` 84 | NUM_PASS_CPU=`expr $NUM_CPU - $NUM_FAIL_CPU` 85 | 86 | echo "Total CPU Test: $NUM_CPU" 87 | echo "Total CPU Pass: $NUM_PASS_CPU" 88 | echo "Total CPU Fail: $NUM_FAIL_CPU" 89 | cat $FAILST 90 | cat $OUTPUT_LOG |grep -q "FAILED" 91 | if [ $? -ne 0 ] 92 | then 93 | echo -e "\nTEST PASSES" 94 | exit 0 95 | else 96 | echo -e "\nTEST FAILS" 97 | exit 1 98 | fi 99 | fi 100 | 101 | popd > /dev/null 102 | -------------------------------------------------------------------------------- /cases/function/core_recovery/runtest_dcu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This test is the SRAR/DCU functional test. 3 | # 4 | 5 | cat <<-EOF 6 | 7 | *************************************************************************** 8 | Pay attention: 9 | 10 | This test is SRAR functional test. It is for DCU part(L1 Data Cache). The 11 | test highly depends on BIOS implementation, which means if BIOS is bogus, 12 | it is possible to cause system hang/crash. If meeting this situation, 13 | please test again after rebooot or just skip this test. 14 | *************************************************************************** 15 | 16 | 17 | EOF 18 | 19 | TMP="../../../work" 20 | TMP_DIR=${TMP_DIR:-$TMP} 21 | if [ ! -d $TMP_DIR ]; then 22 | TMP_DIR=$TMP 23 | fi 24 | export TMP_DIR 25 | 26 | echo 0 > $TMP_DIR/error.$$ 27 | 28 | pushd `dirname $0` > /dev/null 29 | ./srar_recovery.sh -d 30 | [ $? -eq 0 ] || echo 1 > $TMP_DIR/error.$$ 31 | popd > /dev/null 32 | 33 | grep -q "1" $TMP_DIR/error.$$ 34 | if [ $? -eq 0 ] 35 | then 36 | exit 1 37 | else 38 | exit 0 39 | fi 40 | 41 | -------------------------------------------------------------------------------- /cases/function/core_recovery/runtest_ifu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This test is the SRAR/DCU functional test. 3 | # 4 | 5 | cat <<-EOF 6 | 7 | *************************************************************************** 8 | Pay attention: 9 | 10 | This test is SRAR functional test. It is for IFU part(L1 Instruction Cache). 11 | The test highly depends on BIOS implementation, which means if BIOS is bogus, 12 | it is possible to cause system hang/crash. If meeting this situation, 13 | please test again after rebooot or just skip this test. 14 | *************************************************************************** 15 | 16 | 17 | EOF 18 | 19 | TMP="../../../work" 20 | TMP_DIR=${TMP_DIR:-$TMP} 21 | if [ ! -d $TMP_DIR ]; then 22 | TMP_DIR=$TMP 23 | fi 24 | export TMP_DIR 25 | 26 | echo 0 > $TMP_DIR/error.$$ 27 | 28 | pushd `dirname $0` > /dev/null 29 | ./srar_recovery.sh -i 30 | [ $? -eq 0 ] || echo 1 > $TMP_DIR/error.$$ 31 | popd > /dev/null 32 | 33 | grep -q "1" $TMP_DIR/error.$$ 34 | if [ $? -eq 0 ] 35 | then 36 | exit 1 37 | else 38 | exit 0 39 | fi 40 | 41 | -------------------------------------------------------------------------------- /cases/function/core_recovery/srar_recovery.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #set -x 4 | export ROOT=`(cd ../../../; pwd)` 5 | 6 | . $ROOT/lib/functions.sh 7 | setup_path 8 | . $ROOT/lib/mce.sh 9 | 10 | inject_type=0x00000010 11 | EDAC_TYPE="" 12 | 13 | invalid() 14 | { 15 | echo $* 16 | exit 1 17 | } 18 | 19 | apei_inj() 20 | { 21 | echo $inject_type > $g_debugfs/apei/einj/error_type 22 | echo $1 > $g_debugfs/apei/einj/param1 23 | echo 0xfffffffffffff000 > $g_debugfs/apei/einj/param2 24 | echo 1 > $g_debugfs/apei/einj/notrigger 25 | echo 1 > $g_debugfs/apei/einj/error_inject 26 | } 27 | 28 | print_usage() 29 | { 30 | echo -e "usage: 31 | \t./srar_recovery.sh -d\t\tDCU error injection under user context 32 | \t./srar_recovery.sh -i\t\tIFU error injection under user context" 33 | } 34 | 35 | if [ "$1" != "-d" -a "$1" != "-i" ]; then 36 | print_usage 37 | exit 1 38 | fi 39 | check_debugfs 40 | 41 | g_debugfs=`cat /proc/mounts | grep debugfs | cut -d ' ' -f2 | head -1` 42 | #if einj is not builtin, just insmod it 43 | if [ ! -d $g_debugfs/apei/einj ]; then 44 | #if einj is a module, it is ensured to have been loaded 45 | modprobe einj param_extension=1 > /dev/null 2>&1 46 | [ $? -eq 0 ] || invalid "module einj isn't supported?" 47 | fi 48 | [ -f $g_debugfs/apei/einj/param1 ] || invalid "No BIOS extension support for APEI on this platform" 49 | [ -f $g_debugfs/apei/einj/notrigger ] || 50 | invalid "No parameter *notrigger*. Injection maybe causes system crash. Please check commit v3.3-3-gee49089" 51 | 52 | #check if the platform supports Uncorrectable non-fatal Memory Error injection 53 | cat $g_debugfs/apei/einj/available_error_type | grep -q $inject_type 54 | if [ $? -ne 0 ]; then 55 | invalid "Uncorrectable non-fatal Memory Error is not supported" 56 | fi 57 | 58 | # remove possible EDAC module, otherwise, the error information will be ate 59 | # by EDAC module and mcelog will not get it. 60 | # By now, only i7core_edac and sb_edac hook into the mcelog kernel buffer 61 | cat /proc/modules | grep -q i7core_edac 62 | if [ $? -eq 0 ]; then 63 | EDAC_TYPE="i7core_edac" 64 | else 65 | cat /proc/modules | grep -q sb_edac 66 | [ $? -eq 0 ] && EDAC_TYPE="sb_edac" 67 | elif 68 | cat /proc/modules | grep -q skx_edac 69 | [ $? -eq 0 ] && EDAC_TYPE="skx_edac" 70 | fi 71 | rmmod $EDAC_TYPE >/dev/null 2>&1 72 | 73 | [ -e $ROOT/bin/victim ] || invalid "file victim doesn't exist!" \ 74 | "maybe you forget to execute make install under directory $ROOT before test" 75 | killall victim > /dev/null 2>&1 76 | touch trigger 77 | tail -f trigger --pid=$$ | victim $1 > log & 78 | sleep 1 79 | addr=`cat log |cut -d' ' -f6|head -1` 80 | apei_inj $addr 81 | sleep 1 82 | echo go > trigger 83 | sleep 5 84 | rm -f trigger log 85 | id=`pgrep victim` 86 | if [ X"$id" != X ]; then 87 | echo $id | xargs kill -9 > /dev/null 2>&1 88 | invalid "The poisoned process can't be killed by kernel automatically. Test fails!" 89 | fi 90 | 91 | if [ $1 == "-d" ]; then 92 | echo "SRAR/DCU test passes!" 93 | elif [ $1 == "-i" ]; then 94 | echo "SRAR/IFU test passes!" 95 | fi 96 | 97 | -------------------------------------------------------------------------------- /cases/function/edac/runtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This test is used to validate EDAC function for RAS. Only check EDAC 3 | # relative information in dmesg output when inject Memory Correctable 4 | # Error with EINJ tool. 5 | 6 | cat <<-EOF 7 | 8 | *************************************************************************** 9 | Pay attention: 10 | 11 | EDAC subsystem is a hardware specific driver to report hardware related error, 12 | here only Memory Correctable Error is checked. 13 | This test is used for verifying EDAC driver by checking if its output can 14 | keep correct under different kernel release via comparing against a reference 15 | result run earlier or on earlier kernel version. 16 | *************************************************************************** 17 | 18 | EOF 19 | 20 | TMP="../../../work" 21 | TMP_DIR=${TMP_DIR:-$TMP} 22 | if [ ! -d $TMP_DIR ]; then 23 | TMP_DIR=$TMP 24 | fi 25 | export TMP_DIR 26 | 27 | echo 0 > $TMP_DIR/error.$$ 28 | 29 | pushd `dirname $0` > /dev/null 30 | ./edac.sh 31 | [ $? -eq 0 ] || echo 1 > $TMP_DIR/error.$$ 32 | popd > /dev/null 33 | 34 | grep -q "1" $TMP_DIR/error.$$ 35 | if [ $? -eq 0 ] 36 | then 37 | exit 1 38 | else 39 | exit 0 40 | fi 41 | 42 | -------------------------------------------------------------------------------- /cases/function/einj-ext/einj-ext.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (C) 2012, Intel Corp. 4 | # This file is released under the GPLv2. 5 | 6 | cat <<-EOF 7 | ########################################################################### 8 | ### Section 1: Regular error injection with Correctable Memory Error ### 9 | ### Section 2: Vendor Extension Specific Error Injection ### 10 | ########################################################################### 11 | 12 | EOF 13 | 14 | export ROOT=`(cd ../../../; pwd)` 15 | 16 | . $ROOT/lib/functions.sh 17 | setup_path 18 | . $ROOT/lib/mce.sh 19 | 20 | 21 | APEI_IF="" 22 | GHES_REC="Hardware error from APEI Generic Hardware Error Source" 23 | LOG_DIR=$ROOT/cases/function/einj-ext/log 24 | LOG=$LOG_DIR/$(date +%Y-%m-%d.%H.%M.%S)-`uname -r`.log 25 | 26 | mkdir -p $LOG_DIR 27 | echo 0 > $TMP_DIR/error.$$ 28 | 29 | check_support() 30 | { 31 | check_debugfs 32 | #if einj is a module, it is ensured to have been loaded 33 | modinfo einj &> /dev/null 34 | if [ $? -eq 0 ]; then 35 | modprobe einj 36 | [ $? -eq 0 ] || 37 | die "module einj isn't supported or EINJ Table doesn't exist?" 38 | fi 39 | #APEI_IF should be defined after debugfs is mounted 40 | APEI_IF=`cat /proc/mounts | grep debugfs | cut -d ' ' -f2 | head -1`/apei/einj 41 | [ -d $APEI_IF ] || 42 | die "einj isn't supported in the kernel or EINJ Table doesn't exist." 43 | 44 | [ -f $APEI_IF/vendor ] || 45 | die "Does ACPI5.0 is enabled? Please check your BIOS settings!" 46 | } 47 | 48 | check_err_type() 49 | { 50 | local type=`printf 0x%08x $1` 51 | 52 | cat $APEI_IF/available_error_type 2>/dev/null | cut -f1 | grep -q $type 53 | [ $? -eq 0 ] || 54 | { 55 | echo "The error type \"$type\" is not supported on this platform" |tee -a $LOG 56 | return 1 57 | } 58 | } 59 | 60 | # On some machines the trigger will happen after 15 ~ 20 seconds, so 61 | # when no proper log is read out, just execute wait-retry loop until 62 | # timeout. 63 | check_result() 64 | { 65 | local timeout=25 66 | local sleep=5 67 | local time=0 68 | 69 | echo -e "Current OS/kernel version as follows:\n" >> $LOG 70 | uname -a >> $LOG 71 | cat /etc/os-release >> $LOG 72 | echo -e "\ndmesg information as follows:\n" >> $LOG 73 | while [ $time -lt $timeout ] 74 | do 75 | dmesg -c >> $LOG 2>&1 76 | grep -q "$GHES_REC" $LOG 77 | [ $? -eq 0 ] && return 0 78 | sleep $sleep 79 | time=`expr $time + $sleep` 80 | done 81 | return 1 82 | } 83 | 84 | einj_inj() 85 | { 86 | echo -e "====== Section 1: Regular EINJ Injection with Memory Correctable Error =====\n" |tee -a $LOG 87 | 88 | dmesg -c > /dev/null 89 | #inject error type 90 | local type=0x8 91 | check_err_type $type 92 | [ $? -ne 0 ] && return 1 93 | echo $type > $APEI_IF/error_type 94 | 95 | killall victim &> /dev/null 96 | touch trigger 97 | tail -f trigger --pid=$$ | victim -d > $TMP_DIR/pagelist.$$ & 98 | sleep 1 99 | ADDR=`cat $TMP_DIR/pagelist.$$ | awk '{print $NF}' | head -n 1` 100 | if [ -f $APEI_IF/param1 ] 101 | then 102 | echo $ADDR > $APEI_IF/param1 103 | echo 0xfffffffffffff000 > $APEI_IF/param2 104 | echo 1 > $APEI_IF/notrigger 105 | else 106 | killall victim &> /dev/null 107 | rm -f trigger 108 | die "$APEI_IF/param'1-2' are missed! Ensure your BIOS supporting it and enabled." 109 | fi 110 | 111 | echo "1" > $APEI_IF/error_inject 112 | [ $? -ne 0 ] && 113 | { 114 | cat <<-EOF 115 | 116 | *************************************************************************** 117 | Error injection fails. It is possible to happen on bogus BIOS. For example, 118 | some iomem region can't be acquired when requesting some resources. 119 | For detail log information please refer to the following file: 120 | $LOG 121 | *************************************************************************** 122 | 123 | EOF 124 | killall victim &> /dev/null 125 | rm -f trigger 126 | echo 1 > $TMP_DIR/error.$$ 127 | echo -e "\nTest FAILED\n" 128 | exit 1 129 | } 130 | sleep 1 131 | echo go > trigger 132 | sleep 3 133 | 134 | check_result 135 | if [ $? -eq 0 ] 136 | then 137 | echo -e "\nEINJ Injection: GHES record is OK" |tee -a $LOG 138 | echo 0 >> $TMP_DIR/error.$$ 139 | else 140 | echo -e "\nEINJ Injection: GHES record is not expected" |tee -a $LOG 141 | echo 1 > $TMP_DIR/error.$$ 142 | fi 143 | killall victim &> /dev/null 144 | rm -f trigger 145 | } 146 | 147 | vendor_inj() 148 | { 149 | echo -e "\n====== Section 2: Vendor Extension Specific Error Injection ==============\n" |tee -a $LOG 150 | echo -e "Vendor Information as follows:\n" >> $LOG 151 | cat $APEI_IF/vendor >> $LOG 152 | if [ $? -ne 0 ] 153 | then 154 | cat <<-EOF 155 | 156 | Your platform supports ACPI5.0 extension for EINJ but your BIOS 157 | is bogus so that EINJ test fails. Please refer to output 158 | information above. For detail information please see following file: 159 | $LOG 160 | 161 | EOF 162 | else 163 | echo "Vendor Extension: Vendor information check is OK" |tee -a $LOG 164 | fi 165 | echo -e "\nThis test is not available by now. Just skip it.\n" |tee -a $LOG 166 | } 167 | 168 | main() 169 | { 170 | check_support 171 | einj_inj 172 | vendor_inj 173 | grep -q "1" $TMP_DIR/error.$$ 174 | if [ $? -eq 0 ] 175 | then 176 | echo -e "\nTest FAILED\n" 177 | exit 1 178 | else 179 | echo -e "\nTest PASSED\n" 180 | exit 0 181 | fi 182 | } 183 | main 184 | -------------------------------------------------------------------------------- /cases/function/einj-ext/runtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat <<-EOF 4 | 5 | *************************************************************************** 6 | Pay attention: 7 | 8 | This is a functional test for ACPI5.0 extension support for EINJ, including 9 | regular EINJ error injection test and Vendor Extension Specific Error 10 | Injection test with ACPI5.0 enabled BIOS. 11 | *************************************************************************** 12 | 13 | EOF 14 | 15 | TMP="../../../work" 16 | TMP_DIR=${TMP_DIR:-$TMP} 17 | if [ ! -d $TMP_DIR ]; then 18 | TMP_DIR=$TMP 19 | fi 20 | export TMP_DIR 21 | 22 | echo 0 > $TMP_DIR/error.$$ 23 | 24 | pushd `dirname $0` > /dev/null 25 | ./einj-ext.sh 26 | [ $? -eq 0 ] || echo 1 > $TMP_DIR/error.$$ 27 | popd > /dev/null 28 | 29 | grep -q "1" $TMP_DIR/error.$$ 30 | if [ $? -eq 0 ] 31 | then 32 | exit 1 33 | else 34 | exit 0 35 | fi 36 | 37 | 38 | -------------------------------------------------------------------------------- /cases/function/emca-inj/emca-inject.sh: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2014, Intel Corp. 2 | # This file is released under the GPLv2. 3 | # 4 | # 5 | export ROOT=`(cd ../../../; pwd)` 6 | 7 | . $ROOT/lib/functions.sh 8 | setup_path 9 | . $ROOT/lib/mce.sh 10 | 11 | APEI_IF="" 12 | eMCA_REC="DIMM location:" 13 | LOG_DIR=$ROOT/cases/function/emca-inj/log 14 | LOG=$LOG_DIR/$(date +%Y-%m-%d.%H.%M.%S)-`uname -r`.log 15 | 16 | check_err_type() 17 | { 18 | local type=`printf 0x%08x $1` 19 | 20 | cat $APEI_IF/available_error_type 2>/dev/null | cut -f1 | grep -q $type 21 | [ $? -eq 0 ] || 22 | { 23 | echo "The error type \"$1\" is not supported on this platform" 24 | return 1 25 | } 26 | } 27 | 28 | # On some machines the trigger will be happend after 15 ~ 20 seconds, so 29 | # when no proper log is read out, just executing wait-retry loop until 30 | # timeout. 31 | check_result() 32 | { 33 | local timeout=25 34 | local sleep=5 35 | local time=0 36 | 37 | echo -e "<<< kernel version is as below >>>\n" >> $LOG 38 | uname -a >> $LOG 39 | cat /etc/os-release >> $LOG 40 | echo -e "\n<<< dmesg is as below >>>\n" >> $LOG 41 | while [ $time -lt $timeout ] 42 | do 43 | dmesg -c >> $LOG 2>&1 44 | grep -q "$eMCA_REC" $LOG 45 | if [ $? -eq 0 ] 46 | then 47 | echo -e "\neMCA record is OK\n" |tee -a $LOG 48 | echo 0 > $TMP_DIR/emca.$$ 49 | return 50 | fi 51 | sleep $sleep 52 | time=`expr $time + $sleep` 53 | done 54 | echo -e "\neMCA record is not expected\n" |tee -a $LOG 55 | echo 1 > $TMP_DIR/emca.$$ 56 | } 57 | 58 | clean_up_eMCA() 59 | { 60 | rmmod acpi_extlog &> /dev/null 61 | rmmod einj &> /dev/null 62 | } 63 | 64 | main() 65 | { 66 | local ret 67 | #error type 68 | local type=$1 69 | 70 | echo 0 > $TMP_DIR/emca.$$ 71 | mkdir -p $LOG_DIR 72 | dmesg -c > /dev/null 73 | 74 | check_debugfs 75 | APEI_IF=`cat /proc/mounts | grep debugfs | cut -d ' ' -f2 | head -1`/apei/einj 76 | if [ ! -d $APEI_IF ]; then 77 | modprobe einj param_extension=1 78 | if [ $? -ne 0 ];then 79 | clean_up_eMCA 80 | die "module einj isn't supported or EINJ Table doesn't exist?" 81 | fi 82 | fi 83 | check_eMCA_config 84 | check_err_type $type 85 | [ $? -ne 0 ] && return 1 86 | sleep 2 87 | echo $type > $APEI_IF/error_type 88 | 89 | killall victim &> /dev/null 90 | touch trigger 91 | tail -f trigger --pid=$$ | victim -d > $TMP_DIR/pagelist.$$ & 92 | sleep 1 93 | ADDR=`cat $TMP_DIR/pagelist.$$ | awk '{print $NF}' | head -n 1` 94 | if [ -f $APEI_IF/param1 ] 95 | then 96 | echo $ADDR > $APEI_IF/param1 97 | echo 0xfffffffffffff000 > $APEI_IF/param2 98 | echo 1 > $APEI_IF/notrigger 99 | else 100 | killall victim &> /dev/null 101 | clean_up_eMCA 102 | die "$APEI_IF/param'1-2' are missed! Ensure your BIOS supporting it and enabled." 103 | fi 104 | 105 | echo 1 > $APEI_IF/error_inject 106 | if [ $? -ne 0 ]; then 107 | cat <<-EOF 108 | Error injection fails. It may happens because of bogus BIOS. For detail 109 | information please refer to following file: 110 | $LOG 111 | 112 | EOF 113 | killall victim &> /dev/null 114 | clean_up_eMCA 115 | echo 1 > $TMP_DIR/emca.$$ 116 | echo -e "\nTest FAILED\n" 117 | return 1 118 | fi 119 | sleep 1 120 | echo go > trigger 121 | sleep 3 122 | 123 | check_result 124 | grep -q "0" $TMP_DIR/emca.$$ 125 | ret=$? 126 | clean_up_eMCA 127 | killall victim &> /dev/null 128 | rm -f trigger 129 | if [ $ret -ne 0 ] 130 | then 131 | echo -e "\nTest FAILED\n" 132 | else 133 | echo -e "\nTest PASSED\n" 134 | fi 135 | return $ret 136 | } 137 | 138 | usage() 139 | { 140 | cat <<-EOF 141 | usage: ${0##*/} [ available_error_type ] 142 | example: ${0##*/} [ only support 0x8 injection ] 143 | 144 | EOF 145 | 146 | exit 0 147 | } 148 | 149 | [ $# -eq 0 ] && usage 150 | 151 | main $1 152 | -------------------------------------------------------------------------------- /cases/function/emca-inj/runtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat <<-EOF 4 | 5 | *************************************************************************** 6 | Pay attention: 7 | 8 | This is basic eMCA functional test. By now only eMCA Gen1 is supported, 9 | which means only Corrected Error injection/trigger is doable. 10 | *************************************************************************** 11 | 12 | EOF 13 | 14 | TMP="../../../work" 15 | TMP_DIR=${TMP_DIR:-$TMP} 16 | if [ ! -d $TMP_DIR ]; then 17 | TMP_DIR=$TMP 18 | fi 19 | export TMP_DIR 20 | 21 | echo 0 > $TMP_DIR/error.$$ 22 | 23 | pushd `dirname $0` > /dev/null 24 | ./emca-inject.sh 0x8 25 | [ $? -eq 0 ] || echo 1 > $TMP_DIR/error.$$ 26 | popd > /dev/null 27 | 28 | grep -q "1" $TMP_DIR/error.$$ 29 | if [ $? -eq 0 ] 30 | then 31 | exit 1 32 | else 33 | exit 0 34 | fi 35 | 36 | -------------------------------------------------------------------------------- /cases/function/erst-inject/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS := -g -Wall 2 | 3 | erst-inject: erst-inject.o 4 | 5 | install: erst-inject 6 | 7 | clean: 8 | rm -f *.o erst-inject 9 | -------------------------------------------------------------------------------- /cases/function/erst-inject/erst-inject.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Error Record Serialization Table(ERST) is used to save and retrieve hardware 3 | * error information to and from a persistent store, such as flash or NVRAM. 4 | * 5 | * This test case is used to test ERST operation including read/write/clean. 6 | * To be sure of loading erst-dbg module before executing this test. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public 10 | * License as published by the Free Software Foundation; version 2. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should find a copy of v2 of the GNU General Public License somewhere 18 | * on your Linux system; if not, write to the Free Software Foundation, 19 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | * 21 | * Copyright (C) 2011, Intel Corp. 22 | * Author: Chen Gong 23 | * 24 | * Original written by Huang Ying 25 | * Updated by Chen Gong 26 | * 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include "cper.h" 38 | 39 | #define ERST_DEV "/dev/erst_dbg" 40 | 41 | #define APEI_ERST_CLEAR_RECORD _IOW('E', 1, u64) 42 | #define APEI_ERST_GET_RECORD_COUNT _IOR('E', 2, u32) 43 | 44 | #define CPER_CREATOR_LINUX \ 45 | LGUID(0x94DB0E05, 0xEE60, 0x42D8, 0x91, 0xA5, 0xC6, 0xC0, \ 46 | 0x02, 0x41, 0x6C, 0x6A) 47 | 48 | #define ERROR_EXIT_ON(check, fmt, x...) \ 49 | do { \ 50 | if (check) \ 51 | error_exit(fmt, ## x); \ 52 | } while (0) 53 | 54 | void error_exit(char *fmt, ...) 55 | { 56 | va_list ap; 57 | 58 | fprintf(stderr, "Error: "); 59 | va_start(ap, fmt); 60 | vfprintf(stderr, fmt, ap); 61 | va_end(ap); 62 | 63 | if (errno) 64 | fprintf(stderr, ", errno: %d (%s)\n", errno, strerror(errno)); 65 | else 66 | fprintf(stderr, "\n"); 67 | exit(-1); 68 | } 69 | 70 | void inject(int fd, u64 record_id) 71 | { 72 | int rc; 73 | unsigned int len; 74 | struct cper_record_header *rcd_hdr; 75 | struct cper_section_descriptor *sec_hdr; 76 | struct cper_sec_mem_err *mem_err; 77 | 78 | len = sizeof(*rcd_hdr) + sizeof(*sec_hdr) + sizeof(*mem_err); 79 | printf("sizes: %lu, %lu, %lu\n", sizeof(*rcd_hdr), sizeof(*sec_hdr), 80 | sizeof(*mem_err)); 81 | rcd_hdr = malloc(len); 82 | ERROR_EXIT_ON(!rcd_hdr, "Can not alloc mem"); 83 | 84 | #define LE 0 85 | 86 | sec_hdr = (void *)(rcd_hdr + 1); 87 | mem_err = (void *)(sec_hdr + 1); 88 | 89 | memset(rcd_hdr, 0, sizeof(*rcd_hdr)); 90 | #if 0 91 | memcpy(rcd_hdr->signature, "REPC", 4); 92 | #else 93 | memcpy(rcd_hdr->signature, "CPER", 4); 94 | #endif 95 | rcd_hdr->revision = 0x0100; 96 | rcd_hdr->signature_end = 0xffffffff; 97 | rcd_hdr->error_severity = CPER_SER_FATAL; 98 | rcd_hdr->validation_bits = 0; 99 | rcd_hdr->creator_id = CPER_CREATOR_LINUX; 100 | rcd_hdr->notification_type = CPER_NOTIFY_NMI; 101 | rcd_hdr->section_count = 1; 102 | rcd_hdr->record_length = len; 103 | rcd_hdr->record_id = record_id; 104 | #if LE 105 | memcpy(&rcd_hdr->persistence_information, "RE", 2); 106 | #else 107 | memcpy(&rcd_hdr->persistence_information, "ER", 2); 108 | #endif 109 | 110 | memset(sec_hdr, 0, sizeof(*sec_hdr)); 111 | sec_hdr->section_offset = (void *)mem_err - (void *)rcd_hdr; 112 | sec_hdr->section_length = sizeof(*mem_err); 113 | sec_hdr->revision = 0x0100; 114 | sec_hdr->validation_bits = 0; 115 | sec_hdr->flags = 0; 116 | sec_hdr->section_type = CPER_SEC_PLATFORM_MEM; 117 | sec_hdr->section_severity = CPER_SER_FATAL; 118 | 119 | memset(mem_err, 0, sizeof(*mem_err)); 120 | mem_err->validation_bits = 0x6; 121 | mem_err->physical_addr = 0x2000; 122 | mem_err->physical_addr_mask = ~0xfffULL; 123 | 124 | rc = write(fd, rcd_hdr, len); 125 | ERROR_EXIT_ON(rc != len, "Error inject: %d", rc); 126 | 127 | free(rcd_hdr); 128 | } 129 | 130 | #define POLL_BUF_SIZ (1024 * 1024) 131 | 132 | int poll(int fd) 133 | { 134 | int rc; 135 | struct cper_record_header *rcd_hdr; 136 | struct cper_section_descriptor *sec_hdr; 137 | struct cper_sec_mem_err *mem_err; 138 | 139 | rcd_hdr = malloc(POLL_BUF_SIZ); 140 | ERROR_EXIT_ON(!rcd_hdr, "Can not alloc mem"); 141 | 142 | rc = read(fd, rcd_hdr, POLL_BUF_SIZ); 143 | ERROR_EXIT_ON(rc < 0, "Error poll: %d", rc); 144 | 145 | sec_hdr = (void *)(rcd_hdr + 1); 146 | mem_err = (void *)(sec_hdr + 1); 147 | 148 | printf("rc: %d\n", rc); 149 | 150 | printf("rcd sig: %4s\n", rcd_hdr->signature); 151 | printf("rcd id: 0x%llx\n", rcd_hdr->record_id); 152 | 153 | free(rcd_hdr); 154 | 155 | return rc; 156 | } 157 | 158 | void clear(int fd, u64 record_id) 159 | { 160 | int rc; 161 | 162 | printf("clear an error record: id = 0x%llx\n", record_id); 163 | 164 | rc = ioctl(fd, APEI_ERST_CLEAR_RECORD, &record_id); 165 | ERROR_EXIT_ON(rc, "Error clear: %d", rc); 166 | } 167 | 168 | void get_record_count(int fd, u32 *record_count) 169 | { 170 | int rc; 171 | rc = ioctl(fd, APEI_ERST_GET_RECORD_COUNT, record_count); 172 | ERROR_EXIT_ON(rc, "Error get record count: %d", rc); 173 | 174 | printf("total error record count: %u\n", *record_count); 175 | } 176 | 177 | enum { 178 | ERST_INJECT, 179 | ERST_POLL, 180 | ERST_CLEAR, 181 | ERST_COUNT, 182 | ERST_MAX = 255 183 | }; 184 | 185 | void usage() 186 | { 187 | printf("Usage: ./erst-inject [option] \n"); 188 | printf("PAY ATTENTION, is hexadecimal.\n"); 189 | printf("\tp\treturn all error records in the ERST\n"); 190 | printf("\ti\twrite an error record to be persisted into one item with \n"); 191 | printf("\tc\tclean specific error record with \n"); 192 | printf("\tn\treturn error records count in the ERST\n"); 193 | printf("\nExample:\t ./erst-inject -p\n"); 194 | printf("\t\t ./erst-inject -i 0x1234567\n"); 195 | printf("\t\t ./erst-inject -c 5050\n"); 196 | printf("\t\t ./erst-inject -n\n"); 197 | } 198 | 199 | int main(int argc, char *argv[]) 200 | { 201 | int fd; 202 | int todo = ERST_MAX; 203 | int opt; 204 | u64 record_id = 0x12345678; 205 | u32 record_count; 206 | 207 | if (argc == 1) { 208 | usage(); 209 | exit(0); 210 | } 211 | 212 | while ((opt = getopt(argc, argv, "pi:c:n")) != -1) { 213 | switch (opt) { 214 | case 'p': 215 | todo = ERST_POLL; 216 | break; 217 | case 'i': 218 | todo = ERST_INJECT; 219 | record_id = strtoull(optarg, NULL, 16); 220 | break; 221 | case 'c': 222 | todo = ERST_CLEAR; 223 | record_id = strtoull(optarg, NULL, 16); 224 | break; 225 | case 'n': 226 | todo = ERST_COUNT; 227 | break; 228 | } 229 | } 230 | 231 | fd = open(ERST_DEV, O_RDWR); 232 | ERROR_EXIT_ON(fd < 0, "Can not open dev file"); 233 | 234 | switch (todo) { 235 | case ERST_INJECT: 236 | inject(fd, record_id); 237 | break; 238 | case ERST_POLL: 239 | while (poll(fd)); 240 | break; 241 | case ERST_CLEAR: 242 | clear(fd, record_id); 243 | break; 244 | case ERST_COUNT: 245 | get_record_count(fd, &record_count); 246 | break; 247 | case ERST_MAX: 248 | usage(); 249 | break; 250 | } 251 | 252 | close(fd); 253 | 254 | return 0; 255 | } 256 | -------------------------------------------------------------------------------- /cases/function/erst-inject/runtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # APEI ERST firmware interface and implementation has no multiple users 4 | # in mind. For example, there is four records in storage with ID: 1, 2, 5 | # 3 and 4, if two ERST readers enumerate the records via 6 | # GET_NEXT_RECORD_ID as follow, 7 | # 8 | # reader 1 reader 2 9 | # 1 10 | # 2 11 | # 3 12 | # 4 13 | # -1 14 | # -1 15 | # 16 | # where -1 signals there is no more record ID. 17 | # 18 | # Reader 1 has no chance to check record 2 and 4, while reader 2 has no 19 | # chance to check record 1 and 3. And any other GET_NEXT_RECORD_ID will 20 | # return -1, that is, other readers will has no chance to check any 21 | # record even they are not cleared by anyone. 22 | # 23 | # This makes raw GET_NEXT_RECORD_ID not suitable for usage of multiple 24 | # users. 25 | # 26 | # This issue has been resolved since 2.6.39-rc1, so please run this case 27 | # with Linux kernel >=2.6.39-rc1 28 | # 29 | # This program is free software; you can redistribute it and/or 30 | # modify it under the terms of the GNU General Public 31 | # License as published by the Free Software Foundation; version 2. 32 | # 33 | # This program is distributed in the hope that it will be useful, 34 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 35 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36 | # General Public License for more details. 37 | # 38 | # You should find a copy of v2 of the GNU General Public License somewhere 39 | # on your Linux system; if not, write to the Free Software Foundation, 40 | # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 41 | # 42 | # Copyright (C) 2011, Intel Corp. 43 | # Author: Chen Gong 44 | # 45 | 46 | cat <<-EOF 47 | 48 | *************************************************************************** 49 | Pay attention: 50 | 51 | This test is basic APEI/ERST functional test. In this test case, it will 52 | test ERST functionality of READ/WRITE/ERASE. Any error in the test 53 | procedure will be considered as failure and reported. 54 | 55 | Because the ERST test maybe damges the data in the ERST table, please 56 | restore the valid data in the ERST to the other safe place. 57 | 58 | *************************************************************************** 59 | 60 | 61 | EOF 62 | 63 | TMP="../../../work" 64 | TMP_DIR=${TMP_DIR:-$TMP} 65 | if [ ! -d $TMP_DIR ]; then 66 | TMP_DIR=$TMP 67 | fi 68 | export TMP_DIR 69 | 70 | ERST=./erst-inject 71 | LOG=$TMP_DIR/erst.log.$$ 72 | MODSTATUS=0 73 | 74 | err() 75 | { 76 | echo 77 | echo -e ERROR: "$*" 78 | echo ERROR: "Please check dmesg or log for further information" 79 | echo -e "\n\nTEST FAILS" 80 | exit 1 81 | } 82 | 83 | pushd `dirname $0` > /dev/null 84 | 85 | #prepare the test env 86 | ls /dev/erst_dbg >/dev/null 2>&1 87 | if [ $? -ne 0 ]; then 88 | modinfo erst_dbg > /dev/null 2>&1 89 | [ $? -eq 0 ] || err "Please ensure module erst_dbg existing" 90 | modprobe erst_dbg 91 | [ $? -eq 0 ] || err "Fail to load module erst_dbg" 92 | MODSTATUS=1 93 | fi 94 | 95 | which $ERST &> /dev/null 96 | [ $? -eq 0 ] || err "Please compile the test case first" 97 | 98 | # If ERST table is full, the test can't proceed. To ensure below 99 | # test can go on, if existing records, remove one first. 100 | COUNT=`$ERST -n|cut -d' ' -f5` 101 | if [ $COUNT -ne 0 ]; then 102 | ID=`$ERST -p|grep "rcd id"|head -1|cut -d' ' -f3` 103 | $ERST -c $ID 1>/dev/null 104 | fi 105 | 106 | ID=0xdeadbeaf 107 | echo -n "Write one error record into ERST... " 108 | $ERST -i $ID 1>/dev/null 109 | if [ ! $? -eq 0 ]; then 110 | err "ERST writing operation fails.\n"\ 111 | "Please confirm if command parameter erst_disable is used or hardware not available" 112 | fi 113 | sleep 1 114 | echo "DONE" 115 | # read all error records in ERST 116 | $ERST -p > $LOG 117 | echo -n "Check if existing the error record written before... " 118 | grep -q $ID $LOG 119 | if [ ! $? -eq 0 ]; then 120 | err "Don't find the error record written before in ERST" 121 | fi 122 | sleep 1 123 | echo "DONE" 124 | 125 | echo -n "Clear the error record written before... " 126 | $ERST -c $ID 1>/dev/null 127 | if [ ! $? -eq 0 ]; then 128 | err "ERST writing opertion fails" 129 | fi 130 | sleep 1 131 | echo "DONE" 132 | 133 | #read all error records again 134 | $ERST -p > $LOG 135 | 136 | echo -n "Check if the error record has been cleared... " 137 | grep -q $ID $LOG 138 | if [ $? -eq 0 ]; then 139 | err "ERST clearing opertion fails" 140 | fi 141 | sleep 1 142 | echo "DONE" 143 | 144 | popd > /dev/null 145 | 146 | rm -f $LOG 147 | if [ $MODSTATUS -eq 1 ]; then 148 | rmmod -f erst_dbg 149 | fi 150 | 151 | echo -e "\nTEST PASSES" 152 | 153 | -------------------------------------------------------------------------------- /cases/function/erst-inject/uuid.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_GUID_H_ 2 | #define _LINUX_GUID_H_ 3 | 4 | #include 5 | #include 6 | 7 | typedef unsigned char u8; 8 | typedef unsigned short u16; 9 | typedef unsigned int u32; 10 | typedef unsigned long long u64; 11 | 12 | typedef unsigned char __u8; 13 | typedef unsigned short __u16; 14 | typedef unsigned int __u32; 15 | typedef unsigned long long __u64; 16 | 17 | typedef struct { 18 | u8 b[16]; 19 | } lguid_t; 20 | 21 | #define LGUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ 22 | ((lguid_t) \ 23 | {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ 24 | (b) & 0xff, ((b) >> 8) & 0xff, \ 25 | (c) & 0xff, ((c) >> 8) & 0xff, \ 26 | (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /cases/function/hwpoison/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS += -I. -g -Wall 2 | 3 | EXE := tinjpage tsimpleinj tkillpoison tprctl tsoft tsoftinj 4 | EXE += thugetlb ttranshuge thugetlb_overcommit 5 | 6 | OBJ := $(addsuffix .o,${EXE}) 7 | 8 | all: ${EXE} 9 | 10 | install: all 11 | cp ttranshuge ../../../bin/ 12 | 13 | tinjpage: LDFLAGS += -pthread 14 | 15 | clean: 16 | rm -f ${EXE} ${OBJ} 17 | rm -f unpoison-failed offlined 18 | rm -f ~test* ~poison* 19 | 20 | -------------------------------------------------------------------------------- /cases/function/hwpoison/README: -------------------------------------------------------------------------------- 1 | tinjpage 2 | 3 | tinjpage is a coverage test for the hwpoison page recovery code 4 | in the kernel. It tests different cases by putting pages 5 | into different stages, triggering poison injection on them 6 | and verifies the results. 7 | 8 | tinjpage requires a kernel with MADV_POISON injection support and the 9 | hwpoison testkit, but doesn't require a kernel tree and can be built directly with 10 | make tinjpage 11 | 12 | A few of the test cases are timing dependent and might require adjustment 13 | to run successfully. 14 | 15 | -Andi Kleen 16 | -------------------------------------------------------------------------------- /cases/function/hwpoison/helpers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export ROOT=`(cd ../../../; pwd)` 4 | . $ROOT/lib/functions.sh 5 | setup_path 6 | . $ROOT/lib/mce.sh 7 | 8 | TMP="../../../work" 9 | TMP_DIR=${TMP_DIR:-$TMP} 10 | if [ ! -d $TMP_DIR ]; then 11 | TMP_DIR=$TMP 12 | fi 13 | export TMP_DIR 14 | 15 | executed_testcase=0 16 | failed_testcase=0 17 | 18 | sysctl -q vm.memory_failure_early_kill=0 19 | 20 | run_test() { 21 | [ $# -ne 2 ] && echo "$FUNCNAME: Invalid argument" >&2 && exit 1 22 | local tp="$1" 23 | local expect="$2" 24 | local result= 25 | 26 | executed_testcase=$[executed_testcase+1] 27 | eval $tp 28 | [ $? -eq 0 ] && result=success || result=failure 29 | if [ "$result" = "$expect" ] ; then 30 | echo "PASS: $tp" 31 | else 32 | failed_testcase=$[failed_testcase+1] 33 | if [ "$result" = "failure" ] ; then 34 | echo "FAIL: $tp returned with failure." 35 | else 36 | echo "FAIL: $tp returned with unexpected success." 37 | fi 38 | fi 39 | } 40 | 41 | free_resources() { 42 | # free IPC semaphores used by thugetlb.c 43 | ipcs -s | grep $USER | cut -f2 -d' ' | xargs ipcrm sem > /dev/null 2>&1 44 | # remove remaining hugepages on shmem 45 | ipcs -m | sed -n '4,$p' | cut -f2 -d' ' | xargs ipcrm shm > /dev/null 2>&1 46 | 47 | echo "Unpoisoning." 48 | # unpoison hugepages first to avoid needless unpoisoning for tail pages. 49 | page-types -b hwpoison,huge,compound_head=hwpoison,huge,compound_head -x -N 50 | page-types -b hwpoison -x -Nl > tmp.hwpoisonlist 51 | if [ $(grep "^HardwareCorrupted:" /proc/meminfo | awk '{print $2}') -ne 0 ] ; then 52 | echo "WARNING: hwpoison page counter is broken." 53 | grep "^HardwareCorrupted:" /proc/meminfo 54 | fi 55 | } 56 | 57 | show_summary() { 58 | echo "" 59 | echo -n " Num of Executed Test Case: $executed_testcase" 60 | echo -e " Num of Failed Case: $failed_testcase" 61 | echo "" 62 | } 63 | 64 | mount_hugetlbfs() { 65 | HT=$TMP_DIR/hugepage 66 | mkdir -p $HT 67 | mount -t hugetlbfs none $HT 68 | sysctl -q vm.nr_hugepages=500 69 | } 70 | 71 | unmount_hugetlbfs() { 72 | sysctl -q vm.nr_hugepages=0 73 | for mountpoint in $(grep hugetlbfs /proc/mounts | cut -f2 -d' ') ; do 74 | rm -rf $mountpoint/* 75 | done 76 | umount $HT 77 | } 78 | 79 | load_hwpoison_inject() { 80 | local path 81 | 82 | check_debugfs 83 | path=`cat /proc/mounts | grep debugfs | cut -d ' ' -f2 | head -1`/hwpoison 84 | if [ ! -d $path ] ; then 85 | modprobe hwpoison-inject 86 | if [ $? -ne 0 ] ; then 87 | die "Failed to load hwpoison-inject module. Abort." 88 | else 89 | echo "hwpoison-inject module is loaded." 90 | fi 91 | fi 92 | } 93 | -------------------------------------------------------------------------------- /cases/function/hwpoison/hugepage.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | int HPS; 10 | char hugetlbfsdir[256]; 11 | #ifndef UTILS 12 | #include "utils.h" 13 | #endif 14 | #define errmsg(x) fprintf(stderr, x), exit(1) 15 | 16 | /* 17 | * Function : write_hugepage(char *addr, int nr_hugepage, char *avoid_addr) 18 | * Parameters : 19 | * addr head address of hugepage range 20 | * nr_hugepage hugepage number from head address 21 | * avoid_addr the address which avoid to be operated 22 | */ 23 | void write_hugepage(char *addr, int nr_hugepage, char *avoid_addr) 24 | { 25 | int i, j; 26 | for (i = 0; i < nr_hugepage; i++) { 27 | if ((addr + i * HPS) == avoid_addr) 28 | continue; 29 | for (j = 0; j < HPS; j++) { 30 | *(addr + i * HPS + j) = (char)('a' + ((i + j) % 26)); 31 | } 32 | } 33 | } 34 | 35 | /* 36 | * Function : read_hugepage(char *addr, int nr_hugepage, char *avoid_addr) 37 | * Parameters : 38 | * addr head address of hugepage range 39 | * nr_hugepage hugepage number from head address 40 | * avoid_addr the address which avoid to be operated 41 | * 42 | * return : 43 | * 0 OK 44 | * -1 if buffer content differs from the expected ones 45 | */ 46 | int read_hugepage(char *addr, int nr_hugepage, char *avoid_addr) 47 | { 48 | int i, j; 49 | int ret = 0; 50 | 51 | for (i = 0; i < nr_hugepage; i++) { 52 | if ((addr + i * HPS) == avoid_addr) 53 | continue; 54 | for (j = 0; j < HPS; j++) { 55 | if (*(addr + i * HPS + j) != (char)('a' + ((i + j) % 26))) { 56 | printf("Mismatch at %d\n", i + j); 57 | ret = -1; 58 | break; 59 | } 60 | } 61 | } 62 | return ret; 63 | } 64 | 65 | int hugetlbfs_root(char *dir) 66 | { 67 | int found = 0; 68 | FILE *f = fopen("/proc/mounts", "r"); 69 | if (!f) err("open /proc/mounts"); 70 | char *line = NULL; 71 | size_t linelen = 0; 72 | char dummy[100]; 73 | char type[100]; 74 | while (getline(&line, &linelen, f) > 0) { 75 | if (sscanf(line, "%s %s hugetlbfs %[^ ]", 76 | type, dir, dummy) >= 3) { 77 | found = 1; 78 | break; 79 | } 80 | } 81 | free(line); 82 | fclose(f); 83 | if (!found) 84 | printf("cannot find hugetlbfs directory in /proc/mounts\n"); 85 | return found; 86 | } 87 | 88 | int gethugepagesize(void) 89 | { 90 | FILE *fp; 91 | char *line = NULL; 92 | size_t linelen = 0; 93 | int hpagesize = 0; 94 | if ((fp = fopen("/proc/meminfo", "r")) == NULL) 95 | err("open /proc/meminfo"); 96 | while (getline(&line, &linelen, fp) > 0) { 97 | if (sscanf(line, "Hugepagesize: %d kB", &hpagesize) >= 1) 98 | break; 99 | } 100 | free(line); 101 | fclose(fp); 102 | return hpagesize * 1024; 103 | } 104 | 105 | void *alloc_shm_hugepage(int *key, int size) 106 | { 107 | void *addr; 108 | int shmid; 109 | if ((shmid = shmget(*key, size, 110 | SHM_HUGETLB | IPC_CREAT | SHM_R | SHM_W)) < 0) { 111 | perror("shmget"); 112 | return NULL; 113 | } 114 | addr = shmat(shmid, (void *)0x0UL, 0); 115 | if (addr == (char *)-1) { 116 | perror("Shared memory attach failure"); 117 | shmctl(shmid, IPC_RMID, NULL); 118 | return NULL; 119 | } 120 | *key = shmid; 121 | return addr; 122 | } 123 | 124 | void *alloc_anonymous_hugepage(int size, int private) 125 | { 126 | void *addr; 127 | int mapflag = MAP_ANONYMOUS | 0x40000; /* MAP_HUGETLB */ 128 | if (private) 129 | mapflag |= MAP_PRIVATE; 130 | else 131 | mapflag |= MAP_SHARED; 132 | if ((addr = mmap(0, size, 133 | PROT_READ|PROT_WRITE, mapflag, -1, 0)) == MAP_FAILED) { 134 | perror("mmap"); 135 | return NULL; 136 | } 137 | return addr; 138 | } 139 | 140 | void *alloc_filebacked_hugepage(char *filepath, int size, int private, int *fd) 141 | { 142 | int mapflag = MAP_SHARED; 143 | void *addr; 144 | if (private) 145 | mapflag = MAP_PRIVATE; 146 | if ((*fd = open(filepath, O_CREAT | O_RDWR, 0777)) < 0) { 147 | perror("open"); 148 | return NULL; 149 | } 150 | if ((addr = mmap(0, size, 151 | PROT_READ|PROT_WRITE, mapflag, *fd, 0)) == MAP_FAILED) { 152 | perror("mmap"); 153 | unlink(filepath); 154 | return NULL; 155 | } 156 | return addr; 157 | } 158 | 159 | int free_shm_hugepage(int key, void *addr) 160 | { 161 | if (shmdt((const void *)addr) != 0) { 162 | perror("Detach failure"); 163 | shmctl(key, IPC_RMID, NULL); 164 | return -1; 165 | } 166 | shmctl(key, IPC_RMID, NULL); 167 | return 0; 168 | } 169 | 170 | int free_anonymous_hugepage(void *addr, int size) 171 | { 172 | int ret = 0; 173 | if (munmap(addr, size)) { 174 | perror("munmap"); 175 | ret = -1; 176 | } 177 | return ret; 178 | } 179 | 180 | int free_filebacked_hugepage(void *addr, int size, int fd, char *filepath) 181 | { 182 | int ret = 0; 183 | if (munmap(addr, size)) { 184 | perror("munmap"); 185 | ret = -1; 186 | } 187 | if (close(fd)) { 188 | perror("close"); 189 | ret = -1; 190 | } 191 | if (filepath) { 192 | if (unlink(filepath)) { 193 | perror("unlink"); 194 | ret = -1; 195 | } 196 | } else { 197 | fprintf(stderr, "Filepath not specified.\n"); 198 | ret = -1; 199 | } 200 | return ret; 201 | } 202 | -------------------------------------------------------------------------------- /cases/function/hwpoison/random_offline: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # randomly soft offline pages 3 | # random_offline options 4 | # -t seconds runtime in seconds (default unlimited) 5 | # -m max-pages maximum pages to tie up before unpoisoning 6 | # -s seed random seed 7 | # Note: running this for too long may still run out of memory 8 | # because unpoison cannot completely undo what soft offline 9 | # does to larger free memory areas (TBD in the kernel) 10 | # Author: Andi Kleen 11 | 12 | # fixme: uses time seed, non reproducible 13 | 14 | #mount -t debugfs none /debug 15 | 16 | ROOT=`(cd ../../../; pwd)` 17 | . $ROOT/lib/mce.sh 18 | 19 | THRESH=1000 20 | SEED="" 21 | RUNTIME="" 22 | DEBUG="" 23 | 24 | fail() { 25 | echo "ERROR: $@" 26 | exit 0 27 | } 28 | 29 | usage() { 30 | echo "Usage:" 31 | echo "random_offline options" 32 | echo -- "-t seconds runtime in seconds (default unlimited)" 33 | echo -- "-m max-pages maximum pages to tie up before unpoisoning" 34 | echo -- "-s seed random seed" 35 | fail "Invalid option $1" 36 | } 37 | 38 | while getopts "t:m:s:" option ; do 39 | case "$option" in 40 | t) RUNTIME=$OPTARG ;; 41 | m) THRESH=$OPTARG ;; 42 | s) SEED=$OPTARG ;; 43 | *) usage $option ;; 44 | esac 45 | done 46 | 47 | [ "$(whoami)" != root ] && fail "Not root" 48 | check_debugfs 49 | DEBUG=`cat /proc/mounts | grep debugfs | cut -d ' ' -f2 | head -1` 50 | #if hwpoison_inject is a module, it is ensured to have been loaded 51 | modinfo hwpoison_inject > /dev/null 2>&1 52 | if [ $? -eq 0 ]; then 53 | [ -d $DEBUG/hwpoison/ ] || modprobe hwpoison_inject 54 | [ $? -eq 0 ] || fail "module hwpoison_inject isn't supported ?" 55 | fi 56 | [ ! -w /sys/devices/system/memory/soft_offline_page ] && fail "No soft offlining support in kernel" 57 | [ ! -w $DEBUG/hwpoison/unpoison-pfn ] && fail "no unpoison support in kernel" 58 | 59 | end_of_memory() { 60 | for i in /sys/firmware/memmap/* ; do 61 | case "$(< $i/type)" in 62 | "System RAM") ;; 63 | *) continue ;; 64 | esac 65 | 66 | k=$(< $i/end) 67 | k=${k/0x/} 68 | k=$(echo $k | tr a-z A-Z) 69 | 70 | echo "ibase=16; $k/1000" | bc 71 | done | sort -n | tail -n1 72 | } 73 | 74 | E=$(end_of_memory) 75 | 76 | echo "soft offlining pages upto $E" 77 | 78 | unpoison() { 79 | if [ ! -f offlined ] ; then 80 | return 81 | fi 82 | 83 | echo unpoisioning 84 | while read i ; do 85 | #echo -n , 86 | #echo "u $i" 87 | (( utotal++ )) 88 | if ! echo $i | sed 's/000$//' > $DEBUG/hwpoison/unpoison-pfn ; then 89 | echo "$i $?" >> unpoison-failed 90 | echo "unpoisioning $i failed: $?" 91 | else 92 | (( usuccess++ )) 93 | fi 94 | done < offlined 95 | echo done 96 | echo 97 | } 98 | 99 | trap unpoison 0 100 | 101 | if [ "$SEED" = "" ] ; then 102 | SEED=$(date +%s) 103 | fi 104 | RANDOM=$SEED 105 | echo "Using random seed $SEED" 106 | 107 | start=$(date +%s) 108 | failed=0 109 | ufailed=0 110 | success=0 111 | usuccess=0 112 | total=0 113 | utotal=0 114 | 115 | cbefore=$(grep HardwareCorrupted /proc/meminfo) 116 | 117 | 118 | (( k = 0 )) 119 | rm -f offlined unpoison-failed 120 | while true ; do 121 | T=$( 122 | R=$RANDOM 123 | X=$(echo "obase=16; ($R%$E)*4096" | bc) 124 | echo 0x$X 125 | ) 126 | #echo "p $T" 127 | (( total++ )) 128 | if echo 2>/dev/null $T >/sys/devices/system/memory/soft_offline_page ; then 129 | echo $T >> offlined 130 | (( success++ )) 131 | else 132 | #echo offlining $T failed $? 133 | (( failed++ )) 134 | true 135 | fi 136 | #echo -n . 137 | 138 | (( k++ )) 139 | if [ $k -gt $THRESH ] ; then 140 | unpoison 141 | (( k = 0 )) 142 | rm offlined 143 | fi 144 | 145 | if [ ! -z "$RUNTIME" ] ; then 146 | ((DIFF = $(date +%s) - $start)) 147 | if [ $DIFF -gt "$RUNTIME" ] ; then 148 | echo time over 149 | trap 0 150 | break 151 | fi 152 | fi 153 | done 154 | 155 | if [ -f unpoison-failed ] ; then 156 | ufailed=$(wc -l unpoison-failed | awk ' {print $1}') 157 | fi 158 | echo "soft-poison: success $success failed $failed of total $total" 159 | echo "unpoison-failed: success $usuccess failed $ufailed of total $utotal" 160 | echo "poisoned before: $cbefore" 161 | echo -n "poisoned after: " 162 | grep HardwareCorrupted /proc/meminfo 163 | 164 | ### xxx automatic success/failure criteria? 165 | 166 | -------------------------------------------------------------------------------- /cases/function/hwpoison/run_hard.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pushd `dirname $0` > /dev/null 4 | 5 | . ./helpers.sh 6 | 7 | load_hwpoison_inject 8 | 9 | # make sure we have no hwpoisoned hugepage before starting this test. 10 | free_resources > /dev/null 11 | 12 | cat <<-EOF 13 | 14 | *************************************************************************** 15 | Pay attention: 16 | 17 | This test is hard mode of HWPoison functional test. 18 | *************************************************************************** 19 | 20 | 21 | EOF 22 | 23 | echo "------------------------------------------------------------------------" 24 | echo "Running tsimpleinj (simple hard offline test)" 25 | run_test ./tkillpoison failure 26 | 27 | echo "------------------------------------------------------------------------" 28 | echo "Running tsimpleinj (simple hard offline test)" 29 | run_test ./tsimpleinj success 30 | 31 | echo "------------------------------------------------------------------------" 32 | echo "Running tinjpage (hard offline test on various types of pages)" 33 | mount_hugetlbfs 34 | run_test ./tinjpage success 35 | unmount_hugetlbfs 36 | 37 | echo "------------------------------------------------------------------------" 38 | echo "Running tprctl (hard offline test with various prctl settings)" 39 | val=`sysctl -n vm.memory_failure_early_kill` 40 | sysctl -w vm.memory_failure_early_kill=0 41 | run_test ./tprctl success 42 | sysctl -w vm.memory_failure_early_kill=$val 43 | 44 | free_resources 45 | 46 | show_summary 47 | 48 | popd > /dev/null 49 | 50 | exit $failed_testcase 51 | -------------------------------------------------------------------------------- /cases/function/hwpoison/run_hugepage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # run_hugepage.sh: 4 | # Test program for memory error handling for hugepages 5 | # Author: Naoya Horiguchi 6 | 7 | pushd `dirname $0` > /dev/null 8 | 9 | . ./helpers.sh 10 | 11 | mount_hugetlbfs 12 | 13 | load_hwpoison_inject 14 | 15 | # make sure we have no hwpoisoned hugepage before starting this test. 16 | free_resources > /dev/null 17 | 18 | exec_testcase() { 19 | echo "-------------------------------------" 20 | echo "TestCase $@" 21 | local hpage_size=2 22 | local hpage_target=1 23 | local hpage_target_offset= 24 | local process_type= 25 | local file_type= 26 | local share_type= 27 | executed_testcase=$[executed_testcase+1] 28 | 29 | case "$1" in 30 | head) hpage_target_offset=0 ;; 31 | tail) hpage_target_offset=1 ;; 32 | *) echo "Invalid argument" >&2 && exit 1 ;; 33 | esac 34 | hpage_target=$((hpage_target * 512 + hpage_target_offset)) 35 | 36 | case "$2" in 37 | early) process_type="-e" ;; 38 | late_touch) process_type="" ;; 39 | late_avoid) process_type="-a" ;; 40 | *) echo "Invalid argument" >&2 && exit 1 ;; 41 | esac 42 | 43 | case "$3" in 44 | anonymous) file_type="-A" ;; 45 | file) file_type="-f $executed_testcase" ;; 46 | shm) file_type="-S" ;; 47 | *) echo "Invalid argument" >&2 && exit 1 ;; 48 | esac 49 | 50 | case "$4" in 51 | fork_shared) share_type="-F" ;; 52 | fork_private_nocow) share_type="-Fp" ;; 53 | fork_private_cow) share_type="-Fpc" ;; 54 | *) echo "Invalid argument" >&2 && exit 1 ;; 55 | esac 56 | 57 | local command="./thugetlb -x -m $hpage_size -o $hpage_target $process_type $file_type $share_type $HT" 58 | echo $command 59 | eval $command 60 | if [ $? -ne 0 ] ; then 61 | echo "thugetlb was killed." 62 | if [ "$5" = killed ] ; then 63 | echo "PASS" 64 | else 65 | echo "FAIL" 66 | failed_testcase=$[failed_testcase+1] 67 | fi 68 | else 69 | echo "thugetlb exited normally." 70 | if [ "$5" = killed ] ; then 71 | echo "FAIL" 72 | failed_testcase=$[failed_testcase+1] 73 | else 74 | echo "PASS" 75 | fi 76 | fi 77 | 78 | return 0 79 | } 80 | 81 | cat <<-EOF 82 | 83 | *************************************************************************** 84 | Pay attention: 85 | 86 | This is the functional test for huge page support of HWPoison. 87 | *************************************************************************** 88 | 89 | 90 | EOF 91 | 92 | exec_testcase head early file fork_shared killed 93 | exec_testcase head early file fork_private_nocow killed 94 | exec_testcase head early file fork_private_cow killed 95 | exec_testcase head early shm fork_shared killed 96 | exec_testcase head early anonymous fork_shared killed 97 | exec_testcase head early anonymous fork_private_nocow killed 98 | exec_testcase head early anonymous fork_private_cow killed 99 | 100 | exec_testcase head late_touch file fork_shared killed 101 | exec_testcase head late_touch file fork_private_nocow killed 102 | exec_testcase head late_touch file fork_private_cow killed 103 | exec_testcase head late_touch shm fork_shared killed 104 | exec_testcase head late_touch anonymous fork_shared killed 105 | exec_testcase head late_touch anonymous fork_private_nocow killed 106 | exec_testcase head late_touch anonymous fork_private_cow killed 107 | 108 | exec_testcase head late_avoid file fork_shared notkilled 109 | exec_testcase head late_avoid file fork_private_nocow notkilled 110 | exec_testcase head late_avoid file fork_private_cow notkilled 111 | exec_testcase head late_avoid shm fork_shared notkilled 112 | exec_testcase head late_avoid anonymous fork_shared notkilled 113 | exec_testcase head late_avoid anonymous fork_private_nocow notkilled 114 | exec_testcase head late_avoid anonymous fork_private_cow notkilled 115 | 116 | exec_testcase tail early file fork_shared killed 117 | exec_testcase tail early file fork_private_nocow killed 118 | exec_testcase tail early file fork_private_cow killed 119 | exec_testcase tail early shm fork_shared killed 120 | exec_testcase tail early anonymous fork_shared killed 121 | exec_testcase tail early anonymous fork_private_nocow killed 122 | exec_testcase tail early anonymous fork_private_cow killed 123 | 124 | exec_testcase tail late_touch file fork_shared killed 125 | exec_testcase tail late_touch file fork_private_nocow killed 126 | exec_testcase tail late_touch file fork_private_cow killed 127 | exec_testcase tail late_touch shm fork_shared killed 128 | exec_testcase tail late_touch anonymous fork_shared killed 129 | exec_testcase tail late_touch anonymous fork_private_nocow killed 130 | exec_testcase tail late_touch anonymous fork_private_cow killed 131 | 132 | exec_testcase tail late_avoid file fork_shared notkilled 133 | exec_testcase tail late_avoid file fork_private_nocow notkilled 134 | exec_testcase tail late_avoid file fork_private_cow notkilled 135 | exec_testcase tail late_avoid shm fork_shared notkilled 136 | exec_testcase tail late_avoid anonymous fork_shared notkilled 137 | exec_testcase tail late_avoid anonymous fork_private_nocow notkilled 138 | exec_testcase tail late_avoid anonymous fork_private_cow notkilled 139 | 140 | unmount_hugetlbfs 141 | 142 | free_resources 143 | 144 | show_summary 145 | 146 | popd > /dev/null 147 | 148 | exit $failed_testcase 149 | -------------------------------------------------------------------------------- /cases/function/hwpoison/run_hugepage_overcommit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pushd `dirname $0` > /dev/null 4 | 5 | . ./helpers.sh 6 | 7 | load_hwpoison_inject 8 | 9 | # make sure we have no hwpoisoned hugepage before starting this test. 10 | free_resources > /dev/null 11 | 12 | exec_testcase() { 13 | echo "-------------------------------------" 14 | local command="./thugetlb_overcommit 1" 15 | echo "TestCase $command" 16 | sysctl -q vm.nr_overcommit_hugepages=10 17 | sysctl -q vm.nr_hugepages=1 18 | executed_testcase=$[executed_testcase+1] 19 | $command 20 | if [ $? -eq 0 ] ; then 21 | echo "$command returned with success." 22 | else 23 | "FAIL: migration failed." 24 | failed_testcase=$[failed_testcase+1] 25 | fi 26 | } 27 | 28 | cat <<-EOF 29 | 30 | *************************************************************************** 31 | Pay attention: 32 | 33 | This test checks that hugepage soft-offlining works under overcommitting. 34 | *************************************************************************** 35 | 36 | 37 | EOF 38 | 39 | exec_testcase 40 | 41 | free_resources 42 | 43 | show_summary 44 | 45 | popd > /dev/null 46 | 47 | exit $failed_testcase 48 | -------------------------------------------------------------------------------- /cases/function/hwpoison/run_soft.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pushd `dirname $0` > /dev/null 4 | 5 | . ./helpers.sh 6 | 7 | load_hwpoison_inject 8 | 9 | # make sure we have no hwpoisoned hugepage before starting this test. 10 | free_resources > /dev/null 11 | 12 | cat <<-EOF 13 | 14 | *************************************************************************** 15 | Pay attention: 16 | 17 | This test is soft mode of HWPoison functional test. 18 | *************************************************************************** 19 | 20 | 21 | EOF 22 | 23 | echo "------------------------------------------------------------------------" 24 | echo "Running tsoft (simple soft offline test)" 25 | run_test ./tsoft success 26 | 27 | echo "------------------------------------------------------------------------" 28 | echo "Running tsoftinj (soft offline test on various types of pages)" 29 | mount_hugetlbfs 30 | run_test ./tsoftinj success 31 | unmount_hugetlbfs 32 | 33 | echo "------------------------------------------------------------------------" 34 | echo "Running random_offline (random soft offline test for 60 seconds)" 35 | run_test "./random_offline -t 60" success 36 | 37 | free_resources 38 | 39 | show_summary 40 | 41 | popd > /dev/null 42 | 43 | exit $failed_testcase 44 | -------------------------------------------------------------------------------- /cases/function/hwpoison/run_thp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # run_thp.sh: 4 | # Script for hwpoison test of THP(Transparent Huge Page). 5 | # 6 | # 7 | 8 | pushd `dirname $0` > /dev/null 9 | 10 | . ./helpers.sh 11 | 12 | load_hwpoison_inject 13 | 14 | # make sure we have no hwpoisoned hugepage before starting this test. 15 | free_resources > /dev/null 16 | 17 | THP_POISON_PRO="ttranshuge" 18 | 19 | THP_SYS_PATH="/sys/kernel/mm/transparent_hugepage" 20 | THP_SYS_ENABLED_FILE="$THP_SYS_PATH/enabled" 21 | 22 | error() 23 | { 24 | echo "$1" && exit 1 25 | } 26 | 27 | env_check() 28 | { 29 | which $THP_POISON_PRO > /dev/null 2>&1 30 | [ $? -ne 0 ] && error "Please make sure there is file $THP_POISON_PRO." 31 | 32 | if [ ! -d $THP_SYS_PATH ] ; then 33 | error "THP(Transparent Huge Page) may be not supported by kernel." 34 | fi 35 | 36 | thp_enabled="$(cat $THP_SYS_ENABLED_FILE | awk '{print $3}')" 37 | if [ "$thp_enabled" == "[never]" ] ; then 38 | error "THP(Transparent Huge Page) is disabled now." 39 | fi 40 | } 41 | 42 | result_check() 43 | { 44 | if [ "$1" != "0" ] ; then 45 | failed_testcase=`expr $failed_testcase + 1` 46 | fi 47 | } 48 | 49 | exec_testcase() 50 | { 51 | if [ "$1" = "head" ] ; then 52 | page_position_in_thp=0 53 | elif [ "$1" = "tail" ] ; then 54 | page_position_in_thp=1 55 | else 56 | error "Which page do you want to poison?" 57 | fi 58 | 59 | if [ "$2" = "early" ] ; then 60 | process_type="--early-kill" 61 | elif [ "$2" = "late_touch" ] ; then 62 | process_type="" 63 | elif [ "$2" = "late_avoid" ] ; then 64 | process_type="--avoid-touch" 65 | else 66 | error "No such process type." 67 | fi 68 | 69 | executed_testcase=`expr $executed_testcase + 1` 70 | 71 | echo "------------------ Case $executed_testcase --------------------" 72 | 73 | command="$THP_POISON_PRO $process_type --offset $page_position_in_thp" 74 | echo $command 75 | eval $command 76 | result_check $? 77 | 78 | echo -e "\n" 79 | } 80 | 81 | # Environment Check for Test. 82 | env_check 83 | 84 | # Execute Test Cases from Here. 85 | cat <<-EOF 86 | 87 | *************************************************************************** 88 | Pay attention: 89 | 90 | This is the functional test for transparent huge page support of HWPoison. 91 | *************************************************************************** 92 | 93 | 94 | EOF 95 | 96 | echo "============= HWPoison Test of Transparent Huge Page =================" 97 | 98 | exec_testcase "head" "early" 99 | 100 | exec_testcase "head" "late_touch" 101 | 102 | exec_testcase "head" "late_avoid" 103 | 104 | exec_testcase "tail" "early" 105 | 106 | exec_testcase "tail" "late_touch" 107 | 108 | exec_testcase "tail" "late_avoid" 109 | 110 | echo "=======================================================================" 111 | 112 | free_resources 113 | 114 | show_summary 115 | 116 | popd > /dev/null 117 | 118 | exit $failed_testcase 119 | -------------------------------------------------------------------------------- /cases/function/hwpoison/thugetlb_overcommit.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 1 2 | #include 3 | #include 4 | #include 5 | #include "hugepage.h" 6 | 7 | #define HPAGE_SIZE (2UL*1024*1024) 8 | 9 | #define MADV_SOFT_OFFLINE 101 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | int PS = getpagesize(); 14 | int nr_hugepages; 15 | void *addr; 16 | int ret; 17 | 18 | nr_hugepages = strtol(argv[1], NULL, 10); 19 | addr = alloc_anonymous_hugepage(nr_hugepages * HPAGE_SIZE, 0); 20 | write_hugepage(addr, nr_hugepages, NULL); 21 | ret = madvise(addr, PS, MADV_SOFT_OFFLINE); 22 | free_anonymous_hugepage(addr, nr_hugepages * HPAGE_SIZE); 23 | return ret; 24 | } 25 | -------------------------------------------------------------------------------- /cases/function/hwpoison/tkillpoison.c: -------------------------------------------------------------------------------- 1 | // kills itself using poison 2 | #define _GNU_SOURCE 1 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define MADV_POISON 100 9 | 10 | int main(void) 11 | { 12 | int PS = getpagesize(); 13 | char *ptr = mmap(NULL, PS, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE, 0,0);; 14 | printf("ptr = %p\n", ptr); 15 | madvise(ptr, PS, MADV_POISON); 16 | printf("faulting\n"); 17 | *ptr = 1; 18 | printf("waiting\n"); 19 | sleep(100); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /cases/function/hwpoison/tprctl.c: -------------------------------------------------------------------------------- 1 | // test prctl per process setting 2 | #define _GNU_SOURCE 1 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define err(x) perror("FAILURE: " x), exit(1) 12 | #define fail(x) printf("FAILURE: " x "\n"), exit(1) 13 | #define mb() asm volatile("" ::: "memory") 14 | 15 | #define MADV_POISON 100 16 | 17 | /* 18 | * Set early/late kill mode for hwpoison memory corruption. 19 | * This influences when the process gets killed on a memory corruption. 20 | */ 21 | #define PR_MCE_KILL 33 22 | # define PR_MCE_KILL_CLEAR 0 23 | # define PR_MCE_KILL_SET 1 24 | 25 | # define PR_MCE_KILL_LATE 0 26 | # define PR_MCE_KILL_EARLY 1 27 | # define PR_MCE_KILL_DEFAULT 2 28 | 29 | #define PR_MCE_KILL_GET 34 30 | 31 | sigjmp_buf recover_ctx; 32 | volatile int seq; 33 | 34 | void handler(int sig) 35 | { 36 | siglongjmp(recover_ctx, 1); 37 | } 38 | 39 | void test(int early) 40 | { 41 | int PS = getpagesize(); 42 | char *ptr = mmap(NULL, PS, PROT_READ|PROT_WRITE, 43 | MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE, 0,0); 44 | if (ptr == (char *)-1L) 45 | err("mmap"); 46 | signal(SIGBUS, handler); 47 | printf("ptr = %p\n", ptr); 48 | if (sigsetjmp(recover_ctx, 1) == 0) { 49 | seq = 0; 50 | printf("injection\n"); 51 | if (madvise(ptr, PS, MADV_POISON) < 0) 52 | err("MADV_POISON"); 53 | /* early kill should kill here */ 54 | seq++; 55 | mb(); 56 | printf("faulting\n"); 57 | /* late kill should kill here */ 58 | *ptr = 1; 59 | printf("finished\n"); 60 | } else { 61 | printf("recovered\n"); 62 | if (seq == 1 && early) 63 | fail("early mode set, but no early kill"); 64 | if (seq == 0 && !early) 65 | fail("late mode set, but early kill"); 66 | } 67 | } 68 | 69 | int main(void) 70 | { 71 | int err; 72 | err = prctl(PR_MCE_KILL_GET, 0, 0, 0, 0, 0); 73 | if (err < 0) 74 | err("PR_MCE_KILL_GET"); 75 | if (err != PR_MCE_KILL_DEFAULT) 76 | fail("starting policy not default"); 77 | if (prctl(PR_MCE_KILL, PR_MCE_KILL_SET, PR_MCE_KILL_LATE, 0, 0, 0) < 0) 78 | err("PR_MCE_KILL_SET late"); 79 | test(0); 80 | if (prctl(PR_MCE_KILL, PR_MCE_KILL_SET, PR_MCE_KILL_EARLY, 0, 0, 0) < 0) 81 | err("PR_MCE_KILL_SET early"); 82 | test(1); 83 | err = prctl(PR_MCE_KILL_GET, 0, 0, 0,0,0); 84 | if (err < 0) 85 | err("PR_MCE_KILL_GET"); 86 | if (err != PR_MCE_KILL_EARLY) 87 | fail("get mode not early after setting"); 88 | if (prctl(PR_MCE_KILL, PR_MCE_KILL_CLEAR, 0, 0,0,0) < 0) 89 | err("PR_MCE_KILL_CLEAR"); 90 | err = prctl(PR_MCE_KILL_GET, 0, 0, 0, 0, 0); 91 | if (err < 0) 92 | err("PR_MCE_KILL_GET"); 93 | if (err != PR_MCE_KILL_DEFAULT) 94 | fail("ending policy not default"); 95 | return 0; 96 | } 97 | -------------------------------------------------------------------------------- /cases/function/hwpoison/tsimpleinj.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Test program for Linux memory error recovery. 3 | * Requires special injection support. 4 | * 5 | * This is a early primitive version of tinjpage.c, 6 | * but simpler to debug in some cases. 7 | */ 8 | #define _GNU_SOURCE 1 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #define MADV_POISON 100 20 | 21 | #define err(x) perror(x),exit(1) 22 | 23 | int count = 20; 24 | int failure = 0; 25 | int total_cases = 0; 26 | sigjmp_buf recover; 27 | int PS; 28 | 29 | void sighandler(int sig, siginfo_t *si, void *arg) 30 | { 31 | printf("signal %d code %d addr %p\n", sig, si->si_code, si->si_addr); 32 | 33 | if (--count == 0) 34 | exit(1); 35 | 36 | siglongjmp(recover, 1); 37 | } 38 | 39 | void testmem(char *msg, char *page, int write) 40 | { 41 | printf("%s page %p\n", msg, page); 42 | total_cases++; 43 | if (sigsetjmp(recover,1) == 0) { 44 | if (madvise(page, PS, MADV_POISON) != 0) { 45 | failure++; 46 | perror("madvise"); 47 | } 48 | if (write) 49 | *page = 2; 50 | else 51 | printf("%x\n", *(unsigned char *)page); 52 | } 53 | printf("recovered\n"); 54 | } 55 | 56 | void expecterr(char *msg, int res) 57 | { 58 | if (res == 0) 59 | printf("no error on %s\n", msg); 60 | else 61 | perror(msg); 62 | } 63 | 64 | int tempfd(void) 65 | { 66 | static int tmpcount; 67 | int fd; 68 | char buf[30]; 69 | snprintf(buf,30,"./test%d.XXXXXXXX",tmpcount++); 70 | fd = mkstemp(buf); 71 | if (fd >= 0) 72 | unlink(buf); 73 | return fd; 74 | } 75 | 76 | #define RANDOM_FILE "./Makefile" 77 | 78 | int main(void) 79 | { 80 | PS = getpagesize(); 81 | char *page; 82 | 83 | struct sigaction sa = { 84 | .sa_sigaction = sighandler, 85 | .sa_flags = SA_SIGINFO 86 | }; 87 | sigaction(SIGBUS, &sa, NULL); 88 | // sigaction(SIGSEGV, &sa, NULL); 89 | 90 | page = mmap(NULL, PS, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE, 0, 0); 91 | testmem("dirty", page, 1); 92 | 93 | page = mmap(NULL, PS, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_LOCKED, 0, 0); 94 | testmem("mlocked", page, 1); 95 | 96 | int fd = open(RANDOM_FILE, O_RDONLY); 97 | if (fd < 0) err("open " RANDOM_FILE); 98 | page = mmap(NULL, PS, PROT_READ, MAP_SHARED|MAP_POPULATE, fd, 0); 99 | if (page == (char *)-1) err("mmap"); 100 | close(fd); 101 | testmem("clean file", page, 0); 102 | 103 | fd = tempfd(); 104 | if (fd < 0) err("open testfile"); 105 | char *tmp = malloc(PS); 106 | if (!tmp) err("no enough memory"); 107 | memset(tmp, 0xff, PS); 108 | write(fd, tmp, PS); 109 | free(tmp); 110 | page = mmap(NULL, PS, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); 111 | if (page == (char*)-1) err("mmap"); 112 | *page = 1; 113 | testmem("file dirty", page, 0); 114 | expecterr("msync expect error", msync(page, PS, MS_SYNC)); 115 | expecterr("fsync expect error", fsync(fd)); 116 | close(fd); 117 | 118 | /* hole case still broken in the kernel -- doesn't report error */ 119 | fd = tempfd(); 120 | if (fd < 0) err("open testfile"); 121 | ftruncate(fd, PS); 122 | page = mmap(NULL, PS, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); 123 | if (page == (char*)-1) err("mmap"); 124 | *page = 1; 125 | testmem("hole file dirty", page, 0); 126 | expecterr("hole msync expect error", msync(page, PS, MS_SYNC)); 127 | expecterr("hole fsync expect error", fsync(fd)); 128 | close(fd); 129 | 130 | #if 0 131 | const int NPAGES = 10; 132 | int i; 133 | fd = tempfd(); 134 | if (fd < 0) err("open rfp testfile"); 135 | tmp = malloc(PS); 136 | if (!tmp) exit(ENOMEM); 137 | for (i = 0; i < NPAGES; i++) { 138 | memset(tmp, i, PS); 139 | write(fd, tmp, PS); 140 | } 141 | free(tmp); 142 | page = mmap(NULL, PS*NPAGES, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); 143 | if (page == (char*)-1) err("mmap"); 144 | int k = NPAGES - 1; 145 | for (i = 0; i < NPAGES; i++, k--) { 146 | if (remap_file_pages(page + i*PS, PS, 0, k, 0)) 147 | perror("remap_file_pages"); 148 | } 149 | *page = 1; 150 | testmem("rfp file dirty", page, 0); 151 | expecterr("rfp msync expect error", msync(page, PS, MS_SYNC)); 152 | expecterr("rfp fsync expect error", fsync(fd)); 153 | close(fd); 154 | #endif 155 | 156 | if (failure > 0) { 157 | printf("FAILURE -- %d of %d cases broken!\n", failure, total_cases); 158 | return 1; 159 | } 160 | printf("SUCCESS\n"); 161 | 162 | return 0; 163 | } 164 | 165 | 166 | -------------------------------------------------------------------------------- /cases/function/hwpoison/tsoft.c: -------------------------------------------------------------------------------- 1 | /* Simplest soft offline testcase */ 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define err(x) perror(x), exit(1) 8 | 9 | #define MADV_SOFT_OFFLINE 101 /* soft offline page for testing */ 10 | 11 | int PS; 12 | 13 | int main(void) 14 | { 15 | PS = getpagesize(); 16 | char *map = mmap(NULL, PS, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, 0, 0); 17 | 18 | if (map == (char *)-1L) 19 | err("mmap"); 20 | 21 | *map = 1; 22 | 23 | if (madvise(map, PS, MADV_SOFT_OFFLINE) < 0) 24 | perror("madvise SOFT_OFFLINE"); 25 | 26 | *map = 2; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /cases/function/hwpoison/tsoftinj.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Test soft page offline for process pages using madvise injector. 3 | * Requires special injection support in the kernel. 4 | * 5 | * Copyright 2009 Intel Corporation 6 | * 7 | * tsoftinj is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public 9 | * License as published by the Free Software Foundation; version 10 | * 2. 11 | * 12 | * tinjpage is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should find a copy of v2 of the GNU General Public License somewhere 18 | * on your Linux system; if not, write to the Free Software Foundation, 19 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | * 21 | * Author: Andi Kleen 22 | */ 23 | #define _GNU_SOURCE 1 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include "hugepage.h" 31 | 32 | #define MADV_SOFT_OFFLINE 101 33 | 34 | #define TMPDIR "./" 35 | 36 | int PS; 37 | int exitcode; 38 | char empty[4096]; 39 | int corrupted; 40 | 41 | void *checked_mmap(void *addr, size_t length, int prot, int flags, 42 | int fd, off_t offset) 43 | { 44 | void *p = mmap(addr, length, prot, flags, fd, offset); 45 | if (p == (void *)-1L) 46 | err("mmap"); 47 | return p; 48 | } 49 | 50 | unsigned meminfo(char *fmt) 51 | { 52 | int found = 0; 53 | FILE *f = fopen("/proc/meminfo", "r"); 54 | if (!f) err("open /proc/meminfo"); 55 | char *line = NULL; 56 | size_t linelen = 0; 57 | unsigned val = 0; 58 | while (getline(&line, &linelen, f) > 0) { 59 | if (sscanf(line, fmt, &val) == 1) { 60 | found = 1; 61 | break; 62 | } 63 | } 64 | free(line); 65 | fclose(f); 66 | if (!found) { 67 | printf("cannot read HardwareCorruptedPages in meminfo\n"); 68 | exitcode = 1; 69 | } 70 | return val; 71 | } 72 | 73 | unsigned hardware_corrupted(void) 74 | { 75 | return (meminfo("HardwareCorrupted: %u") * 1024) / PS; 76 | } 77 | 78 | char *ndesc(char *buf, char *a, char *b) 79 | { 80 | snprintf(buf, 100, "%s %s", a, b); 81 | return buf; 82 | } 83 | 84 | void offline(char *name, void *p) 85 | { 86 | char buf[100]; 87 | if (madvise(p, PS, MADV_SOFT_OFFLINE) < 0) 88 | err(ndesc(buf, name, "offline")); 89 | corrupted++; 90 | } 91 | 92 | void disk_backed(char *name, int flags) 93 | { 94 | char fn[100]; 95 | snprintf(fn, sizeof fn, TMPDIR "~test%u", getpid()); 96 | printf("private, diskbacked\n"); 97 | int fd = open(fn, O_RDWR|O_CREAT|O_TRUNC, 0644); 98 | if (fd < 0) err("open tmpfile"); 99 | write(fd, empty, sizeof empty); 100 | char *p = checked_mmap(NULL, PS, PROT_READ|PROT_WRITE, 101 | MAP_PRIVATE|flags, fd, 0); 102 | *(volatile int *)p = 1; 103 | offline(ndesc(fn, "disk backed", name), p); 104 | munmap(p, PS); 105 | } 106 | 107 | void anonymous(char *name, int flags) 108 | { 109 | char buf[100]; 110 | char *p = checked_mmap(NULL, PS, PROT_READ|PROT_WRITE, 111 | MAP_PRIVATE|MAP_ANONYMOUS|flags, 0, 0); 112 | printf("anonymous\n"); 113 | *(volatile int *)p = 1; 114 | offline(ndesc(buf, "anonymous", name), p); 115 | *(volatile int *)p = 1; 116 | munmap(p, PS); 117 | } 118 | 119 | void shm_hugepage(char *name, int flags) 120 | { 121 | int shmid = 0; 122 | char buf[100]; 123 | char *p = alloc_shm_hugepage(&shmid, HPS); 124 | if (!p) 125 | errmsg("failed in alloc_shm_hugepage\n"); 126 | printf("shm hugepage\n"); 127 | *(volatile int *)p = 1; 128 | offline(ndesc(buf, "shm hugepage", name), p); 129 | *(volatile int *)p = 1; 130 | free_shm_hugepage(shmid, p); 131 | } 132 | 133 | void anonymous_hugepage(char *name, int flags) 134 | { 135 | char buf[100]; 136 | char *p = alloc_anonymous_hugepage(HPS, 1); 137 | printf("anonymous hugepage\n"); 138 | *(volatile int *)p = 1; 139 | offline(ndesc(buf, "anonymous hugepage", name), p); 140 | *(volatile int *)p = 1; 141 | free_anonymous_hugepage(p, HPS); 142 | } 143 | 144 | void filebacked_hugepage(char *name, int flags) 145 | { 146 | int fd; 147 | char path[100]; 148 | char fn[100]; 149 | snprintf(path, sizeof path, "%s/~test-hugepage%u", 150 | hugetlbfsdir, getpid()); 151 | char *p = alloc_filebacked_hugepage(path, HPS, 0, &fd); 152 | printf("file backed hugepage\n"); 153 | *(volatile int *)p = 1; 154 | offline(ndesc(fn, "file backed hugepage", name), p); 155 | *(volatile int *)p = 1; 156 | free_filebacked_hugepage(p, HPS, fd, path); 157 | } 158 | 159 | void check(unsigned *count, char *name, unsigned expected) 160 | { 161 | unsigned count2 = hardware_corrupted(); 162 | unsigned diff = count2 - *count; 163 | if (diff != expected) { 164 | printf("%s: expected %d corrupted pages, got %u\n", name, 165 | expected, 166 | diff); 167 | if (diff < expected) 168 | exitcode = 1; 169 | } 170 | *count = count2; 171 | corrupted = 0; 172 | } 173 | 174 | int main(void) 175 | { 176 | PS = getpagesize(); 177 | HPS = gethugepagesize(); 178 | 179 | unsigned count = hardware_corrupted(); 180 | if (!hugetlbfs_root(hugetlbfsdir)) 181 | err("hugetlbfs_root"); 182 | anonymous("anonymous", 0); 183 | check(&count, "anonymous", 1); 184 | anonymous("anonymous mlock", MAP_LOCKED); 185 | check(&count, "anonymous mlock", 1); 186 | disk_backed("disk backed", 0); 187 | check(&count, "disk backed", 1); 188 | disk_backed("disk backed mlock", MAP_LOCKED); 189 | check(&count, "disk backed mlock", 1); 190 | shm_hugepage("shm hugepage", 0); 191 | check(&count, "shm hugepage", 1); 192 | anonymous_hugepage("anonymous hugepage", 0); 193 | check(&count, "anonymous hugepage", 1); 194 | filebacked_hugepage("file backed hugepage", 0); 195 | check(&count, "file backed hugepage", 1); 196 | // add more test cases here 197 | 198 | return exitcode; 199 | } 200 | -------------------------------------------------------------------------------- /cases/function/hwpoison/utils.h: -------------------------------------------------------------------------------- 1 | #define err(x) perror(x), exit(1) 2 | -------------------------------------------------------------------------------- /cases/function/kvm/guest/guest_run_victim.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Test script for SRAR error injection 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public 7 | # License as published by the Free Software Foundation; version 8 | # 2. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # General Public License for more details. 14 | # 15 | # You should find a copy of v2 of the GNU General Public License somewhere 16 | # on your Linux system; if not, write to the Free Software Foundation, 17 | # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | # 19 | # Copyright (C) 2015, Intel Corp. 20 | # Author: Wen Jin 21 | # 22 | 23 | killall victim 24 | cat /dev/null > /var/log/mcelog 25 | sleep 1 26 | 27 | cd GUEST_DIR/victim 28 | gcc -o victim victim.c 29 | cd .. 30 | 31 | ./victim/victim -k 0 -d > guest_phys & 32 | sleep 1 33 | 34 | if [ -s guest_phys ]; then 35 | ADDR=`cat guest_phys | awk '{print $NF}'` 36 | echo "guest physical address is $ADDR" > guest_tmp 37 | fi 38 | 39 | -------------------------------------------------------------------------------- /cases/function/kvm/host/SRAO: -------------------------------------------------------------------------------- 1 | CPU 0 BANK 2 2 | STATUS UNCORRECTED SRAO 0x17a 3 | MCGSTATUS MCIP RIPV 4 | MISC 0x8c 5 | -------------------------------------------------------------------------------- /cases/function/kvm/host/guest_init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Source function library. 4 | . /etc/init.d/functions 5 | 6 | 7 | RETVAL=0 8 | 9 | start() { 10 | 11 | touch /root/jobdone 12 | mount -t debugfs null /sys/kernel/debug 13 | echo 1 > /sys/kernel/debug/mce/fake_ser_p 14 | echo EARLYKILL > /proc/sys/vm/memory_failure_early_kill 15 | sh GUESTRUN & 16 | return "$RETVAL" 17 | } 18 | 19 | stop() { 20 | return "$RETVAL" 21 | } 22 | 23 | # See how we were called. 24 | case "$1" in 25 | start) 26 | start 27 | ;; 28 | stop) 29 | stop 30 | ;; 31 | *) 32 | echo $"Usage: $0 {start|stop}" 33 | exit 3 34 | esac 35 | 36 | exit "$RETVAL" 37 | 38 | -------------------------------------------------------------------------------- /cases/function/kvm/patches/fake_ser_p.patch: -------------------------------------------------------------------------------- 1 | From ae0d704daf02ef943bf9e12413ad489358879508 Mon Sep 17 00:00:00 2001 2 | From: Chen Gong 3 | Date: Tue, 15 Mar 2011 10:23:56 +0800 4 | Subject: [PATCH] fake_ser_p 5 | 6 | this patch is only needed on the machines not supporting SRAO 7 | 8 | Signed-off-by: Chen Gong 9 | --- 10 | arch/x86/kernel/cpu/mcheck/mce.c | 12 +++++++++++- 11 | 1 files changed, 11 insertions(+), 1 deletions(-) 12 | 13 | diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c 14 | index d916183..d23ea36 100644 15 | --- a/arch/x86/kernel/cpu/mcheck/mce.c 16 | +++ b/arch/x86/kernel/cpu/mcheck/mce.c 17 | @@ -2195,7 +2195,7 @@ DEFINE_SIMPLE_ATTRIBUTE(fake_panic_fops, fake_panic_get, 18 | 19 | static int __init mcheck_debugfs_init(void) 20 | { 21 | - struct dentry *dmce, *ffake_panic; 22 | + struct dentry *dmce, *ffake_panic, *ffake_ser_p; 23 | 24 | dmce = mce_get_debugfs_dir(); 25 | if (!dmce) 26 | @@ -2204,8 +2204,18 @@ static int __init mcheck_debugfs_init(void) 27 | &fake_panic_fops); 28 | if (!ffake_panic) 29 | return -ENOMEM; 30 | + ffake_ser_p = debugfs_create_u32("fake_ser_p", 0644, dmce, 31 | + (u32 *)&mce_ser); 32 | + if (!ffake_ser_p) 33 | + goto err_clean; 34 | 35 | return 0; 36 | +err_clean: 37 | + if (ffake_ser_p) 38 | + debugfs_remove(ffake_ser_p); 39 | + if (ffake_panic) 40 | + debugfs_remove(ffake_panic); 41 | + return -ENOMEM; 42 | } 43 | late_initcall(mcheck_debugfs_init); 44 | #endif 45 | -- 46 | 1.7.3.1.120.g38a18 47 | 48 | -------------------------------------------------------------------------------- /cases/function/pfa/Makefile: -------------------------------------------------------------------------------- 1 | # pread needs: 2 | # _XOPEN_SOURCE >= 500 || /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L 3 | # but this hides MAP_ANONYMOUS which comes back via _BSD_SOURCE 4 | CFLAGS := -g -Wall -D _BSD_SOURCE -D _XOPEN_SOURCE=500 5 | 6 | all: busy 7 | busy: busy.o 8 | 9 | install: all 10 | 11 | clean: 12 | rm -f *.o busy 13 | -------------------------------------------------------------------------------- /cases/function/pfa/busy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | while (1) 6 | usleep(1000); 7 | } 8 | -------------------------------------------------------------------------------- /cases/function/pfa/load.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | usage() 4 | { 5 | cat <<-EOF 6 | This script is used to add CPU load in the test procedure. 7 | Please kill tese loads in the background after the tests. 8 | 9 | usage: ${0##*/} [program to load] 10 | example: ${0##*/} ./load.sh ./busy 11 | 12 | EOF 13 | 14 | exit 0 15 | } 16 | 17 | 18 | [ X"$1" = X ] && usage 19 | 20 | cpu=`cat /proc/cpuinfo |grep -c processor` 21 | cpu=`expr $cpu - 1` 22 | for i in `seq 0 $cpu` 23 | do 24 | taskset -c $i $1 & 25 | done 26 | -------------------------------------------------------------------------------- /cases/function/pfa/run_pfa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export ROOT=`(cd ../../../; pwd)` 4 | 5 | . $ROOT/lib/functions.sh 6 | setup_path 7 | . $ROOT/lib/mce.sh 8 | 9 | INJ_TYPE=0x00000008 10 | APEI_IF="" 11 | PFA_BIN="" 12 | EDAC_TYPE="" 13 | 14 | invalid() 15 | { 16 | echo $* 17 | exit 1 18 | } 19 | 20 | apei_inj() 21 | { 22 | echo $INJ_TYPE > $APEI_IF/error_type 23 | echo $1 > $APEI_IF/param1 24 | echo 0xfffffffffffff000 > $APEI_IF/param2 25 | echo 1 > $APEI_IF/notrigger 26 | echo 1 > $APEI_IF/error_inject 27 | } 28 | 29 | usage() 30 | { 31 | cat <<-EOF 32 | usage: ${0##*/} [PFA program] [trigger interval time] 33 | example: ${0##*/} ./pfa 10 34 | 35 | EOF 36 | } 37 | 38 | main() 39 | { 40 | check_debugfs 41 | 42 | APEI_IF=`cat /proc/mounts | grep debugfs | cut -d ' ' -f2 | head -1`/apei/einj 43 | 44 | #if einj is not builtin, just insmod it 45 | if [ ! -d $APEI_IF ]; then 46 | #if einj is a module, it is ensured to have been loaded 47 | modprobe einj param_extension=1 > /dev/null 2>&1 48 | [ $? -eq 0 ] || invalid "module einj isn't supported?" 49 | fi 50 | [ -f $APEI_IF/param1 ] || 51 | invalid "no BIOS extension support for APEI on this platform" 52 | 53 | #check if the platform supports Correctable Memory Error injection 54 | cat $APEI_IF/available_error_type | grep -q $INJ_TYPE 55 | [ $? -ne 0 ] && 56 | invalid "Necessary Error Injection for PFA is not supported on this platform" 57 | 58 | # remove possible EDAC module, otherwise, the error information will be ate 59 | # by EDAC module and mcelog will not get it. 60 | # By now, only i7core_edac and sb_edac hook into the mcelog kernel buffer 61 | cat /proc/modules | grep -q i7core_edac 62 | if [ $? -eq 0 ]; then 63 | EDAC_TYPE="i7core_edac" 64 | else 65 | cat /proc/modules | grep -q sb_edac 66 | [ $? -eq 0 ] && EDAC_TYPE="sb_edac" 67 | elif 68 | cat /proc/modules | grep -q skx_edac 69 | [ $? -eq 0 ] && EDAC_TYPE="skx_edac" 70 | fi 71 | rmmod $EDAC_TYPE >/dev/null 2>&1 72 | 73 | #mcelog must be run in daemon mode. 74 | cat /dev/null > /var/log/mcelog 75 | kill -9 `pidof mcelog` >/dev/null 2>&1 76 | sleep 1 77 | mcelog --ignorenodev --daemon 78 | 79 | killall victim &> /dev/null 80 | victim -p | tee log & 81 | #wait to flush stdout into log 82 | sleep 1 83 | addr=`cat log | awk '{print $NF}' | tail -1` 84 | last_addr=$addr 85 | start=`date +%s` 86 | while : 87 | do 88 | echo inject address = $addr 89 | apei_inj $addr 90 | sleep 2 91 | addr=`cat log | awk '{print $NF}' | tail -1` 92 | end=`date +%s` 93 | timeout=`expr $end - $start` 94 | if [ X"$last_addr" != X"$addr" ] 95 | then 96 | break 97 | # assume it is enough to trigger PFA in 5 minutes 98 | elif [ $timeout -ge 300 ]; then 99 | invalid "Timeout! PFA is not triggered" 100 | fi 101 | done 102 | } 103 | 104 | cleanup() 105 | { 106 | rm -f log 107 | killall victim &> /dev/null 108 | modprobe $EDAC_TYPE >/dev/null 2>&1 109 | } 110 | 111 | trap "cleanup" 0 112 | main 113 | -------------------------------------------------------------------------------- /cases/function/pfa/runtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat <<-EOF 4 | 5 | *************************************************************************** 6 | Pay attention: 7 | 8 | This test is for memory PFA support test. PFA test will conflict with EDAC. 9 | Before the test EDAC related drivers must be removed from the kernel (Not 10 | built-in or rmmod). Moreover, PFA support need correct BIOS setting and 11 | mcelog setting. If you are not familiar with it, please skip this test. 12 | 13 | NOTE: CPU sleep may decrease the test efficiency. To avoid this situation, 14 | one can run *load.sh" by hand before the formal test! 15 | *************************************************************************** 16 | 17 | 18 | EOF 19 | 20 | TMP="../../../work" 21 | TMP_DIR=${TMP_DIR:-$TMP} 22 | if [ ! -d $TMP_DIR ]; then 23 | TMP_DIR=$TMP 24 | fi 25 | export TMP_DIR 26 | 27 | echo 0 > $TMP_DIR/error.$$ 28 | 29 | pushd `dirname $0` > /dev/null 30 | ./run_pfa.sh 31 | [ $? -eq 0 ] || echo 1 > $TMP_DIR/error.$$ 32 | popd > /dev/null 33 | 34 | grep -q "1" $TMP_DIR/error.$$ 35 | if [ $? -eq 0 ] 36 | then 37 | echo "PFA test FAILS" 38 | exit 1 39 | else 40 | echo "PFA test PASSES" 41 | exit 0 42 | fi 43 | 44 | -------------------------------------------------------------------------------- /cases/stress/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | $(MAKE) -C hwpoison 3 | 4 | install: 5 | $(MAKE) -C hwpoison 6 | 7 | clean: 8 | $(MAKE) -C hwpoison clean 9 | 10 | -------------------------------------------------------------------------------- /cases/stress/hwpoison/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS := -g -Wall 2 | LDFLAGS := -g 3 | 4 | export CFLAGS 5 | export LDFLAGS 6 | 7 | all: 8 | mkdir -p bin 9 | $(MAKE) -C tools install 10 | 11 | clean: 12 | $(MAKE) -C tools clean 13 | rm -rf bin log result runtest hwpoison 14 | -------------------------------------------------------------------------------- /cases/stress/hwpoison/README: -------------------------------------------------------------------------------- 1 | MCE Stress Test Suite 2 | ===================== 3 | 4 | Oct 10th, 2009 5 | 6 | Haicheng Li 7 | 8 | 9 | About the MCE stress test suite 10 | ------------------------------- 11 | 12 | The MCE stress test suite is a collection of tools and test scripts, which 13 | intends to achieve stress testing for Linux kernel MCA high level handlers 14 | that include HWPosion page recovery, soft page offline, and so on. 15 | 16 | In general, this test suite is designed to do stress testing thru various 17 | test interfaces, i.e. madvise syscall, HWPoison page injector, and APEI 18 | injector (see ACPI4.0 spec). And it's able to support most of popular 19 | Linux File Systems (FS), that is, there is an option (i.e. -f) for user to 20 | specify which FS type they want the test to be running on. 21 | 22 | 23 | Test Dependencies 24 | ----------------- 25 | MCE stress test suite has following dependencies on kernel and other tools: 26 | 27 | * Linux Kernel: 28 | Version 2.6.32 or newer, with MCA high level handlers enabled. 29 | 30 | * ltp-pan: 31 | A test harness of Linux Test Project, http://ltp.sf.net. 32 | 33 | * page-types: 34 | A tool to query page types, which is accompanied with Linux kernel 35 | source (2.6.32 or newer, $KERNEL_SRC/Documentation/vm/page-types.c). 36 | 37 | Pls. refer to the HOWTO doc (../doc/stress-howto.txt) to setup your test 38 | enviroment. 39 | 40 | 41 | In the package 42 | --------------- 43 | Here is a short description of what is included in this test suite. 44 | 45 | README 46 | This document. 47 | 48 | ../doc/stress-howto.txt 49 | HOWTO doc, including design details and usage guide. 50 | 51 | Makefile 52 | Makefile for MCE stress test suite. 53 | 54 | hwposion.sh 55 | Test driver. 56 | 57 | tools/* 58 | Test workloads. 59 | 60 | 61 | Get Started 62 | ----------- 63 | Pls. read through the HOWTO doc (../doc/stress-howto.txt) before you start 64 | the stress testing on your system. 65 | 66 | You can also get help on specific test options in following way: 67 | # ./hwpoison.sh -h 68 | 69 | 70 | Warning! 71 | -------- 72 | Be careful with these tests! 73 | 74 | Don't run them on production systems. They should not cause problems on 75 | properly functioning systems, they are intended to find (or cause) problems. 76 | -------------------------------------------------------------------------------- /cases/stress/hwpoison/run_hard.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public 5 | # License as published by the Free Software Foundation; version 6 | # 2. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should find a copy of v2 of the GNU General Public License somewhere 14 | # on your Linux system; if not, write to the Free Software Foundation, 15 | # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | # 17 | # Copyright (C) 2012, Intel Corp. 18 | # 19 | 20 | cat <<-EOF 21 | 22 | *************************************************************************** 23 | Pay attention: 24 | 25 | This test is for HWPoison stress test. In this test case, it will 26 | try to inject errors via madvice instead of soft-offline. Usually 27 | this test needs to touch many pages and some operations will fail 28 | on some pages. Commonly it is OK when a few failures happen. 29 | The test is always considered as PASS, even if failure happens in test 30 | procedure. When meeting this situation, please contact experts to confirm 31 | whether or not it is a real error. 32 | *************************************************************************** 33 | 34 | 35 | EOF 36 | 37 | TMP="../../../work" 38 | TMP_DIR=${TMP_DIR:-$TMP} 39 | if [ ! -d $TMP_DIR ]; then 40 | TMP_DIR=$TMP 41 | fi 42 | export TMP_DIR 43 | 44 | echo 0 > $TMP_DIR/error.$$ 45 | 46 | pushd `dirname $0` > /dev/null 47 | echo "run hard stress tester for 60 seconds" 48 | ./hwpoison.sh -T -C 20 -t 60 -M 49 | [ $? -eq 0 ] || echo 1 > $TMP_DIR/error.$$ 50 | popd > /dev/null 51 | 52 | grep -q "1" $TMP_DIR/error.$$ 53 | if [ $? -eq 0 ] 54 | then 55 | exit 1 56 | else 57 | exit 0 58 | fi 59 | 60 | -------------------------------------------------------------------------------- /cases/stress/hwpoison/run_soft.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public 5 | # License as published by the Free Software Foundation; version 6 | # 2. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should find a copy of v2 of the GNU General Public License somewhere 14 | # on your Linux system; if not, write to the Free Software Foundation, 15 | # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | # 17 | # Copyright (C) 2012, Intel Corp. 18 | # 19 | 20 | cat <<-EOF 21 | 22 | *************************************************************************** 23 | Pay attention: 24 | 25 | This test is for HWPoison stress test. In this test case, it will 26 | try to inject errors via soft-offline instead of madvice. Usually 27 | this test needs to touch many pages and no failure happens on these pages. 28 | The test is always considered as PASS, even if failure happens in test 29 | procedure. When meeting this situation, please contact experts to confirm 30 | whether or not it is a real error. 31 | *************************************************************************** 32 | 33 | 34 | EOF 35 | 36 | TMP="../../../work" 37 | TMP_DIR=${TMP_DIR:-$TMP} 38 | if [ ! -d $TMP_DIR ]; then 39 | TMP_DIR=$TMP 40 | fi 41 | export TMP_DIR 42 | 43 | echo 0 > $TMP_DIR/error.$$ 44 | 45 | pushd `dirname $0` > /dev/null 46 | echo "run soft stress tester for 60 seconds" 47 | ./hwpoison.sh -T -C 1 -t 60 -S 48 | [ $? -eq 0 ] || echo 1 > $TMP_DIR/error.$$ 49 | popd > /dev/null 50 | 51 | grep -q "1" $TMP_DIR/error.$$ 52 | if [ $? -eq 0 ] 53 | then 54 | exit 1 55 | else 56 | exit 0 57 | fi 58 | 59 | -------------------------------------------------------------------------------- /cases/stress/hwpoison/tools/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS ?= fs-metadata page-poisoning 2 | 3 | all: 4 | @for i in ${SUBDIRS}; do \ 5 | ${MAKE} -C $$i $@; \ 6 | done 7 | 8 | install: 9 | @for i in ${SUBDIRS}; do \ 10 | ${MAKE} -C $$i $@; \ 11 | done 12 | 13 | clean: 14 | @for i in ${SUBDIRS}; do \ 15 | ${MAKE} -C $$i $@; \ 16 | done 17 | -------------------------------------------------------------------------------- /cases/stress/hwpoison/tools/fs-metadata/Makefile: -------------------------------------------------------------------------------- 1 | all: k-tree-gen k-tree-trav 2 | 3 | k-tree-trav: k-tree-trav.o 4 | 5 | k-tree-gen: k-tree-gen.o 6 | 7 | install: all 8 | cp fs-metadata.sh k-thread.sh k-tree-gen k-tree-trav ../../bin 9 | 10 | clean: 11 | rm -f k-tree-gen k-tree-trav *.o 12 | -------------------------------------------------------------------------------- /cases/stress/hwpoison/tools/fs-metadata/README: -------------------------------------------------------------------------------- 1 | File system metadata test program is used to test i-node operations 2 | with heavy workload. Make sure every i-node operation gets the 3 | expected result. This script creates a lot of directory entries with 4 | k-tree data structure. 5 | 6 | k-tree is a transformation of binary tree, For a binary tree, each father 7 | node has 2 children at most; but for a k-tree, it can has k children. We 8 | need to test both file and directory, so we do some changes for k-tree 9 | concept here. viz. each father node has k sub directories and k text files. 10 | 11 | Note, test will caculate approximate disk space firstly based on the test 12 | parameters from user. parameter tree_depth should be less than 10; 13 | parameter node_number should be less than 20. If user passes a larger 14 | number, it will generate a huge directory hierarchy, which might exhaust 15 | your disk space soon. 16 | 17 | As a suggestion, it's better to run the script on a free partition, so 18 | you can recover it easily by formatting disk after test gets finished! 19 | 20 | Here are the component list of fs-metadata test program. 21 | k-tree-gen k-tree generator 22 | k-tree-trav to modify a k-tree with i-nodes operations 23 | k-thread.sh test thread 24 | fs-metadata.sh the script to lauch test threads. 25 | 26 | -------------------------------------------------------------------------------- /cases/stress/hwpoison/tools/fs-metadata/k-thread.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Test thread for File system metadata stress testing script 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public 7 | # License as published by the Free Software Foundation; version 8 | # 2. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # General Public License for more details. 14 | # 15 | # You should find a copy of v2 of the GNU General Public License somewhere 16 | # on your Linux system; if not, write to the Free Software Foundation, 17 | # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | # 19 | # Copyright (C) 2009, Intel Corp. 20 | # Author: Shaohui Zheng 21 | 22 | # run program and do not display the output 23 | function run_quiet() 24 | { 25 | local cmd=$* 26 | $cmd >/dev/null 2>&1 27 | return $? 28 | } 29 | 30 | function k_log() 31 | { 32 | echo [$(date "+%m-%d %H:%M:%S")] $* | tee -a $K_LOG 33 | } 34 | 35 | function k_result() 36 | { 37 | echo [$(date "+%m-%d %H:%M:%S")] $* | tee -a $K_LOG 38 | echo $* | egrep "pass|fail" 39 | ret_val=$? 40 | if [ -f $K_FLAG ] ;then 41 | echo [$(date "+%m-%d %H:%M:%S")] $* >> $K_RESULT 42 | fi 43 | 44 | if [ ! -f $K_FLAG ] && [ $ret_val -ne 0 ] ;then 45 | echo [$(date "+%m-%d %H:%M:%S")] $* >> $K_RESULT 46 | fi 47 | } 48 | 49 | # Compare 2 trees, if it is the same, return 0, or return 1 50 | # 51 | # we need to make sure whether the tree has changes after we 52 | # finish a lot of meta operations on he heavy workloads, this 53 | # function can compare the hierarchy between 2 trees. 54 | # 55 | # the basic idea is diff the output by command find. 56 | 57 | function k_tree_diff() 58 | { 59 | local ta=$1 # tree a 60 | local tb=$2 # tree b 61 | 62 | local md5a=$(run_quiet cd $ta; find | md5sum | awk '{ print $1}') 63 | local md5b=$(run_quiet cd $tb; find | md5sum | awk '{ print $1}') 64 | 65 | if [ $md5a = $md5b ];then 66 | return 0 67 | else 68 | return 1 69 | fi 70 | } 71 | 72 | 73 | dir=$1 74 | depth=$2 75 | width=$3 76 | result= 77 | 78 | k_log "thread $1 starts with pid $$" 79 | echo $$ | tee -a $K_THREADS_PID 80 | # generate new tree 81 | k_log "begin to generate tree $dir" 82 | $K_TREE_GEN $depth $width 83 | k_log "end to generate tree $dir" 84 | 85 | cwd=$(pwd) 86 | run_quiet cd $K_VAR 87 | while [ -e $K_FLAG ] 88 | do 89 | new_dir=$dir-new 90 | cp $dir $new_dir -pr 91 | run_quiet cd $new_dir 92 | k_log "thread $dir: begin to traverse dir $new_dir" 93 | $K_TREE_TRAV $2 $3 94 | k_log "thread $dir: end to traverse dir $new_dir" 95 | run_quiet cd - 96 | result=pass 97 | k_tree_diff $dir $new_dir || result=fail 98 | k_result "thread $dir: $result to compare result between dir $dir and $new_dir" 99 | 100 | rm $new_dir -fr 101 | done 102 | run_quiet cd $cwd 103 | 104 | # test ends, remove the oringal tree 105 | rm $dir -fr 106 | -------------------------------------------------------------------------------- /cases/stress/hwpoison/tools/fs-metadata/k-tree-gen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Metadata stress testing program for file system 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; version 7 | * 2. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should find a copy of v2 of the GNU General Public License somewhere 15 | * on your Linux system; if not, write to the Free Software Foundation, 16 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * This program helps you to generate a k-tree in recusive. 19 | * 20 | * A k-tree is a tranformation of binary tree, A binary has 2 21 | * children at most in each node, but a k-tree has k sub-nodes. 22 | * We test both file and directory entries, So we do some changes. 23 | * We create k sub directories and k text file in each parent. 24 | * 25 | * Copyright (C) 2009, Intel Corp. 26 | * Author: Shaohui Zheng 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #define MAX_PATH 8192 38 | 39 | /* 40 | * k tree generator. 41 | * 42 | * parameters: 43 | * lvl: tree level number from button to top 44 | * node_nr: the maximun nodes number 45 | * return val: if it is leaf, return 0, or return 1 46 | */ 47 | 48 | int k_tree_gen(int lvl, int node_nr) 49 | { 50 | int cnt; 51 | char dir[MAX_PATH], cwd[MAX_PATH], leaf[MAX_PATH]; 52 | if (lvl <= 0) 53 | return 0; 54 | 55 | for (cnt = 0; cnt < node_nr; cnt++) { 56 | int fd = 0, fd2; 57 | // generate dir name or file name 58 | sprintf(dir, "%d-d", cnt); 59 | sprintf(leaf, "%d-f", cnt); 60 | 61 | // create an empty file 62 | // API: open,close,dup,read,write,lseek 63 | fd = open(leaf, O_CREAT | O_RDWR); 64 | fd2 = dup(fd); 65 | close(fd); 66 | fd = fd2; 67 | write(fd, leaf, 3); 68 | lseek(fd, SEEK_SET, 0); 69 | read(fd, leaf, 3); 70 | close(fd); 71 | 72 | // create directory entry 73 | mkdir(dir, 0777); 74 | getcwd(cwd, sizeof(cwd)); 75 | chdir(dir); 76 | k_tree_gen(lvl - 1, node_nr); 77 | chdir(cwd); 78 | } 79 | 80 | return 1; 81 | } 82 | 83 | int main(int argc, char **argv) 84 | { 85 | if (argc < 2) { 86 | printf("Usage: k-tree tree_depth tree_width\n"); 87 | return 1; 88 | } 89 | 90 | printf("Generate k tree (depth: %s, width: %s) ...\n", argv[1], 91 | argv[2]); 92 | k_tree_gen(atoi(argv[1]), atoi(argv[2])); 93 | printf("Generate k tree (depth: %s, width: %s), done\n", argv[1], 94 | argv[2]); 95 | return 0; 96 | } 97 | -------------------------------------------------------------------------------- /cases/stress/hwpoison/tools/fs-metadata/k-tree-trav.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Metadata stress testing program for file system 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; version 7 | * 2. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should find a copy of v2 of the GNU General Public License somewhere 15 | * on your Linux system; if not, write to the Free Software Foundation, 16 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | * 18 | * This program helps you to traverse each node in the k tree 19 | * Do the i-node operations on the all file entries in recursive 20 | * 21 | * Copyright (C) 2009, Intel Corp. 22 | * Author: Shaohui Zheng 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #define MAX_PATH 8192 33 | 34 | /* 35 | * Traverse a k-tree in recusive 36 | * 37 | * parameters: 38 | * lvl: tree level number from button to top 39 | * node_nr: the maximun nodes number 40 | * return val: if it is leaf, return 0, or return 1 41 | */ 42 | 43 | int k_tree_trav(int lvl, int node_nr) 44 | { 45 | int cnt; 46 | char dir[MAX_PATH], cwd[MAX_PATH], f1[MAX_PATH], f2[MAX_PATH], 47 | ln[MAX_PATH]; 48 | if (lvl <= 0) 49 | return 0; 50 | 51 | for (cnt = 0; cnt < node_nr; cnt++) { 52 | sprintf(dir, "%d-d", cnt); 53 | sprintf(f1, "%d-f", cnt); 54 | sprintf(f2, "%d-f-t", cnt); 55 | sprintf(ln, "%d-l", cnt); 56 | 57 | // link and unlink testing for each file i-node 58 | link(f1, f2); 59 | unlink(f1); 60 | rename(f2, f1); 61 | 62 | // symlink testing 63 | symlink(ln, f1); 64 | unlink(ln); 65 | 66 | getcwd(cwd, sizeof(cwd)); 67 | chmod(dir, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); 68 | chdir(dir); 69 | k_tree_trav(lvl - 1, node_nr); 70 | chdir(cwd); 71 | } 72 | 73 | return 1; 74 | } 75 | 76 | int main(int argc, char **argv) 77 | { 78 | if (argc < 2) { 79 | printf("Usage: %s tree_depth tree_width\n", argv[0]); 80 | return 1; 81 | } 82 | 83 | printf("Traverse k tree (depth: %s, width: %s)...\n", argv[1], argv[2]); 84 | k_tree_trav(atoi(argv[1]), atoi(argv[2])); 85 | printf("Traverse k tree (depth: %s, width: %s), done\n", argv[1], 86 | argv[2]); 87 | return 0; 88 | } 89 | -------------------------------------------------------------------------------- /cases/stress/hwpoison/tools/page-poisoning/Makefile: -------------------------------------------------------------------------------- 1 | all: page-poisoning 2 | 3 | page-poisoning: page-poisoning.o 4 | 5 | ../../bin/page-poisoning: page-poisoning 6 | cp page-poisoning ../../bin 7 | 8 | install: ../../bin/page-poisoning 9 | 10 | clean: 11 | rm -f page-poisoning *.o 12 | -------------------------------------------------------------------------------- /cases/stress/hwpoison/tools/page-poisoning/README: -------------------------------------------------------------------------------- 1 | Multi-process based page-poisoning test program. 2 | 3 | page-poisoning test program is an extension of tinjpage test program with a 4 | multi-process model. It spawns thousands of processes that inject HWPosion 5 | error to various pages simultaneously thru madvise syscall. Then it checks 6 | if these errors get handled correctly, i.e. whether each test process 7 | receives or doesn't receive SIGBUS signal as expected. 8 | 9 | In details, page-poisoning is designed to cover all of possible userspace page 10 | types via following two test operations: 11 | - anonymous pages operations. 12 | - file data operations. 13 | 14 | You can get detailed help info in following way: 15 | # ./page-poisoning -h 16 | -------------------------------------------------------------------------------- /doc/casefile-howto.txt: -------------------------------------------------------------------------------- 1 | casefile is used to save what test cases will be used finally. Here is an 2 | example to create it by hand. 3 | 4 | 1. Copy one or more files from directory groups, say function, to somewhere. 5 | 2. Open this file and remove all "on|off" at the end of line from every line. 6 | 3. Delete unnecessary test cases. Here one line corresponds to one test case. 7 | 4. Save this file and rename it to any name you prefer. 8 | 5. When you execute runmcetest, use parameter "-l" along with this file. 9 | -------------------------------------------------------------------------------- /doc/cases/soft-inj_non-panic.txt: -------------------------------------------------------------------------------- 1 | Overall:(4 cases) 2 | 3 | - Test method 4 | * Preparation 5 | + Disable mcelog cron job 6 | * Add cases/soft-inj/non-panic/cases.sh into configuration file, and invoke 7 | a test driver on it. 8 | - Common 9 | * Test script of test cases in this file can be found in 10 | cases/soft-inj/non-panic/cases.sh 11 | 12 | 13 | 1. corrected 14 | 15 | - Objective: 16 | * Test machine_check_poll() and mce_log() 17 | - Code path tested: 18 | * machine_check_poll() 19 | * mce_get_rip(), branch without EIPV, RIPV, rip_msr 20 | * mce_log() 21 | - Reference: 22 | * Inject data file: cases/soft-inj/non-panic/data/corrected 23 | - Expected results: 24 | * MCE records gotten via /dev/mcelog is same as injected ones 25 | * No warning or bug during kernel processing 26 | 27 | 28 | 2. corrected hold 29 | 30 | - Objective: 31 | * Whether is there race condition in machine_check_poll() and mce_log(), 32 | multiple machine_check_poll() or mce_log() may be run simultaneously 33 | on difference CPU. 34 | - Code path tested: 35 | * same as corrected 36 | - Reference: 37 | * Inject data file: cases/soft-inj/non-panic/data/corrected_hold 38 | - Expected results: 39 | * MCE records gotten via /dev/mcelog is same as injected ones 40 | * No warning or bug during kernel processing 41 | 42 | 43 | 3. corrected over 44 | 45 | - Objective: 46 | * Test OVER processing 47 | - Code path tested: 48 | * same as 1 49 | - Reference: 50 | * Inject data file: cases/soft-inj/non-panic/data/corrected_over 51 | - Expected results: 52 | * MCE records gotten via /dev/mcelog is same as injected ones 53 | * No warning or bug during kernel processing 54 | 55 | 56 | 4. corrected without EN 57 | 58 | - Objective: 59 | * Test no EN processing 60 | - Code path tested: 61 | * same as 1 62 | - Reference: 63 | * Inject data file: cases/soft-inj/non-panic/data/corrected_no_en 64 | - Expected results: 65 | * MCE records gotten via /dev/mcelog is same as injected ones 66 | * No warning or bug during kernel processing 67 | -------------------------------------------------------------------------------- /doc/cases/soft-inj_panic.txt: -------------------------------------------------------------------------------- 1 | Overall: (9 cases) 2 | 3 | - Test method 4 | * Add cases/soft-inj/panic/cases.sh into configuration file, and invoke 5 | a test driver on it. 6 | - Common 7 | * Test script of test cases in this file can be found in 8 | cases/soft-inj/panic/cases.sh 9 | 10 | 1. fatal 11 | 12 | - Objective: 13 | * Test MSR read logic of MCE handler 14 | * Test synchronization between monarch and subject 15 | * Test logic to recognize a fatal (PCC) MCE 16 | - Code path tested: 17 | * do_machine_check() 18 | * mce_start() 19 | * mce_end() 20 | * mce_reign() until mce_panic("Fatal Machine check",) 21 | * mce_severity() 22 | * mce_timeout() except if (*t <= 0) branch 23 | * mce_panic() 24 | * print_mce() 25 | * mce_log() 26 | - Reference: 27 | * Inject data file: cases/soft-inj/panic/data/fatal 28 | - Expected result: 29 | * No warning or bug during kernel processing. 30 | * MCE records collected via kernel panic log is same as reference ones. 31 | * Kernel panic message is "Fatal Machine check" 32 | * Exception message is "Processor context corrupt" 33 | 34 | 35 | 2. fatal timeout 36 | 37 | - Objective: 38 | * Test logic of timeout during monarch/subject synchronization 39 | * Test logic to recognize a fatal (PCC) MCE 40 | - Code path tested: 41 | * do_machine_check() 42 | * mce_start() 43 | * mce_timeout() if (*t <= 0) branch 44 | * mce_severity() 45 | * mce_panic("Fatal machine check on current CPU",); 46 | * print_mce() 47 | * mce_log() 48 | - Reference: 49 | * Inject data file: cases/soft-inj/panic/data/fatal_timeout 50 | - Expected result: 51 | * No warning or bug during kernel processing. 52 | * MCE records collected via kernel panic log is same as reference ones. 53 | * Kernel panic message is "Fatal machine check on current CPU" 54 | * Exception message is "Processor context corrupt" 55 | * Timeout message is "Some CPUs didn't answer in synchronization" 56 | 57 | 58 | 3. fatal in irq 59 | 60 | - Objective: 61 | * Test fatal MCE occur in IRQ context 62 | * Test logic to recognize a fatal (PCC) MCE 63 | - Code path tested: 64 | * Same as fatal 65 | - Reference: 66 | * Inject data file: cases/soft-inj/panic/data/fatal_irq 67 | - Expected result: 68 | * No warning or bug during kernel processing. 69 | * MCE records collected via kernel panic log is same as reference ones. 70 | * Kernel panic message is "Fatal Machine check" 71 | * Exception message is "Processor context corrupt" 72 | 73 | 74 | 4. fatal with RIPV 75 | 76 | - Objective: 77 | * Test combination of PCC and RIPV 78 | * Test logic to recognize a fatal (PCC) MCE 79 | - Code path tested: 80 | * MCG_STATUS_RIPV branch of switch(m.mcgstatus) in do_machine_check 81 | * Others are same as fatal 82 | - Reference: 83 | * Inject data file: cases/soft-inj/panic/data/fatal_ripv 84 | - Expected result: 85 | * No warning or bug during kernel processing. 86 | * MCE records collected via kernel panic log is same as reference ones. 87 | * Kernel panic message is "Fatal Machine check" 88 | * Exception message is "Processor context corrupt" 89 | 90 | 91 | 5. fatal timeout with RIPV 92 | 93 | - Objective: 94 | * Test timeout logic of combination of PCC and RIPV 95 | * Test logic to recognize a fatal (PCC) MCE 96 | - Code path tested: 97 | * MCG_STATUS_RIPV branch of switch(m.mcgstatus) in do_machine_check 98 | * Others are same as fatal_timeout 99 | - Reference: 100 | * Inject data file: cases/soft-inj/panic/data/fatal_timeout_ripv 101 | - Expected result: 102 | * No warning or bug during kernel processing. 103 | * MCE records collected via kernel panic log is same as reference ones. 104 | * Kernel panic message is "Fatal machine check on current CPU" 105 | * Exception message is "Processor context corrupt" 106 | * Timeout message is "Some CPUs didn't answer in synchronization" 107 | 108 | 109 | 6. fatal with OVER 110 | 111 | - Objective: 112 | * Test OVER flag in MCI_STATUS processing 113 | * Test logic to recognize a fatal (PCC) MCE 114 | - Code path tested: 115 | * Same as fatal 116 | - Reference: 117 | * Inject data file: cases/soft-inj/panic/data/fatal_over 118 | - Expected result: 119 | * No warning or bug during kernel processing. 120 | * MCE records collected via kernel panic log is same as reference ones. 121 | * Kernel panic message is "Fatal Machine check" 122 | * Exception message is "Processor context corrupt" 123 | 124 | 125 | 7. fatal and UC without EN 126 | 127 | - Objective: 128 | * Test no EN processing. Only one MCE can be injected on one CPU, so 129 | a MCE without EN are injected on other CPU. 130 | * Test logic to recognize a fatal (PCC) MCE 131 | - Code path tested: 132 | * Same as fatal except no EN branch in do_machine_check() 133 | - Reference: 134 | * Inject data file: cases/soft-inj/panic/data/fatal_no_en 135 | * Reference MCE records: cases/soft-inj/panic/refer/fatal_no_en 136 | - Expected result: 137 | * No warning or bug during kernel processing. 138 | * MCE records collected via kernel panic log is same as reference ones. 139 | * Kernel panic message is "Machine check from unknown source" 140 | * No exception message 141 | 142 | 8. fatal with EIPV 143 | 144 | - Objective: 145 | * Test combination of PCC and EIPV 146 | * Test logic to recognize a fatal (PCC) MCE 147 | - Code path tested: 148 | * Same as fatal 149 | - Reference: 150 | * Inject data file: cases/soft-inj/panic/data/fatal_eipv 151 | - Expected result: 152 | * No warning or bug during kernel processing. 153 | * MCE records collected via kernel panic log is same as reference ones. 154 | * Kernel panic message is "Fatal Machine check" 155 | * Exception message is "Processor context corrupt" 156 | 157 | 158 | 9. fatal in userspace 159 | 160 | - Objective: 161 | * Test of PCC in userspace 162 | * Test logic to recognize a fatal (PCC) MCE 163 | - Code path tested: 164 | * Same as fatal 165 | - Reference: 166 | * Inject data file: cases/soft-inj/panic/data/fatal_eipv 167 | - Expected result: 168 | * No warning or bug during kernel processing. 169 | * MCE records collected via kernel panic log is same as reference ones. 170 | * Kernel panic message is "Fatal Machine check" 171 | * Exception message is "Processor context corrupt" 172 | 173 | 174 | -------------------------------------------------------------------------------- /doc/cases/soft-inj_panic_noser.txt: -------------------------------------------------------------------------------- 1 | Overall: (3 cases) 2 | 3 | - Test method 4 | * Add cases/soft-inj/panic_noser/cases.sh into configuration file, and invoke 5 | a test driver on it. 6 | - Common 7 | * Test script of test cases in this file can be found in 8 | cases/soft-inj/panic_noser/cases.sh 9 | 10 | 1. uc_over 11 | 12 | - Objective: 13 | * Test MSR read logic of MCE handler 14 | * Test synchronization between monarch and subject 15 | * Test logic of uncorrected with UC and OVER 16 | - Code path tested: 17 | * do_machine_check() 18 | * mce_start() 19 | * mce_timeout() except if (*t <= 0) branch 20 | * mce_log() 21 | * mce_end() 22 | * mce_severity() 23 | * mce_reign() until mce_panic("Fatal Machine check",) 24 | * mce_panic() 25 | * print_mce() 26 | - Reference: 27 | * Inject data file: cases/soft-inj/panic_noser/data/uc_over 28 | - Expected result: 29 | * No warning or bug during kernel processing. 30 | * MCE records collected via kernel panic log is same as reference ones. 31 | * Kernel panic message is "Fatal Machine check" 32 | * Exception message is "Overflowed uncorrected" 33 | 34 | 35 | 2. uc_over_corrected 36 | 37 | - Objective: 38 | * Test synchronization between monarch and subject 39 | * Test logic of uncorrected and corrected 40 | * Test logic of uncorrected with UC and OVER 41 | * Test logic of corrected with EXCP 42 | - Code path tested: 43 | * do_machine_check() 44 | * mce_start() 45 | * mce_timeout() except if (*t <= 0) branch 46 | * mce_log() 47 | * mce_end() 48 | * mce_severity() 49 | * mce_reign() until mce_panic("Fatal Machine check",) 50 | * mce_panic() 51 | * print_mce() 52 | - Reference: 53 | * Inject data file: cases/soft-inj/panic_noser/data/uc_over_corrected 54 | - Expected result: 55 | * No warning or bug during kernel processing. 56 | * MCE records collected via kernel panic log is same as reference ones. 57 | * Kernel panic message is "Fatal Machine check" 58 | * Exception message is "Overflowed uncorrected" 59 | 60 | 61 | 3. uc_over_timeout 62 | 63 | - Objective: 64 | * Test logic of timeout during monarch/subject synchronization 65 | * Test logic of uncorrected with UC and OVER 66 | - Code path tested: 67 | * do_machine_check() 68 | * mce_start() 69 | * mce_timeout() if (*t <= 0) branch 70 | * mce_log() 71 | * mce_severity() 72 | * mce_panic("Fatal machine check on current CPU",) 73 | * print_mce() 74 | - Reference: 75 | * Inject data file: cases/soft-inj/panic_noser/data/uc_over_timeout 76 | - Expected result: 77 | * No warning or bug during kernel processing. 78 | * MCE records collected via kernel panic log is same as reference ones. 79 | * Kernel panic message is "Fatal machine check on current CPU" 80 | * Exception message is "Overflowed uncorrected" 81 | * Timeout message is "Some CPUs didn't answer in synchronization" 82 | 83 | 84 | -------------------------------------------------------------------------------- /doc/cases/soft-inj_panic_npcc.txt: -------------------------------------------------------------------------------- 1 | Overall:(8 cases) 2 | 3 | - Test method 4 | * Preparation 5 | + Disable mcelog cron job 6 | * Add cases/soft-inj/panic_npcc/cases.sh into configuration file, and invoke 7 | a test driver on it. 8 | - Common 9 | * Test script of test cases in this file can be found in 10 | cases/soft-inj/panic_npcc/cases.sh 11 | 12 | 13 | 1. fatal severity 14 | 15 | - Objective: 16 | * Test severity comparison logic of MCE handler 17 | - Code path tested: 18 | * do_machine_check() 19 | * mce_start() 20 | * mce_end() 21 | * mce_severity() 22 | * mce_regin() for_each_possible_loops loops(check mce-severity message) 23 | * mce_panic() 24 | * mce_log() 25 | * print_mce() 26 | - Reference: 27 | * Inject data file: cases/soft-inj/panic_npcc/data/fatal_severity 28 | - Expected result: 29 | * No warning or bug during kernel processing. 30 | * MCE records collected via kernel panic log is same as reference ones. 31 | * Kernel panic message is "Fatal Machine check" 32 | * Exception message is "Processor context corrupt" 33 | 34 | 35 | 2. uncorrected 36 | 37 | - Objective: 38 | * Test MCE handler logic for EIPV MCE in kernel space 39 | - Code path tested: 40 | * Same as falta severity 41 | - Reference: 42 | * Inject data file: cases/soft-inj/panic_npcc/data/uncorrected 43 | - Expected result: 44 | * No warning or bug during kernel processing. 45 | * MCE records collected via kernel panic log is same as reference ones. 46 | * Kernel panic message is "Fatal Machine check" 47 | * Exception message is "In kernel and no restart IP" 48 | 49 | 50 | 3. uncorrected timeout 51 | 52 | - Objective: 53 | * Test MCE handler timeout logic for EIPV MCE in kernel space 54 | - Code path tested: 55 | * do_machine_check() 56 | * mce_start() until timeout 57 | * mce_severity() 58 | * mce_panic("Fatal machine check on current CPU", ) 59 | * mce_log() 60 | * print_mce() 61 | - Reference: 62 | * Inject data file: cases/soft-inj/panic_npcc/data/uncorrected_timeout 63 | - Expected result: 64 | * No warning or bug during kernel processing. 65 | * MCE records collected via kernel panic log is same as reference ones. 66 | * Kernel panic message is "Fatal machine check on current CPU" 67 | * Exception message is "In kernel and no restart IP" 68 | * Timeout message is "Some CPUs didn't answer in synchronization" 69 | 70 | 71 | 4. uncorrected without MCIP 72 | 73 | - Objective: 74 | * Test MCE handler logic for MCE without PCC, MCIP, EIPV and RIPV 75 | - Code path tested: 76 | * Same as fatal severity 77 | - Reference: 78 | * Inject data file: cases/soft-inj/panic_npcc/data/uncorrected_no_mcip 79 | - Expected result: 80 | * No warning or bug during kernel processing. 81 | * MCE records collected via kernel panic log is same as reference ones. 82 | * Kernel panic message is "Fatal Machine check" 83 | * Exception message is "MCIP not set in MCA handler" 84 | 85 | 86 | 5. uncorrect timeout without MCIP 87 | 88 | - Objective: 89 | * Test MCE handler timeout logic for MCE without PCC, MCIP, EIPV and RIPV 90 | - Code path tested: 91 | * Same as uncorrected timeout 92 | - Reference: 93 | * Inject data file: cases/soft-inj/panic_npcc/data/uncorrected_no_mcip_timeout 94 | - Expected result: 95 | * No warning or bug during kernel processing. 96 | * MCE records collected via kernel panic log is same as reference ones. 97 | * Kernel panic message is "Fatal machine check on current CPU" 98 | * Kernel panic message is "MCIP not set in MCA handler" 99 | * Timeout message is "Some CPUs didn't answer in synchronization" 100 | 101 | 102 | 6. uncorrected without EIPV and RIPV 103 | 104 | - Objective: 105 | * Test MCE handler logic for EIPV and RIPV MCE in kernel space 106 | - Code path tested: 107 | * Same as uncorrected 108 | - Reference: 109 | * Inject data file: cases/soft-inj/panic_npcc/data/uncorrected_no_eripv 110 | - Expected result: 111 | * No warning or bug during kernel processing. 112 | * MCE records collected via kernel panic log is same as reference ones. 113 | * Kernel panic message is "Fatal Machine check" 114 | * Exception message is "Neither restart nor error IP" 115 | 116 | 117 | 7. uncorrected timeout without EIPV and RIPV 118 | 119 | - Objective: 120 | * Test MCE handler timout logic for EIPV|RIPV MCE in kernel space 121 | - Code path tested: 122 | * Same as uncorrected timeout 123 | - Reference: 124 | * Inject data file: cases/soft-inj/panic_npcc/data/uncorrected_no_eripv_timeout 125 | - Expected result: 126 | * No warning or bug during kernel processing. 127 | * MCE records collected via kernel panic log is same as reference ones. 128 | * Kernel panic message is "Fatal Machine check" 129 | * Exception message is "In kernel and no restart IP" 130 | * Timeout message is "Some CPUs didn't answer in synchronization" 131 | 132 | 133 | 8. unknown 134 | 135 | - Objective: 136 | * Test logic for MCE from unknown source (external?) 137 | - Code path tested: 138 | * mce_reign(), mce_panic("Machine check from unknown source") branch 139 | * Others are same as fatal severity 140 | - Reference: 141 | * Inject data file: cases/soft-inj/panic_npcc/data/unknown 142 | - Expected result: 143 | * No warning or bug during kernel processing. 144 | * Kernel panic message is "Machine check from unknown source" 145 | * No exception and timeout message. 146 | -------------------------------------------------------------------------------- /doc/cases/soft-inj_panic_ucr.txt: -------------------------------------------------------------------------------- 1 | Overall: (6 cases) 2 | 3 | - Test method 4 | * Add cases/soft-inj/panic_ucr/cases.sh into configuration file, and invoke 5 | a test driver on it. 6 | - Common 7 | * Test script of test cases in this file can be found in 8 | cases/soft-inj/panic_ucr/cases.sh 9 | 10 | 1. s0_ar1 11 | 12 | - Objective: 13 | * Test MSR read logic of MCE handler 14 | * Test synchronization between monarch and subject 15 | - Code path tested: 16 | * do_machine_check() 17 | * mce_start() 18 | * mce_timeout() except if (*t <= 0) branch 19 | * mce_log() 20 | * mce_end() 21 | * mce_severity() 22 | * mce_reign() until mce_panic("Fatal Machine check",) 23 | * mce_panic() 24 | * print_mce() 25 | - Reference: 26 | * Inject data file: cases/soft-inj/panic_ucr/data/s0_ar1 27 | - Expected result: 28 | * No warning or bug during kernel processing. 29 | * MCE records collected via kernel panic log is same as reference ones. 30 | * Kernel panic message is "Fatal Machine check" 31 | * Exception message is "Illegal combination (UCNA with AR=1)" 32 | 33 | 34 | 2. srar_over 35 | 36 | - Objective: 37 | * Test logic of timeout during monarch/subject synchronization 38 | - Code path tested: 39 | * do_machine_check() 40 | * mce_start() 41 | * mce_timeout() except if (*t <= 0) branch 42 | * mce_log() 43 | * mce_end() 44 | * mce_severity() 45 | * mce_reign() until mce_panic("Fatal Machine check",) 46 | * mce_panic(); 47 | * print_mce() 48 | - Reference: 49 | * Inject data file: cases/soft-inj/panic_ucr/data/srar_over 50 | - Expected result: 51 | * No warning or bug during kernel processing. 52 | * MCE records collected via kernel panic log is same as reference ones. 53 | * Kernel panic message is "Fatal Machine check" 54 | * Exception message is "Action required with lost events" 55 | 56 | 57 | 3. srar_unknown 58 | 59 | - Objective: 60 | * Test fatal MCE occur in IRQ context 61 | - Code path tested: 62 | * do_machine_check() 63 | * mce_start() 64 | * mce_timeout() except if (*t <= 0) branch 65 | * mce_log() 66 | * mce_end() 67 | * mce_severity() 68 | * mce_reign() until mce_panic("Fatal Machine check",) 69 | * mce_panic() 70 | * print_mce() 71 | - Reference: 72 | * Inject data file: cases/soft-inj/panic_ucr/data/srar_unknown 73 | - Expected result: 74 | * No warning or bug during kernel processing. 75 | * MCE records collected via kernel panic log is same as reference ones. 76 | * Kernel panic message is "Fatal Machine check" 77 | * Exception message is "Action required; unknown MCACOD" 78 | 79 | 80 | 4. srar_no_en 81 | 82 | - Objective: 83 | * Test fatal MCE occur 84 | - Code path tested: 85 | * do_machine_check() 86 | * mce_start() 87 | * mce_timeout() except if (*t <= 0) branch 88 | * mce_log() 89 | * mce_end() 90 | * mce_severity() 91 | * mce_reign() until mce_panic("Machine check from unknown source",) 92 | * mce_panic() 93 | * print_mce() 94 | - Reference: 95 | * Inject data file: cases/soft-inj/panic_ucr/data/srar_no_en 96 | * Reference MCE records: cases/soft-inj/panic_ucr/refer/srar_no_en 97 | - Expected result: 98 | * No warning or bug during kernel processing. 99 | * MCE records collected via kernel panic log is same as reference ones. 100 | * Kernel panic message is "Machine check from unknown source" 101 | 102 | 5.srao_ewb_noripv 103 | - Objective: 104 | * Test MCE handler logic for EIPV and RIPV MCE in kernel space 105 | - Code path tested: 106 | * do_machine_check() 107 | * mce_start() 108 | * mce_end() 109 | * mce_severity() 110 | * mce_regin() for_each_possible_loops loops(check mce-severity message) 111 | * mce_panic() 112 | * mce_log() 113 | * print_mce() 114 | - Reference: 115 | * Inject data file: cases/soft-inj/recoverable_ucr/data/srao_ewb_noripv 116 | - Expected result: 117 | * No warning or bug during kernel processing. 118 | * MCE records collected via kernel panic log is same as reference ones. 119 | * Kernel panic message is "Fatal Machine check" 120 | * Exception message is "Neither restart nor error IP" 121 | 122 | 6.srao_mem_scrub_noripv 123 | - Objective: 124 | * Test MCE handler logic for EIPV and RIPV MCE in kernel space 125 | - Code path tested: 126 | * the same as srao_ewb_noripv 127 | - Reference: 128 | * Inject data file: 129 | * cases/soft-inj/recoverable_ucr/data/srao_mem_scrub_noripv 130 | - Expected result: 131 | * No warning or bug during kernel processing. 132 | * MCE records collected via kernel panic log is same as reference ones. 133 | * Kernel panic message is "Fatal Machine check" 134 | * Exception message is "Neither restart nor error IP" 135 | 136 | -------------------------------------------------------------------------------- /doc/cases/soft-inj_poll_ucr.txt: -------------------------------------------------------------------------------- 1 | Overall:(2 cases) 2 | 3 | - Test method 4 | * Preparation 5 | + Disable mcelog cron job 6 | * Add cases/soft-inj/panic_ucr/cases.sh into configuration file, and invoke 7 | a test driver on it. 8 | - Common 9 | * Test script of test cases in this file can be found in 10 | cases/soft-inj/panic_ucr/cases.sh 11 | 12 | 13 | 1. ucna 14 | 15 | - Objective: 16 | * Test severity comparison logic of MCE handler 17 | * Test logic of uncorrected with POLL 18 | - Code path tested: 19 | * machine_check_poll() except 20 | if (!(flags & MCP_UC) && 21 | (m.status & (mce_ser ? MCI_STATUS_S : MCI_STATUS_UC)) 22 | * mce_log() 23 | - Reference: 24 | * Inject data file: cases/soft-inj/poll_ucr/data/ucna 25 | - Expected result: 26 | * MCE records collected via kernel panic log is same as reference ones. 27 | * No warning or bug during kernel processing. 28 | 29 | 30 | 2. ucna_over 31 | 32 | - Objective: 33 | * Test severity comparison logic of MCE handler 34 | * Test logic of uncorrected with POLL 35 | - Code path tested: 36 | * machine_check_poll() except 37 | if (!(flags & MCP_UC) && 38 | (m.status & (mce_ser ? MCI_STATUS_S : MCI_STATUS_UC)) 39 | * mce_log() 40 | - Reference: 41 | * Inject data file: cases/soft-inj/poll_ucr/data/ucna_over 42 | - Expected result: 43 | * MCE records collected via kernel panic log is same as reference ones. 44 | * No warning or bug during kernel processing. 45 | -------------------------------------------------------------------------------- /doc/cases/soft-inj_recoverable_ucr.txt: -------------------------------------------------------------------------------- 1 | overall: (7 cases) 2 | 3 | - Test method 4 | * Add cases/soft-inj/recoverable_ucr/cases.sh into configuration file, and invoke a test driver on it. 5 | - Common 6 | * Test script of test cases in this file can be found in 7 | cases/soft-inj/recoverable_ucr/cases.sh 8 | 9 | 1.srao_corrected 10 | 11 | - Objective: 12 | * Test logic of uncorrected and corrected 13 | * Test logic of uncorrected with S 14 | * Test logic of corrected with EXCP 15 | - Code path tested: 16 | * do_machine_check() 17 | * mce_start() 18 | * mce_timeout() except if (*t <= 0) branch 19 | * mce_severity() 20 | * mce_log() 21 | * mce_end() 22 | * mce_reign() 23 | * mce_report_event() 24 | - Reference: 25 | * Inject data file: cases/soft-inj/recoverable_uc/data/srao_corrected 26 | - Expected result: 27 | * No warning or bug during kernel processing. 28 | * Exception message is "Action optional unknown MCACOD" 29 | 30 | 2.srao_ewb 31 | - Objective: 32 | * Test logic of uncorrected with S 33 | * Test logic of UCR errors detected during last level cache(LLC) explicit writebacks. 34 | - Code path tested: 35 | * do_machine_check() 36 | * mce_start() 37 | * mce_timeout() except if (*t <= 0) branch 38 | * mce_severity() 39 | * mce_ring_add() 40 | * mce_log() 41 | * mce_end() 42 | * mce_reign() 43 | - Reference: 44 | * Inject data file: cases/soft-inj/recoverable_uc/data/srao_ewb 45 | - Expected result: 46 | * No warning or bug during kernel processing. 47 | * Exception message is "Action optional: last level cache writeback error" 48 | 49 | 3.srao_mem_scrub 50 | - Objective: 51 | * Test logic of uncorrected with S 52 | * Test logic of UCR errors detected on data load 53 | - Code path tested: 54 | * do_machine_check() 55 | * mce_start() 56 | * mce_timeout() except if (*t <= 0) branch 57 | * mce_severity() 58 | * mce_ring_add() 59 | * mce_log() 60 | * mce_end() 61 | * mce_reign() 62 | - Reference: 63 | * Inject data file: cases/soft-inj/recoverable_uc/data/srao_mem_scrub 64 | - Expected result: 65 | * No warning or bug during kernel processing. 66 | * Exception message is "Action optional: memory scrubbing error" 67 | 68 | 4.srao_no_en 69 | - Objective: 70 | * Test no EN processing. 71 | - Code path tested: 72 | * do_machine_check() 73 | * mce_start() 74 | * mce_timeout() except if (*t <= 0) branch 75 | * mce_severity() 76 | * mce_end() 77 | * mce_reign() 78 | * mce_panic() 79 | - Reference: 80 | * Inject data file: cases/soft-inj/recoverable_uc/data/srao_no_en 81 | - Expected result: 82 | * No warning or bug during kernel processing. 83 | * Kernel panic message is "Machine check from unknown source" 84 | 85 | 5.srao_over 86 | - Objective: 87 | * Test logic of uncorrected with S and OVER 88 | - Code path tested: 89 | * do_machine_check() 90 | * mce_start() 91 | * mce_timeout() except if (*t <= 0) branch 92 | * mce_severity() 93 | * mce_log() 94 | * mce_end() 95 | * mce_reign() 96 | - Reference: 97 | * Inject data file: cases/soft-inj/recoverable_uc/data/srao_over 98 | - Expected result: 99 | * No warning or bug during kernel processing. 100 | * Exception message is "Action optional with lost events" 101 | 102 | 6.srao_ucna 103 | - Objective: 104 | * Test logic of uncorrected with S 105 | * Test logic of ucna 106 | - Code path tested: 107 | * do_machine_check() 108 | * mce_start() 109 | * mce_timeout() except if (*t <= 0) branch 110 | * mce_severity() 111 | * mce_get_rip() 112 | * mce_log() 113 | * mce_end() 114 | * mce_reign() 115 | - Reference: 116 | * Inject data file: cases/soft-inj/recoverable_uc/data/srao_ucna 117 | - Expected result: 118 | * No warning or bug during kernel processing. 119 | * Exception message is "Action optional with unknown MCACOD" 120 | 121 | 7.srao_unknown 122 | - Objective: 123 | * Test logic of uncorrected with S 124 | - Code path tested: 125 | * do_machine_check() 126 | * mce_start() 127 | * mce_timeout() except if (*t <= 0) branch 128 | * mce_severity() 129 | * mce_get_rip() 130 | * mce_log() 131 | * mce_end() 132 | * mce_reign() 133 | - Reference: 134 | * Inject data file: cases/soft-inj/recoverable_uc/data/srao_unknown 135 | - Expected result: 136 | * No warning or bug during kernel processing. 137 | * Exception message is "Action optional with unknown MCACOD" 138 | 139 | 8.srar_usr_dcu 140 | - Objective: 141 | * Test logic of uncorrected with S & AR 142 | - Code path tested: 143 | * do_machine_check() 144 | * mce_start() 145 | * mce_timeout() except if (*t <= 0) branch 146 | * mce_severity() 147 | * mce_get_rip() 148 | * mce_log() 149 | * mce_end() 150 | * mce_reign() 151 | - Reference: 152 | * Inject data file: cases/soft-inj/recoverable_uc/data/srar_usr_dcu 153 | - Expected result: 154 | * No warning or bug during kernel processing. 155 | * Exception message is "Data CACHE Level-0 Data-Read Error" 156 | 157 | 9.srar_usr_dcu_nmi 158 | - Objective: 159 | * Test logic of uncorrected with S & AR 160 | - Code path tested: 161 | * do_machine_check() 162 | * mce_start() 163 | * mce_timeout() except if (*t <= 0) branch 164 | * mce_severity() 165 | * mce_get_rip() 166 | * mce_log() 167 | * mce_end() 168 | * mce_reign() 169 | - Reference: 170 | * Inject data file: cases/soft-inj/recoverable_uc/data/srar_usr_dcu_nmi 171 | - Expected result: 172 | * No warning or bug during kernel processing. 173 | * Exception message is "Data CACHE Level-0 Data-Read Error" 174 | 175 | 10.srar_dcu_irq 176 | - Objective: 177 | * Test logic of uncorrected with S & AR 178 | - Code path tested: 179 | * do_machine_check() 180 | * mce_start() 181 | * mce_timeout() except if (*t <= 0) branch 182 | * mce_severity() 183 | * mce_get_rip() 184 | * mce_log() 185 | * mce_end() 186 | * mce_reign() 187 | - Reference: 188 | * Inject data file: cases/soft-inj/recoverable_uc/data/srar_dcu_irq 189 | - Expected result: 190 | * No warning or bug during kernel processing. 191 | * Exception message is "Data CACHE Level-0 Data-Read Error" 192 | 193 | -------------------------------------------------------------------------------- /doc/kvm: -------------------------------------------------------------------------------- 1 | SRAO test for KVM can' automatically run, please follow the instructions 2 | in cases/function/kvm/README to do SRAO test for KVM. 3 | -------------------------------------------------------------------------------- /doc/verify.txt: -------------------------------------------------------------------------------- 1 | To verify the result of MCE testing, the MCE record from kernel (via 2 | /dev/mcelog or panic information) should be compared with reference 3 | MCE record (for software inject error: the input MCE record). To 4 | compare MCE record, the following scheme is proposed: 5 | 6 | - Define a standard MCE record representation format. It should be 7 | human readable, compatible with MCE parser in mce-inject, easy to 8 | manipulate in shell (such as remove a field), easy to compare 9 | (literally). 10 | 11 | One MCE record is as follow: 12 | 13 | CPU NUMBER 14 | BANK NUMBER 15 | TSC NUMBER 16 | RIP NUMBER 17 | ADDR NUMBER 18 | MISC NUMBER 19 | STATUS NUMBER 20 | MCGSTATUS NUMBER 21 | 22 | Multiple MCE records are separated by one empty line. 23 | 24 | - Enhance mce-inject or develop a new tool to convert from other 25 | format to standard format. 26 | 27 | - Develop a new tool based on /usr/sbin/mcelog to output mce-inject 28 | compatible MCE record. Because there may be different (uncompatible 29 | version) /usr/sbin/mcelog on different machine. 30 | 31 | - During verifying, firstly convert various MCE recoards from kernel 32 | and reference MCE records to standard format, then compare the 33 | standard format MCE records in shell. 34 | -------------------------------------------------------------------------------- /groups/coverage: -------------------------------------------------------------------------------- 1 | #Coverage test is out-of-date, it is not guaranteed 2 | #working well with newer kernel 3 | 4 | #SIMPLE cases/coverage/soft-inj/run_simple.sh off 5 | #KDUMP cases/coverage/soft-inj/run_kdump.sh off 6 | -------------------------------------------------------------------------------- /groups/function: -------------------------------------------------------------------------------- 1 | APEI-INJ cases/function/apei-inj/runtest.sh on 2 | EINJ-EXT cases/function/einj-ext/runtest.sh off 3 | ERST-INJ cases/function/erst-inject/runtest.sh on 4 | #eMCA test depends on proper BIOS setting 5 | eMCA cases/function/emca-inj/runtest.sh off 6 | #PFA test depends on correct BIOS/mcelog setting 7 | PFA cases/function/pfa/runtest.sh on 8 | EDAC cases/function/edac/runtest.sh off 9 | #SRAR test highly depends on BIOS implementation 10 | SRAR-DCU cases/function/core_recovery/runtest_dcu.sh off 11 | SRAR-IFU cases/function/core_recovery/runtest_ifu.sh off 12 | #HWpoison 13 | HWPOISON-SOFT cases/function/hwpoison/run_soft.sh on 14 | HWPOISON-HARD cases/function/hwpoison/run_hard.sh on 15 | HWPOISON-HUGEPAGE cases/function/hwpoison/run_hugepage.sh on 16 | HWPOISON-HUGEPAGE-OVERCOMMIT cases/function/hwpoison/run_hugepage_overcommit.sh off 17 | HWPOISON-THP cases/function/hwpoison/run_thp.sh on 18 | #BSP 19 | BSP cases/function/bsp/runtest.sh on 20 | #KVM 21 | -------------------------------------------------------------------------------- /groups/stress: -------------------------------------------------------------------------------- 1 | STRESS-HWPOISON-SOFT cases/stress/hwpoison/run_soft.sh on 2 | STRESS-HWPOISON-HARD cases/stress/hwpoison/run_hard.sh on 3 | -------------------------------------------------------------------------------- /lib/dirs.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Setup environment variable for various directories. 3 | # 4 | # Copyright (C) 2008-2012 Intel Corp. 5 | # Author: Huang Ying 6 | # 7 | # This file is released under the GPLv2. 8 | # 9 | 10 | SDIR=$(script_dir) 11 | CDIR=$ROOT/cases/coverage/soft-inj 12 | CONF_DIR=$SDIR/config 13 | RDIR=$LOG_DIR/$driver 14 | WDIR=$TMP_DIR/$driver 15 | LDIR=$ROOT/lib 16 | TDIR=$TOOL_DIR 17 | -------------------------------------------------------------------------------- /lib/functions.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Function library: provide common functions 3 | # 4 | # Copyright (C) 2008, Intel Corp. 5 | # Author: Huang Ying 6 | # 7 | # This file is released under the GPLv2. 8 | # 9 | 10 | setup_path() 11 | { 12 | export PATH=$ROOT/bin:$PATH 13 | } 14 | 15 | script_dir() 16 | { 17 | local rd=$(dirname "$0") 18 | (cd $rd; pwd) 19 | } 20 | 21 | relative_path() 22 | { 23 | local len1=${#1} 24 | local len2=${#2} 25 | if [ $len1 -eq 0 -o $len1 -gt $len2 -o "${2:0:$len1}" != "$1" ]; then 26 | die "$2 is not the sub-path of $1!" 27 | fi 28 | len1=$((len1 + 1)) 29 | echo "${2:$len1}" 30 | } 31 | 32 | die() 33 | { 34 | echo "DIE: $@" 35 | echo "DIE: $@" 1>&2 36 | exit -1 37 | } 38 | 39 | driver_prepare() 40 | { 41 | mkdir -p $WDIR/stamps 42 | } 43 | 44 | check_kern_warning_bug() 45 | { 46 | local f="$1" 47 | [ -n "$f" ] || die "missing parameter for check_kern_warning" 48 | grep -e '----\[ cut here \]---' $f > /dev/null || \ 49 | grep -e 'BUG:' $f > /dev/null 50 | } 51 | 52 | random_sleep() 53 | { 54 | local s=$((RANDOM / 13107 + 5)) 55 | sleep $s 56 | } 57 | 58 | start_background() 59 | { 60 | if [ -n "$BACKGROUND" ]; then 61 | pid_background=$(bash -i -c "$BACKGROUND &>$WDIR/background_log & echo \$!") 62 | if ! ps -p $pid_background > /dev/null; then 63 | die "Failed to start background testing: $BACKGROUND" 64 | fi 65 | fi 66 | } 67 | 68 | stop_background() 69 | { 70 | if [ -n "$pid_background" ]; then 71 | if ! kill -TERM -$pid_background &> /dev/null; then 72 | kill $pid_background || true 73 | fi 74 | fi 75 | } 76 | 77 | filter_fake_panic() 78 | { 79 | local orig_klog=$1 80 | local new_klog=$2 81 | [ $# -eq 2 ] || die "missing parameter for filter_fake_panic" 82 | 83 | local pn 84 | pn=$(grep -n "Fake kernel panic" $orig_klog | cut -d ':' -f 1 | head -1) 85 | if [ -z "$pn" ]; then 86 | cp $orig_klog $new_klog 87 | else 88 | sed -n "1,${pn}p" < $orig_klog > $new_klog 89 | fi 90 | } 91 | -------------------------------------------------------------------------------- /lib/soft-inject.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Software Inject library: Software inject specific functions 3 | # 4 | # Copyright (C) 2008, Intel Corp. 5 | # Author: Huang Ying 6 | # 7 | # This file is released under the GPLv2. 8 | # 9 | 10 | if [ -n "$this_case" ]; then 11 | bcase=$(basename $this_case) 12 | fi 13 | mcelog_result=$RDIR/$this_case/mcelog 14 | klog=$RDIR/$this_case/klog 15 | 16 | soft_inject_verify_mcelog() 17 | { 18 | # check mcelog 19 | if [ -f $RDIR/$this_case/mcelog ]; then 20 | if [ -f $SDIR/refer/$bcase ]; then 21 | mcelog_refer=$SDIR/refer/$bcase 22 | else 23 | mcelog_refer=$SDIR/data/$bcase 24 | fi 25 | mce_reformat $mcelog_refer $RDIR/$this_case/mcelog_refer 26 | 27 | if mce_cmp $RDIR/$this_case/mcelog $mcelog_refer "$removes"; then 28 | echo " Passed: MCE log is ok" 29 | else 30 | echo " Failed: MCE log is different from input" 31 | fi 32 | else 33 | echo " Failed: no MCE log result" 34 | fi 35 | } 36 | 37 | soft_inject_get_klog() 38 | { 39 | local klog=$RDIR/$this_case/klog 40 | local orig_klog=$RDIR/$this_case/orig_klog 41 | 42 | if [ -f $klog ]; then 43 | cp $klog $orig_klog 44 | filter_fake_panic $orig_klog $klog 45 | fi 46 | } 47 | 48 | soft_inject_get_mcelog() 49 | { 50 | case "$driver" in 51 | simple*) 52 | get_mcelog_from_dev $mcelog_result 53 | ;; 54 | kdump*) 55 | get_mcelog_from_klog $klog $mcelog_result 56 | ;; 57 | *) 58 | echo '!!! Unsupported driver !!!' 59 | esac 60 | } 61 | 62 | # verify return value 63 | soft_inject_verify_return_val() 64 | { 65 | if [ -f $RDIR/$this_case/return ] && \ 66 | [ $(cat $RDIR/$this_case/return) -eq 0 ]; then 67 | echo " Passed: inject process continue" 68 | else 69 | echo " Failed: inject process killed" 70 | fi 71 | } 72 | 73 | soft_inject_verify_kill() 74 | { 75 | if [ -f $RDIR/$this_case/return ] && \ 76 | [ $(cat $RDIR/$this_case/return) -eq 139 ]; then 77 | echo " Passed: inject process killed!" 78 | else 79 | echo " Failed: Not killed" 80 | fi 81 | } 82 | 83 | soft_inject_enumerate() 84 | { 85 | local base=$(relative_path ${CDIR} ${SDIR}) 86 | [ -z "$base" ] && die "BUG!!! Please contact your software vendor!" 87 | for c in $(cd $SDIR/data; ls *[^~]); do 88 | echo $base/$c 89 | done 90 | } 91 | 92 | soft_inject_trigger() 93 | { 94 | mcelog &> /dev/null 95 | case "$driver" in 96 | kdump*) 97 | mce-inject --no-random $SDIR/data/$bcase 98 | ;; 99 | *) 100 | mce-inject $SDIR/data/$bcase 101 | ;; 102 | esac 103 | ret=$? 104 | echo $ret > $RDIR/$this_case/return 105 | sleep 1 106 | } 107 | 108 | soft_inject_verify_panic() 109 | { 110 | local mce_panic="$1" 111 | verify_panic_via_klog $klog "$mce_panic" 112 | } 113 | 114 | soft_inject_verify_timeout() 115 | { 116 | verify_timeout_via_klog $klog 117 | } 118 | 119 | soft_inject_verify_exp() 120 | { 121 | verify_exp_via_klog $klog "$@" 122 | } 123 | 124 | soft_inject_main() 125 | { 126 | op="$1" 127 | shift 128 | 129 | case "$op" in 130 | enumerate) 131 | enumerate 132 | ;; 133 | trigger) 134 | trigger "$@" 135 | ;; 136 | get_result) 137 | get_result 138 | ;; 139 | verify) 140 | verify 141 | ;; 142 | *) 143 | die "Usage: $0 enumerate|trigger|get_result|verify" 144 | esac 145 | exit 0 146 | } 147 | -------------------------------------------------------------------------------- /results/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /summary/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file !.gitignore 4 | -------------------------------------------------------------------------------- /tools/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | $(MAKE) -C ltp-pan 3 | $(MAKE) -C page-types 4 | $(MAKE) -C victim 5 | 6 | install: 7 | $(MAKE) -C ltp-pan install 8 | $(MAKE) -C page-types install 9 | $(MAKE) -C victim install 10 | 11 | clean: 12 | $(MAKE) -C ltp-pan clean 13 | $(MAKE) -C page-types clean 14 | $(MAKE) -C victim clean 15 | -------------------------------------------------------------------------------- /tools/ltp-pan/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS := -g -Wall 2 | 3 | ltp-pan: ltp-pan.o zoolib.o splitstr.o 4 | 5 | install: ltp-pan 6 | cp -f ltp-pan ../../bin 7 | clean: 8 | rm -f *.o ltp-pan 9 | -------------------------------------------------------------------------------- /tools/ltp-pan/splitstr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms of version 2 of the GNU General Public License as 6 | * published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it would be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | * 12 | * Further, this software is distributed without any warranty that it is 13 | * free of the rightful claim of any third person regarding infringement 14 | * or the like. Any license provided herein, whether implied or 15 | * otherwise, applies only to this software file. Patent licenses, if 16 | * any, provided herein do not apply to combinations of this program with 17 | * other software, or any other product whatsoever. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write the Free Software Foundation, Inc., 59 21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. 22 | * 23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 24 | * Mountain View, CA 94043, or: 25 | * 26 | * http://www.sgi.com 27 | * 28 | * For further information regarding this notice, see: 29 | * 30 | * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ 31 | * 32 | */ 33 | /* $Id: splitstr.c,v 1.2 2000/09/21 20:42:31 nstraz Exp $ */ 34 | /* 35 | * Synopsis 36 | * 37 | * const char **splitstr(const char *str, const char *separator, int *argcount) 38 | * 39 | * Description 40 | * This function splits a string (str) into components that are separated by 41 | * one or more of the characters in the (separator) string. An array of 42 | * strings is returned, along with argcount being set to the number of strings 43 | * found. Argcount can be NULL. There will always be a NULL element in the 44 | * array after the last valid element. If an error occurs, NULL will be 45 | * returned and argcount will be set to zero. 46 | * 47 | * To rid yourself of the memory allocated for splitstr(), pass the return 48 | * value from splitstr() unmodified to splitstr_free(): 49 | * 50 | * void splitstr_free( const char ** return_from_splitstr ); 51 | * 52 | */ 53 | #include 54 | #include 55 | #include /* for string functions */ 56 | #ifdef UNIT_TEST 57 | #include 58 | #endif /* UNIT_TEST */ 59 | #include "splitstr.h" 60 | 61 | const char ** 62 | splitstr(const char *str, const char *separator, int *argcount) 63 | { 64 | char *arg_string =NULL, 65 | **arg_array =NULL, 66 | *cur_tok =NULL; 67 | 68 | int num_toks =0, 69 | max_toks =20, 70 | i; 71 | 72 | /* 73 | * In most recoverable errors, if argcount is not NULL, 74 | * set argcount to 0. Then return NULL. 75 | */ 76 | if ( str == NULL ) 77 | { 78 | if ( argcount != NULL ) 79 | *argcount = 0; 80 | return(NULL); 81 | } 82 | 83 | /* 84 | * set aside temporary space to work on the string. 85 | */ 86 | arg_string = strdup( str ); 87 | 88 | if ( arg_string == NULL ) 89 | { 90 | if ( argcount != NULL ) 91 | *argcount = 0; 92 | return(NULL); 93 | } 94 | 95 | /* 96 | * set aside an initial char ** array for string array. 97 | */ 98 | arg_array = (char **)malloc( sizeof(char *) * max_toks ); 99 | 100 | if ( arg_array == NULL ) 101 | { 102 | if ( argcount != NULL ) 103 | *argcount = 0; 104 | return(NULL); 105 | } 106 | 107 | if(separator==NULL) 108 | separator = " \t"; 109 | 110 | /* 111 | * Use strtok() to parse 'arg_string', placing pointers to the 112 | * individual tokens into the elements of 'arg_array'. Expand 113 | * 'arg_array' if necessary. 114 | */ 115 | cur_tok = strtok(arg_string, separator); 116 | while ( cur_tok != NULL ) 117 | { 118 | arg_array[num_toks++] = cur_tok; 119 | cur_tok = strtok(NULL, separator); 120 | if ( num_toks == max_toks ) 121 | { 122 | max_toks += 20; 123 | arg_array = (char **)realloc((void *)arg_array, sizeof(char *)*max_toks ); 124 | } 125 | } 126 | arg_array[num_toks] = NULL; 127 | 128 | /* 129 | * If there are any spaces left in our array, make them NULL 130 | */ 131 | for(i=num_toks+1;i 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | typedef FILE *zoo_t; 45 | #define ZELEN 512 46 | extern char zoo_error[ZELEN]; 47 | #define BUFLEN 81 48 | 49 | int lock_file( FILE *fp, short ltype, char **errmsg ); 50 | /* FILE *open_file( char *file, char *mode, char **errmsg ); */ 51 | 52 | void wait_handler(); 53 | 54 | /* char *zoo_active( void ); */ 55 | /* zoo_getname(): create a filename to use for the zoo 56 | * returns NULL on error */ 57 | char *zoo_getname(void); 58 | 59 | /* zoo_open(): open a zoo file for use 60 | * returns NULL on error */ 61 | zoo_t zoo_open(char *zooname); 62 | 63 | /* zoo_close(): close an open zoo file */ 64 | int zoo_close(zoo_t z); 65 | 66 | /* zoo_mark_cmdline(): make an entry to the zoo 67 | * returns 0 on success, -1 on error */ 68 | int zoo_mark_cmdline(zoo_t z, pid_t p, char *tag, char *cmdline); 69 | 70 | /* zoo_mark_args(): make an entry to the zoo using argc argv 71 | * returns 0 on success, -1 on error */ 72 | int zoo_mark_args(zoo_t z, pid_t p, char *tag, int ac, char **av); 73 | 74 | /* zoo_clear(): mark a pid as completed 75 | * returns 0 on success, -1 on error, 1 as warning */ 76 | int zoo_clear(zoo_t z, pid_t p); 77 | 78 | /* zoo_getpid(): get the pid for a specified tag 79 | * returns pid_t on success and 0 on error */ 80 | pid_t zoo_getpid(zoo_t z, char *tag); 81 | 82 | 83 | #endif /* ZOOLIB_H */ 84 | -------------------------------------------------------------------------------- /tools/page-types/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS := -g -Wall 2 | 3 | page-types: page-types.o 4 | 5 | install: page-types 6 | cp -f page-types ../../bin 7 | 8 | clean: 9 | rm -f page-types *.o 10 | -------------------------------------------------------------------------------- /tools/page-types/debugfs.h: -------------------------------------------------------------------------------- 1 | #ifndef __API_DEBUGFS_H__ 2 | #define __API_DEBUGFS_H__ 3 | 4 | #include "findfs.h" 5 | 6 | #ifndef DEBUGFS_MAGIC 7 | #define DEBUGFS_MAGIC 0x64626720 8 | #endif 9 | 10 | #ifndef PERF_DEBUGFS_ENVIRONMENT 11 | #define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR" 12 | #endif 13 | 14 | bool debugfs_configured(void); 15 | const char *debugfs_find_mountpoint(void); 16 | char *debugfs_mount(const char *mountpoint); 17 | 18 | extern char debugfs_mountpoint[]; 19 | 20 | int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename); 21 | int debugfs__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name); 22 | 23 | #endif /* __API_DEBUGFS_H__ */ 24 | -------------------------------------------------------------------------------- /tools/page-types/findfs.h: -------------------------------------------------------------------------------- 1 | #ifndef __API_FINDFS_H__ 2 | #define __API_FINDFS_H__ 3 | 4 | #include 5 | 6 | #define _STR(x) #x 7 | #define STR(x) _STR(x) 8 | 9 | /* 10 | * On most systems would have given us this, but not on some systems 11 | * (e.g. GNU/Hurd). 12 | */ 13 | #ifndef PATH_MAX 14 | #define PATH_MAX 4096 15 | #endif 16 | 17 | const char *find_mountpoint(const char *fstype, long magic, 18 | char *mountpoint, int len, 19 | const char * const *known_mountpoints); 20 | 21 | int valid_mountpoint(const char *mount, long magic); 22 | 23 | #endif /* __API_FINDFS_H__ */ 24 | -------------------------------------------------------------------------------- /tools/page-types/kernel-page-flags.h: -------------------------------------------------------------------------------- 1 | #ifndef _UAPILINUX_KERNEL_PAGE_FLAGS_H 2 | #define _UAPILINUX_KERNEL_PAGE_FLAGS_H 3 | 4 | /* 5 | * Stable page flag bits exported to user space 6 | */ 7 | 8 | #define KPF_LOCKED 0 9 | #define KPF_ERROR 1 10 | #define KPF_REFERENCED 2 11 | #define KPF_UPTODATE 3 12 | #define KPF_DIRTY 4 13 | #define KPF_LRU 5 14 | #define KPF_ACTIVE 6 15 | #define KPF_SLAB 7 16 | #define KPF_WRITEBACK 8 17 | #define KPF_RECLAIM 9 18 | #define KPF_BUDDY 10 19 | 20 | /* 11-20: new additions in 2.6.31 */ 21 | #define KPF_MMAP 11 22 | #define KPF_ANON 12 23 | #define KPF_SWAPCACHE 13 24 | #define KPF_SWAPBACKED 14 25 | #define KPF_COMPOUND_HEAD 15 26 | #define KPF_COMPOUND_TAIL 16 27 | #define KPF_HUGE 17 28 | #define KPF_UNEVICTABLE 18 29 | #define KPF_HWPOISON 19 30 | #define KPF_NOPAGE 20 31 | 32 | #define KPF_KSM 21 33 | #define KPF_THP 22 34 | #define KPF_BALLOON 23 35 | #define KPF_ZERO_PAGE 24 36 | #define KPF_IDLE 25 37 | 38 | 39 | #endif /* _UAPILINUX_KERNEL_PAGE_FLAGS_H */ 40 | -------------------------------------------------------------------------------- /tools/page-types/magic.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_MAGIC_H__ 2 | #define __LINUX_MAGIC_H__ 3 | 4 | #define ADFS_SUPER_MAGIC 0xadf5 5 | #define AFFS_SUPER_MAGIC 0xadff 6 | #define AFS_SUPER_MAGIC 0x5346414F 7 | #define AUTOFS_SUPER_MAGIC 0x0187 8 | #define CODA_SUPER_MAGIC 0x73757245 9 | #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */ 10 | #define CRAMFS_MAGIC_WEND 0x453dcd28 /* magic number with the wrong endianess */ 11 | #define DEBUGFS_MAGIC 0x64626720 12 | #define SECURITYFS_MAGIC 0x73636673 13 | #define SELINUX_MAGIC 0xf97cff8c 14 | #define SMACK_MAGIC 0x43415d53 /* "SMAC" */ 15 | #define RAMFS_MAGIC 0x858458f6 /* some random number */ 16 | #define TMPFS_MAGIC 0x01021994 17 | #define HUGETLBFS_MAGIC 0x958458f6 /* some random number */ 18 | #define SQUASHFS_MAGIC 0x73717368 19 | #define ECRYPTFS_SUPER_MAGIC 0xf15f 20 | #define EFS_SUPER_MAGIC 0x414A53 21 | #define EXT2_SUPER_MAGIC 0xEF53 22 | #define EXT3_SUPER_MAGIC 0xEF53 23 | #define XENFS_SUPER_MAGIC 0xabba1974 24 | #define EXT4_SUPER_MAGIC 0xEF53 25 | #define BTRFS_SUPER_MAGIC 0x9123683E 26 | #define NILFS_SUPER_MAGIC 0x3434 27 | #define F2FS_SUPER_MAGIC 0xF2F52010 28 | #define HPFS_SUPER_MAGIC 0xf995e849 29 | #define ISOFS_SUPER_MAGIC 0x9660 30 | #define JFFS2_SUPER_MAGIC 0x72b6 31 | #define PSTOREFS_MAGIC 0x6165676C 32 | #define EFIVARFS_MAGIC 0xde5e81e4 33 | #define HOSTFS_SUPER_MAGIC 0x00c0ffee 34 | 35 | #define MINIX_SUPER_MAGIC 0x137F /* minix v1 fs, 14 char names */ 36 | #define MINIX_SUPER_MAGIC2 0x138F /* minix v1 fs, 30 char names */ 37 | #define MINIX2_SUPER_MAGIC 0x2468 /* minix v2 fs, 14 char names */ 38 | #define MINIX2_SUPER_MAGIC2 0x2478 /* minix v2 fs, 30 char names */ 39 | #define MINIX3_SUPER_MAGIC 0x4d5a /* minix v3 fs, 60 char names */ 40 | 41 | #define MSDOS_SUPER_MAGIC 0x4d44 /* MD */ 42 | #define NCP_SUPER_MAGIC 0x564c /* Guess, what 0x564c is :-) */ 43 | #define NFS_SUPER_MAGIC 0x6969 44 | #define OPENPROM_SUPER_MAGIC 0x9fa1 45 | #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */ 46 | #define QNX6_SUPER_MAGIC 0x68191122 /* qnx6 fs detection */ 47 | 48 | #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */ 49 | /* used by file system utilities that 50 | look at the superblock, etc. */ 51 | #define REISERFS_SUPER_MAGIC_STRING "ReIsErFs" 52 | #define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs" 53 | #define REISER2FS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs" 54 | 55 | #define SMB_SUPER_MAGIC 0x517B 56 | #define CGROUP_SUPER_MAGIC 0x27e0eb 57 | 58 | 59 | #define STACK_END_MAGIC 0x57AC6E9D 60 | 61 | #define TRACEFS_MAGIC 0x74726163 62 | 63 | #define V9FS_MAGIC 0x01021997 64 | 65 | #define BDEVFS_MAGIC 0x62646576 66 | #define BINFMTFS_MAGIC 0x42494e4d 67 | #define DEVPTS_SUPER_MAGIC 0x1cd1 68 | #define FUTEXFS_SUPER_MAGIC 0xBAD1DEA 69 | #define PIPEFS_MAGIC 0x50495045 70 | #define PROC_SUPER_MAGIC 0x9fa0 71 | #define SOCKFS_MAGIC 0x534F434B 72 | #define SYSFS_MAGIC 0x62656572 73 | #define USBDEVICE_SUPER_MAGIC 0x9fa2 74 | #define MTD_INODE_FS_MAGIC 0x11307854 75 | #define ANON_INODE_FS_MAGIC 0x09041934 76 | #define BTRFS_TEST_MAGIC 0x73727279 77 | #define NSFS_MAGIC 0x6e736673 78 | 79 | #endif /* __LINUX_MAGIC_H__ */ 80 | -------------------------------------------------------------------------------- /tools/scripts/gcov_merge.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Merge gcov graph from several test cases. This can be used to check 4 | # the coverage of several test cases. 5 | # 6 | # Copyright (C) 2008, Intel Corp. 7 | # Author: Huang Ying 8 | # 9 | # This file is released under the GPLv2. 10 | 11 | import sys 12 | 13 | def die(str): 14 | print str 15 | sys.exit(-1) 16 | 17 | def die_on(cond, str): 18 | if cond: 19 | die(str) 20 | 21 | class GCovLine(object): 22 | def __init__(self, l): 23 | object.__init__(self) 24 | self.parse(l) 25 | def parse(self, l): 26 | sep = l.find(':') 27 | die_on(sep <= 0, 'input error format error') 28 | remain = l[sep:] 29 | scnt = l[:sep] 30 | if scnt[-1] == '-': 31 | count = -1 32 | elif scnt[-1] == '#': 33 | count = 0 34 | else: 35 | count = int(scnt) 36 | self.sep = sep 37 | self.count = count 38 | self.remain = remain 39 | def merge(self, gcl): 40 | self.count = self.count + gcl.count 41 | def write(self, of): 42 | if self.count < 0: 43 | of.write("%*s" % (self.sep, '-')) 44 | elif self.count == 0: 45 | of.write("%*s" % (self.sep, '#####')) 46 | else: 47 | of.write("%*d" % (self.sep, self.count)) 48 | of.write(self.remain) 49 | 50 | def parse(f): 51 | return [GCovLine(l) for l in f] 52 | 53 | def merge(gcls1, gcls2): 54 | for gcl1, gcl2 in zip(gcls1, gcls2): 55 | gcl1.merge(gcl2) 56 | 57 | def gcov_merge(fns, of): 58 | f = file(fns[0]) 59 | gcls_base = parse(f) 60 | 61 | for fn in fns[1:]: 62 | f = file(fn) 63 | gcls = parse(f) 64 | merge(gcls_base, gcls) 65 | 66 | for gcl in gcls_base: 67 | gcl.write(of) 68 | 69 | def usage(): 70 | print 'Usage: %s ' % (sys.argv[0]) 71 | 72 | if __name__ == '__main__': 73 | if len(sys.argv) <= 1: 74 | usage() 75 | exit -1 76 | gcov_merge(sys.argv[1:], sys.stdout) 77 | -------------------------------------------------------------------------------- /tools/scripts/grep_result.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Filter out specified test case results from all results. 4 | # 5 | # Copyright (C) 2008, Intel Corp. 6 | # Author: Huang Ying 7 | # 8 | # This file is released under the GPLv2. 9 | # 10 | 11 | tr '\n' '|' | sed -e '1,$s/||/\n/g' | grep "$@" | sed -e '/^$/d' | \ 12 | sed -e '1,$s/^|\?\([^|].*[^|]\)|\?$/\1/' | sed -e '1,$i\ ' | tr '|' '\n' 13 | -------------------------------------------------------------------------------- /tools/scripts/loop-mce-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Run mce test cases in a loop. It exits on failure of any one of the test cases. 4 | # This script is using simple test driver. 5 | # 6 | # Authors: Dean Nelson 7 | # iZheng Jiajia 8 | # This file is released under the GPLv2. 9 | # 10 | # Usage: 11 | #Run as root and invoke this test tool on test configure file. 12 | #For example, ./loop-mce-test simple_ser.conf 13 | #Note that only simple test configure file is used and full path is not needed here. 14 | 15 | sd=$(dirname "$0") 16 | export ROOT=`(cd $sd/..; pwd)` 17 | prog=$(basename "$0") 18 | 19 | usage() 20 | { 21 | echo "$prog " 22 | exit 1 23 | } 24 | 25 | . $ROOT/lib/functions.sh 26 | 27 | [ $# -eq 1 ] || usage 28 | config=$(basename "$1") 29 | [ -f $ROOT/config/$config ] || usage 30 | 31 | i=0 32 | while true ; do 33 | ((i=i+1)) 34 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!! loop $i" 35 | rm $ROOT/results/simple/result 36 | 37 | sh $ROOT/drivers/simple/driver.sh $ROOT/config/$1 38 | 39 | sed -e'/gcov/d' $ROOT/results/simple/result | grep "Fail" > /dev/null 40 | if [ $? = 0 ] ; then 41 | echo "failed on loop $i" 42 | exit 1 43 | fi 44 | done 45 | 46 | -------------------------------------------------------------------------------- /tools/scripts/mce_shell.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Simulate the environment of mce-test driver or test case shell 4 | # script, used for debugging. You can invoking mce-test library 5 | # functions directly in shell created. 6 | # 7 | # Copyright (C) 2009, Intel Corp. 8 | # Author: Huang Ying 9 | # 10 | # This file is released under the GPLv2. 11 | # 12 | 13 | sd=$(dirname "$0") 14 | export ROOT=`(cd $sd/..; pwd)` 15 | 16 | if [ $# -eq 1 ]; then 17 | export driver=$1 18 | else 19 | export driver=simple 20 | fi 21 | 22 | tmpfile=$(mktemp) 23 | 24 | trap "rm $tmpfile" EXIT 25 | 26 | cat <<"EOF" > $tmpfile 27 | if [ -f /etc/bash.bashrc ]; then 28 | source /etc/bash.bashrc 29 | fi 30 | 31 | if [ -f $HOME/.bashrc ]; then 32 | source $HOME/.bashrc 33 | fi 34 | 35 | . $ROOT/lib/functions.sh 36 | setup_path 37 | . $ROOT/lib/dirs.sh 38 | . $ROOT/lib/mce.sh 39 | . $ROOT/lib/soft-inject.sh 40 | 41 | export PS1="MDE $driver: " 42 | 43 | echo "-----------------------------------------------------" 44 | echo "| MCE-test shell, You can use mce internal function |" 45 | echo "-----------------------------------------------------" 46 | EOF 47 | 48 | export PS1="MCE $driver: " 49 | /bin/bash --rcfile $tmpfile 50 | rm $tmpfile 51 | -------------------------------------------------------------------------------- /tools/scripts/scov_merge.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Merge mce serverity coverage file from several test cases. This can 4 | # be used to check the coverage of several test cases. 5 | # 6 | # Copyright (C) 2009, Intel Corp. 7 | # Author: Huang Ying 8 | # 9 | # This file is released under the GPLv2. 10 | 11 | import sys 12 | 13 | def die(str): 14 | print str 15 | sys.exit(-1) 16 | 17 | def die_on(cond, str): 18 | if cond: 19 | die(str) 20 | 21 | class SCovLine(object): 22 | def __init__(self, l): 23 | object.__init__(self) 24 | self.parse(l) 25 | def parse(self, l): 26 | sep = l.find('\t') 27 | die_on(sep <= 0, 'input error format error') 28 | remain = l[sep:] 29 | scnt = l[:sep] 30 | count = int(scnt) 31 | self.count = count 32 | self.remain = remain 33 | def merge(self, gcl): 34 | self.count = self.count + gcl.count 35 | def write(self, of): 36 | if self.count == 0: 37 | of.write("0") 38 | else: 39 | of.write("1") 40 | of.write(self.remain) 41 | 42 | def parse(f): 43 | return [SCovLine(l) for l in f] 44 | 45 | def merge(gcls1, gcls2): 46 | for gcl1, gcl2 in zip(gcls1, gcls2): 47 | gcl1.merge(gcl2) 48 | 49 | def scov_merge(fns, of): 50 | f = file(fns[0]) 51 | gcls_base = parse(f) 52 | 53 | for fn in fns[1:]: 54 | f = file(fn) 55 | gcls = parse(f) 56 | merge(gcls_base, gcls) 57 | 58 | for gcl in gcls_base: 59 | gcl.write(of) 60 | 61 | def usage(): 62 | print 'Usage: %s ' % (sys.argv[0]) 63 | 64 | if __name__ == '__main__': 65 | if len(sys.argv) <= 1: 66 | usage() 67 | exit -1 68 | scov_merge(sys.argv[1:], sys.stdout) 69 | -------------------------------------------------------------------------------- /tools/victim/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS := -g -Wall 2 | 3 | all: victim.o 4 | 5 | install: victim 6 | cp -f victim ../../bin 7 | 8 | clean: 9 | rm -f victim *.o 10 | -------------------------------------------------------------------------------- /work/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | --------------------------------------------------------------------------------