Re: [PATCH] x86/amd_nb: Check for invalid SMN reads
From: Borislav Petkov
Date: Mon Apr 03 2023 - 16:36:52 EST
On Mon, Apr 03, 2023 at 03:40:38PM -0400, Yazen Ghannam wrote:
> I don't think pci_write_config*() sets the PCI Error response like
> pci_read_config(), AFAICT.
diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c
index 4266b64631a4..c4caade434a7 100644
--- a/arch/x86/kernel/amd_nb.c
+++ b/arch/x86/kernel/amd_nb.c
@@ -181,6 +181,13 @@ static int __amd_smn_rw(u16 node, u32 address, u32 *value, bool write)
pr_warn("Error %s SMN address 0x%x.\n",
(write ? "writing to" : "reading from"), address);
+ if (!write) {
+ if (PCI_POSSIBLE_ERROR(*value)) {
+ err = -ENODEV;
+ *value = 0;
+ }
+ }
+
out_unlock:
mutex_unlock(&smn_mutex);
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette