[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] x86/mem-paging: consistently use gfn_t
commit 4c73a2a939a51dee47db77b31208157dbc29fe98 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Mon May 18 17:17:51 2020 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Mon May 18 17:17:51 2020 +0200 x86/mem-paging: consistently use gfn_t Where gprintk()s get touched anyway to switch to PRI_gfn, also switch to %pd for the domain logged. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- xen/arch/x86/hvm/dm.c | 2 +- xen/arch/x86/hvm/hvm.c | 4 ++-- xen/arch/x86/mm.c | 7 ++++--- xen/arch/x86/mm/hap/guest_walk.c | 4 ++-- xen/arch/x86/mm/mem_paging.c | 31 +++++++++++++------------------ xen/arch/x86/mm/p2m.c | 2 +- xen/arch/x86/traps.c | 2 +- xen/common/memory.c | 4 ++-- xen/include/asm-x86/p2m.h | 5 ++--- 9 files changed, 28 insertions(+), 33 deletions(-) diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c index 96c5042b75..e3f845165d 100644 --- a/xen/arch/x86/hvm/dm.c +++ b/xen/arch/x86/hvm/dm.c @@ -278,7 +278,7 @@ static int set_mem_type(struct domain *d, if ( p2m_is_paging(t) ) { put_gfn(d, pfn); - p2m_mem_paging_populate(d, pfn); + p2m_mem_paging_populate(d, _gfn(pfn)); return -EAGAIN; } diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 0a3797ef6e..09ee299bc7 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1988,7 +1988,7 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla, * locks in such circumstance. */ if ( paged ) - p2m_mem_paging_populate(currd, gfn); + p2m_mem_paging_populate(currd, _gfn(gfn)); if ( sharing_enomem ) { @@ -3222,7 +3222,7 @@ enum hvm_translation_result hvm_translate_get_page( if ( p2m_is_paging(p2mt) ) { put_page(page); - p2m_mem_paging_populate(v->domain, gfn_x(gfn)); + p2m_mem_paging_populate(v->domain, gfn); return HVMTRANS_gfn_paged_out; } if ( p2m_is_shared(p2mt) ) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index dba0903c8f..e42044eb74 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -2118,16 +2118,17 @@ static int mod_l1_entry(l1_pgentry_t *pl1e, l1_pgentry_t nl1e, paging_mode_translate(pg_dom) ) { p2m_type_t p2mt; + gfn_t gfn = _gfn(l1e_get_pfn(nl1e)); p2m_query_t q = l1e_get_flags(nl1e) & _PAGE_RW ? P2M_ALLOC | P2M_UNSHARE : P2M_ALLOC; - page = get_page_from_gfn(pg_dom, l1e_get_pfn(nl1e), &p2mt, q); + page = get_page_from_gfn(pg_dom, gfn_x(gfn), &p2mt, q); if ( p2m_is_paged(p2mt) ) { if ( page ) put_page(page); - p2m_mem_paging_populate(pg_dom, l1e_get_pfn(nl1e)); + p2m_mem_paging_populate(pg_dom, gfn); return -ENOENT; } @@ -3949,7 +3950,7 @@ long do_mmu_update( put_page(page); if ( p2m_is_paged(p2mt) ) { - p2m_mem_paging_populate(pt_owner, gmfn); + p2m_mem_paging_populate(pt_owner, _gfn(gmfn)); rc = -ENOENT; } else diff --git a/xen/arch/x86/mm/hap/guest_walk.c b/xen/arch/x86/mm/hap/guest_walk.c index 6001cf3330..f59ebc84a2 100644 --- a/xen/arch/x86/mm/hap/guest_walk.c +++ b/xen/arch/x86/mm/hap/guest_walk.c @@ -68,7 +68,7 @@ unsigned long hap_p2m_ga_to_gfn(GUEST_PAGING_LEVELS)( *pfec = PFEC_page_paged; if ( top_page ) put_page(top_page); - p2m_mem_paging_populate(p2m->domain, cr3 >> PAGE_SHIFT); + p2m_mem_paging_populate(p2m->domain, gaddr_to_gfn(cr3)); return gfn_x(INVALID_GFN); } if ( p2m_is_shared(p2mt) ) @@ -110,7 +110,7 @@ unsigned long hap_p2m_ga_to_gfn(GUEST_PAGING_LEVELS)( { ASSERT(p2m_is_hostp2m(p2m)); *pfec = PFEC_page_paged; - p2m_mem_paging_populate(p2m->domain, gfn_x(gfn)); + p2m_mem_paging_populate(p2m->domain, gfn); return gfn_x(INVALID_GFN); } if ( p2m_is_shared(p2mt) ) diff --git a/xen/arch/x86/mm/mem_paging.c b/xen/arch/x86/mm/mem_paging.c index 84b05cd461..6aa1bffa65 100644 --- a/xen/arch/x86/mm/mem_paging.c +++ b/xen/arch/x86/mm/mem_paging.c @@ -36,12 +36,11 @@ * released by the guest. The pager is supposed to drop its reference of the * gfn. */ -void p2m_mem_paging_drop_page(struct domain *d, unsigned long gfn, - p2m_type_t p2mt) +void p2m_mem_paging_drop_page(struct domain *d, gfn_t gfn, p2m_type_t p2mt) { vm_event_request_t req = { .reason = VM_EVENT_REASON_MEM_PAGING, - .u.mem_paging.gfn = gfn + .u.mem_paging.gfn = gfn_x(gfn) }; /* @@ -89,16 +88,15 @@ void p2m_mem_paging_drop_page(struct domain *d, unsigned long gfn, * already sent to the pager. In this case the caller has to try again until the * gfn is fully paged in again. */ -void p2m_mem_paging_populate(struct domain *d, unsigned long gfn_l) +void p2m_mem_paging_populate(struct domain *d, gfn_t gfn) { struct vcpu *v = current; vm_event_request_t req = { .reason = VM_EVENT_REASON_MEM_PAGING, - .u.mem_paging.gfn = gfn_l + .u.mem_paging.gfn = gfn_x(gfn) }; p2m_type_t p2mt; p2m_access_t a; - gfn_t gfn = _gfn(gfn_l); mfn_t mfn; struct p2m_domain *p2m = p2m_get_hostp2m(d); int rc = vm_event_claim_slot(d, d->vm_event_paging); @@ -106,8 +104,8 @@ void p2m_mem_paging_populate(struct domain *d, unsigned long gfn_l) /* We're paging. There should be a ring. */ if ( rc == -EOPNOTSUPP ) { - gdprintk(XENLOG_ERR, "Dom%d paging gfn %lx yet no ring in place\n", - d->domain_id, gfn_l); + gdprintk(XENLOG_ERR, "%pd paging gfn %"PRI_gfn" yet no ring in place\n", + d, gfn_x(gfn)); /* Prevent the vcpu from faulting repeatedly on the same gfn */ if ( v->domain == d ) vcpu_pause_nosync(v); @@ -218,13 +216,12 @@ void p2m_mem_paging_resume(struct domain *d, vm_event_response_t *rsp) * Once the p2mt is changed the page is readonly for the guest. On success the * pager can write the page contents to disk and later evict the page. */ -static int nominate(struct domain *d, unsigned long gfn_l) +static int nominate(struct domain *d, gfn_t gfn) { struct page_info *page; struct p2m_domain *p2m = p2m_get_hostp2m(d); p2m_type_t p2mt; p2m_access_t a; - gfn_t gfn = _gfn(gfn_l); mfn_t mfn; int ret = -EBUSY; @@ -279,12 +276,11 @@ static int nominate(struct domain *d, unsigned long gfn_l) * could evict it, eviction can not be done either. In this case the gfn is * still backed by a mfn. */ -static int evict(struct domain *d, unsigned long gfn_l) +static int evict(struct domain *d, gfn_t gfn) { struct page_info *page; p2m_type_t p2mt; p2m_access_t a; - gfn_t gfn = _gfn(gfn_l); mfn_t mfn; struct p2m_domain *p2m = p2m_get_hostp2m(d); int ret = -EBUSY; @@ -346,13 +342,12 @@ static int evict(struct domain *d, unsigned long gfn_l) * mfn if populate was called for gfn which was nominated but not evicted. In * this case only the p2mt needs to be forwarded. */ -static int prepare(struct domain *d, unsigned long gfn_l, +static int prepare(struct domain *d, gfn_t gfn, XEN_GUEST_HANDLE_64(const_uint8) buffer) { struct page_info *page = NULL; p2m_type_t p2mt; p2m_access_t a; - gfn_t gfn = _gfn(gfn_l); mfn_t mfn; struct p2m_domain *p2m = p2m_get_hostp2m(d); int ret, page_extant = 1; @@ -417,7 +412,7 @@ static int prepare(struct domain *d, unsigned long gfn_l, : p2m_ram_rw, a); if ( !ret ) { - set_gpfn_from_mfn(mfn_x(mfn), gfn_l); + set_gpfn_from_mfn(mfn_x(mfn), gfn_x(gfn)); if ( !page_extant ) atomic_dec(&d->paged_pages); @@ -461,15 +456,15 @@ int mem_paging_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_paging_op_t) arg) switch( mpo.op ) { case XENMEM_paging_op_nominate: - rc = nominate(d, mpo.gfn); + rc = nominate(d, _gfn(mpo.gfn)); break; case XENMEM_paging_op_evict: - rc = evict(d, mpo.gfn); + rc = evict(d, _gfn(mpo.gfn)); break; case XENMEM_paging_op_prep: - rc = prepare(d, mpo.gfn, mpo.buffer); + rc = prepare(d, _gfn(mpo.gfn), mpo.buffer); if ( !rc ) copyback = 1; break; diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index cc624281e0..17f320b624 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -1835,7 +1835,7 @@ void *map_domain_gfn(struct p2m_domain *p2m, gfn_t gfn, mfn_t *mfn, ASSERT(p2m_is_hostp2m(p2m)); if ( page ) put_page(page); - p2m_mem_paging_populate(p2m->domain, gfn_x(gfn)); + p2m_mem_paging_populate(p2m->domain, gfn); *pfec = PFEC_page_paged; return NULL; } diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 73c6218660..1f6f1dde76 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -848,7 +848,7 @@ int guest_wrmsr_xen(struct vcpu *v, uint32_t idx, uint64_t val) if ( p2m_is_paging(t) ) { - p2m_mem_paging_populate(d, gmfn); + p2m_mem_paging_populate(d, _gfn(gmfn)); return X86EMUL_RETRY; } diff --git a/xen/common/memory.c b/xen/common/memory.c index 6e4b85674d..714077c1e5 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -322,7 +322,7 @@ int guest_remove_page(struct domain *d, unsigned long gmfn) put_gfn(d, gmfn); - p2m_mem_paging_drop_page(d, gmfn, p2mt); + p2m_mem_paging_drop_page(d, _gfn(gmfn), p2mt); return 0; } @@ -1667,7 +1667,7 @@ int check_get_page_from_gfn(struct domain *d, gfn_t gfn, bool readonly, if ( page ) put_page(page); - p2m_mem_paging_populate(d, gfn_x(gfn)); + p2m_mem_paging_populate(d, gfn); return -EAGAIN; } #endif diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index bf691ff568..8abae345e8 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -732,10 +732,9 @@ static inline void p2m_pod_init(struct p2m_domain *p2m) {} int set_shared_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn); /* Tell xenpaging to drop a paged out frame */ -void p2m_mem_paging_drop_page(struct domain *d, unsigned long gfn, - p2m_type_t p2mt); +void p2m_mem_paging_drop_page(struct domain *d, gfn_t gfn, p2m_type_t p2mt); /* Start populating a paged out frame */ -void p2m_mem_paging_populate(struct domain *d, unsigned long gfn); +void p2m_mem_paging_populate(struct domain *d, gfn_t gfn); /* Resume normal operation (in case a domain was paused) */ struct vm_event_st; void p2m_mem_paging_resume(struct domain *d, struct vm_event_st *rsp); -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |