MWAIT_IS_NOP option

This commit is contained in:
Stanislav Shwartsman 2010-03-12 11:28:59 +00:00
parent 173f4ed1f9
commit 4ce211e358
6 changed files with 34 additions and 5 deletions

View File

@ -171,6 +171,10 @@ cpu: count=1, ips=50000000, reset_on_triple_fault=1, ignore_bad_msrs=1, msrs="ms
# Select XSAVE extensions support.
# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6.
#
# 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.
#
# VENDOR_STRING:
# Set the CPUID vendor string returned by CPUID(0x0). This should be a
# twelve-character ASCII string.

View File

@ -1,4 +1,4 @@
$Id: PARAM_TREE.txt,v 1.27 2010-03-01 18:53:53 sshwarts Exp $
$Id: PARAM_TREE.txt,v 1.28 2010-03-12 11:28:59 sshwarts Exp $
Starting from Bochs 2.3 the parameters are organized in a tree structure
instead of a huge flat list. The parameter tree was required for implementing
@ -36,6 +36,7 @@ cpuid
movbe
xsave
xapic
mwait_is_nop
memory
standard

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: config.cc,v 1.199 2010-03-01 18:53:53 sshwarts Exp $
// $Id: config.cc,v 1.200 2010-03-12 11:28:59 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002-2009 The Bochs Project
@ -423,6 +423,12 @@ void bx_init_options()
"xsave", "Support for XSAVE extensions",
"Support for XSAVE extensions",
0);
#if BX_SUPPORT_MONITOR_MWAIT
new bx_param_bool_c(cpuid_param,
"mwait_is_nop", "MWAIT enter CPU to sleep state",
"Don't put CPU to sleep state by MWAIT",
0);
#endif
#endif
cpuid_param->set_options(menu->SHOW_PARENT);
@ -2638,6 +2644,12 @@ static int parse_line_formatted(const char *context, int num_params, char *param
if (parse_param_bool(params[i], 6, BXPN_CPUID_XAPIC) < 0) {
PARSE_ERR(("%s: cpuid directive malformed.", context));
}
#if BX_SUPPORT_MONITOR_MWAIT
} else if (!strncmp(params[i], "mwait_is_nop=", 13)) {
if (parse_param_bool(params[i], 14, BXPN_CPUID_MWAIT_IS_NOP) < 0) {
PARSE_ERR(("%s: cpuid directive malformed.", context));
}
#endif
#endif
} else {
PARSE_ERR(("%s: cpuid directive malformed.", context));
@ -3801,6 +3813,9 @@ int bx_write_configuration(const char *rc, int overwrite)
SIM->get_param_bool(BXPN_CPUID_AES)->get(),
SIM->get_param_bool(BXPN_CPUID_XSAVE)->get(),
SIM->get_param_bool(BXPN_CPUID_MOVBE)->get());
#if BX_SUPPORT_MONITOR_MWAIT
fprintf(fp, ", mwait_is_nop=%d", SIM->get_param_bool(BXPN_CPUID_MWAIT_IS_NOP)->get());
#endif
#endif
fprintf(fp, "\n");
fprintf(fp, "print_timestamps: enabled=%d\n", bx_dbg.print_timestamps);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: msr.cc,v 1.36 2010-03-06 17:09:25 sshwarts Exp $
// $Id: msr.cc,v 1.37 2010-03-12 11:28:59 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2008-2009 Stanislav Shwartsman
@ -362,10 +362,12 @@ bx_bool BX_CPP_AttrRegparmN(2) BX_CPU_C::wrmsr(Bit32u index, Bit64u val_64)
case BX_MSR_MTRRPHYSMASK5:
case BX_MSR_MTRRPHYSMASK6:
case BX_MSR_MTRRPHYSMASK7:
/*
if (! IsValidPhyAddr(val_64)) {
BX_ERROR(("WRMSR[0x%08x]: attempt to write invalid phy addr to variable range MTRR %08x:%08x", index, val32_hi, val32_lo));
return 0;
}
*/
// handle 10-0 reserved bits
if (val32_lo & 0x7ff) {
BX_ERROR(("WRMSR[0x%08x]: variable range MTRR reserved bits violation %08x:%08x", index, val32_hi, val32_lo));

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: proc_ctrl.cc,v 1.317 2010-03-07 09:41:12 sshwarts Exp $
// $Id: proc_ctrl.cc,v 1.318 2010-03-12 11:28:59 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2009 The Bochs Project
@ -1735,6 +1735,12 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::MWAIT(bxInstruction_c *i)
return;
}
static bool mwait_is_nop = SIM->get_param_bool(BXPN_CPUID_MWAIT_IS_NOP)->get();
if (mwait_is_nop) {
BX_DEBUG(("MWAIT: stay awake"));
return;
}
// stops instruction execution and places the processor in a optimized
// state. Events that cause exit from MWAIT state are:
// A store from another processor to monitored range, any unmasked

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: param_names.h,v 1.4 2010-03-01 18:53:53 sshwarts Exp $
// $Id: param_names.h,v 1.5 2010-03-12 11:28:59 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2009 The Bochs Project
@ -50,6 +50,7 @@
#define BXPN_CPUID_SEP "cpuid.sep"
#define BXPN_CPUID_XSAVE "cpuid.xsave"
#define BXPN_CPUID_XAPIC "cpuid.xapic"
#define BXPN_CPUID_MWAIT_IS_NOP "cpuid.mwait_is_nop"
#define BXPN_MEM_SIZE "memory.standard.ram.size"
#define BXPN_HOST_MEM_SIZE "memory.standard.ram.host_size"
#define BXPN_ROM_PATH "memory.standard.rom.path"