Message ID | af0a1f2194fc9a6f8a95cf6c82277b8b0377d029.1679311226.git.geert@linux-m68k.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1165270wrt; Mon, 20 Mar 2023 04:45:10 -0700 (PDT) X-Google-Smtp-Source: AK7set+K0FkZx7TWfDoy5BQFRp0YJzwjR/ntM1k3OXI6CfCpn5ZEJu5fATdgq2cYz6ssf3m/LGHh X-Received: by 2002:a17:902:c411:b0:1a0:7422:939a with SMTP id k17-20020a170902c41100b001a07422939amr24756858plk.4.1679312710232; Mon, 20 Mar 2023 04:45:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679312710; cv=none; d=google.com; s=arc-20160816; b=snsi1ivGo0s5m/Z6I/LKRwnr2YizVi7nUAWXyvkS6aisXIs3xQTgZkG6ujG+va7omL pMgLADxm4AaxcnExP/GEyGC5PKWgKjAt8nGf1qXmcxiOJYKl8+up1MKfSSrYP+4HNMd8 0yXk0/yy3qc5j9O+IZoMqrm/2dwBGAa2KAOBq9wKYkDKH8Vd6VpZSavOX/E6CRJ0uc3/ mJhWCtUm/3xLa545JiBQfkDuUcSTH8ozDg5cKEIcbla5KdkX0gEpzhEsSDGfOFl5u8TV 2gyxD9wlt4eXG8L/yOsxOKQSsnpQQ0qVlgVgi4G+iDF1PlVdoy+p+65vLhTvtLKnzR+P y+vQ== 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; bh=YpHjQo7xlhoYYr74GCWp0bdLkdHysgHQqZqSV9xIwTo=; b=DicwdRv+j0TTuTCJIGT2y344IFYmkiHEqvy7aKpN5oKWHWHP8iR50gs14OyEInf0U7 vRVFYF46qVQu43AUE6VgDim9Kp3OhJbUx88yCD+pI4ayz50/D1etx6SlD1u2T5IwZxOx u2XHb6ZauVIM1VnZSXbSddeOc4PwqQ6ZkMkZc5hPr4ZcMdQNI4Hbuj9ZFQ4/D1MoYpvb Ial/049CAVzD2EIQ/EQMxhi+DHpo9XMPbdahcsRyM+syczhm+dIJ4fbTGhwObGWLCPPq IMO2pdPwLyi36n/T8SMn31JpGT2ujK0QmopqZ9AUOjXmyRyF19ke19xwBS3DQ0qLOgas UvuQ== ARC-Authentication-Results: i=1; mx.google.com; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u8-20020a170902e5c800b001a1cefdaa43si3097900plf.351.2023.03.20.04.44.55; Mon, 20 Mar 2023 04:45:10 -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; 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 S229705AbjCTLWg (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Mon, 20 Mar 2023 07:22:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230113AbjCTLWT (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 20 Mar 2023 07:22:19 -0400 Received: from baptiste.telenet-ops.be (baptiste.telenet-ops.be [IPv6:2a02:1800:120:4::f00:13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E809FBBA9 for <linux-kernel@vger.kernel.org>; Mon, 20 Mar 2023 04:22:01 -0700 (PDT) Received: from ramsan.of.borg ([84.195.187.55]) by baptiste.telenet-ops.be with bizsmtp id abMx2900d1C8whw01bMxVl; Mon, 20 Mar 2023 12:21:59 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from <geert@linux-m68k.org>) id 1peDZk-00E1jv-VC; Mon, 20 Mar 2023 12:21:57 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from <geert@linux-m68k.org>) id 1peDaP-00736z-OM; Mon, 20 Mar 2023 12:21:57 +0100 From: Geert Uytterhoeven <geert@linux-m68k.org> To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@fb.com>, Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me> Cc: Arnd Bergmann <arnd@arndb.de>, linux-nvme@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven <geert@linux-m68k.org> Subject: [PATCH] nvme-tcp: Fix implicit padding in struct nvme_tcp_term_pdu Date: Mon, 20 Mar 2023 12:21:56 +0100 Message-Id: <af0a1f2194fc9a6f8a95cf6c82277b8b0377d029.1679311226.git.geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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?1760887004703033057?= X-GMAIL-MSGID: =?utf-8?q?1760887004703033057?= |
Series |
nvme-tcp: Fix implicit padding in struct nvme_tcp_term_pdu
|
|
Commit Message
Geert Uytterhoeven
March 20, 2023, 11:21 a.m. UTC
On m68k:
drivers/nvme/host/tcp.c: In function ‘nvme_tcp_init_module’:
include/linux/compiler_types.h:397:38: error: call to ‘__compiletime_assert_723’ declared with attribute error: BUILD_BUG_ON failed: sizeof(struct nvme_tcp_term_pdu) != 24
Indeed, on m68k the minimum alignment is 2 bytes, not 4 bytes, thus
triggering the check added in commit 7e87965d3807ab1f ("nvme-tcp: add
nvme-tcp pdu size build protection"), and indicating that NVMe over
Fabrics TCP on m68k must be incompatible with other platforms.
Fix this by adding explicit padding.
Fixes: fc221d05447aa6db ("nvme-tcp: Add protocol header")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
include/linux/nvme-tcp.h | 1 +
1 file changed, 1 insertion(+)
Comments
The nvme_tcp_term_pdu definition needs to be updated anyways to match the spec. FEI is at offset 10, so it isn't 4-byte-aligned. I think we have gotten away with this so far because the NVMe/TCP driver never sends H2CTermReq and doesn't interpret C2HTermReq. Mirroring numdl/numdu in nvme_get_log_page_command, the definition should look something like: struct nvme_tcp_term_pdu { struct nvme_tcp_hdr hdr; __le16 fes; __le16 feil; __le16 feiu; __u8 rsvd[10]; }; Best, Caleb On Mon, Mar 20, 2023 at 4:29 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > > On m68k: > > drivers/nvme/host/tcp.c: In function ‘nvme_tcp_init_module’: > include/linux/compiler_types.h:397:38: error: call to ‘__compiletime_assert_723’ declared with attribute error: BUILD_BUG_ON failed: sizeof(struct nvme_tcp_term_pdu) != 24 > > Indeed, on m68k the minimum alignment is 2 bytes, not 4 bytes, thus > triggering the check added in commit 7e87965d3807ab1f ("nvme-tcp: add > nvme-tcp pdu size build protection"), and indicating that NVMe over > Fabrics TCP on m68k must be incompatible with other platforms. > > Fix this by adding explicit padding. > > Fixes: fc221d05447aa6db ("nvme-tcp: Add protocol header") > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> > --- > include/linux/nvme-tcp.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/include/linux/nvme-tcp.h b/include/linux/nvme-tcp.h > index 75470159a194d97f..ba8f82672e39730f 100644 > --- a/include/linux/nvme-tcp.h > +++ b/include/linux/nvme-tcp.h > @@ -115,6 +115,7 @@ struct nvme_tcp_icresp_pdu { > struct nvme_tcp_term_pdu { > struct nvme_tcp_hdr hdr; > __le16 fes; > + __u8 rsvd2[2]; > __le32 fei; > __u8 rsvd[8]; > }; > -- > 2.34.1 > >
Hi Caleb, On Mon, Mar 20, 2023 at 4:34 PM Caleb Sander <csander@purestorage.com> wrote: > The nvme_tcp_term_pdu definition needs to be updated anyways to match > the spec. FEI is at offset 10, so it isn't 4-byte-aligned. I think we > have gotten away with this so far because the NVMe/TCP driver never > sends H2CTermReq and doesn't interpret C2HTermReq. > Mirroring numdl/numdu in nvme_get_log_page_command, the definition > should look something like: > struct nvme_tcp_term_pdu { > struct nvme_tcp_hdr hdr; > __le16 fes; > __le16 feil; > __le16 feiu; > __u8 rsvd[10]; > }; Great, so it was compliant only on m68k? ;-) > On Mon, Mar 20, 2023 at 4:29 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > > > > On m68k: > > > > drivers/nvme/host/tcp.c: In function ‘nvme_tcp_init_module’: > > include/linux/compiler_types.h:397:38: error: call to ‘__compiletime_assert_723’ declared with attribute error: BUILD_BUG_ON failed: sizeof(struct nvme_tcp_term_pdu) != 24 > > > > Indeed, on m68k the minimum alignment is 2 bytes, not 4 bytes, thus > > triggering the check added in commit 7e87965d3807ab1f ("nvme-tcp: add > > nvme-tcp pdu size build protection"), and indicating that NVMe over > > Fabrics TCP on m68k must be incompatible with other platforms. > > > > Fix this by adding explicit padding. > > > > Fixes: fc221d05447aa6db ("nvme-tcp: Add protocol header") > > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> > > --- > > include/linux/nvme-tcp.h | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/include/linux/nvme-tcp.h b/include/linux/nvme-tcp.h > > index 75470159a194d97f..ba8f82672e39730f 100644 > > --- a/include/linux/nvme-tcp.h > > +++ b/include/linux/nvme-tcp.h > > @@ -115,6 +115,7 @@ struct nvme_tcp_icresp_pdu { > > struct nvme_tcp_term_pdu { > > struct nvme_tcp_hdr hdr; > > __le16 fes; > > + __u8 rsvd2[2]; > > __le32 fei; > > __u8 rsvd[8]; > > }; Gr{oetje,eeting}s, Geert
diff --git a/include/linux/nvme-tcp.h b/include/linux/nvme-tcp.h index 75470159a194d97f..ba8f82672e39730f 100644 --- a/include/linux/nvme-tcp.h +++ b/include/linux/nvme-tcp.h @@ -115,6 +115,7 @@ struct nvme_tcp_icresp_pdu { struct nvme_tcp_term_pdu { struct nvme_tcp_hdr hdr; __le16 fes; + __u8 rsvd2[2]; __le32 fei; __u8 rsvd[8]; };