Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp775553lqh; Thu, 28 Mar 2024 16:41:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWzpxrOUC0ttWu2DJw+0XXeOrjtkJPpKMzBiIvuR4XGXM8PBqGYE4K2O94zO5jyZIdkxZi+kUMTVES77NtdfFS4Mso3C8Yk/gX1HDRuhQ== X-Google-Smtp-Source: AGHT+IENese+X4HSSPjgOYn5MusrdYRcroTKhm/cUDqlELVNKPdRSG+Zuq23DUWeUt67gIPoKndY X-Received: by 2002:a17:906:81d1:b0:a4a:3679:5506 with SMTP id e17-20020a17090681d100b00a4a36795506mr382127ejx.68.1711669294624; Thu, 28 Mar 2024 16:41:34 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z1-20020a170906074100b00a474a4c6081si1104809ejb.173.2024.03.28.16.41.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 16:41:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=eh7wC19G; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-123833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123833-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 264371F2479D for ; Thu, 28 Mar 2024 23:41:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42F3513958C; Thu, 28 Mar 2024 23:41:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b="eh7wC19G" Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2092.outbound.protection.outlook.com [40.107.244.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7054E38FA1; Thu, 28 Mar 2024 23:41:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.92 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711669285; cv=fail; b=ivT93aXg9SO1UXMA4A52xLlnCqs1yOYEdbdr5N5QrShGJrfUIyMlW7X1bT8X1SdVItHgPusz4faYyXv3BZIYS9Cl4RFGWZ2U/+zJ1CKsaqxXCMYcp5whyiDz515eNdUws4icv3a1UvB8uwWycVeY9cAVXcXpSjf1fXTlAyNP1j8= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711669285; c=relaxed/simple; bh=K1EbGR//cNxoepaVsUt2asFYmA562aoc7bpv4D1h5fI=; h=Message-ID:Date:From:Subject:To:Cc:References:In-Reply-To: Content-Type:MIME-Version; b=Pr8kSbG8cpAZxEV99PyEOwXjZODUXWRA4gI2GWFClLxs33HIA1bKMWgft9Od5RAChrhjPasbRDSbQrCbjPVVep7ly+FFNgEYsVpVdfAhe5Mho8+LiMWra9H4kCVPXdzZ5c33DvWwvSbfl03uxlN3/gYnq91hlOou7+YAn3ZmkR8= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com; spf=pass smtp.mailfrom=os.amperecomputing.com; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b=eh7wC19G; arc=fail smtp.client-ip=40.107.244.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=os.amperecomputing.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OLlYYa4IgswAHo/W6RKf4nvc9OC4Zndg2oWfTKOhQQM5Uw+HrDrNe/oEoqEMTSTrxG9ONyCVKbfQ1AwQ+R/qxylF2ERuue2OrWjO6wlUdtmclfyVuIz2etGf0C6AsUf2O/+8pG2ErQjGxtrceGX0d9KFKjiCP7zeHqQatfBG1JPKJHv/plEZsbTw3+XIVM/g1aQmLwE7fDCPu2LSQFGTrSv69WkiyO2uuf7ksNtAsFjOZJ3k7Q4azhoZbBl8ZeKGXkoC+Ds5AWFPDRuxqtEVA1P5VOsl+11Vls5wS0jo+7w1hZPTJokQMcxWWHvBna3zMg4a9JmaBusmJv+sivp7lA== 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=XJx/YV0TFwouXt8PvLCFfp7+wDAcQhhbNpHx+MrnQzU=; b=dACxjbmp7mWBgEQYfSo8kNZqk+RNjprHqM8PL75aNhpjezYcwp+dbBW6b0kQQvqIW78oavNApHUNjWJbY9fR3sRLHMHiCdJz8YpZIwA48I++nPo6p0PdUjrVQZcyy0qzqiCJ08V9slU01aY8r0VESGA7P/BO5+CFAtaneG26WTQxtMjgdUZ1tXF8Amr4gxLVyeBOp/taEJxNwnm3KB3Yr9LjY1xbjBibkCsdUXCk0owzSF1ypnxhzb7nn6AMGXuRUk97kD+S04AvotUZOZz8SwsF5j+E11tzusIpM2I433kaQdGfCH030+WUPCGxeYL5BXOboqVp1S6x4cn/yiVyyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XJx/YV0TFwouXt8PvLCFfp7+wDAcQhhbNpHx+MrnQzU=; b=eh7wC19GpSgHDW+SCNb6hoM5KZn84YLMeO+L1mzjcs7NxAbLApgs4SzugqWxlz/7MFr1XURM/R7vY5KFpK+OOySicZmUjfWH1R8m4usy09EGw1cW3WqNMxd6ug47VhYY7t7bkQ/8UsOW0g/QGUvtB8StX4CSrzCFaLBxlT6HEu4= Received: from CO1PR01MB7370.prod.exchangelabs.com (2603:10b6:303:159::16) by SA1PR01MB8180.prod.exchangelabs.com (2603:10b6:806:339::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.33; Thu, 28 Mar 2024 23:41:21 +0000 Received: from CO1PR01MB7370.prod.exchangelabs.com ([fe80::994c:4200:8a4b:6882]) by CO1PR01MB7370.prod.exchangelabs.com ([fe80::994c:4200:8a4b:6882%6]) with mapi id 15.20.7409.031; Thu, 28 Mar 2024 23:41:21 +0000 Message-ID: <0d398f19-b8df-4936-97e0-fba8eb041d88@os.amperecomputing.com> Date: Thu, 28 Mar 2024 16:41:17 -0700 User-Agent: Mozilla Thunderbird From: Daniel Ferguson Subject: Re: [RFC PATCH v7 11/12] ACPI:RAS2: Add driver for ACPI RAS2 feature table (RAS2) To: shiju.jose@huawei.com, linux-cxl@vger.kernel.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org, dan.j.williams@intel.com, dave@stgolabs.net, jonathan.cameron@huawei.com, dave.jiang@intel.com, alison.schofield@intel.com, vishal.l.verma@intel.com, ira.weiny@intel.com Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, david@redhat.com, Vilas.Sridharan@amd.com, leo.duran@amd.com, Yazen.Ghannam@amd.com, rientjes@google.com, jiaqiyan@google.com, tony.luck@intel.com, Jon.Grimm@amd.com, dave.hansen@linux.intel.com, rafael@kernel.org, lenb@kernel.org, naoya.horiguchi@nec.com, james.morse@arm.com, jthoughton@google.com, somasundaram.a@hpe.com, erdemaktas@google.com, pgonda@google.com, duenwen@google.com, mike.malvestuto@intel.com, gthelen@google.com, wschwartz@amperecomputing.com, dferguson@amperecomputing.com, tanxiaofei@huawei.com, prime.zeng@hisilicon.com, kangkang.shen@futurewei.com, wanghuiqiang@huawei.com, linuxarm@huawei.com, wbs@os.amperecomputing.com References: <20240223143723.1574-1-shiju.jose@huawei.com> <20240223143723.1574-12-shiju.jose@huawei.com> Content-Language: en-US In-Reply-To: <20240223143723.1574-12-shiju.jose@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: CH0PR03CA0195.namprd03.prod.outlook.com (2603:10b6:610:e4::20) To CO1PR01MB7370.prod.exchangelabs.com (2603:10b6:303:159::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR01MB7370:EE_|SA1PR01MB8180:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EaLGzZY7xB8EHyRyUgAuQJSuow52527ozdgFC9g0OnTW8SKdYcdcATqE8Pv35GVZQ73xTkhyP8LpDmAui4DqsRaDd12eWMEWvSrDL18zATUjouSgY5IqxkrJQ7E0bet8V9mYsaFujlX9H+J3R7JJlTrHJ5I1iUieGP5uXzZv/9SMpF2h5C51XN0xZDHtP/GKIZXWx+3CqBraOp+RyAGbB24X+OEDFHBZnAKz2FUWuR+Yg4bnVz2Qb9HjA/IpZ1ja8nfJrc8GW7EQwHc74ir4SbFDyPs7sSIeSQZCTe7R5Ehk5twhtv2IaPuhaKyc/WhOrXHwW6ycPlKRAwS22l9CUWKzFK8eMsJFf1qIoeh/lX9xGqbym85o3FpZEVAIfxCLnKeAM5vU1mDGIpaVAx6VATg73b4lhb5zheMRgdVtiKl+CZ5HGvdp0VGtKr49801kJTb+L/o/xQYjaOo/99ZoQ80SXwe1jfIwOwXOTcHf7J/v4ki3YnNMNXsMOVd4/Yi/yKkWMLl0koRjnhI0+NAJ3wlIt0yzhOjaW8LTYU7EtlcgFw0I9VGMR6ycsy52VM9V1Xkg64iPgQwmdcfZRmaHKNhdQG7jesFwWrXP+13BZkFfYYVSq9fP28lWjGKNaPIDXbCgKS+3JoyldjBOZK27gWpkrFdiEKIHJn4AHJKlZJXF6kcFHkMX/Ilw3kPwY7NKNoQWs8gRDB+t/bYe7J/EtVAh58jqidye/RZ8mT5omYM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR01MB7370.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(7416005)(366007)(376005)(52116005)(921011)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RmZXbWp6SEZaTUloczVUbFk2QTVYZmc5Si9yMWcya1J1Y0ljQ0krY09iUDJH?= =?utf-8?B?ciswc0hZK1V0eHpyTjBKVnExWjI5WnlkT3h4T2t3M0Y4eXJoV3llTmljaU5C?= =?utf-8?B?T2lYNWdIS3puSm5QbnRHTFgwRnVEQ0E4Y0sraHMx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cVI5WHVxUWdhN2xESlIzZTBpQ29sRklMVlBHUHlENGpNQW5qaHoxWjh3?= =?utf-8?B?WjlRdENKS3RaNjd3VHNscHFDbGVmUGhDaXBlWFRKWGZmMDd0T3JvVHBwQUtR?= =?utf-8?B?bzRJdWJxZC9VYVF6N3FwN3NPMXdNRllJS0dybm9xUE9NUmw0TzV4ZmNXeHJT?= =?utf-8?B?M1lUdlB5b2hCdU4rSzFGbk1lOTczS0JRVTkrS3lWaG9kdldudWZDRTVmOU1E?= =?utf-8?Q?SKHFAVRB9PwXQgBx7KaAV7Y=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc8870d1-fdb7-48b4-05c9-08dc4f809286 X-MS-Exchange-CrossTenant-AuthSource: CO1PR01MB7370.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2024 23:41:21.3307 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Bs6aT1qO1aA2smAkxHbD/Brb+wOXHYzhcfwd3/nSWNmwBJqwp25a+usPaXY52R8dOJZ1hOr74SeQh4sCaLQmGT9t3G71p9J80GsAOZqQFtr3cb7AslMRIu8pNxkVp2VQ X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR01MB8180 > +static int __init ras2_acpi_init(void) > +{ > + u8 count; > + acpi_status status; > + acpi_size ras2_size; > + int pcc_subspace_idx; > + struct platform_device *pdev; > + struct acpi_table_ras2 *pRas2Table; > + struct acpi_ras2_pcc_desc *pcc_desc_list; > + struct platform_device **pdev_list = NULL; > + struct acpi_table_header *pAcpiTable = NULL; > + > + status = acpi_get_table("RAS2", 0, &pAcpiTable); > + if (ACPI_FAILURE(status) || !pAcpiTable) { > + pr_err("ACPI RAS2 driver failed to initialize, get table failed\n"); > + return RAS2_FAILURE; > + } > + > + ras2_size = pAcpiTable->length; > + if (ras2_size < sizeof(struct acpi_table_ras2)) { > + pr_err("ACPI RAS2 table present but broken (too short #1)\n"); > + goto free_ras2_table; > + } > + > + pRas2Table = (struct acpi_table_ras2 *)pAcpiTable; > + > + if (pRas2Table->num_pcc_descs <= 0) { > + pr_err("ACPI RAS2 table does not contain PCC descriptors\n"); > + goto free_ras2_table; > + } > + > + pdev_list = kzalloc((pRas2Table->num_pcc_descs * sizeof(struct platform_device *)), > + GFP_KERNEL); > + if (!pdev_list) > + goto free_ras2_table; > + > + pcc_desc_list = (struct acpi_ras2_pcc_desc *) > + ((void *)pRas2Table + sizeof(struct acpi_table_ras2)); > + count = 0; > + while (count < pRas2Table->num_pcc_descs) { > + if (pcc_desc_list->feature_type == RAS2_FEATURE_TYPE_MEMORY) { > + pcc_subspace_idx = pcc_desc_list->channel_id; > + /* Add the platform device and bind ras2 memory driver */ > + pdev = ras2_add_platform_device("ras2", &pcc_subspace_idx, > + sizeof(pcc_subspace_idx)); > + if (!pdev) > + goto free_ras2_pdev; > + pdev_list[count] = pdev; > + } > + count++; > + pcc_desc_list = pcc_desc_list + sizeof(struct acpi_ras2_pcc_desc); This line needs to be: pcc_desc_list = pcc_desc_list + 1 because pcc_desc_list is a type larger than a byte. This bug will crash the module when num_pcc_descs is greater than 1 > + } > + > + acpi_put_table(pAcpiTable); > + return RAS2_SUCCESS; > + > +free_ras2_pdev: > + count = 0; > + while (count < pRas2Table->num_pcc_descs) { > + if (pcc_desc_list->feature_type == > + RAS2_FEATURE_TYPE_MEMORY) > + platform_device_put(pdev_list[count++]); > + } > + kfree(pdev_list); > + > +free_ras2_table: > + acpi_put_table(pAcpiTable); > + return RAS2_FAILURE; > +}