From: Yazen Ghannam <yazen.ghannam@amd.com>
To: Borislav Petkov <bp@alien8.de>
Cc: yazen.ghannam@amd.com, x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/amd_nb: Check for invalid SMN reads
Date: Wed, 5 Apr 2023 15:10:09 -0400 [thread overview]
Message-ID: <83d4ad40-4812-0583-ba4a-da3e79732e51@amd.com> (raw)
In-Reply-To: <05c682d7-bddc-d990-37fb-cd1779f7e604@amd.com>
On 4/5/23 14:32, Yazen Ghannam wrote:
> On 4/5/23 14:06, Borislav Petkov wrote:
>> On Mon, Apr 03, 2023 at 05:36:40PM -0400, Yazen Ghannam wrote:
>>> Yes, that's fine. Should I send another revision?
>>
>> On a second thought, I think we should do what you said in the write
>> function too. Because the write can fail too. So if it can, we need to
>> handle that potential error too.
>>
>> Care to send a new version which does this check in the read and in the
>> write function? Basically what you had initially but with the write side
>> check added too to amd_smn_write.
>>
>
> Sure thing. I don't have a real test for the write path. But I'll test by
> faking it.
>
So I thought about it for a bit and quickly realized the "write and read back"
method isn't robust when done here.
Possible issues:
1) Bits that are "Write-1-to-clear". In this case, we *don't* want the read to
match the write.
2) Bits that are "Read-as-Zero"/"Writes-Ignored". We can't know this
information here.
3) Bits that are "Reserved / Set to 1". Ditto above.
I think all these issues should be handled by the callers of amd_smn_write().
They should do the "write and read back" check themselves, if needed.
For #1, they can see if their target bits got cleared.
For #2 and #3, they can check if their target bits got set as intended.
This matches what we do for rdmsr/wrmsr. As long as there's no #GP, then we're
good, and the caller does their own checking.
The "PCI Error Response" for the SMN read is the only check that would apply
to *any* SMN read. So I think that makes sense to do here instead of at each
call site.
What do you think?
Thanks,
Yazen
next prev parent reply other threads:[~2023-04-05 19:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-03 16:42 Yazen Ghannam
2023-04-03 19:32 ` Borislav Petkov
2023-04-03 19:40 ` Yazen Ghannam
2023-04-03 20:36 ` Borislav Petkov
2023-04-03 21:36 ` Yazen Ghannam
2023-04-05 18:06 ` Borislav Petkov
2023-04-05 18:32 ` Yazen Ghannam
2023-04-05 19:10 ` Yazen Ghannam [this message]
2023-05-08 22:01 ` Yazen Ghannam
2023-05-10 11:35 ` Borislav Petkov
2023-05-10 13:56 ` Yazen Ghannam
2024-06-05 19:40 ` [tip: x86/urgent] " tip-bot2 for Yazen Ghannam
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=83d4ad40-4812-0583-ba4a-da3e79732e51@amd.com \
--to=yazen.ghannam@amd.com \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®