diff options
author | Simon Rettberg | 2022-04-21 16:33:19 +0200 |
---|---|---|
committer | Simon Rettberg | 2022-04-21 16:33:19 +0200 |
commit | 2cbdee897de1497b9ffc54304ac66105b88edcb0 (patch) | |
tree | 38cc03d3d68c467559a828999ea68f55d5882991 /core/modules/hardware-stats | |
parent | [splashtool] Fix size extraction by forcing grep into ASCII mode (diff) | |
download | mltk-2cbdee897de1497b9ffc54304ac66105b88edcb0.tar.gz mltk-2cbdee897de1497b9ffc54304ac66105b88edcb0.tar.xz mltk-2cbdee897de1497b9ffc54304ac66105b88edcb0.zip |
[hardware-stats] Fix detection of vmx/svm support
Newer Linux kernel versions hide the vmx/svm flag from /proc/cpuinfo if
you disable the feature in the BIOS. We wrongfully reported this as
UNSUPPORTED then instead of DISABLED as intended. Read the according
MSRs unconditionally now, and only validate the flag is present if the
MSR values line up with what we expect for the feature to be enabled.
Diffstat (limited to 'core/modules/hardware-stats')
-rwxr-xr-x | core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats index c66af2fa..252c80c7 100755 --- a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats +++ b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats @@ -129,31 +129,32 @@ echo "$RAM MB RAM" # 5) 64bit virtualization support # VT="UNSUPPORTED" +CPU_VENDOR=$( grep -m1 '^vendor_id\s*:' /proc/cpuinfo | awk '{print $3}' ) VIRTTYPE=$(grep -m1 '^flags\s*:' /proc/cpuinfo | grep -wo -e svm -e vmx) -[ -n "$VIRTTYPE" ] && modprobe msr -echo "Virtualization technology: $VIRTTYPE" +[ -n "$CPU_VENDOR" ] && modprobe msr +echo "CPUID: $CPU_VENDOR" -if [ "$VIRTTYPE" = "vmx" ]; then # intel - BIT1=$(rdmsr --bitfield 0:0 0x3a 2>/dev/null || echo "fail") - BIT2=$(rdmsr --bitfield 2:2 0x3a 2>/dev/null || echo "fail") - if [ "$BIT1" = "fail" -o "$BIT2" = "fail" ]; then +if [ "$CPU_VENDOR" = "GenuineIntel" ]; then + BIT1="$( rdmsr --bitfield 0:0 0x3a 2>/dev/null || echo "fail" )" + BIT2="$( rdmsr --bitfield 2:2 0x3a 2>/dev/null || echo "fail" )" + if [ "$BIT1" = "fail" ] || [ "$BIT2" = "fail" ]; then VT="UNKNOWN" - elif [ "$BIT1" = "0" -o "$BIT2" = "1" ]; then - VT="ENABLED" - else + elif [ "$BIT1" = "1" ] && [ "$BIT2" = "0" ]; then VT="DISABLED" + elif [ "$VIRTTYPE" = "vmx" ]; then + VT="ENABLED" fi -elif [ "$VIRTTYPE" = "svm" ]; then # amd - BIT=$(rdmsr --bitfield 4:4 0xc0010114 2>/dev/null || echo "fail") +elif [ "$CPU_VENDOR" = "AuthenticAMD" ]; then + BIT="$( rdmsr --bitfield 4:4 0xc0010114 2>/dev/null || echo "fail" )" if [ "$BIT" = "fail" ]; then VT="UNKNOWN" - elif [ "$BIT" = "0" ]; then - VT="ENABLED" - else + elif [ "$BIT" = "1" ]; then VT="DISABLED" + elif [ "$VIRTTYPE" = "svm" ]; then + VT="ENABLED" fi fi -echo "$VIRTTYPE is $VT" +echo "KVM support is $VT" ################################################################################ # 6) ID44 partition size |