From patchwork Fri Feb 24 10:52:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9589909 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 49F3560471 for ; Fri, 24 Feb 2017 10:55:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E1A02866A for ; Fri, 24 Feb 2017 10:55:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 230D02894F; Fri, 24 Feb 2017 10:55:54 +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 A5C2A2866A for ; Fri, 24 Feb 2017 10:55:53 +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 1chDVN-0003tz-Q1; Fri, 24 Feb 2017 10:53:41 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1chDVM-0003sw-Nz for xen-devel@lists.xen.org; Fri, 24 Feb 2017 10:53:40 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id FB/63-12625-3B010B85; Fri, 24 Feb 2017 10:53:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPLMWRWlGSWpSXmKPExsXS1tYhortZYEO Ewe99MhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8apXXdZCvbrV3Td/MnewDhVrYuRi0NIYBqj xOG1t5m7GDk5JAR4JY4sm8EKYftL7P/bzwZR1Mso0dN8ih0kwSagL7Hi8UGwIhEBaYlrny8zg hQxCyxklNj5qx0sISwQInHu0GmwBhYBVYnm6++AbA4OXgFbia9LkyAWyEtcuHqKBcTmFLCTuH hwNSOILQRUsq77AfMERt4FjAyrGDWKU4vKUot0jUz0kooy0zNKchMzc3QNDYz1clOLixPTU3M Sk4r1kvNzNzECA6KegYFxB+Or436HGCU5mJREef8/XB8hxJeUn1KZkVicEV9UmpNafIhRhoND SYI3mn9DhJBgUWp6akVaZg4wNGHSEhw8SiK870DSvMUFibnFmekQqVOMilLivIIgCQGQREZpH lwbLB4uMcpKCfMyMjAwCPEUpBblZpagyr9iFOdgVBLmrQSZwpOZVwI3/RXQYiagxZbOa0EWly QipKQaGE1cZCuUrhT2Np7dk3JLSNPl8OtJT5yTFJ2K8n1zyriS+VkTHPfuzFGNl9h8YxvzpQn WnUK2uub+jJ2H9ea9OcImyrhCrKJVXulhTInLpaezfe9osFwvypsj6ZM1e8HVW8f9g8WPGSrv EomrWnTPrO/xnD3slx+k7FvdHp9j93hPmkXCiTNdSizFGYmGWsxFxYkAcs5n+IICAAA= X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1487933615!86569883!2 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.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5175 invoked from network); 24 Feb 2017 10:53:39 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-10.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 24 Feb 2017 10:53:39 -0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2017 02:53:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,200,1484035200"; d="scan'208";a="937650283" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.133]) by orsmga003.jf.intel.com with ESMTP; 24 Feb 2017 02:53:35 -0800 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Fri, 24 Feb 2017 18:52:52 +0800 Message-Id: <20170224105256.24668-4-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170224105256.24668-1-haozhong.zhang@intel.com> References: <20170224105256.24668-1-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Christoph Egger , Jan Beulich , Andrew Cooper Subject: [Xen-devel] [PATCH 3/7] x86/mce: set mcinfo_comm.type and .size in x86_mcinfo_reserve() 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 All existing calls to x86_mcinfo_reserve() are followed by statements that set the size and the type of the reserved space, so move them into x86_mcinfo_reserve() to simplify the code. Signed-off-by: Haozhong Zhang Reviewed-by: Jan Beulich --- Cc: Christoph Egger Cc: Jan Beulich Cc: Andrew Cooper Changes: * Use "unsigned int" for arguments "size" and "type" of x86_mcinfo_reserve(). --- xen/arch/x86/cpu/mcheck/mcaction.c | 4 +--- xen/arch/x86/cpu/mcheck/mce.c | 17 +++++++++-------- xen/arch/x86/cpu/mcheck/mce.h | 3 ++- xen/arch/x86/cpu/mcheck/mce_amd.c | 4 +--- xen/arch/x86/cpu/mcheck/mce_intel.c | 6 +----- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/xen/arch/x86/cpu/mcheck/mcaction.c b/xen/arch/x86/cpu/mcheck/mcaction.c index 322163a..32056f2 100644 --- a/xen/arch/x86/cpu/mcheck/mcaction.c +++ b/xen/arch/x86/cpu/mcheck/mcaction.c @@ -13,14 +13,12 @@ mci_action_add_pageoffline(int bank, struct mc_info *mi, if (!mi) return NULL; - rec = x86_mcinfo_reserve(mi, sizeof(*rec)); + rec = x86_mcinfo_reserve(mi, sizeof(*rec), MC_TYPE_RECOVERY); if (!rec) { mi->flags |= MCINFO_FLAGS_UNCOMPLETE; return NULL; } - rec->common.type = MC_TYPE_RECOVERY; - rec->common.size = sizeof(*rec); rec->mc_bank = bank; rec->action_types = MC_ACTION_PAGE_OFFLINE; rec->action_info.page_retire.mfn = mfn; diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c index aa9304f..53ca29c 100644 --- a/xen/arch/x86/cpu/mcheck/mce.c +++ b/xen/arch/x86/cpu/mcheck/mce.c @@ -205,7 +205,7 @@ static void mca_init_bank(enum mca_source who, if (!mi) return; - mib = x86_mcinfo_reserve(mi, sizeof(*mib)); + mib = x86_mcinfo_reserve(mi, sizeof(*mib), MC_TYPE_BANK); if (!mib) { mi->flags |= MCINFO_FLAGS_UNCOMPLETE; @@ -214,8 +214,6 @@ static void mca_init_bank(enum mca_source who, mib->mc_status = mca_rdmsr(MSR_IA32_MCx_STATUS(bank)); - mib->common.type = MC_TYPE_BANK; - mib->common.size = sizeof (struct mcinfo_bank); mib->mc_bank = bank; mib->mc_domid = DOMID_INVALID; @@ -251,8 +249,6 @@ static int mca_init_global(uint32_t flags, struct mcinfo_global *mig) const struct vcpu *curr = current; /* Set global information */ - mig->common.type = MC_TYPE_GLOBAL; - mig->common.size = sizeof (struct mcinfo_global); status = mca_rdmsr(MSR_IA32_MCG_STATUS); mig->mc_gstatus = status; mig->mc_domid = DOMID_INVALID; @@ -349,7 +345,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(*mig)); + mig = x86_mcinfo_reserve(mci, sizeof(*mig), MC_TYPE_GLOBAL); /* mc_info should at least hold up the global information */ ASSERT(mig); mca_init_global(mc_flags, mig); @@ -805,7 +801,8 @@ static void mcinfo_clear(struct mc_info *mi) x86_mcinfo_nentries(mi) = 0; } -void *x86_mcinfo_reserve(struct mc_info *mi, int size) +void *x86_mcinfo_reserve(struct mc_info *mi, + unsigned int size, unsigned int type) { int i; unsigned long end1, end2; @@ -832,7 +829,11 @@ void *x86_mcinfo_reserve(struct mc_info *mi, int size) /* there's enough space. add entry. */ x86_mcinfo_nentries(mi)++; - return memset(mic_index, 0, size); + memset(mic_index, 0, size); + mic_index->size = size; + mic_index->type = type; + + return mic_index; } static void x86_mcinfo_apei_save( diff --git a/xen/arch/x86/cpu/mcheck/mce.h b/xen/arch/x86/cpu/mcheck/mce.h index a28e862..b479b20 100644 --- a/xen/arch/x86/cpu/mcheck/mce.h +++ b/xen/arch/x86/cpu/mcheck/mce.h @@ -150,7 +150,8 @@ typedef struct mcinfo_extended *(*x86_mce_callback_t) (struct mc_info *, uint16_t, uint64_t); extern void x86_mce_callback_register(x86_mce_callback_t); -void *x86_mcinfo_reserve(struct mc_info *mi, int size); +void *x86_mcinfo_reserve(struct mc_info *mi, + unsigned int size, unsigned int type); void x86_mcinfo_dump(struct mc_info *mi); static inline int mce_vendor_bank_msr(const struct vcpu *v, uint32_t msr) diff --git a/xen/arch/x86/cpu/mcheck/mce_amd.c b/xen/arch/x86/cpu/mcheck/mce_amd.c index 599e465..fe51be9 100644 --- a/xen/arch/x86/cpu/mcheck/mce_amd.c +++ b/xen/arch/x86/cpu/mcheck/mce_amd.c @@ -218,15 +218,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(*mc_ext)); + mc_ext = x86_mcinfo_reserve(mi, sizeof(*mc_ext), MC_TYPE_EXTENDED); if ( !mc_ext ) { mi->flags |= MCINFO_FLAGS_UNCOMPLETE; return NULL; } - mc_ext->common.type = MC_TYPE_EXTENDED; - mc_ext->common.size = sizeof(*mc_ext); mc_ext->mc_msrs = 3; mc_ext->mc_msr[0].reg = MSR_F10_MC4_MISC1; diff --git a/xen/arch/x86/cpu/mcheck/mce_intel.c b/xen/arch/x86/cpu/mcheck/mce_intel.c index 005e41d..189c1ed 100644 --- a/xen/arch/x86/cpu/mcheck/mce_intel.c +++ b/xen/arch/x86/cpu/mcheck/mce_intel.c @@ -200,17 +200,13 @@ 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(*mc_ext)); + mc_ext = x86_mcinfo_reserve(mi, sizeof(*mc_ext), MC_TYPE_EXTENDED); if (!mc_ext) { mi->flags |= MCINFO_FLAGS_UNCOMPLETE; return NULL; } - /* this function will called when CAP(9).MCG_EXT_P = 1 */ - mc_ext->common.type = MC_TYPE_EXTENDED; - mc_ext->common.size = sizeof(struct mcinfo_extended); - for (i = MSR_IA32_MCG_EAX; i <= MSR_IA32_MCG_MISC; i++) intel_get_extended_msr(mc_ext, i);