MSR_TSC_AUX is not available without RDTSCP

This commit is contained in:
Stanislav Shwartsman 2011-08-21 19:09:35 +00:00
parent 371dc200fc
commit 002e7a3818
3 changed files with 24 additions and 2 deletions

View File

@ -3488,6 +3488,7 @@ public: // for now...
BX_SMF BX_CPP_INLINE int bx_cpuid_support_x2apic(void);
BX_SMF BX_CPP_INLINE int bx_cpuid_support_smx(void);
BX_SMF BX_CPP_INLINE int bx_cpuid_support_vmx(void);
BX_SMF BX_CPP_INLINE int bx_cpuid_support_rdtscp(void);
BX_SMF BX_CPP_INLINE unsigned which_cpu(void) { return BX_CPU_THIS_PTR bx_cpuid; }
#if BX_DEBUGGER
@ -4019,6 +4020,15 @@ BX_CPP_INLINE int BX_CPU_C::bx_cpuid_support_1g_paging(void)
#endif
}
BX_CPP_INLINE int BX_CPU_C::bx_cpuid_support_rdtscp(void)
{
#if BX_SUPPORT_X86_64
return (BX_CPU_THIS_PTR isa_extensions_bitmask & BX_CPU_RDTSCP);
#else
return 0;
#endif
}
//
// inline simple lazy flags implementation methods
//

View File

@ -245,6 +245,12 @@ bx_bool BX_CPP_AttrRegparmN(2) BX_CPU_C::rdmsr(Bit32u index, Bit64u *msr)
break;
case BX_MSR_TSC_AUX:
if (! bx_cpuid_support_rdtscp()) {
// failed to find the MSR, could #GP or ignore it silently
BX_ERROR(("RDMSR MSR_TSC_AUX: RTDSCP feature not enabled !"));
if (! BX_CPU_THIS_PTR ignore_bad_msrs)
return 0; // will result in #GP fault due to unknown MSR
}
val64 = MSR_TSC_AUX; // 32 bit MSR
break;
#endif
@ -634,6 +640,12 @@ bx_bool BX_CPP_AttrRegparmN(2) BX_CPU_C::wrmsr(Bit32u index, Bit64u val_64)
break;
case BX_MSR_TSC_AUX:
if (! bx_cpuid_support_rdtscp()) {
// failed to find the MSR, could #GP or ignore it silently
BX_ERROR(("WRMSR MSR_TSC_AUX: RTDSCP feature not enabled !"));
if (! BX_CPU_THIS_PTR ignore_bad_msrs)
return 0; // will result in #GP fault due to unknown MSR
}
MSR_TSC_AUX = val32_lo;
break;
#endif // #if BX_SUPPORT_X86_64

View File

@ -2694,10 +2694,10 @@ void ChangeReg()
Bit64u val;
val = cvt64(tmpcb,TRUE); // input either hex or decimal
#if BX_SUPPORT_X86_64
if (i >= EAX_Rnum && i <= EBP_Rnum) // must use RAX-RBP when setting 32b registers
if (i >= EAX_Rnum && i <= EBP_Rnum) // must use RAX-RBP when setting 32b registers
i -= EAX_Rnum - RAX_Rnum;
#endif
RegObject[CurrentCPU][i]->set(val); // the set function should be a bool, not a void
RegObject[CurrentCPU][i]->set(val); // the set function should be a bool, not a void
// bx_bool worked = RegObject[CurrentCPU][i]->set(val);
// if (worked == FALSE)
// DispMessage ("Bochs does not allow you to set that register","Selection Error");