From: Tiejun Chen <tiejun.chen@intel.com>
To: tim@xen.org, JBeulich@suse.com, yang.z.zhang@intel.com,
kevin.tian@intel.com
Cc: xen-devel@lists.xen.org
Subject: [v5][PATCH 1/2] xen:x86:mm:p2m: introduce set_identity_p2m_entry
Date: Tue, 29 Jul 2014 14:40:51 +0800 [thread overview]
Message-ID: <1406616052-11973-1-git-send-email-tiejun.chen@intel.com> (raw)
Its used conveniently to create RMRR mapping in shared EPT case.
Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
---
xen/arch/x86/mm/p2m.c | 26 ++++++++++++++++++++++++++
xen/include/asm-x86/p2m.h | 3 +++
2 files changed, 29 insertions(+)
v5:
* Rename this function as set_identity_p2m_entry()
* Get mfn directly inside set_identity_p2m_entry()
v4:
* new patch to combine get and set together to create RMRR mapping.
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 642ec28..f83f194 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -858,6 +858,32 @@ 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);
}
+int set_identity_p2m_entry(struct domain *d, unsigned long gfn)
+{
+ p2m_type_t p2mt;
+ p2m_access_t a;
+ mfn_t tmp_mfn, mfn = _mfn(gfn);
+ struct p2m_domain *p2m = p2m_get_hostp2m(d);
+ int ret = -EBUSY;
+
+ gfn_lock(p2m, gfn, 0);
+
+ tmp_mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL);
+
+ if ( mfn_valid(tmp_mfn) )
+ {
+ gdprintk(XENLOG_ERR,
+ "Overlapping RMRRs at %"PRIx64".\n", (paddr_t)gfn);
+ goto out;
+ }
+
+ ret = p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, p2m_mmio_direct,
+ p2m_access_rw);
+ out:
+ 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)
{
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index 0ddbadb..d130f9a 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -536,6 +536,9 @@ int p2m_is_logdirty_range(struct p2m_domain *, unsigned long start,
int set_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn);
int clear_mmio_p2m_entry(struct domain *d, unsigned long gfn);
+/* Set identity addresses in the p2m table (for pass-through) */
+int set_identity_p2m_entry(struct domain *d, unsigned long gfn);
+
/* 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
next reply other threads:[~2014-07-29 6:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-29 6:40 Tiejun Chen [this message]
2014-07-29 6:40 ` [v5][PATCH 2/2] xen:vtd: missing RMRR mapping while share EPT Tiejun Chen
2014-07-29 7:05 ` [v5][PATCH 1/2] xen:x86:mm:p2m: introduce set_identity_p2m_entry Jan Beulich
2014-07-29 7:35 ` Chen, Tiejun
2014-07-29 8:19 ` Jan Beulich
2014-07-29 8:46 ` Andrew Cooper
2014-07-29 9:05 ` Jan Beulich
2014-07-29 9:20 ` Chen, Tiejun
2014-07-29 9:43 ` Andrew Cooper
2014-07-29 9:11 ` Chen, Tiejun
2014-07-29 9:53 ` Jan Beulich
2014-07-29 10:18 ` Chen, Tiejun
2014-07-29 10:27 ` Jan Beulich
2014-07-29 11:08 ` Chen, Tiejun
2014-07-29 11:29 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1406616052-11973-1-git-send-email-tiejun.chen@intel.com \
--to=tiejun.chen@intel.com \
--cc=JBeulich@suse.com \
--cc=kevin.tian@intel.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
--cc=yang.z.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).