83 lines · bash
1#!/bin/sh2# SPDX-License-Identifier: GPL-2.0-only3#4# Copyright 2015, Daniel Axtens, IBM Corporation5#6 7 8# do we have ./getscom, ./putscom?9if [ -x ./getscom ] && [ -x ./putscom ]; then10 GETSCOM=./getscom11 PUTSCOM=./putscom12elif which getscom > /dev/null; then13 GETSCOM=$(which getscom)14 PUTSCOM=$(which putscom)15else16 cat <<EOF17Can't find getscom/putscom in . or \$PATH.18See https://github.com/open-power/skiboot.19The tool is in external/xscom-utils20EOF21 exit 122fi23 24# We will get 8 HMI events per injection25# todo: deal with things being offline26expected_hmis=827COUNT_HMIS() {28 dmesg | grep -c 'Harmless Hypervisor Maintenance interrupt'29}30 31# massively expand snooze delay, allowing injection on all cores32ppc64_cpu --smt-snooze-delay=100000000033 34# when we exit, restore it35trap "ppc64_cpu --smt-snooze-delay=100" 0 136 37# for each chip+core combination38# todo - less fragile parsing39grep -E -o 'OCC: Chip [0-9a-f]+ Core [0-9a-f]' < /sys/firmware/opal/msglog |40while read chipcore; do41 chip=$(echo "$chipcore"|awk '{print $3}')42 core=$(echo "$chipcore"|awk '{print $5}')43 fir="0x1${core}013100"44 45 # verify that Core FIR is zero as expected46 if [ "$($GETSCOM -c 0x${chip} $fir)" != 0 ]; then47 echo "FIR was not zero before injection for chip $chip, core $core. Aborting!"48 echo "Result of $GETSCOM -c 0x${chip} $fir:"49 $GETSCOM -c 0x${chip} $fir50 echo "If you get a -5 error, the core may be in idle state. Try stress-ng."51 echo "Otherwise, try $PUTSCOM -c 0x${chip} $fir 0"52 exit 153 fi54 55 # keep track of the number of HMIs handled56 old_hmis=$(COUNT_HMIS)57 58 # do injection, adding a marker to dmesg for clarity59 echo "Injecting HMI on core $core, chip $chip" | tee /dev/kmsg60 # inject a RegFile recoverable error61 if ! $PUTSCOM -c 0x${chip} $fir 2000000000000000 > /dev/null; then62 echo "Error injecting. Aborting!"63 exit 164 fi65 66 # now we want to wait for all the HMIs to be processed67 # we expect one per thread on the core68 i=0;69 new_hmis=$(COUNT_HMIS)70 while [ $new_hmis -lt $((old_hmis + expected_hmis)) ] && [ $i -lt 12 ]; do71 echo "Seen $((new_hmis - old_hmis)) HMI(s) out of $expected_hmis expected, sleeping"72 sleep 5;73 i=$((i + 1))74 new_hmis=$(COUNT_HMIS)75 done76 if [ $i = 12 ]; then77 echo "Haven't seen expected $expected_hmis recoveries after 1 min. Aborting."78 exit 179 fi80 echo "Processed $expected_hmis events; presumed success. Check dmesg."81 echo ""82done83