50 lines
1.6 KiB
Diff
50 lines
1.6 KiB
Diff
|
# HG changeset patch
|
||
|
# User Keir Fraser <keir@xen.org>
|
||
|
# Date 1292410025 0
|
||
|
# Node ID 7a5ee380041707177ca9c78e800095d1f5f3d373
|
||
|
# Parent 01f3b350902385627d1fa9e8cd1c231953e7610c
|
||
|
ept: Remove lock in ept_get_entry, replace with access-once semantics.
|
||
|
|
||
|
This mirrors the RVI/shadow situation, where p2m read access is
|
||
|
lockless because it's done in the hardware (linear map of the p2m
|
||
|
table).
|
||
|
|
||
|
This fixes the original bug (call it bug A) without introducing bug B
|
||
|
(a deadlock).
|
||
|
|
||
|
Bug A was caused by a race when updating p2m entries: between testing
|
||
|
if it's valid, and testing if it's populate-on-demand, it may have
|
||
|
been changed from populate-on-demand to valid.
|
||
|
|
||
|
My original patch simply introduced a lock into ept_get_entry, but
|
||
|
that caused bug B, caused by circular locking order: p2m_change_type
|
||
|
[grabs p2m lock] -> set_p2m_entry -> ept_set_entry ->
|
||
|
ept_set_middle_level -> p2m_alloc [grabs hap lock] write cr4 ->
|
||
|
hap_update_paging_modes [grabes hap lock] -> hap_update_cr3 ->
|
||
|
gfn_to_mfn -> ept_get_entry -> [grabs p2m lock]
|
||
|
|
||
|
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
|
||
|
|
||
|
--- a/xen/arch/x86/mm/hap/p2m-ept.c
|
||
|
+++ b/xen/arch/x86/mm/hap/p2m-ept.c
|
||
|
@@ -395,10 +395,6 @@ static mfn_t ept_get_entry(struct domain
|
||
|
int i;
|
||
|
int ret = 0;
|
||
|
mfn_t mfn = _mfn(INVALID_MFN);
|
||
|
- int do_locking = !p2m_locked_by_me(d->arch.p2m);
|
||
|
-
|
||
|
- if ( do_locking )
|
||
|
- p2m_lock(d->arch.p2m);
|
||
|
|
||
|
*t = p2m_mmio_dm;
|
||
|
|
||
|
@@ -476,8 +472,6 @@ static mfn_t ept_get_entry(struct domain
|
||
|
}
|
||
|
|
||
|
out:
|
||
|
- if ( do_locking )
|
||
|
- p2m_unlock(d->arch.p2m);
|
||
|
unmap_domain_page(table);
|
||
|
return mfn;
|
||
|
}
|