diff --git a/bochs/.bochsrc b/bochs/.bochsrc index 7ea6de784..66c05a535 100644 --- a/bochs/.bochsrc +++ b/bochs/.bochsrc @@ -159,6 +159,10 @@ cpu: count=1, ips=50000000, reset_on_triple_fault=1, ignore_bad_msrs=1, msrs="ms # Select MOVBE Intel(R) Atom instruction support. # This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6. # +# XSAVE: +# Select XSAVE extensions support. +# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6. +# # VENDOR_STRING: # Set the CPUID vendor string returned by CPUID(0x0). This should be a # twelve-character ASCII string. @@ -171,7 +175,7 @@ cpu: count=1, ips=50000000, reset_on_triple_fault=1, ignore_bad_msrs=1, msrs="ms # Determine whether to limit maximum CPUID function to 3. This mode is # required to workaround WinNT installation and boot issues. #======================================================================= -cpuid: sep=1, sse=sse4_2, aes=1, movbe=1, cpuid_limit_winnt=0 +cpuid: sep=1, sse=sse4_2, aes=1, movbe=1, xsave=1, cpuid_limit_winnt=0 #======================================================================= # MEMORY diff --git a/bochs/.conf.everything b/bochs/.conf.everything index 23159468f..731e9a15b 100644 --- a/bochs/.conf.everything +++ b/bochs/.conf.everything @@ -19,7 +19,6 @@ --enable-alignment-check \ --enable-3dnow \ --enable-monitor-mwait \ - --enable-xsave \ --enable-vmx \ --enable-x86-debugger \ --enable-a20-pin \ diff --git a/bochs/CHANGES b/bochs/CHANGES index 645b5a469..08acc326a 100644 --- a/bochs/CHANGES +++ b/bochs/CHANGES @@ -17,8 +17,8 @@ Detailed change log : - Introduced new configure option --enable-xapic. The option is used to differentiate between legacy APIC and Pentium4 XAPIC implementations. - The XAPIC will be automatically enabled by configure for x86-64 only. - Make sure that you add XAPIC option explicitly for Pentium4 like + The XAPIC will be automatically enabled by configure for x86-64 only, + make sure that you add XAPIC option explicitly for Pentium4 like configurations. The option will be extended in future to configure X2APIC emulation as well. @@ -29,10 +29,10 @@ 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 + Now you could enable/disable any of SSEx/AES/MOVBE/SYSENTER_SYSEXIT/XSAVE instruction sets using new CPUID option in .bochsrc. Configure options: - --enable-sse, --enable-aes, --enable-movbe, --enable-sep + --enable-sse, --enable-aes, --enable-movbe, --enable-sep, --enable-xsave are deprecated and should not be used anymore. - CPU diff --git a/bochs/PARAM_TREE.txt b/bochs/PARAM_TREE.txt index eb743d2b7..c0a65f37f 100644 --- a/bochs/PARAM_TREE.txt +++ b/bochs/PARAM_TREE.txt @@ -1,4 +1,4 @@ -$Id: PARAM_TREE.txt,v 1.24 2010-02-25 22:34:56 sshwarts Exp $ +$Id: PARAM_TREE.txt,v 1.25 2010-02-26 22:53:43 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 @@ -29,9 +29,11 @@ cpuid cpuid_limit_winnt vendor_string brand_string + sep sse aes movbe + xsave memory standard diff --git a/bochs/config.cc b/bochs/config.cc index c962f5a6f..9e67c18af 100755 --- a/bochs/config.cc +++ b/bochs/config.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: config.cc,v 1.195 2010-02-26 14:18:18 sshwarts Exp $ +// $Id: config.cc,v 1.196 2010-02-26 22:53:43 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", 7); + bx_list_c *cpuid_param = new bx_list_c(root_param, "cpuid", "CPUID Options", 8); new bx_param_bool_c(cpuid_param, "cpuid_limit_winnt", "Limit max CPUID function to 3", @@ -407,6 +407,10 @@ void bx_init_options() "sep", "Support for SYSENTER/SYSEXIT instructions", "Support for SYSENTER/SYSEXIT instructions", (BX_CPU_LEVEL >= 6 && BX_SUPPORT_MMX) || BX_SUPPORT_X86_64); + new bx_param_bool_c(cpuid_param, + "xsave", "Support for XSAVE extensions", + "Support for XSAVE extensions", + 0); #endif cpuid_param->set_options(menu->SHOW_PARENT); @@ -851,6 +855,9 @@ void bx_init_options() // loader hack bx_list_c *load32bitos = new bx_list_c(boot_params, "load32bitos", "32-bit OS Loader Hack"); + + static const char *loader_os_names[] = { "none", "linux", "nullkernel", NULL }; + bx_param_enum_c *whichOS = new bx_param_enum_c(load32bitos, "which", "Which operating system?", @@ -2615,6 +2622,12 @@ static int parse_line_formatted(const char *context, int num_params, char *param } else { PARSE_ERR(("%s: cpuid directive malformed.", context)); } + } else if (!strncmp(params[i], "xsave=", 6)) { + if (params[i][6] == '0' || params[i][6] == '1') { + SIM->get_param_bool(BXPN_CPUID_XSAVE)->set(params[i][6] - '0'); + } else { + PARSE_ERR(("%s: cpuid directive malformed.", context)); + } #endif } else { PARSE_ERR(("%s: cpuid directive malformed.", context)); @@ -3777,10 +3790,11 @@ int bx_write_configuration(const char *rc, int overwrite) fprintf(fp, "\n"); fprintf(fp, "cpuid: cpuid_limit_winnt=%d", SIM->get_param_bool(BXPN_CPUID_LIMIT_WINNT)->get()); #if BX_CPU_LEVEL >= 6 - fprintf(fp, ", sse=%s, sep=%d, aes=%d, movbe=%d", + fprintf(fp, ", sse=%s, sep=%d, aes=%d, xsave=%d, movbe=%d", SIM->get_param_enum(BXPN_CPUID_SSE)->get_selected(), SIM->get_param_bool(BXPN_CPUID_SEP)->get(), SIM->get_param_bool(BXPN_CPUID_AES)->get(), + SIM->get_param_bool(BXPN_CPUID_XSAVE)->get(), SIM->get_param_bool(BXPN_CPUID_MOVBE)->get()); #endif fprintf(fp, "\n"); diff --git a/bochs/config.h.in b/bochs/config.h.in index d9bd22bb5..f22337307 100644 --- a/bochs/config.h.in +++ b/bochs/config.h.in @@ -687,7 +687,6 @@ typedef #define BX_SUPPORT_3DNOW 0 #define BX_SUPPORT_MISALIGNED_SSE 0 #define BX_SUPPORT_MONITOR_MWAIT 0 -#define BX_SUPPORT_XSAVE 0 #define BX_SUPPORT_VMX 0 #define BX_SUPPORT_1G_PAGES 0 #define BX_SUPPORT_XAPIC 0 diff --git a/bochs/configure b/bochs/configure index 0dbcb6b86..f6c3f9483 100755 --- a/bochs/configure +++ b/bochs/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Id: configure.in,v 1.425 2010/02/25 22:04:30 sshwarts Exp . +# From configure.in Id: configure.in,v 1.426 2010/02/26 11:44:50 sshwarts Exp . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.65. # @@ -974,7 +974,6 @@ enable_fpu enable_vmx enable_mmx enable_3dnow -enable_xsave enable_alignment_check enable_misaligned_sse enable_xapic @@ -1005,6 +1004,7 @@ enable_sse_extension enable_popcnt enable_movbe enable_aes +enable_xsave enable_sep enable_apic enable_ignore_bad_msr @@ -1693,7 +1693,6 @@ Optional Features: --enable-vmx virtualization extensions --enable-mmx MMX support --enable-3dnow 3DNow! support (incomplete) - --enable-xsave support for XSAVE/XRSTOR extensions --enable-alignment-check alignment check (#AC) support --enable-misaligned-sse misaligned SSE support --enable-xapic support for XAPIC extensions @@ -1711,6 +1710,7 @@ Optional Features: --enable-popcnt support for POPCNT intruction (deprecated) --enable-movbe support for MOVBE intruction (deprecated) --enable-aes support for AES intruction set (deprecated) + --enable-xsave support for XSAVE extensions (deprecated) --enable-sep support for SYSENTER/SYSEXIT intructions (deprecated) --enable-apic enable APIC support (deprecated) --enable-ignore-bad-msr ignore bad MSR references (deprecated) @@ -22998,6 +22998,7 @@ fi +support_vmx=0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for VMX support" >&5 $as_echo_n "checking for VMX support... " >&6; } # Check whether --enable-vmx was given. @@ -23007,6 +23008,7 @@ if test "${enable_vmx+set}" = set; then : $as_echo "yes" >&6; } $as_echo "#define BX_SUPPORT_VMX 1" >>confdefs.h + support_vmx=1 elif test "$enableval" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } @@ -23025,6 +23027,10 @@ $as_echo "no" >&6; } fi +if test "$support_vmx" -lt 0 -a "$bx_cpu_level" -lt 6; then + as_fn_error "for VMX support the CPU level must be set to 6" "$LINENO" 5 +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MMX support" >&5 $as_echo_n "checking for MMX support... " >&6; } # Check whether --enable-mmx was given. @@ -23083,35 +23089,6 @@ $as_echo "no" >&6; } -fi - - -use_xsave=0 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for XSAVE/XRSTOR support" >&5 -$as_echo_n "checking for XSAVE/XRSTOR support... " >&6; } -# Check whether --enable-xsave was given. -if test "${enable_xsave+set}" = set; then : - enableval=$enable_xsave; if test "$enableval" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - $as_echo "#define BX_SUPPORT_XSAVE 1" >>confdefs.h - - use_xsave=1 - elif test "$enableval" = no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - $as_echo "#define BX_SUPPORT_XSAVE 0" >>confdefs.h - - fi - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - $as_echo "#define BX_SUPPORT_XSAVE 0" >>confdefs.h - - - fi @@ -25125,6 +25102,22 @@ $as_echo "no" >&6; } fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for XSAVE support (deprecated)" >&5 +$as_echo_n "checking for XSAVE support (deprecated)... " >&6; } +# Check whether --enable-xsave was given. +if test "${enable_xsave+set}" = set; then : + enableval=$enable_xsave; { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enableval" >&5 +$as_echo "$enableval" >&6; } + as_fn_error "DEPRECATED - moved to .bochsrc options" "$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 SEP support (deprecated)" >&5 $as_echo_n "checking for SEP support (deprecated)... " >&6; } # Check whether --enable-sep was given. diff --git a/bochs/configure.in b/bochs/configure.in index 05f63c10a..02c4421d4 100644 --- a/bochs/configure.in +++ b/bochs/configure.in @@ -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.426 2010-02-26 11:44:50 sshwarts Exp $]]) +AC_REVISION([[$Id: configure.in,v 1.427 2010-02-26 22:53:43 sshwarts Exp $]]) AC_CONFIG_HEADER(config.h) AC_CONFIG_HEADER(ltdlconf.h) @@ -1391,12 +1391,14 @@ AC_ARG_ENABLE(fpu, ) AC_SUBST(FPU_VAR) +support_vmx=0 AC_MSG_CHECKING(for VMX support) AC_ARG_ENABLE(vmx, [ --enable-vmx virtualization extensions], [if test "$enableval" = yes; then AC_MSG_RESULT(yes) AC_DEFINE(BX_SUPPORT_VMX, 1) + support_vmx=1 elif test "$enableval" = no; then AC_MSG_RESULT(no) AC_DEFINE(BX_SUPPORT_VMX, 0) @@ -1408,6 +1410,10 @@ AC_ARG_ENABLE(vmx, ] ) +if test "$support_vmx" -lt 0 -a "$bx_cpu_level" -lt 6; then + AC_MSG_ERROR([for VMX support the CPU level must be set to 6]) +fi + AC_MSG_CHECKING(for MMX support) AC_ARG_ENABLE(mmx, [ --enable-mmx MMX support], @@ -1447,25 +1453,6 @@ AC_ARG_ENABLE(3dnow, ] ) -use_xsave=0 -AC_MSG_CHECKING(for XSAVE/XRSTOR support) -AC_ARG_ENABLE(xsave, - [ --enable-xsave support for XSAVE/XRSTOR extensions], - [if test "$enableval" = yes; then - AC_MSG_RESULT(yes) - AC_DEFINE(BX_SUPPORT_XSAVE, 1) - use_xsave=1 - elif test "$enableval" = no; then - AC_MSG_RESULT(no) - AC_DEFINE(BX_SUPPORT_XSAVE, 0) - fi - ], - [ - AC_MSG_RESULT(no) - AC_DEFINE(BX_SUPPORT_XSAVE, 0) - ] - ) - AC_MSG_CHECKING(for alignment check support) AC_ARG_ENABLE(alignment-check, [ --enable-alignment-check alignment check (#AC) support], @@ -2697,6 +2684,16 @@ AC_ARG_ENABLE(aes, AC_MSG_RESULT(no) ]) +AC_MSG_CHECKING(for XSAVE support (deprecated)) +AC_ARG_ENABLE(xsave, + [ --enable-xsave support for XSAVE extensions (deprecated)], + [AC_MSG_RESULT($enableval) + AC_MSG_ERROR([DEPRECATED - moved to .bochsrc options]) + ], + [ + AC_MSG_RESULT(no) + ]) + AC_MSG_CHECKING(for SEP support (deprecated)) AC_ARG_ENABLE(sep, [ --enable-sep support for SYSENTER/SYSEXIT intructions (deprecated)], diff --git a/bochs/cpu/cpu.h b/bochs/cpu/cpu.h index 0664ce5df..2bbbaa012 100644 --- a/bochs/cpu/cpu.h +++ b/bochs/cpu/cpu.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: cpu.h,v 1.641 2010-02-26 11:44:50 sshwarts Exp $ +// $Id: cpu.h,v 1.642 2010-02-26 22:53:43 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001-2009 The Bochs Project @@ -755,9 +755,6 @@ typedef struct { #if BX_SUPPORT_FPU #include "cpu/i387.h" -#endif - -#if BX_CPU_LEVEL >= 6 #include "cpu/xmm.h" #endif @@ -876,7 +873,7 @@ public: // for now... bx_efer_t efer; #endif -#if BX_SUPPORT_XSAVE +#if BX_CPU_LEVEL >= 6 xcr0_t xcr0; #endif @@ -2875,18 +2872,18 @@ public: // for now... #if BX_SUPPORT_MISALIGNED_SSE -#define readVirtualDQwordAligned(s, off, data) \ - if (! MXCSR.get_misaligned_exception_mask()) { \ - read_virtual_dqword_aligned(s, off, data); \ - } \ - else { \ - read_virtual_dqword(s, off, data); \ +#define readVirtualDQwordAligned(s, off, data) \ + if (! BX_CPU_THIS_PTR mxcsr.get_misaligned_exception_mask()) { \ + read_virtual_dqword_aligned(s, off, data); \ + } \ + else { \ + read_virtual_dqword(s, off, data); \ } #else // BX_SUPPORT_MISALIGNED_SSE = 0 -#define readVirtualDQwordAligned(s, off, data) { \ - read_virtual_dqword_aligned(s, off, data); \ +#define readVirtualDQwordAligned(s, off, data) { \ + read_virtual_dqword_aligned(s, off, data); \ } #endif @@ -3341,7 +3338,7 @@ public: // for now... BX_SMF void print_state_SSE(void); #endif -#if BX_SUPPORT_XSAVE +#if BX_CPU_LEVEL >= 6 BX_SMF void prepareXSAVE(void); #endif @@ -3442,7 +3439,7 @@ BX_CPP_INLINE void BX_CPU_C::prepareSSE(void) } #endif -#if BX_SUPPORT_XSAVE +#if BX_CPU_LEVEL >= 6 BX_CPP_INLINE void BX_CPU_C::prepareXSAVE(void) { if(! BX_CPU_THIS_PTR cr4.get_OSXSAVE()) diff --git a/bochs/cpu/cpuid.cc b/bochs/cpu/cpuid.cc index fe770ef12..e576737f0 100755 --- a/bochs/cpu/cpuid.cc +++ b/bochs/cpu/cpuid.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: cpuid.cc,v 1.93 2010-02-26 14:18:18 sshwarts Exp $ +// $Id: cpuid.cc,v 1.94 2010-02-26 22:53:43 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (c) 2007-2009 Stanislav Shwartsman @@ -241,7 +241,7 @@ Bit32u BX_CPU_C::get_std_cpuid_features(void) #if BX_CPU_LEVEL >= 5 if (BX_CPU_THIS_PTR cpuid_features_bitmask & BX_CPU_PENTIUM) { // Pentium only features - features |= (1<<1); + features |= (1<<1); // support VME features |= (1<<3); // support PSE features |= (1<<4); // support Time Stamp Counter features |= (1<<5); // support RDMSR/WRMSR @@ -299,9 +299,7 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::CPUID(bxInstruction_c *i) { #if BX_CPU_LEVEL >= 4 Bit32u function = EAX; -#if BX_SUPPORT_XSAVE Bit32u subfunction = ECX; -#endif #if BX_SUPPORT_VMX if (BX_CPU_THIS_PTR in_vmx_guest) { @@ -324,14 +322,12 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::CPUID(bxInstruction_c *i) RDX &= ~(1<<9); // APIC on chip } #endif -#if BX_SUPPORT_XSAVE if (function == 0xD && subfunction > 0) { RAX = 0; RBX = 0; RCX = 0; RDX = 0; } -#endif return; } } @@ -408,7 +404,7 @@ void BX_CPU_C::set_cpuid_defaults(void) if (! cpuid_limit_winnt) { if (BX_SUPPORT_MONITOR_MWAIT) cpuid->eax = 0x5; - if (BX_SUPPORT_XSAVE) + if (BX_CPU_SUPPORT_FEATURE(BX_CPU_XSAVE)) cpuid->eax = 0xD; } #endif @@ -572,23 +568,24 @@ void BX_CPU_C::set_cpuid_defaults(void) cpuid->edx = 0; #endif -#if BX_SUPPORT_XSAVE // ------------------------------------------------------ // CPUID function 0x0000000D - cpuid = &(BX_CPU_THIS_PTR cpuid_std_function[0xD]); + if (BX_CPU_SUPPORT_FEATURE(BX_CPU_XSAVE)) + { + cpuid = &(BX_CPU_THIS_PTR cpuid_std_function[0xD]); - // EAX - XCR0 lower 32 bits - // EBX - Maximum size (in bytes) required by enabled features - // ECX - Maximum size (in bytes) required by CPU supported features - // EDX - XCR0 upper 32 bits - cpuid->eax = BX_CPU_THIS_PTR xcr0.get32(); - cpuid->ebx = 512+64; - cpuid->ecx = 512+64; - cpuid->edx = 0; -#endif + // EAX - XCR0 lower 32 bits + // EBX - Maximum size (in bytes) required by enabled features + // ECX - Maximum size (in bytes) required by CPU supported features + // EDX - XCR0 upper 32 bits + cpuid->eax = BX_CPU_THIS_PTR xcr0.get32(); + cpuid->ebx = 512+64; + cpuid->ecx = 512+64; + cpuid->edx = 0; + } // do not report Pentium 4 extended functions if not needed - if ((BX_CPU_THIS_PTR cpuid_features_bitmask & BX_CPU_SSE2) == 0) + if (! BX_CPU_SUPPORT_FEATURE(BX_CPU_SSE2)) return; // ------------------------------------------------------ @@ -769,6 +766,7 @@ void BX_CPU_C::init_cpu_features_bitmask(void) bx_bool sep_enabled = SIM->get_param_bool(BXPN_CPUID_SEP)->get(); bx_bool aes_enabled = SIM->get_param_bool(BXPN_CPUID_AES)->get(); bx_bool movbe_enabled = SIM->get_param_bool(BXPN_CPUID_MOVBE)->get(); + bx_bool xsave_enabled = SIM->get_param_bool(BXPN_CPUID_XSAVE)->get(); unsigned sse_enabled = SIM->get_param_enum(BXPN_CPUID_SSE)->get(); // sanity checks @@ -802,7 +800,7 @@ void BX_CPU_C::init_cpu_features_bitmask(void) } } else { - if (BX_SUPPORT_XSAVE) { + if (xsave_enabled) { BX_PANIC(("PANIC: XSAVE emulation requires SSE support !")); return; } @@ -870,24 +868,20 @@ void BX_CPU_C::init_cpu_features_bitmask(void) if (sep_enabled) features_bitmask |= BX_CPU_SYSENTER_SYSEXIT; + + if (xsave_enabled) + features_bitmask |= BX_CPU_XSAVE; + + if (aes_enabled) + features_bitmask |= BX_CPU_AES | BX_CPU_PCLMULQDQ; + + if (movbe_enabled) + features_bitmask |= BX_CPU_MOVBE; #endif #if BX_SUPPORT_VMX features_bitmask |= BX_CPU_VMX; #endif -#if BX_SUPPORT_XSAVE - features_bitmask |= BX_CPU_XSAVE; -#endif - -#if BX_CPU_LEVEL >= 6 - if (aes_enabled) { - features_bitmask |= BX_CPU_AES; - features_bitmask |= BX_CPU_PCLMULQDQ; - } - - if (movbe_enabled) - features_bitmask |= BX_CPU_MOVBE; -#endif #if BX_SUPPORT_X86_64 features_bitmask |= BX_CPU_X86_64; diff --git a/bochs/cpu/crregs.h b/bochs/cpu/crregs.h index 937a73b3e..b02e07138 100755 --- a/bochs/cpu/crregs.h +++ b/bochs/cpu/crregs.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: crregs.h,v 1.21 2010-02-25 22:04:30 sshwarts Exp $ +// $Id: crregs.h,v 1.22 2010-02-26 22:53:43 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (c) 2007-2009 Stanislav Shwartsman @@ -94,7 +94,7 @@ struct bx_cr4_t { #if BX_SUPPORT_VMX IMPLEMENT_CRREG_ACCESSORS(VMXE, 13); #endif -#if BX_SUPPORT_XSAVE +#if BX_CPU_LEVEL >= 6 IMPLEMENT_CRREG_ACCESSORS(OSXSAVE, 18); #endif @@ -125,7 +125,7 @@ struct bx_efer_t { #endif -#if BX_SUPPORT_XSAVE +#if BX_CPU_LEVEL >= 6 struct xcr0_t { Bit32u val32; // 32bit value of register diff --git a/bochs/cpu/init.cc b/bochs/cpu/init.cc index 537b30578..3477b64db 100644 --- a/bochs/cpu/init.cc +++ b/bochs/cpu/init.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: init.cc,v 1.227 2010-02-26 14:18:18 sshwarts Exp $ +// $Id: init.cc,v 1.228 2010-02-26 22:53:43 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001-2009 The Bochs Project @@ -362,8 +362,10 @@ void BX_CPU_C::register_state(void) #if BX_CPU_LEVEL >= 4 BXRS_HEX_PARAM_FIELD(cpu, CR4, cr4.val32); #endif -#if BX_SUPPORT_XSAVE - BXRS_HEX_PARAM_FIELD(cpu, XCR0, xcr0.val32); +#if BX_CPU_LEVEL >= 6 + if (BX_CPU_SUPPORT_FEATURE(BX_CPU_XSAVE)) { + BXRS_HEX_PARAM_FIELD(cpu, XCR0, xcr0.val32); + } #endif for(n=0; n<6; n++) { @@ -915,7 +917,7 @@ void BX_CPU_C::reset(unsigned source) BX_CPU_THIS_PTR cr4.set32(0); #endif -#if BX_SUPPORT_XSAVE +#if BX_CPU_LEVEL >= 6 BX_CPU_THIS_PTR xcr0.set32(0x1); #endif diff --git a/bochs/cpu/proc_ctrl.cc b/bochs/cpu/proc_ctrl.cc index 1e8f1a1d6..35905d0ee 100644 --- a/bochs/cpu/proc_ctrl.cc +++ b/bochs/cpu/proc_ctrl.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: proc_ctrl.cc,v 1.313 2010-02-26 11:44:50 sshwarts Exp $ +// $Id: proc_ctrl.cc,v 1.314 2010-02-26 22:53:43 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001-2009 The Bochs Project @@ -1460,8 +1460,10 @@ bx_address get_cr4_allow_mask(void) allowMask |= (1<<14); /* SMX Enable */ #endif -#if BX_SUPPORT_XSAVE - allowMask |= (1<<18); /* OSXSAVE */ +#if BX_CPU_LEVEL >= 6 + /* OSXSAVE */ + if (BX_CPU_SUPPORT_FEATURE(BX_CPU_XSAVE)) + allowMask |= (1<<18); #endif return allowMask; diff --git a/bochs/cpu/xsave.cc b/bochs/cpu/xsave.cc index aa24641a3..b8db1f930 100755 --- a/bochs/cpu/xsave.cc +++ b/bochs/cpu/xsave.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: xsave.cc,v 1.24 2009-12-04 21:27:17 sshwarts Exp $ +// $Id: xsave.cc,v 1.25 2010-02-26 22:53:43 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (c) 2008-2009 Stanislav Shwartsman @@ -35,7 +35,7 @@ /* 0F AE /4 */ void BX_CPP_AttrRegparmN(1) BX_CPU_C::XSAVE(bxInstruction_c *i) { -#if BX_SUPPORT_XSAVE +#if BX_CPU_LEVEL >= 6 unsigned index; BxPackedXmmRegister xmm; @@ -150,16 +150,13 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::XSAVE(bxInstruction_c *i) // always update header to 'dirty' state write_virtual_qword(i->seg(), eaddr + 512, header1); -#else - BX_INFO(("XSAVE: required XSAVE support, use --enable-xsave option")); - exception(BX_UD_EXCEPTION, 0, 0); #endif } /* 0F AE /5 */ void BX_CPP_AttrRegparmN(1) BX_CPU_C::XRSTOR(bxInstruction_c *i) { -#if BX_SUPPORT_XSAVE +#if BX_CPU_LEVEL >= 6 unsigned index; BxPackedXmmRegister xmm; @@ -301,16 +298,13 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::XRSTOR(bxInstruction_c *i) } } } -#else - BX_INFO(("XRSTOR: required XSAVE support, use --enable-xsave option")); - exception(BX_UD_EXCEPTION, 0, 0); #endif } /* 0F 01 D0 */ void BX_CPP_AttrRegparmN(1) BX_CPU_C::XGETBV(bxInstruction_c *i) { -#if BX_SUPPORT_XSAVE +#if BX_CPU_LEVEL >= 6 if(! BX_CPU_THIS_PTR cr4.get_OSXSAVE()) { BX_ERROR(("XGETBV: OSXSAVE feature is not enabled in CR4!")); exception(BX_UD_EXCEPTION, 0, 0); @@ -325,16 +319,13 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::XGETBV(bxInstruction_c *i) RDX = 0; RAX = BX_CPU_THIS_PTR xcr0.get32(); -#else - BX_INFO(("XGETBV: required XSAVE support, use --enable-xsave option")); - exception(BX_UD_EXCEPTION, 0, 0); #endif } /* 0F 01 D1 */ void BX_CPP_AttrRegparmN(1) BX_CPU_C::XSETBV(bxInstruction_c *i) { -#if BX_SUPPORT_XSAVE +#if BX_CPU_LEVEL >= 6 if(! BX_CPU_THIS_PTR cr4.get_OSXSAVE()) { BX_ERROR(("XSETBV: OSXSAVE feature is not enabled in CR4!")); exception(BX_UD_EXCEPTION, 0, 0); @@ -358,8 +349,5 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::XSETBV(bxInstruction_c *i) } BX_CPU_THIS_PTR xcr0.set32(EAX); -#else - BX_INFO(("XSETBV: required XSAVE support, use --enable-xsave option")); - exception(BX_UD_EXCEPTION, 0, 0); #endif } diff --git a/bochs/doc/docbook/user/user.dbk b/bochs/doc/docbook/user/user.dbk index 65a8cf4db..dcc71eb7c 100644 --- a/bochs/doc/docbook/user/user.dbk +++ b/bochs/doc/docbook/user/user.dbk @@ -1,7 +1,7 @@