[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <78bec0e8-a64a-466c-4245-2386de7db5c9@amd.com>
Date: Mon, 11 Oct 2021 16:12:14 -0500
From: "Koralahalli Channabasappa, Smita" <skoralah@....com>
To: Borislav Petkov <bp@...en8.de>,
Smita Koralahalli <Smita.KoralahalliChannabasappa@....com>
Cc: x86@...nel.org, linux-edac@...r.kernel.org,
linux-kernel@...r.kernel.org, Tony Luck <tony.luck@...el.com>,
"H . Peter Anvin" <hpa@...or.com>, yazen.ghannam@....com
Subject: Re: [PATCH 1/5] x86/mce/inject: Check if a bank is unpopulated before
error simulation
Hi Boris,
Sorry for the delayed response.
When I was coding this up, I came across few issues. Mentioning below.
On 9/24/21 3:26 AM, Borislav Petkov wrote:
> On Wed, Sep 15, 2021 at 06:27:35PM -0500, Smita Koralahalli wrote:
>> The MCA_IPID register uniquely identifies a bank's type on Scalable MCA
>> (SMCA) systems. When an MCA bank is not populated, the MCA_IPID register
>> will read as zero and writes to it will be ignored. Check the value of
>> this register before trying to simulate the error.
>>
>> Signed-off-by: Smita Koralahalli<Smita.KoralahalliChannabasappa@....com>
>> ---
>> arch/x86/kernel/cpu/mce/inject.c | 18 ++++++++++++++++++
>> 1 file changed, 18 insertions(+)
>>
>> diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c
>> index 0bfc14041bbb..51ac575c4605 100644
>> --- a/arch/x86/kernel/cpu/mce/inject.c
>> +++ b/arch/x86/kernel/cpu/mce/inject.c
>> @@ -577,6 +577,24 @@ static int inj_bank_set(void *data, u64 val)
>> }
>>
>> m->bank = val;
>> +
>> + /* Read IPID value to determine if a bank is unpopulated on the target
>> + * CPU.
>> + */
> Kernel comments style format is:
>
> /*
> * A sentence ending with a full-stop.
> * Another sentence. ...
> * More sentences. ...
> */
>
>> + if (boot_cpu_has(X86_FEATURE_SMCA)) {
> This whole thing belongs into inj_ipid_set() where you should verify
> whether the bank is set when you try to set the IPID for that bank.
I do not have the bank number in order to look up the IPID for that bank.
I couldn't know the bank number because mce-inject files are synchronized
in a way that once the bank number is written the injection starts.
Can you please suggest what needs to be done here?
Also, the IPID register is read only from the OS, hence the user provided
IPID values could be useful for "sw" error injection types. For "hw" error
injection types we need to read from the registers to determine the IPID
value.
Should there be two cases where on a "sw" injection use the user provided
IPID value whereas on "hw" injection read from registers?
I'm pasting the code snippet after rework on the comments.
static int inj_ipid_set(void *data, u64 val)
{
struct mce *m = (struct mce *)data;
if (cpu_feature_enabled(X86_FEATURE_SMCA)) {
if (val && inj_type == SW_INJ)
m->ipid = val;
else {
rdmsrl_on_cpu(m->extcpu, MSR_AMD64_SMCA_MCx_IPID(?),
&m->ipid); // Requires bank number here.
if (!m->ipid) {
pr_err("Cannot set IPID - unpopulated bank\n");
return -ENODEV;
}
}
}
return 0;
}
Please let me know what do you think?
Thanks,
>> +
>> + /* Check for user provided IPID value. */
>> + if (!m->ipid) {
>> + rdmsrl_on_cpu(m->extcpu, MSR_AMD64_SMCA_MCx_IPID(val),
>> + &m->ipid);
> Oh well, one IPI per ipid write. We're doing injection so we can't be on
> a production machine so who cares about IPIs there.
>
>> + if (!m->ipid) {
>> + pr_err("Error simulation not possible: Bank %llu unpopulated\n",
> "Cannot set IPID for bank... - bank %d unpopulated\n"
>
> Also, in all your text, use "injection" instead of "simulation" so that
> there's no confusion.
>
> Thx.
>
Powered by blists - more mailing lists