先设置cr4的这些位
#define CR4_OSXSAVE_MASK (1U << 18)
#define CR4_OSFXSR_SHIFT 9
#define CR4_OSFXSR_MASK (1U << CR4_OSFXSR_SHIFT)
#define CR4_OSXMMEXCPT_MASK (1U << 10)
RegisterName = WHvX64RegisterCr4;
uint64_t cr4val = 0;
whpx_get_reg(RegisterName, &cr4val);
cr4val = (cr4val | (1ULL << 5)) & ~(1 << 24);
cr4val |= CR4_OSXSAVE_MASK;
cr4val |= CR4_OSFXSR_MASK;
cr4val |= CR4_OSXMMEXCPT_MASK;
whpx_set_reg(RegisterName, cr4val);
//再设置WHvX64RegisterXCr0的这些位
#define XSTATE_FP_BIT 0
#define XSTATE_SSE_BIT 1
#define XSTATE_FP_MASK (1ULL << XSTATE_FP_BIT)
#define XSTATE_SSE_MASK (1ULL << XSTATE_SSE_BIT)
WHV_REGISTER_VALUE xcr0;
WHV_REGISTER_NAME xcr0_name = WHvX64RegisterXCr0;
if (!whpx_has_xsave()) {
return;
}
env->xcr0 |= XSTATE_FP_MASK;
env->xcr0 |= XSTATE_SSE_MASK;
/* Only xcr0 is supported by the hypervisor currently */
xcr0.Reg64 = env->xcr0;
hr = WHvSetVirtualProcessorRegisters(whpx->partition, whpx->cpu_index,
&xcr0_name, 1, &xcr0);
就可以执行xmm指令了
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32