virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Derek Murray <Derek.Murray@cl.cam.ac.uk>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Juan Quintela <quintela@redhat.com>,
	"Stephen C. Tweedie" <sct@redhat.com>,
	Jan Beulich <jbeulich@novell.com>,
	Glauber de Oliveira Costa <gcosta@redhat.com>,
	Chris Wright <chrisw@sous-sol.org>,
	"virtualization@lists.osdl.org" <virtualization@lists.osdl.org>
Subject: Re: Re: Next steps with pv_ops for Xen
Date: Mon, 03 Dec 2007 14:51:19 +0000	[thread overview]
Message-ID: <475417E7.9070006@cl.cam.ac.uk> (raw)
In-Reply-To: <47540FB8.8000106@redhat.com>

Gerd Hoffmann wrote:
> Derek Murray wrote:
>> I take the blame for that one. I added the hook because, if a process
>> were to die whilst holding one or more grants, there were no hooks that
>> would make it possible to carry out the grant-unmap. All existing hooks
>> on either the device or the VMA were called *after* the PTEs were cleared.
> 
> Hmm.  What exactly is the issue here?
> 
> This is about *userspace* mappings, right?  As far as I can see from a
> quick scan there of the code is an additional kernel space mapping for
> the grants and the userspace mapping is optional.  I don't see any
> problems with userspace mapping going away without *instant*
> notification.  Cleaning up a bit later, called from the
> file_ops->release callback maybe, should work ok.

If we let Linux zap the page tables before we unmap the grant reference, 
then it is not possible to unmap the grant reference. The 
unmap_grant_ref hypercall ultimately calls destroy_grant_pte_mapping in 
xen/arch/x86/mm.c, which ensures that the PTE does in fact point to the 
granted frame. Note also the comment further up in that file (in 
put_page_from_l1e):

     /*
      * Check if this is a mapping that was established via a grant 
reference.
      * If it was then we should not be here: we require that such 
mappings are
      * explicitly destroyed via the grant-table interface.
      *
      * The upshot of this is that the guest can end up with active 
grants that
      * it cannot destroy (because it no longer has a PTE to present to the
      * grant-table interface). This can lead to subtle hard-to-catch bugs,
      * hence a special grant PTE flag can be enabled to catch the bug 
early.
      *
      * (Note that the undestroyable active grants are not a security 
hole in
      * Xen. All active grants can safely be cleaned up when the domain 
dies.)
      */

Effectively, there is a debug option that sets a bit in PTEs that map 
granted pages, and this can be used to force a domain_crash in the event 
that a VM tries to zap the entries normally. The normal behaviour is to 
silently accept the zap operation, and leak granted pages until the 
grantee domain is killed.

> The problem I see with the additional vm_ops callback is that I suspect
> you'll have to come up with some *very* good arguments to get it
> accepted by the VM (as in "virtual memory") folks and merged mainline.

On this point I completely agree with you! If anyone has any less 
radical suggestions, then I'd be delighted to refactor the gntdev code 
to use them. However, I'm not currently aware of any alternative that 
maintains robustness to process crashes.

>> It gets better, though. The same hook is used in the version of blktap
>> in linux-2.6.18-xen (not, as far as I can see, in the sparse tree for
>> xen-3.1-testing):
> 
> Oh, I'm thinking more in the direction of killing blktap altogether in
> favor of a pure userspace implementation on top of gntdev.

I think this would represent good progress, though I wonder if there 
would be a performance penalty due to performing the mapping and 
unmapping in user-space (multiple syscalls per mapping versus a single 
hypercall).

Cheers,

Derek Murray.

  reply	other threads:[~2007-12-03 14:51 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-21 22:05 Next steps with pv_ops for Xen Stephen C. Tweedie
2007-11-21 23:12 ` Jeremy Fitzhardinge
2007-11-26 14:02   ` Juan Quintela
2007-11-26 18:52     ` Jeremy Fitzhardinge
2007-11-27  8:30       ` Jan Beulich
2007-11-27 17:00         ` Jeremy Fitzhardinge
2007-11-27 17:14           ` Jan Beulich
2007-11-27 17:15           ` Stephen C. Tweedie
2007-12-03 12:54 ` Gerd Hoffmann
2007-12-03 13:19   ` Derek Murray
2007-12-03 14:16     ` Gerd Hoffmann
2007-12-03 14:51       ` Derek Murray [this message]
2007-12-03 17:18         ` Mark Williamson
2007-12-03 18:36           ` D.G. Murray
2007-12-03 19:08             ` Mark Williamson
2007-12-04  9:35               ` tgh
2007-12-05  3:42                 ` Mark Williamson
2007-12-06 15:21             ` Gerd Hoffmann
2007-12-06 15:32               ` Derek Murray
2007-12-06 15:55                 ` Gerd Hoffmann
2007-12-21 12:58             ` [Xen-devel] " Gerd Hoffmann
2007-12-03 20:38         ` Gerd Hoffmann
2007-12-04  9:40           ` Derek Murray
2007-12-04 12:01             ` Gerd Hoffmann
2007-12-04 12:39               ` Stephen C. Tweedie
2007-12-04 19:58                 ` Gerd Hoffmann
2007-12-05 11:48                   ` [Xen-devel] " Derek Murray
2007-12-05 13:19                   ` Derek Murray
     [not found]                   ` <47569014.8080008@cl.cam.ac.uk>
2007-12-05 14:12                     ` Gerd Hoffmann
2007-12-05 14:22                       ` Keir Fraser
2007-12-05 14:30                         ` Derek Murray
2007-12-05 16:58                           ` Keir Fraser
2007-12-05 17:17                             ` Derek Murray
2007-12-05 17:22                               ` Keir Fraser
2007-12-05 17:48                                 ` Derek Murray
2007-12-05 17:59                                   ` Keir Fraser
2007-12-05 18:15                                     ` Derek Murray
2007-12-12  8:27                                       ` Isaku Yamahata
2007-12-12  8:39                                         ` Keir Fraser
2007-12-12  8:44                                           ` Isaku Yamahata
2007-12-05 20:06                                     ` Gerd Hoffmann
2007-12-05 18:12                     ` Jeremy Fitzhardinge
2007-12-05 18:29                       ` Derek Murray
2007-12-05 20:15                         ` Jeremy Fitzhardinge
2007-12-05 20:35                           ` Geoffrey Lefebvre
2007-12-06 10:15                             ` Gerd Hoffmann
2007-12-05 20:44                           ` Keir Fraser
2007-12-06 10:00                             ` Derek Murray
2007-12-06 19:55                               ` [Xen-devel] " Jeremy Fitzhardinge
2007-12-05 10:03                 ` Gerd Hoffmann
2007-12-05 12:51                   ` Gerd Hoffmann
2007-12-05 10:11                 ` Derek Murray

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=475417E7.9070006@cl.cam.ac.uk \
    --to=derek.murray@cl.cam.ac.uk \
    --cc=chrisw@sous-sol.org \
    --cc=ehabkost@redhat.com \
    --cc=gcosta@redhat.com \
    --cc=jbeulich@novell.com \
    --cc=kraxel@redhat.com \
    --cc=quintela@redhat.com \
    --cc=sct@redhat.com \
    --cc=virtualization@lists.osdl.org \
    --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).