blob: b32e118794817b91cdda99f35ad484b080d1d9ae (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/bin/ash
# This script checks whether given VMware version supports the CPU:
# * Intel: check for "VMX Unrestricted Guest" CPU flag
# * AMD: check if CPU family is Bulldozer or newer
#
# Please do not move or rename this script, it is expected exactly
# at /opt/openslx/bin/vmware-get-supported-version
VIRTTYPE="$( grep -m1 '^flags\s*:' /proc/cpuinfo | grep -woF -e svm -e vmx )"
if [ -z "$VIRTTYPE" ]; then
# No need to bother with msr
echo "legacy"
exit 0
fi
[ -e "/dev/cpu/0/msr" ] \
|| modprobe msr 2> /dev/null \
|| insmod "$NEWROOT/lib/modules/$( uname -r )/kernel/arch/x86/kernel/msr.ko"*
# * because it might be compressed -> msr.ko.zstd ...
if [ -n "$NEWROOT" ] && [ -d "$NEWROOT" ]; then
export PATH="${PATH}:${NEWROOT}/usr/sbin:${NEWROOT}/usr/bin"
fi
version="legacy"
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
flag="$( rdmsr --bitfield 5:5 0x485 )"
[ "$flag" = "1" ] && version="new"
fi
elif [ "$VIRTTYPE" = "svm" ]; then # amd
BIT1="$( rdmsr --bitfield 4:4 0xc0010114 2>/dev/null || echo "fail" )"
if [ "$BIT1" = "0" ]; then
family="$( awk '$1$2 == "cpufamily" {print $NF;exit}' /proc/cpuinfo )"
[ "$family" -ge 21 ] && version="new"
fi
fi
if [ "$BIT1" = "fail" ]; then
echo "fail"
exit 1
fi
echo "$version"
exit 0
|