From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out28-100.mail.aliyun.com (out28-100.mail.aliyun.com [115.124.28.100]) (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 9CE51221FB6 for ; Fri, 24 Apr 2026 01:43:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.28.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776995000; cv=none; b=XW0R/Oqq1jj0qt/+wm/7eb3PjDZlbEkAAJGGrrUTATgig8qDgYk9VSmLfv9kpMmbjVORYzKdnwjc/4rxxVEYkNedpvTGSRGfkc30tWnlvijYCd2lXR0cby4VTx9RhgvbXUPUtXD231ZyhEa04rjBBA8XWq54/A+PXNAcAFcf6C4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776995000; c=relaxed/simple; bh=lN/ZWePZhnSlOI6CSiRQ5RscHmVWUpyH1BzBvUfzwsI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Zc7neAJZivyBkgQ2XANk4KNtIZV9wAGFjFe/N3MY97Gz1NiSsO3lun87UQlxktZc3GUSztdq/iANcjIKxnUO7PnJ6KaZbNrOXImNXd2+MVe9RLo5IFh5e7LZ4gtakcz4KDSzpV4pBP/kwI/sDrCpz/fPvnRs4ETC+m+OvYgq31M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=open-hieco.net; spf=pass smtp.mailfrom=open-hieco.net; arc=none smtp.client-ip=115.124.28.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=open-hieco.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=open-hieco.net X-Alimail-AntiSpam:AC=CONTINUE;BC=0.1054278|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_regular_dialog|0.0260784-0.00281897-0.971103;FP=4672971276614691816|0|0|0|0|-1|-1|-1;HT=maildocker-contentspam033032053168;MF=wanglin@open-hieco.net;NM=1;PH=DS;RN=7;RT=7;SR=0;TI=SMTPD_---.hJ3RqMQ_1776994992; Received: from 172.18.24.170(mailfrom:wanglin@open-hieco.net fp:SMTPD_---.hJ3RqMQ_1776994992 cluster:ay29) by smtp.aliyun-inc.com; Fri, 24 Apr 2026 09:43:12 +0800 Message-ID: Date: Fri, 24 Apr 2026 09:43:04 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 To: Mario Limonciello , 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> <857e8a70-be18-4ff1-8758-693af88efa00@amd.com> Content-Language: en-US From: Lin Wang In-Reply-To: <857e8a70-be18-4ff1-8758-693af88efa00@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Mario, You're right. After a successful smn_set_roots(), smn_num_nodes is guaranteed to be non-zero because smn_set_roots() already rejects (!roots || !num_nodes). So checking !smn_roots here is sufficient. Will fix in v3. Thanks & Br, Lin On 4/24/2026 3:12 AM, Mario Limonciello wrote: >> +/* >> + * 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.