[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] use clear_page() where-ever possible/reasonable
.. instead of open coded memset() calls (likewise a few replacements memcpy -> copy_page). Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx> Index: 2007-06-18/xen/arch/ia64/xen/domain.c =================================================================== --- 2007-06-18.orig/xen/arch/ia64/xen/domain.c 2007-06-18 08:34:29.000000000 +0200 +++ 2007-06-18/xen/arch/ia64/xen/domain.c 2007-06-18 11:58:40.000000000 +0200 @@ -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; Index: 2007-06-18/xen/arch/ia64/xen/xenmem.c =================================================================== --- 2007-06-18.orig/xen/arch/ia64/xen/xenmem.c 2007-06-18 08:34:29.000000000 +0200 +++ 2007-06-18/xen/arch/ia64/xen/xenmem.c 2007-06-18 11:58:40.000000000 +0200 @@ -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; } Index: 2007-06-18/xen/arch/x86/apic.c =================================================================== --- 2007-06-18.orig/xen/arch/x86/apic.c 2007-06-15 14:05:46.000000000 +0200 +++ 2007-06-18/xen/arch/x86/apic.c 2007-06-18 11:58:40.000000000 +0200 @@ -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", Index: 2007-06-18/xen/arch/x86/domain.c =================================================================== --- 2007-06-18.orig/xen/arch/x86/domain.c 2007-06-18 11:57:46.000000000 +0200 +++ 2007-06-18/xen/arch/x86/domain.c 2007-06-18 11:58:40.000000000 +0200 @@ -464,7 +464,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); } Index: 2007-06-18/xen/arch/x86/domain_build.c =================================================================== --- 2007-06-18.orig/xen/arch/x86/domain_build.c 2007-06-04 08:35:35.000000000 +0200 +++ 2007-06-18/xen/arch/x86/domain_build.c 2007-06-18 11:58:40.000000000 +0200 @@ -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); Index: 2007-06-18/xen/arch/x86/hvm/svm/svm.c =================================================================== --- 2007-06-18.orig/xen/arch/x86/hvm/svm/svm.c 2007-06-18 11:52:49.000000000 +0200 +++ 2007-06-18/xen/arch/x86/hvm/svm/svm.c 2007-06-18 11:58:40.000000000 +0200 @@ -772,8 +772,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++ ) { p = (char *)(hypercall_page + (i * 32)); Index: 2007-06-18/xen/arch/x86/hvm/svm/vmcb.c =================================================================== --- 2007-06-18.orig/xen/arch/x86/hvm/svm/vmcb.c 2007-06-18 11:52:49.000000000 +0200 +++ 2007-06-18/xen/arch/x86/hvm/svm/vmcb.c 2007-06-18 11:58:40.000000000 +0200 @@ -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; } Index: 2007-06-18/xen/arch/x86/hvm/vlapic.c =================================================================== --- 2007-06-18.orig/xen/arch/x86/hvm/vlapic.c 2007-06-15 14:05:46.000000000 +0200 +++ 2007-06-18/xen/arch/x86/hvm/vlapic.c 2007-06-18 11:59:21.000000000 +0200 @@ -935,7 +935,7 @@ int vlapic_init(struct vcpu *v) return -ENOMEM; } - memset(vlapic->regs, 0, PAGE_SIZE); + clear_page(vlapic->regs); vlapic_reset(vlapic); Index: 2007-06-18/xen/arch/x86/hvm/vmx/vmcs.c =================================================================== --- 2007-06-18.orig/xen/arch/x86/hvm/vmx/vmcs.c 2007-06-18 11:52:49.000000000 +0200 +++ 2007-06-18/xen/arch/x86/hvm/vmx/vmcs.c 2007-06-18 11:58:40.000000000 +0200 @@ -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; Index: 2007-06-18/xen/arch/x86/hvm/vmx/vmx.c =================================================================== --- 2007-06-18.orig/xen/arch/x86/hvm/vmx/vmx.c 2007-06-18 11:52:49.000000000 +0200 +++ 2007-06-18/xen/arch/x86/hvm/vmx/vmx.c 2007-06-18 11:58:40.000000000 +0200 @@ -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)); Index: 2007-06-18/xen/arch/x86/x86_32/traps.c =================================================================== --- 2007-06-18.orig/xen/arch/x86/x86_32/traps.c 2007-06-18 11:47:30.000000000 +0200 +++ 2007-06-18/xen/arch/x86/x86_32/traps.c 2007-06-18 11:58:40.000000000 +0200 @@ -502,6 +502,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 ) Index: 2007-06-18/xen/arch/x86/x86_64/traps.c =================================================================== --- 2007-06-18.orig/xen/arch/x86/x86_64/traps.c 2007-06-18 11:52:49.000000000 +0200 +++ 2007-06-18/xen/arch/x86/x86_64/traps.c 2007-06-18 11:58:40.000000000 +0200 @@ -514,6 +514,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) ) Index: 2007-06-18/xen/common/grant_table.c =================================================================== --- 2007-06-18.orig/xen/common/grant_table.c 2007-06-04 08:35:35.000000000 +0200 +++ 2007-06-18/xen/common/grant_table.c 2007-06-18 11:58:40.000000000 +0200 @@ -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-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |