From patchwork Mon Sep 11 07:57:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9946807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A613F603F3 for ; Mon, 11 Sep 2017 08:00:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98C9628B73 for ; Mon, 11 Sep 2017 08:00:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CF3D28B63; Mon, 11 Sep 2017 08:00:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1E5DB28B65 for ; Mon, 11 Sep 2017 08:00:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drJc0-0004q3-WF; Mon, 11 Sep 2017 07:58:32 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drJbz-0004ob-ML for xen-devel@lists.xen.org; Mon, 11 Sep 2017 07:58:31 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 14/54-02224-62246B95; Mon, 11 Sep 2017 07:58:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsXS1tYhoqvqtC3 S4MYHG4slHxezODB6HN39mymAMYo1My8pvyKBNWNK+wzmgs1GFYumbGRuYFwp38XIxSEkMJ1R Ys+7l2xdjJwcEgK8EkeWzWCFsP0lXvz/ywxR1Mso8fXaP3aQBJuAvsSKxwfBikQEpCWufb7MC GIzC1RLTFt5DmgQB4ewgI/Epac8IGEWAVWJrVsh5vMK2Eps/bGACWK+vMSutotgYzgF7CTWXn jNDGILAdU82H2BfQIj7wJGhlWMGsWpRWWpRbqG5npJRZnpGSW5iZk5uoYGxnq5qcXFiempOYl JxXrJ+bmbGIHhwAAEOxhfnvY8xCjJwaQkyvvu+JZIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8 3I7bIoUEi1LTUyvSMnOAgQmTluDgURLhve0AlOYtLkjMLc5Mh0idYtTl6Lh59w+TEEtefl6ql DgvD8gMAZCijNI8uBGwKLnEKCslzMsIdJQQT0FqUW5mCar8K0ZxDkYlYd77IKt4MvNK4Da9Aj qCCegInktbQI4oSURISTUwLgne45e588hWgzWnvXPddx+9+Pr8G7nfElqlpszmacrHShaGts3 pbEpQttEKf30rRyjfvLTb/SHba/aFp1jWuu2+cuZEfemiu12yek59U++1OhiL7P7560a0+GMh OUtxrcVvntYs0PRhvMD7Z1rXyl9n3HNclxr7LU+pvqnntGnr8lsrHjz+o8RSnJFoqMVcVJwIA BzwhIiNAgAA X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1505116705!83266332!3 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63415 invoked from network); 11 Sep 2017 07:58:29 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-11.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Sep 2017 07:58:29 -0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Sep 2017 00:58:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,376,1500966000"; d="scan'208";a="899032750" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.142]) by FMSMGA003.fm.intel.com with ESMTP; 11 Sep 2017 00:58:06 -0700 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Mon, 11 Sep 2017 15:57:55 +0800 Message-Id: <20170911075758.14869-4-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170911075758.14869-1-haozhong.zhang@intel.com> References: <20170911075758.14869-1-haozhong.zhang@intel.com> Cc: Andrew Cooper , Jan Beulich , Haozhong Zhang Subject: [Xen-devel] [PATCH 3/6] x86/mce: adapt mcation.c to Xen hypervisor coding style X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Haozhong Zhang --- xen/arch/x86/cpu/mcheck/mcaction.c | 74 +++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/xen/arch/x86/cpu/mcheck/mcaction.c b/xen/arch/x86/cpu/mcheck/mcaction.c index f959bed2cb..e42267414e 100644 --- a/xen/arch/x86/cpu/mcheck/mcaction.c +++ b/xen/arch/x86/cpu/mcheck/mcaction.c @@ -6,15 +6,16 @@ static struct mcinfo_recovery * mci_action_add_pageoffline(int bank, struct mc_info *mi, - uint64_t mfn, uint32_t status) + uint64_t mfn, uint32_t status) { struct mcinfo_recovery *rec; - if (!mi) + if ( !mi ) return NULL; rec = x86_mcinfo_reserve(mi, sizeof(*rec), MC_TYPE_RECOVERY); - if (!rec) { + if ( !rec ) + { mi->flags |= MCINFO_FLAGS_UNCOMPLETE; return NULL; } @@ -46,14 +47,15 @@ mc_memerr_dhandler(struct mca_binfo *binfo, int vmce_vcpuid; unsigned int mc_vcpuid; - if (!mc_check_addr(bank->mc_status, bank->mc_misc, MC_ADDR_PHYSICAL)) { + if ( !mc_check_addr(bank->mc_status, bank->mc_misc, MC_ADDR_PHYSICAL) ) + { dprintk(XENLOG_WARNING, - "No physical address provided for memory error\n"); + "No physical address provided for memory error\n"); return; } mfn = bank->mc_addr >> PAGE_SHIFT; - if (offline_page(mfn, 1, &status)) + if ( offline_page(mfn, 1, &status) ) { dprintk(XENLOG_WARNING, "Failed to offline page %lx for MCE error\n", mfn); @@ -63,21 +65,26 @@ mc_memerr_dhandler(struct mca_binfo *binfo, mci_action_add_pageoffline(binfo->bank, binfo->mi, mfn, status); /* This is free page */ - if (status & PG_OFFLINE_OFFLINED) + if ( status & PG_OFFLINE_OFFLINED ) *result = MCER_RECOVERED; - else if (status & PG_OFFLINE_AGAIN) + else if ( status & PG_OFFLINE_AGAIN ) *result = MCER_CONTINUE; - else if (status & PG_OFFLINE_PENDING) { + else if ( status & PG_OFFLINE_PENDING ) + { /* This page has owner */ - if (status & PG_OFFLINE_OWNED) { + if ( status & PG_OFFLINE_OWNED ) + { bank->mc_domid = status >> PG_OFFLINE_OWNER_SHIFT; mce_printk(MCE_QUIET, "MCE: This error page is ownded" - " by DOM %d\n", bank->mc_domid); - /* XXX: Cannot handle shared pages yet + " by DOM %d\n", bank->mc_domid); + /* + * XXX: Cannot handle shared pages yet * (this should identify all domains and gfn mapping to - * the mfn in question) */ + * the mfn in question) + */ BUG_ON( bank->mc_domid == DOMID_COW ); - if ( bank->mc_domid != DOMID_XEN ) { + if ( bank->mc_domid != DOMID_XEN ) + { d = get_domain_by_id(bank->mc_domid); ASSERT(d); gfn = get_gpfn_from_mfn((bank->mc_addr) >> PAGE_SHIFT); @@ -85,45 +92,46 @@ mc_memerr_dhandler(struct mca_binfo *binfo, if ( unmmap_broken_page(d, _mfn(mfn), gfn) ) { printk("Unmap broken memory %lx for DOM%d failed\n", - mfn, d->domain_id); + mfn, d->domain_id); goto vmce_failed; } mc_vcpuid = global->mc_vcpuid; - if (mc_vcpuid == XEN_MC_VCPUID_INVALID || - /* - * Because MC# may happen asynchronously with the actual - * operation that triggers the error, the domain ID as - * well as the vCPU ID collected in 'global' at MC# are - * not always precise. In that case, fallback to broadcast. - */ - global->mc_domid != bank->mc_domid || - (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && - (!(global->mc_gstatus & MCG_STATUS_LMCE) || - !(d->vcpu[mc_vcpuid]->arch.vmce.mcg_ext_ctl & - MCG_EXT_CTL_LMCE_EN)))) + if ( mc_vcpuid == XEN_MC_VCPUID_INVALID || + /* + * Because MC# may happen asynchronously with the actual + * operation that triggers the error, the domain ID as + * well as the vCPU ID collected in 'global' at MC# are + * not always precise. In that case, fallback to broadcast. + */ + global->mc_domid != bank->mc_domid || + (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && + (!(global->mc_gstatus & MCG_STATUS_LMCE) || + !(d->vcpu[mc_vcpuid]->arch.vmce.mcg_ext_ctl & + MCG_EXT_CTL_LMCE_EN))) ) vmce_vcpuid = VMCE_INJECT_BROADCAST; else vmce_vcpuid = mc_vcpuid; bank->mc_addr = gfn << PAGE_SHIFT | - (bank->mc_addr & (PAGE_SIZE -1 )); - if (fill_vmsr_data(bank, d, global->mc_gstatus, vmce_vcpuid)) + (bank->mc_addr & (PAGE_SIZE - 1)); + if ( fill_vmsr_data(bank, d, global->mc_gstatus, vmce_vcpuid) ) { mce_printk(MCE_QUIET, "Fill vMCE# data for DOM%d " - "failed\n", bank->mc_domid); + "failed\n", bank->mc_domid); goto vmce_failed; } - /* We will inject vMCE to DOMU*/ + /* We will inject vMCE to DOMU */ if ( inject_vmce(d, vmce_vcpuid) < 0 ) { mce_printk(MCE_QUIET, "inject vMCE to DOM%d" - " failed\n", d->domain_id); + " failed\n", d->domain_id); goto vmce_failed; } - /* Impacted domain go on with domain's recovery job + /* + * Impacted domain go on with domain's recovery job * if the domain has its own MCA handler. * For xen, it has contained the error and finished * its own recovery job.