From: Andrew Rybchenko <arybchenko@solarflare.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>,
Thomas Monjalon <thomas@monjalon.net>
Cc: <dev@dpdk.org>, Renata Saiakhova <renata.saiakhova@ekinops.com>,
"Anatoly Burakov" <anatoly.burakov@intel.com>
Subject: Re: [dpdk-dev] [PATCH] ethdev: verify reserved HW ring
Date: Tue, 23 Jun 2020 19:58:24 +0300 [thread overview]
Message-ID: <7439ff00-012f-bce4-b289-17770c994de4@solarflare.com> (raw)
In-Reply-To: <20200623164111.1939144-1-ferruh.yigit@intel.com>
On 6/23/20 7:41 PM, Ferruh Yigit wrote:
> Function 'rte_eth_dma_zone_reserve()' returns an existing memzone based
> on name match, but other requested attributes are discarded.
> This may cause driver using a memzone with wrong size or alignment.
>
> Verify size, alignment and socket_id for matched memzone, and do not use
> memzone if any one of the attributes are not justified.
>
> Reported-by: Renata Saiakhova <renata.saiakhova@ekinops.com>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Few minor notes below, other than that:
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
> ---
> Cc: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
> lib/librte_ethdev/rte_ethdev.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
> index 8e10a6fc3..0fe84aadc 100644
> --- a/lib/librte_ethdev/rte_ethdev.c
> +++ b/lib/librte_ethdev/rte_ethdev.c
> @@ -4202,8 +4202,18 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,
> }
>
> mz = rte_memzone_lookup(z_name);
> - if (mz)
> + if (mz) {
> + if ((socket_id != SOCKET_ID_ANY && socket_id != mz->socket_id) ||
> + size > mz->len ||
> + (uintptr_t)mz->addr & (align - 1)) {
IMHO, it would be a bit more readable if the result compared
with 0. Up to you.
> + RTE_ETHDEV_LOG(ERR,
> + "memzone %s does not justify the requested attributes\n",
> + mz->name);
> + return NULL;
Initially I thought it is a bad behaviour and memzone should
be freed and reallocated, but it is even worse (implicit free).
May be it is better to highlight it in the description.
> + }
> +
> return mz;
> + }
>
> return rte_memzone_reserve_aligned(z_name, size, socket_id,
> RTE_MEMZONE_IOVA_CONTIG, align);
>
next prev parent reply other threads:[~2020-06-23 16:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 16:41 Ferruh Yigit
2020-06-23 16:58 ` Andrew Rybchenko [this message]
2020-06-24 7:24 ` Ferruh Yigit
2020-06-24 9:35 ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
2020-07-08 18:14 ` Ferruh Yigit
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=7439ff00-012f-bce4-b289-17770c994de4@solarflare.com \
--to=arybchenko@solarflare.com \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=renata.saiakhova@ekinops.com \
--cc=thomas@monjalon.net \
/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).