xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: Andres Lagar-Cavilla <andreslc@gridcentric.ca>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: Re: [PATCH 2/2] xen/privcmd: add PRIVCMD_MMAPBATCH_V2 ioctl
Date: Thu, 30 Aug 2012 18:04:20 +0100	[thread overview]
Message-ID: <503F9D14.8000600@citrix.com> (raw)
In-Reply-To: <12E7F3C7-86B7-4B6B-8F53-23CCFCEF80FB@gridcentric.ca>

On 30/08/12 17:41, Andres Lagar-Cavilla wrote:
> David,
> The patch looks functionally ok, but I still have two lingering concerns:
> - the hideous casting of mfn into err

I considered couple of other approaches (unions, extending
gather_array() to add gaps for the int return). They were all worse.

I also tried your proposal here but it doesn't work. See below.

> - why not signal paged out frames for V1

Because V1 is broken on 64bit and there doesn't seem to be any point in
changing it given that libxc won't call it if V2 is present,

> Rather than keep writing English, I wrote some C :)
> 
> And took the liberty to include your signed-off. David & Konrad, let
> me know what you think, and once we settle on either version we can move
> into unit testing this.
[...]
>  static int mmap_batch_fn(void *data, void *state)
>  {
>         xen_pfn_t *mfnp = data;
>         struct mmap_batch_state *st = state;
> +       int ret;
> +
> +       ret = xen_remap_domain_mfn_range(st->vma, st->va & PAGE_MASK, *mfnp, 1,
> +                                        st->vma->vm_page_prot, st->domain);
> +       if (ret < 0) {
> +               /*
> +                * V2 provides a user-space (pre-checked for access) user_err
> +                * pointer, in which we store the individual map error codes.
> +                *
> +                * V1 encodes the error codes in the 32bit top nibble of the
> +                * mfn (with its known limitations vis-a-vis 64 bit callers).
> +                *
> +                * In either case, global state.err is zero unless one or more
> +                * individual maps fail with -ENOENT, in which case it is -ENOENT.
> +                *
> +                */
> +               if (st->user_err)
> +                       BUG_ON(__put_user(ret, st->user_err++));

You can't access user space pages here while holding
current->mm->mmap_sem.  I tried this and it would sometimes deadlock in
the page fault handler.

access_ok() only checks if the pointer is in the user space virtual
address space - not that a valid mapping exists and is writable.  So
BUG_ON(__put_user()) should not be done.

David

  reply	other threads:[~2012-08-30 17:04 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-30 12:58 [PATCHv3 0/2] xen/privcmd: support for paged-out frames David Vrabel
2012-08-30 12:58 ` [PATCH 1/2] xen/mm: return more precise error from xen_remap_domain_range() David Vrabel
2012-08-30 15:07   ` Andres Lagar-Cavilla
2012-08-30 12:58 ` [PATCH 2/2] xen/privcmd: add PRIVCMD_MMAPBATCH_V2 ioctl David Vrabel
2012-08-30 16:41   ` Andres Lagar-Cavilla
2012-08-30 17:04     ` David Vrabel [this message]
2012-08-30 18:29       ` Andres Lagar-Cavilla
2012-08-31  7:02         ` Ian Campbell
2012-08-30 18:32   ` Andres Lagar-Cavilla
2012-08-31 13:08     ` David Vrabel
2012-08-31 13:13       ` Andres Lagar-Cavilla
2012-09-05 16:17         ` Konrad Rzeszutek Wilk
2012-08-31 13:59   ` Andres Lagar-Cavilla
2012-09-05 16:21     ` Konrad Rzeszutek Wilk
2012-09-05 17:09       ` Andres Lagar-Cavilla
2012-09-05 17:40         ` Konrad Rzeszutek Wilk
2012-09-06 13:41           ` Andres Lagar-Cavilla
2012-09-06 16:20             ` Konrad Rzeszutek Wilk
2012-08-30 20:05 ` [PATCHv3 0/2] xen/privcmd: support for paged-out frames Konrad Rzeszutek Wilk
2012-08-30 20:12   ` Andres Lagar-Cavilla
2012-09-05 18:57     ` Konrad Rzeszutek Wilk
2012-09-05 19:51       ` Andres Lagar-Cavilla
2012-09-05 20:05         ` Konrad Rzeszutek Wilk
  -- strict thread matches above, loose matches on Subject: below --
2012-08-29 13:15 [PATCHv2 " David Vrabel
2012-08-29 13:15 ` [PATCH 2/2] xen/privcmd: add PRIVCMD_MMAPBATCH_V2 ioctl David Vrabel
2012-08-29 16:14   ` Andres Lagar-Cavilla
2012-08-29 16:36     ` David Vrabel
2012-08-29 18:10       ` Andres Lagar-Cavilla

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=503F9D14.8000600@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=andreslc@gridcentric.ca \
    --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).