From: Ilan Bonneau-Zamon <yolezz.secret@gmail.com>
To: yazen.ghannam@amd.com
Cc: bp@alien8.de, mario.limonciello@amd.com, x86@kernel.org,
linux-kernel@vger.kernel.org,
Ilan Bonneau-Zamon <ilan.bonneauzamon@gmail.com>
Subject: [PATCH v6] x86/amd_node: Continue initialization even if SMN reservation fails
Date: Thu, 5 Nov 2026 14:54:48 +0100 [thread overview]
Message-ID: <20261105135448.40695-1-ilan.bonneauzamon@gmail.com> (raw)
In-Reply-To: <20260916163618.GA1395@yaz-khff2.amd.com>
Currently, if reserving PCI config regions fails for a node, amd_smn_init()
exits early. However, keeping successfully reserved regions active helps
prevent userspace from accessing those registers even if one node fails.
Change amd_smn_init() to attempt reserving regions for all nodes
unconditionally, logging a warning on failure instead of exiting.
Suggested-by: Yazen Ghannam <yazen.ghannam@amd.com>
Signed-off-by: Ilan Bonneau-Zamon <ilan.bonneauzamon@gmail.com>
---
Changes in v6:
- Attempt to reserve PCI config regions for all nodes unconditionally,
logging a warning on failure instead of aborting initialization.
- Remove obsolete error cleanup labels and release helper function.
Changes in v5:
- Drop __free() cleanup helpers and custom release logic, switching to
traditional goto cleanup pattern (as suggested by Borislav Petkov).
- Fix changelog attribution regarding brace removal (noted by Mario Limonciello).
- Update author sign-off to use legal name.
Changes in v4:
- Remove unnecessary braces around the kzalloc_objs() error check.
---
arch/x86/kernel/amd_node.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c
index b7926ba3610a..c0391b081c0f 100644
--- a/arch/x86/kernel/amd_node.c
+++ b/arch/x86/kernel/amd_node.c
@@ -250,8 +250,8 @@ __setup("amd_smn_debugfs_enable", amd_smn_enable_dfs);
static int __init amd_smn_init(void)
{
- u16 count, num_roots, roots_per_node, node, num_nodes;
- struct pci_dev *root __free(pci_dev_put) = NULL;
+ u16 count, num_roots = 0, roots_per_node, node, num_nodes;
+ struct pci_dev *root = NULL;
if (!cpu_feature_enabled(X86_FEATURE_ZEN))
return 0;
@@ -261,19 +261,20 @@ static int __init amd_smn_init(void)
if (amd_roots)
return 0;
- num_roots = 0;
while ((root = get_next_root(root))) {
pci_dbg(root, "Reserving PCI config space\n");
/*
- * There are a few SMN index/data pairs and other registers
- * that shouldn't be accessed by user space. So reserve the
- * entire PCI config space for simplicity rather than covering
- * specific registers piecemeal.
- */
+ * There are a few SMN index/data pairs and other registers
+ * that shouldn't be accessed by user space. So reserve the
+ * entire PCI config space simplicity rather than covering
+ * specific registers piecemeal.
+ *
+ * Continue attempt to reserve regions for all roots, and log
+ * a warning if reservation fails on a particular device.
+ */
if (!pci_request_config_region_exclusive(root, 0, PCI_CFG_SPACE_SIZE, NULL)) {
- pci_err(root, "Failed to reserve config space\n");
- return -EEXIST;
+ pci_warn(root, "Failed to reserve config space\n");
}
num_roots++;
@@ -298,6 +299,7 @@ static int __init amd_smn_init(void)
count = 0;
node = 0;
+ root = NULL;
while (node < num_nodes && (root = get_next_root(root))) {
/* Use one root for each node and skip the rest. */
if (count++ % roots_per_node)
@@ -316,6 +318,7 @@ static int __init amd_smn_init(void)
}
return 0;
+
}
fs_initcall(amd_smn_init);
--
2.56.0
prev parent reply other threads:[~2026-11-05 13:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 11:59 [PATCH v5] x86/amd_node: Fix resource leak in amd_smn_init() error path Ilan Bonneau-Zamon
2026-09-16 16:36 ` Yazen Ghannam
2026-11-05 13:54 ` Ilan Bonneau-Zamon [this message]
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=20261105135448.40695-1-ilan.bonneauzamon@gmail.com \
--to=yolezz.secret@gmail.com \
--cc=bp@alien8.de \
--cc=ilan.bonneauzamon@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=x86@kernel.org \
--cc=yazen.ghannam@amd.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
all inboxes | Powered by JetHome®