Re: [PATCH] x86/amd_nb: Check for invalid SMN reads

From: Yazen Ghannam
Date: Mon Apr 03 2023 - 15:40:59 EST


On 4/3/23 15:32, Borislav Petkov wrote:
> On Mon, Apr 03, 2023 at 04:42:44PM +0000, Yazen Ghannam wrote:
>> int amd_smn_read(u16 node, u32 address, u32 *value)
>> {
>> - return __amd_smn_rw(node, address, value, false);
>> + int err = __amd_smn_rw(node, address, value, false);
>> +
>> + if (PCI_POSSIBLE_ERROR(*value)) {
>> + err = -ENODEV;
>> + *value = 0;
>> + }
>
> Why not put this check in __amd_smn_rw()?
>

I don't think pci_write_config*() sets the PCI Error response like
pci_read_config(), AFAICT.

I think to solve the writes-ignored problem, we'd need to do another read and
compare it to what we intended to write. That could go into amd_smn_write(),
if needed. Unless the PCI kernel API has something like this.

Thanks,
Yazen