Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1300011pxp; Thu, 10 Mar 2022 02:48:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwM0n+mHuS6Ex6rU5PIcyeSvZSscfHmM4Xbf/t0tBVgChcciRUEUfHM1LM6wsgMNCyhtM7N X-Received: by 2002:a17:907:1612:b0:6d9:b302:4756 with SMTP id hb18-20020a170907161200b006d9b3024756mr3702905ejc.26.1646909316618; Thu, 10 Mar 2022 02:48:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1646909316; cv=pass; d=google.com; s=arc-20160816; b=njt+SVJOlWcVh4L1jxDfh94FoosBV7282nzNAF8TqHw+Cmdo3b2c4mGwlMwTGi63u0 lHRzJjyBfqkN/8XcJFrZaVwxHZaTf0y5NipflG/9522K+OaSBAF2v7M4bCRjTNRxJN4a NLaUmf0cYuDSdXZeFICsgcwg1u9rPCUuC85EgjvlzI8qdV+vzI8PHJ+jzEdtjlUGUs0a rBDItWc4TqXU+OeymWCsSpHu5QHROhLmvCDF8gL3XSh9xmHgV/2hk6DvQipyErvoFJme 72rucmhK8QiC59SgBYSSfGJn2bZU5W1iY+AmiDROcIQTpl1YWW3pBr2fWUbce7310Q7L 72MQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:organization:from:references:cc:to:content-language :subject:user-agent:date:message-id:dkim-signature; bh=bvAkx6adJwjc83B76Xs11rZYey2Gl6pRvNp8OS4Sh6w=; b=WT7xpQFTmeJADddbZbRItrmN7df86XBmXKNOcSGXkn5lpgng5OogZC6CMx+ScWA94F BdRAwKgxaf07vso3vzgUfwynuXGD33c8OFN0ZrKQSNgmqtg1S39k6nGijVlccsVA2GWL xUmstrKk4uWgJxrKGcn2BeeHAQLaqEukHhdfU0JnDqqbGQs8yP8jQmtHEnYLQRiDvJNX N70A9y/rGKYf1fIpCglRYScZVNcM2SKoczwXPqlrVss1u6L7VBFV0NHF6HHoFkbJbe3A PlhiyC1HUTHPWt/YrQaI/PTY3vO2GCOSCzVSKXPzXgZSPpzMR1hUS/xUblUYZczNg5vL /63A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@axentia.se header.s=selector2 header.b=GV3sSV8i; arc=pass (i=1 spf=pass spfdomain=axentia.se dkim=pass dkdomain=axentia.se dmarc=pass fromdomain=axentia.se); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kz9-20020a17090777c900b006cfd1959b85si2760650ejc.363.2022.03.10.02.48.12; Thu, 10 Mar 2022 02:48:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@axentia.se header.s=selector2 header.b=GV3sSV8i; arc=pass (i=1 spf=pass spfdomain=axentia.se dkim=pass dkdomain=axentia.se dmarc=pass fromdomain=axentia.se); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238497AbiCJKAF (ORCPT + 99 others); Thu, 10 Mar 2022 05:00:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbiCJKAE (ORCPT ); Thu, 10 Mar 2022 05:00:04 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2124.outbound.protection.outlook.com [40.107.20.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A539210874A for ; Thu, 10 Mar 2022 01:59:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IF6f4MkcpQufPXx/vr6GtT8XipuIxElx9X+UWuYtkzHQFmhNpfpWt6dLp+gNiq1jQ1FU1C2b0+rbix0vz+91AKU/6BtrVrhWkaLakUCYdfjLtjvmnFY7VvISl8u8DqM/VfQS3ieTeDlVxVxM4x7T6GdqRAKpJdkKMfaqVhGmBvbYCPpVXmK7mXD+QVJJohJTp8a6q414jMSbCklPVZxEiZZtVE13cT2SHC2sO+kxG+FIH29polJwRejsq/QEQdwefGia2L1j7NMDV8F+YogTsRhgrQd1IQK3tBWxJfgSdGW98EM7zAr8BcVryVcgkpLMTIOAJGSZU0QSxVL/gRNCdg== 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=bvAkx6adJwjc83B76Xs11rZYey2Gl6pRvNp8OS4Sh6w=; b=SDHfKb96yaTXZp4Uc2oTBc9g7MaeeCjNmTLssS11Jfp0qtkltQe5bSlt0+xJruSda6QNaeN04+xmj0uTrLyamNNJ054/6W/EjGVfljZWUDpnoKeMg+22/158xiZ1mNtZ/Wx88prCJshTeJxS6bEGGy8l3pQd/EuQ+ACYK/tk5pSRyOJt55g1suFrd9bSKCkeKmrO1WzxtmgbKfQyjwx6o5CscChVl5iRKa8t+6AGYEzJKW2tF4u1PeIam2eNPg9W3RELTAddqubBwgg6cP1vMdVWfrZqgvliedGCdaCHTbFcQM6cxaPnyiTRzziXVBsXjQ7qjpgXKou5Mz+L+dPlRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=axentia.se; dmarc=pass action=none header.from=axentia.se; dkim=pass header.d=axentia.se; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentia.se; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bvAkx6adJwjc83B76Xs11rZYey2Gl6pRvNp8OS4Sh6w=; b=GV3sSV8iYf7Ra2K2dc1LHrq+nO1PlBxVu3W7bs8aGBa3Z5PeZbqTxzWd6TpX05XZlfR8lEiKV8duKyga2It9FbLwooof4VtEEXcPJw/zdEv+z2M1uGLyODNx06jkBenjKVmVmpjz599KVPTsTxb0zJwqxVFzJWj0e63/orf/arM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=axentia.se; Received: from AM0PR02MB4436.eurprd02.prod.outlook.com (2603:10a6:208:ed::15) by AM4PR0202MB2852.eurprd02.prod.outlook.com (2603:10a6:200:8e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.22; Thu, 10 Mar 2022 09:59:00 +0000 Received: from AM0PR02MB4436.eurprd02.prod.outlook.com ([fe80::7d29:dd84:d2bf:a1a0]) by AM0PR02MB4436.eurprd02.prod.outlook.com ([fe80::7d29:dd84:d2bf:a1a0%4]) with mapi id 15.20.5038.027; Thu, 10 Mar 2022 09:59:00 +0000 Message-ID: <220ddbef-5592-47b7-5150-4291f9532c6d@axentia.se> Date: Thu, 10 Mar 2022 10:58:56 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: Regression: memory corruption on Atmel SAMA5D31 Content-Language: en-US To: Nicolas Ferre , Tudor.Ambarus@microchip.com, Alexandre Belloni Cc: Daniels Umanovskis , Patrice Vilchez , Cristian Birsan , Ludovic Desroches , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , Greg Kroah-Hartman , Saravana Kannan References: <13c6c9a2-6db5-c3bf-349b-4c127ad3496a@axentia.se> <69bb004f-0bb4-ec56-479c-5deab0ece00f@axentia.se> <7edb467a-c8b4-fe29-9947-f71c655caa9f@axentia.se> <8484ce66-639c-03f5-c5db-3574ea26690c@microchip.com> <075a196f-79c2-0d58-15f9-ad5e33e2306b@axentia.se> <3beb80ad-d6f8-8c6a-e17d-e40a644bba07@microchip.com> <9e24034e-f586-a721-9031-179601a69abb@axentia.se> <7214ea3d-1445-c0fb-2620-cdc3d6167bcc@axentia.se> <6d9561a4-39e4-3dbe-5fe2-c6f88ee2a4c6@axentia.se> From: Peter Rosin Organization: Axentia Technologies AB In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: HE1P190CA0015.EURP190.PROD.OUTLOOK.COM (2603:10a6:3:bc::25) To AM0PR02MB4436.eurprd02.prod.outlook.com (2603:10a6:208:ed::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a48ab20b-f117-47af-89ea-08da027c995a X-MS-TrafficTypeDiagnostic: AM4PR0202MB2852:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yzxVwB7G4FY0lDVt8QZMBkWj/Hk14PKEsJL4g9LHgBU7dCcBEhWEEzhIY3iLSg1q5ep2SOi2Y4SF+jzx44lBjsltUbKPgmMaW/FJvNof8NR1yj0YWBIAs87g8/ENmTwwIO0HZf0rD4uQkEh/y/tF9PY7XDbk2nreYFLuduOTHEAZafrY2Fga61bk9sXBr2Mu0ES7MxacJkBwHHZEdKNTH1/W1oaDdbx1ri+j9YOv6pqODeAW7IJgDM8GrrbXfd14To+MTYO/HfBEyZ6YOQ5hVBb2+STYd+EMBV0AO87b7ccJ/llz13WCZiBFhCTstGHvxN0b+d6M8I9CyjlTQM/b4LepPUxES+lgIPsp8bukonG/56smU4GilpIqB2GhRNxSXGlmgv7FFs7rJ38N+lt6PuEjIi0Nn6DjnfMbSK3D5mg/6F9OASdA85eDrM5MoL/AqCwgcZfM6TA3YdqNXAdA31Opbr3KeQ/L4uSsMR2JSBFdnhDgj8WYjVkntSrpKc4sF2xHmS2FtQpVL10eD/weD+Z9r3v1kRkAFNcVgaVHXywM4d8RAlNDmlL1ueoHB/T5gAOLmgp4HUV4GS6fV3UC3jUjPTcmNJviOljDPsiLcuAOUOjJDHwYa9147Go79J+5amzTj9C0kPpdzoG0jRocsQx2/YEBefh7URPF0KAhTs7qiT6QXxI9/AROwwDGUPV4LqCg2ijc6FFPSM2iQgCeJgUXBGZequI/YcPinkZhvBN2Hl/x87otKfU+iwGWa0LQMUyXek+rorFpHtSFInhZRCQf7V6UrFO/RfPqVNMQOu5CXryN6o0zqMyvDC83yEGx X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR02MB4436.eurprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(396003)(346002)(136003)(376002)(39830400003)(366004)(53546011)(6512007)(6666004)(186003)(2616005)(6486002)(66556008)(2906002)(31686004)(36916002)(6506007)(83380400001)(36756003)(5660300002)(26005)(8936002)(7416002)(31696002)(86362001)(110136005)(508600001)(66476007)(54906003)(316002)(66946007)(4326008)(966005)(38100700002)(8676002)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?U0tEbDNEMFdDcUlpMUpaSE9mNXdOaHdnZ0NrUGp1UHU3SWYraU5Xb2NCcG83?= =?utf-8?B?Y1R3VGxETjF5WDR6QWZNY1RzQ0NjWktPSDVYSGQ0MGUzUkVaYzczb0h2ZStH?= =?utf-8?B?dkQ3SnpaWkRzamUvWW1OV0c3cXI4bWttaGNka3dlVVZLSFIyN1JZYndEWGZB?= =?utf-8?B?Nks1YWRlMFlBeXhiZkxjcUQrZmgyeFBHUXNYYnNOTUpqM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id: a48ab20b-f117-47af-89ea-08da027c995a X-MS-Exchange-CrossTenant-AuthSource: AM0PR02MB4436.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2022 09:59:00.4800 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Es6NOMr1+cDYALDtnh1TROB+lpsBUEVigbxhRdedJ8ahaIYZVfD3YoD9EIoCErpl X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0202MB2852 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [bringing this threadlet back to the lists, hope that's ok] On 2022-03-10 09:27, Nicolas Ferre wrote: > On 09/03/2022 at 12:42, Peter Rosin wrote: >> On 2022-03-09 11:38, Nicolas Ferre wrote: >>> Hi Peter, >>> *snip* >>> One of my colleagues had an idea about this issue and in particular with >>> the fact that removing some of the entries in the structure triggered >>> the problem: "isn't it some kind of misalignment between structures that >>> are supposed to be treated in 64 bits machines and our 32 bits core that >>> we use?" >>> This misalignment or "wrong assumption" of using 64 bits machine might >>> be present in the USB stack as it seems to be related to this sub-system >>> somehow. >> >> Yes, something like that has been creeping around in the back of my >> head too. And it could be something much later in struct device that >> is no longer sufficiently aligned when struct dev_links_info changes. >> But what? I verified the alignment of various things. With the old working struct dev_links_info, i.e. struct dev_links_info { struct list_head suppliers; struct list_head consumers; struct list_head needs_suppliers; struct list_head defer_sync; bool need_for_probe; enum dl_dev_state status; }; I get sizeof(struct device) 440 sizeof(struct dev_links_info) 40 offsetof(struct device, links) 80 offsetof(struct device, power) 120 "power" is the next member after "struct dev_links_info links" in struct device, and I find no other uses of struct dev_links_info. With the new problematic layout, i.e. struct dev_links_info { struct list_head suppliers; struct list_head consumers; struct list_head defer_sync; enum dl_dev_state status; }; I get: sizeof(struct device) 432 sizeof(struct dev_links_info) 28 offsetof(struct device, links) 80 offsetof(struct device, power) 112 Which means that everything around and within dev_links_info is 8-byte aligned in the same way in either case. The exception being that "status" no longer shares 8-byte space with "need_for_probe" (which is gone). But that should only make things better, no? That combined with the test with this permuted version (swapped two list_heads in the middle): struct dev_links_info { struct list_head suppliers; struct list_head consumers; struct list_head defer_sync; struct list_head needs_suppliers; bool need_for_probe; enum dl_dev_state status; }; which displayed a new failure mode (BUG instead of corruption, see upthread) indicates that this is not an alignment issue. Famous last words... > From that article: > https://lwn.net/Articles/885941/ > > I read: > "Koschel included a patch fixing a bug in the USB subsystem where the > iterator passed to this macro was used after the exit from the macro, > which is a dangerous thing to do. Depending on what happens within the > list, the contents of that iterator could be something surprising, even > in the absence of speculative execution. Koschel fixed the problem by > reworking the code in question to stop using the iterator after the loop. " > > USB subsystem, "struct list_head *next, *prev;"... Some keywords present > there... worth a try? > > Regards, > Nicolas gr_udc.c is not built with the config that is in use, which is sad because it looked like a good candidate. Cheers, Peter