linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: <linux-edac@vger.kernel.org>, <linux-acpi@vger.kernel.org>,
	<linux-efi@vger.kernel.org>, Borislav Petkov <bp@alien8.de>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	<james.morse@arm.com>, <rjw@rjwysocki.net>, <tony.luck@intel.com>,
	<linuxarm@huawei.com>, <ard.biesheuvel@linaro.org>,
	<nariman.poushin@linaro.org>,
	Thanu Rangarajan <Thanu.Rangarajan@arm.com>
Subject: Re: [PATCH v4 1/6] efi / ras: CCIX Memory error reporting
Date: Thu, 14 Nov 2019 12:43:26 +0000	[thread overview]
Message-ID: <20191114124326.0000158c@huawei.com> (raw)
In-Reply-To: <20191114062227.46d6c60e@kernel.org>

On Thu, 14 Nov 2019 06:22:27 +0100
Mauro Carvalho Chehab <mchehab+huawei@kernel.org> wrote:

> Em Wed, 13 Nov 2019 23:16:22 +0800
> Jonathan Cameron <Jonathan.Cameron@huawei.com> escreveu:
> 
> > CCIX defines a number of different error types
> > (See CCIX spec 1.0) and UEFI 2.8 defines a CPER record to allow
> > for them to be reported when firmware first handling is in use.
> > The last part of that record is a copy of the CCIX protocol
> > error record which can provide very detailed information.
> > 
> > This patch introduces infrastructure and support for one of those
> > error types, CCIX Memory Errors.  Later patches will supply
> > equivalent support for the other error types.
> > 
> > The variable length and content of the different messages makes
> > a single tracepoint impractical.  As such the current RAS
> > tracepoint only covers the memory error. Additional trace points
> > will be introduced for other error types along with their
> > cper handling in a follow up series.  
> 
> I want to see the entire series before reviewing the tracepoint
> stuff.

Sorry, that's stray text left from an earlier version which only had
this patch.  The whole set are in this series.  This is the full set
of error recorded defined in the relevant specs.  I'll clear that
out in v5.

> 
> For now, I'm pointing just some issues I found at the code.
> 
> > 
> > RAS daemon support to follow shortly.  
> 
> That's ok. I probably will review RAS daemon patchsets only after we merge 
> the Kernel patchset.

This bit of the message is out of date as well.  Cover letter has link
to last posted version of RAS daemon patches.  I'll rebase those and
drop the legal boilerplate as done here.

> 
> > qemu injection patches
> > also available but not currently planing to upstream those.
> > 
...

> > +static int cper_ccix_err_location(struct cper_ccix_mem_err_compact *cmem_err,
> > +				  char *msg)
> > +{
> > +	u32 len = CPER_REC_LEN - 1;  
> 
> I don't like much the code here... I mean, based on the code below, the
> msg to be passed here should have CPER_REC_LEN, but the function  prototype
> doesn't reflect that. I would  instead, either pass len as a function parameter
> or change the above to something like:
> 
> 	static int cper_ccix_err_location(struct cper_ccix_mem_err_compact *cmem_err,
> 					  char msg[CPER_REC_LEN])
> 	{
> 		u32 len = sizeof(msg) - 1;

Annoyingly can't do this last part.  
warning: 'sizeof' on array function parameter 'msg' wil return size of 'char *'.

> 
> With that, gcc should be able to generate a warning if someone passes a
> buffer with a different size.

Agreed :) I may have taken copying local style a bit too far
here. Taken directly from cper.c cper_mem_err_location.

> 
> > +	u32 n = 0;
> > +
> > +	if (!msg)
> > +		return 0;
> > +
> > +	if (cmem_err->validation_bits & CCIX_MEM_ERR_GENERIC_MEM_VALID)
> > +		n += snprintf(msg + n, len, "Pool Generic Type: %s ",
> > +			      cper_ccix_mem_err_generic_type_str(cmem_err->pool_generic_type));  
> 
> Here, n will always be 0, so no need of doing msg + n.
and can use

n = sprintf(...) One we have change the first one to not stylistically math
the others might as well go the whole way.

> 
> > +
> > +	if (cmem_err->validation_bits & CCIX_MEM_ERR_MEM_ERR_TYPE_VALID)
> > +		n += snprintf(msg + n, len, "Err Type: %s ",
> > +			      cper_ccix_mem_err_type_str(cmem_err->mem_err_type));  
> 
> Well, as the msg buffer size is given by len, and you have already
> n characters there, you need to decrement the size at snprintf, in order
> to avoid going past of len, e. g., starting from here, all snprintf()
> statements should be, instead:
> 
> 		n += snprintf(msg + n, len - n, ...);

Gah. That's embarrassing.  Fixed.

> 
> 
> > +	if (cmem_err->validation_bits & CCIX_MEM_ERR_OP_VALID)
> > +		n += snprintf(msg + n, len, "Operation: %s ",
> > +			     cper_ccix_mem_err_op_str(cmem_err->op_type));
> > +
> > +	if (cmem_err->validation_bits & CCIX_MEM_ERR_CARD_VALID)
> > +		n += snprintf(msg + n, len, "Card: %d ", cmem_err->card);
> > +	if (cmem_err->validation_bits & CCIX_MEM_ERR_MOD_VALID)
> > +		n += snprintf(msg + n, len, "Mod: %d ", cmem_err->module);
> > +	if (cmem_err->validation_bits & CCIX_MEM_ERR_BANK_VALID)
> > +		n += snprintf(msg + n, len, "Bank: %d ", cmem_err->bank);
> > +	if (cmem_err->validation_bits & CCIX_MEM_ERR_DEVICE_VALID)
> > +		n += snprintf(msg + n, len, "Device: %d ", cmem_err->device);
> > +	if (cmem_err->validation_bits & CCIX_MEM_ERR_ROW_VALID)
> > +		n += snprintf(msg + n, len, "Row: %d ", cmem_err->row);
> > +	if (cmem_err->validation_bits & CCIX_MEM_ERR_COL_VALID)
> > +		n += snprintf(msg + n, len, "Col: %d ", cmem_err->column);
> > +	if (cmem_err->validation_bits & CCIX_MEM_ERR_RANK_VALID)
> > +		n += snprintf(msg + n, len, "Rank: %d ", cmem_err->rank);
> > +	if (cmem_err->validation_bits & CCIX_MEM_ERR_BIT_POS_VALID)
> > +		n += snprintf(msg + n, len, "BitPos: %d ", cmem_err->bit_pos);
> > +	if (cmem_err->validation_bits & CCIX_MEM_ERR_CHIP_ID_VALID)
> > +		n += snprintf(msg + n, len, "ChipID: %d ", cmem_err->chip_id);
> > +	if (cmem_err->validation_bits & CCIX_MEM_ERR_SPEC_TYPE_VALID)
> > +		n += snprintf(msg + n, len, "Pool Specific Type: %s ",
> > +			      cper_ccix_mem_err_spec_type_str(cmem_err->pool_specific_type));
> > +	n += snprintf(msg + n, len, "FRU: %d ", cmem_err->fru);
> > +
> > +	return n;
> > +}

...

Thanks, v5 to follow shortly with this stuff fixed across all patches,

Jonathan



  reply	other threads:[~2019-11-14 12:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13 15:16 [PATCH v4 0/6] CCIX Protocol error reporting Jonathan Cameron
2019-11-13 15:16 ` [PATCH v4 1/6] efi / ras: CCIX Memory " Jonathan Cameron
2019-11-14  5:22   ` Mauro Carvalho Chehab
2019-11-14 12:43     ` Jonathan Cameron [this message]
2019-11-13 15:16 ` [PATCH v4 2/6] efi / ras: CCIX Cache " Jonathan Cameron
2019-11-14  5:38   ` Mauro Carvalho Chehab
2019-11-14 13:17     ` Jonathan Cameron
2019-11-15  9:58       ` Jonathan Cameron
2019-11-13 15:16 ` [PATCH v4 3/6] efi / ras: CCIX Address Translation " Jonathan Cameron
2019-11-14  5:41   ` Mauro Carvalho Chehab
2019-11-13 15:16 ` [PATCH v4 4/6] efi / ras: CCIX Port " Jonathan Cameron
2019-11-13 15:16 ` [PATCH v4 5/6] efi / ras: CCIX Link " Jonathan Cameron
2019-11-13 15:16 ` [PATCH v4 6/6] efi / ras: CCIX Agent internal " Jonathan Cameron

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=20191114124326.0000158c@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=Thanu.Rangarajan@arm.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=bp@alien8.de \
    --cc=james.morse@arm.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mchehab+huawei@kernel.org \
    --cc=mchehab@kernel.org \
    --cc=nariman.poushin@linaro.org \
    --cc=rjw@rjwysocki.net \
    --cc=tony.luck@intel.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;
as well as URLs for NNTP newsgroup(s).