xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* libxc: fix bug of xc_tbuf_get_size()
@ 2010-02-09 10:57 Yu Zhiguo
  2010-02-10  9:17 ` Keir Fraser
  2010-02-12 17:09 ` George Dunlap
  0 siblings, 2 replies; 4+ messages in thread
From: Yu Zhiguo @ 2010-02-09 10:57 UTC (permalink / raw)
  To: Keir Fraser, xen-devel

The size in pages of trace buffer should be t_info->tbuf_size
rather than t_info pages.

Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>

diff --git a/tools/libxc/xc_tbuf.c b/tools/libxc/xc_tbuf.c
--- a/tools/libxc/xc_tbuf.c
+++ b/tools/libxc/xc_tbuf.c
@@ -15,6 +15,7 @@
  */
 
 #include "xc_private.h"
+#include <xen/trace.h>
 
 static int tbuf_enable(int xc_handle, int enable)
 {
@@ -44,6 +45,7 @@
 
 int xc_tbuf_get_size(int xc_handle, unsigned long *size)
 {
+    struct t_info *t_info;
     int rc;
     DECLARE_SYSCTL;
 
@@ -52,9 +54,19 @@
     sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_get_info;
 
     rc = xc_sysctl(xc_handle, &sysctl);
-    if (rc == 0)
-        *size = sysctl.u.tbuf_op.size;
-    return rc;
+    if ( rc != 0 )
+        return rc;
+
+    t_info = xc_map_foreign_range(xc_handle, DOMID_XEN,
+                    sysctl.u.tbuf_op.size, PROT_READ | PROT_WRITE,
+                    sysctl.u.tbuf_op.buffer_mfn);
+
+    if ( t_info == NULL || t_info->tbuf_size == 0 )
+        return -1;
+
+    *size = t_info->tbuf_size;
+
+    return 0;
 }
 
 int xc_tbuf_enable(int xc_handle, unsigned long pages, unsigned long *mfn,

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

* Re: libxc: fix bug of xc_tbuf_get_size()
  2010-02-09 10:57 libxc: fix bug of xc_tbuf_get_size() Yu Zhiguo
@ 2010-02-10  9:17 ` Keir Fraser
  2010-02-10 11:30   ` Yu Zhiguo
  2010-02-12 17:09 ` George Dunlap
  1 sibling, 1 reply; 4+ messages in thread
From: Keir Fraser @ 2010-02-10  9:17 UTC (permalink / raw)
  To: Yu Zhiguo, xen-devel@lists.xensource.com; +Cc: George Dunlap

When did this change, and who changed it? It would be good to collect an
appropriate Ack, e.g., from George Dunlap, if it was his xentrace changes.

I can't take un-acked patches from non-maintainers on stuff I don't have
good knowledge of myself, this late in the release cycle.

 -- Keir

On 09/02/2010 10:57, "Yu Zhiguo" <yuzg@cn.fujitsu.com> wrote:

> The size in pages of trace buffer should be t_info->tbuf_size
> rather than t_info pages.
> 
> Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
> 
> diff --git a/tools/libxc/xc_tbuf.c b/tools/libxc/xc_tbuf.c
> --- a/tools/libxc/xc_tbuf.c
> +++ b/tools/libxc/xc_tbuf.c
> @@ -15,6 +15,7 @@
>   */
>  
>  #include "xc_private.h"
> +#include <xen/trace.h>
>  
>  static int tbuf_enable(int xc_handle, int enable)
>  {
> @@ -44,6 +45,7 @@
>  
>  int xc_tbuf_get_size(int xc_handle, unsigned long *size)
>  {
> +    struct t_info *t_info;
>      int rc;
>      DECLARE_SYSCTL;
>  
> @@ -52,9 +54,19 @@
>      sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_get_info;
>  
>      rc = xc_sysctl(xc_handle, &sysctl);
> -    if (rc == 0)
> -        *size = sysctl.u.tbuf_op.size;
> -    return rc;
> +    if ( rc != 0 )
> +        return rc;
> +
> +    t_info = xc_map_foreign_range(xc_handle, DOMID_XEN,
> +                    sysctl.u.tbuf_op.size, PROT_READ | PROT_WRITE,
> +                    sysctl.u.tbuf_op.buffer_mfn);
> +
> +    if ( t_info == NULL || t_info->tbuf_size == 0 )
> +        return -1;
> +
> +    *size = t_info->tbuf_size;
> +
> +    return 0;
>  }
>  
>  int xc_tbuf_enable(int xc_handle, unsigned long pages, unsigned long *mfn,
> 

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

* Re: libxc: fix bug of xc_tbuf_get_size()
  2010-02-10  9:17 ` Keir Fraser
@ 2010-02-10 11:30   ` Yu Zhiguo
  0 siblings, 0 replies; 4+ messages in thread
From: Yu Zhiguo @ 2010-02-10 11:30 UTC (permalink / raw)
  To: George Dunlap; +Cc: xen-devel@lists.xensource.com, Keir Fraser

Hi keir and George,

Keir Fraser wrote:
> When did this change, and who changed it? It would be good to collect an
> appropriate Ack, e.g., from George Dunlap, if it was his xentrace changes.
> 

 I found this bug when I try 'xentrace_setsize'. The default
'current tbuf size' should be 0x14 but 0x2 outputted.
 xc_tbuf_set_size() sets the tbuf size, it's ok. But xc_tbuf_get_size()
tries to get the size of t_info pages.

 Could George have a look at this problem?

Regards,

Yu

> I can't take un-acked patches from non-maintainers on stuff I don't have
> good knowledge of myself, this late in the release cycle.
> 
>  -- Keir
> 
> On 09/02/2010 10:57, "Yu Zhiguo" <yuzg@cn.fujitsu.com> wrote:
> 
>> The size in pages of trace buffer should be t_info->tbuf_size
>> rather than t_info pages.
>>
>> Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
>>
>> diff --git a/tools/libxc/xc_tbuf.c b/tools/libxc/xc_tbuf.c
>> --- a/tools/libxc/xc_tbuf.c
>> +++ b/tools/libxc/xc_tbuf.c
>> @@ -15,6 +15,7 @@
>>   */
>>  
>>  #include "xc_private.h"
>> +#include <xen/trace.h>
>>  
>>  static int tbuf_enable(int xc_handle, int enable)
>>  {
>> @@ -44,6 +45,7 @@
>>  
>>  int xc_tbuf_get_size(int xc_handle, unsigned long *size)
>>  {
>> +    struct t_info *t_info;
>>      int rc;
>>      DECLARE_SYSCTL;
>>  
>> @@ -52,9 +54,19 @@
>>      sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_get_info;
>>  
>>      rc = xc_sysctl(xc_handle, &sysctl);
>> -    if (rc == 0)
>> -        *size = sysctl.u.tbuf_op.size;
>> -    return rc;
>> +    if ( rc != 0 )
>> +        return rc;
>> +
>> +    t_info = xc_map_foreign_range(xc_handle, DOMID_XEN,
>> +                    sysctl.u.tbuf_op.size, PROT_READ | PROT_WRITE,
>> +                    sysctl.u.tbuf_op.buffer_mfn);
>> +
>> +    if ( t_info == NULL || t_info->tbuf_size == 0 )
>> +        return -1;
>> +
>> +    *size = t_info->tbuf_size;
>> +
>> +    return 0;
>>  }
>>  
>>  int xc_tbuf_enable(int xc_handle, unsigned long pages, unsigned long *mfn,
>>
> 
> 
> 
> 
> 

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

* Re: libxc: fix bug of xc_tbuf_get_size()
  2010-02-09 10:57 libxc: fix bug of xc_tbuf_get_size() Yu Zhiguo
  2010-02-10  9:17 ` Keir Fraser
@ 2010-02-12 17:09 ` George Dunlap
  1 sibling, 0 replies; 4+ messages in thread
From: George Dunlap @ 2010-02-12 17:09 UTC (permalink / raw)
  To: Yu Zhiguo; +Cc: xen-devel, Keir Fraser

(Replying to the whole list)

This is changing a function that is only used in one place in the Xen
source tree; the change makes sense.

Acked-by: George Dunlap <george.dunlap@eu.citrix.com>

On Tue, Feb 9, 2010 at 10:57 AM, Yu Zhiguo <yuzg@cn.fujitsu.com> wrote:
> The size in pages of trace buffer should be t_info->tbuf_size
> rather than t_info pages.
>
> Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
>
> diff --git a/tools/libxc/xc_tbuf.c b/tools/libxc/xc_tbuf.c
> --- a/tools/libxc/xc_tbuf.c
> +++ b/tools/libxc/xc_tbuf.c
> @@ -15,6 +15,7 @@
>  */
>
>  #include "xc_private.h"
> +#include <xen/trace.h>
>
>  static int tbuf_enable(int xc_handle, int enable)
>  {
> @@ -44,6 +45,7 @@
>
>  int xc_tbuf_get_size(int xc_handle, unsigned long *size)
>  {
> +    struct t_info *t_info;
>     int rc;
>     DECLARE_SYSCTL;
>
> @@ -52,9 +54,19 @@
>     sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_get_info;
>
>     rc = xc_sysctl(xc_handle, &sysctl);
> -    if (rc == 0)
> -        *size = sysctl.u.tbuf_op.size;
> -    return rc;
> +    if ( rc != 0 )
> +        return rc;
> +
> +    t_info = xc_map_foreign_range(xc_handle, DOMID_XEN,
> +                    sysctl.u.tbuf_op.size, PROT_READ | PROT_WRITE,
> +                    sysctl.u.tbuf_op.buffer_mfn);
> +
> +    if ( t_info == NULL || t_info->tbuf_size == 0 )
> +        return -1;
> +
> +    *size = t_info->tbuf_size;
> +
> +    return 0;
>  }
>
>  int xc_tbuf_enable(int xc_handle, unsigned long pages, unsigned long *mfn,
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
>

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

end of thread, other threads:[~2010-02-12 17:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-09 10:57 libxc: fix bug of xc_tbuf_get_size() Yu Zhiguo
2010-02-10  9:17 ` Keir Fraser
2010-02-10 11:30   ` Yu Zhiguo
2010-02-12 17:09 ` George Dunlap

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).