From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D19ABA0A0E; Mon, 10 May 2021 16:03:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BE447406A3; Mon, 10 May 2021 16:03:20 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 969A34003E; Mon, 10 May 2021 16:03:19 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14ABSP5H012745; Mon, 10 May 2021 07:03:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=9rOVsOEKS+48U57VcfBOVLtaIbcMF1FbsMAS/YB31Bs=; b=U3OME7/PVPVoG2+ue5q7krARf1avcBm5igIU7Weu7QBZM/a6E5YCNW2n90M6KExSt06L OFqXMTL1lXsKdp5r3FUpnmah9aZlg+B0exIsJHeE1TgPaXnKYkk5T15hEJenzGSqZvzx 9daHAyvoQ7x6RA0wPwzroM6iYd5gRUAFd0AawKPqwwWtI7u8ctbjdBMh3U/c0pGizqWU GOlz9pK5Z8gJUePqjyRu1QAkS7rhLOJ0dnL7qNKvM+xmQ0L51gvA/2wdCH+6KM3jZqYQ ICHq84DxGZ6iWbqU1mwjzeWX6YVOMYNC/fVQQhu+i7wQzF3MCW+FNszCMXAijz6iZ6/6 vQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 38eygy992y-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 10 May 2021 07:03:17 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 10 May 2021 07:02:25 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 10 May 2021 07:02:25 -0700 Received: from BG-LT7430.marvell.com (BG-LT7430.marvell.com [10.28.177.176]) by maili.marvell.com (Postfix) with ESMTP id 2A0E86737A; Mon, 10 May 2021 07:02:20 -0700 (PDT) From: To: , Haiyue Wang , "Matan Azrad" , Shahaf Shuler , "Viacheslav Ovsiienko" , Jiawen Wu , "Jian Wang" , Thomas Monjalon , "Ferruh Yigit" , Andrew Rybchenko CC: , Pavan Nikhilesh , Date: Mon, 10 May 2021 19:32:13 +0530 Message-ID: <20210510140214.2627-2-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210510140214.2627-1-pbhagavatula@marvell.com> References: <20210509171803.1385-1-pbhagavatula@marvell.com> <20210510140214.2627-1-pbhagavatula@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: zIUW1C4n5JsaUL4nmS8ziTyxy-jaf5f3 X-Proofpoint-ORIG-GUID: zIUW1C4n5JsaUL4nmS8ziTyxy-jaf5f3 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-05-10_06:2021-05-10, 2021-05-10 signatures=0 Subject: [dpdk-dev] [PATCH v2 2/2] eal: fix side effects in ptr align macros X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Pavan Nikhilesh Avoid expanding parameters inside RTE_*_ALIGN macros. Update common_autotest to detect macro side effects. Workaround static arrays relying on RTE_ALIGN macros. Fixes: af75078fece3 ("first public release") Cc: stable@dpdk.org Signed-off-by: Pavan Nikhilesh Signed-off-by: David Marchand --- app/test/test_common.c | 6 ++++++ drivers/net/e1000/e1000_ethdev.h | 7 ++++--- drivers/net/ixgbe/ixgbe_ethdev.h | 6 ++++-- drivers/net/mlx5/mlx5_rxtx_vec.h | 7 ++++--- drivers/net/txgbe/txgbe_ethdev.h | 6 ++++-- lib/eal/include/rte_common.h | 17 +++++++++++++---- lib/ethdev/rte_eth_ctrl.h | 5 +++-- 7 files changed, 38 insertions(+), 16 deletions(-) diff --git a/app/test/test_common.c b/app/test/test_common.c index 0dbb87e741..9efe3b10f9 100644 --- a/app/test/test_common.c +++ b/app/test/test_common.c @@ -69,6 +69,12 @@ test_macros(int __rte_unused unused_parm) TEST_SIDE_EFFECT_2(RTE_PTR_ADD, void *, size_t); TEST_SIDE_EFFECT_2(RTE_PTR_DIFF, void *, void *); TEST_SIDE_EFFECT_2(RTE_PTR_SUB, void *, size_t); + TEST_SIDE_EFFECT_2(RTE_PTR_ALIGN, void *, size_t); + TEST_SIDE_EFFECT_2(RTE_PTR_ALIGN_CEIL, void *, size_t); + TEST_SIDE_EFFECT_2(RTE_PTR_ALIGN_FLOOR, void *, size_t); + TEST_SIDE_EFFECT_2(RTE_ALIGN, unsigned int, unsigned int); + TEST_SIDE_EFFECT_2(RTE_ALIGN_CEIL, unsigned int, unsigned int); + TEST_SIDE_EFFECT_2(RTE_ALIGN_FLOOR, unsigned int, unsigned int); TEST_SIDE_EFFECT_2(RTE_ALIGN_MUL_CEIL, unsigned int, unsigned int); TEST_SIDE_EFFECT_2(RTE_ALIGN_MUL_FLOOR, unsigned int, unsigned int); TEST_SIDE_EFFECT_2(RTE_ALIGN_MUL_NEAR, unsigned int, unsigned int); diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h index 3b4d9c3ee6..155d825d89 100644 --- a/drivers/net/e1000/e1000_ethdev.h +++ b/drivers/net/e1000/e1000_ethdev.h @@ -332,9 +332,10 @@ struct igb_eth_syn_filter_ele { }; #define IGB_FLEX_FILTER_MAXLEN 128 /**< bytes to use in flex filter. */ -#define IGB_FLEX_FILTER_MASK_SIZE \ - (RTE_ALIGN(IGB_FLEX_FILTER_MAXLEN, CHAR_BIT) / CHAR_BIT) - /**< mask bytes in flex filter. */ +#define IGB_FLEX_FILTER_MASK_SIZE \ + (RTE_ALIGN_FLOOR(IGB_FLEX_FILTER_MAXLEN + (CHAR_BIT - 1), CHAR_BIT) / \ + CHAR_BIT) +/**< mask bytes in flex filter. */ /** * A structure used to define the flex filter entry diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index a0ce18ca24..f2f8b943d2 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -311,8 +311,10 @@ struct ixgbe_5tuple_filter { uint16_t queue; /* rx queue assigned to */ }; -#define IXGBE_5TUPLE_ARRAY_SIZE \ - (RTE_ALIGN(IXGBE_MAX_FTQF_FILTERS, (sizeof(uint32_t) * NBBY)) / \ +#define IXGBE_5TUPLE_ARRAY_SIZE \ + (RTE_ALIGN_FLOOR(IXGBE_MAX_FTQF_FILTERS + (sizeof(uint32_t) * NBBY) - \ + 1, \ + (sizeof(uint32_t) * NBBY)) / \ (sizeof(uint32_t) * NBBY)) struct ixgbe_ethertype_filter { diff --git a/drivers/net/mlx5/mlx5_rxtx_vec.h b/drivers/net/mlx5/mlx5_rxtx_vec.h index 93b4f517bb..5d105db474 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec.h @@ -42,8 +42,8 @@ S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, hash) == S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, ol_flags) == offsetof(struct rte_mbuf, rearm_data) + 8); S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, rearm_data) == - RTE_ALIGN(offsetof(struct rte_mbuf, rearm_data), 16)); - + RTE_ALIGN_FLOOR(offsetof(struct rte_mbuf, rearm_data) + 15, + 16)); /* rxq_burst_v() */ S_ASSERT_RTE_MBUF(offsetof(struct rte_mbuf, pkt_len) == offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4); @@ -63,7 +63,8 @@ S_ASSERT_MLX5_CQE(offsetof(struct mlx5_cqe, vlan_info) == S_ASSERT_MLX5_CQE(offsetof(struct mlx5_cqe, lro_num_seg) + 12 == offsetof(struct mlx5_cqe, byte_cnt)); S_ASSERT_MLX5_CQE(offsetof(struct mlx5_cqe, sop_drop_qpn) == - RTE_ALIGN(offsetof(struct mlx5_cqe, sop_drop_qpn), 8)); + RTE_ALIGN_FLOOR(offsetof(struct mlx5_cqe, sop_drop_qpn) + 7, + 8)); S_ASSERT_MLX5_CQE(offsetof(struct mlx5_cqe, op_own) == offsetof(struct mlx5_cqe, sop_drop_qpn) + 7); diff --git a/drivers/net/txgbe/txgbe_ethdev.h b/drivers/net/txgbe/txgbe_ethdev.h index 3021933965..05537b34c7 100644 --- a/drivers/net/txgbe/txgbe_ethdev.h +++ b/drivers/net/txgbe/txgbe_ethdev.h @@ -219,8 +219,10 @@ struct txgbe_5tuple_filter { uint16_t queue; /* rx queue assigned to */ }; -#define TXGBE_5TUPLE_ARRAY_SIZE \ - (RTE_ALIGN(TXGBE_MAX_FTQF_FILTERS, (sizeof(uint32_t) * NBBY)) / \ +#define TXGBE_5TUPLE_ARRAY_SIZE \ + (RTE_ALIGN_FLOOR(TXGBE_MAX_FTQF_FILTERS + (sizeof(uint32_t) * NBBY) - \ + 1, \ + (sizeof(uint32_t) * NBBY)) / \ (sizeof(uint32_t) * NBBY)) struct txgbe_ethertype_filter { diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index a142596587..6acd067b5c 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -294,8 +294,13 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) * point to an address no lower than the first parameter. Second parameter * must be a power-of-two value. */ -#define RTE_PTR_ALIGN_CEIL(ptr, align) \ - RTE_PTR_ALIGN_FLOOR((typeof(ptr))RTE_PTR_ADD(ptr, (align) - 1), align) +#define RTE_PTR_ALIGN_CEIL(ptr, align) \ + __extension__({ \ + typeof(ptr) _pc = (ptr); \ + typeof(align) _ac = (align); \ + RTE_PTR_ALIGN_FLOOR((typeof(ptr))RTE_PTR_ADD(_pc, _ac - 1), \ + _ac); \ + }) /** * Macro to align a value to a given power-of-two. The resultant value @@ -303,8 +308,12 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) * than the first parameter. Second parameter must be a power-of-two * value. */ -#define RTE_ALIGN_CEIL(val, align) \ - RTE_ALIGN_FLOOR(((val) + ((typeof(val)) (align) - 1)), align) +#define RTE_ALIGN_CEIL(val, align) \ + __extension__({ \ + typeof(val) _vc = (val); \ + typeof(val) _ac = (typeof(val))(align); \ + RTE_ALIGN_FLOOR((_vc + _ac - 1), _ac); \ + }) /** * Macro to align a pointer to a given power-of-two. The resultant diff --git a/lib/ethdev/rte_eth_ctrl.h b/lib/ethdev/rte_eth_ctrl.h index 42652f9cce..863e56170b 100644 --- a/lib/ethdev/rte_eth_ctrl.h +++ b/lib/ethdev/rte_eth_ctrl.h @@ -431,8 +431,9 @@ enum rte_fdir_mode { }; #define UINT64_BIT (CHAR_BIT * sizeof(uint64_t)) -#define RTE_FLOW_MASK_ARRAY_SIZE \ - (RTE_ALIGN(RTE_ETH_FLOW_MAX, UINT64_BIT)/UINT64_BIT) +#define RTE_FLOW_MASK_ARRAY_SIZE \ + (RTE_ALIGN_FLOOR(RTE_ETH_FLOW_MAX + (UINT64_BIT - 1), UINT64_BIT) / \ + UINT64_BIT) /** * A structure used to get the information of flow director filter. -- 2.17.1