[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Use clear_page() wherever possible/reasonable instead of open coded
# HG changeset patch # User kfraser@xxxxxxxxxxxxxxxxxxxxx # Date 1182349994 -3600 # Node ID 005dd6b1cf8e0008aba7984b828274a40e8d7d95 # Parent 45a44a9cbe8d1028f1bc57b95734153e571602ab Use clear_page() wherever possible/reasonable instead of open coded memset() calls (likewise a few replacements memcpy -> copy_page). Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx> --- xen/arch/ia64/xen/domain.c | 9 ++++----- xen/arch/ia64/xen/xenmem.c | 2 +- xen/arch/x86/apic.c | 4 ++-- xen/arch/x86/domain.c | 2 +- xen/arch/x86/domain_build.c | 6 +++--- xen/arch/x86/hvm/svm/svm.c | 2 -- xen/arch/x86/hvm/svm/vmcb.c | 6 +++--- xen/arch/x86/hvm/vlapic.c | 2 +- xen/arch/x86/hvm/vmx/vmcs.c | 2 +- xen/arch/x86/hvm/vmx/vmx.c | 2 -- xen/arch/x86/x86_32/traps.c | 1 + xen/arch/x86/x86_64/traps.c | 1 + xen/common/grant_table.c | 12 ++++++------ 13 files changed, 24 insertions(+), 27 deletions(-) diff -r 45a44a9cbe8d -r 005dd6b1cf8e xen/arch/ia64/xen/domain.c --- a/xen/arch/ia64/xen/domain.c Wed Jun 20 15:29:53 2007 +0100 +++ b/xen/arch/ia64/xen/domain.c Wed Jun 20 15:33:14 2007 +0100 @@ -1146,9 +1146,8 @@ static void __init loaddomainelfimage(st dom_imva = __va_ul(page_to_maddr(p)); if (filesz > 0) { if (filesz >= PAGE_SIZE) - memcpy((void *) dom_imva, - (void *) elfaddr, - PAGE_SIZE); + copy_page((void *) dom_imva, + (void *) elfaddr); else { // copy partial page memcpy((void *) dom_imva, @@ -1166,7 +1165,7 @@ static void __init loaddomainelfimage(st } else if (memsz > 0) { /* always zero out entire page */ - memset((void *) dom_imva, 0, PAGE_SIZE); + clear_page((void *) dom_imva); } memsz -= PAGE_SIZE; filesz -= PAGE_SIZE; @@ -1367,7 +1366,7 @@ int __init construct_dom0(struct domain if (start_info_page == NULL) panic("can't allocate start info page"); si = page_to_virt(start_info_page); - memset(si, 0, PAGE_SIZE); + clear_page(si); snprintf(si->magic, sizeof(si->magic), "xen-%i.%i-ia64", xen_major_version(), xen_minor_version()); si->nr_pages = max_pages; diff -r 45a44a9cbe8d -r 005dd6b1cf8e xen/arch/ia64/xen/xenmem.c --- a/xen/arch/ia64/xen/xenmem.c Wed Jun 20 15:29:53 2007 +0100 +++ b/xen/arch/ia64/xen/xenmem.c Wed Jun 20 15:33:14 2007 +0100 @@ -90,7 +90,7 @@ alloc_dir_page(void) panic("Not enough memory for virtual frame table!\n"); ++table_size; dir = mfn << PAGE_SHIFT; - memset(__va(dir), 0, PAGE_SIZE); + clear_page(__va(dir)); return dir; } diff -r 45a44a9cbe8d -r 005dd6b1cf8e xen/arch/x86/apic.c --- a/xen/arch/x86/apic.c Wed Jun 20 15:29:53 2007 +0100 +++ b/xen/arch/x86/apic.c Wed Jun 20 15:33:14 2007 +0100 @@ -817,7 +817,7 @@ void __init init_apic_mappings(void) */ if (!smp_found_config && detect_init_APIC()) { apic_phys = __pa(alloc_xenheap_page()); - memset(__va(apic_phys), 0, PAGE_SIZE); + clear_page(__va(apic_phys)); } else apic_phys = mp_lapic_addr; @@ -852,7 +852,7 @@ void __init init_apic_mappings(void) } else { fake_ioapic_page: ioapic_phys = __pa(alloc_xenheap_page()); - memset(__va(ioapic_phys), 0, PAGE_SIZE); + clear_page(__va(ioapic_phys)); } set_fixmap_nocache(idx, ioapic_phys); apic_printk(APIC_VERBOSE, "mapped IOAPIC to %08lx (%08lx)\n", diff -r 45a44a9cbe8d -r 005dd6b1cf8e xen/arch/x86/domain.c --- a/xen/arch/x86/domain.c Wed Jun 20 15:29:53 2007 +0100 +++ b/xen/arch/x86/domain.c Wed Jun 20 15:33:14 2007 +0100 @@ -476,7 +476,7 @@ int arch_domain_create(struct domain *d) if ( (d->shared_info = alloc_xenheap_page()) == NULL ) goto fail; - memset(d->shared_info, 0, PAGE_SIZE); + clear_page(d->shared_info); share_xen_page_with_guest( virt_to_page(d->shared_info), d, XENSHARE_writable); } diff -r 45a44a9cbe8d -r 005dd6b1cf8e xen/arch/x86/domain_build.c --- a/xen/arch/x86/domain_build.c Wed Jun 20 15:29:53 2007 +0100 +++ b/xen/arch/x86/domain_build.c Wed Jun 20 15:33:14 2007 +0100 @@ -505,7 +505,7 @@ int __init construct_dom0( v->arch.guest_table = pagetable_from_paddr((unsigned long)l3start); #else l2start = l2tab = (l2_pgentry_t *)mpt_alloc; mpt_alloc += PAGE_SIZE; - memcpy(l2tab, idle_pg_table, PAGE_SIZE); + copy_page(l2tab, idle_pg_table); l2tab[LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT] = l2e_from_paddr((unsigned long)l2start, __PAGE_HYPERVISOR); v->arch.guest_table = pagetable_from_paddr((unsigned long)l2start); @@ -645,7 +645,7 @@ int __init construct_dom0( panic("Not enough RAM for domain 0 PML4.\n"); l4start = l4tab = page_to_virt(page); } - memcpy(l4tab, idle_pg_table, PAGE_SIZE); + copy_page(l4tab, idle_pg_table); l4tab[l4_table_offset(LINEAR_PT_VIRT_START)] = l4e_from_paddr(__pa(l4start), __PAGE_HYPERVISOR); l4tab[l4_table_offset(PERDOMAIN_VIRT_START)] = @@ -823,7 +823,7 @@ int __init construct_dom0( /* Set up start info area. */ si = (start_info_t *)vstartinfo_start; - memset(si, 0, PAGE_SIZE); + clear_page(si); si->nr_pages = nr_pages; si->shared_info = virt_to_maddr(d->shared_info); diff -r 45a44a9cbe8d -r 005dd6b1cf8e xen/arch/x86/hvm/svm/svm.c --- a/xen/arch/x86/hvm/svm/svm.c Wed Jun 20 15:29:53 2007 +0100 +++ b/xen/arch/x86/hvm/svm/svm.c Wed Jun 20 15:33:14 2007 +0100 @@ -765,8 +765,6 @@ static void svm_init_hypercall_page(stru { char *p; int i; - - memset(hypercall_page, 0, PAGE_SIZE); for ( i = 0; i < (PAGE_SIZE / 32); i++ ) { diff -r 45a44a9cbe8d -r 005dd6b1cf8e xen/arch/x86/hvm/svm/vmcb.c --- a/xen/arch/x86/hvm/svm/vmcb.c Wed Jun 20 15:29:53 2007 +0100 +++ b/xen/arch/x86/hvm/svm/vmcb.c Wed Jun 20 15:33:14 2007 +0100 @@ -56,7 +56,7 @@ struct vmcb_struct *alloc_vmcb(void) return NULL; } - memset(vmcb, 0, PAGE_SIZE); + clear_page(vmcb); return vmcb; } @@ -72,11 +72,11 @@ struct host_save_area *alloc_host_save_a hsa = alloc_xenheap_page(); if ( hsa == NULL ) { - printk(XENLOG_WARNING "Warning: failed to allocate vmcb.\n"); + printk(XENLOG_WARNING "Warning: failed to allocate hsa.\n"); return NULL; } - memset(hsa, 0, PAGE_SIZE); + clear_page(hsa); return hsa; } diff -r 45a44a9cbe8d -r 005dd6b1cf8e xen/arch/x86/hvm/vlapic.c --- a/xen/arch/x86/hvm/vlapic.c Wed Jun 20 15:29:53 2007 +0100 +++ b/xen/arch/x86/hvm/vlapic.c Wed Jun 20 15:33:14 2007 +0100 @@ -934,7 +934,7 @@ int vlapic_init(struct vcpu *v) return -ENOMEM; } - memset(vlapic->regs, 0, PAGE_SIZE); + clear_page(vlapic->regs); vlapic_reset(vlapic); diff -r 45a44a9cbe8d -r 005dd6b1cf8e xen/arch/x86/hvm/vmx/vmcs.c --- a/xen/arch/x86/hvm/vmx/vmcs.c Wed Jun 20 15:29:53 2007 +0100 +++ b/xen/arch/x86/hvm/vmx/vmcs.c Wed Jun 20 15:33:14 2007 +0100 @@ -158,7 +158,7 @@ static struct vmcs_struct *vmx_alloc_vmc return NULL; } - memset(vmcs, 0, PAGE_SIZE); + clear_page(vmcs); vmcs->vmcs_revision_id = vmcs_revision_id; return vmcs; diff -r 45a44a9cbe8d -r 005dd6b1cf8e xen/arch/x86/hvm/vmx/vmx.c --- a/xen/arch/x86/hvm/vmx/vmx.c Wed Jun 20 15:29:53 2007 +0100 +++ b/xen/arch/x86/hvm/vmx/vmx.c Wed Jun 20 15:33:14 2007 +0100 @@ -1070,8 +1070,6 @@ static void vmx_init_hypercall_page(stru char *p; int i; - memset(hypercall_page, 0, PAGE_SIZE); - for ( i = 0; i < (PAGE_SIZE / 32); i++ ) { p = (char *)(hypercall_page + (i * 32)); diff -r 45a44a9cbe8d -r 005dd6b1cf8e xen/arch/x86/x86_32/traps.c --- a/xen/arch/x86/x86_32/traps.c Wed Jun 20 15:29:53 2007 +0100 +++ b/xen/arch/x86/x86_32/traps.c Wed Jun 20 15:33:14 2007 +0100 @@ -513,6 +513,7 @@ static void hypercall_page_initialise_ri void hypercall_page_initialise(struct domain *d, void *hypercall_page) { + memset(hypercall_page, 0xCC, PAGE_SIZE); if ( is_hvm_domain(d) ) hvm_hypercall_page_initialise(d, hypercall_page); else if ( supervisor_mode_kernel ) diff -r 45a44a9cbe8d -r 005dd6b1cf8e xen/arch/x86/x86_64/traps.c --- a/xen/arch/x86/x86_64/traps.c Wed Jun 20 15:29:53 2007 +0100 +++ b/xen/arch/x86/x86_64/traps.c Wed Jun 20 15:33:14 2007 +0100 @@ -510,6 +510,7 @@ static void hypercall_page_initialise_ri void hypercall_page_initialise(struct domain *d, void *hypercall_page) { + memset(hypercall_page, 0xCC, PAGE_SIZE); if ( is_hvm_domain(d) ) hvm_hypercall_page_initialise(d, hypercall_page); else if ( !is_pv_32bit_domain(d) ) diff -r 45a44a9cbe8d -r 005dd6b1cf8e xen/common/grant_table.c --- a/xen/common/grant_table.c Wed Jun 20 15:29:53 2007 +0100 +++ b/xen/common/grant_table.c Wed Jun 20 15:33:14 2007 +0100 @@ -148,7 +148,7 @@ get_maptrack_handle( return -1; } - memset(new_mt, 0, PAGE_SIZE); + clear_page(new_mt); new_mt_limit = lgt->maptrack_limit + MAPTRACK_PER_PAGE; @@ -624,7 +624,7 @@ gnttab_grow_table(struct domain *d, unsi { if ( (gt->active[i] = alloc_xenheap_page()) == NULL ) goto active_alloc_failed; - memset(gt->active[i], 0, PAGE_SIZE); + clear_page(gt->active[i]); } /* Shared */ @@ -632,7 +632,7 @@ gnttab_grow_table(struct domain *d, unsi { if ( (gt->shared[i] = alloc_xenheap_page()) == NULL ) goto shared_alloc_failed; - memset(gt->shared[i], 0, PAGE_SIZE); + clear_page(gt->shared[i]); } /* Share the new shared frames with the recipient domain */ @@ -1365,7 +1365,7 @@ grant_table_create( { if ( (t->active[i] = alloc_xenheap_page()) == NULL ) goto no_mem_2; - memset(t->active[i], 0, PAGE_SIZE); + clear_page(t->active[i]); } /* Tracking of mapped foreign frames table */ @@ -1375,7 +1375,7 @@ grant_table_create( memset(t->maptrack, 0, max_nr_maptrack_frames() * sizeof(t->maptrack[0])); if ( (t->maptrack[0] = alloc_xenheap_page()) == NULL ) goto no_mem_3; - memset(t->maptrack[0], 0, PAGE_SIZE); + clear_page(t->maptrack[0]); t->maptrack_limit = PAGE_SIZE / sizeof(struct grant_mapping); for ( i = 0; i < t->maptrack_limit; i++ ) t->maptrack[0][i].ref = i+1; @@ -1389,7 +1389,7 @@ grant_table_create( { if ( (t->shared[i] = alloc_xenheap_page()) == NULL ) goto no_mem_4; - memset(t->shared[i], 0, PAGE_SIZE); + clear_page(t->shared[i]); } for ( i = 0; i < INITIAL_NR_GRANT_FRAMES; i++ ) _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |