All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen: x86: copy back tsc info, not pointer to tsc info in domctl
@ 2015-05-26 10:04 Ian Campbell
  2015-05-26 10:13 ` Andrew Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Campbell @ 2015-05-26 10:04 UTC (permalink / raw)
  To: jbeulich, andy; +Cc: Ian Campbell, xen-devel

In 38b37ed82705 "x86/domctl: cleanup", XEN_DOMCTL_gettscinfo was
changed to use the standard copyback mechanism.

However the output TSC Info is a guerst handle, i.e. a pointer to the
location for the information, copyback just copies the unchanged
pointer back.

Switch back to fetching the details into a local struct and explicitly
copying it back.

This caused test failures in the Cambridge instance of osstest, but
not for some reason in the production instance.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
 xen/arch/x86/domctl.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 684259b..e7da735 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -703,13 +703,16 @@ long arch_do_domctl(
             ret = -EINVAL;
         else
         {
+            xen_guest_tsc_info_t info = { 0 };
+
             domain_pause(d);
-            tsc_get_info(d, &domctl->u.tsc_info.info.tsc_mode,
-                         &domctl->u.tsc_info.info.elapsed_nsec,
-                         &domctl->u.tsc_info.info.gtsc_khz,
-                         &domctl->u.tsc_info.info.incarnation);
+            tsc_get_info(d, &info.tsc_mode,
+                            &info.elapsed_nsec,
+                            &info.gtsc_khz,
+                            &info.incarnation);
+            if ( copy_to_guest(domctl->u.tsc_info.out_info, &info, 1) )
+                ret = -EFAULT;
             domain_unpause(d);
-            copyback = 1;
         }
         break;
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] xen: x86: copy back tsc info, not pointer to tsc info in domctl
  2015-05-26 10:04 [PATCH] xen: x86: copy back tsc info, not pointer to tsc info in domctl Ian Campbell
@ 2015-05-26 10:13 ` Andrew Cooper
  2015-05-26 10:18   ` Ian Campbell
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cooper @ 2015-05-26 10:13 UTC (permalink / raw)
  To: Ian Campbell, jbeulich; +Cc: xen-devel

On 26/05/15 11:04, Ian Campbell wrote:
> In 38b37ed82705 "x86/domctl: cleanup", XEN_DOMCTL_gettscinfo was
> changed to use the standard copyback mechanism.
>
> However the output TSC Info is a guerst handle, i.e. a pointer to the
> location for the information, copyback just copies the unchanged
> pointer back.
>
> Switch back to fetching the details into a local struct and explicitly
> copying it back.
>
> This caused test failures in the Cambridge instance of osstest, but
> not for some reason in the production instance.
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

Oops - I feel very silly for not noticing that.  My testing also didn't
notice this.

> ---
>  xen/arch/x86/domctl.c |   13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
> index 684259b..e7da735 100644
> --- a/xen/arch/x86/domctl.c
> +++ b/xen/arch/x86/domctl.c
> @@ -703,13 +703,16 @@ long arch_do_domctl(
>              ret = -EINVAL;
>          else
>          {
> +            xen_guest_tsc_info_t info = { 0 };
> +
>              domain_pause(d);
> -            tsc_get_info(d, &domctl->u.tsc_info.info.tsc_mode,
> -                         &domctl->u.tsc_info.info.elapsed_nsec,
> -                         &domctl->u.tsc_info.info.gtsc_khz,
> -                         &domctl->u.tsc_info.info.incarnation);
> +            tsc_get_info(d, &info.tsc_mode,
> +                            &info.elapsed_nsec,
> +                            &info.gtsc_khz,
> +                            &info.incarnation);
> +            if ( copy_to_guest(domctl->u.tsc_info.out_info, &info, 1) )
> +                ret = -EFAULT;
>              domain_unpause(d);

The copy_to_guest() can be after the domain_unpause().

Alternatively, being a domctl, we can change tsc_info to not be a guest
handle.  There is plenty of space inside the union, and it saves a
further memory access.

~Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xen: x86: copy back tsc info, not pointer to tsc info in domctl
  2015-05-26 10:13 ` Andrew Cooper
@ 2015-05-26 10:18   ` Ian Campbell
  2015-05-26 10:20     ` Andrew Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Campbell @ 2015-05-26 10:18 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: jbeulich, xen-devel

On Tue, 2015-05-26 at 11:13 +0100, Andrew Cooper wrote:
> On 26/05/15 11:04, Ian Campbell wrote:
> > In 38b37ed82705 "x86/domctl: cleanup", XEN_DOMCTL_gettscinfo was
> > changed to use the standard copyback mechanism.
> >
> > However the output TSC Info is a guerst handle, i.e. a pointer to the
> > location for the information, copyback just copies the unchanged
> > pointer back.
> >
> > Switch back to fetching the details into a local struct and explicitly
> > copying it back.
> >
> > This caused test failures in the Cambridge instance of osstest, but
> > not for some reason in the production instance.
> >
> > Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> 
> Oops - I feel very silly for not noticing that.  My testing also didn't
> notice this.

It's pretty subtle.

My best guess is that the h/w in Cambridge tends to be older and
therefore perhaps doesn't all have synchronous TSCs or something.

> > ---
> >  xen/arch/x86/domctl.c |   13 ++++++++-----
> >  1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
> > index 684259b..e7da735 100644
> > --- a/xen/arch/x86/domctl.c
> > +++ b/xen/arch/x86/domctl.c
> > @@ -703,13 +703,16 @@ long arch_do_domctl(
> >              ret = -EINVAL;
> >          else
> >          {
> > +            xen_guest_tsc_info_t info = { 0 };
> > +
> >              domain_pause(d);
> > -            tsc_get_info(d, &domctl->u.tsc_info.info.tsc_mode,
> > -                         &domctl->u.tsc_info.info.elapsed_nsec,
> > -                         &domctl->u.tsc_info.info.gtsc_khz,
> > -                         &domctl->u.tsc_info.info.incarnation);
> > +            tsc_get_info(d, &info.tsc_mode,
> > +                            &info.elapsed_nsec,
> > +                            &info.gtsc_khz,
> > +                            &info.incarnation);
> > +            if ( copy_to_guest(domctl->u.tsc_info.out_info, &info, 1) )
> > +                ret = -EFAULT;
> >              domain_unpause(d);
> 
> The copy_to_guest() can be after the domain_unpause().

So it can. 

> Alternatively, being a domctl, we can change tsc_info to not be a guest
> handle.  There is plenty of space inside the union, and it saves a
> further memory access.

If you prefer, sure.

Perhaps fix then cleanup in a separate patch?

Ian.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xen: x86: copy back tsc info, not pointer to tsc info in domctl
  2015-05-26 10:18   ` Ian Campbell
@ 2015-05-26 10:20     ` Andrew Cooper
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2015-05-26 10:20 UTC (permalink / raw)
  To: Ian Campbell; +Cc: jbeulich, xen-devel

On 26/05/15 11:18, Ian Campbell wrote:
> On Tue, 2015-05-26 at 11:13 +0100, Andrew Cooper wrote:
>> On 26/05/15 11:04, Ian Campbell wrote:
>>> In 38b37ed82705 "x86/domctl: cleanup", XEN_DOMCTL_gettscinfo was
>>> changed to use the standard copyback mechanism.
>>>
>>> However the output TSC Info is a guerst handle, i.e. a pointer to the
>>> location for the information, copyback just copies the unchanged
>>> pointer back.
>>>
>>> Switch back to fetching the details into a local struct and explicitly
>>> copying it back.
>>>
>>> This caused test failures in the Cambridge instance of osstest, but
>>> not for some reason in the production instance.
>>>
>>> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
>> Oops - I feel very silly for not noticing that.  My testing also didn't
>> notice this.
> It's pretty subtle.
>
> My best guess is that the h/w in Cambridge tends to be older and
> therefore perhaps doesn't all have synchronous TSCs or something.
>
>>> ---
>>>  xen/arch/x86/domctl.c |   13 ++++++++-----
>>>  1 file changed, 8 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
>>> index 684259b..e7da735 100644
>>> --- a/xen/arch/x86/domctl.c
>>> +++ b/xen/arch/x86/domctl.c
>>> @@ -703,13 +703,16 @@ long arch_do_domctl(
>>>              ret = -EINVAL;
>>>          else
>>>          {
>>> +            xen_guest_tsc_info_t info = { 0 };
>>> +
>>>              domain_pause(d);
>>> -            tsc_get_info(d, &domctl->u.tsc_info.info.tsc_mode,
>>> -                         &domctl->u.tsc_info.info.elapsed_nsec,
>>> -                         &domctl->u.tsc_info.info.gtsc_khz,
>>> -                         &domctl->u.tsc_info.info.incarnation);
>>> +            tsc_get_info(d, &info.tsc_mode,
>>> +                            &info.elapsed_nsec,
>>> +                            &info.gtsc_khz,
>>> +                            &info.incarnation);
>>> +            if ( copy_to_guest(domctl->u.tsc_info.out_info, &info, 1) )
>>> +                ret = -EFAULT;
>>>              domain_unpause(d);
>> The copy_to_guest() can be after the domain_unpause().
> So it can. 
>
>> Alternatively, being a domctl, we can change tsc_info to not be a guest
>> handle.  There is plenty of space inside the union, and it saves a
>> further memory access.
> If you prefer, sure.
>
> Perhaps fix then cleanup in a separate patch?

Can do.

For this patch (subject to the reordering), Reviewed-by: Andrew Cooper
<andrew.cooper3@citrix.com>

>
> Ian.
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-26 10:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-26 10:04 [PATCH] xen: x86: copy back tsc info, not pointer to tsc info in domctl Ian Campbell
2015-05-26 10:13 ` Andrew Cooper
2015-05-26 10:18   ` Ian Campbell
2015-05-26 10:20     ` Andrew Cooper

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.