linux-edac.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: Borislav Petkov <bp@alien8.de>
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: Thu, 13 Jun 2019 18:06:22 +0100	[thread overview]
Message-ID: <9bda9613-09b3-aa6d-183f-3668ef9a99c6@arm.com> (raw)
In-Reply-To: <20190612043410.GE32652@zn.tnic>

Hi Boris,

On 12/06/2019 05:34, Borislav Petkov wrote:
> 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)


>> 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?

edac_raw_mc_handle_error() prints it out,


> I mean, we set it now so that grain_bits can be computed but since
> you're doing that directly...

We could replace edac_raw_mc_handle_error()'s use of e->grain with e->grain_bits, which
would also make Robert's life easier when trying to merge those paths, but that's a more
invasive change.

I did did it like this to make it the minimum change if it was going as a fix. If we're
confident that no-one has-noticed/cared this can be papered over as part of Robert's
series, otherwise it will conflict.


Thanks,

James

  reply	other threads:[~2019-06-13 17:06 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
2019-06-13 17:06   ` James Morse [this message]
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=9bda9613-09b3-aa6d-183f-3668ef9a99c6@arm.com \
    --to=james.morse@arm.com \
    --cc=bp@alien8.de \
    --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).