|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3] altp2m: Allow the hostp2m to be shared
Don't propagate altp2m changes from ept_set_entry for memshare as memshare
already has the lock. We call altp2m propagate changes once memshare
successfully finishes. Allow the hostp2m entries to be of type
p2m_ram_shared when applying mem_access. Also, do not trigger PoD for hostp2m
when setting altp2m mem_access to be in-line with non-altp2m mem_access path.
Signed-off-by: Tamas K Lengyel <tamas@xxxxxxxxxxxxx>
---
Cc: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
Cc: Keir Fraser <keir@xxxxxxx>
Cc: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Cc: Jun Nakajima <jun.nakajima@xxxxxxxxx>
Cc: Kevin Tian <kevin.tian@xxxxxxxxx>
v3: Add comment to the unshare routine pointing out where altp2m gets updated
v2: Cosmetic fixes and addressing PoD in the commit message
---
xen/arch/x86/mm/mem_sharing.c | 11 ++++++++++-
xen/arch/x86/mm/p2m-ept.c | 2 +-
xen/arch/x86/mm/p2m.c | 5 ++---
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
index a522423..b6c7e33 100644
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -35,6 +35,7 @@
#include <asm/p2m.h>
#include <asm/atomic.h>
#include <asm/event.h>
+#include <asm/altp2m.h>
#include <xsm/xsm.h>
#include "mm-locks.h"
@@ -926,11 +927,12 @@ int mem_sharing_share_pages(struct domain *sd, unsigned
long sgfn, shr_handle_t
int ret = -EINVAL;
mfn_t smfn, cmfn;
p2m_type_t smfn_type, cmfn_type;
+ p2m_access_t cmfn_a;
struct two_gfns tg;
struct rmap_iterator ri;
get_two_gfns(sd, sgfn, &smfn_type, NULL, &smfn,
- cd, cgfn, &cmfn_type, NULL, &cmfn,
+ cd, cgfn, &cmfn_type, &cmfn_a, &cmfn,
0, &tg);
/* This tricky business is to avoid two callers deadlocking if
@@ -1026,6 +1028,12 @@ int mem_sharing_share_pages(struct domain *sd, unsigned
long sgfn, shr_handle_t
/* We managed to free a domain page. */
atomic_dec(&nr_shared_mfns);
atomic_inc(&nr_saved_mfns);
+
+ /* Save the change to the altp2m tables as well if active */
+ if ( altp2m_active(cd) )
+ p2m_altp2m_propagate_change(cd, _gfn(cgfn), smfn, PAGE_ORDER_4K,
+ p2m_ram_shared, cmfn_a);
+
ret = 0;
err_out:
@@ -1222,6 +1230,7 @@ int __mem_sharing_unshare_page(struct domain *d,
put_page_and_type(old_page);
private_page_found:
+ /* The following will also update the altp2m tables (if any) */
if ( p2m_change_type_one(d, gfn, p2m_ram_shared, p2m_ram_rw) )
{
gdprintk(XENLOG_ERR, "Could not change p2m type d %hu gfn %lx.\n",
diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index 1ed5b47..ff84242 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -847,7 +847,7 @@ out:
if ( is_epte_present(&old_entry) )
ept_free_entry(p2m, &old_entry, target);
- if ( rc == 0 && p2m_is_hostp2m(p2m) )
+ if ( rc == 0 && p2m_is_hostp2m(p2m) && p2mt != p2m_ram_shared )
p2m_altp2m_propagate_change(d, _gfn(gfn), mfn, order, p2mt, p2ma);
return rc;
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 6eef2f3..2a42b91 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -1765,11 +1765,10 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct
p2m_domain *hp2m,
/* Check host p2m if no valid entry in alternate */
if ( !mfn_valid(mfn) )
{
- mfn = hp2m->get_entry(hp2m, gfn_l, &t, &old_a,
- P2M_ALLOC | P2M_UNSHARE, &page_order, NULL);
+ mfn = hp2m->get_entry(hp2m, gfn_l, &t, &old_a, 0, &page_order, NULL);
rc = -ESRCH;
- if ( !mfn_valid(mfn) || t != p2m_ram_rw )
+ if ( !mfn_valid(mfn) || (t != p2m_ram_rw && t != p2m_ram_shared) )
return rc;
/* If this is a superpage, copy that first */
--
2.8.1
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |