From: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: xen-devel <xen-devel@lists.xen.org>
Subject: Re: xc_evtchn_status fails with EFAULT on HVM, the same on PV works
Date: Fri, 13 Jan 2017 19:32:39 +0100 [thread overview]
Message-ID: <20170113183239.GK5268@mail-itl> (raw)
In-Reply-To: <3f9e01ca-3450-6af9-eb0c-8c867c3a6f96@citrix.com>
[-- Attachment #1.1: Type: text/plain, Size: 2942 bytes --]
On Fri, Jan 13, 2017 at 06:15:35PM +0000, Andrew Cooper wrote:
> On 13/01/17 18:03, Marek Marczykowski-Górecki wrote:
> > On Fri, Jan 13, 2017 at 05:38:42PM +0000, Andrew Cooper wrote:
> >> On 13/01/17 17:31, Marek Marczykowski-Górecki wrote:
> >>> Hi,
> >>>
> >>> I have a strange problem - xc_evtchn_status fails when running in HVM,
> >>> while exactly the same code (same kernel, same application etc) works
> >>> fine in PV. I've narrowed it down to copy_from_guest call in
> >>> common/event_channel.c, but no idea why it fails there. Xen version is
> >>> 4.8.0. kernel is kernel-4.8.13-100.fc23. Any idea?
> >> Which specific copy_from_guest() call?
> >>
> >> Copying data out of a PV guest is different to copying out of a HVM
> >> guest, but copy_from_guest() should cope properly with both.
> >>
> >> However, to progress, it would help to know exactly which piece of data
> >> is being requested.
> > This one:
> > https://github.com/xen-project/xen/blob/stable-4.8/xen/common/event_channel.c#L1104
> >
> > case EVTCHNOP_status: {
> > struct evtchn_status status;
> > if ( copy_from_guest(&status, arg, 1) != 0 )
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > return -EFAULT;
> > rc = evtchn_status(&status);
> > if ( !rc && __copy_to_guest(arg, &status, 1) )
> > rc = -EFAULT;
> > break;
> >
> > The evtchn_status structure in application is on stack (local variable),
> > but I think it shouldn't matter, as libxc copy it to a bounce buffer.
> >
>
> The intent of bounce buffers is certainly to avoid this problem from
> happening.
>
> Is this a 32bit HVM guest? Compat argument translation does make the
> logic a little more complicated.
No, its 64bit guest.
> Can you get the result of this piece of debugging in the failure case?
I've got this:
** d4v0 CFG(24, 00007f794bd07004, 1) = 24
> diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
> index 638dc5e..ab5d82a 100644
> --- a/xen/common/event_channel.c
> +++ b/xen/common/event_channel.c
> @@ -1101,8 +1101,13 @@ long do_event_channel_op(int cmd,
> XEN_GUEST_HANDLE_PARAM(void) arg)
>
> case EVTCHNOP_status: {
> struct evtchn_status status;
> - if ( copy_from_guest(&status, arg, 1) != 0 )
> + unsigned int res = copy_from_guest(&status, arg, 1);
> + if ( res != 0 )
> + {
> + printk("** %pv CFG(%zu, %p, 1) = %u\n",
> + current, sizeof(status), _p(arg.p), res);
> return -EFAULT;
> + }
> rc = evtchn_status(&status);
> if ( !rc && __copy_to_guest(arg, &status, 1) )
> rc = -EFAULT;
--
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
[-- Attachment #2: Type: text/plain, Size: 127 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-01-13 18:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-13 17:31 xc_evtchn_status fails with EFAULT on HVM, the same on PV works Marek Marczykowski-Górecki
2017-01-13 17:38 ` Andrew Cooper
2017-01-13 18:03 ` Marek Marczykowski-Górecki
2017-01-13 18:15 ` Andrew Cooper
2017-01-13 18:32 ` Marek Marczykowski-Górecki [this message]
2017-01-13 18:37 ` Andrew Cooper
2017-01-13 18:59 ` Marek Marczykowski-Górecki
2017-01-13 19:27 ` Andrew Cooper
2017-01-13 19:40 ` Marek Marczykowski-Górecki
2017-01-13 19:54 ` Andrew Cooper
2017-01-13 20:32 ` Marek Marczykowski-Górecki
2017-01-14 1:47 ` Andrew Cooper
2017-01-14 2:52 ` Marek Marczykowski-Górecki
2017-01-16 12:17 ` Jan Beulich
2017-01-16 23:06 ` Marek Marczykowski-Górecki
2017-01-16 23:41 ` Andrew Cooper
2017-06-22 8:23 ` Marek Marczykowski-Górecki
2017-06-22 8:27 ` Andrew Cooper
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=20170113183239.GK5268@mail-itl \
--to=marmarek@invisiblethingslab.com \
--cc=andrew.cooper3@citrix.com \
--cc=xen-devel@lists.xen.org \
/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.