|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 4/7] x86: extend mod_l1_entry() to optionally return the old PTE value
Calling mod_l1_entry() with a valid ol1e_out pointer will do an atomic xchg to
set the new pte value and return the old pte value through the ol1e_out
pointer. If the ol1e_out pointer is NULL then old behavior is preserved.
Signed-off-by: Kevin Lampis <kevin.lampis@xxxxxxxxxx>
---
Changes in v2:
- UPDATE_ENTRY now returns the old pte value instead of using an out
pointer
---
xen/arch/x86/mm.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index dcbc44f57c54..59ad5ce16486 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -2150,7 +2150,8 @@ static void l3t_unlock(struct page_info *page)
/* Update the L1 entry at pl1e to new value nl1e. */
static int mod_l1_entry(l1_pgentry_t *pl1e, l1_pgentry_t nl1e,
mfn_t gl1mfn, unsigned int update_flags,
- struct vcpu *pt_vcpu, struct domain *pg_dom)
+ struct vcpu *pt_vcpu, struct domain *pg_dom,
+ l1_pgentry_t *ol1e_out)
{
l1_pgentry_t ol1e = l1e_read(pl1e);
struct domain *pt_dom = pt_vcpu->domain;
@@ -2211,9 +2212,12 @@ static int mod_l1_entry(l1_pgentry_t *pl1e, l1_pgentry_t
nl1e,
/* Fast path for sufficiently-similar mappings. */
if ( !l1e_has_changed(ol1e, nl1e, ~FASTPATH_FLAG_WHITELIST) )
{
- UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu, update_flags);
+ ol1e.l1 = UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu,
+ update_flags);
if ( page )
put_page(page);
+ if ( ol1e_out )
+ *ol1e_out = ol1e;
return 0;
}
@@ -2234,14 +2238,20 @@ static int mod_l1_entry(l1_pgentry_t *pl1e,
l1_pgentry_t nl1e,
if ( page )
put_page(page);
- UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu, update_flags);
+ ol1e.l1 = UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu,
+ update_flags);
}
else if ( pv_l1tf_check_l1e(pt_dom, nl1e) )
return -ERESTART;
else
- UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu, update_flags);
+ ol1e.l1 = UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu,
+ update_flags);
put_page_from_l1e(ol1e, pt_dom);
+
+ if ( !rc && ol1e_out )
+ *ol1e_out = ol1e;
+
return rc;
}
@@ -4109,7 +4119,7 @@ long do_mmu_update(
{
case PGT_l1_page_table:
rc = mod_l1_entry(va, l1e_from_intpte(req.val), mfn,
- update_flags, v, pg_owner);
+ update_flags, v, pg_owner, NULL);
break;
case PGT_l2_page_table:
@@ -4474,7 +4484,8 @@ static int __do_update_va_mapping(
goto out;
}
- rc = mod_l1_entry(pl1e, val, gl1mfn, MMU_NORMAL_PT_UPDATE, v, pg_owner);
+ rc = mod_l1_entry(pl1e, val, gl1mfn, MMU_NORMAL_PT_UPDATE, v, pg_owner,
+ NULL);
page_unlock(gl1pg);
put_page(gl1pg);
--
2.52.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |