[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] EPT: Walk and print EPT tables on an unexpected EPT violation



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1262949858 0
# Node ID 13b349c42eed80cd12549e17b8f4ead3df50ffbc
# Parent  5e8b6ecd045e827f3229f3a2fb15621946c50a6b
EPT: Walk and print EPT tables on an unexpected EPT violation

Wrote this when I was tracking down the HAP-PoD problem, figured it
might come in handy sometime.

Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
---
 xen/arch/x86/hvm/vmx/vmx.c        |    2 +
 xen/arch/x86/mm/hap/p2m-ept.c     |   49 ++++++++++++++++++++++++++++++++++++++
 xen/include/asm-x86/hvm/vmx/vmx.h |    1 
 3 files changed, 52 insertions(+)

diff -r 5e8b6ecd045e -r 13b349c42eed xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c        Fri Jan 08 11:22:41 2010 +0000
+++ b/xen/arch/x86/hvm/vmx/vmx.c        Fri Jan 08 11:24:18 2010 +0000
@@ -2116,6 +2116,8 @@ static void ept_handle_violation(unsigne
              (qualification & EPT_EFFECTIVE_EXEC) ? 'x' : '-',
              gpa, mfn_x(mfn), p2mt);
 
+    ept_walk_table(current->domain, gfn);
+
     if ( qualification & EPT_GLA_VALID )
     {
         gla = __vmread(GUEST_LINEAR_ADDRESS);
diff -r 5e8b6ecd045e -r 13b349c42eed xen/arch/x86/mm/hap/p2m-ept.c
--- a/xen/arch/x86/mm/hap/p2m-ept.c     Fri Jan 08 11:22:41 2010 +0000
+++ b/xen/arch/x86/mm/hap/p2m-ept.c     Fri Jan 08 11:24:18 2010 +0000
@@ -496,6 +496,55 @@ static ept_entry_t ept_get_entry_content
     return content;
 }
 
+void ept_walk_table(struct domain *d, unsigned long gfn)
+{
+    ept_entry_t *table =
+        map_domain_page(mfn_x(pagetable_get_mfn(d->arch.phys_table)));
+    unsigned long gfn_remainder = gfn;
+
+    int i;
+
+    gdprintk(XENLOG_ERR, "Walking EPT tables for domain %d gfn %lx\n",
+           d->domain_id, gfn);
+
+    /* This pfn is higher than the highest the p2m map currently holds */
+    if ( gfn > d->arch.p2m->max_mapped_pfn )
+    {
+        gdprintk(XENLOG_ERR, " gfn exceeds max_mapped_pfn %lx\n",
+               d->arch.p2m->max_mapped_pfn);
+        goto out;
+    }
+
+    for ( i = EPT_DEFAULT_GAW; i >= 0; i-- )
+    {
+        ept_entry_t *ept_entry, *next;
+        u32 index;
+
+        /* Stolen from ept_next_level */
+        index = gfn_remainder >> (i*EPT_TABLE_ORDER);
+        ept_entry = table + index;
+
+        gdprintk(XENLOG_ERR, " epte %"PRIx64"\n", ept_entry->epte);
+
+        if ( i==0 || !(ept_entry->epte & 0x7) || ept_entry->sp_avail)
+            goto out;
+        else
+        {
+            gfn_remainder &= (1UL << (i*EPT_TABLE_ORDER)) - 1;
+
+            next = map_domain_page(ept_entry->mfn);
+
+            unmap_domain_page(*table);
+
+            table = next;
+        }
+    }
+
+out:
+    unmap_domain_page(table);
+    return;
+}
+
 static mfn_t ept_get_entry_current(unsigned long gfn, p2m_type_t *t,
                                    p2m_query_t q)
 {
diff -r 5e8b6ecd045e -r 13b349c42eed xen/include/asm-x86/hvm/vmx/vmx.h
--- a/xen/include/asm-x86/hvm/vmx/vmx.h Fri Jan 08 11:22:41 2010 +0000
+++ b/xen/include/asm-x86/hvm/vmx/vmx.h Fri Jan 08 11:24:18 2010 +0000
@@ -357,6 +357,7 @@ void vmx_inject_nmi(void);
 void vmx_inject_nmi(void);
 
 void ept_p2m_init(struct domain *d);
+void ept_walk_table(struct domain *d, unsigned long gfn);
 
 /* EPT violation qualifications definitions */
 #define _EPT_READ_VIOLATION         0

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.