[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC][v2][PATCH 05/14] xen/x86/p2m: introduce set_identity_p2m_entry
We will create this sort of identity mapping as follows: If the gfn space is unoccupied, we just set the mapping. If the space is already occupied by 1:1 mappings, do nothing. Failed for any other cases. Signed-off-by: Tiejun Chen <tiejun.chen@xxxxxxxxx> --- xen/arch/x86/mm/p2m.c | 30 ++++++++++++++++++++++++++++++ xen/include/asm-x86/p2m.h | 4 ++++ 2 files changed, 34 insertions(+) diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 1fd1194..c674201 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -898,6 +898,36 @@ int set_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn, return set_typed_p2m_entry(d, gfn, mfn, p2m_mmio_direct, access); } +int set_identity_p2m_entry(struct domain *d, unsigned long gfn, + p2m_access_t p2ma) +{ + p2m_type_t p2mt; + p2m_access_t a; + mfn_t mfn; + struct p2m_domain *p2m = p2m_get_hostp2m(d); + int ret = -EBUSY; + + gfn_lock(p2m, gfn, 0); + + mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL); + + if ( p2mt == p2m_invalid ) + ret = p2m_set_entry(p2m, gfn, _mfn(gfn), PAGE_ORDER_4K, + p2m_mmio_direct, p2ma); + else if ( mfn_x(mfn) == gfn && p2mt == p2m_mmio_direct && a == p2ma ) + ret = 0; + else + { + printk(XENLOG_G_WARNING + "Cannot identity map d%d:%lx, already mapped to %lx.\n", + d->domain_id, gfn, mfn_x(mfn)); + } + + gfn_unlock(p2m, gfn, 0); + + return ret; +} + /* Returns: 0 for success, -errno for failure */ int clear_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn) { diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index b49c09b..95b6266 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -543,6 +543,10 @@ int set_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn, p2m_access_t access); int clear_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn); +/* Set identity addresses in the p2m table (for pass-through) */ +int set_identity_p2m_entry(struct domain *d, unsigned long gfn, + p2m_access_t p2ma); + /* Add foreign mapping to the guest's p2m table. */ int p2m_add_foreign(struct domain *tdom, unsigned long fgfn, unsigned long gpfn, domid_t foreign_domid); -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |