added VMX .bochsrc option to ctoggle VMX ON/OFF on runtime

This commit is contained in:
Stanislav Shwartsman 2011-12-21 09:11:51 +00:00
parent e7ed8aca5c
commit 2dee4b12be
7 changed files with 61 additions and 22 deletions

View File

@ -260,6 +260,10 @@ cpu: cpuid_limit_winnt=0
# When this option is enabled MWAIT will not put the CPU into a sleep state.
# This option exists only if Bochs compiled with --enable-monitor-mwait.
#
# VMX:
# Select VMX extensions emulation support.
# This option exists only if Bochs compiled with --enable-vmx option.
#
# VENDOR_STRING:
# Set the CPUID vendor string returned by CPUID(0x0). This should be a
# twelve-character ASCII string.

View File

@ -41,6 +41,7 @@ cpuid
movbe
xsave
xsaveopt
vmx
avx
avx_f16c
avx_fma

View File

@ -446,6 +446,13 @@ void bx_init_options()
"Don't put CPU to sleep state by MWAIT",
0);
#endif
#if BX_SUPPORT_VMX
new bx_param_num_c(cpuid_param,
"vmx", "Support for Intel VMX extensions emulation",
"Support for Intel VMX extensions emulation",
0, BX_SUPPORT_VMX,
1);
#endif
#endif
cpuid_param->set_options(menu->SHOW_PARENT);
@ -2797,6 +2804,10 @@ static int parse_line_formatted(const char *context, int num_params, char *param
PARSE_ERR(("%s: cpuid directive malformed.", context));
}
#endif
#if BX_SUPPORT_VMX
} else if (!strncmp(params[i], "vmx=", 4)) {
SIM->get_param_num(BXPN_CPUID_VMX)->set(atol(&params[i][4]));
#endif
#if BX_SUPPORT_X86_64
} else if (!strncmp(params[i], "x86_64=", 7)) {
if (parse_param_bool(params[i], 7, BXPN_CPUID_X86_64) < 0) {
@ -4152,6 +4163,9 @@ int bx_write_configuration(const char *rc, int overwrite)
SIM->get_param_bool(BXPN_CPUID_TBM)->get(),
SIM->get_param_bool(BXPN_CPUID_FMA4)->get());
#endif
#if BX_SUPPORT_VMX
fprintf(fp, ", vmx=%d", SIM->get_param_num(BXPN_CPUID_VMX)->get());
#endif
#if BX_SUPPORT_X86_64
fprintf(fp, ", x86_64=%d, 1g_pages=%d, pcid=%d, fsgsbase=%d",
SIM->get_param_bool(BXPN_CPUID_X86_64)->get(),

View File

@ -853,11 +853,14 @@ void bx_generic_cpuid_t::init_isa_extensions_bitmask(void)
#endif // BX_SUPPORT_X86_64
#if BX_SUPPORT_VMX
features_bitmask |= BX_ISA_VMX;
static unsigned vmx_enabled = SIM->get_param_num(BXPN_CPUID_VMX)->get();
if (vmx_enabled) {
features_bitmask |= BX_ISA_VMX;
if (! sep_enabled) {
BX_PANIC(("PANIC: VMX emulation requires SYSENTER/SYSEXIT support !"));
return;
if (! sep_enabled) {
BX_PANIC(("PANIC: VMX emulation requires SYSENTER/SYSEXIT support !"));
return;
}
}
#endif
@ -937,30 +940,36 @@ void bx_generic_cpuid_t::init_cpu_extensions_bitmask(void)
#if BX_SUPPORT_VMX
void bx_generic_cpuid_t::init_vmx_extensions_bitmask(void)
{
Bit32u features_bitmask = BX_VMX_VIRTUAL_NMI;
Bit32u features_bitmask = 0;
static bx_bool x86_64_enabled = SIM->get_param_bool(BXPN_CPUID_X86_64)->get();
if (x86_64_enabled) {
features_bitmask |= BX_VMX_TPR_SHADOW;
static unsigned vmx_enabled = SIM->get_param_num(BXPN_CPUID_VMX)->get();
if (vmx_enabled) {
features_bitmask |= BX_VMX_VIRTUAL_NMI;
features_bitmask |= BX_VMX_APIC_VIRTUALIZATION |
BX_VMX_WBINVD_VMEXIT;
static bx_bool x86_64_enabled = SIM->get_param_bool(BXPN_CPUID_X86_64)->get();
if (x86_64_enabled) {
features_bitmask |= BX_VMX_TPR_SHADOW |
BX_VMX_APIC_VIRTUALIZATION |
BX_VMX_WBINVD_VMEXIT;
#if BX_SUPPORT_VMX >= 2
features_bitmask |= BX_VMX_PREEMPTION_TIMER |
BX_VMX_PAT |
BX_VMX_EFER |
BX_VMX_EPT |
BX_VMX_VPID |
BX_VMX_UNRESTRICTED_GUEST |
BX_VMX_DESCRIPTOR_TABLE_EXIT |
BX_VMX_X2APIC_VIRTUALIZATION |
BX_VMX_PAUSE_LOOP_EXITING;
if (vmx_enabled >= 2) {
features_bitmask |= BX_VMX_PREEMPTION_TIMER |
BX_VMX_PAT |
BX_VMX_EFER |
BX_VMX_EPT |
BX_VMX_VPID |
BX_VMX_UNRESTRICTED_GUEST |
BX_VMX_DESCRIPTOR_TABLE_EXIT |
BX_VMX_X2APIC_VIRTUALIZATION |
BX_VMX_PAUSE_LOOP_EXITING;
features_bitmask |= BX_VMX_SAVE_DEBUGCTL_DISABLE |
/* BX_VMX_MONITOR_TRAP_FLAG | */ // not implemented yet
BX_VMX_PERF_GLOBAL_CTRL;
features_bitmask |= BX_VMX_SAVE_DEBUGCTL_DISABLE |
/* BX_VMX_MONITOR_TRAP_FLAG | */ // not implemented yet
BX_VMX_PERF_GLOBAL_CTRL;
}
#endif
}
}
this->vmx_extensions_bitmask = features_bitmask;

View File

@ -3095,6 +3095,11 @@ This option exists only if Bochs compiled with --enable-monitor-mwait.
When this option is enabled MWAIT will not put the CPU into a sleep state.
This option exists only if Bochs compiled with --enable-monitor-mwait.
</para>
<para><command>vmx</command></para>
<para>
Select VMX extensions emulation support.
This option exists only if Bochs compiled with --enable-vmx option.
</para>
<para><command>family</command></para>
<para>
Set family information returned by CPUID. Default family value determined

View File

@ -304,6 +304,11 @@ mwait_is_nop:
When this option is enabled MWAIT will not put the CPU into a sleep state.
This option exists only if Bochs compiled with --enable-monitor-mwait.
vmx:
Select VMX extensions emulation support.
This option exists only if Bochs compiled with --enable-vmx option.
family:
Set family information returned by CPUID. Default family value determined

View File

@ -55,6 +55,7 @@
#define BXPN_CPUID_SEP "cpuid.sep"
#define BXPN_CPUID_XSAVE "cpuid.xsave"
#define BXPN_CPUID_XSAVEOPT "cpuid.xsaveopt"
#define BXPN_CPUID_VMX "cpuid.vmx"
#define BXPN_CPUID_AVX "cpuid.avx"
#define BXPN_CPUID_AVX_F16CVT "cpuid.avx_f16c"
#define BXPN_CPUID_AVX_FMA "cpuid.avx_fma"