From: "Jan Beulich" Subject: [PATCH] use clear_page() where-ever possible/reasonable Date: Tue, 19 Jun 2007 11:18:28 +0100 Message-ID: <4677C994.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org .. instead of open coded memset() calls (likewise a few replacements memcpy -> copy_page). Signed-off-by: Jan Beulich Index: 2007-06-18/xen/arch/ia64/xen/domain.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-06-18.orig/xen/arch/ia64/xen/domain.c 2007-06-18 08:34:29.0000000= 00 +0200 +++ 2007-06-18/xen/arch/ia64/xen/domain.c 2007-06-18 11:58:40.0000000= 00 +0200 @@ -1146,9 +1146,8 @@ static void __init loaddomainelfimage(st dom_imva =3D __va_ul(page_to_maddr(p)); if (filesz > 0) { if (filesz >=3D 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 -=3D PAGE_SIZE; filesz -=3D PAGE_SIZE; @@ -1367,7 +1366,7 @@ int __init construct_dom0(struct domain=20 if (start_info_page =3D=3D NULL) panic("can't allocate start info page"); si =3D 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 =3D max_pages; Index: 2007-06-18/xen/arch/ia64/xen/xenmem.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-06-18.orig/xen/arch/ia64/xen/xenmem.c 2007-06-18 08:34:29.0000000= 00 +0200 +++ 2007-06-18/xen/arch/ia64/xen/xenmem.c 2007-06-18 11:58:40.0000000= 00 +0200 @@ -90,7 +90,7 @@ alloc_dir_page(void) panic("Not enough memory for virtual frame table!\n"); ++table_size; dir =3D mfn << PAGE_SHIFT; - memset(__va(dir), 0, PAGE_SIZE); + clear_page(__va(dir)); return dir; } =20 Index: 2007-06-18/xen/arch/x86/apic.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =3D __pa(alloc_xenheap_page()); - memset(__va(apic_phys), 0, PAGE_SIZE); + clear_page(__va(apic_phys)); } else apic_phys =3D mp_lapic_addr; =20 @@ -852,7 +852,7 @@ void __init init_apic_mappings(void) } else { fake_ioapic_page: ioapic_phys =3D __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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-06-18.orig/xen/arch/x86/domain.c 2007-06-18 11:57:46.0000000= 00 +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 =3D alloc_xenheap_page()) =3D=3D NULL ) goto fail; =20 - 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-06-18.orig/xen/arch/x86/domain_build.c 2007-06-04 08:35:35.0000000= 00 +0200 +++ 2007-06-18/xen/arch/x86/domain_build.c 2007-06-18 11:58:40.0000000= 00 +0200 @@ -505,7 +505,7 @@ int __init construct_dom0( v->arch.guest_table =3D pagetable_from_paddr((unsigned long)l3start); #else l2start =3D l2tab =3D (l2_pgentry_t *)mpt_alloc; mpt_alloc +=3D = PAGE_SIZE; - memcpy(l2tab, idle_pg_table, PAGE_SIZE); + copy_page(l2tab, idle_pg_table); l2tab[LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT] =3D l2e_from_paddr((unsigned long)l2start, __PAGE_HYPERVISOR); v->arch.guest_table =3D pagetable_from_paddr((unsigned long)l2start); @@ -645,7 +645,7 @@ int __init construct_dom0( panic("Not enough RAM for domain 0 PML4.\n"); l4start =3D l4tab =3D 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)] =3D l4e_from_paddr(__pa(l4start), __PAGE_HYPERVISOR); l4tab[l4_table_offset(PERDOMAIN_VIRT_START)] =3D @@ -823,7 +823,7 @@ int __init construct_dom0( =20 /* Set up start info area. */ si =3D (start_info_t *)vstartinfo_start; - memset(si, 0, PAGE_SIZE); + clear_page(si); si->nr_pages =3D nr_pages; =20 si->shared_info =3D virt_to_maddr(d->shared_info); Index: 2007-06-18/xen/arch/x86/hvm/svm/svm.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-06-18.orig/xen/arch/x86/hvm/svm/svm.c 2007-06-18 11:52:49.0000000= 00 +0200 +++ 2007-06-18/xen/arch/x86/hvm/svm/svm.c 2007-06-18 11:58:40.0000000= 00 +0200 @@ -772,8 +772,6 @@ static void svm_init_hypercall_page(stru char *p; int i; =20 - memset(hypercall_page, 0, PAGE_SIZE); - for ( i =3D 0; i < (PAGE_SIZE / 32); i++ ) { p =3D (char *)(hypercall_page + (i * 32)); Index: 2007-06-18/xen/arch/x86/hvm/svm/vmcb.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-06-18.orig/xen/arch/x86/hvm/svm/vmcb.c 2007-06-18 11:52:49.0000000= 00 +0200 +++ 2007-06-18/xen/arch/x86/hvm/svm/vmcb.c 2007-06-18 11:58:40.0000000= 00 +0200 @@ -56,7 +56,7 @@ struct vmcb_struct *alloc_vmcb(void)=20 return NULL; } =20 - memset(vmcb, 0, PAGE_SIZE); + clear_page(vmcb); return vmcb; } =20 @@ -72,11 +72,11 @@ struct host_save_area *alloc_host_save_a hsa =3D alloc_xenheap_page(); if ( hsa =3D=3D NULL ) { - printk(XENLOG_WARNING "Warning: failed to allocate vmcb.\n"); + printk(XENLOG_WARNING "Warning: failed to allocate hsa.\n"); return NULL; } =20 - memset(hsa, 0, PAGE_SIZE); + clear_page(hsa); return hsa; } =20 Index: 2007-06-18/xen/arch/x86/hvm/vlapic.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-06-18.orig/xen/arch/x86/hvm/vlapic.c 2007-06-15 14:05:46.0000000= 00 +0200 +++ 2007-06-18/xen/arch/x86/hvm/vlapic.c 2007-06-18 11:59:21.0000000= 00 +0200 @@ -935,7 +935,7 @@ int vlapic_init(struct vcpu *v) return -ENOMEM; } =20 - memset(vlapic->regs, 0, PAGE_SIZE); + clear_page(vlapic->regs); =20 vlapic_reset(vlapic); =20 Index: 2007-06-18/xen/arch/x86/hvm/vmx/vmcs.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-06-18.orig/xen/arch/x86/hvm/vmx/vmcs.c 2007-06-18 11:52:49.0000000= 00 +0200 +++ 2007-06-18/xen/arch/x86/hvm/vmx/vmcs.c 2007-06-18 11:58:40.0000000= 00 +0200 @@ -158,7 +158,7 @@ static struct vmcs_struct *vmx_alloc_vmc return NULL; } =20 - memset(vmcs, 0, PAGE_SIZE); + clear_page(vmcs); vmcs->vmcs_revision_id =3D vmcs_revision_id; =20 return vmcs; Index: 2007-06-18/xen/arch/x86/hvm/vmx/vmx.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-06-18.orig/xen/arch/x86/hvm/vmx/vmx.c 2007-06-18 11:52:49.0000000= 00 +0200 +++ 2007-06-18/xen/arch/x86/hvm/vmx/vmx.c 2007-06-18 11:58:40.0000000= 00 +0200 @@ -1070,8 +1070,6 @@ static void vmx_init_hypercall_page(stru char *p; int i; =20 - memset(hypercall_page, 0, PAGE_SIZE); - for ( i =3D 0; i < (PAGE_SIZE / 32); i++ ) { p =3D (char *)(hypercall_page + (i * 32)); Index: 2007-06-18/xen/arch/x86/x86_32/traps.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-06-18.orig/xen/arch/x86/x86_32/traps.c 2007-06-18 11:47:30.0000000= 00 +0200 +++ 2007-06-18/xen/arch/x86/x86_32/traps.c 2007-06-18 11:58:40.0000000= 00 +0200 @@ -502,6 +502,7 @@ static void hypercall_page_initialise_ri =20 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-06-18.orig/xen/arch/x86/x86_64/traps.c 2007-06-18 11:52:49.0000000= 00 +0200 +++ 2007-06-18/xen/arch/x86/x86_64/traps.c 2007-06-18 11:58:40.0000000= 00 +0200 @@ -514,6 +514,7 @@ static void hypercall_page_initialise_ri =20 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-06-18.orig/xen/common/grant_table.c 2007-06-04 08:35:35.0000000= 00 +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; } =20 - memset(new_mt, 0, PAGE_SIZE); + clear_page(new_mt); =20 new_mt_limit =3D lgt->maptrack_limit + MAPTRACK_PER_PAGE; =20 @@ -624,7 +624,7 @@ gnttab_grow_table(struct domain *d, unsi { if ( (gt->active[i] =3D alloc_xenheap_page()) =3D=3D NULL ) goto active_alloc_failed; - memset(gt->active[i], 0, PAGE_SIZE); + clear_page(gt->active[i]); } =20 /* Shared */ @@ -632,7 +632,7 @@ gnttab_grow_table(struct domain *d, unsi { if ( (gt->shared[i] =3D alloc_xenheap_page()) =3D=3D NULL ) goto shared_alloc_failed; - memset(gt->shared[i], 0, PAGE_SIZE); + clear_page(gt->shared[i]); } =20 /* Share the new shared frames with the recipient domain */ @@ -1365,7 +1365,7 @@ grant_table_create( { if ( (t->active[i] =3D alloc_xenheap_page()) =3D=3D NULL ) goto no_mem_2; - memset(t->active[i], 0, PAGE_SIZE); + clear_page(t->active[i]); } =20 /* 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] =3D alloc_xenheap_page()) =3D=3D NULL ) goto no_mem_3; - memset(t->maptrack[0], 0, PAGE_SIZE); + clear_page(t->maptrack[0]); t->maptrack_limit =3D PAGE_SIZE / sizeof(struct grant_mapping); for ( i =3D 0; i < t->maptrack_limit; i++ ) t->maptrack[0][i].ref =3D i+1; @@ -1389,7 +1389,7 @@ grant_table_create( { if ( (t->shared[i] =3D alloc_xenheap_page()) =3D=3D NULL ) goto no_mem_4; - memset(t->shared[i], 0, PAGE_SIZE); + clear_page(t->shared[i]); } =20 for ( i =3D 0; i < INITIAL_NR_GRANT_FRAMES; i++ )