common: Use get_page_from_gfn() instead of get_gfn()/put_gfn.

Signed-off-by: Tim Deegan <tim@xen.org>
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
This commit is contained in:
Tim Deegan committed 2012-05-17 10:24:54 +01:00
1 parent d5132620b5
commit 06e7bfed20
3 files changed
+28 -29

No files matched your search

+7 -7
View File
@@ -676,7 +676,7 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE(void) arg)
case XENMEM_remove_from_physmap:
{
struct xen_remove_from_physmap xrfp;
unsigned long mfn;
struct page_info *page;
struct domain *d;
if ( copy_from_guest(&xrfp, arg, 1) )
@@ -694,15 +694,15 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE(void) arg)
domain_lock(d);
mfn = get_gfn_untyped(d, xrfp.gpfn);
if ( mfn_valid(mfn) )
guest_physmap_remove_page(d, xrfp.gpfn, mfn, 0);
page = get_page_from_gfn(d, xrfp.gpfn, NULL, P2M_ALLOC);
if ( page )
{
guest_physmap_remove_page(d, xrfp.gpfn, page_to_mfn(page), 0);
put_page(page);
}
else
rc = -ENOENT;
put_gfn(d, xrfp.gpfn);
domain_unlock(d);
rcu_unlock_domain(d);
+10 -16
View File
@@ -107,30 +107,25 @@ static inline void cli_put_page(tmem_cli_mfn_t cmfn, void *cli_va, pfp_t *cli_pf
static inline void *cli_get_page(tmem_cli_mfn_t cmfn, unsigned long *pcli_mfn,
pfp_t **pcli_pfp, bool_t cli_write)
{
unsigned long cli_mfn;
p2m_type_t t;
struct page_info *page;
int ret;
cli_mfn = mfn_x(get_gfn(current->domain, cmfn, &t));
if ( t != p2m_ram_rw || !mfn_valid(cli_mfn) )
page = get_page_from_gfn(current->domain, cmfn, &t, P2M_ALLOC);
if ( !page || t != p2m_ram_rw )
{
put_gfn(current->domain, (unsigned long) cmfn);
return NULL;
if ( page )
put_page(page);
}
page = mfn_to_page(cli_mfn);
if ( cli_write )
ret = get_page_and_type(page, current->domain, PGT_writable_page);
else
ret = get_page(page, current->domain);
if ( !ret )
if ( cli_write && !get_page_type(page, PGT_writable_page) )
{
put_gfn(current->domain, (unsigned long) cmfn);
put_page(page);
return NULL;
}
*pcli_mfn = cli_mfn;
*pcli_mfn = page_to_mfn(page);
*pcli_pfp = (pfp_t *)page;
return map_domain_page(cli_mfn);
return map_domain_page(*pcli_mfn);
}
static inline void cli_put_page(tmem_cli_mfn_t cmfn, void *cli_va, pfp_t *cli_pfp,
@@ -144,7 +139,6 @@ static inline void cli_put_page(tmem_cli_mfn_t cmfn, void *cli_va, pfp_t *cli_pf
else
put_page((struct page_info *)cli_pfp);
unmap_domain_page(cli_va);
put_gfn(current->domain, (unsigned long) cmfn);
}
#endif
+11 -6
View File
@@ -1318,6 +1318,7 @@ static int flask_mmu_normal_update(struct domain *d, struct domain *t,
struct domain_security_struct *dsec;
u32 fsid;
struct avc_audit_data ad;
struct page_info *page = NULL;
if (d != t)
rc = domain_has_perm(d, t, SECCLASS_MMU, MMU__REMOTE_REMAP);
@@ -1333,8 +1334,9 @@ static int flask_mmu_normal_update(struct domain *d, struct domain *t,
map_perms |= MMU__MAP_WRITE;
AVC_AUDIT_DATA_INIT(&ad, MEMORY);
fmfn = get_gfn_untyped(f, l1e_get_pfn(l1e_from_intpte(fpte)));
page = get_page_from_gfn(f, l1e_get_pfn(l1e_from_intpte(fpte)),
NULL, P2M_ALLOC);
fmfn = page ? page_to_mfn(page) : INVALID_MFN;
ad.sdom = d;
ad.tdom = f;
ad.memory.pte = fpte;
@@ -1342,7 +1344,8 @@ static int flask_mmu_normal_update(struct domain *d, struct domain *t,
rc = get_mfn_sid(fmfn, &fsid);
put_gfn(f, fmfn);
if ( page )
put_page(page);
if ( rc )
return rc;
@@ -1370,7 +1373,7 @@ static int flask_update_va_mapping(struct domain *d, struct domain *f,
int rc = 0;
u32 psid;
u32 map_perms = MMU__MAP_READ;
unsigned long mfn;
struct page_info *page = NULL;
struct domain_security_struct *dsec;
if ( !(l1e_get_flags(pte) & _PAGE_PRESENT) )
@@ -1381,8 +1384,10 @@ static int flask_update_va_mapping(struct domain *d, struct domain *f,
dsec = d->ssid;
mfn = get_gfn_untyped(f, l1e_get_pfn(pte));
rc = get_mfn_sid(mfn, &psid);
page = get_page_from_gfn(f, l1e_get_pfn(pte), NULL, P2M_ALLOC);
rc = get_mfn_sid(page ? page_to_mfn(page) : INVALID_MFN, &psid);
if ( page )
put_page(page);
if ( rc )
return rc;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.