From mboxrd@z Thu Jan 1 00:00:00 1970 From: Don Slutz Subject: [PATCH v7 13/17] xenctx: Add convert of more registers to symbols Date: Fri, 21 Mar 2014 13:43:46 -0400 Message-ID: <532C7A52.5010507@terremark.com> References: <1395342425-16260-1-git-send-email-dslutz@verizon.com> <1395342425-16260-14-git-send-email-dslutz@verizon.com> <532C218B0200007800126737@nat28.tlf.novell.com> <532C31EF.9010404@terremark.com> <532C487C.7020904@terremark.com> <532C5E7F0200007800126A41@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020507080009040100000803" Return-path: In-Reply-To: <532C5E7F0200007800126A41@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: Ian Campbell , Stefano Stabellini , George Dunlap , Ian Jackson , Don Slutz , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------020507080009040100000803 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 03/21/14 10:45, Jan Beulich wrote: >>>> On 21.03.14 at 15:11, Don Slutz wrote: >> --- a/tools/xentrace/xenctx.c >> +++ b/tools/xentrace/xenctx.c >> @@ -106,6 +106,9 @@ unsigned long long kernel_start = 0xffffffff80000000UL; >> unsigned long long kernel_start = 0xffffff8000000000UL; >> #endif >> >> +static const uint64_t cr_reg_mask[5] = { [2] = ~UINT64_C(0) }; >> +static const uint64_t dr_reg_mask[8] = { [0 ... 3] = ~UINT64_C(0) }; > This should be in an x86-specific section (preferably be added to > an existing one rather than adding yet another). > > Also the patch came through line wrapped. > > Jan > Here is v7 with them moved (and hopefully not line wrapped): From bc8a441b718e302128f59a53908a1c05afca8680 Mon Sep 17 00:00:00 2001 From: Don Slutz Date: Sat, 9 Nov 2013 20:32:40 -0500 Subject: [PATCH 13/17] xenctx: Add convert of more registers to symbols For example can change: gs: 0000 @ ffffffff803ac000/0000000000000000 to gs: 0000 @ ffffffff803ac000/0000000000000000 boot_cpu_pda/ Signed-off-by: Don Slutz --- tools/xentrace/xenctx.c | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c index c574996..e6e41b6 100644 --- a/tools/xentrace/xenctx.c +++ b/tools/xentrace/xenctx.c @@ -43,6 +43,8 @@ typedef enum type_of_addr_ { } type_of_addr; #if defined (__i386__) || defined (__x86_64__) +static const uint64_t cr_reg_mask[5] = { [2] = ~UINT64_C(0) }; +static const uint64_t dr_reg_mask[8] = { [0 ... 3] = ~UINT64_C(0) }; typedef unsigned long long guest_word_t; #define FMT_32B_WORD "%08llx" #define FMT_64B_WORD "%016llx" @@ -330,17 +332,29 @@ static void print_flags(uint64_t flags) printf("\n"); } -static void print_special(void *regs, const char *name, unsigned int mask, int width) +static void print_special(void *regs, const char *name, unsigned int mask, + const uint64_t reg_is_addr_mask[], int width) { unsigned int i; printf("\n"); for (i = 0; mask; mask >>= 1, ++i) if (mask & 1) { - if (width == 4) - printf("%s%u: %08"PRIx32"\n", name, i, ((uint32_t *) regs)[i]); + if ( width == 4 ) + { + printf("%s%u: %08"PRIx32, name, i, ((uint32_t *) regs)[i]); + if ( reg_is_addr_mask[i] ) + print_symbol(reg_is_addr_mask[i] & ((uint32_t *) regs)[i], + KERNEL_DATA_ADDR); + } else - printf("%s%u: %08"PRIx64"\n", name, i, ((uint64_t *) regs)[i]); + { + printf("%s%u: %016"PRIx64, name, i, ((uint64_t *) regs)[i]); + if ( reg_is_addr_mask[i] ) + print_symbol(reg_is_addr_mask[i] & ((uint64_t *) regs)[i], + KERNEL_DATA_ADDR); + } + printf("\n"); } } @@ -368,8 +382,8 @@ static void print_ctx_32(vcpu_guest_context_x86_32_t *ctx) printf(" gs: %04x\n", regs->gs); if (xenctx.disp_all) { - print_special(ctx->ctrlreg, "cr", 0x1d, 4); - print_special(ctx->debugreg, "dr", 0xcf, 4); + print_special(ctx->ctrlreg, "cr", 0x1d, cr_reg_mask, 4); + print_special(ctx->debugreg, "dr", 0xcf, dr_reg_mask, 4); } } @@ -397,8 +411,8 @@ static void print_ctx_32on64(vcpu_guest_context_x86_64_t *ctx) printf(" gs: %04x\n", regs->gs); if (xenctx.disp_all) { - print_special(ctx->ctrlreg, "cr", 0x1d, 4); - print_special(ctx->debugreg, "dr", 0xcf, 4); + print_special(ctx->ctrlreg, "cr", 0x1d, cr_reg_mask, 4); + print_special(ctx->debugreg, "dr", 0xcf, dr_reg_mask, 4); } } @@ -436,13 +450,21 @@ static void print_ctx_64(vcpu_guest_context_x86_64_t *ctx) printf(" ds: %04x\t", regs->ds); printf(" es: %04x\n", regs->es); - printf(" fs: %04x @ %016"PRIx64"\n", regs->fs, ctx->fs_base); - printf(" gs: %04x @ %016"PRIx64"/%016"PRIx64"\n", regs->gs, + printf(" fs: %04x @ %016"PRIx64, regs->fs, ctx->fs_base); + print_symbol(ctx->fs_base, KERNEL_DATA_ADDR); + printf("\n"); + printf(" gs: %04x @ %016"PRIx64"/%016"PRIx64, regs->gs, ctx->gs_base_kernel, ctx->gs_base_user); + if (symbol_table) { + print_symbol(ctx->gs_base_kernel, KERNEL_DATA_ADDR); + printf("/"); + print_symbol(ctx->gs_base_user, KERNEL_DATA_ADDR); + } + printf("\n"); if (xenctx.disp_all) { - print_special(ctx->ctrlreg, "cr", 0x1d, 8); - print_special(ctx->debugreg, "dr", 0xcf, 8); + print_special(ctx->ctrlreg, "cr", 0x1d, cr_reg_mask, 8); + print_special(ctx->debugreg, "dr", 0xcf, dr_reg_mask, 8); } } -- 1.7.11.7 Attached also just in case. -Don Slutz --------------020507080009040100000803 Content-Type: text/x-patch; name="0013-xenctx-Add-convert-of-more-registers-to-symbols.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0013-xenctx-Add-convert-of-more-registers-to-symbols.patch" >>From bc8a441b718e302128f59a53908a1c05afca8680 Mon Sep 17 00:00:00 2001 From: Don Slutz Date: Sat, 9 Nov 2013 20:32:40 -0500 Subject: [PATCH 13/17] xenctx: Add convert of more registers to symbols For example can change: gs: 0000 @ ffffffff803ac000/0000000000000000 to gs: 0000 @ ffffffff803ac000/0000000000000000 boot_cpu_pda/ Signed-off-by: Don Slutz --- tools/xentrace/xenctx.c | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c index c574996..e6e41b6 100644 --- a/tools/xentrace/xenctx.c +++ b/tools/xentrace/xenctx.c @@ -43,6 +43,8 @@ typedef enum type_of_addr_ { } type_of_addr; #if defined (__i386__) || defined (__x86_64__) +static const uint64_t cr_reg_mask[5] = { [2] = ~UINT64_C(0) }; +static const uint64_t dr_reg_mask[8] = { [0 ... 3] = ~UINT64_C(0) }; typedef unsigned long long guest_word_t; #define FMT_32B_WORD "%08llx" #define FMT_64B_WORD "%016llx" @@ -330,17 +332,29 @@ static void print_flags(uint64_t flags) printf("\n"); } -static void print_special(void *regs, const char *name, unsigned int mask, int width) +static void print_special(void *regs, const char *name, unsigned int mask, + const uint64_t reg_is_addr_mask[], int width) { unsigned int i; printf("\n"); for (i = 0; mask; mask >>= 1, ++i) if (mask & 1) { - if (width == 4) - printf("%s%u: %08"PRIx32"\n", name, i, ((uint32_t *) regs)[i]); + if ( width == 4 ) + { + printf("%s%u: %08"PRIx32, name, i, ((uint32_t *) regs)[i]); + if ( reg_is_addr_mask[i] ) + print_symbol(reg_is_addr_mask[i] & ((uint32_t *) regs)[i], + KERNEL_DATA_ADDR); + } else - printf("%s%u: %08"PRIx64"\n", name, i, ((uint64_t *) regs)[i]); + { + printf("%s%u: %016"PRIx64, name, i, ((uint64_t *) regs)[i]); + if ( reg_is_addr_mask[i] ) + print_symbol(reg_is_addr_mask[i] & ((uint64_t *) regs)[i], + KERNEL_DATA_ADDR); + } + printf("\n"); } } @@ -368,8 +382,8 @@ static void print_ctx_32(vcpu_guest_context_x86_32_t *ctx) printf(" gs: %04x\n", regs->gs); if (xenctx.disp_all) { - print_special(ctx->ctrlreg, "cr", 0x1d, 4); - print_special(ctx->debugreg, "dr", 0xcf, 4); + print_special(ctx->ctrlreg, "cr", 0x1d, cr_reg_mask, 4); + print_special(ctx->debugreg, "dr", 0xcf, dr_reg_mask, 4); } } @@ -397,8 +411,8 @@ static void print_ctx_32on64(vcpu_guest_context_x86_64_t *ctx) printf(" gs: %04x\n", regs->gs); if (xenctx.disp_all) { - print_special(ctx->ctrlreg, "cr", 0x1d, 4); - print_special(ctx->debugreg, "dr", 0xcf, 4); + print_special(ctx->ctrlreg, "cr", 0x1d, cr_reg_mask, 4); + print_special(ctx->debugreg, "dr", 0xcf, dr_reg_mask, 4); } } @@ -436,13 +450,21 @@ static void print_ctx_64(vcpu_guest_context_x86_64_t *ctx) printf(" ds: %04x\t", regs->ds); printf(" es: %04x\n", regs->es); - printf(" fs: %04x @ %016"PRIx64"\n", regs->fs, ctx->fs_base); - printf(" gs: %04x @ %016"PRIx64"/%016"PRIx64"\n", regs->gs, + printf(" fs: %04x @ %016"PRIx64, regs->fs, ctx->fs_base); + print_symbol(ctx->fs_base, KERNEL_DATA_ADDR); + printf("\n"); + printf(" gs: %04x @ %016"PRIx64"/%016"PRIx64, regs->gs, ctx->gs_base_kernel, ctx->gs_base_user); + if (symbol_table) { + print_symbol(ctx->gs_base_kernel, KERNEL_DATA_ADDR); + printf("/"); + print_symbol(ctx->gs_base_user, KERNEL_DATA_ADDR); + } + printf("\n"); if (xenctx.disp_all) { - print_special(ctx->ctrlreg, "cr", 0x1d, 8); - print_special(ctx->debugreg, "dr", 0xcf, 8); + print_special(ctx->ctrlreg, "cr", 0x1d, cr_reg_mask, 8); + print_special(ctx->debugreg, "dr", 0xcf, dr_reg_mask, 8); } } -- 1.7.11.7 --------------020507080009040100000803 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --------------020507080009040100000803--