* [PATCH v8] x86/amd_node: Continue initialization even if SMN reservation fails [not found] <Message-ID-de-Mario> @ 2026-11-29 10:38 ` Ilan Bonneau-Zamon 2026-11-29 18:12 ` Borislav Petkov 0 siblings, 1 reply; 8+ messages in thread From: Ilan Bonneau-Zamon @ 2026-11-29 10:38 UTC (permalink / raw) To: Mario Limonciello Cc: Yazen Ghannam, Borislav Petkov, Thomas Gleixner, Ingo Molnar, Dave Hansen, H . Peter Anvin, x86, linux-kernel, Ilan Bonneau-Zamon Currently, amd_smn_init() returns -EEXIST if reserving PCI config space fails for any root device. On systems where reservation fails for one root, this aborts initialization for the remaining nodes. Log a warning instead of failing immediately when reserving PCI config space for a root device fails, so initialization can continue for other roots. Return -EEXIST if reserving config space fails for all discovered roots. Suggested-by: Yazen Ghannam <yazen.ghannam@amd.com> Suggested-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Ilan Bonneau-Zamon <ilan.bonneauzamon@gmail.com> --- Changes in v8: - Track failed reservations and return -EEXIST if all roots fail. - Add Suggested-by tag for Mario Limonciello. --- arch/x86/kernel/amd_node.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c index b7926ba3610a..14a97df63ce2 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, failed = 0, roots_per_node, node, num_nodes; + struct pci_dev *root = NULL; if (!cpu_feature_enabled(X86_FEATURE_ZEN)) return 0; @@ -261,7 +261,6 @@ 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"); @@ -272,8 +271,8 @@ static int __init amd_smn_init(void) * specific registers piecemeal. */ 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"); + failed++; } num_roots++; @@ -284,6 +283,9 @@ static int __init amd_smn_init(void) if (!num_roots) return -ENODEV; + if (failed == num_roots) + return -EEXIST; + num_nodes = amd_num_nodes(); amd_roots = kzalloc_objs(*amd_roots, num_nodes); if (!amd_roots) -- 2.56.1 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v8] x86/amd_node: Continue initialization even if SMN reservation fails 2026-11-29 10:38 ` [PATCH v8] x86/amd_node: Continue initialization even if SMN reservation fails Ilan Bonneau-Zamon @ 2026-11-29 18:12 ` Borislav Petkov 2026-11-30 17:28 ` [PATCH v9] " Ilan Bonneau-Zamon 0 siblings, 1 reply; 8+ messages in thread From: Borislav Petkov @ 2026-11-29 18:12 UTC (permalink / raw) To: Ilan Bonneau-Zamon Cc: Mario Limonciello, Yazen Ghannam, Thomas Gleixner, Ingo Molnar, Dave Hansen, H . Peter Anvin, x86, linux-kernel, Ilan Bonneau-Zamon On Sun, Nov 29, 2026 at 11:38:29AM +0100, Ilan Bonneau-Zamon wrote: > Currently, amd_smn_init() returns -EEXIST if reserving PCI config space > fails for any root device. On systems where reservation fails for one > root, this aborts initialization for the remaining nodes. > > Log a warning instead of failing immediately when reserving PCI config > space for a root device fails, so initialization can continue for other > roots. Please, do not talk about *what* the patch is doing in the commit message - that should be obvious from the diff itself. Rather, concentrate on the *why* it needs to be done and why your patch exists. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v9] x86/amd_node: Continue initialization even if SMN reservation fails 2026-11-29 18:12 ` Borislav Petkov @ 2026-11-30 17:28 ` Ilan Bonneau-Zamon 2026-11-30 18:12 ` Yazen Ghannam 2026-11-30 18:34 ` Borislav Petkov 0 siblings, 2 replies; 8+ messages in thread From: Ilan Bonneau-Zamon @ 2026-11-30 17:28 UTC (permalink / raw) To: Borislav Petkov Cc: Mario Limonciello, Yazen Ghannam, Thomas Gleixner, Ingo Molnar, Dave Hansen, H . Peter Anvin, x86, linux-kernel, Ilan Bonneau-Zamon On multi-root AMD systems, another driver or firmware mechanism may already have reserved the PCI config space of a single root device. Aborting amd_smn_init() on the first reservation failure needlessly prevents initializing and protecting the SMN registers on the remaining roots. However, if reserving PCI config space fails for every discovered root, no SMN protection is in place at all and initialization must still fail with -EEXIST. Suggested-by: Yazen Ghannam <yazen.ghannam@amd.com> Suggested-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Ilan Bonneau-Zamon <ilan.bonneauzamon@gmail.com> --- Changes in v9: - Rewrite commit message to focus on why the change is needed rather than describing what the diff does. Changes in v8: - Track failed reservations and return -EEXIST if all roots fail. - Add Suggested-by tag for Mario Limonciello. --- arch/x86/kernel/amd_node.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c index b7926ba3610a..14a97df63ce2 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, failed = 0, roots_per_node, node, num_nodes; + struct pci_dev *root = NULL; if (!cpu_feature_enabled(X86_FEATURE_ZEN)) return 0; @@ -261,7 +261,6 @@ 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"); @@ -272,8 +271,8 @@ static int __init amd_smn_init(void) * specific registers piecemeal. */ 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"); + failed++; } num_roots++; @@ -284,6 +283,9 @@ static int __init amd_smn_init(void) if (!num_roots) return -ENODEV; + if (failed == num_roots) + return -EEXIST; + num_nodes = amd_num_nodes(); amd_roots = kzalloc_objs(*amd_roots, num_nodes); if (!amd_roots) -- 2.56.1 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v9] x86/amd_node: Continue initialization even if SMN reservation fails 2026-11-30 17:28 ` [PATCH v9] " Ilan Bonneau-Zamon @ 2026-11-30 18:12 ` Yazen Ghannam 2026-11-30 18:53 ` Ilan Bonneau-Zamon 2026-11-30 18:34 ` Borislav Petkov 1 sibling, 1 reply; 8+ messages in thread From: Yazen Ghannam @ 2026-11-30 18:12 UTC (permalink / raw) To: Ilan Bonneau-Zamon Cc: Borislav Petkov, Mario Limonciello, Thomas Gleixner, Ingo Molnar, Dave Hansen, H . Peter Anvin, x86, linux-kernel, Ilan Bonneau-Zamon On Mon, Nov 30, 2026 at 06:28:15PM +0100, Ilan Bonneau-Zamon wrote: > On multi-root AMD systems, another driver or firmware mechanism may > already have reserved the PCI config space of a single root device. > Aborting amd_smn_init() on the first reservation failure needlessly > prevents initializing and protecting the SMN registers on the remaining > roots. > > However, if reserving PCI config space fails for every discovered root, > no SMN protection is in place at all and initialization must still > fail with -EEXIST. > > Suggested-by: Yazen Ghannam <yazen.ghannam@amd.com> > Suggested-by: Mario Limonciello <mario.limonciello@amd.com> > Signed-off-by: Ilan Bonneau-Zamon <ilan.bonneauzamon@gmail.com> > --- > Changes in v9: > - Rewrite commit message to focus on why the change is needed rather > than describing what the diff does. > Changes in v8: > - Track failed reservations and return -EEXIST if all roots fail. > - Add Suggested-by tag for Mario Limonciello. > --- > arch/x86/kernel/amd_node.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c > index b7926ba3610a..14a97df63ce2 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, failed = 0, roots_per_node, node, num_nodes; > + struct pci_dev *root = NULL; > > if (!cpu_feature_enabled(X86_FEATURE_ZEN)) > return 0; > @@ -261,7 +261,6 @@ 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"); > You didn't answer about these changes. Thanks, Yazen ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v9] x86/amd_node: Continue initialization even if SMN reservation fails 2026-11-30 18:12 ` Yazen Ghannam @ 2026-11-30 18:53 ` Ilan Bonneau-Zamon 0 siblings, 0 replies; 8+ messages in thread From: Ilan Bonneau-Zamon @ 2026-11-30 18:53 UTC (permalink / raw) To: Yazen Ghannam Cc: Mario Limonciello, Borislav Petkov, Thomas Gleixner, Ingo Molnar, Dave Hansen, H . Peter Anvin, x86, linux-kernel, Ilan Bonneau-Zamon Hi Yazen, Sorry for not addressing the logic change directly earlier. Following Mario's point about the case where all roots fail, I kept a failure counter so individual root reservation failures still log a warning and allow other roots to be initialized, while returning -EEXIST if reserving config space fails for all discovered roots (since no SMN protection would be active at all). Thanks, Ilan ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v9] x86/amd_node: Continue initialization even if SMN reservation fails 2026-11-30 17:28 ` [PATCH v9] " Ilan Bonneau-Zamon 2026-11-30 18:12 ` Yazen Ghannam @ 2026-11-30 18:34 ` Borislav Petkov 2026-11-30 18:53 ` Ilan Bonneau-Zamon 1 sibling, 1 reply; 8+ messages in thread From: Borislav Petkov @ 2026-11-30 18:34 UTC (permalink / raw) To: Ilan Bonneau-Zamon Cc: Mario Limonciello, Yazen Ghannam, Thomas Gleixner, Ingo Molnar, Dave Hansen, H . Peter Anvin, x86, linux-kernel, Ilan Bonneau-Zamon On Mon, Nov 30, 2026 at 06:28:15PM +0100, Ilan Bonneau-Zamon wrote: > On multi-root AMD systems, another driver or firmware mechanism may > already have reserved the PCI config space of a single root device. > Aborting amd_smn_init() on the first reservation failure needlessly > prevents initializing and protecting the SMN registers on the remaining > roots. Sounds to me like some homegrown solution is trying to accomodate an upstream kernel. If so, you can keep that patch in your own tree. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v9] x86/amd_node: Continue initialization even if SMN reservation fails 2026-11-30 18:34 ` Borislav Petkov @ 2026-11-30 18:53 ` Ilan Bonneau-Zamon 2026-11-30 18:59 ` Borislav Petkov 0 siblings, 1 reply; 8+ messages in thread From: Ilan Bonneau-Zamon @ 2026-11-30 18:53 UTC (permalink / raw) To: Borislav Petkov Cc: Mario Limonciello, Yazen Ghannam, Thomas Gleixner, Ingo Molnar, Dave Hansen, H . Peter Anvin, x86, linux-kernel, Ilan Bonneau-Zamon Hi Boris, That was poor phrasing on my part—there is no homegrown workaround or out-of-tree setup involved here. My point was simply that if one root's config space cannot be reserved exclusively, failing the entire init skips setting up protection on the remaining roots, whereas failing with -EEXIST when all roots fail avoids reporting success with zero protection. Thanks, Ilan ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v9] x86/amd_node: Continue initialization even if SMN reservation fails 2026-11-30 18:53 ` Ilan Bonneau-Zamon @ 2026-11-30 18:59 ` Borislav Petkov 0 siblings, 0 replies; 8+ messages in thread From: Borislav Petkov @ 2026-11-30 18:59 UTC (permalink / raw) To: Ilan Bonneau-Zamon Cc: Mario Limonciello, Yazen Ghannam, Thomas Gleixner, Ingo Molnar, Dave Hansen, H . Peter Anvin, x86, linux-kernel On Mon, Nov 30, 2026 at 07:53:48PM +0100, Ilan Bonneau-Zamon wrote: > That was poor phrasing on my part—there is no homegrown workaround or > out-of-tree setup involved here. My point was simply that if one root's > config space cannot be reserved exclusively, Why would that happen at all in the first place? Is this something you're seeing or are you "fixing" a contrived failure? Please explain in detail what you're trying to achieve here. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-30 19:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <Message-ID-de-Mario>
2026-11-29 10:38 ` [PATCH v8] x86/amd_node: Continue initialization even if SMN reservation fails Ilan Bonneau-Zamon
2026-11-29 18:12 ` Borislav Petkov
2026-11-30 17:28 ` [PATCH v9] " Ilan Bonneau-Zamon
2026-11-30 18:12 ` Yazen Ghannam
2026-11-30 18:53 ` Ilan Bonneau-Zamon
2026-11-30 18:34 ` Borislav Petkov
2026-11-30 18:53 ` Ilan Bonneau-Zamon
2026-11-30 18:59 ` Borislav Petkov
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®