[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2 of 6] x86/mm: remove 'p2m_guest' lookup type
# HG changeset patch # User Tim Deegan <tim@xxxxxxx> # Date 1330013729 0 # Node ID ec94098841bfae20101608f3daf7a1a01ff71c49 # Parent e165cfc82565addf9881487ee1aa829de1ee1402 x86/mm: remove 'p2m_guest' lookup type. It was neither consistently used by callers nor correctly handled by the lookup code. Instead, treat any lookup that might allocate or unshare memory as a 'guest' lookup for the purposes of: - detecting the highest pod gfn populated; and - crashing the guest on access to a broken page which were the only things this was used for. Signed-off-by: Tim Deegan <tim@xxxxxxx> diff -r e165cfc82565 -r ec94098841bf xen/arch/x86/hvm/emulate.c --- a/xen/arch/x86/hvm/emulate.c Thu Feb 23 16:15:29 2012 +0000 +++ b/xen/arch/x86/hvm/emulate.c Thu Feb 23 16:15:29 2012 +0000 @@ -696,7 +696,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_guest, &tg); + p2m_alloc, &tg); if ( !p2m_is_ram(sp2mt) && !p2m_is_grant(sp2mt) ) { diff -r e165cfc82565 -r ec94098841bf xen/arch/x86/hvm/hvm.c --- a/xen/arch/x86/hvm/hvm.c Thu Feb 23 16:15:29 2012 +0000 +++ b/xen/arch/x86/hvm/hvm.c Thu Feb 23 16:15:29 2012 +0000 @@ -1234,7 +1234,8 @@ int hvm_hap_nested_page_fault(unsigned l } p2m = p2m_get_hostp2m(v->domain); - mfn = get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, p2m_guest, NULL); + mfn = get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, + access_w ? p2m_unshare : p2m_alloc, NULL); /* Check access permissions first, then handle faults */ if ( mfn_x(mfn) != INVALID_MFN ) diff -r e165cfc82565 -r ec94098841bf xen/arch/x86/hvm/svm/svm.c --- a/xen/arch/x86/hvm/svm/svm.c Thu Feb 23 16:15:29 2012 +0000 +++ b/xen/arch/x86/hvm/svm/svm.c Thu Feb 23 16:15:29 2012 +0000 @@ -1287,7 +1287,7 @@ static void svm_do_nested_pgfault(struct if ( p2m == NULL ) p2m = p2m_get_p2m(v); /* Everything else is an error. */ - mfn = get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, p2m_guest, NULL); + mfn = get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, p2m_query, NULL); __put_gfn(p2m, gfn); gdprintk(XENLOG_ERR, "SVM violation gpa %#"PRIpaddr", mfn %#lx, type %i\n", diff -r e165cfc82565 -r ec94098841bf xen/arch/x86/mm/p2m-pod.c --- a/xen/arch/x86/mm/p2m-pod.c Thu Feb 23 16:15:29 2012 +0000 +++ b/xen/arch/x86/mm/p2m-pod.c Thu Feb 23 16:15:29 2012 +0000 @@ -1023,7 +1023,7 @@ p2m_pod_demand_populate(struct p2m_domai } /* Keep track of the highest gfn demand-populated by a guest fault */ - if ( q == p2m_guest && gfn > p2m->pod.max_guest ) + if ( gfn > p2m->pod.max_guest ) p2m->pod.max_guest = gfn; if ( p2m->pod.count == 0 ) diff -r e165cfc82565 -r ec94098841bf xen/arch/x86/mm/p2m.c --- a/xen/arch/x86/mm/p2m.c Thu Feb 23 16:15:29 2012 +0000 +++ b/xen/arch/x86/mm/p2m.c Thu Feb 23 16:15:29 2012 +0000 @@ -180,7 +180,7 @@ mfn_t __get_gfn_type_access(struct p2m_d { /* Return invalid_mfn to avoid caller's access */ mfn = _mfn(INVALID_MFN); - if (q == p2m_guest) + if (q != p2m_query) domain_crash(p2m->domain); } #endif diff -r e165cfc82565 -r ec94098841bf xen/arch/x86/mm/shadow/multi.c --- a/xen/arch/x86/mm/shadow/multi.c Thu Feb 23 16:15:29 2012 +0000 +++ b/xen/arch/x86/mm/shadow/multi.c Thu Feb 23 16:15:29 2012 +0000 @@ -3189,7 +3189,7 @@ static int sh_page_fault(struct vcpu *v, /* What mfn is the guest trying to access? */ gfn = guest_l1e_get_gfn(gw.l1e); - gmfn = get_gfn_guest(d, gfn, &p2mt); + gmfn = get_gfn(d, gfn, &p2mt); if ( shadow_mode_refcounts(d) && ((!p2m_is_valid(p2mt) && !p2m_is_grant(p2mt)) || @@ -4840,7 +4840,7 @@ static mfn_t emulate_gva_to_mfn(struct v /* Translate the GFN to an MFN */ ASSERT(!paging_locked_by_me(v->domain)); - mfn = get_gfn_guest(v->domain, _gfn(gfn), &p2mt); + mfn = get_gfn(v->domain, _gfn(gfn), &p2mt); if ( p2m_is_readonly(p2mt) ) { diff -r e165cfc82565 -r ec94098841bf xen/arch/x86/mm/shadow/types.h --- a/xen/arch/x86/mm/shadow/types.h Thu Feb 23 16:15:29 2012 +0000 +++ b/xen/arch/x86/mm/shadow/types.h Thu Feb 23 16:15:29 2012 +0000 @@ -194,8 +194,6 @@ static inline shadow_l4e_t shadow_l4e_fr /* 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) -#undef get_gfn_guest -#define get_gfn_guest(d, g, t) get_gfn_type((d), gfn_x(g), (t), p2m_guest) /* The shadow types needed for the various levels. */ diff -r e165cfc82565 -r ec94098841bf xen/include/asm-x86/p2m.h --- a/xen/include/asm-x86/p2m.h Thu Feb 23 16:15:29 2012 +0000 +++ b/xen/include/asm-x86/p2m.h Thu Feb 23 16:15:29 2012 +0000 @@ -114,11 +114,11 @@ typedef enum { /* NOTE: Assumed to be only 4 bits right now */ } 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_guest, /* Guest demand-fault; implies alloc */ } p2m_query_t; /* We use bitmaps and maks to handle groups of types */ @@ -332,7 +332,6 @@ static inline mfn_t get_gfn_type(struct * 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_guest(d, g, t) get_gfn_type((d), (g), (t), p2m_guest) #define get_gfn_unshare(d, g, t) get_gfn_type((d), (g), (t), p2m_unshare) /* Compatibility function exporting the old untyped interface */ _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |