Message ID | 20230616090439.2484857-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1189479vqr; Fri, 16 Jun 2023 02:12:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5AHhHfEBQHErSJhB4hHNBiZ4Ou5StSCxnJuecPXmDGOyi/o+v3OE9el3xGbdtEvPhifaGn X-Received: by 2002:a05:6808:1d8:b0:398:57fe:5fa with SMTP id x24-20020a05680801d800b0039857fe05famr1509929oic.29.1686906731241; Fri, 16 Jun 2023 02:12:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686906731; cv=none; d=google.com; s=arc-20160816; b=I1EO5SOXNm/Q6TSlcvRU74QnZRfCoxYmygDKyDjoazOPo5fG/db1pG3YKx7txxMca3 DU2kdHj2tStaqMrZRlD4Pn6YFfmsHICMX6eaDIGKaZdBbwv56oCnwBE+zofZ3/ZA2v+1 sinuCsCwZD+8yvLoAgn1CnYDwgku1D65i7vVjO8VmRLwXz5VcSqpGpEOY3tKiBbx6Axv 17NSLEuUDJgpw0ffqQKduZhBtyHdLv3qWvVgyqAIxsiDuUyRBDqTLViT4Lrj8cLkDeEA IJgwu9ZXtkk8KaWFTNdukWMsVc2BLeikauP7LwvyMH2/RQNmigWQJgisOi8i4KzKOQEC cLNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=/QndeYAMjYgQThG1RsDhoiczl73vcasgX3QgQhLGjfM=; b=psM9nuhGqqIxiEfpwZYt4xrweU8XxWHXYiZVZC+OBwWysmtl3q1hRh8X4qQFCdz2tj JlIO0P88TjzQ6Ghs7fBn7AziopTUFsyOtlaPM3/kgBIIBVj12rwowCnVwhX0NTNMi7Ji fxq+D+DZk6y/k4VhfrcnF8sW8vtJ3K19e/eZY3VVfCnzPyZMR9pnkpplHN6dU3+43u1C BZHqqntvD8GcmBKXlr8K7YeQpIYOsdk9pikHEdwZEVNI7lIsSzVFPlU0Y+yGlPOjvlr9 NbsFJFhVnXinEhh2DQLc0N0M0pUUpcwD1/gXpY1lhYNArG5CfEjKEdnVMh6l7gUb525I mkVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=niagvxX+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m17-20020a17090b069100b0025c0784b6f4si1125566pjz.144.2023.06.16.02.11.59; Fri, 16 Jun 2023 02:12:11 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=niagvxX+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344001AbjFPJHU (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Fri, 16 Jun 2023 05:07:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232983AbjFPJGw (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 16 Jun 2023 05:06:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6505344AD; Fri, 16 Jun 2023 02:04:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8CBFE62994; Fri, 16 Jun 2023 09:04:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A29AC433C8; Fri, 16 Jun 2023 09:04:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686906284; bh=ZIfwN7dOKIbw077DPRJk3QvTD8i+PX9joN3XwIVd+S4=; h=From:To:Cc:Subject:Date:From; b=niagvxX+xZgRBkm7C+5UOsMAzDVNBPf2P6YfN8GJVEbuR9LLPyGBI1Ze0/8OkqPHH 5Eo2SLeUs+boCURI5yINU2SZdHjASmTKRE31nhPUCf+oBHbPwXolxGkpJN/G18WPf2 xr1sBtcTkFPgWblY+xRVvXHqtp5tTvd2TwjcfttzxQyJ6cy5Aqrnh67dgzVNIsL3ap 0Uq4gXNrl1nl/qT2KOwe6MPKv+la4iwplFfir2ZoySdn/VixobzkILcvyaUTP07W0B nk4IikvGP5tH+pN+9Ee8QV7KEAoax2XB3PHXluqu/s675J2Rjfs7e1idrGFcLJbXWa gKas7TYDSeE0g== From: Arnd Bergmann <arnd@kernel.org> To: Kalle Valo <kvalo@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Kees Cook <keescook@chromium.org>, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] ath10k: improve structure padding Date: Fri, 16 Jun 2023 11:04:21 +0200 Message-Id: <20230616090439.2484857-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768849912488605550?= X-GMAIL-MSGID: =?utf-8?q?1768849912488605550?= |
Series |
ath10k: improve structure padding
|
|
Commit Message
Arnd Bergmann
June 16, 2023, 9:04 a.m. UTC
From: Arnd Bergmann <arnd@arndb.de> Including an aligned structure inside of a packed one is ambiguous and can lead to misaligned data, as pointed out by this clang warning: drivers/net/wireless/ath/ath10k/htt.h:715:34: error: field prefix within 'struct htt_rx_indication' is less aligned than 'struct htt_rx_indication_prefix' and is usually due to 'struct htt_rx_indication' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] struct htt_rx_indication_prefix prefix; ^ drivers/net/wireless/ath/ath10k/htt.h:736:34: error: field prefix within 'struct htt_rx_indication_hl' is less aligned than 'struct htt_rx_indication_prefix' and is usually due to 'struct htt_rx_indication_hl' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] struct htt_rx_indication_prefix prefix; ^ drivers/net/wireless/ath/ath10k/htt.h:1564:2: error: field within 'struct htt_tx_fetch_ind' is less aligned than 'union htt_tx_fetch_ind::(anonymous at drivers/net/wireless/ath/ath10k/htt.h:1564:2)' and is usually due to 'struct htt_tx_fetch_ind' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] union { ^ drivers/net/wireless/ath/ath10k/htt.h:1702:2: error: field within 'struct htt_resp' is less aligned than 'union htt_resp::(anonymous at drivers/net/wireless/ath/ath10k/htt.h:1702:2)' and is usually due to 'struct htt_resp' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] These structures appear to actually need the packing since they are embedded at misaligned offsets. Add even more such annotations here to enforce bytewise access throughout the driver. Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/net/wireless/ath/ath10k/htt.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Comments
Arnd Bergmann <arnd@kernel.org> wrote: > Including an aligned structure inside of a packed one is ambiguous > and can lead to misaligned data, as pointed out by this clang warning: > > drivers/net/wireless/ath/ath10k/htt.h:715:34: error: field prefix within 'struct htt_rx_indication' is less aligned than 'struct htt_rx_indication_prefix' and is usually due to 'struct htt_rx_indication' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] > struct htt_rx_indication_prefix prefix; > ^ > drivers/net/wireless/ath/ath10k/htt.h:736:34: error: field prefix within 'struct htt_rx_indication_hl' is less aligned than 'struct htt_rx_indication_prefix' and is usually due to 'struct htt_rx_indication_hl' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] > struct htt_rx_indication_prefix prefix; > ^ > drivers/net/wireless/ath/ath10k/htt.h:1564:2: error: field within 'struct htt_tx_fetch_ind' is less aligned than 'union htt_tx_fetch_ind::(anonymous at drivers/net/wireless/ath/ath10k/htt.h:1564:2)' and is usually due to 'struct htt_tx_fetch_ind' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] > union { > ^ > drivers/net/wireless/ath/ath10k/htt.h:1702:2: error: field within 'struct htt_resp' is less aligned than 'union htt_resp::(anonymous at drivers/net/wireless/ath/ath10k/htt.h:1702:2)' and is usually due to 'struct htt_resp' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] > > These structures appear to actually need the packing since they > are embedded at misaligned offsets. Add even more such annotations > here to enforce bytewise access throughout the driver. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Patch applied to ath-next branch of ath.git, thanks. 12ec37be3faf wifi: ath10k: improve structure padding
diff --git a/drivers/net/wireless/ath/ath10k/htt.h b/drivers/net/wireless/ath/ath10k/htt.h index c051a22fce145..e0c9f45e74761 100644 --- a/drivers/net/wireless/ath/ath10k/htt.h +++ b/drivers/net/wireless/ath/ath10k/htt.h @@ -707,7 +707,7 @@ struct htt_rx_indication_prefix { __le16 fw_rx_desc_bytes; u8 pad0; u8 pad1; -}; +} __packed; struct htt_rx_indication { struct htt_rx_indication_hdr hdr; @@ -1565,7 +1565,7 @@ struct htt_tx_fetch_ind { /* ath10k_htt_get_tx_fetch_ind_resp_ids() */ DECLARE_FLEX_ARRAY(__le32, resp_ids); DECLARE_FLEX_ARRAY(struct htt_tx_fetch_record, records); - }; + } __packed; } __packed; static inline void * @@ -1723,7 +1723,7 @@ struct htt_resp { struct htt_tx_mode_switch_ind tx_mode_switch_ind; struct htt_channel_change chan_change; struct htt_peer_tx_stats peer_tx_stats; - }; + } __packed; } __packed; /*** host side structures follow ***/