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: Wed, 29 Aug 2012 17:36:42 +0100 [thread overview]
Message-ID: <503E451A.20107@citrix.com> (raw)
In-Reply-To: <7392D0E0-02A4-48D7-8B16-4F93EA01F3AF@gridcentric.ca>
On 29/08/12 17:14, Andres Lagar-Cavilla wrote:
>
> On Aug 29, 2012, at 9:15 AM, David Vrabel wrote:
>
>> From: David Vrabel <david.vrabel@citrix.com>
>>
>> PRIVCMD_MMAPBATCH_V2 extends PRIVCMD_MMAPBATCH with an additional
>> field for reporting the error code for every frame that could not be
>> mapped. libxc prefers PRIVCMD_MMAPBATCH_V2 over PRIVCMD_MMAPBATCH.
[...]
>> diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c
>> index ccee0f1..ddd32cf 100644
>> --- a/drivers/xen/privcmd.c
>> +++ b/drivers/xen/privcmd.c
>> @@ -248,18 +248,23 @@ struct mmap_batch_state {
>> struct vm_area_struct *vma;
>> int err;
>>
>> - xen_pfn_t __user *user;
>> + xen_pfn_t __user *user_mfn;
>> + int __user *user_err;
>> };
>>
>> static int mmap_batch_fn(void *data, void *state)
>> {
>> xen_pfn_t *mfnp = data;
>> + int *err = data;
> Am I missing something or is there an aliasing here? Both mfnp and err point to data?
There is deliberate aliasing here. We use the mfn array to save the
error codes for later processing.
>> struct mmap_batch_state *st = state;
>> + int ret;
>>
>> - if (xen_remap_domain_mfn_range(st->vma, st->va & PAGE_MASK, *mfnp, 1,
>> - st->vma->vm_page_prot, st->domain) < 0) {
>> - *mfnp |= 0xf0000000U;
>> - st->err++;
>> + ret = xen_remap_domain_mfn_range(st->vma, st->va & PAGE_MASK, *mfnp, 1,
>> + st->vma->vm_page_prot, st->domain);
>> + if (ret < 0) {
>> + *err = ret;
>> + if (st->err == 0 || st->err == -ENOENT)
>> + st->err = ret;
> This will unset -ENOENT if a frame after an ENOENT error fails differently.
I thought that was what the original implementation did but it seems it
does not.
>> @@ -325,12 +359,16 @@ static long privcmd_ioctl_mmap_batch(void __user *udata)
>>
>> up_write(&mm->mmap_sem);
>>
>> - if (state.err > 0) {
>> - state.user = m.arr;
>> + if (state.err) {
>> + state.user_mfn = (xen_pfn_t *)m.arr;
>> + state.user_err = m.err;
>> ret = traverse_pages(m.num, sizeof(xen_pfn_t),
>> - &pagelist,
>> - mmap_return_errors, &state);
>> - }
>> + &pagelist,
>> + mmap_return_errors, &state);
> The callback now maps data to err (instead of mfnp … but I see no
> change to the gather_array other than a cast …am I missing something?
The kernel mfn and the err array are aliased.
I could have made gather_array() allow the kernel array to have larger
elements than the user array but that looked like too much work.
David
next prev parent reply other threads:[~2012-08-29 16:36 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-29 13:15 [PATCHv2 0/2] xen/privcmd: support for paged-out frames David Vrabel
2012-08-29 13:15 ` [PATCH 1/2] xen/mm: return more precise error from xen_remap_domain_range() 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 [this message]
2012-08-29 18:10 ` Andres Lagar-Cavilla
2012-08-29 16:23 ` [PATCHv2 0/2] xen/privcmd: support for paged-out frames Ian Campbell
2012-08-29 16:56 ` David Vrabel
2012-08-29 18:05 ` Ian Campbell
2012-08-30 10:09 ` David Vrabel
-- strict thread matches above, loose matches on Subject: below --
2012-08-30 12:58 [PATCHv3 " David Vrabel
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
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
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=503E451A.20107@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).