From: Paul Durrant <Paul.Durrant@citrix.com>
To: 'Juergen Gross' <jgross@suse.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Cc: "sstabellini@kernel.org" <sstabellini@kernel.org>,
Wei Liu <wei.liu2@citrix.com>,
Andrew Cooper <Andrew.Cooper3@citrix.com>,
"Tim (Xen.org)" <tim@xen.org>,
George Dunlap <George.Dunlap@citrix.com>,
"julien.grall@arm.com" <julien.grall@arm.com>,
"jbeulich@suse.com" <jbeulich@suse.com>,
Ian Jackson <Ian.Jackson@citrix.com>,
"dgdegra@tycho.nsa.gov" <dgdegra@tycho.nsa.gov>
Subject: Re: [PATCH v6 01/12] xen: correct gnttab_get_status_frames()
Date: Wed, 13 Sep 2017 17:36:34 +0000 [thread overview]
Message-ID: <30d9e0c2122a41fd82e3b25e6e6a77d7@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <5599ada3-b909-b6f6-eef3-17f1934160fe@suse.com>
> -----Original Message-----
> From: Juergen Gross [mailto:jgross@suse.com]
> Sent: 13 September 2017 09:58
> To: Paul Durrant <Paul.Durrant@citrix.com>; xen-devel@lists.xen.org
> Cc: sstabellini@kernel.org; Wei Liu <wei.liu2@citrix.com>; George Dunlap
> <George.Dunlap@citrix.com>; Andrew Cooper
> <Andrew.Cooper3@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Tim
> (Xen.org) <tim@xen.org>; julien.grall@arm.com; jbeulich@suse.com;
> dgdegra@tycho.nsa.gov
> Subject: Re: [Xen-devel] [PATCH v6 01/12] xen: correct
> gnttab_get_status_frames()
>
> On 13/09/17 18:01, Paul Durrant wrote:
> >> -----Original Message-----
> >> From: Xen-devel [mailto:xen-devel-bounces@lists.xen.org] On Behalf Of
> >> Juergen Gross
> >> Sent: 13 September 2017 08:47
> >> To: xen-devel@lists.xen.org
> >> Cc: Juergen Gross <jgross@suse.com>; sstabellini@kernel.org; Wei Liu
> >> <wei.liu2@citrix.com>; George Dunlap <George.Dunlap@citrix.com>;
> >> Andrew Cooper <Andrew.Cooper3@citrix.com>; Ian Jackson
> >> <Ian.Jackson@citrix.com>; Tim (Xen.org) <tim@xen.org>;
> >> julien.grall@arm.com; jbeulich@suse.com; dgdegra@tycho.nsa.gov
> >> Subject: [Xen-devel] [PATCH v6 01/12] xen: correct
> >> gnttab_get_status_frames()
> >>
> >> In gnttab_get_status_frames() all accesses to nr_status_frames should
> >> be done with the grant table lock held.
> >
> > Is this true? The value can only increase so what does the increase lock
> scope actually protect against?
>
> The comment above nr_status_frames() says so. Either the comment or the
> code is wrong.
Ok. I suspect that was cut'n'paste from nr_grant_fames() but I see no particular harm in the increased scope since it's a read lock.
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
>
>
> Juergen
>
> >
> > Paul
> >
> >>
> >> While at it correct coding style: labels should be indented by one
> >> space.
> >>
> >> Signed-off-by: Juergen Gross <jgross@suse.com>
> >> ---
> >> xen/common/grant_table.c | 15 ++++++++-------
> >> 1 file changed, 8 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
> >> index c3895e6201..00ff075bd9 100644
> >> --- a/xen/common/grant_table.c
> >> +++ b/xen/common/grant_table.c
> >> @@ -2866,19 +2866,19 @@
> >>
> gnttab_get_status_frames(XEN_GUEST_HANDLE_PARAM(gnttab_get_statu
> >> s_frames_t) uop,
> >>
> >> gt = d->grant_table;
> >>
> >> + op.status = GNTST_okay;
> >> +
> >> + grant_read_lock(gt);
> >> +
> >> if ( unlikely(op.nr_frames > nr_status_frames(gt)) )
> >> {
> >> gdprintk(XENLOG_INFO, "Guest requested addresses for %d grant
> >> status "
> >> "frames, but only %d are available.\n",
> >> op.nr_frames, nr_status_frames(gt));
> >> op.status = GNTST_general_error;
> >> - goto out2;
> >> + goto unlock;
> >> }
> >>
> >> - op.status = GNTST_okay;
> >> -
> >> - grant_read_lock(gt);
> >> -
> >> for ( i = 0; i < op.nr_frames; i++ )
> >> {
> >> gmfn = gnttab_status_gmfn(d, gt, i);
> >> @@ -2886,10 +2886,11 @@
> >>
> gnttab_get_status_frames(XEN_GUEST_HANDLE_PARAM(gnttab_get_statu
> >> s_frames_t) uop,
> >> op.status = GNTST_bad_virt_addr;
> >> }
> >>
> >> + unlock:
> >> grant_read_unlock(gt);
> >> -out2:
> >> + out2:
> >> rcu_unlock_domain(d);
> >> -out1:
> >> + out1:
> >> if ( unlikely(__copy_field_to_guest(uop, &op, status)) )
> >> return -EFAULT;
> >>
> >> --
> >> 2.12.3
> >>
> >>
> >> _______________________________________________
> >> Xen-devel mailing list
> >> Xen-devel@lists.xen.org
> >> https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-09-13 17:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20170913154651.2366-1-jgross@suse.com>
[not found] ` <20170913154651.2366-2-jgross@suse.com>
2017-09-13 16:01 ` [PATCH v6 01/12] xen: correct gnttab_get_status_frames() Paul Durrant
2017-09-13 16:58 ` Juergen Gross
2017-09-13 17:36 ` Paul Durrant [this message]
2017-09-18 15:02 ` Wei Liu
[not found] ` <20170913154651.2366-5-jgross@suse.com>
2017-09-13 17:32 ` [PATCH v6 04/12] xen: add new domctl hypercall to set grant table resource limits Daniel De Graaf
[not found] ` <20170913154651.2366-10-jgross@suse.com>
2017-09-14 5:41 ` [PATCH v6 09/12] xen: delay allocation of grant table sub structures Juergen Gross
[not found] ` <20170913154651.2366-12-jgross@suse.com>
2017-09-14 5:42 ` [PATCH v6 11/12] xen: make grant resource limits per domain Juergen Gross
[not found] ` <20170913154651.2366-3-jgross@suse.com>
2017-09-14 17:20 ` [PATCH v6 02/12] xen: move XENMAPSPACE_grant_table code into grant_table.c Julien Grall
2017-09-15 7:25 ` Juergen Gross
[not found] ` <20170913154651.2366-11-jgross@suse.com>
2017-09-14 17:31 ` [PATCH v6 10/12] xen/arm: move arch specific grant table bits " Julien Grall
2017-09-15 7:22 ` Juergen Gross
2017-09-15 8:49 ` Julien Grall
2017-09-15 9:21 ` Juergen Gross
[not found] ` <20170913154651.2366-7-jgross@suse.com>
2017-09-18 15:22 ` [PATCH v6 06/12] tools: set grant limits for xenstore stubdom Wei Liu
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=30d9e0c2122a41fd82e3b25e6e6a77d7@AMSPEX02CL03.citrite.net \
--to=paul.durrant@citrix.com \
--cc=Andrew.Cooper3@citrix.com \
--cc=George.Dunlap@citrix.com \
--cc=Ian.Jackson@citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=jbeulich@suse.com \
--cc=jgross@suse.com \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.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).