From 2cbdee897de1497b9ffc54304ac66105b88edcb0 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 21 Apr 2022 16:33:19 +0200 Subject: [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. --- .../opt/openslx/scripts/systemd-hardware_stats | 31 +++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'core/modules/hardware-stats') 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 -- cgit v1.2.3-55-g7522