Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1102796rwo; Wed, 2 Aug 2023 08:45:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlEemvdXNaKbxF8yS/p6wygVykW8eADju0sy3a+Db0L9fFVYpkcQfJJXV2DJ5zcjyTMxmf54 X-Received: by 2002:a05:6a21:6d9a:b0:137:68c3:c86f with SMTP id wl26-20020a056a216d9a00b0013768c3c86fmr17156059pzb.55.1690991129153; Wed, 02 Aug 2023 08:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690991129; cv=none; d=google.com; s=arc-20160816; b=CgaD9ml3atwGtG2HUuCRHfA0dnejnwM+GPMif9iZF5fju4Ireykomb15r9pf5KqHje V5iXb+hl3ba81UWBdb7Pb9Zer+T1bymeFH6UBxrFMFlxGEYsR6afRcvIr1GZeJZxsiJ7 v68XijHg4iSlG6XxEj7+LpPOIRmbxNNv5TAMDDgGcg7/EiWeVHcce6hK8B4Njl59uNy+ CwE2kQ3pShW3tMMS7t7QcETntCF0/He+6EuVS1+l+zLNhRzDMYp0UiWvRgYeSIGdsFew Ef3arKJNLgyIKyFIe1OdK6NhJrY6v62010zE3VauTkb4+425vgk+JRnaE9we6ImQhwQP Ft5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=9lxR0CWef0VRpoPjmXnJ7LAW58bcX/1VKH8L8N1A/PY=; fh=JOhtTsYpWBYv+uoCE6QYMg24o6cly66KlfPix+Wh/yM=; b=YQcacvw0x0bkmz8uQOCXgO6YO8HqoDC8KEyE08mx2f470zFr2z2yArw9bV5qYD52GP naflKjS+khgXdagsxi4mbtf5oLAA/ZZtWueXgQBy1hzwOBXpUuWWf1X2/VfZvcsgeLd9 9PdXY25qlqypM5N/G2s5g2uRQ/h0Hmy3D4vd6u8nTvlwRhkqRYSEP9+K2g0cUsj+yKE7 ce70WMY+AdlkP1w8hPind5Fy55xBViE4FjMqo0M7pnbBHX2BBD0YAdhqFKvM0hWiEkwB ueEcNCZ9vyF+ppc1GLxrUh9sbEJmTLhJy26A0UG+Tiluc0LO1O80b57ziD15qQWDxMMf MVAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jgjaj4Fw; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s63-20020a635e42000000b00563de4bf5absi10876455pgb.543.2023.08.02.08.45.14; Wed, 02 Aug 2023 08:45:29 -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=jgjaj4Fw; 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 S234405AbjHBOp0 (ORCPT + 99 others); Wed, 2 Aug 2023 10:45:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234343AbjHBOpY (ORCPT ); Wed, 2 Aug 2023 10:45:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D8091FF3; Wed, 2 Aug 2023 07:45:23 -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 183D761935; Wed, 2 Aug 2023 14:45:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D4C1C433C8; Wed, 2 Aug 2023 14:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690987522; bh=MoMUpb0Ss3thYLsphFCCaQgq68tYvFO+u3uZ4M9Dy5I=; h=Date:From:To:Cc:Subject:From; b=jgjaj4FwqBc7wTc9bYPMguqpKlMXlSWf/QhAxjpeNESH/Zfj+v3pky5NH8khA3Vrp Cu2Da+UFFnbQR2n2x0y5QmegpPGudZ6sLdS6qvGQrTdPdEdPRP67Lie96yj6y8AlfL E7h/RvQWUkKo0SmfjA+yVnN42o0UndbmE+8Gep6IHFVV79jjF0pL/2s3UIJhzRJY2V ay3sWw1gEogD4PPxEM0Ts4SRZ8bAM0vt1J9yjWKdqWS0C/0k5idlKAx/hJgJEDDm1j vQRR9Xo7p6KpbotDXIifxda0/idPl7zjbdMovQ86mhUm/NmgjkqZtiLsks7al8k5Jd 16ozUiwvbn8mA== Date: Wed, 2 Aug 2023 08:46:26 -0600 From: "Gustavo A. R. Silva" To: Mustafa Ismail , Shiraz Saleem , Jason Gunthorpe , Leon Romanovsky , "Gustavo A. R. Silva" Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] RDMA/irdma: Replace one-element array with flexible-array member Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: X-Mailing-List: linux-kernel@vger.kernel.org One-element and zero-length arrays are deprecated. So, replace one-element array in struct irdma_qvlist_info with flexible-array member. A patch for this was sent a while ago[1]. However, it seems that, at the time, the changes were partially folded[2][3], and the actual flexible-array transformation was omitted. This patch fixes that. The only binary difference seen before/after changes is shown below: | drivers/infiniband/hw/irdma/hw.o | @@ -868,7 +868,7 @@ | drivers/infiniband/hw/irdma/hw.c:484 (discriminator 2) | size += struct_size(iw_qvlist, qv_info, rf->msix_count); | 55b: imul $0x45c,%rdi,%rdi |- 562: add $0x10,%rdi |+ 562: add $0x4,%rdi which is, of course, expected as it reflects the mistake made while folding the patch I've mentioned above. Worth mentioning is the fact that with this change we save 12 bytes of memory, as can be inferred from the diff snapshot above. Notice that: $ pahole -C rdma_qv_info idrivers/infiniband/hw/irdma/hw.o struct irdma_qv_info { u32 v_idx; /* 0 4 */ u16 ceq_idx; /* 4 2 */ u16 aeq_idx; /* 6 2 */ u8 itr_idx; /* 8 1 */ /* size: 12, cachelines: 1, members: 4 */ /* padding: 3 */ /* last cacheline: 12 bytes */ }; Link: https://lore.kernel.org/linux-hardening/20210525230038.GA175516@embeddedor/ [1] Link: https://lore.kernel.org/linux-hardening/bf46b428deef4e9e89b0ea1704b1f0e5@intel.com/ [2] Link: https://lore.kernel.org/linux-rdma/20210520143809.819-1-shiraz.saleem@intel.com/T/#u [3] Fixes: 44d9e52977a1 ("RDMA/irdma: Implement device initialization definitions") Signed-off-by: Gustavo A. R. Silva --- drivers/infiniband/hw/irdma/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/irdma/main.h b/drivers/infiniband/hw/irdma/main.h index 5483684a534c..82fc5f5b002c 100644 --- a/drivers/infiniband/hw/irdma/main.h +++ b/drivers/infiniband/hw/irdma/main.h @@ -239,7 +239,7 @@ struct irdma_qv_info { struct irdma_qvlist_info { u32 num_vectors; - struct irdma_qv_info qv_info[1]; + struct irdma_qv_info qv_info[]; }; struct irdma_gen_ops { -- 2.34.1