From: George Dunlap <george.dunlap@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
xen-devel <xen-devel@lists.xenproject.org>
Cc: Kevin Tian <kevin.tian@intel.com>, Keir Fraser <keir@xen.org>,
George Dunlap <George.Dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
Ian Campbell <Ian.Campbell@eu.citrix.com>,
Jun Nakajima <jun.nakajima@intel.com>
Subject: Re: [PATCH] use clear_domain_page() instead of open coding it
Date: Tue, 20 Oct 2015 10:53:39 +0100 [thread overview]
Message-ID: <56260F23.7080007@citrix.com> (raw)
In-Reply-To: <56251FA002000078000AC6C0@prv-mh.provo.novell.com>
On 19/10/15 15:51, Jan Beulich wrote:
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
mm bits:
Acked-by: George Dunlap <george.dunlap@citrix.com>
>
> --- a/xen/arch/x86/hvm/stdvga.c
> +++ b/xen/arch/x86/hvm/stdvga.c
> @@ -552,8 +552,7 @@ void stdvga_init(struct domain *d)
> {
> struct hvm_hw_stdvga *s = &d->arch.hvm_domain.stdvga;
> struct page_info *pg;
> - void *p;
> - int i;
> + unsigned int i;
>
> memset(s, 0, sizeof(*s));
> spin_lock_init(&s->lock);
> @@ -564,9 +563,7 @@ void stdvga_init(struct domain *d)
> if ( pg == NULL )
> break;
> s->vram_page[i] = pg;
> - p = __map_domain_page(pg);
> - clear_page(p);
> - unmap_domain_page(p);
> + clear_domain_page(_mfn(page_to_mfn(pg)));
> }
>
> if ( i == ARRAY_SIZE(s->vram_page) )
> --- a/xen/arch/x86/hvm/vmx/vvmx.c
> +++ b/xen/arch/x86/hvm/vmx/vvmx.c
> @@ -68,7 +68,7 @@ int nvmx_vcpu_initialise(struct vcpu *v)
> if ( cpu_has_vmx_vmcs_shadowing )
> {
> struct page_info *vmread_bitmap, *vmwrite_bitmap;
> - unsigned long *vr, *vw;
> + unsigned long *vw;
>
> vmread_bitmap = alloc_domheap_page(NULL, 0);
> if ( !vmread_bitmap )
> @@ -78,6 +78,8 @@ int nvmx_vcpu_initialise(struct vcpu *v)
> }
> v->arch.hvm_vmx.vmread_bitmap = vmread_bitmap;
>
> + clear_domain_page(_mfn(page_to_mfn(vmread_bitmap)));
> +
> vmwrite_bitmap = alloc_domheap_page(NULL, 0);
> if ( !vmwrite_bitmap )
> {
> @@ -86,10 +88,7 @@ int nvmx_vcpu_initialise(struct vcpu *v)
> }
> v->arch.hvm_vmx.vmwrite_bitmap = vmwrite_bitmap;
>
> - vr = __map_domain_page(vmread_bitmap);
> vw = __map_domain_page(vmwrite_bitmap);
> -
> - clear_page(vr);
> clear_page(vw);
>
> /*
> @@ -101,7 +100,6 @@ int nvmx_vcpu_initialise(struct vcpu *v)
> set_bit(IO_BITMAP_B, vw);
> set_bit(VMCS_HIGH(IO_BITMAP_B), vw);
>
> - unmap_domain_page(vr);
> unmap_domain_page(vw);
> }
>
> --- a/xen/arch/x86/mm/p2m.c
> +++ b/xen/arch/x86/mm/p2m.c
> @@ -1907,7 +1907,7 @@ p2m_flush_table(struct p2m_domain *p2m)
> {
> struct page_info *top, *pg;
> struct domain *d = p2m->domain;
> - void *p;
> + mfn_t mfn;
>
> p2m_lock(p2m);
>
> @@ -1928,15 +1928,14 @@ p2m_flush_table(struct p2m_domain *p2m)
> p2m->np2m_base = P2M_BASE_EADDR;
>
> /* Zap the top level of the trie */
> - top = mfn_to_page(pagetable_get_mfn(p2m_get_pagetable(p2m)));
> - p = __map_domain_page(top);
> - clear_page(p);
> - unmap_domain_page(p);
> + mfn = pagetable_get_mfn(p2m_get_pagetable(p2m));
> + clear_domain_page(mfn);
>
> /* Make sure nobody else is using this p2m table */
> nestedhvm_vmcx_flushtlb(p2m);
>
> /* Free the rest of the trie pages back to the paging pool */
> + top = mfn_to_page(mfn);
> while ( (pg = page_list_remove_head(&p2m->pages)) )
> if ( pg != top )
> d->arch.paging.free_page(d, pg);
> --- a/xen/arch/x86/mm/paging.c
> +++ b/xen/arch/x86/mm/paging.c
> @@ -78,12 +78,10 @@ static mfn_t paging_new_log_dirty_page(s
> static mfn_t paging_new_log_dirty_leaf(struct domain *d)
> {
> mfn_t mfn = paging_new_log_dirty_page(d);
> +
> if ( mfn_valid(mfn) )
> - {
> - void *leaf = map_domain_page(mfn);
> - clear_page(leaf);
> - unmap_domain_page(leaf);
> - }
> + clear_domain_page(mfn);
> +
> return mfn;
> }
>
> --- a/xen/arch/x86/mm/shadow/common.c
> +++ b/xen/arch/x86/mm/shadow/common.c
> @@ -1437,8 +1437,7 @@ mfn_t shadow_alloc(struct domain *d,
> unsigned int pages = shadow_size(shadow_type);
> struct page_list_head tmp_list;
> cpumask_t mask;
> - void *p;
> - int i;
> + unsigned int i;
>
> ASSERT(paging_locked_by_me(d));
> ASSERT(shadow_type != SH_type_none);
> @@ -1484,10 +1483,7 @@ mfn_t shadow_alloc(struct domain *d,
> flush_tlb_mask(&mask);
> }
> /* Now safe to clear the page for reuse */
> - p = __map_domain_page(sp);
> - ASSERT(p != NULL);
> - clear_page(p);
> - unmap_domain_page(p);
> + clear_domain_page(page_to_mfn(sp));
> INIT_PAGE_LIST_ENTRY(&sp->list);
> page_list_add(sp, &tmp_list);
> sp->u.sh.type = shadow_type;
> --- a/xen/common/page_alloc.c
> +++ b/xen/common/page_alloc.c
> @@ -1959,22 +1959,16 @@ __initcall(pagealloc_keyhandler_init);
>
> void scrub_one_page(struct page_info *pg)
> {
> - void *p;
> -
> if ( unlikely(pg->count_info & PGC_broken) )
> return;
>
> - p = __map_domain_page(pg);
> -
> #ifndef NDEBUG
> /* Avoid callers relying on allocations returning zeroed pages. */
> - memset(p, 0xc2, PAGE_SIZE);
> + unmap_domain_page(memset(__map_domain_page(pg), 0xc2, PAGE_SIZE));
> #else
> /* For a production build, clear_page() is the fastest way to scrub. */
> - clear_page(p);
> + clear_domain_page(_mfn(page_to_mfn(pg)));
> #endif
> -
> - unmap_domain_page(p);
> }
>
> static void dump_heap(unsigned char key)
>
>
next prev parent reply other threads:[~2015-10-20 9:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-19 14:51 [PATCH] use clear_domain_page() instead of open coding it Jan Beulich
2015-10-20 9:53 ` Andrew Cooper
2015-10-20 9:53 ` George Dunlap [this message]
2015-10-26 13:06 ` Ping: " Jan Beulich
2015-10-26 15:47 ` Ian Jackson
2015-10-26 15:59 ` Jan Beulich
2015-11-02 13:50 ` Ian Campbell
2015-10-29 1:13 ` Tian, Kevin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56260F23.7080007@citrix.com \
--to=george.dunlap@citrix.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=Ian.Campbell@eu.citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=jun.nakajima@intel.com \
--cc=keir@xen.org \
--cc=kevin.tian@intel.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.