Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.194.55 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796121095; b=JCWDrRc8+LsF+bF+YP/0yupj+cwPMjWJjK9A6yN6C067b8cUh/GS7ARLeCot56heUa25 ILcIf9tgiYxAls92H7PpfVEYe8nhUu79Ccg0K1s5dJV47dmdBZzsKA4fct7rnkp8I2O+9 fAXZ+GSjltW+Gw5OdX5vd9yHCxIYn9DkAPcoaehBT1GMgcxLguigeleOCjhIqMRTQfMuY bXsEPDHxHuVkWYUNeDIWYilSVsx59PNxagOfIm1a5BRuWwfAbpKXE/hUseu9JhAdafr9O kCRYFyZnEHHaFW+LJU5sLjTLCQq73mmhVtpsP50LLks5AjZ3MVAI6u2BcML9lNu5SHw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796121095; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: From:To:CC:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=sOjU6PQRQQT4GwBS2pdF9ozGtxVcLMNCmsiYZxOsNas=; b=l3jseHONIQjbbCIOQc3U1a+dhSHqkTYgKWkZLHH/c+qc/CvRhK8whikbYwbkH2K92Lx+ q4l9SdH1rlXDY3RHaiBFJ3vaheoz9P0Aku3hxP9IxpwVS9+tvvKsOVCWM+2XgtF5MF7OS 066bAFZzTRmnlJvQXff2p3GOAYcZECGxCZt8T60UXZ4A7CW/+2YZkFHe3nUZfqq0+7/x5 vEGixvc8lXVFUwMRveb+5ZxN0e3QRi/qsgeLD9N/J76yKVz2OMNWR+e4bFZPqwYSU+pr9 new1AjJFjv/yrae5pMPbBgtLLLCcxhrfH+QmYsu8JM1bsE0cFRMV2wu1yMv72o5WO/w== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=vyeIqCS5; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.194.55 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011055.outbound.protection.outlook.com [40.93.194.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70503606A33D; Tue, 1 Dec 2026 10:31:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 70503606A33D 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, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=vyeIqCS5 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oz2neUovryU+OqIPRFG9iWhiAArXERyH039CmPUs2pHCsj6jZrR+eotxPIGP+y0nE8K2D6X9tEbBN5PliyD0c3YIvMw52F8K7n1glGirlhRSNlmN131sHxLCbnNi5+MLuD6VPcibkmCt+YYLQOKia4XOVgVs52Zg4Lt64sz7vDk2RkOTBzJTZ1/LV25bmfXfNIPMJzOhEYoNqcZKh1Y8MkKl5lMnMvzHUyp73PDgP2HnBmg2XwqAdb5D0qs75QZhoRMHE49Pc7eDlXKA7yyA6fOwdAHd/7BcwBICsnWgai/iOWiSS+OCa7400TiR5ibRKIr1cXgK6NvuzSnkA98djg== 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=sOjU6PQRQQT4GwBS2pdF9ozGtxVcLMNCmsiYZxOsNas=; b=DoHqk6VRWf2qyXf0vVnHj8y0/PQrIX5izH8APGJYKRv8EB8DcLSWKoVBlynu6ukAojEXDKE5WfMJNd3+bnvXTyz7PJREsFZNirllgvM1XLkZ1Hu2OEZGZyBs3WZl540UHGj0UfFS0Zwu5AYFDBVgnA2m79f3NlOwiMytpUO4jMQeMhLRY4IOAHtMRCHncrOBsSPkaWfxS2YHAapEJHRxMfG2+0d2gFGZpMLHKWJstK/TLCJwf5dmNClouJ+g/4SlFJLCi+jPfRDS5/H2ANW0KC3CaZi2RL9Rz5N3wA8NkdZM5R6zofZ2nbI9WlLkwRdLgyg6XV+BjBL7IvpWFry7xA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) 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=sOjU6PQRQQT4GwBS2pdF9ozGtxVcLMNCmsiYZxOsNas=; b=vyeIqCS54YYmDdLBP/K1gGJp3DEhHD0+GqhRno8JW3898g6B8DAOaNvP61sFZNmjgcQSGSrV9kqxu8WsT32NTjV9ZbomvR3q8aAOvW+LbUrR3sWpR0ygpHOxjF3njjq+HYO0W7cF5txDd13JXV7duDhvoggb0l33bkP/AWlgEzE= Received: from BLAPR05CA0021.namprd05.prod.outlook.com (2603:10b6:208:36e::17) by MW4PR12MB5667.namprd12.prod.outlook.com (2603:10b6:303:18a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.10; Tue, 1 Dec 2026 10:31:22 +0000 Received: from IA0PEPF00000040.namprd04.prod.outlook.com (2603:10b6:208:36e:cafe::4c) by BLAPR05CA0021.outlook.office365.com (2603:10b6:208:36e::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.10 via Frontend Transport; Tue, 1 Dec 2026 10:31:22 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by IA0PEPF00000040.mail.protection.outlook.com (10.167.249.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Tue, 1 Dec 2026 10:31:21 +0000 Received: from dcsm-trdripper1.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Tue, 1 Dec 2026 04:31:20 -0600 From: Muralidhara M K To: CC: , , , Muralidhara M K Subject: [PATCH v3 0/2] platform/x86/amd/hsmp: Validate num_args and Report raw SMU mailbox status Date: Tue, 1 Dec 2026 16:01:00 +0530 Message-ID: <20261201103102.601993-1-muralidhara.mk@amd.com> X-Mailer: git-send-email 2.34.1 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 Content-Type: text/plain X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA0PEPF00000040:EE_|MW4PR12MB5667:EE_ X-MS-Office365-Filtering-Correlation-Id: df7c4003-850d-469c-7b49-08df4f963e5c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|23010399003|376014|36860700016|18002099003|3023799007|10067099003|56012099006|261021121427099003|11063799006|261021123027099003|261102123227099003|261026140227099003|261026121527099003|261028144727099003|261022075727099003|261022105027099003|261009223027099003; X-Microsoft-Antispam-Message-Info: RYqHUwbT4BoYY67n6CozZKKvG7R6gncrG0WJ/gqaWuCKbgkbGhhTLrJZ3EXMJRrImq+SZ0+mRJkXyT2UXrz67EytPIdl/pj126GsMMXKRftlPJDQ3CWoRY+tSKeetuPpmGlIdhzlBukukTD/rRKeN7rxAN8RQtprZiwFHIly0eMNVOrrw/O3L4eFTjuhClGiYe53K6nEmWfH42HkfLjc6iGHd9LnbId19fqHIbDX03QxvHMBs9xA0UFNLAUZmS2YtIAo8YMDJC58GUEuNnqdAsv3DdFee3dxGy9GPwv65b7f+ktzI2s+ZwTxDYIPIxpZb7in/yOV8y4WmA2GRMW5HGnfoGzFiDfcxFhboqFJd3DaRYb84ZC/xmIZLc7aaYKzAxwnChM+LGSO6lbwLX8mvBpEwlG15fR22Y0t9QmWw8f++Hncy6i0+3JFGuGytkgrHgGUU++NtJLYXM7liLi9Wn752c34/uM5FMCb7NZ78s4jnjwME35I8gbivvw/qrDf6oIpJY40m+WNdJypvqWTJ7jauwBWbIlz/k6ZqhvQ+PbKsMimrEswD6hqrfEOewHRYYFCXXqbCdzLYjlioyULk2DRQJnJtqoSl01/7iyIyI75o5ZmlwT5FRSSCpEG2GILUh2IvWl0ZH8/cprueYelQKW8G/9dvVjQRT2PQTB6+KMOoyNkPSJVUButb+uUkpHrp6cOafGQrla5UbHEl6eNdQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(23010399003)(376014)(36860700016)(18002099003)(3023799007)(10067099003)(56012099006)(261021121427099003)(11063799006)(261021123027099003)(261102123227099003)(261026140227099003)(261026121527099003)(261028144727099003)(261022075727099003)(261022105027099003)(261009223027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: giUGnOFWiJERmQsDK2SUXu+1YZWX4KKzsG18tnYfqtpKslczz1nD5eN1ZbLPMdIbWOI4G4WB4fZsCv6Vyq+QTneAitPV/93khNVsEgJy/ZQoKzU7xHrdJM92icUVpA9WOkDqWiVX+EeJepAbiRIhZM0494AuPo9JpcEf3ogXJUVqyS8QReuV6Nozy458BIRLXD2gTsbO5SZVYj7p/mdyxuVFsos1IPAlT4a4NmrW/H4TRbpfNuD0H9NaK9CB2vdOyVFKNAMs0kZsSDtEcbEDFM6KkHgS9xWIxlXXpEDJe0Sy6seW7ewJKqdSRnmwetxMVaHtwrRghDk/W3IQeBg9JHRU0ABl2h2WbCJFrBKM+EHaaocyWcBxalfjs3APH8lu6s7jWnEaiHNLyW633nk4T4/Ea2fwIH7U+YSh7Z0EdzbWwZNoM+9bevbwv1DhbBSy X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 10:31:21.9456 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df7c4003-850d-469c-7b49-08df4f963e5c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: IA0PEPF00000040.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5667 This series adds a __u16 smu_response field to struct hsmp_message and struct hsmp_telemetry_data, so userspace can inspect the raw SMU mailbox status instead of only the translated errno. Patch 1 is a preparatory fix: hsmp_ioctl_msg()'s fd-mode gate calls is_get_msg(), which reads msg.args[0], before checking that num_args matches the message descriptor, so a request with no args can still reach that read. Validate num_args first. Patch 2 adds smu_response to both structs, set from the polled SMU mailbox status register, and has hsmp_ioctl_msg() always copy the message struct back to userspace, even on failure, so smu_response is visible on every call. It also fixes a related copy_to_user() error-check bug in hsmp_ioctl_get_telemetry() uncovered along the way. smu_response is __u16, matching the width of existing spare padding in both structs, so sizeof(struct hsmp_message), sizeof(struct hsmp_telemetry_data), and the encoded HSMP_IOCTL_CMD command number are unchanged. HSMP_IOCTL_GET_TELEMETRY_DATA is switched from _IOW to _IOWR, since the kernel now writes smu_response back into the request struct. v3: - Reverted smu_response from __u32 back to __u16: the mailbox status register is accessed as __u32 purely because that is the SMN/MMIO bus access granularity shared by all mailbox registers, not because the status value itself needs 32 bits. Every documented HSMP status/error code fits in a single byte, so __u16 is lossless and avoids the ABI break (struct size / ioctl command number change) that __u32 would have introduced. - Fixed a redundant whitespace-only diff in Documentation/arch/x86/amd_hsmp.rst where the struct hsmp_message code block had been reformatted from tabs to spaces; restored the original tab alignment so only the smu_response line shows as new. Each patch builds individually and is clean under checkpatch.pl --strict. Muralidhara M K (2): platform/x86/amd/hsmp: Validate num_args before the fd-mode gate in hsmp_ioctl_msg() platform/x86/amd/hsmp: Report raw SMU mailbox status via smu_response Documentation/arch/x86/amd_hsmp.rst | 23 +++++- arch/x86/include/uapi/asm/amd_hsmp.h | 25 ++++-- drivers/platform/x86/amd/hsmp/hsmp.c | 117 +++++++++++++++++---------- 3 files changed, 114 insertions(+), 51 deletions(-) base-commit: 9437ee8b6cf607e883b36e44bd755968daaebd48 -- 2.34.1