@@ -604,13 +604,27 @@ done
604604 SSTTFHPScriptName : {
605605 Name : SSTTFHPScriptName ,
606606 ScriptTemplate : `# Is SST-TF supported?
607- supported=$(pcm-tpmi 5 0xF8 -d -b 12:12 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}')
607+ if ! supported=$(pcm-tpmi 5 0xF8 -d -b 12:12 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}'); then
608+ echo "Error: Failed to check if SST-TF is supported" >&2
609+ exit 1
610+ fi
611+ if [[ ! "$supported" =~ ^[0-9]+$ ]]; then
612+ echo "Error: Invalid output from pcm-tpmi when checking support" >&2
613+ exit 1
614+ fi
608615if [ "$supported" -eq 0 ]; then
609616 echo "SST-TF is not supported"
610617 exit 0
611618fi
612619# Is SST-TF enabled?
613- enabled=$(pcm-tpmi 5 0x78 -d -b 9:9 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}')
620+ if ! enabled=$(pcm-tpmi 5 0x78 -d -b 9:9 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}'); then
621+ echo "Error: Failed to check if SST-TF is enabled" >&2
622+ exit 1
623+ fi
624+ if [[ ! "$enabled" =~ ^[0-9]+$ ]]; then
625+ echo "Error: Invalid output from pcm-tpmi when checking enabled status" >&2
626+ exit 1
627+ fi
614628if [ "$enabled" -eq 0 ]; then
615629 echo "SST-TF is not enabled"
616630 exit 0
622636 # Get the # of cores in this bucket
623637 bithigh=$((i*8+7))
624638 bitlow=$((i*8))
625- numcores=$(pcm-tpmi 5 0x100 -d -b $bithigh:$bitlow -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}')
639+ if ! numcores=$(pcm-tpmi 5 0x100 -d -b $bithigh:$bitlow -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}'); then
640+ echo "Error: Failed to get number of cores for bucket $i" >&2
641+ exit 1
642+ fi
643+ if [[ ! "$numcores" =~ ^[0-9]+$ ]]; then
644+ echo "Error: Invalid output from pcm-tpmi when getting number of cores for bucket $i" >&2
645+ exit 1
646+ fi
626647 # if the number of cores is 0, skip this bucket
627648 if [ "$numcores" -eq 0 ]; then
628649 continue
634655 # 5 isa frequencies per bucket (AVX, AVX2, AVX-512, AVX-512 heavy, AMX)
635656 for((j=0; j<5; j++))
636657 do
637- offset=$((j*8 + 264)) // 264 is 0x108 (SST_TF_INFO_2) AVX
638- freq=$(pcm-tpmi 5 $offset -d -b $bithigh:$bitlow -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}')
658+ offset=$((j*8 + 264)) # 264 is 0x108 (SST_TF_INFO_2) AVX
659+ if ! freq=$(pcm-tpmi 5 $offset -d -b $bithigh:$bitlow -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}'); then
660+ echo "Error: Failed to get frequency for instruction set $j in bucket $i" >&2
661+ exit 1
662+ fi
663+ if [[ ! "$freq" =~ ^[0-9]+$ ]]; then
664+ echo "Error: Invalid frequency value for instruction set $j in bucket $i" >&2
665+ exit 1
666+ fi
639667 echo -n "$freq"
640668 if [ $j -lt 4 ]; then
641669 echo -n ","
@@ -653,13 +681,29 @@ done
653681 SSTTFLPScriptName : {
654682 Name : SSTTFLPScriptName ,
655683 ScriptTemplate : `# Is SST-TF supported?
656- supported=$(pcm-tpmi 5 0xF8 -d -b 12:12 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}')
684+ if ! supported=$(pcm-tpmi 5 0xF8 -d -b 12:12 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}'); then
685+ echo "Error: Failed to check if SST-TF is supported" >&2
686+ exit 1
687+ fi
688+ if [[ ! "$supported" =~ ^[0-9]+$ ]]; then
689+ echo "Error: Invalid output from pcm-tpmi when checking support" >&2
690+ exit 1
691+ fi
692+
657693if [ "$supported" -eq 0 ]; then
658694 echo "SST-TF is not supported"
659695 exit 0
660696fi
661697# Is SST-TF enabled?
662- enabled=$(pcm-tpmi 5 0x78 -d -b 9:9 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}')
698+ if ! enabled=$(pcm-tpmi 5 0x78 -d -b 9:9 -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}'); then
699+ echo "Error: Failed to check if SST-TF is enabled" >&2
700+ exit 1
701+ fi
702+ if [[ ! "$enabled" =~ ^[0-9]+$ ]]; then
703+ echo "Error: Invalid output from pcm-tpmi when checking enabled status" >&2
704+ exit 1
705+ fi
706+
663707if [ "$enabled" -eq 0 ]; then
664708 echo "SST-TF is not enabled"
665709 exit 0
@@ -670,7 +714,14 @@ for((j=0; j<5; j++))
670714do
671715 bithigh=$((j*8+23))
672716 bitlow=$((j*8+16))
673- freq=$(pcm-tpmi 5 0xF8 -d -b $bithigh:$bitlow -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}')
717+ if ! freq=$(pcm-tpmi 5 0xF8 -d -b $bithigh:$bitlow -i 0 -e 0 | tail -n 2 | head -n 1 | awk '{print $5}'); then
718+ echo "Error: Failed to get frequency for instruction set $j" >&2
719+ exit 1
720+ fi
721+ if [[ ! "$freq" =~ ^[0-9]+$ ]]; then
722+ echo "Error: Invalid frequency value for instruction set $j" >&2
723+ exit 1
724+ fi
674725 echo -n "$freq"
675726 if [ $j -ne 4 ]; then
676727 echo -n ","
0 commit comments