From patchwork Mon Jun 12 21:51:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avadhut Naik X-Patchwork-Id: 13277611 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 52572C7EE2E for ; Mon, 12 Jun 2023 21:52:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236259AbjFLVwO (ORCPT ); Mon, 12 Jun 2023 17:52:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238089AbjFLVwH (ORCPT ); Mon, 12 Jun 2023 17:52:07 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFCF110F3; Mon, 12 Jun 2023 14:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KZtu1bpB1RWqhGX+sYQVSHhNDWDpE99ByaaGgPBatIvFm7gUIdMMnzY3a7nn8J1TgQf9F9eAj7/kbU4Z9d/XF50gdlg53mRnBY0/LN5Mj4yM5CbwYIT+qc6Bx6Z+dwxS30vdcRFj3fKMRBEKcfdPXQplizPP4iKtk7wNGN1Jmm2Kr4I2C1mGGt0mgbigsC6ptsAeHVW6dIHRPTx1crA5pPOUytPYD2vcAyiH1pi5CrQ6jsihCyHi+VsiDBSbdq00F0w9tgDp+Lc3pGuPAddUqKNr2YOLMPrjB6LS2XVf7BMRnQ6scAiUWmSI+IALPFD8vsJZCIMYhrsmktfcXW+Avw== 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=JCQmKw5MbrFFiqbnJKW9xzYzac3xAvBPmjQ+XzJ3zAI=; b=VkM5dcLSgxzT5mDGymQt/V5CaTq6ESZo3GEP9TjHlnkkvGFgU/W3L7b3lsqGUPufp4P4wwm7p29otkXum+a82AS+JQzXc7p+AiUH9ZMmipMEOUHFn77rLee7Cey+UxvRaVT3GPufwdEFya2j8p4O8iyiopP3siefcuAvHIaNKlLu3LB7yGJFvm1Cpca4ywblOozPjHLkwmtQM2NqfeMS9ppEqT5V+grlN6BoF10B43tIq7Ajm3DEzB8poD2+krRjAk2nu0GjfFC56r9ABL1VJi7rewm+u3rx7lxMWCCdIwmsZy4uEcom4MOX4rMn1HPU5IDRxKWLf7tsmUQx7hR7dQ== 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=JCQmKw5MbrFFiqbnJKW9xzYzac3xAvBPmjQ+XzJ3zAI=; b=vHbBgKqSuj2CAEjF28xHGrmQnbcg506ZvveHIcelGl3a1gegLvO7zRoML+cuvjZn6qXdNwQTYdQksHZnBKd2g07LvHwvizWMdieSjZmh9YB7ojHeMZ81/ib0a6WsewomG4wDcHkJQnK5Vg2B4ejqdj2of5LK6mbawF5vMydSRdg= Received: from MW4PR03CA0255.namprd03.prod.outlook.com (2603:10b6:303:b4::20) by CH3PR12MB7618.namprd12.prod.outlook.com (2603:10b6:610:14c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.29; Mon, 12 Jun 2023 21:52:00 +0000 Received: from CO1PEPF000044FB.namprd21.prod.outlook.com (2603:10b6:303:b4:cafe::d) by MW4PR03CA0255.outlook.office365.com (2603:10b6:303:b4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.34 via Frontend Transport; Mon, 12 Jun 2023 21:51:59 +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 CO1PEPF000044FB.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.4 via Frontend Transport; Mon, 12 Jun 2023 21:51:59 +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; Mon, 12 Jun 2023 16:51:58 -0500 From: Avadhut Naik To: , , , , CC: , , , Subject: [RFC PATCH v3 1/3] ACPI: APEI: EINJ: Refactor available_error_type_show() Date: Mon, 12 Jun 2023 21:51:37 +0000 Message-ID: <20230612215139.5132-2-Avadhut.Naik@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230612215139.5132-1-Avadhut.Naik@amd.com> References: <20230612215139.5132-1-Avadhut.Naik@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FB:EE_|CH3PR12MB7618:EE_ X-MS-Office365-Filtering-Correlation-Id: 69e42f8c-4432-4e56-0848-08db6b8f3fca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /tR7fAjku33pMYBhzEu/+vODoh2FFBJE1c3aJJxwv85dF3US73fUbFOTZK6r5Sg4/gkFHQ5xC2vq/9xC0mxPKnA2YgcXchxygX6MCLdZTBvVmae7/0BHb4qg4isJnEfNoO9SD4jMQvIGUErta2kVWsnfRxlaS4tK/yR0A5+XKEKolvPWuPu/W5qWhaXHWYKhyr0h/6z5xQuBOYfsvABK8qrfLgWdLQr97Jh6XDfJEt/3f7++blnNx1G4jmPd8TtAJM3gaL/YXBqy4n3G/iIpGqdIip4ASCyRj13NZq4oFGg2wgbLtXq9xvZQcflTxxR/dQFOmxlXA+Z/aSQeKnCnVkoCHPnHgMa//EbdNhEvIhbWj/4I9JC/Jx+E5DGvnmW1VpY4qr//96oRYTjvDAzOqNUE1tw5m4lqwrU995MEJIQnAxW3Jad//THE6AtCYPhCbzThnzFSGUacb1mM1zdJsiPR0ZaCIhyCfBjtx7r3F90XnBJB9uCvmoLhBGwKQYJdRnSvQmySnqTdDgqSgcixpPjvMA5wLN0tNvYrnvi4VpvhD3f5RCHesshMogQOuGiPFw2idTEc2O9392MQJZONJK1lIuIv3Kvw5reSQzKpjo9MHgpQqpX1T1TN3sIb8cd9UmAXw2GmfRwfGkEyhCDcNmZPVBryG8wlThZahrWybp4OGAVpWvlB+apqG0rp1I5HMsDroYq95wzRzwrLPkvrU0Ox1LCNLxJ+CtbQbEVt4Xt6ZQDRN8E/R2lnrLoV4CqqdeCsxi2I0CbRoqdEFHvaOSUBU7S2P/1BM+rpG1Jjrp0= 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)(346002)(396003)(136003)(39860400002)(451199021)(40470700004)(36840700001)(46966006)(40460700003)(6666004)(70206006)(70586007)(316002)(110136005)(4326008)(54906003)(478600001)(86362001)(36756003)(47076005)(36860700001)(1076003)(26005)(336012)(426003)(83380400001)(16526019)(186003)(5660300002)(8936002)(82310400005)(40480700001)(8676002)(2906002)(7696005)(356005)(41300700001)(2616005)(81166007)(82740400003)(36900700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 21:51:59.6351 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69e42f8c-4432-4e56-0848-08db6b8f3fca 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: CO1PEPF000044FB.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7618 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 Mon Jun 12 21:51:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avadhut Naik X-Patchwork-Id: 13277612 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 8BD1BC7EE2E for ; Mon, 12 Jun 2023 21:52:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238200AbjFLVwd (ORCPT ); Mon, 12 Jun 2023 17:52:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238197AbjFLVw0 (ORCPT ); Mon, 12 Jun 2023 17:52:26 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2056.outbound.protection.outlook.com [40.107.237.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B53E110CC; Mon, 12 Jun 2023 14:52:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z1D4RSjFtkStWamAnnprgTm+J53pSP1AhSOZwOmRxqePpDTJCGNE1Rci55E5IlDzaCtvNKhqF1sqcflSjG5KwoJukWIOjRvLXw9dw5yCRg4qTOmSquGkJVP6ZHX+e+2D+TnjPkmW61cps7QcYJfYnsffyY1eLFdz0GTFOidugf1/g4v0JTAqc7Vs0/5NM1eGdPxXe1C3VHPT7y4qgvGCusvWCVN1mo2ukWcqkPqnci1tJCpPO/tJ/vVlptlhhZ+IThlbaTKzgG3LjzZzc7cVMXzArzSnp/Z70ehWixDG1O8JoCE2ZXa8Hf5fm9ZmGpTXG2OeNu9VtFCnPT/shCejrg== 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=fhzr12iAfX7o0oegtTi3+RnBb0S6bBGxFqh0obObEdY=; b=ObyHkUzzipXHhoFhvagHxdwE2eRAmYbXzmBj75gnDIaQgl5lbwbnPWzOKqr6bB9zgFKgJpbEHqtJZDP2QUURzEB3+NpLi2Ua47Dqai/AsIyQOYe3tE28EBYVp0PSFsivVIYB0sPekM9+bTE+vyeYoK94uETK+Du/uuQDg98RCvrahRHs8z4z0U5yOo21B48Qo8CLCEp+ZxZ+QVeiBSUpaOqFe80ACReuAheyYkxsGmu0U7QmmpMGcgPnXS7/SfRITPDcWVYearQszxQlPuiX2J1A5Iu9Ax/RVf3z0qk8ILwXMmmcD6wRTjF/umNtJsVubZNvdEwLx769c/6+3drbig== 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=fhzr12iAfX7o0oegtTi3+RnBb0S6bBGxFqh0obObEdY=; b=NSl64GcRwzM0lvamefWVOIrvUQ4CXsjqmsNwPs8MBoxPyxKD8Ox50WI+sjWkVxo/fgRJkffRgPozn/GgwuZy5xhOBfpjgsmR3v/hO376SCZShJYwrfh0BTDfI/KhavhPL7iykeOI8chi7n6kBCInpx4kEVnOUox8E8d+Ereb3ik= Received: from MW4PR03CA0052.namprd03.prod.outlook.com (2603:10b6:303:8e::27) by DM6PR12MB5005.namprd12.prod.outlook.com (2603:10b6:5:1be::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.39; Mon, 12 Jun 2023 21:52:12 +0000 Received: from CO1PEPF000044F9.namprd21.prod.outlook.com (2603:10b6:303:8e:cafe::b0) by MW4PR03CA0052.outlook.office365.com (2603:10b6:303:8e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.34 via Frontend Transport; Mon, 12 Jun 2023 21:52:11 +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 CO1PEPF000044F9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.0 via Frontend Transport; Mon, 12 Jun 2023 21:52:11 +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; Mon, 12 Jun 2023 16:52:10 -0500 From: Avadhut Naik To: , , , , CC: , , , Subject: [RFC PATCH v3 2/3] fs: debugfs: Add write functionality to debugfs blobs Date: Mon, 12 Jun 2023 21:51:38 +0000 Message-ID: <20230612215139.5132-3-Avadhut.Naik@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230612215139.5132-1-Avadhut.Naik@amd.com> References: <20230612215139.5132-1-Avadhut.Naik@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F9:EE_|DM6PR12MB5005:EE_ X-MS-Office365-Filtering-Correlation-Id: ad76d6f4-4d5c-47a7-8dad-08db6b8f46de X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XEviCnkQr1SzK9mEimgRVtMsAGBCet7a5O/7/ocPfCvORV8G2yuiOhmkhGNDgwuxyFZgU6XmFdBqCoD+DuFTgelV3UuRuHtIRU51WIfcmtQF4o5Waii0Ac1KReiixZ0b75tyzV0vtdiNjS+msK5ie+kDJO4o2ow58UUiJSAa8/lB/Ro4EdkeqT7Q92LQUY+xuLc7wLkJALp2WJ9tDP6sNZX2Q5qYz2H5xs9UU1tc5Yi3sXhV0HmQ+qPdamZrbf/RlN6yepeIVVSmRndnO/1KD2xf6GvuOokgyviaH1yG4qICp161ukcWWro8uVKaAyd2wyQxaZVnc93Ej4T/d/a9CYew5av3v2Hz1Iy5RcUJK6AciAthVn0Pd9rsPgpkpsE/vRen3iI6+krGwl6RETiWOe2aJ+r+RskQpY7VdQpv4k63K5horv2TQSl/MWQlxSZ5HgMARsiuA4ka6t94VO53pzrseGKF7GkZ6kmXk7MdraOqXlkT4Zf3bwY7+GRYr1pOrtCe5l77Uh2f1RPp5l3DRfLYubfvjPnO1HtYK9m+79I42/32P30HRs/hN5DXxsER7b0YDtHNmF0BG8eq//1b6ynmk7xMtZS1eJVA0fENXJhyTESZbh2cdCIcSEGaH86Y73Z5hp6qmjvdk6Lp7jis6HbqGcXqI4jBouDziM33F/h7WK/FuUyYPk21yQPgHGFa35OA87LXkT0yt1bXCJ7cEO1qGdrhS/l35/dEz71QDnDXX6ND7dGbQtALIuSnXLhlNxPxUQhdTkCqhJ5RsbJqfzZ7A73NTRrz3zQ8wZS8/1w= 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)(39860400002)(346002)(136003)(376002)(396003)(451199021)(40470700004)(36840700001)(46966006)(70586007)(70206006)(8676002)(8936002)(36756003)(5660300002)(4326008)(478600001)(110136005)(54906003)(6666004)(41300700001)(40460700003)(7696005)(316002)(40480700001)(81166007)(356005)(82740400003)(86362001)(16526019)(26005)(47076005)(186003)(1076003)(2616005)(36860700001)(426003)(336012)(2906002)(82310400005)(83380400001)(2101003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 21:52:11.5136 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad76d6f4-4d5c-47a7-8dad-08db6b8f46de 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: CO1PEPF000044F9.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB5005 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 --- 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 Mon Jun 12 21:51:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avadhut Naik X-Patchwork-Id: 13277613 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 12D6DC88CB2 for ; Mon, 12 Jun 2023 21:52:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238463AbjFLVwz (ORCPT ); Mon, 12 Jun 2023 17:52:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238203AbjFLVwe (ORCPT ); Mon, 12 Jun 2023 17:52:34 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2076.outbound.protection.outlook.com [40.107.220.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A036CE53; Mon, 12 Jun 2023 14:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pq666t3W0mekr4844OS/1m1nx2nHg7cauqhU3BJqDE/yPbRoMZfffOrZ+YWeFw2b5K8q8EF66kYMgyXEuJCcs/CoGHXA+oTX7Na0K6ouuiI06CzPBAO1MWc3VrXoIe+KP+kfLVViuyPdly8BJBZYrwHqPQwMkxu4+oT4d+vh+TR4odgfytRxPtygma85twc5ctF0z8BYxeWsON7b6NOGjeRb05XL8ecl1boIjJMExMTR2jsr9YGL5ZHK3JaAI+x5N6IE5ewRwAtcARXHJHZgdGHTWtKhGzk1jlZNFxn6ZQKr+NOGlDx7h70r28lxqQBOJnZF+rADfzIzDv1akim4ng== 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=drjmXGR0uevHsHUEc4WrNSZN9mgeD1hvbACzX4EAKls=; b=JV2rPRTBiAfIAOjwlCGAhoNv53s64qJSo/NzxtP90ot4Zv2c5r5d1k6oFWAih4icdtY4QqAcv+mUMqvvDQQFqEGnseOJMbjQjldqW1oarEBdMIJzD8ZjC7cdhkG9Yy2BDorx42tXvoYa2R1TjkoG2CLDduT88K5LWlDfvXG4WLcv0DrtG82hbNPgPJtCgVnxeK94fMq+ZZtT3hTICWXPT+hQzFb7mNW+7QInjVLmq1VEO1FWluxalS4EmS53M703kf8V8f3HkwC+5okDv6/vkp/p9bdyU7vy+9/9SezPHfM6lqElwH1XclK7SzWzX9K/AmCHqnidco3+rK08t1fRJA== 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=drjmXGR0uevHsHUEc4WrNSZN9mgeD1hvbACzX4EAKls=; b=Q6LSNukugQ0HuDZ92mO1w2BSZwC9cG+mwEksd1EfrYh9tEtHGfG3kNhVoIv513aFb1yNbddLZSTSYbFFzMkfaNcPvdqf6cnQ2WJrkh+GrxwWJ/HYo0T24YAiQ5Vxvvnq0B/4CJQuoDW9Vdyd0fOMF0m2KDrXYRmuB96N0MRr74Y= Received: from MW4PR04CA0121.namprd04.prod.outlook.com (2603:10b6:303:84::6) by DS7PR12MB8369.namprd12.prod.outlook.com (2603:10b6:8:eb::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Mon, 12 Jun 2023 21:52:23 +0000 Received: from CO1PEPF000044FC.namprd21.prod.outlook.com (2603:10b6:303:84:cafe::58) by MW4PR04CA0121.outlook.office365.com (2603:10b6:303:84::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.34 via Frontend Transport; Mon, 12 Jun 2023 21:52:23 +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 CO1PEPF000044FC.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.4 via Frontend Transport; Mon, 12 Jun 2023 21:52:23 +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; Mon, 12 Jun 2023 16:52:22 -0500 From: Avadhut Naik To: , , , , CC: , , , Subject: [RFC PATCH v3 3/3] ACPI: APEI: EINJ: Add support for vendor defined error types Date: Mon, 12 Jun 2023 21:51:39 +0000 Message-ID: <20230612215139.5132-4-Avadhut.Naik@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230612215139.5132-1-Avadhut.Naik@amd.com> References: <20230612215139.5132-1-Avadhut.Naik@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FC:EE_|DS7PR12MB8369:EE_ X-MS-Office365-Filtering-Correlation-Id: 2717fff1-0d60-4514-270f-08db6b8f4e0c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2z+EVIh2EXfQicGlr76exHm6KjYYqjY5MmETUJypFJCteScXDxmkEw+odnB/5E+fD9XGw8Q5S2tUprHpD7Ad0/eXzlzy1BcreL9fDX5XgrK8WB+FYWQ3Gf3ZjBz9BETlZVwGvT7CIFWIhLCvLTTF+yyu9ybiaZA05yEvVFzL0cmf0JH6F+syAdPYBNGJVuzvuxW4J5ORvE8nEwb1r50TdqaXL1K4It6PtktkSG/tmdThobZpWqdW+GKDj/2tVv7o5QLP4LTzk8IZCV7NTPOb9Ya9CVNT/yXA0fZYIoNt6qd5fL4rAXsYKBGSmlNmb/AUDi3x48OImYsRdPXFJfXyMYlih2GViK6xA3DIy8rrIs2Ghw3b8pf/2WqY2bzai+AxsH6FFyO9HRGyxuvcSnFvnPaRRijk+VWfGRmrmQGD0gdc1Etl5phla+PcRqtM8a7zNs3cgwUE+qGGCdd3BDtumo+8Ol5w6KT2x4hME3GIbmDDfO829O/sIL8YrWXWq1QKM+jGy9RfCm8C+jLNECrrCQImj7OBTSpdEPozpZMxY/jg3eAdKGxQ6EiGWbXAgonHnMNyhAG5TsJsk7xsxPMiJ1yBaPLDKPRftfcOCq/oiFmROgiXLkPNek3cN3OhnaUFMGb31LmNP7uL7GXEFXLsByQORj+qe5C0izsIjzm30PGwX3RyQ0KNQAGbF/39Lrt9WLOq75KG7TPZyK2Rq3GSNpq8qRQ+6zstKoYj8XUAEB0Nx9qv+FOhmTMSYaEgckHtyUfA3cACCFvQ1qkAPQ8yEr/gMss5ZvI+tLstpi99vJA= 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)(396003)(346002)(136003)(376002)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(47076005)(336012)(82740400003)(426003)(40480700001)(110136005)(478600001)(8936002)(8676002)(356005)(4326008)(86362001)(70206006)(70586007)(81166007)(5660300002)(41300700001)(316002)(36756003)(7696005)(6666004)(82310400005)(36860700001)(54906003)(2906002)(40460700003)(16526019)(26005)(186003)(1076003)(2616005)(2101003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 21:52:23.5409 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2717fff1-0d60-4514-270f-08db6b8f4e0c 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: CO1PEPF000044FC.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8369 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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..292dd252cf65 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_iomem(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_iomem(vendor_errors.data, vendor_errors.size); } einj_exec_ctx_init(&ctx); apei_exec_post_unmap_gars(&ctx);