brintos

brintos / linux-shallow public Read only

0
0
Text · 1.0 KiB · e454509 Raw
50 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.0-or-later3 4TIMEOUT=305 6DEBUFS_DIR=`cat /proc/mounts | grep debugfs | awk '{print $2}'`7if [ ! -e "$DEBUFS_DIR" ]8then9	echo "debugfs not found, skipping" 1>&210	exit 411fi12 13if [ ! -e "$DEBUFS_DIR/tracing/current_tracer" ]14then15	echo "Tracing files not found, skipping" 1>&216	exit 417fi18 19 20echo "Testing for spurious faults when mapping kernel memory..."21 22if grep -q "FUNCTION TRACING IS CORRUPTED" "$DEBUFS_DIR/tracing/trace"23then24	echo "FAILED: Ftrace already dead. Probably due to a spurious fault" 1>&225	exit 126fi27 28dmesg -C29START_TIME=`date +%s`30END_TIME=`expr $START_TIME + $TIMEOUT`31while [ `date +%s` -lt $END_TIME ]32do33	echo function > $DEBUFS_DIR/tracing/current_tracer34	echo nop > $DEBUFS_DIR/tracing/current_tracer35	if dmesg | grep -q 'ftrace bug'36	then37		break38	fi39done40 41echo nop > $DEBUFS_DIR/tracing/current_tracer42if dmesg | grep -q 'ftrace bug'43then44	echo "FAILED: Mapping kernel memory causes spurious faults" 1>&245	exit 146else47	echo "OK: Mapping kernel memory does not cause spurious faults"48	exit 049fi50