Re: [PATCH 2/2] RAS: Introduce the FRU Memory Poison Manager

From: Borislav Petkov
Date: Wed Feb 14 2024 - 15:10:57 EST


On Wed, Feb 14, 2024 at 10:26:41AM -0500, Yazen Ghannam wrote:
> > > +static bool is_valid_fmp(struct fru_rec *rec)
> >
> > fmp_is_valid()
> >
>
> Ack.

diff --git a/drivers/ras/amd/fmpm.c b/drivers/ras/amd/fmpm.c
index bcee828cb916..3600bf0dca53 100644
--- a/drivers/ras/amd/fmpm.c
+++ b/drivers/ras/amd/fmpm.c
@@ -447,7 +447,7 @@ static int save_new_records(void)
return ret;
}

-static bool is_valid_fmp(struct fru_rec *rec)
+static bool fmp_is_valid(struct fru_rec *rec)
{
struct cper_sec_fru_mem_poison *fmp = &rec->fmp;
u32 len = get_fmp_len(rec);
@@ -486,19 +486,12 @@ static bool is_valid_fmp(struct fru_rec *rec)
return true;
}

-static void restore_record(struct fru_rec *new, struct fru_rec *old)
-{
- /* Records larger than max_rec_len were skipped earlier. */
- size_t len = min(max_rec_len, old->hdr.record_length);
-
- memcpy(new, old, len);
-}
-
static bool valid_record(struct fru_rec *old)
{
struct fru_rec *new;
+ size_t len;

- if (!is_valid_fmp(old)) {
+ if (!fmp_is_valid(old)) {
pr_debug("Ignoring invalid record");
return false;
}
@@ -509,8 +502,11 @@ static bool valid_record(struct fru_rec *old)
return false;
}

- /* What if ERST has duplicate FRU entries? */
- restore_record(new, old);
+ /* Records larger than max_rec_len were skipped earlier. */
+ len = min(max_rec_len, old->hdr.record_length);
+
+ /* Restore the record */
+ memcpy(new, old, len);

return true;
}

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette