From: Borislav Petkov <bp@alien8.de>
To: James Morse <james.morse@arm.com>
Cc: linux-edac@vger.kernel.org,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Robert Richter <rrichter@marvell.com>,
Toshi Kani <toshi.kani@hpe.com>
Subject: Re: [PATCH] EDAC, ghes: Fix grain calculation
Date: Wed, 12 Jun 2019 06:34:10 +0200 [thread overview]
Message-ID: <20190612043410.GE32652@zn.tnic> (raw)
In-Reply-To: <20190529152232.187580-1-james.morse@arm.com>
On Wed, May 29, 2019 at 04:22:32PM +0100, James Morse wrote:
> ghes_edac_report_mem_error() attempts to calculate the 'grain' or
> granule affected by the error from the firmware-provided 'physical address
> mask'. This mask tells us which bits of the physical address are valid.
>
> The current calculation:
> | e->grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK);
> will always cause the top bits to be set as they are cleared by &,
> then set again by ~. For a hypervisor reporting its page-size as the
> region affected by the error:
> | {1}[Hardware Error]: physical_address: 0x00000000deadbeef
> | {1}[Hardware Error]: physical_address_mask: 0xfffffffffffff000
> | {1}[Hardware Error]: error_type: 6, master abort
> | EDAC MC0: 1 CE Master abort on unknown label ( page:0xdead offset:0xbeef
> | grain:-61441 syndrome:0x0 - status(0x0000000000000001): reserved)
>
> Here the grain has been miscalculated as the hypervisor reported a 4K
> size granule, due to its page size, whereas the guest kernel uses 64K.
> This gives us e->grain of 0xffffffffffff0fff
>
> Fix this, calculating grain_bits directly from ~physical_address_mask,
> and setting e->grain from that. In the same example we now get:
> | EDAC MC0: 1 CE Master abort on unknown label ( page:0xdead offset:0xbeef
> | grain:4096 syndrome:0x0 - status(0x0000000000000001): reserved)
>
> Cc: Robert Richter <rrichter@marvell.com>
> Cc: Toshi Kani <toshi.kani@hpe.com>
> Signed-off-by: James Morse <james.morse@arm.com>
> ---
> This has always been broken, so I suspect no-one cares about this, it was
> added by:
> Fixes: f04c62a7036a ("ghes_edac: add support for reporting errors via EDAC")
>
> I've only tested this with firmware I've written.
>
> drivers/edac/ghes_edac.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c
> index 49396bf6ad88..fac96ff45b7e 100644
> --- a/drivers/edac/ghes_edac.c
> +++ b/drivers/edac/ghes_edac.c
> @@ -202,8 +202,8 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
> struct mem_ctl_info *mci;
> struct ghes_edac_pvt *pvt = ghes_pvt;
> unsigned long flags;
> + u8 grain_bits = 0;
> char *p;
> - u8 grain_bits;
>
> if (!pvt)
> return;
> @@ -318,8 +318,10 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
> }
>
> /* Error grain */
> - if (mem_err->validation_bits & CPER_MEM_VALID_PA_MASK)
> - e->grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK);
> + if (mem_err->validation_bits & CPER_MEM_VALID_PA_MASK) {
> + grain_bits = fls_long(~mem_err->physical_addr_mask);
> + e->grain = 1UL<<grain_bits;
Do we need to set that e->grain at all?
I mean, we set it now so that grain_bits can be computed but since
you're doing that directly...
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
next prev parent reply other threads:[~2019-06-12 4:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-29 15:22 [PATCH] EDAC, ghes: Fix grain calculation James Morse
2019-05-30 16:50 ` Kani, Toshi
2019-06-12 4:34 ` Borislav Petkov [this message]
2019-06-13 17:06 ` James Morse
2019-06-13 19:18 ` Borislav Petkov
2019-06-13 21:07 ` Robert Richter
2019-06-13 22:41 ` Borislav Petkov
2019-06-14 7:21 ` Robert Richter
2019-06-14 8:39 ` Robert Richter
2019-06-14 10:09 ` Borislav Petkov
2019-06-14 14:40 ` Robert Richter
2019-06-14 15:06 ` Borislav Petkov
2019-06-14 6:32 ` Robert Richter
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=20190612043410.GE32652@zn.tnic \
--to=bp@alien8.de \
--cc=james.morse@arm.com \
--cc=linux-edac@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=rrichter@marvell.com \
--cc=toshi.kani@hpe.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).