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