DPDK patches and discussions
 help / color / mirror / Atom feed
From: Michal Krawczyk <mk@semihalf.com>
To: Marcin Wojtas <mw@semihalf.com>,
	Michal Krawczyk <mk@semihalf.com>,
	Guy Tzalik <gtzalik@amazon.com>,
	Evgeny Schemeilin <evgenys@amazon.com>
Cc: dev@dpdk.org, matua@amazon.com, Rafal Kozik <rk@semihalf.com>
Subject: [dpdk-dev] [PATCH v1 24/24] net/ena: fix GENMASK_ULL macro
Date: Wed,  9 May 2018 14:47:14 +0200	[thread overview]
Message-ID: <20180509124714.23305-15-mk@semihalf.com> (raw)
In-Reply-To: <20180509124714.23305-1-mk@semihalf.com>

From: Rafal Kozik <rk@semihalf.com>

When use GENMASK_ULL(63,0) left shift by 64 bits is performed.
Shifting by number greater or equal then word length
is undefined operation and failed on some platforms.

Fixes: 9ba7981ec992 ("ena: add communication layer for DPDK")

Signed-off-by: Rafal Kozik <rk@semihalf.com>
Acked-by: Michal Krawczyk <mk@semihalf.com>
---
 drivers/net/ena/base/ena_plat_dpdk.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index b89cdb55d..58ef57d2b 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -116,11 +116,13 @@ typedef uint64_t dma_addr_t;
 #define ENA_MIN16(x, y) RTE_MIN((x), (y))
 #define ENA_MIN8(x, y) RTE_MIN((x), (y))

+#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8)
 #define U64_C(x) x ## ULL
 #define BIT(nr)         (1UL << (nr))
 #define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l)	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
-#define GENMASK_ULL(h, l) (((U64_C(1) << ((h) - (l) + 1)) - 1) << (l))
+#define GENMASK_ULL(h, l) (((~0ULL) - (1ULL << (l)) + 1) & \
+			  (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))

 #ifdef RTE_LIBRTE_ENA_COM_DEBUG
 #define ena_trc_dbg(format, arg...)					\
--
2.14.1

      parent reply	other threads:[~2018-05-09 12:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-09 12:47 [dpdk-dev] [PATCH v1 10/24] net/ena: add watchdog and keep alive AENQ handler Michal Krawczyk
2018-05-09 12:47 ` [dpdk-dev] [PATCH v1 11/24] net/ena: add checking for admin queue state Michal Krawczyk
2018-05-09 12:47 ` [dpdk-dev] [PATCH v1 12/24] net/ena: make watchdog configurable Michal Krawczyk
2018-05-09 12:47 ` [dpdk-dev] [PATCH v1 13/24] net/ena: add RX out of order completion Michal Krawczyk
2018-05-09 12:47 ` [dpdk-dev] [PATCH v1 14/24] net/ena: linearize Tx mbuf Michal Krawczyk
2018-05-09 12:47 ` [dpdk-dev] [PATCH v1 15/24] net/ena: add info about max number of Tx/Rx descriptors Michal Krawczyk
2018-05-09 12:47 ` [dpdk-dev] [PATCH v1 16/24] net/ena: unimplemented handler error Michal Krawczyk
2018-05-09 12:47 ` [dpdk-dev] [PATCH v1 17/24] net/ena: rework configuration of IO queue numbers Michal Krawczyk
2018-05-09 12:47 ` [dpdk-dev] [PATCH v1 18/24] net/ena: validate Tx req id Michal Krawczyk
2018-05-09 12:47 ` [dpdk-dev] [PATCH v1 19/24] net/ena: add (un)likely statements Michal Krawczyk
2018-05-09 12:47 ` [dpdk-dev] [PATCH v1 20/24] net/ena: adjust error checking and cleaning Michal Krawczyk
2018-05-09 12:47 ` [dpdk-dev] [PATCH v1 21/24] net/ena: update numa node Michal Krawczyk
2018-05-09 12:47 ` [dpdk-dev] [PATCH v1 22/24] net/ena: check pointer before memset Michal Krawczyk
2018-05-09 12:47 ` [dpdk-dev] [PATCH v1 23/24] net/ena: change memory type Michal Krawczyk
2018-05-09 12:47 ` Michal Krawczyk [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180509124714.23305-15-mk@semihalf.com \
    --to=mk@semihalf.com \
    --cc=dev@dpdk.org \
    --cc=evgenys@amazon.com \
    --cc=gtzalik@amazon.com \
    --cc=matua@amazon.com \
    --cc=mw@semihalf.com \
    --cc=rk@semihalf.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).