p2m cleanup: remove unused function
PATCH 1/1 p2m cleanup: remove unused function
Hi!
Attached patch removes gfn_to_mfn_current(). It is redundant and effectively unused.
All remaining users now use proper replacement function.
=> No functional change.
While here, silence stdvga and use page_mode_hap() consequently.
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
xen/arch/x86/hvm/emulate.c +4 -3
@@ -62,7 +62,7 @@ static int hvmemul_do_io(int rc;/* Check for paged out page */ - ram_mfn =gfn_to_mfn_unshare (current->domain, ram_gfn, &p2mt,0 ); + ram_mfn =gfn_to_mfn_unshare (curr->domain, ram_gfn, &p2mt,0 );if (p2m_is_paging (p2mt) ) {p2m_mem_paging_populate (curr->domain, ram_gfn);
@@ -638,6 +638,7 @@ static int hvmemul_rep_movs(unsigned long saddr, daddr, bytes;paddr_t sgpa, dgpa;uint32_t pfec = PFEC_page_present; +struct domain *d = current->domain;p2m_type_t p2mt;int rc, df = !!(ctxt->regs->eflags &X86_EFLAGS_DF );char *buf;
@@ -668,12 +669,12 @@ static int hvmemul_rep_movs(if ( rc !=X86EMUL_OKAY )return rc; - (void )gfn_to_mfn_current (sgpa >>PAGE_SHIFT , &p2mt); + (void )gfn_to_mfn (d, sgpa >>PAGE_SHIFT , &p2mt);if ( !p2m_is_ram (p2mt) && !p2m_is_grant (p2mt) )return hvmemul_do_mmio ( sgpa, reps, bytes_per_rep, dgpa,IOREQ_READ , df,NULL ); - (void )gfn_to_mfn_current (dgpa >>PAGE_SHIFT , &p2mt); + (void )gfn_to_mfn (d, dgpa >>PAGE_SHIFT , &p2mt);if ( !p2m_is_ram (p2mt) && !p2m_is_grant (p2mt) )return hvmemul_do_mmio ( dgpa, reps, bytes_per_rep, sgpa,IOREQ_WRITE , df,NULL );
xen/arch/x86/hvm/hvm.c +15 -13
@@ -933,8 +933,9 @@ bool_t hvm_hap_nested_page_fault(unsigne {p2m_type_t p2mt;mfn_t mfn; +struct domain *d = current->domain; - mfn =gfn_to_mfn_type_current (gfn, &p2mt, p2m_guest); + mfn =gfn_to_mfn_guest (d, gfn, &p2mt);/* * If this GFN is emulated MMIO or marked as read-only, pass the fault
@@ -949,20 +950,20 @@ bool_t hvm_hap_nested_page_fault(unsigne/* Check if the page has been paged out */ if (p2m_is_paged (p2mt) || (p2mt == p2m_ram_paging_out) ) -p2m_mem_paging_populate (current->domain, gfn); +p2m_mem_paging_populate (d, gfn);/* Mem sharing: unshare the page and try again */ if ( p2mt == p2m_ram_shared ) { -mem_sharing_unshare_page (current->domain, gfn,0 ); +mem_sharing_unshare_page (d, gfn,0 );return 1 ; }/* Spurious fault? PoD and log-dirty also take this path. */ if (p2m_is_ram (p2mt) ) { -paging_mark_dirty (current->domain,mfn_x (mfn)); -p2m_change_type (current->domain, gfn, p2m_ram_logdirty, p2m_ram_rw); +paging_mark_dirty (d,mfn_x (mfn)); +p2m_change_type (d, gfn, p2m_ram_logdirty, p2m_ram_rw);return 1 ; }
@@ -1087,7 +1088,7 @@ int hvm_set_cr0(unsigned long value) {/* The guest CR3 must be pointing to the guest physical. */ gfn = v->arch.hvm_vcpu.guest_cr[3 ]>>PAGE_SHIFT ; - mfn =mfn_x (gfn_to_mfn_current (gfn, &p2mt)); + mfn =mfn_x (gfn_to_mfn (v->domain, gfn, &p2mt));if ( !p2m_is_ram (p2mt) || !mfn_valid (mfn) || !get_page (mfn_to_page (mfn), v->domain)) {
@@ -1174,7 +1175,7 @@ int hvm_set_cr3(unsigned long value) {/* Shadow-mode CR3 change. Check PDBR and update refcounts. */ HVM_DBG_LOG (DBG_LEVEL_VMMU ,"CR3 value = %lx" , value); - mfn =mfn_x (gfn_to_mfn_current (value >>PAGE_SHIFT , &p2mt)); + mfn =mfn_x (gfn_to_mfn (v->domain, value >>PAGE_SHIFT , &p2mt));if ( !p2m_is_ram (p2mt) || !mfn_valid (mfn) || !get_page (mfn_to_page (mfn), v->domain) ) goto bad_cr3;
@@ -1317,6 +1318,7 @@ static void *hvm_map_entry(unsigned longunsigned long gfn, mfn;p2m_type_t p2mt;uint32_t pfec; +struct vcpu *v = current;if ( ((va & ~PAGE_MASK ) +8 ) >PAGE_SIZE ) {
@@ -1330,13 +1332,13 @@ static void *hvm_map_entry(unsigned long* write the accessed flags in the descriptors (in 32-bit mode), but * we still treat it as a kernel-mode read (i.e. no access checks). */ pfec = PFEC_page_present; - gfn =paging_gva_to_gfn (current, va, &pfec); + gfn =paging_gva_to_gfn (v, va, &pfec);if ( pfec == PFEC_page_paged || pfec == PFEC_page_shared )return NULL ; - mfn =mfn_x (gfn_to_mfn_unshare (current->domain, gfn, &p2mt,0 )); + mfn =mfn_x (gfn_to_mfn_unshare (v->domain, gfn, &p2mt,0 ));if (p2m_is_paging (p2mt) ) { -p2m_mem_paging_populate (current->domain, gfn); +p2m_mem_paging_populate (v->domain, gfn);return NULL ; }if (p2m_is_shared (p2mt) )
@@ -1344,13 +1346,13 @@ static void *hvm_map_entry(unsigned longif ( !p2m_is_ram (p2mt) ) {gdprintk (XENLOG_ERR ,"Failed to look up descriptor table entry\n" ); -domain_crash (current->domain); +domain_crash (v->domain);return NULL ; }ASSERT (mfn_valid (mfn)); -paging_mark_dirty (current->domain, mfn); +paging_mark_dirty (v->domain, mfn);return (char *)map_domain_page (mfn) + (va & ~PAGE_MASK ); }
@@ -1731,7 +1733,7 @@ static enum hvm_copy_result __hvm_copy( gfn = addr >>PAGE_SHIFT ; } - mfn =mfn_x (gfn_to_mfn_unshare (current->domain, gfn, &p2mt,0 )); + mfn =mfn_x (gfn_to_mfn_unshare (curr->domain, gfn, &p2mt,0 ));if (p2m_is_paging (p2mt) ) {
xen/arch/x86/hvm/stdvga.c +7 -4
@@ -481,7 +481,8 @@ static int mmio_move(struct hvm_hw_stdvgif (hvm_copy_to_guest_phys (data, &tmp, p->size) != HVMCOPY_okay ) { - (void )gfn_to_mfn_current (data >>PAGE_SHIFT , &p2mt); + (void )gfn_to_mfn (current->domain, + data >>PAGE_SHIFT , &p2mt);/* * The only case we handle is vga_mem <-> vga_mem. * Anything else disables caching and leaves it to qemu-dm.
@@ -503,7 +504,8 @@ static int mmio_move(struct hvm_hw_stdvgif (hvm_copy_from_guest_phys (&tmp, data, p->size) != HVMCOPY_okay ) { - (void )gfn_to_mfn_current (data >>PAGE_SHIFT , &p2mt); + (void )gfn_to_mfn (current->domain, + data >>PAGE_SHIFT , &p2mt);if ( (p2mt != p2m_mmio_dm) || (data <VGA_MEM_BASE ) || ((data + p->size) > (VGA_MEM_BASE +VGA_MEM_SIZE )) )return 0 ;
@@ -561,8 +563,9 @@ static int stdvga_intercept_mmio(ioreq_t {case IOREQ_TYPE_COPY : buf =mmio_move (s, p); -if ( buf ) -break ; +if ( !buf ) + s->cache =0 ; +break ;default :gdprintk (XENLOG_WARNING ,"unsupported mmio request type:%d " "addr:0x%04x data:0x%04x size:%d count:%d state:%d "
xen/arch/x86/hvm/svm/svm.c +1 -1
@@ -915,7 +915,7 @@ static void svm_do_nested_pgfault(paddr_return ;/* Everything else is an error. */ - mfn =gfn_to_mfn_type_current (gfn, &p2mt, p2m_guest); + mfn =gfn_to_mfn_guest (current->domain, gfn, &p2mt);gdprintk (XENLOG_ERR ,"SVM violation gpa %#" PRIpaddr", mfn %#lx, type %i\n" , gpa,mfn_x (mfn), p2mt);domain_crash (current->domain);
xen/arch/x86/hvm/vmx/vmx.c +1 -1
@@ -2121,7 +2121,7 @@ static void ept_handle_violation(unsignereturn ;/* Everything else is an error. */ - mfn =gfn_to_mfn_type_current (gfn, &p2mt, p2m_guest); + mfn =gfn_to_mfn_guest (current->domain, gfn, &p2mt); gdprintk(XENLOG_ERR, "EPT violation %#lx (%c%c%c/%c%c%c), " "gpa %#"PRIpaddr", mfn %#lx, type %i.\n", qualification,
xen/arch/x86/mm.c +1 -1
@@ -3673,7 +3673,7 @@ static int replace_grant_p2m_mapping(if ( new_addr !=0 || (flags & GNTMAP_contains_pte) )return GNTST_general_error; - old_mfn =gfn_to_mfn_current (gfn, &type); + old_mfn =gfn_to_mfn (current->domain, gfn, &type);if ( !p2m_is_grant (type) ||mfn_x (old_mfn) != frame ) { gdprintk(XENLOG_WARNING,
xen/arch/x86/mm/hap/p2m-ept.c +0 -7
@@ -542,12 +542,6 @@ out:return ; } -static mfn_t ept_get_entry_current (unsigned long gfn,p2m_type_t *t, -p2m_query_t q) -{ -return ept_get_entry (current->domain, gfn, t, q); -} -/* * To test if the new emt type is the same with old, * return 1 to not to reset ept entry.
@@ -718,7 +712,6 @@ void ept_p2m_init(struct domain *d) { d->arch.p2m->set_entry = ept_set_entry; d->arch.p2m->get_entry = ept_get_entry; - d->arch.p2m->get_entry_current = ept_get_entry_current; d->arch.p2m->change_entry_type_global = ept_change_entry_type_global; }
xen/arch/x86/mm/hap/private.h +1 -1
@@ -31,4 +31,4 @@ unsigned long hap_gva_to_gfn_4_levels(st uint32_t *pfec); -#endif /* __SVM_NPT_H__ */ +#endif /* __HAP_PRIVATE_H__ */
xen/arch/x86/mm/p2m.c +3 -129
158 lines not on this page · raw message
xen/include/asm-x86/p2m.h +1 -15
@@ -179,9 +179,6 @@ struct p2m_domain {mfn_t (*get_entry )(struct domain *d,unsigned long gfn,p2m_type_t *p2mt,p2m_query_t q); -mfn_t (*get_entry_current)(unsigned long gfn, -p2m_type_t *p2mt, -p2m_query_t q);void (*change_entry_type_global)(struct domain *d,p2m_type_t ot,p2m_type_t nt);
@@ -267,13 +264,6 @@ static inline p2m_type_t p2m_flags_to_ty#endif } -/* Read the current domain's p2m table. Do not populate PoD pages. */ -static inline mfn_t gfn_to_mfn_type_current (unsigned long gfn,p2m_type_t *t, -p2m_query_t q) -{ -return current->domain->arch.p2m->get_entry_current (gfn, t, q); -} -/* Read another domain's P2M table, mapping pages as we go. * Do not populate PoD pages. */ static inline
@@ -295,17 +285,13 @@ static inline mfn_t _gfn_to_mfn_type(str *t = p2m_ram_rw;return _mfn (gfn); } -if (likely (current->domain == d) ) -return gfn_to_mfn_type_current (gfn, t, q); -else -return gfn_to_mfn_type_foreign (d, gfn, t, q); +return gfn_to_mfn_type_foreign (d, gfn, t, q); }#define gfn_to_mfn (d, g, t) _gfn_to_mfn_type((d), (g), (t), p2m_alloc)#define gfn_to_mfn_query (d, g, t) _gfn_to_mfn_type((d), (g), (t), p2m_query)#define gfn_to_mfn_guest (d, g, t) _gfn_to_mfn_type((d), (g), (t), p2m_guest) -#define gfn_to_mfn_current (g, t) gfn_to_mfn_type_current((g), (t), p2m_alloc)#define gfn_to_mfn_foreign (d, g, t) gfn_to_mfn_type_foreign((d), (g), (t), p2m_alloc) static inline mfn_t gfn_to_mfn_unshare(struct domain *d,
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 2 lines · Christoph Egger
Attached patch removes
gfn_to_mfn_current(). It is redundant and effectively unused.
Hm, well, it's unused after your patch, but used a fair bit right now. It'll need an Ack from Tim Deegan, who's on holiday until middle of next week.
Quoted 4 lines
All remaining users now use proper replacement function. => No functional change.
While here, silence stdvga
Is that a bug fix? Anyhow would belong in a separate properly explained patch.
Quoted 2 lines
and use
page_mode_hap()
consequently.
I see you change over to using page_mode_hap() in a few places. I wasn't sure on the justification. If you could get rid of arch.hvm_domain.hap_enabled entirely that might make it seem more worthwhile. Again, it would need Ack from Tim.
-- Keir
I thought the whole point of gfn_to_mfn_current() was that it can walk the p2m table more efficiently if the domain in question is current. This isn't true with EPT-HAP, but I thought that it was true for both shadowed and NPT-HAP. Is this no longer the case?
-George
Quoted 33 lines · Keir Fraser
Quoted 2 lines · Christoph Egger
Attached patch removes
gfn_to_mfn_current(). It is redundant and effectively unused.Hm, well, it's unused after your patch, but used a fair bit right now. It'll need an Ack from Tim Deegan, who's on holiday until middle of next week.
Quoted 4 lines
All remaining users now use proper replacement function. => No functional change.
While here, silence stdvga
Is that a bug fix? Anyhow would belong in a separate properly explained patch.
Quoted 2 lines
and use
page_mode_hap()
consequently.I see you change over to using
page_mode_hap()in a few places. I wasn't sure on the justification. If you could get rid of arch.hvm_domain.hap_enabled entirely that might make it seem more worthwhile. Again, it would need Ack from Tim.-- Keir
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel