The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Yazen Ghannam <yazen.ghannam@amd.com>
To: "Luck, Tony" <tony.luck@intel.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: Thu, 14 Aug 2025 11:39:33 -0400	[thread overview]
Message-ID: <20250814153933.GA148298@yaz-khff2.amd.com> (raw)
In-Reply-To: <aJ0Bmgx7-h1uMFG2@agluck-desk3>

On Wed, Aug 13, 2025 at 02:20:26PM -0700, Luck, Tony wrote:
> 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?

Yes, maybe. I do think we should get the severity once. Maybe this means
splitting context, action, message, etc., into separate helper functions
rather than all done in mce_severity().

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

Right, because of each mce_severity() call. Intel has multiple because
of the monarch reign flow. Those additional calls are just to get the
"message" for printing.

I have another revision with a more minimal diff. It'll just cover the
quirks case and leaves out the changes for VM86 and mce_severity() for
now.

Thanks,
Yazen

      reply	other threads:[~2025-08-14 15:39 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
2025-08-14 15:39   ` Yazen Ghannam [this message]

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=20250814153933.GA148298@yaz-khff2.amd.com \
    --to=yazen.ghannam@amd.com \
    --cc=avadhut.naik@amd.com \
    --cc=john.allen@amd.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.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