* [PATCH] xen: restore GNTTABOP_dump_table
@ 2012-10-19 15:47 Roger Pau Monne
2012-11-16 12:24 ` Roger Pau Monné
2012-11-16 14:52 ` David Vrabel
0 siblings, 2 replies; 6+ messages in thread
From: Roger Pau Monne @ 2012-10-19 15:47 UTC (permalink / raw)
To: xen-devel; +Cc: Roger Pau Monne
This operation was dropped long time ago, but I found it quite helpful
for debugging purposes. This re-implementation uses the code already
present in gnttab_usage_print and adds the maptrack-table dump.
Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
---
xen/common/grant_table.c | 83 ++++++++++++++++++++++++++++++++++++++---
xen/include/xen/grant_table.h | 3 +
2 files changed, 80 insertions(+), 6 deletions(-)
diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index c8e342b..a5de9c6 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -1393,6 +1393,40 @@ gnttab_setup_table(
return 0;
}
+static long
+gnttab_dump_table(
+ XEN_GUEST_HANDLE(gnttab_dump_table_t) uop, unsigned int count)
+{
+ struct gnttab_dump_table op;
+ struct domain *d;
+
+ if ( !IS_PRIV(current->domain) )
+ return -EPERM;
+
+ if ( unlikely(copy_from_guest(&op, uop, sizeof(op)) != 0) )
+ {
+ gdprintk(XENLOG_INFO, "Fault while reading gnttab_dump_table_t.\n");
+ return -EFAULT;
+ }
+
+ d = gt_lock_target_domain_by_id(op.dom);
+ if ( IS_ERR(d) )
+ {
+ op.status = PTR_ERR(d);
+ goto out;
+ }
+
+ gnttab_usage_print(d, 1);
+
+ rcu_unlock_domain(d);
+
+out:
+ if ( unlikely(copy_to_guest(uop, &op, 1)) )
+ return -EFAULT;
+
+ return 0;
+}
+
static long
gnttab_query_size(
XEN_GUEST_HANDLE(gnttab_query_size_t) uop, unsigned int count)
@@ -2495,6 +2529,12 @@ do_grant_table_op(
ASSERT(rc <= 0);
break;
}
+ case GNTTABOP_dump_table:
+ {
+ rc = gnttab_dump_table(guest_handle_cast(uop, gnttab_dump_table_t),
+ count);
+ break;
+ }
case GNTTABOP_transfer:
{
XEN_GUEST_HANDLE(gnttab_transfer_t) transfer =
@@ -2796,7 +2836,7 @@ grant_table_destroy(
d->grant_table = NULL;
}
-void gnttab_usage_print(struct domain *rd)
+void gnttab_usage_print(struct domain *rd, int print_maptrack)
{
int first = 1;
grant_ref_t ref;
@@ -2808,7 +2848,7 @@ void gnttab_usage_print(struct domain *rd)
spin_lock(>->lock);
if ( gt->gt_version == 0 )
- goto out;
+ goto out_grant;
for ( ref = 0; ref != nr_grant_entries(gt); ref++ )
{
@@ -2853,12 +2893,43 @@ void gnttab_usage_print(struct domain *rd)
sha->domid, frame, status);
}
- out:
- spin_unlock(>->lock);
-
+out_grant:
if ( first )
printk("grant-table for remote domain:%5d ... "
"no active grant table entries\n", rd->domain_id);
+
+ if ( !print_maptrack )
+ goto out;
+
+ first = 1;
+
+ printk(" -------- maptrack --------\n");
+ printk("[ref] domid gnt flags\n");
+
+ for ( ref = 0; ref != gt->maptrack_limit; ref++ )
+ {
+ struct grant_mapping *maptrack = &maptrack_entry(gt, ref);
+
+ if ( maptrack->flags ) {
+
+ if ( first )
+ {
+ printk("maptrack-table for remote domain:%5d\n",
+ rd->domain_id);
+ first = 0;
+ }
+ /* [ddd] ddddd 0xXXXXXXXX 0xXX */
+ printk("[%3d] %5d 0x%08x 0x%02x\n",
+ ref, maptrack->domid, maptrack->ref, maptrack->flags);
+ }
+ }
+
+ if ( first )
+ printk("maptrack-table for remote domain:%5d ... "
+ "no active maptrack table entries\n", rd->domain_id);
+
+ out:
+ spin_unlock(>->lock);
}
static void gnttab_usage_print_all(unsigned char key)
@@ -2866,7 +2937,7 @@ static void gnttab_usage_print_all(unsigned char key)
struct domain *d;
printk("%s [ key '%c' pressed\n", __FUNCTION__, key);
for_each_domain ( d )
- gnttab_usage_print(d);
+ gnttab_usage_print(d, 0);
printk("%s ] done\n", __FUNCTION__);
}
diff --git a/xen/include/xen/grant_table.h b/xen/include/xen/grant_table.h
index 0820da1..34a8304 100644
--- a/xen/include/xen/grant_table.h
+++ b/xen/include/xen/grant_table.h
@@ -111,6 +111,9 @@ gnttab_release_mappings(
int
gnttab_grow_table(struct domain *d, unsigned int req_nr_frames);
+/* Print grant table for given domain. */
+void gnttab_usage_print(struct domain *rd, int print_maptrack);
+
/* Number of grant table frames. Caller must hold d's grant table lock. */
static inline unsigned int nr_grant_frames(struct grant_table *gt)
{
--
1.7.7.5 (Apple Git-26)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] xen: restore GNTTABOP_dump_table
2012-10-19 15:47 [PATCH] xen: restore GNTTABOP_dump_table Roger Pau Monne
@ 2012-11-16 12:24 ` Roger Pau Monné
2012-11-16 14:52 ` David Vrabel
1 sibling, 0 replies; 6+ messages in thread
From: Roger Pau Monné @ 2012-11-16 12:24 UTC (permalink / raw)
To: xen-devel
On 19/10/12 17:47, Roger Pau Monne wrote:
> This operation was dropped long time ago, but I found it quite helpful
> for debugging purposes. This re-implementation uses the code already
> present in gnttab_usage_print and adds the maptrack-table dump.
Is there any interest on this patch?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xen: restore GNTTABOP_dump_table
2012-10-19 15:47 [PATCH] xen: restore GNTTABOP_dump_table Roger Pau Monne
2012-11-16 12:24 ` Roger Pau Monné
@ 2012-11-16 14:52 ` David Vrabel
2012-11-16 15:02 ` Roger Pau Monné
1 sibling, 1 reply; 6+ messages in thread
From: David Vrabel @ 2012-11-16 14:52 UTC (permalink / raw)
To: Roger Pau Monne; +Cc: xen-devel
On 19/10/12 16:47, Roger Pau Monne wrote:
> This operation was dropped long time ago, but I found it quite helpful
> for debugging purposes. This re-implementation uses the code already
> present in gnttab_usage_print and adds the maptrack-table dump.
Why is the operation useful? Isn't the debug key sufficient?
# xl debug-key g
(XEN) gnttab_usage_print_all [ key 'g' pressed
(XEN) -------- active -------- -------- shared --------
(XEN) [ref] localdom mfn pin localdom gmfn flags
(XEN) grant-table for remote domain: 0 ... no active grant table entries
(XEN) gnttab_usage_print_all ] done
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xen: restore GNTTABOP_dump_table
2012-11-16 14:52 ` David Vrabel
@ 2012-11-16 15:02 ` Roger Pau Monné
2012-11-19 14:29 ` Ian Campbell
0 siblings, 1 reply; 6+ messages in thread
From: Roger Pau Monné @ 2012-11-16 15:02 UTC (permalink / raw)
To: David Vrabel; +Cc: xen-devel@lists.xen.org
On 16/11/12 15:52, David Vrabel wrote:
> On 19/10/12 16:47, Roger Pau Monne wrote:
>> This operation was dropped long time ago, but I found it quite helpful
>> for debugging purposes. This re-implementation uses the code already
>> present in gnttab_usage_print and adds the maptrack-table dump.
>
> Why is the operation useful? Isn't the debug key sufficient?
The debug key doesn't print the maptrack, and also I found it quite
useful to be able to call this from the guest kernel itself at certain
specific points (like before and after cleaning the list of persistent
grants), which is not possible when using the debug key.
> # xl debug-key g
> (XEN) gnttab_usage_print_all [ key 'g' pressed
> (XEN) -------- active -------- -------- shared --------
> (XEN) [ref] localdom mfn pin localdom gmfn flags
> (XEN) grant-table for remote domain: 0 ... no active grant table entries
> (XEN) gnttab_usage_print_all ] done
>
> David
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xen: restore GNTTABOP_dump_table
2012-11-16 15:02 ` Roger Pau Monné
@ 2012-11-19 14:29 ` Ian Campbell
2012-11-19 14:38 ` Roger Pau Monné
0 siblings, 1 reply; 6+ messages in thread
From: Ian Campbell @ 2012-11-19 14:29 UTC (permalink / raw)
To: Roger Pau Monné; +Cc: David Vrabel, xen-devel@lists.xen.org
On Fri, 2012-11-16 at 15:02 +0000, Roger Pau Monné wrote:
> On 16/11/12 15:52, David Vrabel wrote:
> > On 19/10/12 16:47, Roger Pau Monne wrote:
> >> This operation was dropped long time ago, but I found it quite helpful
> >> for debugging purposes. This re-implementation uses the code already
> >> present in gnttab_usage_print and adds the maptrack-table dump.
> >
> > Why is the operation useful? Isn't the debug key sufficient?
>
> The debug key doesn't print the maptrack, and also I found it quite
> useful to be able to call this from the guest kernel itself at certain
> specific points (like before and after cleaning the list of persistent
> grants), which is not possible when using the debug key.
I presume this involved temporarily patching Xen to allow this since you
wouldn't want this function to be callable by guests in general.
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xen: restore GNTTABOP_dump_table
2012-11-19 14:29 ` Ian Campbell
@ 2012-11-19 14:38 ` Roger Pau Monné
0 siblings, 0 replies; 6+ messages in thread
From: Roger Pau Monné @ 2012-11-19 14:38 UTC (permalink / raw)
To: Ian Campbell; +Cc: David Vrabel, xen-devel@lists.xen.org
On 19/11/12 15:29, Ian Campbell wrote:
> On Fri, 2012-11-16 at 15:02 +0000, Roger Pau Monné wrote:
>> On 16/11/12 15:52, David Vrabel wrote:
>>> On 19/10/12 16:47, Roger Pau Monne wrote:
>>>> This operation was dropped long time ago, but I found it quite helpful
>>>> for debugging purposes. This re-implementation uses the code already
>>>> present in gnttab_usage_print and adds the maptrack-table dump.
>>>
>>> Why is the operation useful? Isn't the debug key sufficient?
>>
>> The debug key doesn't print the maptrack, and also I found it quite
>> useful to be able to call this from the guest kernel itself at certain
>> specific points (like before and after cleaning the list of persistent
>> grants), which is not possible when using the debug key.
>
> I presume this involved temporarily patching Xen to allow this since you
> wouldn't want this function to be callable by guests in general.
By guest kernel I meant Dom0 kernel, sorry for the confusion. I've
always used the check below to prevent non privileged kernels from
getting this information:
+ if ( !IS_PRIV(current->domain) )
+ return -EPERM;
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-11-19 14:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-19 15:47 [PATCH] xen: restore GNTTABOP_dump_table Roger Pau Monne
2012-11-16 12:24 ` Roger Pau Monné
2012-11-16 14:52 ` David Vrabel
2012-11-16 15:02 ` Roger Pau Monné
2012-11-19 14:29 ` Ian Campbell
2012-11-19 14:38 ` Roger Pau Monné
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).