cleanup. fixing warnings from shellcheck
This commit is contained in:
parent
2282910d06
commit
42f3f66d5c
|
@ -1061,15 +1061,15 @@ sys_interface_check()
|
||||||
|
|
||||||
number_of_cpus()
|
number_of_cpus()
|
||||||
{
|
{
|
||||||
n=$(cat /proc/cpuinfo | grep processor| wc -l)
|
n=$(grep -c ^processor /proc/cpuinfo)
|
||||||
return $n
|
return "$n"
|
||||||
}
|
}
|
||||||
|
|
||||||
# $1 - msr number
|
# $1 - msr number
|
||||||
# $2 - cpu index
|
# $2 - cpu index
|
||||||
check_msr_enable()
|
check_msr_enable()
|
||||||
{
|
{
|
||||||
dd if=/dev/cpu/$2/msr of=/dev/null bs=8 count=1 skip=$1 iflag=skip_bytes 2>/dev/null; ret=$?
|
dd if=/dev/cpu/"$2"/msr of=/dev/null bs=8 count=1 skip="$1" iflag=skip_bytes 2>/dev/null; ret=$?
|
||||||
return $ret
|
return $ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1078,7 +1078,7 @@ check_msr_enable()
|
||||||
# $3 - value
|
# $3 - value
|
||||||
write_to_msr()
|
write_to_msr()
|
||||||
{
|
{
|
||||||
$echo_cmd -ne $3 | dd of=/dev/cpu/$2/msr bs=8 count=1 seek=$1 oflag=seek_bytes 2>/dev/null; ret=$?
|
$echo_cmd -ne "$3" | dd of=/dev/cpu/"$2"/msr bs=8 count=1 seek="$1" oflag=seek_bytes 2>/dev/null; ret=$?
|
||||||
return $ret
|
return $ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1086,8 +1086,8 @@ write_to_msr()
|
||||||
# $2 - cpu index
|
# $2 - cpu index
|
||||||
read_msr()
|
read_msr()
|
||||||
{
|
{
|
||||||
msr=$(dd if=/dev/cpu/$2/msr bs=8 count=1 skip=$1 iflag=skip_bytes 2>/dev/null | od -t u1 -A n | awk '{print $8}');
|
msr=$(dd if=/dev/cpu/"$2"/msr bs=8 count=1 skip="$1" iflag=skip_bytes 2>/dev/null | od -t u1 -A n | awk '{print $8}');
|
||||||
return msr
|
return "$msr"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1100,7 +1100,7 @@ check_cpu()
|
||||||
_info_nol " * SPEC_CTRL MSR is available: "
|
_info_nol " * SPEC_CTRL MSR is available: "
|
||||||
number_of_cpus
|
number_of_cpus
|
||||||
ncpus=$?
|
ncpus=$?
|
||||||
idx_max_cpu=$(($ncpus-1))
|
idx_max_cpu=$((ncpus-1))
|
||||||
if [ ! -e /dev/cpu/0/msr ]; then
|
if [ ! -e /dev/cpu/0/msr ]; then
|
||||||
# try to load the module ourselves (and remember it so we can rmmod it afterwards)
|
# try to load the module ourselves (and remember it so we can rmmod it afterwards)
|
||||||
load_msr
|
load_msr
|
||||||
|
@ -1115,14 +1115,14 @@ check_cpu()
|
||||||
# skip=9 because 8*9=72=0x48
|
# skip=9 because 8*9=72=0x48
|
||||||
val=0
|
val=0
|
||||||
cpu_mismatch=0
|
cpu_mismatch=0
|
||||||
for i in $(seq 0 $idx_max_cpu)
|
for i in $(seq 0 "$idx_max_cpu")
|
||||||
do
|
do
|
||||||
check_msr_enable 72 $i
|
check_msr_enable 72 "$i"
|
||||||
ret=$?
|
ret=$?
|
||||||
if [ $i -eq 0 ]; then
|
if [ "$i" -eq 0 ]; then
|
||||||
val=$ret
|
val=$ret
|
||||||
else
|
else
|
||||||
if [ $ret -eq $val ]; then
|
if [ "$ret" -eq $val ]; then
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
cpu_mismatch=1
|
cpu_mismatch=1
|
||||||
|
@ -1135,7 +1135,7 @@ check_cpu()
|
||||||
pstatus green YES
|
pstatus green YES
|
||||||
else
|
else
|
||||||
spec_ctrl_msr=1
|
spec_ctrl_msr=1
|
||||||
pstatus green YES "(But not in all CPUs)"
|
pstatus green YES "But not in all CPUs"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
spec_ctrl_msr=0
|
spec_ctrl_msr=0
|
||||||
|
@ -1183,14 +1183,14 @@ check_cpu()
|
||||||
# if we get a write error, the MSR is not there
|
# if we get a write error, the MSR is not there
|
||||||
val=0
|
val=0
|
||||||
cpu_mismatch=0
|
cpu_mismatch=0
|
||||||
for i in $(seq 0 $idx_max_cpu)
|
for i in $(seq 0 "$idx_max_cpu")
|
||||||
do
|
do
|
||||||
write_to_msr 73 $i "\0\0\0\0\0\0\0\0"
|
write_to_msr 73 "$i" "\0\0\0\0\0\0\0\0"
|
||||||
ret=$?
|
ret=$?
|
||||||
if [ $i -eq 0 ]; then
|
if [ "$i" -eq 0 ]; then
|
||||||
val=$ret
|
val=$ret
|
||||||
else
|
else
|
||||||
if [ $ret -eq $val ]; then
|
if [ "$ret" -eq $val ]; then
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
cpu_mismatch=1
|
cpu_mismatch=1
|
||||||
|
@ -1202,7 +1202,7 @@ check_cpu()
|
||||||
if [ $cpu_mismatch -eq 0 ]; then
|
if [ $cpu_mismatch -eq 0 ]; then
|
||||||
pstatus green YES
|
pstatus green YES
|
||||||
else
|
else
|
||||||
pstatus green YES "(But not in all CPUs)"
|
pstatus green YES "But not in all CPUs"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
pstatus red NO
|
pstatus red NO
|
||||||
|
@ -1278,17 +1278,17 @@ check_cpu()
|
||||||
val=0
|
val=0
|
||||||
val_cap_msr=0
|
val_cap_msr=0
|
||||||
cpu_mismatch=0
|
cpu_mismatch=0
|
||||||
for i in $(seq 0 $idx_max_cpu)
|
for i in $(seq 0 "$idx_max_cpu")
|
||||||
do
|
do
|
||||||
check_msr_enable 266 $i
|
check_msr_enable 266 "$i"
|
||||||
ret=$?
|
ret=$?
|
||||||
read_msr 266 $i
|
read_msr 266 "$i"
|
||||||
capabilities=$?
|
capabilities=$?
|
||||||
if [ $i -eq 0 ]; then
|
if [ "$i" -eq 0 ]; then
|
||||||
val=$ret
|
val=$ret
|
||||||
val_cap_msr=$capabilities
|
val_cap_msr=$capabilities
|
||||||
else
|
else
|
||||||
if [ $ret -eq $val && $capabilities -eq $val_cap_msr ]; then
|
if [ "$ret" -eq "$val" -a "$capabilities" -eq "$val_cap_msr" ]; then
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
cpu_mismatch=1
|
cpu_mismatch=1
|
||||||
|
@ -1307,7 +1307,7 @@ check_cpu()
|
||||||
if [ $cpu_mismatch -eq 0 ]; then
|
if [ $cpu_mismatch -eq 0 ]; then
|
||||||
pstatus green YES
|
pstatus green YES
|
||||||
else:
|
else:
|
||||||
pstatus green YES "(But not in all CPUs)"
|
pstatus green YES "But not in all CPUs"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
pstatus red NO
|
pstatus red NO
|
||||||
|
|
Loading…
Reference in New Issue