|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 05/14] x86/p2m: Don't overwrite p2m_altp2m_lazy_copy()'s callers p2m pointer
The final parameter to p2m_altp2m_lazy_copy() appears to be unnecessary, and
results in very hard-to-follow code. Have the sole caller set its local p2m
pointer appropriately, and drop the parameter.
With that done, a level of indirection of ap2m can be dropped inside
p2m_altp2m_lazy_copy(). While changing the API, switch it from bool_t to
bool, and drop printing of the altp2m's virtual address, because it is of no
use even when debugging.
No (intended) overall change in behaviour.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
--
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx>
CC: Tamas K Lengyel <tamas@xxxxxxxxxxxxx>
CC: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
---
xen/arch/x86/hvm/hvm.c | 4 +++-
xen/arch/x86/mm/p2m.c | 24 ++++++++++++------------
xen/include/asm-x86/p2m.h | 4 ++--
3 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index e2e4204..94fe441 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -1760,7 +1760,9 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long
gla,
if ( ap2m_active )
{
- if ( p2m_altp2m_lazy_copy(curr, gpa, gla, npfec, &p2m) )
+ p2m = p2m_get_altp2m(curr);
+
+ if ( p2m_altp2m_lazy_copy(curr, gpa, gla, npfec) )
{
/* entry was lazily copied from host -- retry */
__put_gfn(hostp2m, gfn);
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index ae9cb20..8b9898a 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -2172,23 +2172,23 @@ bool_t p2m_switch_vcpu_altp2m_by_id(struct vcpu *v,
unsigned int idx)
* indicate that outer handler should handle fault
*/
-bool_t p2m_altp2m_lazy_copy(struct vcpu *v, paddr_t gpa,
- unsigned long gla, struct npfec npfec,
- struct p2m_domain **ap2m)
+bool p2m_altp2m_lazy_copy(struct vcpu *v, paddr_t gpa,
+ unsigned long gla, struct npfec npfec)
{
struct p2m_domain *hp2m = p2m_get_hostp2m(v->domain);
+ struct p2m_domain *ap2m = p2m_get_altp2m(v);
p2m_type_t p2mt;
p2m_access_t p2ma;
unsigned int page_order;
- gfn_t gfn = _gfn(paddr_to_pfn(gpa));
+ gfn_t gfn = gaddr_to_gfn(gpa);
unsigned long mask;
mfn_t mfn;
int rv;
bool ret;
- *ap2m = p2m_get_altp2m(v);
+ ASSERT(p2m_locked_by_me(hp2m));
- mfn = get_gfn_type_access(*ap2m, gfn_x(gfn), &p2mt, &p2ma,
+ mfn = get_gfn_type_access(ap2m, gfn_x(gfn), &p2mt, &p2ma,
0, &page_order);
/* Entry already present in ap2m? Caller should handle the fault. */
@@ -2216,15 +2216,15 @@ bool_t p2m_altp2m_lazy_copy(struct vcpu *v, paddr_t gpa,
mfn = _mfn(mfn_x(mfn) & mask);
gfn = _gfn(gfn_x(gfn) & mask);
- p2m_lock(*ap2m);
- rv = p2m_set_entry(*ap2m, gfn, mfn, page_order, p2mt, p2ma);
- p2m_unlock(*ap2m);
+ p2m_lock(ap2m);
+ rv = p2m_set_entry(ap2m, gfn, mfn, page_order, p2mt, p2ma);
+ p2m_unlock(ap2m);
if ( rv )
{
gdprintk(XENLOG_ERR,
- "failed to set entry for %#"PRIx64" -> %#"PRIx64" p2m %#"PRIx64"\n",
- gfn_x(gfn), mfn_x(mfn), (unsigned long)*ap2m);
+ "failed to set entry for %#"PRIx64" -> %#"PRIx64"\n",
+ gfn_x(gfn), mfn_x(mfn));
domain_crash(hp2m->domain);
}
@@ -2233,7 +2233,7 @@ bool_t p2m_altp2m_lazy_copy(struct vcpu *v, paddr_t gpa,
put_hp2m:
__put_gfn(hp2m, gfn_x(gfn));
put_ap2m:
- __put_gfn(*ap2m, gfn_x(gfn));
+ __put_gfn(ap2m, gfn_x(gfn));
return ret;
}
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index 6d849a5..04c2104 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -868,8 +868,8 @@ void p2m_altp2m_check(struct vcpu *v, uint16_t idx);
void p2m_flush_altp2m(struct domain *d);
/* Alternate p2m paging */
-bool_t p2m_altp2m_lazy_copy(struct vcpu *v, paddr_t gpa,
- unsigned long gla, struct npfec npfec, struct p2m_domain **ap2m);
+bool p2m_altp2m_lazy_copy(struct vcpu *v, paddr_t gpa,
+ unsigned long gla, struct npfec npfec);
/* Make a specific alternate p2m valid */
int p2m_init_altp2m_by_id(struct domain *d, unsigned int idx);
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |