1#!/bin/bash 2# 3# Copyright (c) 2010, Intel Corporation 4# 5# This program is free software; you can redistribute it and/or 6# modify it under the terms of the GNU General Public License version 7# 2 as published by the Free Software Foundation. 8# 9# This program is distributed in the hope that it will be useful, but 10# 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 have received a copy of the GNU General Public License 15# along with this program; If not, see <http://www.gnu.org/licenses/>. 16# 17# Author: Xudong Hao <xudong.hao@intel.com> 18# 19 20sd=$(dirname $0) 21export ROOT=`(cd $sd/../../../; pwd)` 22export this_case=srao_mem_xen 23 24. $ROOT/lib/xen-mceinj-tool.sh 25 26usage() 27{ 28 echo "Usage: ./cases.sh [-options] [arguments]" 29 echo "================Below are the optional options================" 30 echo -e "\t-c injcpu\t: which cpu to inject error" 31 echo -e "\t-p pageaddr\t: Guest Physical Address to inject error" 32 echo -e "\t\t\tBy default, the GPA is 0x180020" 33 echo -e "\t-h help" 34 exit 0 35} 36 37while getopts ":c:p:h" option 38do 39 case "$option" in 40 c) injcpu=$OPTARG;; 41 p) pageaddr=$OPTARG;; 42 h) usage;; 43 *) echo "invalid option!"; usage;; 44 esac 45done 46 47inject() 48{ 49 mce_inject_trigger $MCE_SRAO_MEM -u $injcpu -p $pageaddr 50 if [ $? -eq 0 ]; then 51 show " Passed: Successfully to fake and inject a MCE error" 52 else 53 show " Failed: Fake error and inject fail !!" 54 return 1 55 fi 56 return 0 57} 58 59do_main() 60{ 61 ret_val=0 62 clean_env 63 inject || ret_val=1 64 xen_verify || ret_val=1 65 mcelog_verify $MCE_SRAO_MEM || ret_val=1 66 gen_result $ret_val 67} 68 69do_main "$@" 70