debuggers.hg

changeset 21275:ffcc927a19a4

Add debug-key 'D' to dump EPT p2m table.

Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Apr 23 08:40:58 2010 +0100 (2010-04-23)
parents 49e3aa844902
children c87ec146229a
files xen/arch/x86/hvm/vmx/vmx.c xen/arch/x86/mm/hap/p2m-ept.c xen/include/asm-x86/hvm/vmx/vmx.h
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Fri Apr 23 08:39:29 2010 +0100
     1.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Fri Apr 23 08:40:58 2010 +0100
     1.3 @@ -1444,7 +1444,10 @@ void start_vmx(void)
     1.4      }
     1.5  
     1.6      if ( cpu_has_vmx_ept )
     1.7 +    {
     1.8          vmx_function_table.hap_supported = 1;
     1.9 +        setup_ept_dump();
    1.10 +    }
    1.11      
    1.12      vmx_function_table.hap_1gb_pgtb = ( vmx_ept_super_page_level_limit == 2 ) ?
    1.13                                          1 : 0;
     2.1 --- a/xen/arch/x86/mm/hap/p2m-ept.c	Fri Apr 23 08:39:29 2010 +0100
     2.2 +++ b/xen/arch/x86/mm/hap/p2m-ept.c	Fri Apr 23 08:40:58 2010 +0100
     2.3 @@ -29,6 +29,8 @@
     2.4  #include <xen/iommu.h>
     2.5  #include <asm/mtrr.h>
     2.6  #include <asm/hvm/cacheattr.h>
     2.7 +#include <xen/keyhandler.h>
     2.8 +#include <xen/softirq.h>
     2.9  
    2.10  /* Non-ept "lock-and-check" wrapper */
    2.11  static int ept_pod_check_and_populate(struct domain *d, unsigned long gfn,
    2.12 @@ -725,6 +727,77 @@ void ept_p2m_init(struct domain *d)
    2.13      d->arch.p2m->change_entry_type_global = ept_change_entry_type_global;
    2.14  }
    2.15  
    2.16 +static void ept_dump_p2m_table(unsigned char key)
    2.17 +{
    2.18 +    struct domain *d;
    2.19 +    ept_entry_t *table, *ept_entry;
    2.20 +    mfn_t mfn;
    2.21 +    int order;
    2.22 +    int i;
    2.23 +    int is_pod;
    2.24 +    int ret;
    2.25 +    unsigned long index;
    2.26 +    unsigned long gfn, gfn_remainder;
    2.27 +    unsigned long record_counter = 0;
    2.28 +
    2.29 +    for_each_domain(d)
    2.30 +    {
    2.31 +        if ( !(is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled) )
    2.32 +            continue;
    2.33 +
    2.34 +        printk("\ndomain%d EPT p2m table: \n", d->domain_id);
    2.35 +
    2.36 +        for ( gfn = 0; gfn <= d->arch.p2m->max_mapped_pfn; gfn += (1 << order) )
    2.37 +        {
    2.38 +            gfn_remainder = gfn;
    2.39 +            mfn = _mfn(INVALID_MFN);
    2.40 +            table =
    2.41 +                map_domain_page(mfn_x(pagetable_get_mfn(d->arch.phys_table)));
    2.42 +
    2.43 +            for ( i = EPT_DEFAULT_GAW; i > 0; i-- )
    2.44 +            {
    2.45 +                ret = ept_next_level(d, 1, &table, &gfn_remainder,
    2.46 +                                     i * EPT_TABLE_ORDER);
    2.47 +                if ( ret != GUEST_TABLE_NORMAL_PAGE )
    2.48 +                    break;
    2.49 +            }
    2.50 +
    2.51 +            order = i * EPT_TABLE_ORDER;
    2.52 +
    2.53 +            if ( ret == GUEST_TABLE_MAP_FAILED )
    2.54 +                goto out;
    2.55 +
    2.56 +            index = gfn_remainder >> order;
    2.57 +            ept_entry = table + index;
    2.58 +            if ( ept_entry->avail1 != p2m_invalid )
    2.59 +            {
    2.60 +                ( ept_entry->avail1 == p2m_populate_on_demand ) ? 
    2.61 +                ( mfn = _mfn(INVALID_MFN), is_pod = 1 ) :
    2.62 +                ( mfn = _mfn(ept_entry->mfn), is_pod = 0 );
    2.63 +
    2.64 +                printk("gfn: %-16lx  mfn: %-16lx  order: %2d  is_pod: %d\n",
    2.65 +                       gfn, mfn_x(mfn), order, is_pod);
    2.66 +
    2.67 +                if ( !(record_counter++ % 100) )
    2.68 +                    process_pending_softirqs();
    2.69 +            }
    2.70 +out:
    2.71 +            unmap_domain_page(table);
    2.72 +        }
    2.73 +    }
    2.74 +}
    2.75 +
    2.76 +static struct keyhandler ept_p2m_table = {
    2.77 +    .diagnostic = 0,
    2.78 +    .u.fn = ept_dump_p2m_table,
    2.79 +    .desc = "dump ept p2m table"
    2.80 +};
    2.81 +
    2.82 +void setup_ept_dump(void)
    2.83 +{
    2.84 +    register_keyhandler('D', &ept_p2m_table);
    2.85 +}
    2.86 +
    2.87  /*
    2.88   * Local variables:
    2.89   * mode: C
     3.1 --- a/xen/include/asm-x86/hvm/vmx/vmx.h	Fri Apr 23 08:39:29 2010 +0100
     3.2 +++ b/xen/include/asm-x86/hvm/vmx/vmx.h	Fri Apr 23 08:40:58 2010 +0100
     3.3 @@ -357,6 +357,7 @@ void vmx_inject_nmi(void);
     3.4  
     3.5  void ept_p2m_init(struct domain *d);
     3.6  void ept_walk_table(struct domain *d, unsigned long gfn);
     3.7 +void setup_ept_dump(void);
     3.8  
     3.9  /* EPT violation qualifications definitions */
    3.10  #define _EPT_READ_VIOLATION         0