Patchwork [36/49] x86: mce_banks always have the same size

login
register
mail settings
Submitter Juan Quintela
Date Sept. 29, 2009, 8:48 p.m.
Message ID <bac527d85cf2b6189f8e4655ef3800dfa031dce2.1254255997.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/34488/
State Superseded
Headers show

Comments

Juan Quintela - Sept. 29, 2009, 8:48 p.m.
mce_banks is always MCE_BANKS_DEF * 4 in size, value never change

CC: Huang Ying <ying.huang@intel.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 target-i386/cpu.h     |    2 +-
 target-i386/helper.c  |    3 +--
 target-i386/machine.c |    4 ++--
 3 files changed, 4 insertions(+), 5 deletions(-)

Patch

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index af122a1..bea9ac3 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -697,7 +697,7 @@  typedef struct CPUX86State {
     uint64 mcg_cap;
     uint64 mcg_status;
     uint64 mcg_ctl;
-    uint64 *mce_banks;
+    uint64 mce_banks[MCE_BANKS_DEF*4];
 } CPUX86State;

 CPUX86State *cpu_x86_init(const char *cpu_model);
diff --git a/target-i386/helper.c b/target-i386/helper.c
index 999c1bf..c961544 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -1597,8 +1597,7 @@  static void mce_init(CPUX86State *cenv)
         && (cenv->cpuid_features&(CPUID_MCE|CPUID_MCA)) == (CPUID_MCE|CPUID_MCA)) {
         cenv->mcg_cap = MCE_CAP_DEF | MCE_BANKS_DEF;
         cenv->mcg_ctl = ~(uint64_t)0;
-        bank_num = cenv->mcg_cap & 0xff;
-        cenv->mce_banks = qemu_mallocz(bank_num * sizeof(uint64_t) * 4);
+        bank_num = MCE_BANKS_DEF;
         for (bank = 0; bank < bank_num; bank++)
             cenv->mce_banks[bank*4] = ~(uint64_t)0;
     }
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 69e2620..88c085d 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -157,7 +157,7 @@  void cpu_save(QEMUFile *f, void *opaque)
     if (env->mcg_cap) {
         qemu_put_be64s(f, &env->mcg_status);
         qemu_put_be64s(f, &env->mcg_ctl);
-        for (i = 0; i < (env->mcg_cap & 0xff); i++) {
+        for (i = 0; i < MCE_BANKS_DEF; i++) {
             qemu_put_be64s(f, &env->mce_banks[4*i]);
             qemu_put_be64s(f, &env->mce_banks[4*i + 1]);
             qemu_put_be64s(f, &env->mce_banks[4*i + 2]);
@@ -354,7 +354,7 @@  int cpu_load(QEMUFile *f, void *opaque, int version_id)
         if (env->mcg_cap) {
             qemu_get_be64s(f, &env->mcg_status);
             qemu_get_be64s(f, &env->mcg_ctl);
-            for (i = 0; i < (env->mcg_cap & 0xff); i++) {
+            for (i = 0; i < MCE_BANKS_DEF; i++) {
                 qemu_get_be64s(f, &env->mce_banks[4*i]);
                 qemu_get_be64s(f, &env->mce_banks[4*i + 1]);
                 qemu_get_be64s(f, &env->mce_banks[4*i + 2]);