Set VMX and LOCK bit in IA32_FEATURE_CONTROL.

This commit is contained in:
Volker Ruppert 2020-01-15 17:06:10 +00:00
parent 23b442e80d
commit 8679542678
3 changed files with 24 additions and 2 deletions

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2006-2018 Volker Ruppert
// Copyright (C) 2006-2020 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -174,6 +174,11 @@
#define CPUID_APIC (1 << 9)
#define CPUID_MTRR (1 << 12)
#define CPUID_EXT_VMX (1 << 5)
#define MSR_FEATURE_CTRL 0x03a
#define FEATURE_CTRL_LOCK 0x1
#define FEATURE_CTRL_VMX 0x4
#define APIC_BASE ((uint8_t *)0xfee00000)
#define APIC_ICR_LOW 0x300
#define APIC_SVR 0x0F0

View File

@ -4,7 +4,7 @@
//
// 32 bit Bochs BIOS init code
// Copyright (C) 2006 Fabrice Bellard
// Copyright (C) 2001-2019 The Bochs Project
// Copyright (C) 2001-2020 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -574,6 +574,7 @@ extern uint8_t smp_ap_boot_code_end;
void smp_probe(void)
{
uint32_t val, sipi_vector;
uint64_t val64;
writew(&smp_cpus, 1);
if (cpuid_features & CPUID_APIC) {
@ -598,6 +599,12 @@ void smp_probe(void)
while (cmos_readb(0x5f) + 1 != readw(&smp_cpus))
;
#endif
/* enable VMX for CPU #0 in IA32_FEATURE_CONTROL */
if ((cpuid_ext_features & CPUID_EXT_VMX) > 0) {
val64 = rdmsr(MSR_FEATURE_CTRL);
val64 |= (FEATURE_CTRL_LOCK | FEATURE_CTRL_VMX);
wrmsr(MSR_FEATURE_CTRL, val64);
}
}
BX_INFO("Found %d cpu(s)\n", readw(&smp_cpus));
}

View File

@ -4,6 +4,7 @@
//
// 32 bit Bochs BIOS init code
// Copyright (C) 2006 Fabrice Bellard
// Copyright (C) 2020 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -62,6 +63,15 @@ smp_ap_boot_code_start:
add $12, %ebx
jmp 11b
12:
mov $1, %eax
cpuid
and $CPUID_EXT_VMX, %ecx
jz 13f
mov $MSR_FEATURE_CTRL, %ecx
rdmsr
or $FEATURE_CTRL_LOCK | FEATURE_CTRL_VMX, %eax
wrmsr
13:
lock incw smp_cpus
1: