All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 00 of 24] [RFC] libxc: hypercall buffers
Date: Mon, 06 Sep 2010 14:38:20 +0100	[thread overview]
Message-ID: <patchbomb.1283780300@localhost.localdomain> (raw)

libxc currently locks various on-stack data structures present on the
stack using mlock(2) in order to try and make them safe for passing to
hypercalls (which requires the memory to be mapped)

There are several issues with this approach:

1) mlock/munlock do not nest, therefore mlocking multiple pieces of
   data on the stack which happen to share a page causes everything to
   be unlocked on the first munlock not the last. This is likely to be
   currently OK for the uses in libxc taken in isolation but could
   impact any caller of libxc which uses mlock itself.
2) mlocking only parts of the stack is considered by many to be a
   dubious, if strictly speaking allowed by the relevant
   specifications, use of mlock.
3) mlock may not provide the required semantics needed for hypercall
   safe memory. mlock simply ensures that there cvan be no major
   faults (page faults requiring I/O to satisfy) but does not
   necessarily rule out minor faults (e.g. due to page migration)

The following introduces an explicit hypercall-safe memory pool API
which includes support for bouncing user-supplied memory buffers into
suitable memory.

This series addresses (1) and (2) but does not directly address (3)
other than by encapsulating the code which acquires hypercall safe
memory into one place where it can be more easily fixed.

There is also the slightly separate issue of code which forgets to
lock buffers as necessary and therefor this series overrides the Xen
guest-handle interfaces to attempt to improve compile-time checking
for the correct use of the memory pool. This scheme works for the
pointers contained within hypercall argument structures but doesn't
catch the actual hypercall arguments themselves. I'm open to
suggestions on how to extend it cleanly to catch those cases.

This RFC series only partially translates over to the the new
scheme. It is intended that the final series end with a patch which
effectively does s/xc_set_xen_guest_handle/set_xen_guest_handle/g in
order to catch future errors (it should also remove the now redundant
hcall_buf_prep and hcall_buf_release calls and assiciated
infrastructure).

The RFC has already grown to many more patches than I originally
intended so I'd like to solicit some comments on the basic premise,
usability of the interface etc, before I dig down and convert/cleanup
the rest.

I've tried in this initial pass to keep the locking/bouncing at the
same level of the call stack. There seems to be several opportunities
for pushing this up or down to reduce unnecessary bouncing. While it
would be nice to avoid exposing the explicit allocation to users of
libxc (by using bounce buffers at all public interfaces) I do not
think this will be possible for performance reasons in many
cases. Already there are several users of libxc which lock their own
buffers.

             reply	other threads:[~2010-09-06 13:38 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-06 13:38 Ian Campbell [this message]
2010-09-06 13:38 ` [PATCH 01 of 24] xen: define raw version of set_xen_guest_handle Ian Campbell
2010-09-06 13:38 ` [PATCH 02 of 24] libxc: flask: use (un)lock pages rather than open coding m(un)lock Ian Campbell
2010-09-06 13:38 ` [PATCH 03 of 24] libxc: pass an xc_interface handle to page locking functions Ian Campbell
2010-09-06 13:38 ` [PATCH 04 of 24] libxc: Remove unnecessary double indirection from xc_readconsolering Ian Campbell
2010-09-06 13:38 ` [PATCH 05 of 24] libxc: use correct size of struct xen_mc Ian Campbell
2010-09-06 13:38 ` [PATCH 06 of 24] libxc: add to xc_domain_maximum_gpfn Ian Campbell
2010-09-06 13:38 ` [PATCH 07 of 24] libxc: replace open-coded use of XENMEM_decrease_reservation Ian Campbell
2010-09-06 13:38 ` [PATCH 08 of 24] libxc: simplify performance counters API Ian Campbell
2010-09-06 13:38 ` [PATCH 09 of 24] libxc: simplify lock profiling API Ian Campbell
2010-09-06 13:38 ` [PATCH 10 of 24] libxc: infrastructure for hypercall safe data buffers Ian Campbell
2010-09-07  8:44   ` Jeremy Fitzhardinge
2010-09-07  9:56     ` Ian Campbell
2010-09-07 17:23       ` Ian Jackson
2010-09-07 18:44         ` Ian Campbell
2010-09-07 23:31         ` Jeremy Fitzhardinge
2010-09-06 13:38 ` [PATCH 11 of 24] libxc: convert xc_version over to hypercall buffers Ian Campbell
2010-09-06 13:38 ` [PATCH 12 of 24] libxc: convert domctl interfaces " Ian Campbell
2010-09-06 13:38 ` [PATCH 13 of 24] libxc: convert shadow domctl interfaces and save/restore " Ian Campbell
2010-09-06 13:38 ` [PATCH 14 of 24] libxc: convert sysctl interfaces " Ian Campbell
2010-09-06 13:38 ` [PATCH 15 of 24] libxc: convert watchdog interface " Ian Campbell
2010-09-06 13:38 ` [PATCH 16 of 24] libxc: convert acm interfaces " Ian Campbell
2010-09-06 13:38 ` [PATCH 17 of 24] libxc: convert evtchn " Ian Campbell
2010-09-06 13:38 ` [PATCH 18 of 24] libxc: convert schedop " Ian Campbell
2010-09-06 13:38 ` [PATCH 19 of 24] libxc: convert physdevop interface " Ian Campbell
2010-09-06 13:38 ` [PATCH 20 of 24] libxc: convert flask interfaces " Ian Campbell
2010-09-06 13:38 ` [PATCH 21 of 24] libxc: convert hvmop " Ian Campbell
2010-09-06 13:38 ` [PATCH 22 of 24] libxc: convert mca interface " Ian Campbell
2010-09-06 13:38 ` [PATCH 23 of 24] libxc: convert tmem " Ian Campbell
2010-09-06 13:38 ` [PATCH 24 of 24] libxc: convert gnttab interfaces " Ian Campbell
2010-09-06 13:41 ` [PATCH 00 of 24] [RFC] libxc: " Ian Campbell
2010-09-07 16:35 ` Ian Jackson
2010-09-07 16:36   ` Ian Campbell
2010-09-07 17:28     ` Ian Jackson

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=patchbomb.1283780300@localhost.localdomain \
    --to=ian.campbell@citrix.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.