05bba0
From 5f40ed9dd62b914f259c1b6a51298fedb6bb2a24 Mon Sep 17 00:00:00 2001
05bba0
From: Eduardo Habkost <ehabkost@redhat.com>
05bba0
Date: Thu, 25 Jun 2015 19:31:26 +0200
05bba0
Subject: [PATCH 06/10] target-i386: fix set of registers zeroed on reset
05bba0
05bba0
Message-id: <1435260689-9556-6-git-send-email-ehabkost@redhat.com>
05bba0
Patchwork-id: 66505
05bba0
O-Subject: [RHEL-7.2 qemu-kvm PATCH 5/8] target-i386: fix set of registers zeroed on reset
05bba0
Bugzilla: 1233350
05bba0
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
05bba0
RH-Acked-by: Bandan Das <bsd@redhat.com>
05bba0
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
05bba0
05bba0
From: Paolo Bonzini <pbonzini@redhat.com>
05bba0
05bba0
BND0-3, BNDCFGU, BNDCFGS, BNDSTATUS were not zeroed on reset, but they
05bba0
should be (Intel Instruction Set Extensions Programming Reference
05bba0
319433-015, pages 9-4 and 9-6).  Same for YMM.
05bba0
05bba0
XCR0 should be reset to 1.
05bba0
05bba0
TSC and TSC_RESET were zeroed already by the memset, remove the explicit
05bba0
assignments.
05bba0
05bba0
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
05bba0
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
05bba0
(cherry picked from commit 05e7e819d7d159a75a46354aead95e1199b8f168)
05bba0
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
05bba0
Conflicts:
05bba0
	target-i386/cpu.c
05bba0
05bba0
Backport notes:
05bba0
 * The TSC and TSC_RESET reset lines were never added to the
05bba0
   qemu-kvm-1.5.3 tree
05bba0
---
05bba0
 target-i386/cpu.c |  2 ++
05bba0
 target-i386/cpu.h | 11 ++++++-----
05bba0
 2 files changed, 8 insertions(+), 5 deletions(-)
05bba0
05bba0
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
05bba0
index 2eeff5c..96af1bf 100644
05bba0
--- a/target-i386/cpu.c
05bba0
+++ b/target-i386/cpu.c
05bba0
@@ -2402,6 +2402,8 @@ static void x86_cpu_reset(CPUState *s)
05bba0
     cpu_breakpoint_remove_all(env, BP_CPU);
05bba0
     cpu_watchpoint_remove_all(env, BP_CPU);
05bba0
 
05bba0
+    env->xcr0 = 1;
05bba0
+
05bba0
     /*
05bba0
      * SDM 11.11.5 requires:
05bba0
      *  - IA32_MTRR_DEF_TYPE MSR.E = 0
05bba0
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
05bba0
index 7ebdbb3..715ba63 100644
05bba0
--- a/target-i386/cpu.h
05bba0
+++ b/target-i386/cpu.h
05bba0
@@ -798,6 +798,10 @@ typedef struct CPUX86State {
05bba0
     target_ulong cr[5]; /* NOTE: cr1 is unused */
05bba0
     int32_t a20_mask;
05bba0
 
05bba0
+    BNDReg bnd_regs[4];
05bba0
+    BNDCSReg bndcs_regs;
05bba0
+    uint64_t msr_bndcfgs;
05bba0
+
05bba0
     /* FPU state */
05bba0
     unsigned int fpstt; /* top of stack index */
05bba0
     uint16_t fpus;
05bba0
@@ -820,6 +824,8 @@ typedef struct CPUX86State {
05bba0
     XMMReg xmm_t0;
05bba0
     MMXReg mmx_t0;
05bba0
 
05bba0
+    XMMReg ymmh_regs[CPU_NB_REGS];
05bba0
+
05bba0
     /* sysenter registers */
05bba0
     uint32_t sysenter_cs;
05bba0
     target_ulong sysenter_esp;
05bba0
@@ -931,12 +937,7 @@ typedef struct CPUX86State {
05bba0
     uint16_t fpus_vmstate;
05bba0
     uint16_t fptag_vmstate;
05bba0
     uint16_t fpregs_format_vmstate;
05bba0
-
05bba0
     uint64_t xstate_bv;
05bba0
-    XMMReg ymmh_regs[CPU_NB_REGS];
05bba0
-    BNDReg bnd_regs[4];
05bba0
-    BNDCSReg bndcs_regs;
05bba0
-    uint64_t msr_bndcfgs;
05bba0
 
05bba0
     uint64_t xcr0;
05bba0
 
05bba0
-- 
05bba0
1.8.3.1
05bba0