Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2303007pxb; Fri, 5 Feb 2021 14:24:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJzW7dGR91Ac2/8jRKIETCyz40F+E8PM+OhArzrq8Fc774FLPI8Jm+rYjrW8ljqCSzAla5xz X-Received: by 2002:a17:906:2ccb:: with SMTP id r11mr6204274ejr.39.1612563890235; Fri, 05 Feb 2021 14:24:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612563890; cv=none; d=google.com; s=arc-20160816; b=itljXxuYORLqUS+wc2F+pSb0okXbo5hkQfbvdOCi9JsR4yyxBCiS+PSj9e1nAU3jky o5gWBbSZQd0R9Rs7ESBwOPpAU2n2xM/eJyzOqwSfxwrPB1Zog1TkW9no/GhVGU6m/5sh DxSFe+XYel5VDLmuxHbnkWofiRhrgPWi6iBSs91/WAA1eUpVfBjUarUMJnJ5/HVhrHtM ABIvj0qDdEvpaEuDuWfob0R5EEWyUZrdbgILzsPmxWuOzUCv0YiW18iFLr0cRS349lIG WeNkjqTDbk0j0PvxBVi/M80bHpEFSCC/OBzTc5eHcS2ITrswZ+wEnDP7rAqvZa9XLJwp Cv6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=oyK2WLCuam/n+DALnL7kw5Jo7DMPsyagIePs/fF/sj8=; b=GjOShV9UVTaHAnorPQqa78b3bu4KjhGlMfhIVxudHW5sXjlzHZ/tn4AHf7tIYLUMib +PCjgLV10K4T9RDGZ5X7b8SF8gDzLsWvJ7gnvrK4vvPMbQp8Qs51rbZwIfRLHqsHOcUF ZCAw766VNct3jPR7BCUqvnbZk9DPVSuqtS0wbfnL0ABZUjerK585KuTSYziv5+xpNVbF LriAiZtGbKjz72QpiGRgyoH3b6eTNGvGJc/1so+2WntOXaEXBRyR6RCcMRLhI4RqnkSD 9c4f5Dya6IZPhASp8g/oE7A325EWApd4pWYLkK1VbuS2c6E0f0cgYZ5gYV2C3faKQR2J FmLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f27si6789479ejf.555.2021.02.05.14.24.25; Fri, 05 Feb 2021 14:24:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232524AbhBEWXE convert rfc822-to-8bit (ORCPT + 99 others); Fri, 5 Feb 2021 17:23:04 -0500 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:40368 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231910AbhBEO1w (ORCPT ); Fri, 5 Feb 2021 09:27:52 -0500 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-270-8he-aNJfMmyMpb8HPVFbEw-1; Fri, 05 Feb 2021 15:31:26 +0000 X-MC-Unique: 8he-aNJfMmyMpb8HPVFbEw-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 5 Feb 2021 15:31:19 +0000 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Fri, 5 Feb 2021 15:31:19 +0000 From: David Laight To: 'Arnd Bergmann' , Christian Lamparter , Kalle Valo , "David S. Miller" , Jakub Kicinski CC: Arnd Bergmann , "Gustavo A. R. Silva" , "linux-wireless@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] carl9170: fix struct alignment conflict Thread-Topic: [PATCH] carl9170: fix struct alignment conflict Thread-Index: AQHW+xSTHrCr5fMAo0K1NzKrRUoyIapJsAIQ Date: Fri, 5 Feb 2021 15:31:19 +0000 Message-ID: <8e03db0fb69f4df5ad3cb24695055728@AcuMS.aculab.com> References: <20210204162926.3262598-1-arnd@kernel.org> In-Reply-To: <20210204162926.3262598-1-arnd@kernel.org> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Arnd Bergmann > Sent: 04 February 2021 16:29 > > Multiple structures in the carl9170 driver have alignment > impossible alignment constraints that gcc warns about when > building with 'make W=1': > > drivers/net/wireless/ath/carl9170/fwcmd.h:243:2: warning: alignment 1 of 'union ' is less > than 4 [-Wpacked-not-aligned] > drivers/net/wireless/ath/carl9170/wlan.h:373:1: warning: alignment 1 of 'struct > ar9170_rx_frame_single' is less than 2 [-Wpacked-not-aligned] > > In the carl9170_cmd structure, multiple members that have an explicit > alignment requirement of four bytes are added into a union with explicit > byte alignment, but this in turn is part of a structure that also has > four-byte alignment. > > In the wlan.h header, multiple structures contain a ieee80211_hdr member > that is required to be two-byte aligned to avoid alignmnet faults when > processing network headers, but all members are forced to be byte-aligned > using the __packed tag at the end of the struct definition. > > In both cases, leaving out the packing does not change the internal > layout of the structure but changes the alignment constraint of the > structure itself. > > Change all affected structures to only apply packing where it does > not violate the alignment requirement of the contained structure. I think I'd add compile-time assert that some of these structures are exactly the expected size. Then look at removing the outer packed/aligned attributes and just putting the attribute on the 16/32 bit member(s) that themselves might be misaligned. Much the way that the 32bit aligned 64bit values are handled in the x86 compat code in x86-64. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)