public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
To: linux-kernel@vger.kernel.org
Cc: "x86@kernel.org" <x86@kernel.org>, Ingo Molnar <mingo@elte.hu>,
	Borislav Petkov <bp@amd64.org>, Tony Luck <tony.luck@gmail.com>
Subject: [PATCH 07/12] x86, mce: introduce mce_gather_info()
Date: Wed, 08 Jun 2011 10:57:46 +0900	[thread overview]
Message-ID: <4DEED71A.1060906@jp.fujitsu.com> (raw)
In-Reply-To: <4DEED509.1040504@jp.fujitsu.com>

This patch introduces new function mce_gather_info() to be called
at beginning of error handling, to gather minimum error information
from proper error registers (and saved registers).

As the result the mce_get_rip() is integrated and unnecessary
zero-ing is removed.  This also fix an expected issue that RIP is
required to make some decision about error severity (for SRAR errors)
but it was retrieved later in the handler.

v2:
  update comment (Thanks Tony)

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
CC: Tony Luck <tony.luck@intel.com>
---
 arch/x86/kernel/cpu/mcheck/mce.c |   50 ++++++++++++++++++++-----------------
 1 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index e807508..a182875 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -369,6 +369,31 @@ static void mce_wrmsrl(u32 msr, u64 v)
 }
 
 /*
+ * Collect all global (w.r.t. this processor) status about this machine
+ * check into our "mce" struct so that we can use it later to assess
+ * the severity of the problem as we read per-bank specific details.
+ */
+static inline void mce_gather_info(struct mce *m, struct pt_regs *regs)
+{
+	mce_setup(m);
+
+	m->mcgstatus = mce_rdmsrl(MSR_IA32_MCG_STATUS);
+	if (regs) {
+		/*
+		 * Get the address of the instruction at the time of
+		 * the machine check error.
+		 */
+		if (m->mcgstatus & (MCG_STATUS_RIPV|MCG_STATUS_EIPV)) {
+			m->ip = regs->ip;
+			m->cs = regs->cs;
+		}
+		/* Use accurate RIP reporting if available. */
+		if (rip_msr)
+			m->ip = mce_rdmsrl(rip_msr);
+	}
+}
+
+/*
  * Simple lockless ring to communicate PFNs from the exception handler with the
  * process context work function. This is vastly simplified because there's
  * only a single reader and a single writer.
@@ -439,24 +464,6 @@ static void mce_schedule_work(void)
 	}
 }
 
-/*
- * Get the address of the instruction at the time of the machine check
- * error.
- */
-static inline void mce_get_rip(struct mce *m, struct pt_regs *regs)
-{
-
-	if (regs && (m->mcgstatus & (MCG_STATUS_RIPV|MCG_STATUS_EIPV))) {
-		m->ip = regs->ip;
-		m->cs = regs->cs;
-	} else {
-		m->ip = 0;
-		m->cs = 0;
-	}
-	if (rip_msr)
-		m->ip = mce_rdmsrl(rip_msr);
-}
-
 DEFINE_PER_CPU(struct irq_work, mce_irq_work);
 
 static void mce_irq_work_cb(struct irq_work *entry)
@@ -506,9 +513,8 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b)
 
 	percpu_inc(mce_poll_count);
 
-	mce_setup(&m);
+	mce_gather_info(&m, NULL);
 
-	m.mcgstatus = mce_rdmsrl(MSR_IA32_MCG_STATUS);
 	for (i = 0; i < banks; i++) {
 		if (!mce_banks[i].ctl || !test_bit(i, *b))
 			continue;
@@ -907,9 +913,8 @@ void do_machine_check(struct pt_regs *regs, long error_code)
 	if (!banks)
 		goto out;
 
-	mce_setup(&m);
+	mce_gather_info(&m, regs);
 
-	m.mcgstatus = mce_rdmsrl(MSR_IA32_MCG_STATUS);
 	final = &__get_cpu_var(mces_seen);
 	*final = m;
 
@@ -993,7 +998,6 @@ void do_machine_check(struct pt_regs *regs, long error_code)
 		if (severity == MCE_AO_SEVERITY && mce_usable_address(&m))
 			mce_ring_add(m.addr >> PAGE_SHIFT);
 
-		mce_get_rip(&m, regs);
 		mce_log(&m);
 
 		if (severity > worst) {
-- 
1.7.1



  parent reply	other threads:[~2011-06-08  1:58 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-08  1:48 [PATCH 00/12] x86: minor cleanups/fixes for MCE codes (v2) Hidetoshi Seto
2011-06-08  1:51 ` [PATCH 01/12] mce-severity: fixes for mce severity table Hidetoshi Seto
2011-06-16 11:16   ` [tip:ras/core] x86, mce, severity: Fix two severities table signatures tip-bot for Tony Luck
2011-06-08  1:52 ` [PATCH 02/12] mce-severity: cleanup severity table, prep Hidetoshi Seto
2011-06-16 11:16   ` [tip:ras/core] x86, mce, severity: Make formatting a bit more readable tip-bot for Hidetoshi Seto
2011-06-08  1:53 ` [PATCH 03/12] mce-severity: cleanup severity table Hidetoshi Seto
2011-06-16 11:16   ` [tip:ras/core] x86, mce, severity: Cleanup " tip-bot for Hidetoshi Seto
2011-06-08  1:55 ` [PATCH 04/12] mce-severity: trivial cleanups Hidetoshi Seto
2011-06-16 11:17   ` [tip:ras/core] x86, mce, severity: Clean up trivial coding style problems tip-bot for Hidetoshi Seto
2011-06-08  1:56 ` [PATCH 05/12] x86, mce: replace MCE_SELF_VECTOR by irq_work Hidetoshi Seto
2011-06-16 11:17   ` [tip:ras/core] x86, mce: Replace " tip-bot for Hidetoshi Seto
2011-06-08  1:56 ` [PATCH 06/12] x86, mce: replace MCM_ to MCI_MISC_ Hidetoshi Seto
2011-06-16 11:18   ` [tip:ras/core] x86, mce: Replace MCM_ with MCI_MISC_ tip-bot for Hidetoshi Seto
2011-06-08  1:57 ` Hidetoshi Seto [this message]
2011-06-16 11:18   ` [tip:ras/core] x86, mce: Introduce mce_gather_info() tip-bot for Hidetoshi Seto
2011-06-08  1:58 ` [PATCH 08/12] x86, mce: check the result of ancient_init() Hidetoshi Seto
2011-06-16 11:19   ` [tip:ras/core] x86, mce: Check " tip-bot for Hidetoshi Seto
2011-06-08  1:59 ` [PATCH 09/12] x86, mce: cleanup mce_create/remove_device Hidetoshi Seto
2011-06-16 11:19   ` [tip:ras/core] x86, mce: Cleanup mce_create()/remove_device() tip-bot for Hidetoshi Seto
2011-06-08  2:00 ` [PATCH 10/12] x86, mce: cleanup mce_read Hidetoshi Seto
2011-06-16 11:19   ` [tip:ras/core] x86, mce: Cleanup mce_read() tip-bot for Hidetoshi Seto
2011-06-08  2:00 ` [PATCH 11/12] x86, mce: use prefix mce_chrdev_ to group functions Hidetoshi Seto
2011-06-16 11:20   ` [tip:ras/core] x86, mce: Use mce_chrdev_ prefix " tip-bot for Hidetoshi Seto
2011-06-08  2:02 ` [PATCH 12/12] x86, mce: use prefix mce_sysdev_ " Hidetoshi Seto
2011-06-16 11:20   ` [tip:ras/core] x86, mce: Use mce_sysdev_ prefix " tip-bot for Hidetoshi Seto
2011-06-08 10:19 ` [PATCH 00/12] x86: minor cleanups/fixes for MCE codes (v2) Borislav Petkov
2011-06-10  8:24   ` Hidetoshi Seto
  -- strict thread matches above, loose matches on Subject: below --
2011-05-27  4:00 [PATCH 00/12] minor cleanups/fixes for MCE codes Hidetoshi Seto
2011-05-27  4:09 ` [PATCH 07/12] x86, mce: introduce mce_gather_info() Hidetoshi Seto
2011-05-27  6:27   ` Tony Luck
2011-05-27  8:00     ` Ingo Molnar
2011-05-27 16:29       ` Tony Luck
2011-05-30  5:42         ` Hidetoshi Seto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DEED71A.1060906@jp.fujitsu.com \
    --to=seto.hidetoshi@jp.fujitsu.com \
    --cc=bp@amd64.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tony.luck@gmail.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox