From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SA9PR02CU001.outbound.protection.outlook.com (mail-southcentralusazon11013047.outbound.protection.outlook.com [40.93.196.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 325B439182F for ; Thu, 23 Apr 2026 19:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.196.47 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776971558; cv=fail; b=D1eq35X2AID/q0o+bm1l9o4LzGYvoolGCuz8K3+MhwHU3poteo864EeIYdmcZTyjGJxpP8gypi+MaCOuujolZaq8CoyjKfpcAA3hliBy6U34QCoKff8geRVZL6k7orMkHoFNyHPzmVUhAoKtxp/eXYr2MPp/VybLdNFTaVx3Iqc= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776971558; c=relaxed/simple; bh=6RONxEI5VqkGZFLZ/nDYiFNnztJezS6sldkDXkPlasQ=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=UxSVQSQ1qVL/UootlYRWLL17qy670Uk1VKgpsjb5mNyuyBlSJnCoClaC0+eZe4W/drZeyVcQjNyNk9QKxuuplqbANBQ4xf887Y8ta1HjM2oGRmvSn5yiQRrxfTgVaTwXsK9yJzEZA8c7fn92CPh3CrnZ95iqUD7BBdqY0Qe2TmI= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=udwRBsi0; arc=fail smtp.client-ip=40.93.196.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="udwRBsi0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WKRlcyDIUcvfjilBaKiVO7eShO00koyFz62AaQXFiPDjgT0n4OWzs8HZStgbD1s9/heY/AUHhV3cPWons10mCBENG96rUKxyWCfM/bZtVrtVUWUxc4oUQ5/eQZkeFb458Ph07sRzn5QGq2BE/TcxV8PhAjGT4D7aachjLVQLD9fd0+UOsacFo9dv9Fyg/Bwh29wZbhc+Ig01qVvfXUFrEWvups5hR6m+4VmCI2rTB3tr1vbYQfGVqeAeSzCLi43/Mdgs8phaj3hiaVhnBmsdeF8lg7/VntKgu6ewhTJMlPBSRv3r5vMyyp8Xl+WvjMpSLnIxFL3tD5Eq+J1W3Xm4TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/PnOUODyt3PFxFdRwnRqMgCAFiLRf9vAvibddrM9gzk=; b=A766IKLmM33FHrceMrz6jw4BjgQjKfdzbCa+6i4C43CdwZ/HBuC9yPRKhtLwI8jl7wjyD+XjxgPxdhLouIfpbZxpmhvHUZi3fqs/N9XD8ttMviag6cZB1qJqrRucIR/nbmeMgPhs8pORyjVB0JHoVsh69jKMIQF90OGdL5ATElwwwOgmhNWWMkCrCmiTAFHth4qNllLP5GBRR8Wfl/0NS4QrCitazUKFHLuyWTnfJacxAjbO8wHn3M7X3dEE4vUyoqUd+wjHuNyn3UluCMfCrNtUKw1q+l8Fk74bEnM3GTI1gA7JsiUgYqMm/JYoHH3Sq8SA2j+XVcd6gTRrKHLLyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/PnOUODyt3PFxFdRwnRqMgCAFiLRf9vAvibddrM9gzk=; b=udwRBsi0m9fedzh1mb4GdeIQtHyBvowOC4CozTmIZwRqTABoEwbZuQBLS6Bbok9UdeWJUomB1abK90oUJY+MWDRe+m+zz7+KwO+iE/dS4esW1ltImRdbLLLI9hcD8IFSmZDNJLS8eOMp9kkqNJdvS63hhwcrLs+5q+6XZ84CYP0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM6PR12MB4546.namprd12.prod.outlook.com (2603:10b6:5:2ae::19) by SA1PR12MB8968.namprd12.prod.outlook.com (2603:10b6:806:388::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.20; Thu, 23 Apr 2026 19:12:34 +0000 Received: from DM6PR12MB4546.namprd12.prod.outlook.com ([fe80::fb8a:9cdf:eb62:d31]) by DM6PR12MB4546.namprd12.prod.outlook.com ([fe80::fb8a:9cdf:eb62:d31%5]) with mapi id 15.20.9846.021; Thu, 23 Apr 2026 19:12:33 +0000 Message-ID: <857e8a70-be18-4ff1-8758-693af88efa00@amd.com> Date: Thu, 23 Apr 2026 14:12:30 -0500 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v2 4/5] x86/amd_node: Add smn_set_roots() and smn_activate() for external SMN registration Content-Language: en-US To: Lin Wang , yazen.ghannam@amd.com, Borislav Petkov Cc: tglx@kernel.org, mingo@redhat.com, x86@kernel.org, linux-kernel@vger.kernel.org References: <20260423060420.1785357-1-wanglin@open-hieco.net> <20260423060420.1785357-5-wanglin@open-hieco.net> From: Mario Limonciello In-Reply-To: <20260423060420.1785357-5-wanglin@open-hieco.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: CH0PR08CA0004.namprd08.prod.outlook.com (2603:10b6:610:33::9) To DM6PR12MB4546.namprd12.prod.outlook.com (2603:10b6:5:2ae::19) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB4546:EE_|SA1PR12MB8968:EE_ X-MS-Office365-Filtering-Correlation-Id: c2c76597-8f7d-4343-c33e-08dea16c455a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|22082099003|18002099003|56012099003; X-Microsoft-Antispam-Message-Info: FE7x9nMR0I5YnTH7gvoHT/3mS3vAujlbpCYvib53gSBz4AcBimDgxo7QBYFvZNe9/XEWiWMHW9pJOF/POiPB/NFMLQvVF/AfDQ/FpLzgTgjZmfyHNs9+J4ZyT4l2YLU/b0MUeq4c+W2SCudVQiRd/MnTFSsUbLpccv8CHA9t4wp9yLxxXgeGJoCqjSOjPYBv0JJbByhafwXHn2fBg+sFxpZ5KSiaN+Lt5W4K+nXoiy704SzYCMPiOYt4Q/EXdIlipSDvl/4NzOYaFemjE2fIIjjlRLoZ6Q2sYGDzs84HeTnA32CvHdsA0Lh1xs+GaK1lmBpGUlul0oXQWP9FpCuYf2dThc0y8PaP6qXYWVOhHUg4UXle046D69szhL+kqEeJk/njEEpPtmluJTBq88ZTV+9Lq66SLkqxh2ruqhsiPlL+X/hoBG0mY8o/J72oLVrOAX67SySbfyNtPwpezKqL4dFzNika+VMXpiYyptZCQKRmOc52IaZV6jnQPdZWGzw8XGAquHT/SI0NY+/ypHC9H1LgI0afoSP+yz59AM/VqyTGMrSLKglf4miSiKY3y9Wxg73AsqHFO2zyW7LZrgyA/Gm2Z2gQSNigsKAxkRHOZCxssJGCT0v87ty0Y1lt7bnKvtpSQY8qalQJW4eQ8Yus85iaETLhUkutE/5njss1wRZ+tFXZ9RXEJFSbgWzoYuiUFT1eQFYOKzvcymeiBNVoNnSpBNKutUvDJ5AiTsBpfhU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4546.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(22082099003)(18002099003)(56012099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OUVHNnd6V0ZKbWdrUDltV01HUlhDb2Juc3Njb1kraGpTWkllSkdrc3gyb2t1?= =?utf-8?B?TlJ4OXRBMlI2bjFzZWFaVVJjbUxDOXR2RUs1T1dETmVnRDRodWlMNW5WclpB?= =?utf-8?B?OHZIbUJvWjRvS1V6KzR3TVNrMk1sUFdGOXFhK3ZGU3JTYlpkMkxuUFFUc3Jq?= =?utf-8?B?K1VwM0RVUFBBNkFhVXlFTGF2R3RkTGtQaGh4WHo1WHJhM3hSM0ZlUnZtNlpW?= =?utf-8?B?V3d5czVqTnFQc2ZzeUpsRHZZakJkMmd4WEtNb3FNMmR3MDJVZDR1bHJmYVFi?= =?utf-8?B?UzFvYXhwL2ZXVm9GVG55MUljNXA2aFpLdUtBbEdkdlZCbW8vQnMvREZMT3Rn?= =?utf-8?B?TFMwMjRjeEp6Vm40V2J4MG9vSWF4SFZJb1ZIaW84dC9UR0tFK2FleVdxVzZN?= =?utf-8?B?YnpTQjkwQUNYdmNQNkpnRUVqSE16SmhuWWhIUUR5enYxeVZmM2NETUkzNXE0?= =?utf-8?B?OExtbnJTR052UWt1Y2Vvd3d3WFRrOXVub2YrRFppTHJoanJPVlZRUEM5c3d0?= =?utf-8?B?NTgxWDkzakZWdENHMVNYUnFlR2ljUGdZeHpZTm9jSUZrT0svcWxZVm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-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4546.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2026 19:12:33.1657 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ih14FILa1dbkXM0fTnqP/ZPfBSRf+94ucLezXhCx4yUnzAw5/pIZLhlS+NU/3OlI0AOY/wW3JpdlkGWi3eqxMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8968 On 4/23/26 01:04, Lin Wang wrote: > Guard the AMD SMN init (amd_smn_init) to X86_VENDOR_AMD only, removing > the PCI_VENDOR_ID_HYGON check from get_next_root() so that Hygon host > bridges are no longer enumerated by the AMD path. > > Split the original monolithic root registration into two explicit phases: > > smn_set_roots() -- pure data registration: saves the per-node root > array and node count, with no side effects. > > smn_activate() -- enables the SMN access layer: creates the optional > debugfs interface (gated by amd_smn_debugfs_enable) > and sets smn_exclusive so that amd_smn_read/write() > begin accepting requests. Takes a debugfs_name > parameter so each vendor can use its own directory > name (e.g. "amd_smn", "hygon_smn"). > > This two-phase design keeps the API names honest (set_roots is a pure > setter, activate is an explicit state transition) and lets each vendor > control when the shared SMN layer becomes live. > > Export both functions so that any vendor-specific init module can hand a > pre-built per-node root array to the shared SMN layer. > > No functional change for AMD systems. > > Signed-off-by: Lin Wang > --- > arch/x86/include/asm/amd/node.h | 4 ++ > arch/x86/kernel/amd_node.c | 106 +++++++++++++++++++++++++------- > 2 files changed, 87 insertions(+), 23 deletions(-) > > diff --git a/arch/x86/include/asm/amd/node.h b/arch/x86/include/asm/amd/node.h > index a672b8765fa8..2705b4f59361 100644 > --- a/arch/x86/include/asm/amd/node.h > +++ b/arch/x86/include/asm/amd/node.h > @@ -32,12 +32,16 @@ static inline u16 amd_num_nodes(void) > #ifdef CONFIG_AMD_NODE > int __must_check amd_smn_read(u16 node, u32 address, u32 *value); > int __must_check amd_smn_write(u16 node, u32 address, u32 value); > +int smn_set_roots(struct pci_dev **roots, u16 num_nodes); > +int smn_activate(const char *debugfs_name); > > /* Should only be used by the HSMP driver. */ > int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *value, bool write); > #else > static inline int __must_check amd_smn_read(u16 node, u32 address, u32 *value) { return -ENODEV; } > static inline int __must_check amd_smn_write(u16 node, u32 address, u32 value) { return -ENODEV; } > +static inline int smn_set_roots(struct pci_dev **roots, u16 num_nodes) { return -ENODEV; } > +static inline int smn_activate(const char *debugfs_name) { return -ENODEV; } > > static inline int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *value, bool write) > { > diff --git a/arch/x86/kernel/amd_node.c b/arch/x86/kernel/amd_node.c > index 0be01725a2a4..76dbf847e567 100644 > --- a/arch/x86/kernel/amd_node.c > +++ b/arch/x86/kernel/amd_node.c > @@ -9,6 +9,7 @@ > */ > > #include > +#include > #include > > /* > @@ -34,7 +35,8 @@ struct pci_dev *amd_node_get_func(u16 node, u8 func) > return pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(AMD_NODE0_PCI_SLOT + node, func)); > } > > -static struct pci_dev **amd_roots; > +static struct pci_dev **smn_roots; > +static u16 smn_num_nodes; > > /* Protect the PCI config register pairs used for SMN. */ > static DEFINE_MUTEX(smn_mutex); > @@ -88,10 +90,10 @@ static int __amd_smn_rw(u8 i_off, u8 d_off, u16 node, u32 address, u32 *value, b > struct pci_dev *root; > int err = -ENODEV; > > - if (node >= amd_num_nodes()) > + if (node >= smn_num_nodes) > return err; > > - root = amd_roots[node]; > + root = smn_roots[node]; > if (!root) > return err; > > @@ -151,7 +153,7 @@ static ssize_t smn_node_write(struct file *file, const char __user *userbuf, > if (ret) > return ret; > > - if (node >= amd_num_nodes()) > + if (node >= smn_num_nodes) > return -ENODEV; > > debug_node = node; > @@ -225,8 +227,7 @@ static struct pci_dev *get_next_root(struct pci_dev *root) > if (root->devfn) > continue; > > - if (root->vendor != PCI_VENDOR_ID_AMD && > - root->vendor != PCI_VENDOR_ID_HYGON) > + if (root->vendor != PCI_VENDOR_ID_AMD) > continue; > > break; > @@ -244,17 +245,78 @@ static int __init amd_smn_enable_dfs(char *str) > } > __setup("amd_smn_debugfs_enable", amd_smn_enable_dfs); > > +/* > + * Register a pre-built per-node SMN root array. The caller allocates > + * @roots and transfers ownership to the SMN layer; the array must remain > + * valid for the lifetime of the system. > + * > + * This is a pure data registration; the SMN access layer is not yet > + * usable until smn_activate() is called. > + * > + * Not concurrency-safe. Intended to be called exactly once during boot > + * (e.g. from an fs_initcall). The caller is responsible for any > + * serialization required by its own init path. > + */ > +int smn_set_roots(struct pci_dev **roots, u16 num_nodes) > +{ > + if (!roots || !num_nodes) > + return -EINVAL; > + > + if (smn_roots) > + return -EBUSY; > + > + smn_roots = roots; > + smn_num_nodes = num_nodes; > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(smn_set_roots); > + > +/* > + * Activate the SMN access layer after roots have been registered via > + * smn_set_roots(). Creates the optional debugfs interface (gated by > + * the amd_smn_debugfs_enable boot parameter) and sets smn_exclusive so > + * that amd_smn_read()/amd_smn_write() begin accepting requests. > + * > + * @debugfs_name: directory name under arch_debugfs_dir (e.g. "amd_smn") > + * > + * Same serialization rules as smn_set_roots(): must be called exactly > + * once, at boot, after smn_set_roots() succeeds. > + */ > +int smn_activate(const char *debugfs_name) > +{ > + if (!smn_roots || !smn_num_nodes) > + return -EINVAL; You don't need the !smn_num_nodes check here. smn_set_roots() already has it. > + > + if (smn_exclusive) > + return -EBUSY; > + > + if (enable_dfs) { > + debugfs_dir = debugfs_create_dir(debugfs_name, arch_debugfs_dir); > + > + debugfs_create_file("node", 0600, debugfs_dir, NULL, &smn_node_fops); > + debugfs_create_file("address", 0600, debugfs_dir, NULL, &smn_address_fops); > + debugfs_create_file("value", 0600, debugfs_dir, NULL, &smn_value_fops); > + } > + > + smn_exclusive = true; > + return 0; > +} > +EXPORT_SYMBOL_GPL(smn_activate); > + > static int __init amd_smn_init(void) > { > u16 count, num_roots, roots_per_node, node, num_nodes; > - struct pci_dev *root; > + struct pci_dev **roots, *root; > + int ret; > > - if (!cpu_feature_enabled(X86_FEATURE_ZEN)) > + if (!cpu_feature_enabled(X86_FEATURE_ZEN) || > + boot_cpu_data.x86_vendor != X86_VENDOR_AMD) > return 0; > > guard(mutex)(&smn_mutex); > > - if (amd_roots) > + if (smn_roots) > return 0; > > num_roots = 0; > @@ -268,7 +330,9 @@ static int __init amd_smn_init(void) > * entire PCI config space for simplicity rather than covering > * specific registers piecemeal. > */ > - if (!pci_request_config_region_exclusive(root, 0, PCI_CFG_SPACE_SIZE, NULL)) { > + if (!pci_request_config_region_exclusive(root, 0, > + PCI_CFG_SPACE_SIZE, > + NULL)) { > pci_err(root, "Failed to reserve config space\n"); > return -EEXIST; > } > @@ -276,14 +340,14 @@ static int __init amd_smn_init(void) > num_roots++; > } > > - pr_debug("Found %d AMD root devices\n", num_roots); > + pr_debug("Found %d SMN root devices\n", num_roots); > > if (!num_roots) > return -ENODEV; > > num_nodes = amd_num_nodes(); > - amd_roots = kzalloc_objs(*amd_roots, num_nodes); > - if (!amd_roots) > + roots = kzalloc_objs(*roots, num_nodes); > + if (!roots) > return -ENOMEM; > > roots_per_node = num_roots / num_nodes; > @@ -297,20 +361,16 @@ static int __init amd_smn_init(void) > continue; > > pci_dbg(root, "is root for AMD node %u\n", node); > - amd_roots[node++] = root; > + roots[node++] = root; > } > > - if (enable_dfs) { > - debugfs_dir = debugfs_create_dir("amd_smn", arch_debugfs_dir); > - > - debugfs_create_file("node", 0600, debugfs_dir, NULL, &smn_node_fops); > - debugfs_create_file("address", 0600, debugfs_dir, NULL, &smn_address_fops); > - debugfs_create_file("value", 0600, debugfs_dir, NULL, &smn_value_fops); > + ret = smn_set_roots(roots, num_nodes); > + if (ret) { > + kfree(roots); > + return ret; > } > > - smn_exclusive = true; > - > - return 0; > + return smn_activate("amd_smn"); > } > > fs_initcall(amd_smn_init);