From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796059703; b=LSEa76gbCmuzCP4ZlwBHqUGAyVtNSup3w8/Jjhw8IA27xQglZNKXtyQEdxr9biR7dzed 1PHphf6usWSQ8JgN/itysKmY2NtrEwqPjTxvbGifFWaTft+j9gQJBotY54X0a6YtprUcP HFqUDgzCz+3ho2FdE0vNQ4nXPdPgFK5k+3KyrZ+vycNkoN7XU6bjFloFIgSUZsFX58Pfb gIMlvWaU+4W0FF0cYkztE/urGwyPC6n9/yjyfHYSZZ7yWwQpEZ9S9mPz2USOWsMhDsSlN Py9H+HJw8p8SKOGYV2cVDWECJc9bDpo0+wejprDBrxO4I0Ixqh6DY8Pju5oZtJPWDOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796059703; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:X-Google-Original-From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=HyTrsOSzHsELD5P3Nkgf+M0La/e/+p3I/xxJbbojyuo=; b=rmGai26A5ex6NkDsK6sMRxOreym0+Z01IhJcU85QW1CAPiLzhZJa8J38VEJG5CcizZhp Rj5iCOAbLvBA84P4RoGGGcPLfT5raW+n1Eqo93Kn79dH8SpTyJVEvZvVMOSzHH/5iYm7O viC8azHR8fNITBWizioDp3dhIiP/sSZNIxoyyamIWOyQyFiRYt8EY3EgWmPt/jam72sBb D5XiSLVvGQkHTx21Ejg/BC1CCwyAMIY3EO+oIRDyxK/zWmfRG1xfTA3K1oojM7bhIN7vg qi8g47zYSDCXAGsMqih6hhQjz/NPY1hnUdkyiN73CGpLozURi2wMLzz9l2zggjDpJdg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=kUFKaubL; arc=none smtp.remote-ip=209.85.221.50 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93BC2606A330 for ; Mon, 30 Nov 2026 17:28:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 93BC2606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=kUFKaubL Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-4acb44dcd7bso9588527f8f.0 for ; Mon, 30 Nov 2026 09:28:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796059701; x=1796664501; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=HyTrsOSzHsELD5P3Nkgf+M0La/e/+p3I/xxJbbojyuo=; b=kUFKaubLkvWaZfBC83u297EGaIisJ9sJXf8u+98xCN6cMTNst49HGKOJAbei9IwhbD Ch3tV+8sCVKqQ+lrPNzUCOKR4jRcU7RsH9PuuDyM6/VlyGbJLFQ8kvwbpUwLEPHbSzkD FqzEfchsjMZbEwaZf+k2zODY0C7CyguLkuulIi0LqVF2t77Uv6YLxeSatYJ2AKePekZ0 J703SEIdKQVrwoj6uz/decljMutPGHARQedy+kaiCGcNTX81s1Tv2y8WhdBFrVwtmI1r 6jI0NdlHrAN60e/8MZSIpocRZ4ql08HjfeUF6clo2zx3/PH2tMThBg8+uKyAxgOl+QSw 0u9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796059701; x=1796664501; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=HyTrsOSzHsELD5P3Nkgf+M0La/e/+p3I/xxJbbojyuo=; b=Y7npYA7k8fMRp9i6mUie5K6eL4UQCAXcSisv3ftmvyBDOF9GnljbkZMWwdpfel/jFo K6wfDncXW2fWUqyeIPigfjIFPGd7iJfs4ZeJYkQum7np58HRImlONcsyut25pFx8YRRm A8c179P1iPfAYPy+NLmOhMlkHgjr0hNJCBfBBzvDDTm05Mc/hbRTVKa2blA+lFNLuaoA dHc65ktsfyMqeTszKrWk8NzHQNqkQVEeOG7jAOofYhowR3CRNhBwgMcLTAP1IPdV+PUq 02jnDZKCpY2akUHydTn6kQJM+kBpXX39PshBWbgO5EOtCwkXZaH25s5F//DuXxSjvGhF yvdg== X-Forwarded-Encrypted: i=1; AL+hErFP6O3G7rVibjxZ+UfWx6JJN+sQFU4o9hvk1Mt9jMIgF/ahan22wET4/vqO3A74/mMuSimPglm9IqmzbbA=@vger.kernel.org X-Gm-Message-State: APuU4Z9q0qveClJCzh1LIJ1DlJqw4M1Q73NQ7TpIJvhS1q9QzcueGVtm jJG2YrHZWgBl/1TsPd98h9RV70kQAXgF5BRUMUmeMjapqXBU2r4Gixnk X-Gm-Gg: AZFdTZebtzgOG5FudCh9DM+mHDBgDt2M5GjP6Nhr3GdUPXJwzg119GJTNR51BW4iqFK Ag+1x+Vrkcq48+3w4kZ46ZhAaO/AAwoMoFyd53JG8R+Zbx69IS7sfZvJh3hcJN5hAvLLYcyfPxE TNRwz9lLA6DYFG/NcxaPZ8yNRBcN5AZVjcz5PuhdLfEpwzKH7fORQSqdQ5/6B/bJivvnfdr7LgD 2dsgJZWOd4XcFwJtDTiPgQGD0gjbAVlZoXEks7RnYK/+ayWWCBw53nXTLogGKMMa4nwacjXhVR0 WcBGKp5hOn9LyBQE3VBE2f1JjZf6eic0Jo1PtmDak/NC8aerB8bnqMcJJOApje41htyL4bPV1aU qn2ACNdi4EnpnKLj7EgcfoZqsdtxBXEd/xG7CWrNxx6ag8FLzjuF7m4QKqg4YiYQE5sGfm9XDkq n4Usu7XgUB8GHB7ci5w8tHiy+B9kmd8qYzN5d5A7eoGDFZWagHzxbHuD+9qR7D+KjhOrhc4CDqp d6BHspAaJ17vJ53ceYFJDVTVvxmHTxdlP++L4KCNJe9ikkXVtRwo2+L8vqz+lMnqV/C8sOW+AlC GDi3sOZIjJQr4Po1p324+5buWkLuJR9S3sRpk7LYWm/2PIx+sQ3IesU5Nw1g+sisAmaJ4H+gFYz QANKZ7rhT4F3FGO6mm6PxQETDQJSh/J2m0UC+2u2GfsKjTSB7TWH375HDT8yChf56J3dOr+E= X-Received: by 2002:a05:6000:2887:b0:4b3:e5d7:215a with SMTP id ffacd0b85a97d-4b3e5d72317mr52662157f8f.24.1796059700662; Mon, 30 Nov 2026 09:28:20 -0800 (PST) Received: from fedora-portable.home (2a01cb0082e4ed0003fef01df0cf8b0e.ipv6.abo.wanadoo.fr. [2a01:cb00:82e4:ed00:3fe:f01d:f0cf:8b0e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6bc8ce06sm62954046f8f.47.2026.11.30.09.28.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 09:28:18 -0800 (PST) From: Ilan Bonneau-Zamon X-Google-Original-From: Ilan Bonneau-Zamon To: Borislav Petkov Cc: Mario Limonciello , Yazen Ghannam , Thomas Gleixner , Ingo Molnar , Dave Hansen , "H . Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, Ilan Bonneau-Zamon Subject: [PATCH v9] x86/amd_node: Continue initialization even if SMN reservation fails Date: Mon, 30 Nov 2026 18:28:15 +0100 Message-ID: <20261130172815.18404-1-ilan.bonneauzamon@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261129181258.GAawxrKj-7W6xvu9Jy@fat_crate.local> References: <20261129181258.GAawxrKj-7W6xvu9Jy@fat_crate.local> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Suggested-by: Mario Limonciello Signed-off-by: Ilan Bonneau-Zamon --- 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