From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xen.org
Cc: julien.grall@citrix.com, tim@xen.org,
Ian Campbell <ian.campbell@citrix.com>,
stefano.stabellini@eu.citrix.com
Subject: [PATCH 07/17] xen: arm: support dumping 64-bit guest stack
Date: Mon, 29 Jul 2013 13:20:56 +0100 [thread overview]
Message-ID: <1375100466-7564-7-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1375100431.14896.95.camel@kazak.uk.xensource.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
xen/arch/arm/traps.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 76 insertions(+), 4 deletions(-)
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 3d33fba..a757d47 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -574,9 +574,81 @@ void vcpu_show_registers(const struct vcpu *v)
_show_registers(&v->arch.cpu_info->guest_cpu_user_regs, &ctxt, 1, v);
}
-static void show_guest_stack(struct cpu_user_regs *regs)
+static void show_guest_stack(struct vcpu *v, struct cpu_user_regs *regs)
{
- printk("GUEST STACK GOES HERE\n");
+ int i;
+ vaddr_t sp;
+ paddr_t stack_phys;
+ void *mapped;
+ unsigned long *stack, addr;
+
+ switch ( regs->cpsr & PSR_MODE_MASK )
+ {
+ case PSR_MODE_USR:
+ case PSR_MODE_SYS:
+#ifdef CONFIG_ARM_64
+ case PSR_MODE_EL0t:
+#endif
+ printk("No stack trace for guest user-mode\n");
+ return;
+
+ case PSR_MODE_FIQ:
+ case PSR_MODE_IRQ:
+ case PSR_MODE_SVC:
+ case PSR_MODE_ABT:
+ case PSR_MODE_UND:
+ printk("No stack trace for 32-bit guest kernel-mode\n");
+ return;
+
+#ifdef CONFIG_ARM_64
+ case PSR_MODE_EL1t:
+ sp = regs->sp_el0;
+ break;
+ case PSR_MODE_EL1h:
+ sp = regs->sp_el1;
+ break;
+#endif
+
+ case PSR_MODE_HYP:
+ case PSR_MODE_MON:
+#ifdef CONFIG_ARM_64
+ case PSR_MODE_EL3h:
+ case PSR_MODE_EL3t:
+ case PSR_MODE_EL2h:
+ case PSR_MODE_EL2t:
+#endif
+ default:
+ BUG();
+ return;
+ }
+
+ printk("Guest stack trace from sp=%"PRIvaddr":\n ", sp);
+
+ if ( gvirt_to_maddr(sp, &stack_phys) )
+ {
+ printk("Failed to convert stack to physical address\n");
+ return;
+ }
+
+ mapped = map_domain_page(stack_phys >> PAGE_SHIFT);
+
+ stack = mapped + (sp & ~PAGE_MASK);
+
+ for ( i = 0; i < (debug_stack_lines*stack_words_per_line); i++ )
+ {
+ if ( (((long)stack - 1) ^ ((long)(stack + 1) - 1)) & PAGE_SIZE )
+ break;
+ addr = *stack;
+ if ( (i != 0) && ((i % stack_words_per_line) == 0) )
+ printk("\n ");
+ printk(" %p", _p(addr));
+ stack++;
+ }
+ if ( i == 0 )
+ printk("Stack empty.");
+ printk("\n");
+ unmap_domain_page(mapped);
+
}
#define STACK_BEFORE_EXCEPTION(regs) ((register_t*)(regs)->sp)
@@ -659,7 +731,7 @@ void show_stack(struct cpu_user_regs *regs)
int i;
if ( guest_mode(regs) )
- return show_guest_stack(regs);
+ return show_guest_stack(current, regs);
printk("Xen stack trace from sp=%p:\n ", stack);
@@ -701,7 +773,7 @@ void vcpu_show_execution_state(struct vcpu *v)
vcpu_show_registers(v);
if ( !usr_mode(&v->arch.cpu_info->guest_cpu_user_regs) )
- show_guest_stack(&v->arch.cpu_info->guest_cpu_user_regs);
+ show_guest_stack(v, &v->arch.cpu_info->guest_cpu_user_regs);
vcpu_unpause(v);
}
--
1.7.2.5
next prev parent reply other threads:[~2013-07-29 12:20 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-29 12:20 [PATCH v4 00/17] xen: arm: 64-bit dom0 kernel support Ian Campbell
2013-07-29 12:20 ` [PATCH 01/17] xen: arm: tweak arm64 stack frame layout Ian Campbell
2013-07-29 12:20 ` [PATCH 02/17] xen: arm: rename 32-bit specific zImage field offset constants Ian Campbell
2013-07-29 12:20 ` [PATCH 03/17] xen: arm: support for loading 64-bit zImage dom0 Ian Campbell
2013-07-29 12:20 ` [PATCH 04/17] xen: arm: support building a 64-bit dom0 domain Ian Campbell
2013-07-29 18:29 ` Julien Grall
2013-07-30 9:34 ` Ian Campbell
2013-07-30 9:43 ` Julien Grall
2013-08-02 16:07 ` Ian Campbell
2013-07-29 12:20 ` [PATCH 05/17] xen: arm: precalculate VTTBR_EL2 for a domain when setting up its p2m Ian Campbell
2013-07-29 12:20 ` [PATCH 06/17] xen: arm: improve register dump output for 64-bit guest (and more generally too) Ian Campbell
2013-07-29 12:53 ` Tim Deegan
2013-07-29 12:20 ` Ian Campbell [this message]
2013-07-29 12:20 ` [PATCH 08/17] xen: arm: show less words in a line of a stack trace in 64-bit builds Ian Campbell
2013-07-29 12:20 ` [PATCH 09/17] xen: arm: Set EL1 register width in HCR_EL2 during context switch Ian Campbell
2013-07-29 12:20 ` [PATCH 10/17] xen: arm: some cleanups to hypervisor entry code Ian Campbell
2013-07-29 12:56 ` Tim Deegan
2013-07-29 12:21 ` [PATCH 11/17] xen: arm: refactor 64-bit return from trap path Ian Campbell
2013-07-29 13:01 ` Tim Deegan
2013-07-29 12:21 ` [PATCH 12/17] xen: arm: handle traps from 64-bit guests Ian Campbell
2013-07-29 13:49 ` Tim Deegan
2013-07-29 12:21 ` [PATCH 13/17] xen: arm: handle hypercalls " Ian Campbell
2013-07-29 12:21 ` [PATCH 14/17] xen: arm: handle 64-bit system register access traps Ian Campbell
2013-07-29 12:21 ` [PATCH 15/17] xen: arm: align some comments Ian Campbell
2013-07-29 12:21 ` [PATCH 16/17] xen: arm: document HCR bits Ian Campbell
2013-07-29 12:21 ` [PATCH 17/17] xen: arm: Handle SMC from 64-bit guests Ian Campbell
2013-07-29 13:53 ` Tim Deegan
2013-07-29 12:21 ` [PATCH v4 00/17] xen: arm: 64-bit dom0 kernel support Ian Campbell
2013-07-29 15:58 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1375100466-7564-7-git-send-email-ian.campbell@citrix.com \
--to=ian.campbell@citrix.com \
--cc=julien.grall@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).