From 33560245dccbe638761790f3e6b786abcb402248 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 18 Oct 2019 13:10:56 +0200 Subject: [vmware-version-check] Check if VT-x SVM is enabled at all first --- .../opt/openslx/bin/vmware-get-supported-version | 50 ++++++++++++++++------ 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/core/modules/vmware-version-check/data/opt/openslx/bin/vmware-get-supported-version b/core/modules/vmware-version-check/data/opt/openslx/bin/vmware-get-supported-version index 82bd7d50..0165191d 100755 --- a/core/modules/vmware-version-check/data/opt/openslx/bin/vmware-get-supported-version +++ b/core/modules/vmware-version-check/data/opt/openslx/bin/vmware-get-supported-version @@ -5,18 +5,42 @@ export PATH=$PATH:/opt/openslx/sbin:/opt/openslx/bin -get_supported_version() { - local vendor="$( awk '$1 == "vendor_id" {print $NF;exit}' /proc/cpuinfo )" - local version=12 - if [ "$vendor" = "GenuineIntel" ]; then - modprobe msr - flag="$( rdmsr --bitfield 5:5 0x485 )" - [ "$flag" = 1 ] && version=15 - elif [ "$vendor" = "AuthenticAMD" ]; then - family="$( awk '$1$2 == "cpufamily" {print $NF;exit}' /proc/cpuinfo )" - [ "$family" -ge 21 ] && version=15 +VIRTTYPE=$(grep -m1 '^flags\s*:' /proc/cpuinfo | grep -wo -e svm -e vmx) + +if [ -z "$VIRTTYPE" ]; then + echo 12 + exit 0 +fi + +modprobe msr + +VT= +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" = "0" ] || [ "$BIT2" = "1" ]; then + VT="ENABLED" + fi +elif [ "$VIRTTYPE" = "svm" ]; then # amd + BIT=$(rdmsr --bitfield 4:4 0xc0010114 2>/dev/null || echo "fail") + if [ "$BIT" = "0" ]; then + VT="ENABLED" fi - echo "$version" -} +fi + +if [ "$VT" != "ENABLED" ]; then + echo 12 + exit 0 +fi + +version=12 +if [ "$VIRTTYPE" = "vmx" ]; then + flag="$( rdmsr --bitfield 5:5 0x485 )" + [ "$flag" = "1" ] && version=15 +elif [ "$VIRTTYPE" = "svm" ]; then + family="$( awk '$1$2 == "cpufamily" {print $NF;exit}' /proc/cpuinfo )" + [ "$family" -ge 21 ] && version=15 +fi + +echo "$version" -get_supported_version -- cgit v1.2.3-55-g7522