- Determine and select max physical address size automatically at

configure time:
    - 32-bit physical address for 386/486 guests
    - 36-bit physical address for PSE-36 enabled Pentium guest
    - 40-bit physical address for PAE enabled P6 or later guests
This commit is contained in:
Stanislav Shwartsman 2010-05-12 14:55:12 +00:00
parent f899949c3a
commit d849cdf128
7 changed files with 79 additions and 61 deletions

View File

@ -8,7 +8,6 @@
--enable-x86-64 \
--enable-all-optimizations \
--enable-long-phy-address \
--enable-1g-pages \
--enable-configurable-msrs \
--enable-debugger \
--enable-disasm \

View File

@ -466,7 +466,11 @@ typedef bx_address bx_lin_address;
#if BX_PHY_ADDRESS_LONG
typedef Bit64u bx_phy_address;
#define BX_PHY_ADDRESS_WIDTH 40
#if BX_CPU_LEVEL == 5
#define BX_PHY_ADDRESS_WIDTH 36
#else
#define BX_PHY_ADDRESS_WIDTH 40
#endif
#else
typedef Bit32u bx_phy_address;
#define BX_PHY_ADDRESS_WIDTH 32

67
bochs/configure vendored
View File

@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in Id: configure.in,v 1.437 2010/04/25 07:57:19 vruppert Exp .
# From configure.in Id: configure.in,v 1.438 2010/04/29 19:22:02 sshwarts Exp .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.65.
#
@ -941,8 +941,8 @@ enable_plugins
enable_a20_pin
enable_x86_64
enable_smp
enable_long_phy_address
enable_cpu_level
enable_long_phy_address
enable_compressed_hd
enable_ne2000
enable_acpi
@ -1660,8 +1660,8 @@ Optional Features:
--enable-a20-pin compile in support for A20 pin
--enable-x86-64 compile in support for x86-64 instructions
--enable-smp compile in support for SMP configurations
--enable-long-phy-address compile in support for physical address larger than 32 bit
--enable-cpu-level select cpu level (3,4,5,6)
--enable-long-phy-address compile in support for physical address larger than 32 bit
--enable-compressed-hd allows compressed (zlib) hard disk image (not implemented yet)
--enable-ne2000 enable limited ne2000 support
--enable-acpi enable ACPI support
@ -21697,33 +21697,6 @@ $as_echo "no" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for larger than 32 bit physical address emulation" >&5
$as_echo_n "checking for larger than 32 bit physical address emulation... " >&6; }
# Check whether --enable-long-phy-address was given.
if test "${enable_long_phy_address+set}" = set; then :
enableval=$enable_long_phy_address; if test "$enableval" = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define BX_PHY_ADDRESS_LONG 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
$as_echo "#define BX_PHY_ADDRESS_LONG 0" >>confdefs.h
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
$as_echo "#define BX_PHY_ADDRESS_LONG 0" >>confdefs.h
fi
@ -21784,6 +21757,40 @@ $as_echo "6" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for larger than 32 bit physical address emulation" >&5
$as_echo_n "checking for larger than 32 bit physical address emulation... " >&6; }
# Check whether --enable-long-phy-address was given.
if test "${enable_long_phy_address+set}" = set; then :
enableval=$enable_long_phy_address; if test "$enableval" = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define BX_PHY_ADDRESS_LONG 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
$as_echo "#define BX_PHY_ADDRESS_LONG 0" >>confdefs.h
fi
else
if test "$bx_cpu_level" -ge 5; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define BX_PHY_ADDRESS_LONG 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
$as_echo "#define BX_PHY_ADDRESS_LONG 0" >>confdefs.h
fi
fi
ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
if test "x$ac_cv_header_zlib_h" = x""yes; then :

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.438 2010-04-29 19:22:02 sshwarts Exp $]])
AC_REVISION([[$Id: configure.in,v 1.439 2010-05-12 14:55:11 sshwarts Exp $]])
AC_CONFIG_HEADER(config.h)
AC_CONFIG_HEADER(ltdlconf.h)
@ -530,23 +530,6 @@ AC_ARG_ENABLE(smp,
]
)
AC_MSG_CHECKING(for larger than 32 bit physical address emulation)
AC_ARG_ENABLE(long-phy-address,
[ --enable-long-phy-address compile in support for physical address larger than 32 bit],
[if test "$enableval" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE(BX_PHY_ADDRESS_LONG, 1)
else
AC_MSG_RESULT(no)
AC_DEFINE(BX_PHY_ADDRESS_LONG, 0)
fi
],
[
AC_MSG_RESULT(no)
AC_DEFINE(BX_PHY_ADDRESS_LONG, 0)
]
)
AC_MSG_CHECKING(for cpu level)
AC_ARG_ENABLE(cpu-level,
[ --enable-cpu-level select cpu level (3,4,5,6)],
@ -590,6 +573,28 @@ AC_ARG_ENABLE(cpu-level,
]
)
AC_MSG_CHECKING(for larger than 32 bit physical address emulation)
AC_ARG_ENABLE(long-phy-address,
[ --enable-long-phy-address compile in support for physical address larger than 32 bit],
[if test "$enableval" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE(BX_PHY_ADDRESS_LONG, 1)
else
AC_MSG_RESULT(no)
AC_DEFINE(BX_PHY_ADDRESS_LONG, 0)
fi
],
[
if test "$bx_cpu_level" -ge 5; then
AC_MSG_RESULT(yes)
AC_DEFINE(BX_PHY_ADDRESS_LONG, 1)
else
AC_MSG_RESULT(no)
AC_DEFINE(BX_PHY_ADDRESS_LONG, 0)
fi
]
)
AC_CHECK_HEADER(zlib.h, [AC_CHECK_LIB(z, gzopen, AC_DEFINE(BX_HAVE_ZLIB,1))] )

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: cpu.h,v 1.674 2010-05-08 08:30:04 sshwarts Exp $
// $Id: cpu.h,v 1.675 2010-05-12 14:55:12 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2010 The Bochs Project
@ -3275,6 +3275,7 @@ public: // for now...
BX_SMF void bx_cpuid_xsave_leaf(Bit32u subfunction);
#endif
BX_SMF BX_CPP_INLINE int bx_cpuid_support_debug_extensions(void);
BX_SMF BX_CPP_INLINE int bx_cpuid_support_1g_paging(void);
BX_SMF BX_CPP_INLINE int bx_cpuid_support_vme(void);
BX_SMF BX_CPP_INLINE int bx_cpuid_support_pae(void);
@ -3709,6 +3710,11 @@ BX_CPP_INLINE int BX_CPU_C::bx_cpuid_support_vme(void)
return (BX_CPU_THIS_PTR cpuid_std_function[1].edx >> 1) & 0x1;
}
BX_CPP_INLINE int BX_CPU_C::bx_cpuid_support_debug_extensions(void)
{
return (BX_CPU_THIS_PTR cpuid_std_function[1].edx >> 2) & 0x1;
}
BX_CPP_INLINE int BX_CPU_C::bx_cpuid_support_pae(void)
{
return (BX_CPU_THIS_PTR cpuid_std_function[1].edx >> 6) & 0x1;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: crregs.cc,v 1.16 2010-05-06 21:46:39 sshwarts Exp $
// $Id: crregs.cc,v 1.17 2010-05-12 14:55:12 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2010 Stanislav Shwartsman
@ -853,7 +853,7 @@ bx_bool BX_CPP_AttrRegparmN(1) BX_CPU_C::SetCR0(bx_address val)
return 0;
}
if (BX_CPU_THIS_PTR gen_reg[BX_64BIT_REG_RIP].dword.hrx != 0) {
BX_PANIC(("SetCR0(): attempt to leave x86-64 LONG mode with RIP upper != 0 !!!"));
BX_PANIC(("SetCR0(): attempt to leave x86-64 LONG mode with RIP upper != 0"));
}
BX_CPU_THIS_PTR efer.set_LMA(0);
}
@ -935,7 +935,8 @@ Bit32u BX_CPU_C::get_cr4_allow_mask(void)
allowMask |= BX_CR4_TSD_MASK;
#endif
allowMask |= BX_CR4_DE_MASK;
if (bx_cpuid_support_debug_extensions())
allowMask |= BX_CR4_DE_MASK;
#if BX_CPU_LEVEL >= 5
if (bx_cpuid_support_pse36())

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: icache.h,v 1.52 2010-05-08 08:30:04 sshwarts Exp $
// $Id: icache.h,v 1.53 2010-05-12 14:55:12 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2009 Stanislav Shwartsman
@ -51,12 +51,8 @@ public:
~bxPageWriteStampTable() { delete [] pageWriteStampTable; }
BX_CPP_INLINE Bit32u hash(bx_phy_address pAddr) const {
#if BX_PHY_ADDRESS_LONG
// can share writeStamps between multiple pages
return (Bit32u) ((pAddr >> 12) & (PHY_MEM_PAGES-1));
#else
return (Bit32u) (pAddr) >> 12;
#endif
// can share writeStamps between multiple pages if >32 bit phy address
return ((Bit32u) pAddr) >> 12;
}
BX_CPP_INLINE Bit32u getPageWriteStamp(bx_phy_address pAddr) const