]> xenbits.xensource.com Git - xen.git/commitdiff
x86: make x86_mcinfo_reserve() clear its result buffer
authorJan Beulich <jbeulich@suse.com>
Mon, 4 Mar 2013 09:25:24 +0000 (10:25 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 4 Mar 2013 09:25:24 +0000 (10:25 +0100)
... instead of all but one of its callers.

Also adjust the corresponding sizeof() expressions to specify the
pointed-to type of the result variable rather than the literal type
(so that a type change of the variable will imply the size to get
adjusted too).

Suggested-by: Ian Campbell <Ian.Campbell@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/cpu/mcheck/amd_f10.c
xen/arch/x86/cpu/mcheck/mcaction.c
xen/arch/x86/cpu/mcheck/mce.c
xen/arch/x86/cpu/mcheck/mce_intel.c

index 487fbce893dfc0b5688310f7fa317c2e5216803c..61319dc3ce07047d3cb9b8d8102e5b8dd8e377d5 100644 (file)
@@ -62,14 +62,13 @@ amd_f10_handler(struct mc_info *mi, uint16_t bank, uint64_t status)
        if (!(status & MCi_STATUS_MISCV))
                return NULL;
 
-       mc_ext = x86_mcinfo_reserve(mi, sizeof(struct mcinfo_extended));
+       mc_ext = x86_mcinfo_reserve(mi, sizeof(*mc_ext));
        if (!mc_ext)
        {
                mi->flags |= MCINFO_FLAGS_UNCOMPLETE;
                return NULL;
        }
 
-       memset(mc_ext, 0, sizeof(*mc_ext));
        mc_ext->common.type = MC_TYPE_EXTENDED;
        mc_ext->common.size = sizeof(*mc_ext);
        mc_ext->mc_msrs = 3;
index 27e37960fcb33cc3f395ea12767d986fbe515f90..5627192bbc6c06c0a6afe8ac2518c8afba7afcd6 100644 (file)
@@ -13,14 +13,12 @@ mci_action_add_pageoffline(int bank, struct mc_info *mi,
     if (!mi)
         return NULL;
 
-    rec = x86_mcinfo_reserve(mi, sizeof(struct mcinfo_recovery));
+    rec = x86_mcinfo_reserve(mi, sizeof(*rec));
     if (!rec) {
         mi->flags |= MCINFO_FLAGS_UNCOMPLETE;
         return NULL;
     }
 
-    memset(rec, 0, sizeof(struct mcinfo_recovery));
-
     rec->common.type = MC_TYPE_RECOVERY;
     rec->common.size = sizeof(*rec);
     rec->mc_bank = bank;
index 4e284248dd858b0a075a9b25336fcae6fe447239..ced1a89f4ffdf23479af959b6de545b139eb7a59 100644 (file)
@@ -200,14 +200,13 @@ static void mca_init_bank(enum mca_source who,
     if (!mi)
         return;
 
-    mib = x86_mcinfo_reserve(mi, sizeof(struct mcinfo_bank));
+    mib = x86_mcinfo_reserve(mi, sizeof(*mib));
     if (!mib)
     {
         mi->flags |= MCINFO_FLAGS_UNCOMPLETE;
         return;
     }
 
-    memset(mib, 0, sizeof (struct mcinfo_bank));
     mib->mc_status = mca_rdmsr(MSR_IA32_MCx_STATUS(bank));
 
     mib->common.type = MC_TYPE_BANK;
@@ -247,7 +246,6 @@ static int mca_init_global(uint32_t flags, struct mcinfo_global *mig)
     struct domain *d;
 
     /* Set global information */
-    memset(mig, 0, sizeof (struct mcinfo_global));
     mig->common.type = MC_TYPE_GLOBAL;
     mig->common.size = sizeof (struct mcinfo_global);
     status = mca_rdmsr(MSR_IA32_MCG_STATUS);
@@ -349,7 +347,7 @@ mcheck_mca_logout(enum mca_source who, struct mca_banks *bankmask,
             if ( (mctc = mctelem_reserve(which)) != NULL ) {
                 mci = mctelem_dataptr(mctc);
                 mcinfo_clear(mci);
-                mig = x86_mcinfo_reserve(mci, sizeof(struct mcinfo_global));
+                mig = x86_mcinfo_reserve(mci, sizeof(*mig));
                 /* mc_info should at least hold up the global information */
                 ASSERT(mig);
                 mca_init_global(mc_flags, mig);
@@ -820,7 +818,7 @@ void *x86_mcinfo_reserve(struct mc_info *mi, int size)
     /* there's enough space. add entry. */
     x86_mcinfo_nentries(mi)++;
 
-    return mic_index;
+    return memset(mic_index, 0, size);
 }
 
 void *x86_mcinfo_add(struct mc_info *mi, void *mcinfo)
index 00401109084642d5502b04fc653b2640e20a271d..b32fdb2fdbc9cc31a654ef6ffeca8b28fedeb7a0 100644 (file)
@@ -192,7 +192,7 @@ intel_get_extended_msrs(struct mcinfo_global *mig, struct mc_info *mi)
             !(mig->mc_gstatus & MCG_STATUS_EIPV))
         return NULL;
 
-    mc_ext = x86_mcinfo_reserve(mi, sizeof(struct mcinfo_extended));
+    mc_ext = x86_mcinfo_reserve(mi, sizeof(*mc_ext));
     if (!mc_ext)
     {
         mi->flags |= MCINFO_FLAGS_UNCOMPLETE;
@@ -200,7 +200,6 @@ intel_get_extended_msrs(struct mcinfo_global *mig, struct mc_info *mi)
     }
 
     /* this function will called when CAP(9).MCG_EXT_P = 1 */
-    memset(mc_ext, 0, sizeof(*mc_ext));
     mc_ext->common.type = MC_TYPE_EXTENDED;
     mc_ext->common.size = sizeof(struct mcinfo_extended);