From: Daniel De Graaf <dgdegra@tycho.nsa.gov>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: jeremy@goop.org, xen-devel@lists.xensource.com, Ian.Campbell@citrix.com
Subject: Re: [PATCH v6] Userspace grant communication
Date: Mon, 14 Feb 2011 12:55:36 -0500 [thread overview]
Message-ID: <4D596C98.4090401@tycho.nsa.gov> (raw)
In-Reply-To: <20110214161403.GB11034@dumpdata.com>
On 02/14/2011 11:14 AM, Konrad Rzeszutek Wilk wrote:
> On Thu, Feb 03, 2011 at 12:18:58PM -0500, Daniel De Graaf wrote:
>> Changes since v5:
>> - Added a tested xen version to workaround in #4
>> - Cleaned up variable names & structures
>> - Clarified some of the cleanup in gntalloc
>> - Removed copyright statement from public-domain files
>>
>> [PATCH 1/6] xen-gntdev: Change page limit to be global instead of per-open
>> [PATCH 2/6] xen-gntdev: Use find_vma rather than iterating our vma list manually
>> [PATCH 3/6] xen-gntdev: Add reference counting to maps
>> [PATCH 4/6] xen-gntdev: Support mapping in HVM domains
>> [PATCH 5/6] xen-gntalloc: Userspace grant allocation driver
>> [PATCH 6/6] xen/gntalloc,gntdev: Add unmap notify ioctl
>
> Hey Daniel,
>
> I took a look at the patchset and then the bug-fixes:
>
> Daniel De Graaf (12):
> xen-gntdev: Change page limit to be global instead of per-open
> xen-gntdev: Use find_vma rather than iterating our vma list manually
> xen-gntdev: Add reference counting to maps
> xen-gntdev: Support mapping in HVM domains
> xen-gntalloc: Userspace grant allocation driver
> xen/gntalloc,gntdev: Add unmap notify ioctl
> xen-gntdev: Fix memory leak when mmap fails
> xen-gntdev: Fix unmap notify on PV domains
> xen-gntdev: Use map->vma for checking map validity
> xen-gntdev: Avoid unmapping ranges twice
> xen-gntdev: prevent using UNMAP_NOTIFY_CLEAR_BYTE on read-only mappings
> xen-gntdev: Avoid double-mapping memory
>
>
> And besides the two questions I posted today they look OK to me. However
> I have on question that I think points to a bug.
>
> Say that I call GNTDEV_MAP_GRANT_REF three times. The first time I provide
> a count of 4, then 1, and then once more 1.
>
> The first call would end up with priv having:
>
> priv-map[0] => map.count=4, map.user=1, map.index=0. We return op.index as 0.
>
> The next call:
>
> priv-map[0] => map.count=4, map.user=1, map.index=0.
> priv-map[1] => map.count=1, map.user=1, map.index=5 (gntdev_add_map
> ends up adding the index and the count from the previous map to it). We return op.index as 20480.
>
I think this will come out with map.index=4, op.index=8192, since the only
entry in priv->maps has map->index = 0 and map->count = 4.
> The last call ends up with
> priv-map[0] => map.count=4, map.user=1, map.index=0.
> priv-map[1] => map.count=1, map.user=1, map.index=5
> priv-map[2] => map.count=1, map.user=1, map.index=0. And we return
> op.index as = 0.
>
How do we return that? The "goto done" branch should not be taken unless there is
a hole in the existing priv->maps list created by a previous deletion.
I see add->index starting at 0, then set to 4 and then 5, its final value.
> It looks as gntdev_add_map ends does not do anything to the
> map.index if the "if (add->index + add->count < map->index)" comes
> out true, and we end up with op.index=0. Which naturally is
> incorrect as that is associated with grant_map that has four entries!
>
> I hadn't yet tried to modify the nice test-case program you provided
> to see if this is can happen in practice, but it sure looks like it could?
This code wasn't changed from the old gntdev code. In gntalloc, I went with the
much simpler method of an always-incrementing index for generating offsets;
there's no reason that that can't be done here if it looks like there's a
mistake. The code does look correct to me, and I have tested it with variable-size
grants (although not in the 4/1/1 configuration you suggested).
--
Daniel De Graaf
National Security Agency
next prev parent reply other threads:[~2011-02-14 17:55 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-03 17:18 [PATCH v6] Userspace grant communication Daniel De Graaf
2011-02-03 17:18 ` [PATCH 1/6] xen-gntdev: Change page limit to be global instead of per-open Daniel De Graaf
2011-02-03 17:19 ` [PATCH 2/6] xen-gntdev: Use find_vma rather than iterating our vma list manually Daniel De Graaf
2011-02-03 17:19 ` [PATCH 3/6] xen-gntdev: Add reference counting to maps Daniel De Graaf
2011-02-03 17:19 ` [PATCH 4/6] xen-gntdev: Support mapping in HVM domains Daniel De Graaf
2011-02-14 15:51 ` Konrad Rzeszutek Wilk
2011-02-14 17:43 ` Daniel De Graaf
2011-02-14 18:52 ` Konrad Rzeszutek Wilk
2011-02-03 17:19 ` [PATCH 5/6] xen-gntalloc: Userspace grant allocation driver Daniel De Graaf
2011-02-08 22:48 ` Konrad Rzeszutek Wilk
2011-02-09 18:52 ` Daniel De Graaf
2011-02-03 17:19 ` [PATCH 6/6] xen/gntalloc, gntdev: Add unmap notify ioctl Daniel De Graaf
2011-02-14 15:37 ` Konrad Rzeszutek Wilk
2011-02-14 18:07 ` Daniel De Graaf
2011-02-03 19:16 ` [PATCH] xen-gntdev: Fix memory leak when mmap fails Daniel De Graaf
2011-02-07 23:14 ` [PATCH v6] Userspace grant communication Konrad Rzeszutek Wilk
2011-02-08 14:14 ` [PATCH] xen-gntdev: Fix unmap notify on PV domains Daniel De Graaf
2011-02-08 22:58 ` Konrad Rzeszutek Wilk
2011-02-09 20:33 ` [PATCH] xen-gntdev: prevent using UNMAP_NOTIFY_CLEAR_BYTE on read-only mappings Daniel De Graaf
2011-02-09 21:09 ` [PATCH v2] " Daniel De Graaf
2011-02-09 22:22 ` [PATCH] " Jeremy Fitzhardinge
2011-02-09 23:11 ` Daniel De Graaf
2011-02-09 23:15 ` [PATCH v3] " Daniel De Graaf
2011-02-08 21:49 ` [PATCH v6] Userspace grant communication Konrad Rzeszutek Wilk
2011-02-09 20:11 ` [PATCH] xen-gntdev: Use map->vma for checking map validity Daniel De Graaf
2011-02-09 20:12 ` [PATCH] xen-gntdev: Avoid unmapping ranges twice Daniel De Graaf
2011-02-09 21:11 ` [PATCH] xen-gntdev: Avoid double-mapping memory Daniel De Graaf
2011-02-14 16:14 ` [PATCH v6] Userspace grant communication Konrad Rzeszutek Wilk
2011-02-14 16:38 ` Konrad Rzeszutek Wilk
2011-02-14 17:56 ` Daniel De Graaf
2011-02-14 19:21 ` Konrad Rzeszutek Wilk
2011-02-14 20:55 ` Daniel De Graaf
2011-02-14 17:55 ` Daniel De Graaf [this message]
2011-02-14 19:04 ` Konrad Rzeszutek Wilk
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=4D596C98.4090401@tycho.nsa.gov \
--to=dgdegra@tycho.nsa.gov \
--cc=Ian.Campbell@citrix.com \
--cc=jeremy@goop.org \
--cc=konrad.wilk@oracle.com \
--cc=xen-devel@lists.xensource.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).