diff options
author | Tim Deegan <tim@xen.org> | 2012-03-15 11:46:54 +0000 |
---|---|---|
committer | Tim Deegan <tim@xen.org> | 2012-03-15 11:46:54 +0000 |
commit | 5125dc02d9fb1fd2177aea8af7e1b3b7873357d6 (patch) | |
tree | 40bef0d693c30c9668e38392ff2da0088161773f | |
parent | 923d946a0db1e1f6c2523c5d2e210f7ddd7a33af (diff) | |
download | xen-5125dc02d9fb1fd2177aea8af7e1b3b7873357d6.tar.gz xen-5125dc02d9fb1fd2177aea8af7e1b3b7873357d6.tar.bz2 xen-5125dc02d9fb1fd2177aea8af7e1b3b7873357d6.zip |
x86/mm: make 'query type' argument to get_gfn into a set of flags
Having an enum for this won't work if we want to add any orthogonal
options to it -- the existing code is only correct (after the removal of
p2m_guest in the previous patch) because there are no tests anywhere for
'== p2m_alloc', only for '!= p2m_query' and '== p2m_unshare'.
Replace it with a set of flags.
Signed-off-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
-rw-r--r-- | xen/arch/x86/hvm/emulate.c | 2 | ||||
-rw-r--r-- | xen/arch/x86/hvm/hvm.c | 2 | ||||
-rw-r--r-- | xen/arch/x86/hvm/svm/svm.c | 4 | ||||
-rw-r--r-- | xen/arch/x86/mm/guest_walk.c | 3 | ||||
-rw-r--r-- | xen/arch/x86/mm/hap/guest_walk.c | 6 | ||||
-rw-r--r-- | xen/arch/x86/mm/hap/nested_hap.c | 2 | ||||
-rw-r--r-- | xen/arch/x86/mm/mem_sharing.c | 4 | ||||
-rw-r--r-- | xen/arch/x86/mm/p2m-ept.c | 4 | ||||
-rw-r--r-- | xen/arch/x86/mm/p2m-pod.c | 12 | ||||
-rw-r--r-- | xen/arch/x86/mm/p2m-pt.c | 12 | ||||
-rw-r--r-- | xen/arch/x86/mm/p2m.c | 46 | ||||
-rw-r--r-- | xen/arch/x86/mm/shadow/types.h | 2 | ||||
-rw-r--r-- | xen/include/asm-x86/guest_pt.h | 2 | ||||
-rw-r--r-- | xen/include/asm-x86/p2m.h | 18 |
14 files changed, 62 insertions, 57 deletions
diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index 362f351599..82efd1aa45 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -716,7 +716,7 @@ static int hvmemul_rep_movs( get_two_gfns(current->domain, sgpa >> PAGE_SHIFT, &sp2mt, NULL, NULL, current->domain, dgpa >> PAGE_SHIFT, &dp2mt, NULL, NULL, - p2m_alloc, &tg); + P2M_ALLOC, &tg); if ( !p2m_is_ram(sp2mt) && !p2m_is_grant(sp2mt) ) { diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index dd1412dc7c..9832daf214 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1270,7 +1270,7 @@ int hvm_hap_nested_page_fault(unsigned long gpa, p2m = p2m_get_hostp2m(v->domain); mfn = get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, - access_w ? p2m_unshare : p2m_alloc, NULL); + P2M_ALLOC | (access_w ? P2M_UNSHARE : 0), NULL); /* Check access permissions first, then handle faults */ if ( mfn_x(mfn) != INVALID_MFN ) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 1d000c10f0..f87afd90e2 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1265,7 +1265,7 @@ static void svm_do_nested_pgfault(struct vcpu *v, p2m = p2m_get_p2m(v); _d.gpa = gpa; _d.qualification = 0; - mfn = get_gfn_type_access(p2m, gfn, &_d.p2mt, &p2ma, p2m_query, NULL); + mfn = get_gfn_type_access(p2m, gfn, &_d.p2mt, &p2ma, 0, NULL); __put_gfn(p2m, gfn); _d.mfn = mfn_x(mfn); @@ -1287,7 +1287,7 @@ static void svm_do_nested_pgfault(struct vcpu *v, if ( p2m == NULL ) p2m = p2m_get_p2m(v); /* Everything else is an error. */ - mfn = get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, p2m_query, NULL); + mfn = get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, 0, NULL); __put_gfn(p2m, gfn); gdprintk(XENLOG_ERR, "SVM violation gpa %#"PRIpaddr", mfn %#lx, type %i\n", diff --git a/xen/arch/x86/mm/guest_walk.c b/xen/arch/x86/mm/guest_walk.c index 88fc4f8cf4..ab7785436e 100644 --- a/xen/arch/x86/mm/guest_walk.c +++ b/xen/arch/x86/mm/guest_walk.c @@ -98,7 +98,8 @@ static inline void *map_domain_gfn(struct p2m_domain *p2m, void *map; /* Translate the gfn, unsharing if shared */ - *mfn = get_gfn_type_access(p2m, gfn_x(gfn), p2mt, &p2ma, p2m_unshare, NULL); + *mfn = get_gfn_type_access(p2m, gfn_x(gfn), p2mt, &p2ma, + P2M_ALLOC | P2M_UNSHARE, NULL); if ( p2m_is_paging(*p2mt) ) { ASSERT(!p2m_is_nestedp2m(p2m)); diff --git a/xen/arch/x86/mm/hap/guest_walk.c b/xen/arch/x86/mm/hap/guest_walk.c index afa2a81f37..ee62948131 100644 --- a/xen/arch/x86/mm/hap/guest_walk.c +++ b/xen/arch/x86/mm/hap/guest_walk.c @@ -60,7 +60,8 @@ unsigned long hap_p2m_ga_to_gfn(GUEST_PAGING_LEVELS)( /* Get the top-level table's MFN */ top_gfn = cr3 >> PAGE_SHIFT; - top_mfn = get_gfn_type_access(p2m, top_gfn, &p2mt, &p2ma, p2m_unshare, NULL); + top_mfn = get_gfn_type_access(p2m, top_gfn, &p2mt, &p2ma, + P2M_ALLOC | P2M_UNSHARE, NULL); if ( p2m_is_paging(p2mt) ) { ASSERT(!p2m_is_nestedp2m(p2m)); @@ -96,7 +97,8 @@ unsigned long hap_p2m_ga_to_gfn(GUEST_PAGING_LEVELS)( if ( missing == 0 ) { gfn_t gfn = guest_l1e_get_gfn(gw.l1e); - (void)get_gfn_type_access(p2m, gfn_x(gfn), &p2mt, &p2ma, p2m_unshare, NULL); + (void)get_gfn_type_access(p2m, gfn_x(gfn), &p2mt, &p2ma, + P2M_ALLOC | P2M_UNSHARE, NULL); if ( p2m_is_paging(p2mt) ) { ASSERT(!p2m_is_nestedp2m(p2m)); diff --git a/xen/arch/x86/mm/hap/nested_hap.c b/xen/arch/x86/mm/hap/nested_hap.c index c41b66edf2..c49ec5335d 100644 --- a/xen/arch/x86/mm/hap/nested_hap.c +++ b/xen/arch/x86/mm/hap/nested_hap.c @@ -150,7 +150,7 @@ nestedhap_walk_L0_p2m(struct p2m_domain *p2m, paddr_t L1_gpa, paddr_t *L0_gpa, /* walk L0 P2M table */ mfn = get_gfn_type_access(p2m, L1_gpa >> PAGE_SHIFT, &p2mt, &p2ma, - p2m_query, page_order); + 0, page_order); rc = NESTEDHVM_PAGEFAULT_MMIO; if ( p2m_is_mmio(p2mt) ) diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index ad7738a437..1456de55d7 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -729,7 +729,7 @@ int mem_sharing_share_pages(struct domain *sd, unsigned long sgfn, shr_handle_t get_two_gfns(sd, sgfn, &smfn_type, NULL, &smfn, cd, cgfn, &cmfn_type, NULL, &cmfn, - p2m_query, &tg); + 0, &tg); /* This tricky business is to avoid two callers deadlocking if * grabbing pages in opposite client/source order */ @@ -844,7 +844,7 @@ int mem_sharing_add_to_physmap(struct domain *sd, unsigned long sgfn, shr_handle get_two_gfns(sd, sgfn, &smfn_type, NULL, &smfn, cd, cgfn, &cmfn_type, &a, &cmfn, - p2m_query, &tg); + 0, &tg); /* Get the source shared page, check and lock */ ret = XENMEM_SHARING_OP_S_HANDLE_INVALID; diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index a1ffa238b3..f373905dd1 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -514,7 +514,7 @@ static mfn_t ept_get_entry(struct p2m_domain *p2m, goto out; else if ( ret == GUEST_TABLE_POD_PAGE ) { - if ( q == p2m_query ) + if ( !(q & P2M_ALLOC) ) { *t = p2m_populate_on_demand; goto out; @@ -541,7 +541,7 @@ static mfn_t ept_get_entry(struct p2m_domain *p2m, if ( ept_entry->sa_p2mt == p2m_populate_on_demand ) { - if ( q == p2m_query ) + if ( !(q & P2M_ALLOC) ) { *t = p2m_populate_on_demand; goto out; diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 43f08b3380..c0fe224d78 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -529,7 +529,7 @@ p2m_pod_decrease_reservation(struct domain *d, p2m_access_t a; p2m_type_t t; - (void)p2m->get_entry(p2m, gpfn + i, &t, &a, p2m_query, NULL); + (void)p2m->get_entry(p2m, gpfn + i, &t, &a, 0, NULL); if ( t == p2m_populate_on_demand ) pod++; @@ -570,7 +570,7 @@ p2m_pod_decrease_reservation(struct domain *d, p2m_type_t t; p2m_access_t a; - mfn = p2m->get_entry(p2m, gpfn + i, &t, &a, p2m_query, NULL); + mfn = p2m->get_entry(p2m, gpfn + i, &t, &a, 0, NULL); if ( t == p2m_populate_on_demand ) { set_p2m_entry(p2m, gpfn + i, _mfn(INVALID_MFN), 0, p2m_invalid, p2m->default_access); @@ -656,7 +656,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) for ( i=0; i<SUPERPAGE_PAGES; i++ ) { p2m_access_t a; - mfn = p2m->get_entry(p2m, gfn + i, &type, &a, p2m_query, NULL); + mfn = p2m->get_entry(p2m, gfn + i, &type, &a, 0, NULL); if ( i == 0 ) { @@ -786,7 +786,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) for ( i=0; i<count; i++ ) { p2m_access_t a; - mfns[i] = p2m->get_entry(p2m, gfns[i], types + i, &a, p2m_query, NULL); + mfns[i] = p2m->get_entry(p2m, gfns[i], types + i, &a, 0, NULL); /* If this is ram, and not a pagetable or from the xen heap, and probably not mapped elsewhere, map it; otherwise, skip. */ if ( p2m_is_ram(types[i]) @@ -932,7 +932,7 @@ p2m_pod_emergency_sweep(struct p2m_domain *p2m) for ( i=p2m->pod.reclaim_single; i > 0 ; i-- ) { p2m_access_t a; - (void)p2m->get_entry(p2m, i, &t, &a, p2m_query, NULL); + (void)p2m->get_entry(p2m, i, &t, &a, 0, NULL); if ( p2m_is_ram(t) ) { gfns[j] = i; @@ -1130,7 +1130,7 @@ guest_physmap_mark_populate_on_demand(struct domain *d, unsigned long gfn, for ( i = 0; i < (1UL << order); i++ ) { p2m_access_t a; - omfn = p2m->get_entry(p2m, gfn + i, &ot, &a, p2m_query, NULL); + omfn = p2m->get_entry(p2m, gfn + i, &ot, &a, 0, NULL); if ( p2m_is_ram(ot) ) { printk("%s: gfn_to_mfn returned type %d!\n", diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c index be0201857d..00e74e036d 100644 --- a/xen/arch/x86/mm/p2m-pt.c +++ b/xen/arch/x86/mm/p2m-pt.c @@ -513,7 +513,7 @@ pod_retry_l3: (p2m_flags_to_type(l3e_get_flags(l3e)) == p2m_populate_on_demand) ) { /* The read has succeeded, so we know that mapping exists */ - if ( q != p2m_query ) + if ( q & P2M_ALLOC ) { if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_1G, q) ) goto pod_retry_l3; @@ -565,7 +565,7 @@ pod_retry_l2: { /* The read has succeeded, so we know that the mapping * exits at this point. */ - if ( q != p2m_query ) + if ( q & P2M_ALLOC ) { if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_2M, q) ) @@ -623,7 +623,7 @@ pod_retry_l1: { /* The read has succeeded, so we know that the mapping * exits at this point. */ - if ( q != p2m_query ) + if ( q & P2M_ALLOC ) { if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_4K, q) ) @@ -714,7 +714,7 @@ pod_retry_l3: { if ( p2m_flags_to_type(l3e_get_flags(*l3e)) == p2m_populate_on_demand ) { - if ( q != p2m_query ) + if ( q & P2M_ALLOC ) { if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_1G, q) ) goto pod_retry_l3; @@ -753,7 +753,7 @@ pod_retry_l2: /* PoD: Try to populate a 2-meg chunk */ if ( p2m_flags_to_type(l2e_get_flags(*l2e)) == p2m_populate_on_demand ) { - if ( q != p2m_query ) { + if ( q & P2M_ALLOC ) { if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_2M, q) ) goto pod_retry_l2; } else @@ -786,7 +786,7 @@ pod_retry_l1: /* PoD: Try to populate */ if ( p2m_flags_to_type(l1e_get_flags(*l1e)) == p2m_populate_on_demand ) { - if ( q != p2m_query ) { + if ( q & P2M_ALLOC ) { if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_4K, q) ) goto pod_retry_l1; } else diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 3420a417b2..b0ae3411d3 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -151,6 +151,10 @@ mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn, { mfn_t mfn; + /* Unshare makes no sense withuot populate. */ + if ( q & P2M_UNSHARE ) + q |= P2M_ALLOC; + if ( !p2m || !paging_mode_translate(p2m->domain) ) { /* Not necessarily true, but for non-translated guests, we claim @@ -167,7 +171,7 @@ mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn, mfn = p2m->get_entry(p2m, gfn, t, a, q, page_order); #ifdef __x86_64__ - if ( q == p2m_unshare && p2m_is_shared(*t) ) + if ( (q & P2M_UNSHARE) && p2m_is_shared(*t) ) { ASSERT(!p2m_is_nestedp2m(p2m)); /* Try to unshare. If we fail, communicate ENOMEM without @@ -183,7 +187,7 @@ mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn, { /* Return invalid_mfn to avoid caller's access */ mfn = _mfn(INVALID_MFN); - if (q != p2m_query) + if ( q & P2M_ALLOC ) domain_crash(p2m->domain); } #endif @@ -370,7 +374,7 @@ void p2m_teardown(struct p2m_domain *p2m) for ( gfn=0; gfn < p2m->max_mapped_pfn; gfn++ ) { p2m_access_t a; - mfn = p2m->get_entry(p2m, gfn, &t, &a, p2m_query, NULL); + mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL); if ( mfn_valid(mfn) && (t == p2m_ram_shared) ) { ASSERT(!p2m_is_nestedp2m(p2m)); @@ -441,7 +445,7 @@ p2m_remove_page(struct p2m_domain *p2m, unsigned long gfn, unsigned long mfn, { for ( i = 0; i < (1UL << page_order); i++ ) { - mfn_return = p2m->get_entry(p2m, gfn + i, &t, &a, p2m_query, NULL); + mfn_return = p2m->get_entry(p2m, gfn + i, &t, &a, 0, NULL); if ( !p2m_is_grant(t) && !p2m_is_shared(t) ) set_gpfn_from_mfn(mfn+i, INVALID_M2P_ENTRY); ASSERT( !p2m_is_valid(t) || mfn + i == mfn_x(mfn_return) ); @@ -503,7 +507,7 @@ guest_physmap_add_entry(struct domain *d, unsigned long gfn, /* First, remove m->p mappings for existing p->m mappings */ for ( i = 0; i < (1UL << page_order); i++ ) { - omfn = p2m->get_entry(p2m, gfn + i, &ot, &a, p2m_query, NULL); + omfn = p2m->get_entry(p2m, gfn + i, &ot, &a, 0, NULL); #ifdef __x86_64__ if ( p2m_is_shared(ot) ) { @@ -528,7 +532,7 @@ guest_physmap_add_entry(struct domain *d, unsigned long gfn, (void)mem_sharing_notify_enomem(p2m->domain, gfn + i, 0); return rc; } - omfn = p2m->get_entry(p2m, gfn + i, &ot, &a, p2m_query, NULL); + omfn = p2m->get_entry(p2m, gfn + i, &ot, &a, 0, NULL); ASSERT(!p2m_is_shared(ot)); } #endif /* __x86_64__ */ @@ -577,7 +581,7 @@ guest_physmap_add_entry(struct domain *d, unsigned long gfn, * address */ P2M_DEBUG("aliased! mfn=%#lx, old gfn=%#lx, new gfn=%#lx\n", mfn + i, ogfn, gfn + i); - omfn = p2m->get_entry(p2m, ogfn, &ot, &a, p2m_query, NULL); + omfn = p2m->get_entry(p2m, ogfn, &ot, &a, 0, NULL); if ( p2m_is_ram(ot) && !p2m_is_paged(ot) ) { ASSERT(mfn_valid(omfn)); @@ -636,7 +640,7 @@ p2m_type_t p2m_change_type(struct domain *d, unsigned long gfn, gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, gfn, &pt, &a, p2m_query, NULL); + mfn = p2m->get_entry(p2m, gfn, &pt, &a, 0, NULL); if ( pt == ot ) set_p2m_entry(p2m, gfn, mfn, PAGE_ORDER_4K, nt, p2m->default_access); @@ -664,7 +668,7 @@ void p2m_change_type_range(struct domain *d, for ( gfn = start; gfn < end; gfn++ ) { - mfn = p2m->get_entry(p2m, gfn, &pt, &a, p2m_query, NULL); + mfn = p2m->get_entry(p2m, gfn, &pt, &a, 0, NULL); if ( pt == ot ) set_p2m_entry(p2m, gfn, mfn, PAGE_ORDER_4K, nt, p2m->default_access); } @@ -690,7 +694,7 @@ set_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn) return 0; gfn_lock(p2m, gfn, 0); - omfn = p2m->get_entry(p2m, gfn, &ot, &a, p2m_query, NULL); + omfn = p2m->get_entry(p2m, gfn, &ot, &a, 0, NULL); if ( p2m_is_grant(ot) ) { p2m_unlock(p2m); @@ -726,7 +730,7 @@ clear_mmio_p2m_entry(struct domain *d, unsigned long gfn) return 0; gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, gfn, &t, &a, p2m_query, NULL); + mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL); /* Do not use mfn_valid() here as it will usually fail for MMIO pages. */ if ( (INVALID_MFN == mfn_x(mfn)) || (t != p2m_mmio_direct) ) @@ -757,7 +761,7 @@ set_shared_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn) return 0; gfn_lock(p2m, gfn, 0); - omfn = p2m->get_entry(p2m, gfn, &ot, &a, p2m_query, NULL); + omfn = p2m->get_entry(p2m, gfn, &ot, &a, 0, NULL); /* At the moment we only allow p2m change if gfn has already been made * sharable first */ ASSERT(p2m_is_shared(ot)); @@ -809,7 +813,7 @@ int p2m_mem_paging_nominate(struct domain *d, unsigned long gfn) gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, p2m_query, NULL); + mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL); /* Check if mfn is valid */ if ( !mfn_valid(mfn) ) @@ -872,7 +876,7 @@ int p2m_mem_paging_evict(struct domain *d, unsigned long gfn) gfn_lock(p2m, gfn, 0); /* Get mfn */ - mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, p2m_query, NULL); + mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL); if ( unlikely(!mfn_valid(mfn)) ) goto out; @@ -999,7 +1003,7 @@ void p2m_mem_paging_populate(struct domain *d, unsigned long gfn) /* Fix p2m mapping */ gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, p2m_query, NULL); + mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL); /* Allow only nominated or evicted pages to enter page-in path */ if ( p2mt == p2m_ram_paging_out || p2mt == p2m_ram_paged ) { @@ -1061,7 +1065,7 @@ int p2m_mem_paging_prep(struct domain *d, unsigned long gfn, uint64_t buffer) gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, p2m_query, NULL); + mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL); ret = -ENOENT; /* Allow missing pages */ @@ -1154,7 +1158,7 @@ void p2m_mem_paging_resume(struct domain *d) if ( !(rsp.flags & MEM_EVENT_FLAG_DROP_PAGE) ) { gfn_lock(p2m, rsp.gfn, 0); - mfn = p2m->get_entry(p2m, rsp.gfn, &p2mt, &a, p2m_query, NULL); + mfn = p2m->get_entry(p2m, rsp.gfn, &p2mt, &a, 0, NULL); /* Allow only pages which were prepared properly, or pages which * were nominated but not evicted */ if ( mfn_valid(mfn) && (p2mt == p2m_ram_paging_in) ) @@ -1187,7 +1191,7 @@ bool_t p2m_mem_access_check(unsigned long gpa, bool_t gla_valid, unsigned long g /* First, handle rx2rw conversion automatically */ gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, gfn, &p2mt, &p2ma, p2m_query, NULL); + mfn = p2m->get_entry(p2m, gfn, &p2mt, &p2ma, 0, NULL); if ( access_w && p2ma == p2m_access_rx2rw ) { @@ -1316,7 +1320,7 @@ int p2m_set_mem_access(struct domain *d, unsigned long start_pfn, p2m_lock(p2m); for ( pfn = start_pfn; pfn < start_pfn + nr; pfn++ ) { - mfn = p2m->get_entry(p2m, pfn, &t, &_a, p2m_query, NULL); + mfn = p2m->get_entry(p2m, pfn, &t, &_a, 0, NULL); if ( p2m->set_entry(p2m, pfn, mfn, PAGE_ORDER_4K, t, a) == 0 ) { rc = -ENOMEM; @@ -1357,7 +1361,7 @@ int p2m_get_mem_access(struct domain *d, unsigned long pfn, } gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, pfn, &t, &a, p2m_query, NULL); + mfn = p2m->get_entry(p2m, pfn, &t, &a, 0, NULL); gfn_unlock(p2m, gfn, 0); if ( mfn_x(mfn) == INVALID_MFN ) @@ -1598,7 +1602,7 @@ void audit_p2m(struct domain *d, continue; } - p2mfn = get_gfn_type_access(p2m, gfn, &type, &p2ma, p2m_query, NULL); + p2mfn = get_gfn_type_access(p2m, gfn, &type, &p2ma, 0, NULL); if ( mfn_x(p2mfn) != mfn ) { mpbad++; diff --git a/xen/arch/x86/mm/shadow/types.h b/xen/arch/x86/mm/shadow/types.h index cec90b188b..43ce1dbb0a 100644 --- a/xen/arch/x86/mm/shadow/types.h +++ b/xen/arch/x86/mm/shadow/types.h @@ -193,7 +193,7 @@ static inline shadow_l4e_t shadow_l4e_from_mfn(mfn_t mfn, u32 flags) /* Override get_gfn to work with gfn_t */ #undef get_gfn_query -#define get_gfn_query(d, g, t) get_gfn_type((d), gfn_x(g), (t), p2m_query) +#define get_gfn_query(d, g, t) get_gfn_type((d), gfn_x(g), (t), 0) /* The shadow types needed for the various levels. */ diff --git a/xen/include/asm-x86/guest_pt.h b/xen/include/asm-x86/guest_pt.h index 8c613d6349..a5714e1403 100644 --- a/xen/include/asm-x86/guest_pt.h +++ b/xen/include/asm-x86/guest_pt.h @@ -53,7 +53,7 @@ gfn_to_paddr(gfn_t gfn) /* Override get_gfn to work with gfn_t */ #undef get_gfn -#define get_gfn(d, g, t) get_gfn_type((d), gfn_x(g), (t), p2m_alloc) +#define get_gfn(d, g, t) get_gfn_type((d), gfn_x(g), (t), P2M_ALLOC) /* Types of the guest's page tables and access functions for them */ diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 4b29e0714c..576e6772e6 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -117,11 +117,9 @@ typedef enum { } p2m_access_t; /* Modifiers to the query */ -typedef enum { - p2m_query, /* Do not populate a PoD entries */ - p2m_alloc, /* Automatically populate PoD entries */ - p2m_unshare, /* Break c-o-w sharing; implies alloc */ -} p2m_query_t; +typedef unsigned int p2m_query_t; +#define P2M_ALLOC (1u<<0) /* Populate PoD and paged-out entries */ +#define P2M_UNSHARE (1u<<1) /* Break CoW sharing */ /* We use bitmaps and maks to handle groups of types */ #define p2m_to_mask(_t) (1UL << (_t)) @@ -332,9 +330,10 @@ static inline mfn_t get_gfn_type(struct domain *d, * N.B. get_gfn_query() is the _only_ one guaranteed not to take the * p2m lock; none of the others can be called with the p2m or paging * lock held. */ -#define get_gfn(d, g, t) get_gfn_type((d), (g), (t), p2m_alloc) -#define get_gfn_query(d, g, t) get_gfn_type((d), (g), (t), p2m_query) -#define get_gfn_unshare(d, g, t) get_gfn_type((d), (g), (t), p2m_unshare) +#define get_gfn(d, g, t) get_gfn_type((d), (g), (t), P2M_ALLOC) +#define get_gfn_query(d, g, t) get_gfn_type((d), (g), (t), 0) +#define get_gfn_unshare(d, g, t) get_gfn_type((d), (g), (t), \ + P2M_ALLOC | P2M_UNSHARE) /* Compatibility function exporting the old untyped interface */ static inline unsigned long get_gfn_untyped(struct domain *d, unsigned long gpfn) @@ -366,8 +365,7 @@ static inline mfn_t get_gfn_query_unlocked(struct domain *d, p2m_type_t *t) { p2m_access_t a; - return __get_gfn_type_access(p2m_get_hostp2m(d), gfn, t, &a, - p2m_query, NULL, 0); + return __get_gfn_type_access(p2m_get_hostp2m(d), gfn, t, &a, 0, NULL, 0); } /* General conversion function from mfn to gfn */ |