|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] x86/mm: pull a sanity check earlier in xenmem_add_to_physmap_one()
commit f8582da0417660269bec69e399f8667f761e886b
Author: Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Tue Jun 29 11:03:29 2021 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Jun 29 11:03:29 2021 +0200
x86/mm: pull a sanity check earlier in xenmem_add_to_physmap_one()
We should try to limit the failure reasons after we've started making
changes.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
xen/arch/x86/mm/p2m.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index dbb1cbeb59..7b3cf7e9fc 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -2756,6 +2756,15 @@ int xenmem_add_to_physmap_one(
goto put_both;
}
+ /* XENMAPSPACE_gmfn: Check if the MFN is associated with another GFN. */
+ old_gpfn = get_gpfn_from_mfn(mfn_x(mfn));
+ ASSERT(!SHARED_M2P(old_gpfn));
+ if ( space == XENMAPSPACE_gmfn && old_gpfn != gfn )
+ {
+ rc = -EXDEV;
+ goto put_both;
+ }
+
/* Remove previously mapped page if it was present. */
prev_mfn = get_gfn(d, gfn_x(gpfn), &p2mt);
if ( mfn_valid(prev_mfn) )
@@ -2774,13 +2783,6 @@ int xenmem_add_to_physmap_one(
goto put_both;
/* Unmap from old location, if any. */
- old_gpfn = get_gpfn_from_mfn(mfn_x(mfn));
- ASSERT(!SHARED_M2P(old_gpfn));
- if ( space == XENMAPSPACE_gmfn && old_gpfn != gfn )
- {
- rc = -EXDEV;
- goto put_both;
- }
if ( old_gpfn != INVALID_M2P_ENTRY )
rc = guest_physmap_remove_page(d, _gfn(old_gpfn), mfn, PAGE_ORDER_4K);
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |