extract xcr0_support bits calculation to a function
This commit is contained in:
parent
6bd7a954fc
commit
0c75e0beaf
@ -631,7 +631,7 @@ typedef struct
|
||||
#endif
|
||||
|
||||
#if BX_CPU_LEVEL >= 6
|
||||
Bit64u msr_xss;
|
||||
Bit64u ia32_xss;
|
||||
#endif
|
||||
|
||||
Bit32u ia32_spec_ctrl; // SCA
|
||||
@ -4817,6 +4817,8 @@ public: // for now...
|
||||
#endif
|
||||
|
||||
#if BX_CPU_LEVEL >= 6
|
||||
BX_SMF Bit32u get_xcr0_allow_mask(void);
|
||||
|
||||
BX_SMF bx_bool xsave_x87_state_xinuse(void);
|
||||
BX_SMF bx_bool xsave_sse_state_xinuse(void);
|
||||
#if BX_SUPPORT_AVX
|
||||
|
@ -320,7 +320,7 @@ void bx_cpuid_t::get_std_cpuid_xsave_leaf(Bit32u subfunction, cpuid_function_t *
|
||||
leaf->ebx = 0;
|
||||
if (is_cpu_extension_supported(BX_ISA_XSAVES)) {
|
||||
xcr0_t xcr0_xss = cpu->xcr0;
|
||||
xcr0_xss.val32 |= cpu->msr.msr_xss;
|
||||
xcr0_xss.val32 |= cpu->msr.ia32_xss;
|
||||
#if BX_SUPPORT_AVX
|
||||
if (xcr0_xss.get_YMM())
|
||||
leaf->ebx = XSAVE_YMM_STATE_OFFSET + XSAVE_YMM_STATE_LEN;
|
||||
|
@ -1633,3 +1633,24 @@ void BX_CPU_C::iobreakpoint_match(unsigned port, unsigned len)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if BX_CPU_LEVEL >= 6
|
||||
Bit32u BX_CPU_C::get_xcr0_allow_mask()
|
||||
{
|
||||
Bit32u allowMask = 0x3;
|
||||
#if BX_SUPPORT_AVX
|
||||
if (BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_AVX))
|
||||
allowMask |= BX_XCR0_YMM_MASK;
|
||||
#if BX_SUPPORT_EVEX
|
||||
if (BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_AVX512))
|
||||
allowMask |= BX_XCR0_OPMASK_MASK | BX_XCR0_ZMM_HI256_MASK | BX_XCR0_HI_ZMM_MASK;
|
||||
#endif
|
||||
#endif // BX_SUPPORT_AVX
|
||||
#if BX_SUPPORT_PKEYS
|
||||
if (BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_PKU))
|
||||
allowMask |= BX_XCR0_PKRU_MASK;
|
||||
#endif
|
||||
|
||||
return allowMask;
|
||||
}
|
||||
#endif
|
||||
|
@ -389,7 +389,7 @@ void BX_CPU_C::register_state(void)
|
||||
BXRS_HEX_PARAM_FIELD(MSR, mtrr_deftype, msr.mtrr_deftype);
|
||||
|
||||
if (BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_XSAVES)) {
|
||||
BXRS_HEX_PARAM_FIELD(MSR, msr_xss, msr.msr_xss);
|
||||
BXRS_HEX_PARAM_FIELD(MSR, ia32_xss, msr.ia32_xss);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -828,20 +828,9 @@ void BX_CPU_C::reset(unsigned source)
|
||||
if (source == BX_RESET_HARDWARE) {
|
||||
BX_CPU_THIS_PTR xcr0.set32(0x1);
|
||||
}
|
||||
BX_CPU_THIS_PTR xcr0_suppmask = 0x3;
|
||||
#if BX_SUPPORT_AVX
|
||||
if (BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_AVX))
|
||||
BX_CPU_THIS_PTR xcr0_suppmask |= BX_XCR0_YMM_MASK;
|
||||
#if BX_SUPPORT_EVEX
|
||||
if (BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_AVX512))
|
||||
BX_CPU_THIS_PTR xcr0_suppmask |= BX_XCR0_OPMASK_MASK | BX_XCR0_ZMM_HI256_MASK | BX_XCR0_HI_ZMM_MASK;
|
||||
#endif
|
||||
#endif // BX_SUPPORT_AVX
|
||||
#if BX_SUPPORT_PKEYS
|
||||
if (BX_CPUID_SUPPORT_ISA_EXTENSION(BX_ISA_PKU))
|
||||
BX_CPU_THIS_PTR xcr0_suppmask |= BX_XCR0_PKRU_MASK;
|
||||
#endif
|
||||
BX_CPU_THIS_PTR msr.msr_xss = 0;
|
||||
BX_CPU_THIS_PTR xcr0_suppmask = get_xcr0_allow_mask();
|
||||
|
||||
BX_CPU_THIS_PTR msr.ia32_xss = 0;
|
||||
#endif // BX_CPU_LEVEL >= 6
|
||||
|
||||
BX_CPU_THIS_PTR msr.ia32_spec_ctrl = 0;
|
||||
|
@ -164,7 +164,7 @@ bx_bool BX_CPP_AttrRegparmN(2) BX_CPU_C::rdmsr(Bit32u index, Bit64u *msr)
|
||||
|
||||
#if BX_CPU_LEVEL >= 6
|
||||
case BX_MSR_XSS:
|
||||
val64 = BX_CPU_THIS_PTR msr.msr_xss;
|
||||
val64 = BX_CPU_THIS_PTR msr.ia32_xss;
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
@ -190,7 +190,7 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::XSAVEC(bxInstruction_c *i)
|
||||
|
||||
VMCS_CACHE *vm = &BX_CPU_THIS_PTR vmcs;
|
||||
Bit64u requested_features = (((Bit64u) EDX) << 32) | EAX;
|
||||
if (requested_features & BX_CPU_THIS_PTR msr.msr_xss & vm->xss_exiting_bitmap)
|
||||
if (requested_features & BX_CPU_THIS_PTR msr.ia32_xss & vm->xss_exiting_bitmap)
|
||||
VMexit_Instruction(i, VMX_VMEXIT_XSAVES);
|
||||
}
|
||||
#endif
|
||||
@ -221,7 +221,7 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::XSAVEC(bxInstruction_c *i)
|
||||
|
||||
Bit32u xcr0 = BX_CPU_THIS_PTR xcr0.get32();
|
||||
if (xsaves)
|
||||
xcr0 |= BX_CPU_THIS_PTR msr.msr_xss;
|
||||
xcr0 |= BX_CPU_THIS_PTR msr.ia32_xss;
|
||||
|
||||
Bit32u requested_feature_bitmap = xcr0 & EAX;
|
||||
Bit32u xinuse = get_xinuse_vector(requested_feature_bitmap);
|
||||
@ -326,7 +326,7 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::XRSTOR(bxInstruction_c *i)
|
||||
|
||||
VMCS_CACHE *vm = &BX_CPU_THIS_PTR vmcs;
|
||||
Bit64u requested_features = (((Bit64u) EDX) << 32) | EAX;
|
||||
if (requested_features & BX_CPU_THIS_PTR msr.msr_xss & vm->xss_exiting_bitmap)
|
||||
if (requested_features & BX_CPU_THIS_PTR msr.ia32_xss & vm->xss_exiting_bitmap)
|
||||
VMexit_Instruction(i, VMX_VMEXIT_XRSTORS);
|
||||
}
|
||||
#endif
|
||||
@ -373,7 +373,7 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::XRSTOR(bxInstruction_c *i)
|
||||
|
||||
Bit32u xcr0 = BX_CPU_THIS_PTR xcr0.get32();
|
||||
if (xrstors)
|
||||
xcr0 |= BX_CPU_THIS_PTR msr.msr_xss;
|
||||
xcr0 |= BX_CPU_THIS_PTR msr.ia32_xss;
|
||||
|
||||
if (! compaction) {
|
||||
if ((~xcr0 & xstate_bv) != 0 || (GET32H(xstate_bv) << 1) != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user