[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH for-4.19? 1/2] xen/x86: account for max guest gfn and number of foreign mappings in the p2m
Keep track of the maximum gfn that has ever been populated into the p2m, and also account for the number of foreign mappings. Such information will be needed in order to remove foreign mappings during teardown for HVM guests. Right now the introduced counters are not consumed. Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> --- xen/arch/x86/include/asm/p2m.h | 11 +++++++++++ xen/arch/x86/mm/p2m.c | 2 ++ 2 files changed, 13 insertions(+) diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h index 111badf89a6e..d95341ef4242 100644 --- a/xen/arch/x86/include/asm/p2m.h +++ b/xen/arch/x86/include/asm/p2m.h @@ -380,6 +380,14 @@ struct p2m_domain { unsigned int flags; unsigned long entry_count; } ioreq; + + /* + * Max gfn possibly mapped into the guest p2m. Note max_gfn is not + * adjusted to account for removals from the p2m. + */ + gfn_t max_gfn; + /* Number of foreign mappings. */ + unsigned long nr_foreign; #endif /* CONFIG_HVM */ }; @@ -1049,6 +1057,8 @@ static inline int p2m_entry_modify(struct p2m_domain *p2m, p2m_type_t nt, if ( !page_get_owner_and_reference(mfn_to_page(nfn)) ) return -EBUSY; + p2m->nr_foreign++; + break; default: @@ -1069,6 +1079,7 @@ static inline int p2m_entry_modify(struct p2m_domain *p2m, p2m_type_t nt, return -EINVAL; } put_page(mfn_to_page(ofn)); + p2m->nr_foreign--; break; default: diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index ce742c12e0de..05d8536adcd7 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -413,6 +413,8 @@ int p2m_set_entry(struct p2m_domain *p2m, gfn_t gfn, mfn_t mfn, set_rc = p2m->set_entry(p2m, gfn, mfn, order, p2mt, p2ma, -1); if ( set_rc ) rc = set_rc; + else + p2m->max_gfn = gfn_max(gfn_add(gfn, 1u << order), p2m->max_gfn); gfn = gfn_add(gfn, 1UL << order); if ( !mfn_eq(mfn, INVALID_MFN) ) -- 2.44.0
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |