move 1G_pages support to runtime option

This commit is contained in:
Stanislav Shwartsman 2010-04-24 09:36:04 +00:00
parent 637d055ccd
commit 1c2fa8cd0c
13 changed files with 96 additions and 96 deletions

View File

@ -172,6 +172,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.
#
# 1G_PAGES:
# Enable 1G page size support in long mode.
# This option exists only if Bochs compiled with x86-64 support.
#
# 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.

View File

@ -23,11 +23,13 @@ Detailed change log :
configure option is deprecated and should not be used anymore.
- Enable changing part of CPU functionality at runtime through .bochsrc.
Now you could enable/disable any of SSEx/AES/MOVBE/SYSENTER_SYSEXIT/XSAVE
instruction sets using new CPUID option in .bochsrc.
- Now you could enable/disable any of SSEx/AES/MOVBE/SYSENTER_SYSEXIT/XSAVE
instruction sets using new CPUID option in .bochsrc.
- When x86-64 support is compiled in, you could enable/disable long mode
1G pages support without recompile using new CPUID option in .bochsrc.
Configure options:
--enable-mmx, --enable-sse, --enable-movbe, --enable-xsave,
--enable-sep, --enable-aes
--enable-sep, --enable-aes, --enable-1g-pages
are deprecated and should not be used anymore.
- Local APIC configure option --enable-apic is deprecated and should not

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: config.cc,v 1.201 2010-03-12 11:42:34 sshwarts Exp $
// $Id: config.cc,v 1.202 2010-04-24 09:36:04 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002-2009 The Bochs Project
@ -358,7 +358,7 @@ void bx_init_options()
cpu_param->set_options(menu->SHOW_PARENT);
// cpuid subtree
bx_list_c *cpuid_param = new bx_list_c(root_param, "cpuid", "CPUID Options", 11);
bx_list_c *cpuid_param = new bx_list_c(root_param, "cpuid", "CPUID Options", 12);
new bx_param_bool_c(cpuid_param,
"cpuid_limit_winnt", "Limit max CPUID function to 3",
@ -423,6 +423,12 @@ void bx_init_options()
"xsave", "Support for XSAVE extensions",
"Support for XSAVE extensions",
0);
#if BX_SUPPORT_X86_64
new bx_param_bool_c(cpuid_param,
"1g_pages", "1G pages support in long mode",
"Support for 1G pages in long mode",
0);
#endif
#if BX_SUPPORT_MONITOR_MWAIT
new bx_param_bool_c(cpuid_param,
"mwait_is_nop", "MWAIT enter CPU to sleep state",
@ -2644,6 +2650,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_X86_64
} else if (!strncmp(params[i], "1g_pages=", 9)) {
if (parse_param_bool(params[i], 9, BXPN_CPUID_1G_PAGES) < 0) {
PARSE_ERR(("%s: cpuid directive malformed.", context));
}
#endif
#if BX_SUPPORT_MONITOR_MWAIT
} else if (!strncmp(params[i], "mwait_is_nop=", 13)) {
if (parse_param_bool(params[i], 13, BXPN_CPUID_MWAIT_IS_NOP) < 0) {
@ -3813,6 +3825,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_X86_64
fprintf(fp, ", 1g_pages=%d", SIM->get_param_bool(BXPN_CPUID_1G_PAGES)->get());
#endif
#if BX_SUPPORT_MONITOR_MWAIT
fprintf(fp, ", mwait_is_nop=%d", SIM->get_param_bool(BXPN_CPUID_MWAIT_IS_NOP)->get());
#endif

View File

@ -687,7 +687,6 @@ typedef
#define BX_SUPPORT_MISALIGNED_SSE 0
#define BX_SUPPORT_MONITOR_MWAIT 0
#define BX_SUPPORT_VMX 0
#define BX_SUPPORT_1G_PAGES 0
#if BX_SUPPORT_VMX >= 2 && BX_SUPPORT_X86_64 == 0
#error "VMXx2 require x86-64 support"
@ -730,10 +729,6 @@ typedef
#error "VMX only supported with CPU_LEVEL >= 6 !"
#endif
#if (BX_SUPPORT_X86_64 == 0 && BX_SUPPORT_1G_PAGES)
#error "1G only supported with x86-64 !"
#endif
#if BX_SUPPORT_X86_64
// Sanity checks to ensure that you cannot accidently use conflicting options.

56
bochs/configure vendored
View File

@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in Id: configure.in,v 1.434 2010/04/08 15:50:39 sshwarts Exp .
# From configure.in Id: configure.in,v 1.435 2010/04/10 06:15:32 sshwarts Exp .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.65.
#
@ -952,7 +952,6 @@ enable_usb
enable_usb_ohci
enable_pnic
enable_x2apic
enable_1g_pages
enable_repeat_speedups
enable_trace_cache
enable_fast_function_calls
@ -1008,6 +1007,7 @@ enable_xsave
enable_sep
enable_apic
enable_ignore_bad_msr
enable_1g_pages
enable_pae
enable_mtrr
enable_large_pages
@ -1671,7 +1671,6 @@ Optional Features:
--enable-usb-ohci enable limited USB OHCI support
--enable-pnic enable PCI pseudo NIC support
--enable-x2apic support for X2APIC
--enable-1g-pages support for 1G pages in long mode
--enable-repeat-speedups support repeated IO and mem copy speedups
--enable-trace-cache support instruction trace cache
--enable-fast-function-calls support for fast function calls (gcc on x86 only)
@ -1714,6 +1713,7 @@ Optional Features:
--enable-sep support for SYSENTER/SYSEXIT intructions (deprecated)
--enable-apic enable APIC support (deprecated)
--enable-ignore-bad-msr ignore bad MSR references (deprecated)
--enable-1g-pages support for 1G pages in long mode (deprecated)
--enable-pae enables PAE support (deprecated)
--enable-mtrr enables MTRR/PAT support (deprecated)
--enable-large-pages enables PSE support (deprecated)
@ -22243,39 +22243,6 @@ $as_echo "no" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for long mode 1G pages support" >&5
$as_echo_n "checking for long mode 1G pages support... " >&6; }
# Check whether --enable-1g-pages was given.
if test "${enable_1g_pages+set}" = set; then :
enableval=$enable_1g_pages; if test "$enableval" = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define BX_SUPPORT_1G_PAGES 1" >>confdefs.h
support_1g_pages=1
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
$as_echo "#define BX_SUPPORT_1G_PAGES 0" >>confdefs.h
support_1g_pages=0
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
$as_echo "#define BX_SUPPORT_1G_PAGES 0" >>confdefs.h
support_1g_pages=0
fi
if test "$support_1g_pages" = 1 -a "$use_x86_64" = 0; then
as_fn_error "x86-64 mode is required for 1G pages support" "$LINENO" 5
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for repeated IO and mem copy speedups" >&5
$as_echo_n "checking for repeated IO and mem copy speedups... " >&6; }
# Check whether --enable-repeat-speedups was given.
@ -25153,6 +25120,22 @@ $as_echo "no" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for long mode 1G pages support" >&5
$as_echo_n "checking for long mode 1G pages support... " >&6; }
# Check whether --enable-1g-pages was given.
if test "${enable_1g_pages+set}" = set; then :
enableval=$enable_1g_pages; { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enableval" >&5
$as_echo "$enableval" >&6; }
as_fn_error "DEPRECATED - moved to runtime option in .bochsrc" "$LINENO" 5
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PAE support (deprecated)" >&5
$as_echo_n "checking for PAE support (deprecated)... " >&6; }
# Check whether --enable-pae was given.
@ -25185,6 +25168,7 @@ $as_echo "no" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LARGE PAGES (PSE) support (deprecated)" >&5
$as_echo_n "checking for LARGE PAGES (PSE) support (deprecated)... " >&6; }
# Check whether --enable-large-pages was given.

View File

@ -2,7 +2,7 @@ dnl // Process this file with autoconf to produce a configure script.
AC_PREREQ(2.50)
AC_INIT(bochs.h)
AC_REVISION([[$Id: configure.in,v 1.435 2010-04-10 06:15:32 sshwarts Exp $]])
AC_REVISION([[$Id: configure.in,v 1.436 2010-04-24 09:36:04 sshwarts Exp $]])
AC_CONFIG_HEADER(config.h)
AC_CONFIG_HEADER(ltdlconf.h)
@ -876,29 +876,6 @@ AC_ARG_ENABLE(x2apic,
]
)
AC_MSG_CHECKING(for long mode 1G pages support)
AC_ARG_ENABLE(1g-pages,
[ --enable-1g-pages support for 1G pages in long mode],
[if test "$enableval" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE(BX_SUPPORT_1G_PAGES, 1)
support_1g_pages=1
else
AC_MSG_RESULT(no)
AC_DEFINE(BX_SUPPORT_1G_PAGES, 0)
support_1g_pages=0
fi],
[
AC_MSG_RESULT(no)
AC_DEFINE(BX_SUPPORT_1G_PAGES, 0)
support_1g_pages=0
]
)
if test "$support_1g_pages" = 1 -a "$use_x86_64" = 0; then
AC_MSG_ERROR([x86-64 mode is required for 1G pages support])
fi
AC_MSG_CHECKING(for repeated IO and mem copy speedups)
AC_ARG_ENABLE(repeat-speedups,
[ --enable-repeat-speedups support repeated IO and mem copy speedups],
@ -2719,6 +2696,16 @@ AC_ARG_ENABLE(ignore-bad-msr,
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(for long mode 1G pages support)
AC_ARG_ENABLE(1g-pages,
[ --enable-1g-pages support for 1G pages in long mode (deprecated)],
[AC_MSG_RESULT($enableval)
AC_MSG_ERROR([DEPRECATED - moved to runtime option in .bochsrc])
],
[
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(for PAE support (deprecated))
AC_ARG_ENABLE(pae,
[ --enable-pae enables PAE support (deprecated)],
@ -2739,6 +2726,7 @@ AC_ARG_ENABLE(mtrr,
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING(for LARGE PAGES (PSE) support (deprecated))
AC_ARG_ENABLE(large-pages,
[ --enable-large-pages enables PSE support (deprecated)],

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.h,v 1.670 2010-04-22 18:48:39 sshwarts Exp $
// $Id: cpu.h,v 1.671 2010-04-24 09:36:04 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2010 The Bochs Project
@ -3273,6 +3273,8 @@ public: // for now...
BX_SMF void bx_cpuid_xsave_leaf(Bit32u subfunction);
#endif
BX_SMF BX_CPP_INLINE int bx_cpuid_support_1g_paging(void);
BX_SMF BX_CPP_INLINE unsigned which_cpu(void) { return BX_CPU_THIS_PTR bx_cpuid; }
BX_SMF BX_CPP_INLINE const bx_gen_reg_t *get_gen_regfile() { return BX_CPU_THIS_PTR gen_reg; }
@ -3686,6 +3688,15 @@ BX_CPP_INLINE bx_bool BX_CPU_C::alignment_check(void)
}
#endif
BX_CPP_INLINE int BX_CPU_C::bx_cpuid_support_1g_paging(void)
{
#if BX_SUPPORT_X86_64
return (BX_CPU_THIS_PTR cpuid_ext_function[1].edx >> 26) & 0x1;
#else
return 0;
#endif
}
BOCHSAPI extern const Bit8u bx_parity_lookup[256];
BX_CPP_INLINE void BX_CPU_C::set_PF_base(Bit8u val)

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpuid.cc,v 1.113 2010-04-22 18:48:39 sshwarts Exp $
// $Id: cpuid.cc,v 1.114 2010-04-24 09:36:04 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2010 Stanislav Shwartsman
@ -377,6 +377,9 @@ void BX_CPU_C::set_cpuid_defaults(void)
Bit8u *vendor_string = (Bit8u *)SIM->get_param_string(BXPN_VENDOR_STRING)->getptr();
Bit8u *brand_string = (Bit8u *)SIM->get_param_string(BXPN_BRAND_STRING)->getptr();
bool cpuid_limit_winnt = SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get();
#if BX_SUPPORT_X86_64
bx_bool xlarge_pages_enabled = SIM->get_param_bool(BXPN_CPUID_1G_PAGES)->get();
#endif
cpuid_function_t *cpuid;
int i;
@ -708,9 +711,8 @@ void BX_CPU_C::set_cpuid_defaults(void)
#endif
#if BX_SUPPORT_X86_64
features |= (1 << 29) | (1 << 27) | (1 << 25) | (1 << 20) | (1 << 11);
#if BX_SUPPORT_1G_PAGES
features |= (1 << 26);
#endif
if (xlarge_pages_enabled)
features |= (1 << 26);
#endif
cpuid->edx = features;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: paging.cc,v 1.219 2010-04-14 15:41:57 sshwarts Exp $
// $Id: paging.cc,v 1.220 2010-04-24 09:36:04 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2010 The Bochs Project
@ -682,7 +682,7 @@ bx_phy_address BX_CPU_C::translate_linear_long_mode(bx_address laddr, Bit32u &lp
if (leaf == BX_LEVEL_PTE) break;
if (curr_entry & 0x80) {
if (leaf > (BX_LEVEL_PDE + BX_SUPPORT_1G_PAGES)) {
if (leaf > (BX_LEVEL_PDE + bx_cpuid_support_1g_paging())) {
BX_DEBUG(("%s: PS bit set !"));
page_fault(ERROR_RESERVED | ERROR_PROTECTION, laddr, pl, rw);
}
@ -1263,7 +1263,7 @@ bx_phy_address BX_CPU_C::translate_guest_physical(bx_phy_address guest_paddr, bx
}
if (curr_entry & 0x80) {
if (leaf > (BX_LEVEL_PDE + BX_SUPPORT_1G_PAGES)) {
if (leaf > (BX_LEVEL_PDE + bx_cpuid_support_1g_paging())) {
BX_DEBUG(("EPT %s: PS bit set !"));
vmexit_reason = VMX_VMEXIT_EPT_VIOLATION;
break;
@ -1346,7 +1346,7 @@ bx_bool BX_CPU_C::dbg_translate_guest_physical(bx_phy_address guest_paddr, bx_ph
if (level == BX_LEVEL_PTE) break;
if (pte & 0x80) {
if (level > (BX_LEVEL_PDE + BX_SUPPORT_1G_PAGES))
if (level > (BX_LEVEL_PDE + bx_cpuid_support_1g_paging()))
return 0;
pt_address &= BX_CONST64(0x000fffffffffe000);
@ -1414,20 +1414,20 @@ bx_bool BX_CPU_C::dbg_xlate_linear2phy(bx_address laddr, bx_phy_address *phy)
pt_address = bx_phy_address(pte & BX_CONST64(0x000ffffffffff000));
if (level == BX_LEVEL_PTE) break;
if (pte & 0x80) {
if (level == BX_LEVEL_PDE) { // 2M page
// 2M page
if (level == BX_LEVEL_PDE) {
pt_address &= BX_CONST64(0x000fffffffffe000);
if (pt_address & offset_mask)
goto page_fault;
break;
}
#if BX_SUPPORT_1G_PAGES
if (level == BX_LEVEL_PDPE && long_mode()) { // 1G page
// 1G page
if (bx_cpuid_support_1g_paging() && level == BX_LEVEL_PDPE && long_mode()) {
pt_address &= BX_CONST64(0x000fffffffffe000);
if (pt_address & offset_mask)
goto page_fault;
break;
}
#endif
goto page_fault;
}
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: vmx.h,v 1.29 2010-04-09 11:31:55 sshwarts Exp $
// $Id: vmx.h,v 1.30 2010-04-24 09:36:04 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2009 Stanislav Shwartsman
@ -1020,7 +1020,7 @@ enum VMX_INVEPT_INVVPID_type {
// [25] - INVEPT single-context invalidation supported
// [26] - INVEPT all-context invalidation supported
#define VMX_MSR_VMX_EPT_VPID_CAP_LO (0x06114141 | (BX_SUPPORT_1G_PAGES << 17))
#define VMX_MSR_VMX_EPT_VPID_CAP_LO (0x06114141 | (bx_cpuid_support_1g_paging() << 17))
// [32] - INVVPID instruction supported
// [40] - individual-address INVVPID is supported

View File

@ -1,7 +1,7 @@
<!--
================================================================
doc/docbook/user/user.dbk
$Id: user.dbk,v 1.276 2010-03-01 18:53:53 sshwarts Exp $
$Id: user.dbk,v 1.277 2010-04-24 09:36:04 sshwarts Exp $
This is the top level file for the Bochs Users Manual.
================================================================
@ -2074,11 +2074,6 @@ turn it off.
Add support for x86-64 instruction set, written by Peter Tattam and Stanislav Shwartsman.
</entry>
</row>
<row>
<entry>--enable-1g-pages</entry>
<entry>no</entry>
<entry>support for 1G page extensions in x86-64 long mode</entry>
</row>
<row>
<entry>--enable-vmx</entry>
<entry>no</entry>

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: main.cc,v 1.419 2010-04-03 13:30:58 sshwarts Exp $
// $Id: main.cc,v 1.420 2010-04-24 09:36:04 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2009 The Bochs Project
@ -1006,6 +1006,9 @@ void bx_init_hardware()
bx_bool sep_enabled = SIM->get_param_bool(BXPN_CPUID_SEP)->get();
bx_bool xsave_enabled = SIM->get_param_bool(BXPN_CPUID_XSAVE)->get();
#endif
#if BX_SUPPORT_X86_64
bx_bool xlarge_pages_enabled = SIM->get_param_bool(BXPN_CPUID_1G_PAGES)->get();
#endif
// Output to the log file the cpu and device settings
// This will by handy for bug reports
@ -1039,10 +1042,10 @@ void bx_init_hardware()
BX_INFO((" XSAVE support: %s",xsave_enabled?"yes":"no"));
BX_INFO((" AES support: %s",aes_enabled?"yes":"no"));
BX_INFO((" MOVBE support: %s",movbe_enabled?"yes":"no"));
#if BX_SUPPORT_X86_64
BX_INFO((" 1G paging support: %s",BX_SUPPORT_1G_PAGES?"yes":"no"));
#endif
BX_INFO((" x86-64 support: %s",BX_SUPPORT_X86_64?"yes":"no"));
#if BX_SUPPORT_X86_64
BX_INFO((" 1G paging support: %s",xlarge_pages_enabled?"yes":"no"));
#endif
BX_INFO((" MWAIT support: %s",BX_SUPPORT_MONITOR_MWAIT?"yes":"no"));
#if BX_SUPPORT_VMX
BX_INFO((" VMX support: %d",BX_SUPPORT_VMX));

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: param_names.h,v 1.5 2010-03-12 11:28:59 sshwarts Exp $
// $Id: param_names.h,v 1.6 2010-04-24 09:36:04 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2009 The Bochs Project
@ -51,6 +51,7 @@
#define BXPN_CPUID_XSAVE "cpuid.xsave"
#define BXPN_CPUID_XAPIC "cpuid.xapic"
#define BXPN_CPUID_MWAIT_IS_NOP "cpuid.mwait_is_nop"
#define BXPN_CPUID_1G_PAGES "cpuid.1g_pages"
#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"