From: "Jan Beulich" Subject: [PATCH] x86: MCE fixes Date: Tue, 09 Feb 2010 13:26:26 +0000 Message-ID: <4B717092020000780002E75A@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartA2889592.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartA2889592.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline - fill_vmsr_data() leaked a domain reference; since the caller already obtained one, there's no need to obtain another one here - intel_UCR_handler() could call put_domain() with a NULL pointer - mcheck_mca_logout() updated a local data structure that wasn't used after the update Signed-off-by: Jan Beulich --- 2010-02-09.orig/xen/arch/x86/cpu/mcheck/mce.c 2010-02-03 = 16:15:15.000000000 +0100 +++ 2010-02-09/xen/arch/x86/cpu/mcheck/mce.c 2010-02-09 09:00:50.0000000= 00 +0100 @@ -300,13 +300,15 @@ mctelem_cookie_t mcheck_mca_logout(enum=20 =20 if (mci !=3D NULL && errcnt > 0) { x86_mcinfo_lookup(mic, mci, MC_TYPE_GLOBAL); - mig =3D (struct mcinfo_global *)mic; - if (pcc) - mcg.mc_flags |=3D MC_FLAG_UNCORRECTABLE; + mig =3D container_of(mic, struct mcinfo_global, common); + if (mic =3D=3D NULL) + ; + else if (pcc) + mig->mc_flags |=3D MC_FLAG_UNCORRECTABLE; else if (uc) - mcg.mc_flags |=3D MC_FLAG_RECOVERABLE; + mig->mc_flags |=3D MC_FLAG_RECOVERABLE; else - mcg.mc_flags |=3D MC_FLAG_CORRECTABLE; + mig->mc_flags |=3D MC_FLAG_CORRECTABLE; } =20 =20 --- 2010-02-09.orig/xen/arch/x86/cpu/mcheck/mce_intel.c 2010-02-03 = 16:15:15.000000000 +0100 +++ 2010-02-09/xen/arch/x86/cpu/mcheck/mce_intel.c 2010-02-09 = 09:16:49.000000000 +0100 @@ -225,22 +225,13 @@ static struct bank_entry* alloc_bank_ent for vMCE# MSRs virtualization */ =20 -static int fill_vmsr_data(struct mcinfo_bank *mc_bank,=20 +static int fill_vmsr_data(struct mcinfo_bank *mc_bank, struct domain *d, uint64_t gstatus) { - struct domain *d; struct bank_entry *entry; =20 /* This error bank impacts one domain, we need to fill domain related * data for vMCE MSRs virtualization and vMCE# injection */ if (mc_bank->mc_domid !=3D (uint16_t)~0) { - d =3D get_domain_by_id(mc_bank->mc_domid); - - /* Not impact a valid domain, skip this error of the bank */ - if (!d) { - mce_printk(MCE_QUIET, "MCE: Not found valid impacted DOM\n"); - return 0; - } - /* For HVM guest, Only when first vMCE is consumed by HVM guest = successfully, * will we generete another node and inject another vMCE */ @@ -365,15 +356,18 @@ static void intel_UCR_handler(struct mci if ( mca_ctl_conflict(bank, d) ) { /* Guest has different MCE ctl with = hypervisor */ - put_domain(d); + if ( d ) + put_domain(d); return; } =20 + ASSERT(d); gfn =3D get_gpfn_from_mfn((bank->mc_addr) >> = PAGE_SHIFT); bank->mc_addr =3D gfn << PAGE_SHIFT | (bank->mc_addr & (PAGE_SIZE -1 = )); - if (fill_vmsr_data(bank, global->mc_gstatus) = =3D=3D -1) + if ( fill_vmsr_data(bank, d, + global->mc_gstatus) =3D=3D = -1 ) { mce_printk(MCE_QUIET, "Fill vMCE# data for = DOM%d " "failed\n", result->owner); --=__PartA2889592.0__= Content-Type: text/plain; name="x86-mce-domain.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-mce-domain.patch" - fill_vmsr_data() leaked a domain reference; since the caller already=0A = obtained one, there's no need to obtain another one here=0A- intel_UCR_hand= ler() could call put_domain() with a NULL pointer=0A- mcheck_mca_logout() = updated a local data structure that wasn't used=0A after the update=0A=0AS= igned-off-by: Jan Beulich =0A=0A--- 2010-02-09.orig/xe= n/arch/x86/cpu/mcheck/mce.c 2010-02-03 16:15:15.000000000 +0100=0A+++ = 2010-02-09/xen/arch/x86/cpu/mcheck/mce.c 2010-02-09 09:00:50.0000000= 00 +0100=0A@@ -300,13 +300,15 @@ mctelem_cookie_t mcheck_mca_logout(enum = =0A =0A if (mci !=3D NULL && errcnt > 0) {=0A x86_mcinfo_= lookup(mic, mci, MC_TYPE_GLOBAL);=0A- mig =3D (struct mcinfo_glob= al *)mic;=0A- if (pcc)=0A- mcg.mc_flags |=3D = MC_FLAG_UNCORRECTABLE;=0A+ mig =3D container_of(mic, struct = mcinfo_global, common);=0A+ if (mic =3D=3D NULL)=0A+ = ;=0A+ else if (pcc)=0A+ mig->mc_fla= gs |=3D MC_FLAG_UNCORRECTABLE;=0A else if (uc)=0A- = mcg.mc_flags |=3D MC_FLAG_RECOVERABLE;=0A+ = mig->mc_flags |=3D MC_FLAG_RECOVERABLE;=0A else=0A- = mcg.mc_flags |=3D MC_FLAG_CORRECTABLE;=0A+ = mig->mc_flags |=3D MC_FLAG_CORRECTABLE;=0A }=0A =0A =0A--- 2010-02-09.= orig/xen/arch/x86/cpu/mcheck/mce_intel.c 2010-02-03 16:15:15.0000000= 00 +0100=0A+++ 2010-02-09/xen/arch/x86/cpu/mcheck/mce_intel.c 2010-02-09 = 09:16:49.000000000 +0100=0A@@ -225,22 +225,13 @@ static struct bank_entry* = alloc_bank_ent=0A for vMCE# MSRs virtualization=0A */=0A =0A-static = int fill_vmsr_data(struct mcinfo_bank *mc_bank, =0A+static int fill_vmsr_da= ta(struct mcinfo_bank *mc_bank, struct domain *d,=0A uint64_t = gstatus) {=0A- struct domain *d;=0A struct bank_entry *entry;=0A = =0A /* This error bank impacts one domain, we need to fill domain = related=0A * data for vMCE MSRs virtualization and vMCE# injection = */=0A if (mc_bank->mc_domid !=3D (uint16_t)~0) {=0A- d =3D = get_domain_by_id(mc_bank->mc_domid);=0A-=0A- /* Not impact a valid = domain, skip this error of the bank */=0A- if (!d) {=0A- = mce_printk(MCE_QUIET, "MCE: Not found valid impacted DOM\n");=0A- = return 0;=0A- }=0A-=0A /* For HVM guest, Only when first = vMCE is consumed by HVM guest successfully,=0A * will we generete = another node and inject another vMCE=0A */=0A@@ -365,15 +356,18 = @@ static void intel_UCR_handler(struct mci=0A = if ( mca_ctl_conflict(bank, d) )=0A {=0A = /* Guest has different MCE ctl with hypervisor = */=0A- put_domain(d);=0A+ = if ( d )=0A+ put_domain(d);=0A = return;=0A }=0A =0A+ = ASSERT(d);=0A gfn = =3D=0A get_gpfn_from_mfn((bank->mc_addr) >> = PAGE_SHIFT);=0A bank->mc_addr =3D gfn << = PAGE_SHIFT |=0A (bank->mc_addr & = (PAGE_SIZE -1 ));=0A- if (fill_vmsr_data(bank, = global->mc_gstatus) =3D=3D -1)=0A+ if ( fill_vmsr_= data(bank, d,=0A+ global->mc_g= status) =3D=3D -1 )=0A {=0A = mce_printk(MCE_QUIET, "Fill vMCE# data for DOM%d "=0A = "failed\n", result->owner);=0A --=__PartA2889592.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartA2889592.0__=--