Merge pull request #2503 from larskanis/fix-amd-svm-detection-on-linux

Fix detection of virtualization support on AMD CPU.
This commit is contained in:
Jean-Laurent de Morlhon 2015-12-07 09:37:54 +01:00
commit 1de66c75e4
2 changed files with 19 additions and 18 deletions

View File

@ -9,7 +9,7 @@ import (
// IsVTXDisabled checks if VT-X is disabled in the BIOS. If it is, the vm will fail to start.
// If we can't be sure it is disabled, we carry on and will check the vm logs after it's started.
// We want to check that either vmx or smd flags are present in /proc/cpuinfo.
// We want to check that either vmx or svm flags are present in /proc/cpuinfo.
func (d *Driver) IsVTXDisabled() bool {
cpuinfo, err := ioutil.ReadFile("/proc/cpuinfo")
if err != nil {
@ -22,7 +22,7 @@ func (d *Driver) IsVTXDisabled() bool {
func isVTXDisabled(cpuinfo []byte) bool {
features := [2][]byte{
{'v', 'm', 'x'},
{'s', 'm', 'd'},
{'s', 'v', 'm'},
}
for _, v := range features {
if bytes.Contains(cpuinfo, v) {

View File

@ -9,31 +9,32 @@ import (
const (
amdCPUInfo = `
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 70
model name : Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
stepping : 1
microcode : 0x19
cpu MHz : 2294.688
cache size : 6144 KB
vendor_id : AuthenticAMD
cpu family : 20
model : 1
model name : AMD C-50 Processor
stepping : 0
microcode : 0x5000026
cpu MHz : 800.000
cache size : 512 KB
physical id : 0
siblings : 1
siblings : 2
core id : 0
cpu cores : 1
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
cpuid level : 6
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 smd clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq monitor ssse3 cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx rdrand hypervisor lahf_lm abm
bugs :
bogomips : 4589.37
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc extd_apicid aperfmperf pni monitor ssse3 cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch ibs skinit wdt arat hw_pstate npt lbrv svm_lock nrip_save pausefilter vmmcall
bugs : fxsave_leak sysret_ss_attrs
bogomips : 1995.09
TLB size : 1024 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:
address sizes : 36 bits physical, 48 bits virtual
power management: ts ttp tm stc 100mhzsteps hwpstate
`
intelCPUInfo = `
processor : 0