From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.107.201.65 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796141521; b=2Wo1JryvFEDGaPs+ftsfpvF1tNoDduRlrfYayIdkIxsXnaA3PIaHRIBY2sQ6SaU2u9TM AMQCYZY8rVl5VAgeXF65tIgQ+VqvR7EekLDPYuyheo1HwMRf07rhJ1+A2AJ75GBZmRr06 coNgF12q6QH6Vf6EtIhxp4KnkHeX2BFkpyL3Jl3ZDdAgEY8QRjTA1FYTYtSooWyIGv22B DuKwAmi9jcVK3/6yFx281ObJ8b6SaLkdp1ixGbbf2IGrPcPURm+x8VYdF50VJ5th3BVou npU9fD/phqZHjjc4ya56wA+8RH6d+5WOuT6/TmPVZWZrsymiCnhw6kQ/bGNRKmI7ohw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796141521; 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=lcnAMfzsePD11pgTps9iUZrE0+XBn1f8fOOKwBObckU=; b=qDFpOgIoadVMOuqrZaXxVwI5oXV/6+AXbJsuVo2mUtFFiAroS4HrCsktWMNcgjDwCRM6 qV2VYs1yyGF3XrA1EIsQsXRQOjsyqLNMZ6PkT3PuX4cAHdvoWmmk0ADEbBOGW6oeQqEhb E5epGax6Fb0wxsc+9gdt3caUSByk7fWkObff9vXv0y++8sG3ObZ6X1QajJZ02mwkE72yE fiMS+UpyzWYf4OnJMnbmQMaZbtNmItP5zX9Hplbynlulfl1Mj1xLv9He6VtYD7F8PU8j8 ldPDSIBKKbhWWza26UtSI5y7Tvrl+oTjFoetE/eTPV7bopJFn0oci/zzvDGZ7ouQ+Iw== 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="3j2TQr/D"; arc=pass header.oldest-pass=0 smtp.remote-ip=40.107.201.65 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013065.outbound.protection.outlook.com [40.107.201.65]) (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 7681D606A322; Tue, 1 Dec 2026 16:12:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7681D606A322 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=3j2TQr/D ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eXhjm7MTYQ90fvE5Wcv9nbmIETQZ9EfNqJsrD003NDFULrD7BU3QEMyacrZ971e4ZN4rCt1ByNmof2SXzLl+ce2olvW7sENXIVlxYnwN5TlMX3lZ3HWdTFYOFppt6iSIWH47fX23JoIWIlj2+HRqs47pPuVSfNmZ5w7ufwipdPM4Z6qinLinLt5l2U4BwRcHsUVfqxhdyiFAuHQFZAfhh4F+aQtVq3VG1S67unz5ymOTsi9cCDw/JakZe9HzGcE8vV8L11xfNaQQF2z8OWqMIthxgMA1cSA6uyN/w5MK+6ekDhqxZqwLmUYdUrr0VJChyC9326ojb/YsW9QEYRRfRQ== 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=lcnAMfzsePD11pgTps9iUZrE0+XBn1f8fOOKwBObckU=; b=ZmxCJzBjg7DydzURJBpTTol7oTB3zgT81FTehSFmjyqd+iC4sKAC1aLBorxwLx+mGp3U2cveNPf130xR9aNBE6ekK14PoEcKFS2t7of88r0XwQ7FRAK+D2S6wfuERvxVjMDRYP3J/DSVLSvrZX12QX2sDl8CNpbRs4+qj/qerv2+yqhyMzLycrPRkYyPBLnf6IskWf0jvTyrghXPMXaxJ0849cJd4SHyjw1oGGekeKiiPBq5vUcY2+lb3LhXhX8UbfhKv5JrfKq9Ag1aIP8Gxt1DVAuGzMbysM5JNx9fZlj8L76QMX+uSOItWPs3LLnaYwrOOC+dyF3Vwfk9vof5uw== 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=lcnAMfzsePD11pgTps9iUZrE0+XBn1f8fOOKwBObckU=; b=3j2TQr/DLL3eb6rOkbVUsICMOWCFmA4Y1fe8hvL3ZCwCmRCzoAOnP873ODZK5IWYJ7T6uv4JHXyF6obNmp5REyUluZQPsfqHUwTRLZFv0C6sEZtdQL+3pxjqBWrHavv72TPLcf/FBkpcl2KMfva+T9qsn6VPbgBmvLt++6jy99s= Received: from DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) by SA1PR12MB9003.namprd12.prod.outlook.com (2603:10b6:806:389::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.12; Tue, 1 Dec 2026 16:11:46 +0000 Received: from LV8PEPF0000005E.namprd02.prod.outlook.com (2603:10b6:5:3b4:cafe::81) by DS7PR03CA0137.outlook.office365.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.13 via Frontend Transport; Tue, 1 Dec 2026 16:11:46 +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 LV8PEPF0000005E.mail.protection.outlook.com (10.167.245.138) 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 16:11:45 +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 10:11:43 -0600 From: Muralidhara M K To: CC: , , , Muralidhara M K Subject: [PATCH v4 0/2] platform/x86/amd/hsmp: Validate num_args and Report raw SMU mailbox status Date: Tue, 1 Dec 2026 21:41:27 +0530 Message-ID: <20261201161129.767731-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: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV8PEPF0000005E:EE_|SA1PR12MB9003:EE_ X-MS-Office365-Filtering-Correlation-Id: d924834a-73b6-43d7-d134-08df4fc5cbee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700016|1800799024|23010399003|11063799006|261009223027099003|18002099003|3023799007|261028144727099003|56012099006|261021123027099003|261026121527099003|261026140227099003|261102123227099003|10067099003|261021121427099003|261022075727099003|261022105027099003; X-Microsoft-Antispam-Message-Info: JbNbBlC+WRxT5i7y1GuO5Dn2ild4sl1LDzXRq4sXFPQCre2V2HjjR55KkkI8ELjm57Q+FQcQ87dUKnVUulyrno+YVNAjH7C7VtAK0RzeUw6Lja7TcO7XajEwoc7kbr3KwBRdbDC/9NmbXSqxP+/Kf89TexbfjbCWPmxiCE/e74dHfQCrKF2K0lJVmRLox0ppmrvDdEtFANh6pdyWgR3STCB3ZcOSlVnwGetuXJwiv1TbKhbIjbcQpNxPk3FLM6LtKBw48EeXcKLekKv77PnywWWe7jqer7nfvh9Nl4zYkltJn/ybi66eXyR/+sncBZPkDaVzhTIF8RuTgTqvZdbccK+ctXIG/bvZDnaqfVGhMgtQxHSQCfTnuYOE5yAozt3gdscsdutcDEoPtXiVP+RmXOSP5k68oG2zbs4Qfythsku6J7px1cMnn2y5+VkKgkXHdDwysObOhUAIwXHfq5eU/NDVk1xlCMFQzjy1zGlfR0wXl9OHK5vVuucWQLBuiOw0+wzxewFfahHwjdO1fH35qwugIKPFgm6jpkKA6eSR+QLIWV5I14Z1zeSh6NQokyz3ybAvJksdwQrL7Iw59uZFEKbWYy7AVvvLLErsTO6NyA/02QGmfdB3JrqLHM5X2OX0PNRvimXHwY7FDNiYFpIW3HuhNv4iLgvmzXt4i/VIS6cqgkqTUNIMiyqJadxWUZnRmq1IGAhuQ38G/HlvbsvKYw== 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)(376014)(36860700016)(1800799024)(23010399003)(11063799006)(261009223027099003)(18002099003)(3023799007)(261028144727099003)(56012099006)(261021123027099003)(261026121527099003)(261026140227099003)(261102123227099003)(10067099003)(261021121427099003)(261022075727099003)(261022105027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Q86tzLdRHCOPGnu0SCH1t68pHvM9ZVFZt+e4rvdAxeJLvYFYQfoz2JzB/swGS0YxxNMgnpabR+dvPs+mAdrKhw/omghniyoyE90X7NWivO+fhwTYaYQhnhoDNm+ht0zCGS18AZtG/GzkT+/tyDPx5ATOUlex3adpaoNc3N+9uPcg27uRSfK+N1tLv7Hv5h7pr+JANSN61pOiAJ1Wu4D1o+8DkSQ+/ZDpuuMDkRsJrc9RqRKFq30bqVKNNmsWYbE8XJJh5rSMTBHEiKJsIfouL+VhDflDtrVcA4sM5Ow9WILtT2lkGB1DLXdEqd/zwJ5lNqzE1l8kwoByZPMACpgmFKALMFXpjU/xCG/F4/NAg2w2Wli41IgKclsdDMloTcVazoKhoY8dzs4qi3wgABx7gZPn1X+0N+JXD8SZr5Z2+8PtJACRGePkyqVRZvadU5O8 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 16:11:45.8036 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d924834a-73b6-43d7-d134-08df4fc5cbee 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: LV8PEPF0000005E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB9003 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) and sizeof(struct hsmp_telemetry_data) are unchanged. Both ioctl command numbers, HSMP_IOCTL_CMD and HSMP_IOCTL_GET_TELEMETRY_DATA, are also unchanged from what is already shipped. v4: - Kept HSMP_IOCTL_GET_TELEMETRY_DATA as _IOW instead of switching it to _IOWR. This ioctl already shipped as _IOW in v7.3; _IOW/_IOWR only affect the ioctl command number used for dispatch, not whether the kernel is allowed to write data back via copy_to_user(), so there is no functional need for _IOWR here, and switching to it would have changed the command number and broken already-compiled userspace built against the released header. 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 | 19 ++++- drivers/platform/x86/amd/hsmp/hsmp.c | 117 +++++++++++++++++---------- 3 files changed, 111 insertions(+), 48 deletions(-) base-commit: 9437ee8b6cf607e883b36e44bd755968daaebd48 -- 2.34.1