Received: from eggs.gnu.org ([2001:4830:134:3::10]:60414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZD72J-0001vr-4V for qemu-devel@nongnu.org; Thu, 09 Jul 2015 04:18:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZD72F-0002Q3-Jm for qemu-devel@nongnu.org; Thu, 09 Jul 2015 04:18:27 -0400 Received: from mail-ob0-x231.google.com ([2607:f8b0:4003:c01::231]:34007) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZD72F-0002Pt-Ex for qemu-devel@nongnu.org; Thu, 09 Jul 2015 04:18:23 -0400 Received: by obbkm3 with SMTP id km3so167096172obb.1 for ; Thu, 09 Jul 2015 01:18:23 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Thu, 9 Jul 2015 09:17:29 +0100 Message-Id: <1436429849-18052-15-git-send-email-rth@twiddle.net> In-Reply-To: <1436429849-18052-1-git-send-email-rth@twiddle.net> References: <1436429849-18052-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PATCH 14/14] target-i386: Enable XCR0 features for user-mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, ehabkost@redhat.com Signed-off-by: Richard Henderson --- target-i386/cpu.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index c19ff8a..2402c2a 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2654,7 +2654,17 @@ static void x86_cpu_reset(CPUState *s) cpu_set_fpuc(env, 0x37f); env->mxcsr = 0x1f80; - env->xstate_bv = XSTATE_FP | XSTATE_SSE; + + /* ??? This variable is somewhat silly. Methinks KVM should be + using XCR0 to store into the XSTATE_BV field. Either that or + there's more missing information, e.g. the AVX bits. */ + env->xstate_bv = XSTATE_FP; + if (env->features[FEAT_1_EDX] & CPUID_SSE) { + env->xstate_bv |= XSTATE_SSE; + } + if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_MPX) { + env->xstate_bv |= XSTATE_BNDREGS | XSTATE_BNDCSR; + } env->pat = 0x0007040600070406ULL; env->msr_ia32_misc_enable = MSR_IA32_MISC_ENABLE_DEFAULT; @@ -2665,7 +2675,15 @@ static void x86_cpu_reset(CPUState *s) cpu_breakpoint_remove_all(s, BP_CPU); cpu_watchpoint_remove_all(s, BP_CPU); - env->xcr0 = 1; + env->xcr0 = XSTATE_FP; + +#ifdef CONFIG_USER_ONLY + /* Enable all the features for user-mode. */ + env->xcr0 = env->xstate_bv; + if (env->features[FEAT_1_ECX] & CPUID_EXT_XSAVE) { + cpu_x86_update_cr4(env, CR4_OSFXSR_MASK | CR4_OSXSAVE_MASK); + } +#endif /* * SDM 11.11.5 requires: -- 2.4.3