Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2938305lqp; Mon, 25 Mar 2024 13:46:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV+ym9VJ9to+SDPa4GUfFnaBqeVIWP93LNF9LRxVzbkzLOXyzCdzrTxZpg4/euaeKxfK9DX4kNj8ChgS/DrZXYp3pIHFG8OMNZw00a65w== X-Google-Smtp-Source: AGHT+IFchqGt5nYtbZ8TvMnLgov1DYc++yzxOEk4LVp8C+H5NNVLh09mWtuErliWTJ56do6yJNvZ X-Received: by 2002:a17:903:18a:b0:1e0:b709:139b with SMTP id z10-20020a170903018a00b001e0b709139bmr5208559plg.56.1711399592503; Mon, 25 Mar 2024 13:46:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711399592; cv=pass; d=google.com; s=arc-20160816; b=hTB01FCRw3Qynp+PVoEHEJhVDdVU9lDzSoPfpE704pxOWlqrlNyVykmVPEBhHXeS3Y o0WSMwYNA5HCe5G2YDvG1mxuki0/yg2I0nmT2u23RsRNKPl3GmESp+Q3B9BuzJ0aWvQ5 F84nV8yd5xsAKXm4tYi/VghiUqw0XWAYdI1PSuSrHWWbp33FG5QCoMoclwodc8yty4EU sdySZVT0gRj80USv4OZyAKBm1GCxOdzYneM9x3FhW7nf0ivaEWrRnniJ1HYqq+8nMsAh m9Aoaqtz0SI5JaYJefkdEOnpYXqBm5/gKtS/jp+2TXpWIT34LvZCl9p+um54DZwOeNT5 FNkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=q1zlvdnJpqaTnllJ/lRQg8Ac6LRENcEuqQ1BkstWBBs=; fh=ZLkLY6beVw31d5inWwF72ihpyRmJmWUCpeL9qIbHdD8=; b=b8X8tWAi8ZF11L7hB8ixuL/IbIf5rF3gfIRS3Gt8ZGseiFQJJ5R9aKR7COoeE1eDMj OPfwibJi/Rff+0aSnQQIiMjOf1wWrMH3S9dT0QtNJzfIkc2TXlTYbSNy2EpQb+x0ifHH RaUOgLbOJkNBMGp23qXpI6Sr6l3QG7QdUZSM+j2dtdjVEGcB/XSAIuy2Qft7HvLzi5NO aubM4XqOLE8CuZeuQYfHyD5FmOgyYbEDBF0IZABCYjXa4Y0iNpp4zzsl08p0ZB2T24Bx WAtPnxIaTnNsxBuR+xhQZabQq8o3kE1RFg5loa+KtbcvR4MzVRIq1dXHYIkG6ReMphej +S+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ibWoL9px; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-2856-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2856-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s8-20020a170902ea0800b001d9004b68f2si6038758plg.239.2024.03.25.13.46.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 13:46:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2856-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ibWoL9px; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-2856-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2856-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2D9E532596A for ; Mon, 25 Mar 2024 20:46:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D3CD71B49; Mon, 25 Mar 2024 20:44:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ibWoL9px" X-Original-To: linux-crypto@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35ECA71739; Mon, 25 Mar 2024 20:44:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711399499; cv=none; b=AfQiccP/gWoWnfdXYSR3JPFI3eId3z8eZ8sxveDQoRwRDxRVmkxwSoG8Go2rIcPkY/0Qt4v1Nn2BbhXetG3VD/+ZKVvWuctFpRZmaEOcf/xmnQMWxEYEvXJUYlLAKkzF4QOk2wP/D7TuXb/yEsrLTMvzRijRN6XNE8iEeja8ypg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711399499; c=relaxed/simple; bh=8Q5dBDtztW2JoXr9nD0hK47pMWPXBqeI3oSF7O+vO+Q=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=paYpFtouHn/71TrMkP4rbNF2IA+Y7IiwusvagECDRcpScfA52AxKCGSxsfUQeLrBThzvfwZDFJGytJEcEcsZsF8EJrLl9fshdRJtzvi2l4BgIDvSPGiGbMOFn+c92s95ZIYIAptTlji7AWTXCB2xihj+qTIxDVBP+OvZia411qM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ibWoL9px; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7716C433B2; Mon, 25 Mar 2024 20:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711399498; bh=8Q5dBDtztW2JoXr9nD0hK47pMWPXBqeI3oSF7O+vO+Q=; h=Date:From:To:Cc:Subject:From; b=ibWoL9pxXqCF2Ggso3naA2fD2G+wfd/tLQLp9GtIz1ZJxRdpx4wyIylnAk70loO4Q fqC++a7QClTXwKYl+rqx2yq/KxOMF6el7gcH+3IItQ2RPBnHtZUU8I8GYnew92AWl3 cwdSQoCZSnY2SEyDgnmPRtGNj4aJuPHGBToEMLbw2PF6XKhwqZ+ulQmEuV6A6AqL68 9B4r/D1GnrYMTuXJkMJcadrI5i6Ge6BUvUxse+BmTNJ1gck4oChgKclkW9q9eMsXIa B8iM+DBPW0oLwRuH+I4jU1FbJXAAFtB5uBxdiwaPP7FQ/EQm/YGk+HdvpoxZJM4hKv yeX2J6n6l7OfA== Date: Mon, 25 Mar 2024 14:44:55 -0600 From: "Gustavo A. R. Silva" To: Giovanni Cabiddu , Herbert Xu , "David S. Miller" Cc: qat-linux@intel.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] crypto: qat - Avoid -Wflex-array-member-not-at-end warnings Message-ID: Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting ready to enable it globally. Use the `__struct_group()` helper to separate the flexible array from the rest of the members in flexible `struct qat_alg_buf_list`, through tagged `struct qat_alg_buf_list_hdr`, and avoid embedding the flexible-array member in the middle of `struct qat_alg_fixed_buf_list`. Also, use `container_of()` whenever we need to retrieve a pointer to the flexible structure. So, with these changes, fix the following warnings: drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/crypto/intel/qat/qat_common/qat_bl.h:25:33: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] Link: https://github.com/KSPP/linux/issues/202 Signed-off-by: Gustavo A. R. Silva --- drivers/crypto/intel/qat/qat_common/qat_bl.c | 6 ++++-- drivers/crypto/intel/qat/qat_common/qat_bl.h | 11 +++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/crypto/intel/qat/qat_common/qat_bl.c b/drivers/crypto/intel/qat/qat_common/qat_bl.c index 76baed0a76c0..338acf29c487 100644 --- a/drivers/crypto/intel/qat/qat_common/qat_bl.c +++ b/drivers/crypto/intel/qat/qat_common/qat_bl.c @@ -81,7 +81,8 @@ static int __qat_bl_sgl_to_bufl(struct adf_accel_dev *accel_dev, if (unlikely(!bufl)) return -ENOMEM; } else { - bufl = &buf->sgl_src.sgl_hdr; + bufl = container_of(&buf->sgl_src.sgl_hdr, + struct qat_alg_buf_list, hdr); memset(bufl, 0, sizeof(struct qat_alg_buf_list)); buf->sgl_src_valid = true; } @@ -139,7 +140,8 @@ static int __qat_bl_sgl_to_bufl(struct adf_accel_dev *accel_dev, if (unlikely(!buflout)) goto err_in; } else { - buflout = &buf->sgl_dst.sgl_hdr; + buflout = container_of(&buf->sgl_dst.sgl_hdr, + struct qat_alg_buf_list, hdr); memset(buflout, 0, sizeof(struct qat_alg_buf_list)); buf->sgl_dst_valid = true; } diff --git a/drivers/crypto/intel/qat/qat_common/qat_bl.h b/drivers/crypto/intel/qat/qat_common/qat_bl.h index d87e4f35ac39..85bc32a9ec0e 100644 --- a/drivers/crypto/intel/qat/qat_common/qat_bl.h +++ b/drivers/crypto/intel/qat/qat_common/qat_bl.h @@ -15,14 +15,17 @@ struct qat_alg_buf { } __packed; struct qat_alg_buf_list { - u64 resrvd; - u32 num_bufs; - u32 num_mapped_bufs; + /* New members must be added within the __struct_group() macro below. */ + __struct_group(qat_alg_buf_list_hdr, hdr, __packed, + u64 resrvd; + u32 num_bufs; + u32 num_mapped_bufs; + ); struct qat_alg_buf buffers[]; } __packed; struct qat_alg_fixed_buf_list { - struct qat_alg_buf_list sgl_hdr; + struct qat_alg_buf_list_hdr sgl_hdr; struct qat_alg_buf descriptors[QAT_MAX_BUFF_DESC]; } __packed __aligned(64); -- 2.34.1