0001
0002
0003
0004 TIMEOUT=30
0005
0006 DEBUFS_DIR=`cat /proc/mounts | grep debugfs | awk '{print $2}'`
0007 if [ ! -e "$DEBUFS_DIR" ]
0008 then
0009 echo "debugfs not found, skipping" 1>&2
0010 exit 4
0011 fi
0012
0013 if [ ! -e "$DEBUFS_DIR/tracing/current_tracer" ]
0014 then
0015 echo "Tracing files not found, skipping" 1>&2
0016 exit 4
0017 fi
0018
0019
0020 echo "Testing for spurious faults when mapping kernel memory..."
0021
0022 if grep -q "FUNCTION TRACING IS CORRUPTED" "$DEBUFS_DIR/tracing/trace"
0023 then
0024 echo "FAILED: Ftrace already dead. Probably due to a spurious fault" 1>&2
0025 exit 1
0026 fi
0027
0028 dmesg -C
0029 START_TIME=`date +%s`
0030 END_TIME=`expr $START_TIME + $TIMEOUT`
0031 while [ `date +%s` -lt $END_TIME ]
0032 do
0033 echo function > $DEBUFS_DIR/tracing/current_tracer
0034 echo nop > $DEBUFS_DIR/tracing/current_tracer
0035 if dmesg | grep -q 'ftrace bug'
0036 then
0037 break
0038 fi
0039 done
0040
0041 echo nop > $DEBUFS_DIR/tracing/current_tracer
0042 if dmesg | grep -q 'ftrace bug'
0043 then
0044 echo "FAILED: Mapping kernel memory causes spurious faults" 1>&2
0045 exit 1
0046 else
0047 echo "OK: Mapping kernel memory does not cause spurious faults"
0048 exit 0
0049 fi