From patchwork Wed Jun 21 03:50:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avadhut Naik X-Patchwork-Id: 13286632 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC7BEEB64D7 for ; Wed, 21 Jun 2023 03:51:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229821AbjFUDvo (ORCPT ); Tue, 20 Jun 2023 23:51:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbjFUDvo (ORCPT ); Tue, 20 Jun 2023 23:51:44 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2062.outbound.protection.outlook.com [40.107.223.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9E57B4; Tue, 20 Jun 2023 20:51:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rd4VcUr5hd00HBIhIdCJQvcR1Ql3qu5PtzVNgS+ptULAhXexkNnhklD4wYjhsE4MNMVoy6P+t1FfYFVZkLN4OpfWRYmwUa5zeWnebhb6UFvqq4c12slN28bwXy8EgjZNhXAlWuJKpkq/dU0rE4JiqW8QeKf+7BKJuqWJGuCoC9D250z39Q57DUv2guvr7GvECpJzAUh12y/dcxYnyZZhhHVPxmp33ccRNRwiE95XODi+hGTrwmNnOEYzcAbBfu+zzJLZwo/ahII5NmwEAisWHoOKe5xl10Qq6xxQpgL9wy5umlGKKQNDWIsGv+YrmmvmyaJDalhODTwvxPvLI7cjtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=MA3Y6jGCoRGvIpIYfOWMFchg/cw5lcr9kqodQe2gV4Y=; b=JgsLOLaANBr+G5mgb5mJZbiP514mmKSUuR35pdmDyIIYnywtT7F+/nLIPJwtXBlZQLCnetnP9U7xMBcfQFk9VmPOSNhvgG3yyhDkub3VSR06MaE0sYvzLbaaEL4XV2Wq9lTc2gvfB5p+n9McpsmfEtXmu8OrP1FpWxUziJ80a4Yd3ZHSnFs19Yui+t+RLofEY2m9XktIz4Rov6c7De/Mz1Z0m1BvD0YuniFTNhSrQDbf8LyWK4NIzfmV0sLd6M0x5sK1ZnN57U6MRowHE8leHixe0QuY+4hXzV41PUxLZP15X5Zf4GlMomKvkxlLkVFDC5wQzQZXT6rJDyBn7VJaKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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 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=MA3Y6jGCoRGvIpIYfOWMFchg/cw5lcr9kqodQe2gV4Y=; b=PKYj61TANSrHdddcAHVn1yED9UyURN8a8uoghbVs96wMJ9cNrR6k3Je+lAedoM5cCPQk/Ktx7KpfQRyD8huSTfi7kGDH0A3OVdghqWztCqVGcKrqaLonM4jKbDoxUwBv7vwYCtV0xMCqa777DeXUSDAPBzd6HTutDylRSdjF5zo= Received: from CY8PR10CA0039.namprd10.prod.outlook.com (2603:10b6:930:4b::26) by SN7PR12MB7450.namprd12.prod.outlook.com (2603:10b6:806:29a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37; Wed, 21 Jun 2023 03:51:40 +0000 Received: from CY4PEPF0000EE30.namprd05.prod.outlook.com (2603:10b6:930:4b:cafe::d7) by CY8PR10CA0039.outlook.office365.com (2603:10b6:930:4b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Wed, 21 Jun 2023 03:51:40 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE30.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Wed, 21 Jun 2023 03:51:40 +0000 Received: from onyx-7400host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 20 Jun 2023 22:51:39 -0500 From: Avadhut Naik To: , , , , CC: , , , Subject: [PATCH v4 1/4] ACPI: APEI: EINJ: Refactor available_error_type_show() Date: Wed, 21 Jun 2023 03:50:59 +0000 Message-ID: <20230621035102.13463-2-avadhut.naik@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621035102.13463-1-avadhut.naik@amd.com> References: <20230621035102.13463-1-avadhut.naik@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE30:EE_|SN7PR12MB7450:EE_ X-MS-Office365-Filtering-Correlation-Id: c9b4a8a9-6576-4c1e-f106-08db720ad24a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JjXHUD6bsFEgiv8OmRPym5r/qVjvilI0oMunBtX0/Mzeb7H116ipuS49iIMaK9ymqe4wC3naaH16fwM/snW1gT88/YwkwYOJy/f2lSCoGNVogPx3036CqFG+WkNFNdPPokidaHgkBn2NGDXEavy0by/2rt9jNI9TkdvAqqave+oQ6FOirTBOrMrFdWftbny+r/rq3TO8Y+WRa26TGCizDi6rjdsJ2du5kBQ43ynXXpK48sHX7+Ummf7Rmq3vFwtyhggBRor9ZtbTELLr+MdT1aYBN4Bmr16yeg6o5OMtXhWjbweHlx3F1JNkXCAR+DK8u8o7zNZY03ao0LtC+EdmW118Xky6bkCO8AilTTq2ZBzQjwg6Qg4bEVr2TVrJv19+HUCQbbnDS187sB+wTvQGZhYrOYHIrVIgWKZs+1pg3y0KC06lGsHxdDvLTLWmWkPeCA+WfkxX6udJH//KBZAc4tXPOByvmuMdyclBpQb+S/YE5Qw/Uvwb0DE0OV1u9e2+4+J2qtlu4d/WZPjB7cjheth1AIbMh7JS7yxADMhaqqFAFwLRgAMU5sBWdSIXRCwZ9H42XCBCa7W1srzsMpCJImwPMAfdSiBTy34r9/9y+gUWadaH6Yf/cXBRquEu9IQGwDtTMb3BzvaCOSH+oqz5IYS6xjfZUlt/mMj1mzJs2ATgMM2Uaeuzig0i+istCnvT9+ZFEdLXb9NFQMjC43ZGVQH+16zOyZINFVpX8sERDViegoimt+auYQIfA4/ECUpcYwyqJmv/w2QQ3DMo/amMZhSNnVYY1Rfqe+lIl7Z033c= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(39860400002)(136003)(376002)(396003)(451199021)(40470700004)(36840700001)(46966006)(82310400005)(44832011)(36860700001)(86362001)(40480700001)(2616005)(40460700003)(5660300002)(8936002)(1076003)(8676002)(54906003)(26005)(16526019)(6666004)(110136005)(186003)(36756003)(7696005)(478600001)(2906002)(47076005)(81166007)(356005)(82740400003)(83380400001)(336012)(426003)(70586007)(4326008)(316002)(70206006)(41300700001)(2101003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 03:51:40.5329 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c9b4a8a9-6576-4c1e-f106-08db720ad24a 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE30.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7450 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Avadhut Naik OSPM can discover the error injection capabilities of the platform by executing GET_ERROR_TYPE error injection action.[1] The action returns a DWORD representing a bitmap of platform supported error injections.[2] The available_error_type_show() function determines the bits set within this DWORD and provides a verbose output, from einj_error_type_string array, through /sys/kernel/debug/apei/einj/available_error_type file. The function however, assumes one to one correspondence between an error's position in the bitmap and its array entry offset. Consequently, some errors like Vendor Defined Error Type fail this assumption and will incorrectly be shown as not supported, even if their corresponding bit is set in the bitmap and they have an entry in the array. Navigate around the issue by converting einj_error_type_string into an array of structures with a predetermined mask for all error types corresponding to their bit position in the DWORD returned by GET_ERROR_TYPE action. The same breaks the aforementioned assumption resulting in all supported error types by a platform being outputted through the above available_error_type file. [1] ACPI specification 6.5, Table 18.25 [2] ACPI specification 6.5, Table 18.30 Suggested-by: Alexey Kardashevskiy Signed-off-by: Avadhut Naik --- drivers/acpi/apei/einj.c | 43 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c index 013eb621dc92..ee360fcb1618 100644 --- a/drivers/acpi/apei/einj.c +++ b/drivers/acpi/apei/einj.c @@ -577,25 +577,25 @@ static u64 error_param2; static u64 error_param3; static u64 error_param4; static struct dentry *einj_debug_dir; -static const char * const einj_error_type_string[] = { - "0x00000001\tProcessor Correctable\n", - "0x00000002\tProcessor Uncorrectable non-fatal\n", - "0x00000004\tProcessor Uncorrectable fatal\n", - "0x00000008\tMemory Correctable\n", - "0x00000010\tMemory Uncorrectable non-fatal\n", - "0x00000020\tMemory Uncorrectable fatal\n", - "0x00000040\tPCI Express Correctable\n", - "0x00000080\tPCI Express Uncorrectable non-fatal\n", - "0x00000100\tPCI Express Uncorrectable fatal\n", - "0x00000200\tPlatform Correctable\n", - "0x00000400\tPlatform Uncorrectable non-fatal\n", - "0x00000800\tPlatform Uncorrectable fatal\n", - "0x00001000\tCXL.cache Protocol Correctable\n", - "0x00002000\tCXL.cache Protocol Uncorrectable non-fatal\n", - "0x00004000\tCXL.cache Protocol Uncorrectable fatal\n", - "0x00008000\tCXL.mem Protocol Correctable\n", - "0x00010000\tCXL.mem Protocol Uncorrectable non-fatal\n", - "0x00020000\tCXL.mem Protocol Uncorrectable fatal\n", +static struct { u32 mask; const char *str; } const einj_error_type_string[] = { + {BIT(0), "Processor Correctable"}, + {BIT(1), "Processor Uncorrectable non-fatal"}, + {BIT(2), "Processor Uncorrectable fatal"}, + {BIT(3), "Memory Correctable"}, + {BIT(4), "Memory Uncorrectable non-fatal"}, + {BIT(5), "Memory Uncorrectable fatal"}, + {BIT(6), "PCI Express Correctable"}, + {BIT(7), "PCI Express Uncorrectable non-fatal"}, + {BIT(8), "PCI Express Uncorrectable fatal"}, + {BIT(9), "Platform Correctable"}, + {BIT(10), "Platform Uncorrectable non-fatal"}, + {BIT(11), "Platform Uncorrectable fatal"}, + {BIT(12), "CXL.cache Protocol Correctable"}, + {BIT(13), "CXL.cache Protocol Uncorrectable non-fatal"}, + {BIT(14), "CXL.cache Protocol Uncorrectable fatal"}, + {BIT(15), "CXL.mem Protocol Correctable"}, + {BIT(16), "CXL.mem Protocol Uncorrectable non-fatal"}, + {BIT(17), "CXL.mem Protocol Uncorrectable fatal"}, }; static int available_error_type_show(struct seq_file *m, void *v) @@ -607,8 +607,9 @@ static int available_error_type_show(struct seq_file *m, void *v) if (rc) return rc; for (int pos = 0; pos < ARRAY_SIZE(einj_error_type_string); pos++) - if (available_error_type & BIT(pos)) - seq_puts(m, einj_error_type_string[pos]); + if (available_error_type & einj_error_type_string[pos].mask) + seq_printf(m, "0x%08x\t%s\n", einj_error_type_string[pos].mask, + einj_error_type_string[pos].str); return 0; } From patchwork Wed Jun 21 03:51:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avadhut Naik X-Patchwork-Id: 13286633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9D99EB64D7 for ; Wed, 21 Jun 2023 03:52:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229871AbjFUDwh (ORCPT ); Tue, 20 Jun 2023 23:52:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229984AbjFUDwZ (ORCPT ); Tue, 20 Jun 2023 23:52:25 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2067.outbound.protection.outlook.com [40.107.93.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 116AFE6E; Tue, 20 Jun 2023 20:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZrXgnYeFWpK8atVN5Itz90GVAN8Gc0mKHgXH7AsFgHdeL5U7vH5mZxOPx1fhjDlJuW4TKP35ifD+z+OCSrN+82s0WvJVPcdC6yu5+Jv/V+PK2LtNzIjCMIvJfmoO80Amub18/T8ydnrZhHqoSh0TphTNP4QMz43kDIyMWuatnge0Qpy+gC/Hhry1anL784hF9x0rWXnGdOTsAEW3+ixZCPx7crejC7tkHQCYdz4jI+m/o3m6+U193g/34c06cBaez5ZK5x0MklaGFSO7Cfj1s6/yuIdsxQnAOyojb25I9oq7pVf5wHGQikgyUlfV8yakMvpWoASoaqkMY/KOoQ/Tvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=K0f06PgbYTz/YGVW6UaOhvo6HPdiSicDEdPIR9gaBL0=; b=Z5Zp6ZGeSac3DmjvopeWUzTt6B1a3JOCPdNawtjOXX5WUIM0jGe2MnpEu2whgheI508ol51yVC/Pk37do/CNzToYONQ3aNB1gfV7/IdQ7vFwvRjv5W96eZANIjcpYKSJkPXHTjAoLAkNL4n63bwmZcrFOc7csAEwqp/KvQThjcE6FPRn2nYFEh+Wdf1psBSIjPL3GgOrFIT1qPC/stIofnct8hTneOrKHTB8PknoJGE9cbYnqITS/sDWp5mXgasodV/AOyclAjloocLmGJkXUIrH+73FGsyJjOK4UTzIxxWpFkO8pICdCsQqLJDDHS7UwVhqHA34M63iDs5UvXqV9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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 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=K0f06PgbYTz/YGVW6UaOhvo6HPdiSicDEdPIR9gaBL0=; b=jEPUqMI4l0tWgYQhwGqJOY7T64/9uvz195MOUu1lKiM1zPgiiXZcUUWEt2EaMRBhIifwUR0Y58Q/CWkIoPOdqyu8fpD0vIVzck+qTXDWZjYfLyiF8vzzT155jlDVh+ebV44/C6vGAKDUG+btahfddwkQvdjPt8NVkATj49Tuvdo= Received: from CY8PR11CA0009.namprd11.prod.outlook.com (2603:10b6:930:48::13) by DS7PR12MB5790.namprd12.prod.outlook.com (2603:10b6:8:75::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Wed, 21 Jun 2023 03:52:07 +0000 Received: from CY4PEPF0000EE34.namprd05.prod.outlook.com (2603:10b6:930:48:cafe::fc) by CY8PR11CA0009.outlook.office365.com (2603:10b6:930:48::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Wed, 21 Jun 2023 03:52:06 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE34.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Wed, 21 Jun 2023 03:52:06 +0000 Received: from onyx-7400host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 20 Jun 2023 22:52:03 -0500 From: Avadhut Naik To: , , , , CC: , , , Subject: [PATCH v4 2/4] fs: debugfs: Add write functionality to debugfs blobs Date: Wed, 21 Jun 2023 03:51:00 +0000 Message-ID: <20230621035102.13463-3-avadhut.naik@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621035102.13463-1-avadhut.naik@amd.com> References: <20230621035102.13463-1-avadhut.naik@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE34:EE_|DS7PR12MB5790:EE_ X-MS-Office365-Filtering-Correlation-Id: d37a2293-74a4-4c50-2f0c-08db720ae1e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A0DZzi8m/cOBN4gAOgGj21UHAlcsFfz3e5NeNs3e7/y0cJHo+KmZ0zk9vVu7KOM2JZ4O16shtGaOhYNsw104UGSYcKW+deXhNymBQnNUMfP5jqGnI/Br45ooEaI/Tn9hL6bcPCsYWfeSSnB21UjFbAIY++67nUJENUoICR6aK0W17xGP0qP0Nts1PK/zoEi3DuJm3x1oFuti5uuG578Msl7BDQjmGNSLF3vOfZ+GaWunr7YwtQg5qJ7K5rER/CCW71sAUNa/0PHwd6cvt7MQymGPBG8Z8dEOcw/9XffNDO6MM0hbr7XGwY61JoVxr95o8TD0145f5gOcrlFkEBnHZWEpZuKCXm8EoTopH1xdneGzZvvzefb3VKFFCRFovEOJu69uCRqREUQuZfDb8LZBpz7Sqp2xhFsLZXCx8S5CtTK6IJALaOUoKCcueKA2hOszRmP4sfLl/JEXd2uWY9HosuPMAmzgJo9HEn+rUsWElif3jZjkBFIc1BRqRCROZ+/pAfTC/4GvBncb/Dw9HxpbWUZZZP3s7s0yshhOs14sj5sHN9zIftQQEndjb926Rlr02FZxpQddlD4xiXkDGnunmm6ss5Lfytk1+/EUi6rqhzBK2Y8tN5u6R5CJN2pz6nM0v1SQFQ3OAPR6iMoDa7nCrR9a8x3NFtDL9txKoxjM/F3737r/RAoaPsF28cpHqh/g+S7jojDw7tHSgCKs4ycJ70JKdgfIJsCiTYoQQs7GKgNrTrPXLu4b/P9DU+ZPwiYzxj7FWgGKnDrFijGRSiDYQ0eTJfhD97nyCysCoDuQTGs= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(136003)(39860400002)(346002)(376002)(396003)(451199021)(36840700001)(46966006)(40470700004)(186003)(82310400005)(36860700001)(36756003)(81166007)(70206006)(356005)(44832011)(5660300002)(8676002)(40460700003)(41300700001)(8936002)(316002)(40480700001)(86362001)(70586007)(4326008)(82740400003)(426003)(2616005)(47076005)(478600001)(16526019)(26005)(1076003)(2906002)(54906003)(83380400001)(7696005)(110136005)(336012)(2101003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 03:52:06.7096 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d37a2293-74a4-4c50-2f0c-08db720ae1e5 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE34.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5790 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Avadhut Naik Currently, debugfs_create_blob() creates read-only debugfs binary blob files. In some cases, however, userspace tools need to write variable length data structures into predetermined memory addresses. An example is when injecting Vendor-defined error types through the einj module. In such cases, the functionality to write to these blob files in debugfs would be desired since the mapping aspect can be handled within the modules with userspace tools only needing to write into the blob files. Implement a write callback to enable writing to these blob files in debugfs. Signed-off-by: Avadhut Naik Reviewed-by: Alexey Kardashevskiy Reviewed-by: Greg Kroah-Hartman --- fs/debugfs/file.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 1f971c880dde..fab5a562b57c 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -973,17 +973,35 @@ static ssize_t read_file_blob(struct file *file, char __user *user_buf, return r; } +static ssize_t write_file_blob(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct debugfs_blob_wrapper *blob = file->private_data; + struct dentry *dentry = F_DENTRY(file); + ssize_t r; + + r = debugfs_file_get(dentry); + if (unlikely(r)) + return r; + r = simple_write_to_buffer(blob->data, blob->size, ppos, user_buf, + count); + + debugfs_file_put(dentry); + return r; +} + static const struct file_operations fops_blob = { .read = read_file_blob, + .write = write_file_blob, .open = simple_open, .llseek = default_llseek, }; /** - * debugfs_create_blob - create a debugfs file that is used to read a binary blob + * debugfs_create_blob - create a debugfs file that is used to read and write + * a binary blob * @name: a pointer to a string containing the name of the file to create. - * @mode: the read permission that the file should have (other permissions are - * masked out) + * @mode: the permission that the file should have * @parent: a pointer to the parent dentry for this file. This should be a * directory dentry if set. If this parameter is %NULL, then the * file will be created in the root of the debugfs filesystem. @@ -992,7 +1010,7 @@ static const struct file_operations fops_blob = { * * This function creates a file in debugfs with the given name that exports * @blob->data as a binary blob. If the @mode variable is so set it can be - * read from. Writing is not supported. + * read from and written to. * * This function will return a pointer to a dentry if it succeeds. This * pointer must be passed to the debugfs_remove() function when the file is @@ -1007,7 +1025,7 @@ struct dentry *debugfs_create_blob(const char *name, umode_t mode, struct dentry *parent, struct debugfs_blob_wrapper *blob) { - return debugfs_create_file_unsafe(name, mode & 0444, parent, blob, &fops_blob); + return debugfs_create_file_unsafe(name, mode, parent, blob, &fops_blob); } EXPORT_SYMBOL_GPL(debugfs_create_blob); From patchwork Wed Jun 21 03:51:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avadhut Naik X-Patchwork-Id: 13286634 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F31AC0015E for ; Wed, 21 Jun 2023 03:52:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229927AbjFUDwk (ORCPT ); Tue, 20 Jun 2023 23:52:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229994AbjFUDw1 (ORCPT ); Tue, 20 Jun 2023 23:52:27 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2071.outbound.protection.outlook.com [40.107.220.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4FC11737; Tue, 20 Jun 2023 20:52:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M3ufBURWBHnkiREgxooDRS1671ZJdEmfkTdPwMo97MGDC/57cEFVuLsKIes9bKsPpxtXQED6YRFhmFjpM5MGtuJGwLCKZPUfQ8d7kYzXjVKfohsNIlhMjIt9ZluIU2vBF7KcyUKdLKKqoXBy8YDGpEFTiIo1nBn6dHDwbuba72uLR803Ktqs7Kku7x4ST2+q/htRBODTkGIE2AGr6VLs2vKCKRyoMV04r/1z1hbzDutqjPMy2+oc0sgUdro7xrsd+Iwf9q3Cy1WyMmfotar49xK3sNzuVgPui69DoJMmM59PHUFQG9mHXBM90Sdd8QNWv+hammBhFZyJ7YrPP/nS+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=S3vzg9K4jeNL/nHvCAwQ6GIQOW4T7hIJBssaA6MeG0M=; b=f924sLexSBKz6+rKKkMRdWDWxbv1qzIDVqIIpK52nmKKR+FZlMC6aba6A2b4nbgPUJZKd4Y0U9lEj+iFmyyNcRm3OjlX34RILPRB+WtQsooNG7pn03CpOKyB6AH1faFzZWtU6tvQknYcs2ZEQ3aI6UoUN8BDzg0tjwZ/repRuA1jMYcQ+47AZ3lXodxG1KfgL/dMX+dA/88d3CEM11evN9Nbpo9VA+UiI7d2KcJMhKXwappDoRjRolNyRxzW9CreoCI60HQgwEXaQ0H0jVASIw7tkaD8SoY5F+8o9w7OaSWAuVvGUbXaF7rtoKb2/cucfhb8+JHNqpHfzOheDlEi0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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 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=S3vzg9K4jeNL/nHvCAwQ6GIQOW4T7hIJBssaA6MeG0M=; b=h3zV16rbxqH9Fz5ngltiJNaFoZLIpHGe7JpQI7uNgqspgKMNuiMLgtUynOYaowYqujIMpme4WS/ZVwHz9wzsNAijeREurrNemFIifAJeyC7BPjMFpdD8+wUXvii0WIHId9Ug3ggWyFTS9Y89i9tI/8Y68BPgWgcLBlLZhOWduXo= Received: from CY8PR11CA0019.namprd11.prod.outlook.com (2603:10b6:930:48::28) by CH3PR12MB8403.namprd12.prod.outlook.com (2603:10b6:610:133::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.35; Wed, 21 Jun 2023 03:52:16 +0000 Received: from CY4PEPF0000EE34.namprd05.prod.outlook.com (2603:10b6:930:48:cafe::2) by CY8PR11CA0019.outlook.office365.com (2603:10b6:930:48::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Wed, 21 Jun 2023 03:52:16 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE34.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Wed, 21 Jun 2023 03:52:16 +0000 Received: from onyx-7400host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 20 Jun 2023 22:52:15 -0500 From: Avadhut Naik To: , , , , CC: , , , Subject: [PATCH v4 3/4] platform/chrome: cros_ec_debugfs: Fix permissions for panicinfo Date: Wed, 21 Jun 2023 03:51:01 +0000 Message-ID: <20230621035102.13463-4-avadhut.naik@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621035102.13463-1-avadhut.naik@amd.com> References: <20230621035102.13463-1-avadhut.naik@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE34:EE_|CH3PR12MB8403:EE_ X-MS-Office365-Filtering-Correlation-Id: 5384493e-9d0c-4140-7682-08db720ae79f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +HJlN/RbwKYR/amipIigw1/UlytCIk5v59ZUfHOg3TnypmemcHh/DLZd0pPUCxydI31lQXqNm4j+I+yKBURnAPUI+JqB075DfZGkCWHqM5EtDgpT43zEOxnTPr0XB8Ne3y7B+iH1J87dqVevPYw2QLO+dLlHvaVZFUn8zdhhFaeVNgKFzeOb3z5xbxKlvgz3nxioczdg+v0ip71h63yjEnnG17NjylF0/9VoIM2lFXPXVGwGHfq9njR5orlYKnEz7U1qijHHx818nn03QHHk+mUnmB/4Xa9cs4TT9SYvIKdXWJVlal7mUlWpak6vC3INent55haFlx/jHl3/aDBL2KiP9/zs89PP75ewnedSKbH+HeJTI4qmOaqt50/vGr1NTjcKTtf1aCty4IhjNHaUBPkpEwn1GZM888gflAUvIzdvnqmKLDuHDuUeMS4VXzzrEvnpnHXndvRr3vnlfQ4tI1Z5hlXlwvpIaQF632vUgHGftctsUs+lMX65ugwLcHx6txSeE7u51s9+aVHOT3nzpLyLvEe3sWd8Y30E7Zu1HMbJUm/5ZXdqBiqb+E1UAzwvO3PgJGgUHnHgEYvj6zExrvfyH0F/G2F2xraA21cgHeGAg9OzyktmclGQ8QrKOhZ3RdLe+3JUN5EPeVIjj0omenhr9saBFhW/jJzOd9J88ky7yCEvsIleHB4KvdTtB2pNUbx4BR5pRtSz7fAE3ZFSH2r749EkcaYS+Afkeldsc8N2023Bi0I3aF/vUtHOMY6AHl7cZAGuWiVTiZl1CKXiho+2mb0N2ZWBrTC3dCZR9xk= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(39860400002)(346002)(396003)(451199021)(46966006)(40470700004)(36840700001)(82310400005)(356005)(81166007)(40480700001)(40460700003)(36756003)(86362001)(82740400003)(6666004)(7696005)(16526019)(186003)(26005)(8676002)(8936002)(5660300002)(44832011)(1076003)(478600001)(110136005)(41300700001)(316002)(54906003)(4326008)(2906002)(70206006)(70586007)(36860700001)(426003)(83380400001)(2616005)(336012)(47076005)(2101003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 03:52:16.3190 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5384493e-9d0c-4140-7682-08db720ae79f 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE34.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8403 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Avadhut Naik The debugfs_create_blob() function has been used to create read-only binary blobs in debugfs. The function filters out permissions, other than S_IRUSR, S_IRGRP and S_IROTH, provided while creating the blobs. The very behavior though is being changed through previous patch in the series (fs: debugfs: Add write functionality to debugfs blobs) which makes the binary blobs writable. As such, rectify the permissions of panicinfo file to ensure it remains read-only. Signed-off-by: Avadhut Naik Reviewed-by: Greg Kroah-Hartman --- drivers/platform/chrome/cros_ec_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_debugfs.c b/drivers/platform/chrome/cros_ec_debugfs.c index c876120e0ebc..4428dcbd2a68 100644 --- a/drivers/platform/chrome/cros_ec_debugfs.c +++ b/drivers/platform/chrome/cros_ec_debugfs.c @@ -454,7 +454,7 @@ static int cros_ec_create_panicinfo(struct cros_ec_debugfs *debug_info) debug_info->panicinfo_blob.data = data; debug_info->panicinfo_blob.size = ret; - debugfs_create_blob("panicinfo", S_IFREG | 0444, debug_info->dir, + debugfs_create_blob("panicinfo", 0444, debug_info->dir, &debug_info->panicinfo_blob); return 0; From patchwork Wed Jun 21 03:51:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avadhut Naik X-Patchwork-Id: 13286635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7617BEB64D8 for ; Wed, 21 Jun 2023 03:53:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230228AbjFUDxJ (ORCPT ); Tue, 20 Jun 2023 23:53:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229913AbjFUDwk (ORCPT ); Tue, 20 Jun 2023 23:52:40 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2079.outbound.protection.outlook.com [40.107.244.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3D5D19C; Tue, 20 Jun 2023 20:52:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kUp+BIPzzfmMaS/U+jzqnDDY12GzXNsIi57BkIr4t+uINDH0UWHfqX8w4rGYAZTyHDFOvG4Ls3UjmNQrhMUwElJlvhnN791YPUPT2MYGwC/0rKmgoUwyWaGnqOGCKXXSkHItyc+xKFJoJjOeVoJHa5hU6t3NiY/nr3c/33qZD7PPDuuC6FndQMtYrpTqJpoENBjTg7ibhXugKo8enO2ClacDXZbJ0ulLeSTYNw09rWgd5afIekoeBYsVlAGckVHQlUoGr1jnKcQqeMvo/GLc95GEo9BusthcQei4GNWwPSIG5pgwtiPrId+nia4QfcCD+VdoTb+T5bEwvVWbZqIFCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=B4W6Bg0HaS2Dows5MPE7yWaN1Bd89L+tiBlnI0Q6rPI=; b=GckO464xn8Rh6DilpKOILeU0Xs6mb9kY+rtLTedex99kN8q7sm7/zFzLa8JAppS4KDcQcIVRniXORk8xSQ0b3BeD7p45eHvOkClDb/fkmfn4VZWal0m0Zu7Y4rfh/dVzwvj9KwBKnLbNAmvjVc2JKyRvMTxTHl4CXGKWzVDN0jz/ZW2Nmvoq/8LghxXJfvb+EHDomtFQOjNeW6jWlbtqKg2qjkCvyph4mUsDo5WvB8Qgtbe+yA1zEyzccMxIEXNFE856qsllM7FJZ+Z7yD1F+EyJ2Bl4Ej0zlBKDGbj93XxWb8Ed0pd5qYAq5R4q0PKXTAQ1f4uJ94IXSP3MVdH9Sw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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 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=B4W6Bg0HaS2Dows5MPE7yWaN1Bd89L+tiBlnI0Q6rPI=; b=QkpDS0mpvbvG4Rw05bFR0G9Sw47qQxlMXUSS0Nkjn4oktpAFqUdMKOgVXGIgqgQfzVk8XQVcdsjxk9BVgLIe0pgwbhFd4ItjDkZ6wjq1A4WSMwJ86UjHpQnfBbqEw1f3wpfm6DaRqrNUxu4xsLgmvD6wMp4lbPKJSF6GflU6XQQ= Received: from CY5PR10CA0021.namprd10.prod.outlook.com (2603:10b6:930:1c::25) by PH8PR12MB6865.namprd12.prod.outlook.com (2603:10b6:510:1c8::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36; Wed, 21 Jun 2023 03:52:34 +0000 Received: from CY4PEPF0000EE33.namprd05.prod.outlook.com (2603:10b6:930:1c:cafe::8a) by CY5PR10CA0021.outlook.office365.com (2603:10b6:930:1c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Wed, 21 Jun 2023 03:52:34 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE33.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Wed, 21 Jun 2023 03:52:34 +0000 Received: from onyx-7400host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 20 Jun 2023 22:52:32 -0500 From: Avadhut Naik To: , , , , CC: , , , Subject: [PATCH v4 4/4] ACPI: APEI: EINJ: Add support for vendor defined error types Date: Wed, 21 Jun 2023 03:51:02 +0000 Message-ID: <20230621035102.13463-5-avadhut.naik@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621035102.13463-1-avadhut.naik@amd.com> References: <20230621035102.13463-1-avadhut.naik@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE33:EE_|PH8PR12MB6865:EE_ X-MS-Office365-Filtering-Correlation-Id: b94abac9-9686-4b8f-777c-08db720af298 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z7wAuJlhex+fQ33TE2ZAUbSWnfUFJ5/4+igp2i2e4teRR4lO2GhpgLTa/XDeiVS+eOhft3V+7/lcl5Se690IVrVBG41JpxsSGp6/VqQwakukbr9OlaFLR3BwpoyUMT0kAolr8rJQhQQAUOn3Dd3wdTU0SF3w/AydKZ6ioNfkXcgNY8d1atVojjmieY8AkGkRpEyQCsNLIAKeRf5vRxp2E3YUbQyWc+Uck0qc253ZeAHdG15NR7rQhdwccVZGamvsgeRKlsQSRzwGQnO73Dp8qTOg2oGiQWbUAISD3fIAxLi9faQby1pibp2fo4Y1MLe/O2EMRMrIIRPLCey++oJaJy9hJJpnI31o80w3INfgsm3SbQZ95m9uqNYnvge5Oia3yExxIrTg6B3vSbWm8RpwGpMBBJzpzrDvz21tSg+xWt0TsA1vLzUMKzdTcW3J65RNdqW76iL/I/ZMOse84iuP/Q1eJgFYQhGkpTr/VU43q+2YPWOTsExb9WE0FbLpqB7AICSdppKhOS4MURGV3QmntLvzSlbx3NuBapxnkrWcoZqQRjnRkcO7qOl5rqTePIjebKECFoQhiBgWxoNyfPjdVTRuRMDMAgKiXsThXGUL4eBBDqlpxlzsh5PxelhVe3Wq1GVHD4w3NR7Ipj+1K+fXj0vIdUNtYoVUr3GLrYAY0jjYh64RDjlldoateBWCbMcJpUzguLLABb7By2m9f7tE7zEI8uxBwoWu2B93PLVcGy0/6puH3P302tML3nu5MyU+UgF0Cq5c1LjT96SihCtBCXd5scO3T6qvGbZ4/40RcSI= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(346002)(136003)(39860400002)(451199021)(46966006)(40470700004)(36840700001)(82310400005)(40480700001)(356005)(81166007)(82740400003)(40460700003)(36756003)(86362001)(16526019)(6666004)(7696005)(186003)(26005)(8936002)(8676002)(5660300002)(44832011)(478600001)(110136005)(54906003)(316002)(4326008)(41300700001)(70586007)(70206006)(2906002)(1076003)(36860700001)(2616005)(336012)(426003)(47076005)(2101003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 03:52:34.7281 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b94abac9-9686-4b8f-777c-08db720af298 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE33.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6865 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Avadhut Naik Vendor-Defined Error types are supported by the platform apart from standard error types if bit 31 is set in the output of GET_ERROR_TYPE Error Injection Action.[1] While the errors themselves and the length of their associated "OEM Defined data structure" might vary between vendors, the physical address of this structure can be computed through vendor_extension and length fields of "SET_ERROR_TYPE_WITH_ADDRESS" and "Vendor Error Type Extension" Structures respectively.[2][3] Currently, however, the einj module only computes the physical address of Vendor Error Type Extension Structure. Neither does it compute the physical address of OEM Defined structure nor does it establish the memory mapping required for injecting Vendor-defined errors. Consequently, userspace tools have to establish the very mapping through /dev/mem, nopat kernel parameter and system calls like mmap/munmap initially before injecting Vendor-defined errors. Circumvent the issue by computing the physical address of OEM Defined data structure and establishing the required mapping with the structure. Create a new file "oem_error", if the system supports Vendor-defined errors, to export this mapping, through debugfs_create_blob(). Userspace tools can then populate their respective OEM Defined structure instances and just write to the file as part of injecting Vendor-defined Errors. [1] ACPI specification 6.5, section 18.6.4 [2] ACPI specification 6.5, Table 18.31 [3] ACPI specification 6.5, Table 18.32 Suggested-by: Yazen Ghannam Signed-off-by: Avadhut Naik Reviewed-by: Alexey Kardashevskiy --- drivers/acpi/apei/einj.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c index ee360fcb1618..0ae2cd325da0 100644 --- a/drivers/acpi/apei/einj.c +++ b/drivers/acpi/apei/einj.c @@ -73,6 +73,7 @@ static u32 notrigger; static u32 vendor_flags; static struct debugfs_blob_wrapper vendor_blob; +static struct debugfs_blob_wrapper vendor_errors; static char vendor_dev[64]; /* @@ -182,6 +183,21 @@ static int einj_timedout(u64 *t) return 0; } +static void get_oem_vendor_struct(u64 paddr, int offset, + struct vendor_error_type_extension *v) +{ + unsigned long vendor_size; + u64 target_pa = paddr + offset + sizeof(struct vendor_error_type_extension); + + vendor_size = v->length - sizeof(struct vendor_error_type_extension); + + if (vendor_size) + vendor_errors.data = acpi_os_map_memory(target_pa, vendor_size); + + if (vendor_errors.data) + vendor_errors.size = vendor_size; +} + static void check_vendor_extension(u64 paddr, struct set_error_type_with_address *v5param) { @@ -194,6 +210,7 @@ static void check_vendor_extension(u64 paddr, v = acpi_os_map_iomem(paddr + offset, sizeof(*v)); if (!v) return; + get_oem_vendor_struct(paddr, offset, v); sbdf = v->pcie_sbdf; sprintf(vendor_dev, "%x:%x:%x.%x vendor_id=%x device_id=%x rev_id=%x\n", sbdf >> 24, (sbdf >> 16) & 0xff, @@ -596,6 +613,7 @@ static struct { u32 mask; const char *str; } const einj_error_type_string[] = { {BIT(15), "CXL.mem Protocol Correctable"}, {BIT(16), "CXL.mem Protocol Uncorrectable non-fatal"}, {BIT(17), "CXL.mem Protocol Uncorrectable fatal"}, + {BIT(31), "Vendor Defined Error Types"}, }; static int available_error_type_show(struct seq_file *m, void *v) @@ -768,6 +786,10 @@ static int __init einj_init(void) einj_debug_dir, &vendor_flags); } + if (vendor_errors.size) + debugfs_create_blob("oem_error", 0200, einj_debug_dir, + &vendor_errors); + pr_info("Error INJection is initialized.\n"); return 0; @@ -793,6 +815,8 @@ static void __exit einj_exit(void) sizeof(struct einj_parameter); acpi_os_unmap_iomem(einj_param, size); + if (vendor_errors.size) + acpi_os_unmap_memory(vendor_errors.data, vendor_errors.size); } einj_exec_ctx_init(&ctx); apei_exec_post_unmap_gars(&ctx);