mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
x86/p2m: re-arrange {,__}put_gfn()
All explicit callers of __put_gfn() are in HVM-only code and hold a valid P2M pointer in their hands. Move the paging_mode_translate() check out of there into put_gfn(), renaming __put_gfn() and making its GFN parameter type-safe. Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: George Dunlap <george.dunlap@citrix.com>
This commit is contained in:
1 parent
aa70b89599
commit
819cdc5a73
4 files changed
+20
-21
No files matched your search
@@ -1962,9 +1962,9 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla,
|
||||
* altp2m_list lock.
|
||||
*/
|
||||
if ( p2m != hostp2m )
|
||||
__put_gfn(p2m, gfn);
|
||||
p2m_put_gfn(p2m, _gfn(gfn));
|
||||
p2m_change_type_one(currd, gfn, p2m_ram_logdirty, p2m_ram_rw);
|
||||
__put_gfn(hostp2m, gfn);
|
||||
p2m_put_gfn(hostp2m, _gfn(gfn));
|
||||
|
||||
goto out;
|
||||
}
|
||||
@@ -1986,8 +1986,8 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla,
|
||||
|
||||
out_put_gfn:
|
||||
if ( p2m != hostp2m )
|
||||
__put_gfn(p2m, gfn);
|
||||
__put_gfn(hostp2m, gfn);
|
||||
p2m_put_gfn(p2m, _gfn(gfn));
|
||||
p2m_put_gfn(hostp2m, _gfn(gfn));
|
||||
out:
|
||||
/*
|
||||
* All of these are delayed until we exit, since we might
|
||||
|
||||
@@ -509,9 +509,16 @@ static inline mfn_t __nonnull(3) get_gfn_type(
|
||||
P2M_ALLOC | P2M_UNSHARE)
|
||||
|
||||
/* Will release the p2m_lock for this gfn entry. */
|
||||
void __put_gfn(struct p2m_domain *p2m, unsigned long gfn);
|
||||
void p2m_put_gfn(struct p2m_domain *p2m, gfn_t gfn);
|
||||
|
||||
#define put_gfn(d, gfn) __put_gfn(p2m_get_hostp2m((d)), (gfn))
|
||||
static inline void put_gfn(struct domain *d, unsigned long gfn)
|
||||
{
|
||||
if ( !paging_mode_translate(d) )
|
||||
/* Nothing to do in this case */
|
||||
return;
|
||||
|
||||
p2m_put_gfn(p2m_get_hostp2m(d), _gfn(gfn));
|
||||
}
|
||||
|
||||
/* The intent of the "unlocked" accessor is to have the caller not worry about
|
||||
* put_gfn. They apply to very specific situations: debug printk's, dumps
|
||||
|
||||
@@ -149,7 +149,7 @@ static int nestedhap_walk_L0_p2m(
|
||||
direct_mmio_out:
|
||||
*L0_gpa = (mfn_x(mfn) << PAGE_SHIFT) + (L1_gpa & ~PAGE_MASK);
|
||||
out:
|
||||
__put_gfn(p2m, L1_gpa >> PAGE_SHIFT);
|
||||
p2m_put_gfn(p2m, gaddr_to_gfn(L1_gpa));
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
+6
-14
@@ -333,21 +333,13 @@ mfn_t p2m_get_gfn_type_access(struct p2m_domain *p2m, gfn_t gfn,
|
||||
return mfn;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_HVM */
|
||||
|
||||
void __put_gfn(struct p2m_domain *p2m, unsigned long gfn)
|
||||
void p2m_put_gfn(struct p2m_domain *p2m, gfn_t gfn)
|
||||
{
|
||||
if ( !p2m || !paging_mode_translate(p2m->domain) )
|
||||
/* Nothing to do in this case */
|
||||
return;
|
||||
ASSERT(gfn_locked_by_me(p2m, gfn_x(gfn)));
|
||||
|
||||
ASSERT(gfn_locked_by_me(p2m, gfn));
|
||||
|
||||
gfn_unlock(p2m, gfn, 0);
|
||||
gfn_unlock(p2m, gfn_x(gfn), 0);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_HVM
|
||||
|
||||
/* Atomically look up a GFN and take a reference count on the backing page. */
|
||||
struct page_info *p2m_get_page_from_gfn(
|
||||
struct p2m_domain *p2m, gfn_t gfn,
|
||||
@@ -2222,10 +2214,10 @@ int p2m_altp2m_propagate_change(struct domain *d, gfn_t gfn,
|
||||
if ( !ret )
|
||||
ret = rc;
|
||||
|
||||
__put_gfn(p2m, gfn_x(gfn));
|
||||
p2m_put_gfn(p2m, gfn);
|
||||
}
|
||||
else
|
||||
__put_gfn(p2m, gfn_x(gfn));
|
||||
p2m_put_gfn(p2m, gfn);
|
||||
}
|
||||
|
||||
altp2m_list_unlock(d);
|
||||
@@ -2310,7 +2302,7 @@ void audit_p2m(struct domain *d,
|
||||
* blow away the m2p entry. */
|
||||
set_gpfn_from_mfn(mfn, INVALID_M2P_ENTRY);
|
||||
}
|
||||
__put_gfn(p2m, gfn);
|
||||
p2m_put_gfn(p2m, _gfn(gfn));
|
||||
|
||||
P2M_PRINTK("OK: mfn=%#lx, gfn=%#lx, p2mfn=%#lx\n",
|
||||
mfn, gfn, mfn_x(p2mfn));
|
||||
|
||||