debuggers.hg
changeset 18990:0cd1ba8bd7cd
PoD (populate-on-demand) memory 1/9: Add a p2m query type.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Mon Jan 05 10:41:48 2009 +0000 (2009-01-05) |
parents | de38a475ab9e |
children | 629f028d22f9 |
files | xen/arch/x86/mm/hap/p2m-ept.c xen/arch/x86/mm/p2m.c xen/include/asm-x86/guest_pt.h xen/include/asm-x86/p2m.h |
line diff
1.1 --- a/xen/arch/x86/mm/hap/p2m-ept.c Mon Dec 29 14:13:07 2008 +0000 1.2 +++ b/xen/arch/x86/mm/hap/p2m-ept.c Mon Jan 05 10:41:48 2009 +0000 1.3 @@ -274,7 +274,8 @@ out: 1.4 } 1.5 1.6 /* Read ept p2m entries */ 1.7 -static mfn_t ept_get_entry(struct domain *d, unsigned long gfn, p2m_type_t *t) 1.8 +static mfn_t ept_get_entry(struct domain *d, unsigned long gfn, p2m_type_t *t, 1.9 + p2m_query_t q) 1.10 { 1.11 ept_entry_t *table = 1.12 map_domain_page(mfn_x(pagetable_get_mfn(d->arch.phys_table))); 1.13 @@ -359,9 +360,10 @@ static uint64_t ept_get_entry_content(st 1.14 return content; 1.15 } 1.16 1.17 -static mfn_t ept_get_entry_current(unsigned long gfn, p2m_type_t *t) 1.18 +static mfn_t ept_get_entry_current(unsigned long gfn, p2m_type_t *t, 1.19 + p2m_query_t q) 1.20 { 1.21 - return ept_get_entry(current->domain, gfn, t); 1.22 + return ept_get_entry(current->domain, gfn, t, q); 1.23 } 1.24 1.25 void ept_change_entry_emt_with_range(struct domain *d, unsigned long start_gfn,
2.1 --- a/xen/arch/x86/mm/p2m.c Mon Dec 29 14:13:07 2008 +0000 2.2 +++ b/xen/arch/x86/mm/p2m.c Mon Jan 05 10:41:48 2009 +0000 2.3 @@ -345,7 +345,8 @@ p2m_set_entry(struct domain *d, unsigned 2.4 } 2.5 2.6 static mfn_t 2.7 -p2m_gfn_to_mfn(struct domain *d, unsigned long gfn, p2m_type_t *t) 2.8 +p2m_gfn_to_mfn(struct domain *d, unsigned long gfn, p2m_type_t *t, 2.9 + p2m_query_t q) 2.10 { 2.11 mfn_t mfn; 2.12 paddr_t addr = ((paddr_t)gfn) << PAGE_SHIFT; 2.13 @@ -436,7 +437,8 @@ p2m_gfn_to_mfn(struct domain *d, unsigne 2.14 } 2.15 2.16 /* Read the current domain's p2m table (through the linear mapping). */ 2.17 -static mfn_t p2m_gfn_to_mfn_current(unsigned long gfn, p2m_type_t *t) 2.18 +static mfn_t p2m_gfn_to_mfn_current(unsigned long gfn, p2m_type_t *t, 2.19 + p2m_query_t q) 2.20 { 2.21 mfn_t mfn = _mfn(INVALID_MFN); 2.22 p2m_type_t p2mt = p2m_mmio_dm;
3.1 --- a/xen/include/asm-x86/guest_pt.h Mon Dec 29 14:13:07 2008 +0000 3.2 +++ b/xen/include/asm-x86/guest_pt.h Mon Jan 05 10:41:48 2009 +0000 3.3 @@ -49,7 +49,7 @@ gfn_to_paddr(gfn_t gfn) 3.4 3.5 /* Override gfn_to_mfn to work with gfn_t */ 3.6 #undef gfn_to_mfn 3.7 -#define gfn_to_mfn(d, g, t) _gfn_to_mfn((d), gfn_x(g), (t)) 3.8 +#define gfn_to_mfn(d, g, t) _gfn_to_mfn_type((d), gfn_x(g), (t), p2m_alloc) 3.9 3.10 3.11 /* Types of the guest's page tables and access functions for them */
4.1 --- a/xen/include/asm-x86/p2m.h Mon Dec 29 14:13:07 2008 +0000 4.2 +++ b/xen/include/asm-x86/p2m.h Mon Jan 05 10:41:48 2009 +0000 4.3 @@ -66,6 +66,12 @@ typedef enum { 4.4 p2m_mmio_direct = 5, /* Read/write mapping of genuine MMIO area */ 4.5 } p2m_type_t; 4.6 4.7 +typedef enum { 4.8 + p2m_query = 0, /* Do not populate a PoD entries */ 4.9 + p2m_alloc = 1, /* Automatically populate PoD entries */ 4.10 + p2m_guest = 2, /* Guest demand-fault; implies alloc */ 4.11 +} p2m_query_t; 4.12 + 4.13 /* We use bitmaps and maks to handle groups of types */ 4.14 #define p2m_to_mask(_t) (1UL << (_t)) 4.15 4.16 @@ -105,9 +111,11 @@ struct p2m_domain { 4.17 mfn_t mfn, unsigned int page_order, 4.18 p2m_type_t p2mt); 4.19 mfn_t (*get_entry )(struct domain *d, unsigned long gfn, 4.20 - p2m_type_t *p2mt); 4.21 + p2m_type_t *p2mt, 4.22 + p2m_query_t q); 4.23 mfn_t (*get_entry_current)(unsigned long gfn, 4.24 - p2m_type_t *p2mt); 4.25 + p2m_type_t *p2mt, 4.26 + p2m_query_t q); 4.27 void (*change_entry_type_global)(struct domain *d, 4.28 p2m_type_t ot, 4.29 p2m_type_t nt); 4.30 @@ -123,23 +131,26 @@ static inline p2m_type_t p2m_flags_to_ty 4.31 return (flags >> 9) & 0x7; 4.32 } 4.33 4.34 -/* Read the current domain's p2m table. */ 4.35 -static inline mfn_t gfn_to_mfn_current(unsigned long gfn, p2m_type_t *t) 4.36 +/* Read the current domain's p2m table. Do not populate PoD pages. */ 4.37 +static inline mfn_t gfn_to_mfn_type_current(unsigned long gfn, p2m_type_t *t, 4.38 + p2m_query_t q) 4.39 { 4.40 - return current->domain->arch.p2m->get_entry_current(gfn, t); 4.41 + return current->domain->arch.p2m->get_entry_current(gfn, t, q); 4.42 } 4.43 4.44 -/* Read another domain's P2M table, mapping pages as we go */ 4.45 +/* Read another domain's P2M table, mapping pages as we go. 4.46 + * Do not populate PoD pages. */ 4.47 static inline 4.48 -mfn_t gfn_to_mfn_foreign(struct domain *d, unsigned long gfn, p2m_type_t *t) 4.49 +mfn_t gfn_to_mfn_type_foreign(struct domain *d, unsigned long gfn, p2m_type_t *t, 4.50 + p2m_query_t q) 4.51 { 4.52 - return d->arch.p2m->get_entry(d, gfn, t); 4.53 + return d->arch.p2m->get_entry(d, gfn, t, q); 4.54 } 4.55 4.56 /* General conversion function from gfn to mfn */ 4.57 -#define gfn_to_mfn(d, g, t) _gfn_to_mfn((d), (g), (t)) 4.58 -static inline mfn_t _gfn_to_mfn(struct domain *d, 4.59 - unsigned long gfn, p2m_type_t *t) 4.60 +static inline mfn_t _gfn_to_mfn_type(struct domain *d, 4.61 + unsigned long gfn, p2m_type_t *t, 4.62 + p2m_query_t q) 4.63 { 4.64 if ( !paging_mode_translate(d) ) 4.65 { 4.66 @@ -149,11 +160,18 @@ static inline mfn_t _gfn_to_mfn(struct d 4.67 return _mfn(gfn); 4.68 } 4.69 if ( likely(current->domain == d) ) 4.70 - return gfn_to_mfn_current(gfn, t); 4.71 + return gfn_to_mfn_type_current(gfn, t, q); 4.72 else 4.73 - return gfn_to_mfn_foreign(d, gfn, t); 4.74 + return gfn_to_mfn_type_foreign(d, gfn, t, q); 4.75 } 4.76 4.77 +#define gfn_to_mfn(d, g, t) _gfn_to_mfn_type((d), (g), (t), p2m_alloc) 4.78 +#define gfn_to_mfn_query(d, g, t) _gfn_to_mfn_type((d), (g), (t), p2m_query) 4.79 +#define gfn_to_mfn_guest(d, g, t) _gfn_to_mfn_type((d), (g), (t), p2m_guest) 4.80 + 4.81 +#define gfn_to_mfn_current(g, t) gfn_to_mfn_type_current((g), (t), p2m_alloc) 4.82 +#define gfn_to_mfn_foreign(d, g, t) gfn_to_mfn_type_foreign((d), (g), (t), p2m_alloc) 4.83 + 4.84 /* Compatibility function exporting the old untyped interface */ 4.85 static inline unsigned long gmfn_to_mfn(struct domain *d, unsigned long gpfn) 4.86 {