#!/usr/bin/perl
# License: WTFPLv2
# minimal "rdmsr" implementation
$msr = shift
or die "need msr as parameter";
$msr = hex($msr) if ($msr =~ m/^0x/i);
open(FD, "/dev/cpu/0/msr")
or die "open /dev/cpu/0/msr: $!";
sysseek(FD, $msr, SEEK_SET)
or die "sysseek: $!";
sysread(FD, $reg, 8 ) == 8
or die "sysread: $!";
$reg = reverse($reg);
$hex = unpack('H*', $reg);
$hex =~s/^0*//;
print "$hex\n";
Yes, i know, my perl is horrible :-) but maybe this is useful for someone else anyway.
lscpu also checks for VT extensions, not sure how exactly, though.
ReplyDeletelscpu seems to look in /proc/cpuinfo, but checking the flags there just shows if the CPU is capable of VT-x / svm, but not if it has been enabled in the BIOS.
ReplyDeleteAnother method would have been to just try to load the "kvm" module (which fails if the BIOS has the feature disabled), but my solution needed to work in a SLES11 GM installation initrd environment -- where the kvm module is not present. Thus I resorted to rdmsr, which I also had to implement by myself :-)