From: "Michael S. Tsirkin" <mst@redhat.com>
To: Eli Cohen <elic@nvidia.com>
Cc: lvivier@redhat.com, virtualization@lists.linux-foundation.org,
eperezma@redhat.com, si-wei.liu@oracle.com
Subject: Re: [PATCH 1/4] vdpa: Protect vdpa reset with cf_mutex
Date: Tue, 11 Jan 2022 11:36:02 -0500 [thread overview]
Message-ID: <20220111112941-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20220111161238.GA168233@mtl-vdi-166.wap.labs.mlnx>
On Tue, Jan 11, 2022 at 06:12:38PM +0200, Eli Cohen wrote:
> On Tue, Jan 11, 2022 at 11:01:01AM -0500, Michael S. Tsirkin wrote:
> > On Tue, Jan 11, 2022 at 09:22:17AM +0200, Eli Cohen wrote:
> > > Call reset using the wrapper function vdpa_reset() to make sure the
> > > operation is serialized with cf_mutex.
> > >
> > > Signed-off-by: Eli Cohen <elic@nvidia.com>
> >
> > The motivation is vague here, this does not really explain.
> > Which operations are we trying to serialize?
> > Multiple reset requests from userspace?
> > Is anything broken right now without this patch?
>
> vdpa_reset will reset the features which can be read or even be set
> through devlink (see vdpa_get_config_unlocked()). So this lock ensures
> serialization of the operations to ensure consitent value is read.
My point is that this is the kind of thing that needs to go into commit log.
A good log for a bugfix looks like this:
if XYZ triggers a vdpa reset while ABC is reading the features through
devlink, with the result that EFG. Similarly for write which can lead
to HIJ.
Fix this by calling reset using the wrapper function vdpa_reset() to make sure the
operation is serialized with cf_mutex.
Fixes: <hash> ("subject")
> >
> > > ---
> > > drivers/vhost/vdpa.c | 3 +--
> > > 1 file changed, 1 insertion(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> > > index 6e7edaf2472b..fe0bbea4dab6 100644
> > > --- a/drivers/vhost/vdpa.c
> > > +++ b/drivers/vhost/vdpa.c
> > > @@ -155,7 +155,6 @@ static long vhost_vdpa_get_status(struct vhost_vdpa *v, u8 __user *statusp)
> > > static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
> > > {
> > > struct vdpa_device *vdpa = v->vdpa;
> > > - const struct vdpa_config_ops *ops = vdpa->config;
> > > u8 status, status_old;
> > > int ret, nvqs = v->nvqs;
> > > u16 i;
> > > @@ -177,7 +176,7 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
> > > vhost_vdpa_unsetup_vq_irq(v, i);
> > >
> > > if (status == 0) {
> > > - ret = ops->reset(vdpa);
> > > + ret = vdpa_reset(vdpa);
> > > if (ret)
> > > return ret;
> > > } else
> > > --
> > > 2.34.1
> >
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
prev parent reply other threads:[~2022-01-11 16:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220111072217.101836-1-elic@nvidia.com>
2022-01-11 9:27 ` [PATCH 1/4] vdpa: Protect vdpa reset with cf_mutex Si-Wei Liu
2022-01-11 16:01 ` Michael S. Tsirkin
[not found] ` <20220111161238.GA168233@mtl-vdi-166.wap.labs.mlnx>
2022-01-11 16:36 ` Michael S. Tsirkin [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=20220111112941-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=elic@nvidia.com \
--cc=eperezma@redhat.com \
--cc=lvivier@redhat.com \
--cc=si-wei.liu@oracle.com \
--cc=virtualization@lists.linux-foundation.org \
/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).