diff mbox

[Xen-devel,for-xen-4-5,v4] xen/arm: dump guest stack even if not the current VCPU

Message ID CAHt6W4frKnbRF2gZPDAOjWeZY_uVDquOQrJh6mqZoMpCpU_9cg@mail.gmail.com
State New
Headers show

Commit Message

Frediano Ziglio Oct. 23, 2014, 4:18 p.m. UTC
From: Frediano Ziglio <frediano.ziglio@huawei.com>

If show_guest_stack was called from Xen context (for instance hitting
'0' key on Xen console) get_page_from_gva was not able to get the
page returning NULL.
Detecting different domain and changing VTTBR register make
get_page_from_gva works for different domains.

Signed-off-by: Frediano Ziglio <frediano.ziglio@huawei.com>
---
 xen/arch/arm/p2m.c   | 24 ++++++++++++++++++++----
 xen/arch/arm/traps.c |  2 +-
 2 files changed, 21 insertions(+), 5 deletions(-)

This is a bug fix to fix guest stack dumps.

The function get_page_from_gva is used in hot path (see
arch/arm/guestcopy.c) but always with the current domain. The function
will be used with another domain than current only when the stack of
the guest will be dumped. The code added is self-containted.

Changed from v3:
- removed a possible false warning from some compilers.

         printk("Failed to convert stack to physical address\n");

Comments

Ian Campbell Oct. 27, 2014, 10:46 a.m. UTC | #1
On Thu, 2014-10-23 at 17:18 +0100, Frediano Ziglio wrote:
> From: Frediano Ziglio <frediano.ziglio@huawei.com>
> 
> If show_guest_stack was called from Xen context (for instance hitting
> '0' key on Xen console) get_page_from_gva was not able to get the
> page returning NULL.
> Detecting different domain and changing VTTBR register make
> get_page_from_gva works for different domains.
> 
> Signed-off-by: Frediano Ziglio <frediano.ziglio@huawei.com>

Acked + applied, even though it was whitespace damaged again.
diff mbox

Patch

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 1585d35..bad2b18 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1176,13 +1176,29 @@  struct page_info *get_page_from_gva(struct domain *d
 {
     struct p2m_domain *p2m = &d->arch.p2m;
     struct page_info *page = NULL;
-    paddr_t maddr;
-
-    ASSERT(d == current->domain);
+    paddr_t maddr = 0;
+    int rc;

     spin_lock(&p2m->lock);

-    if ( gvirt_to_maddr(va, &maddr, flags) )
+    if ( unlikely(d != current->domain) )
+    {
+        unsigned long irq_flags;
+
+        local_irq_save(irq_flags);
+        p2m_load_VTTBR(d);
+
+        rc = gvirt_to_maddr(va, &maddr, flags);
+
+        p2m_load_VTTBR(current->domain);
+        local_irq_restore(irq_flags);
+    }
+    else
+    {
+        rc = gvirt_to_maddr(va, &maddr, flags);
+    }
+
+    if ( rc )
         goto err;

     if ( !mfn_valid(maddr >> PAGE_SHIFT) )
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index f6fc8f8..4c93250 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -892,7 +892,7 @@  static void show_guest_stack(struct vcpu *v,
struct cpu_user_regs *regs)
         return;
     }

-    page = get_page_from_gva(current->domain, sp, GV2M_READ);
+    page = get_page_from_gva(v->domain, sp, GV2M_READ);
     if ( page == NULL )
     {