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_dom0 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-d domainID\t: 0" 31 echo -e "\t-c injcpu\t: which cpu to inject error" 32 echo -e "\t-p pageaddr\t: Guest Physical Address to inject error" 33 echo -e "\t\t\tBy default, the GPA is 0x180020" 34 echo -e "\t-h help" 35 exit 0 36} 37 38while getopts ":c:d:p:h" option 39do 40 case "$option" in 41 c) injcpu=$OPTARG;; 42 d) domid=$OPTARG;; 43 p) pageaddr=$OPTARG;; 44 h) usage;; 45 *) echo "invalid option!"; usage;; 46 esac 47done 48 49[ -z $domid ] && domid=0 50 51inject() 52{ 53 mce_inject_trigger $MCE_SRAO_MEM -d $domid -u $injcpu -p $pageaddr 54 if [ $? -eq 0 ]; then 55 show " Passed: Successfully to fake and inject a MCE error" 56 else 57 show " Failed: Fake error and inject fail !!" 58 return 1 59 fi 60 return 0 61} 62 63do_main() 64{ 65 ret_val=0 66 clean_env 67 inject || ret_val=1 68 xen_verify || ret_val=1 69 mcelog_verify $MCE_SRAO_MEM || ret_val=1 70 gen_result $ret_val 71} 72 73do_main "$@" 74