Linux EDAC development
 help / color / mirror / Atom feed
From: "Luck, Tony" <tony.luck@intel.com>
To: Yazen Ghannam <yazen.ghannam@amd.com>
Cc: <linux-edac@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<x86@kernel.org>, <avadhut.naik@amd.com>, <john.allen@amd.com>
Subject: Re: [PATCH] x86/mce: Do away with unnecessary context quirks
Date: Wed, 13 Aug 2025 14:20:26 -0700	[thread overview]
Message-ID: <aJ0Bmgx7-h1uMFG2@agluck-desk3> (raw)
In-Reply-To: <20250813154455.162489-1-yazen.ghannam@amd.com>

On Wed, Aug 13, 2025 at 03:44:55PM +0000, Yazen Ghannam wrote:

> -static noinstr void mce_gather_info(struct mce_hw_err *err, struct pt_regs *regs)
> +static noinstr void mce_gather_info(struct mce_hw_err *err)
>  {
> -	struct mce *m;
>  	/*
>  	 * Enable instrumentation around mce_prep_record() which calls external
>  	 * facilities.
> @@ -467,29 +466,7 @@ static noinstr void mce_gather_info(struct mce_hw_err *err, struct pt_regs *regs
>  	mce_prep_record(err);
>  	instrumentation_end();
>  
> -	m = &err->m;
> -	m->mcgstatus = mce_rdmsrq(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;
> -
> -			/*
> -			 * When in VM86 mode make the cs look like ring 3
> -			 * always. This is a lie, but it's better than passing
> -			 * the additional vm86 bit around everywhere.
> -			 */
> -			if (v8086_mode(regs))
> -				m->cs |= 3;
> -		}
> -		/* Use accurate RIP reporting if available. */
> -		if (mca_cfg.rip_msr)
> -			m->ip = mce_rdmsrq(mca_cfg.rip_msr);
> -	}

You moved an abbrevated vesion of this code from mce_gather_info() ...

>  static noinstr int error_context(struct mce *m, struct pt_regs *regs)
>  {
>  	int fixup_type;
>  	bool copy_user;
>  
> -	if ((m->cs & 3) == 3)
> +	/* Without register info, assume the worst. */
> +	if (!regs)
> +		return IN_KERNEL;
> +
> +	m->ip = regs->ip;
> +	m->cs = regs->cs;

... to here in error_context().

Would it work to hoist the error_context() code into mce_gather_info()
and have it set a new mce::error_context field?

I ask because mce_gather_info() is called once, while error_context()
is called multiple times (on Intel ... not sure of flow on AMD).

-Tony

  reply	other threads:[~2025-08-13 21:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13 15:44 [PATCH] x86/mce: Do away with unnecessary context quirks Yazen Ghannam
2025-08-13 21:20 ` Luck, Tony [this message]
2025-08-14 15:39   ` Yazen Ghannam

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=aJ0Bmgx7-h1uMFG2@agluck-desk3 \
    --to=tony.luck@intel.com \
    --cc=avadhut.naik@amd.com \
    --cc=john.allen@amd.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    --cc=yazen.ghannam@amd.com \
    /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