DPDK patches and discussions
 help / color / mirror / Atom feed
From: Srujana Challa <schalla@marvell.com>
To: David Marchand <david.marchand@redhat.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	"maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>,
	"chenbox@nvidia.com" <chenbox@nvidia.com>,
	Jerin Jacob <jerinj@marvell.com>,
	Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>,
	Vamsi Krishna Attunuru <vattunuru@marvell.com>
Subject: RE: [EXTERNAL] Re: [PATCH v2] net/virtio_user: fix issue with converting cq descriptor IOVA address to VA
Date: Thu, 11 Jul 2024 17:46:07 +0000	[thread overview]
Message-ID: <DS0PR18MB53681B2533173ADB9258050DA0A52@DS0PR18MB5368.namprd18.prod.outlook.com> (raw)
In-Reply-To: <CAJFAV8xYe-tF4E=B6BfT5FazKAUmFw_Us7eQQdW61oPRAxjPRA@mail.gmail.com>

> On Thu, Jul 11, 2024 at 2:44 PM Srujana Challa <schalla@marvell.com> wrote:
> >
> > This patch modifies the code to convert descriptor buffer IOVA
> > addresses to virtual addresses only when use_va flag is false.
> >
> > This patch resolves a segmentation fault with the vhost-user backend
> > that occurs during the processing of the shadow control queue.
> >
> > 'Fixes: 67e9e504dae2 ("net/virtio_user: convert cq descriptor IOVA
> > address to Virtual address")'
> 
> No single quote around the Fixes: tag, and on a single line please.
Ack
> 
> As for the title, how about: "net/virtio_user: fix cq descriptor conversion with
> non vDPA backend" ?
Ack
> 
> >
> > Reported-by: David Marchand <david.marchand@redhat.com>
> > Signed-off-by: Srujana Challa <schalla@marvell.com>
> > ---
> > v2:
> > - Added Reported-by tag.
> >
> >  .../net/virtio/virtio_user/virtio_user_dev.c  | 28
> > +++++++++++--------
> >  1 file changed, 16 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > index fed66d2ae9..94e0ddcb94 100644
> > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > @@ -905,12 +905,12 @@ virtio_user_handle_mq(struct virtio_user_dev
> > *dev, uint16_t q_pairs)  #define CVQ_MAX_DATA_DESCS 32
> >
> >  static inline void *
> > -virtio_user_iova2virt(rte_iova_t iova)
> > +virtio_user_iova2virt(rte_iova_t iova, bool use_va)
> 
> All the code in this file passes the virtio_user_dev object, please keep this
> convention.
Ack
> 
> IOW:
> -virtio_user_iova2virt(rte_iova_t iova)
> +virtio_user_iova2virt(struct virtio_user_dev *dev, rte_iova_t iova)
> 
> >  {
> > -       if (rte_eal_iova_mode() == RTE_IOVA_VA)
> > -               return (void *)(uintptr_t)iova;
> > -       else
> > +       if (rte_eal_iova_mode() == RTE_IOVA_PA && !use_va)
> >                 return rte_mem_iova2virt(iova);
> > +       else
> > +               return (void *)(uintptr_t)iova;
> 
> Why do we need to invert this test?
Made this change to ensure that rte_mem_iova2virt() is not called when the IOVA mode is RTE_IOVA_DC
by any chance.
> 
> I would make the change as simple as:
> -       if (rte_eal_iova_mode() == RTE_IOVA_VA)
> +       if (rte_eal_iova_mode() == RTE_IOVA_VA || dev->hw.use_va)
> 
> 
> >  }
> >
> >  static uint32_t
> > @@ -922,6 +922,7 @@ virtio_user_handle_ctrl_msg_split(struct
> virtio_user_dev *dev, struct vring *vri
> >         uint16_t i, idx_data, idx_status;
> >         uint32_t n_descs = 0;
> >         int dlen[CVQ_MAX_DATA_DESCS], nb_dlen = 0;
> > +       bool use_va = dev->hw.use_va;
> >
> >         /* locate desc for header, data, and status */
> >         idx_data = vring->desc[idx_hdr].next; @@ -938,18 +939,18 @@
> > virtio_user_handle_ctrl_msg_split(struct virtio_user_dev *dev, struct vring
> *vri
> >         idx_status = i;
> >         n_descs++;
> >
> > -       hdr = virtio_user_iova2virt(vring->desc[idx_hdr].addr);
> > +       hdr = virtio_user_iova2virt(vring->desc[idx_hdr].addr,
> > + use_va);
> >         if (hdr->class == VIRTIO_NET_CTRL_MQ &&
> >             hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
> >                 uint16_t queues, *addr;
> >
> > -               addr = virtio_user_iova2virt(vring->desc[idx_data].addr);
> > +               addr =
> > + virtio_user_iova2virt(vring->desc[idx_data].addr, use_va);
> >                 queues = *addr;
> >                 status = virtio_user_handle_mq(dev, queues);
> >         } else if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd ==
> VIRTIO_NET_CTRL_MQ_RSS_CONFIG) {
> >                 struct virtio_net_ctrl_rss *rss;
> >
> > -               rss = virtio_user_iova2virt(vring->desc[idx_data].addr);
> > +               rss =
> > + virtio_user_iova2virt(vring->desc[idx_data].addr, use_va);
> >                 status = virtio_user_handle_mq(dev, rss->max_tx_vq);
> >         } else if (hdr->class == VIRTIO_NET_CTRL_RX  ||
> >                    hdr->class == VIRTIO_NET_CTRL_MAC || @@ -962,7
> > +963,8 @@ virtio_user_handle_ctrl_msg_split(struct virtio_user_dev *dev,
> struct vring *vri
> >                                 (struct virtio_pmd_ctrl *)hdr, dlen,
> > nb_dlen);
> >
> >         /* Update status */
> > -       *(virtio_net_ctrl_ack *)virtio_user_iova2virt(vring-
> >desc[idx_status].addr) = status;
> > +       *(virtio_net_ctrl_ack *)
> > +               virtio_user_iova2virt(vring->desc[idx_status].addr,
> > + use_va) = status;
> 
> Afaics, no need for reindenting.
It crossed 100 line boundary actually.
> 
> >
> >         return n_descs;
> >  }
> > @@ -987,6 +989,7 @@ virtio_user_handle_ctrl_msg_packed(struct
> virtio_user_dev *dev,
> >         /* initialize to one, header is first */
> >         uint32_t n_descs = 1;
> >         int dlen[CVQ_MAX_DATA_DESCS], nb_dlen = 0;
> > +       bool use_va = dev->hw.use_va;
> >
> >         /* locate desc for header, data, and status */
> >         idx_data = idx_hdr + 1;
> > @@ -1004,18 +1007,18 @@ virtio_user_handle_ctrl_msg_packed(struct
> virtio_user_dev *dev,
> >                 n_descs++;
> >         }
> >
> > -       hdr = virtio_user_iova2virt(vring->desc[idx_hdr].addr);
> > +       hdr = virtio_user_iova2virt(vring->desc[idx_hdr].addr,
> > + use_va);
> >         if (hdr->class == VIRTIO_NET_CTRL_MQ &&
> >             hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
> >                 uint16_t queues, *addr;
> >
> > -               addr = virtio_user_iova2virt(vring->desc[idx_data].addr);
> > +               addr =
> > + virtio_user_iova2virt(vring->desc[idx_data].addr, use_va);
> >                 queues = *addr;
> >                 status = virtio_user_handle_mq(dev, queues);
> >         } else if (hdr->class == VIRTIO_NET_CTRL_MQ && hdr->cmd ==
> VIRTIO_NET_CTRL_MQ_RSS_CONFIG) {
> >                 struct virtio_net_ctrl_rss *rss;
> >
> > -               rss = virtio_user_iova2virt(vring->desc[idx_data].addr);
> > +               rss =
> > + virtio_user_iova2virt(vring->desc[idx_data].addr, use_va);
> >                 status = virtio_user_handle_mq(dev, rss->max_tx_vq);
> >         } else if (hdr->class == VIRTIO_NET_CTRL_RX  ||
> >                    hdr->class == VIRTIO_NET_CTRL_MAC || @@ -1028,7
> > +1031,8 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev
> *dev,
> >                                 (struct virtio_pmd_ctrl *)hdr, dlen,
> > nb_dlen);
> >
> >         /* Update status */
> > -       *(virtio_net_ctrl_ack *)virtio_user_iova2virt(vring-
> >desc[idx_status].addr) = status;
> > +       *(virtio_net_ctrl_ack *)
> > +               virtio_user_iova2virt(vring->desc[idx_status].addr,
> > + use_va) = status;
> 
> Idem, no reindenting.
> 
> >
> >         /* Update used descriptor */
> >         vring->desc[idx_hdr].id = vring->desc[idx_status].id;
> > --
> > 2.25.1
> >
> 
> 
> --
> David Marchand


  reply	other threads:[~2024-07-11 17:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-11 12:44 Srujana Challa
2024-07-11 15:02 ` David Marchand
2024-07-11 17:46   ` Srujana Challa [this message]
2024-07-12  7:57     ` [EXTERNAL] " David Marchand
2024-07-12 11:30     ` David Marchand
2024-07-12 11:51       ` Srujana Challa
2024-07-12 12:36 ` [PATCH v3] net/virtio_user: fix cq descriptor conversion with non vDPA backend Srujana Challa
2024-07-12 14:24   ` David Marchand

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=DS0PR18MB53681B2533173ADB9258050DA0A52@DS0PR18MB5368.namprd18.prod.outlook.com \
    --to=schalla@marvell.com \
    --cc=chenbox@nvidia.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=ndabilpuram@marvell.com \
    --cc=vattunuru@marvell.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).