[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 15/16] target-i386: Enable CR4/XCR0 features for use
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH 15/16] target-i386: Enable CR4/XCR0 features for user-mode |
Date: |
Wed, 10 Feb 2016 04:43:51 +1100 |
Signed-off-by: Richard Henderson <address@hidden>
---
target-i386/cpu.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 4682166..063c8fb 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2643,6 +2643,8 @@ static void x86_cpu_reset(CPUState *s)
X86CPU *cpu = X86_CPU(s);
X86CPUClass *xcc = X86_CPU_GET_CLASS(cpu);
CPUX86State *env = &cpu->env;
+ target_ulong cr4;
+ uint64_t xcr0;
int i;
xcc->parent_reset(s);
@@ -2702,7 +2704,8 @@ static void x86_cpu_reset(CPUState *s)
cpu_set_fpuc(env, 0x37f);
env->mxcsr = 0x1f80;
- env->xstate_bv = XSTATE_FP | XSTATE_SSE;
+ /* All units are in INIT state. */
+ env->xstate_bv = 0;
env->pat = 0x0007040600070406ULL;
env->msr_ia32_misc_enable = MSR_IA32_MISC_ENABLE_DEFAULT;
@@ -2713,7 +2716,24 @@ static void x86_cpu_reset(CPUState *s)
cpu_breakpoint_remove_all(s, BP_CPU);
cpu_watchpoint_remove_all(s, BP_CPU);
- env->xcr0 = 1;
+ cr4 = 0;
+ xcr0 = XSTATE_FP;
+
+#ifdef CONFIG_USER_ONLY
+ /* Enable all the features for user-mode. */
+ if (env->features[FEAT_1_EDX] & CPUID_SSE) {
+ xcr0 |= XSTATE_SSE;
+ }
+ if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_MPX) {
+ xcr0 |= XSTATE_BNDREGS | XSTATE_BNDCSR;
+ }
+ if (env->features[FEAT_1_ECX] & CPUID_EXT_XSAVE) {
+ cr4 |= CR4_OSFXSR_MASK | CR4_OSXSAVE_MASK;
+ }
+#endif
+
+ env->xcr0 = xcr0;
+ cpu_x86_update_cr4(env, cr4);
/*
* SDM 11.11.5 requires:
--
2.5.0
- [Qemu-devel] [PATCH 05/16] target-i386: Implement XSAVEOPT, (continued)
- [Qemu-devel] [PATCH 05/16] target-i386: Implement XSAVEOPT, Richard Henderson, 2016/02/09
- [Qemu-devel] [PATCH 06/16] target-i386: Enable control registers for MPX, Richard Henderson, 2016/02/09
- [Qemu-devel] [PATCH 09/16] target-i386: Implement BNDMK, Richard Henderson, 2016/02/09
- [Qemu-devel] [PATCH 07/16] target-i386: Perform set/reset_inhibit_irq inline, Richard Henderson, 2016/02/09
- [Qemu-devel] [PATCH 08/16] target-i386: Split up gen_lea_modrm, Richard Henderson, 2016/02/09
- [Qemu-devel] [PATCH 10/16] target-i386: Implement BNDMOV, Richard Henderson, 2016/02/09
- [Qemu-devel] [PATCH 11/16] target-i386: Implement BNDCL, BNDCU, BNDCN, Richard Henderson, 2016/02/09
- [Qemu-devel] [PATCH 12/16] target-i386: Update BNDSTATUS for exceptions raised by BOUND, Richard Henderson, 2016/02/09
- [Qemu-devel] [PATCH 13/16] target-i386: Implement BNDLDX, BNDSTX, Richard Henderson, 2016/02/09
- [Qemu-devel] [PATCH 14/16] target-i386: Clear bndregs during legacy near jumps, Richard Henderson, 2016/02/09
- [Qemu-devel] [PATCH 15/16] target-i386: Enable CR4/XCR0 features for user-mode,
Richard Henderson <=
- [Qemu-devel] [PATCH 16/16] target-i386: Implement FSGSBASE, Richard Henderson, 2016/02/09