ia64/xen-unstable
changeset 15405:005dd6b1cf8e
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@novell.com>
memset() calls (likewise a few replacements memcpy -> copy_page).
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author | kfraser@localhost.localdomain |
---|---|
date | Wed Jun 20 15:33:14 2007 +0100 (2007-06-20) |
parents | 45a44a9cbe8d |
children | 810885428743 79b180596baf |
files | xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/xenmem.c xen/arch/x86/apic.c xen/arch/x86/domain.c xen/arch/x86/domain_build.c xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/svm/vmcb.c xen/arch/x86/hvm/vlapic.c xen/arch/x86/hvm/vmx/vmcs.c xen/arch/x86/hvm/vmx/vmx.c xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/traps.c xen/common/grant_table.c |
line diff
1.1 --- a/xen/arch/ia64/xen/domain.c Wed Jun 20 15:29:53 2007 +0100 1.2 +++ b/xen/arch/ia64/xen/domain.c Wed Jun 20 15:33:14 2007 +0100 1.3 @@ -1146,9 +1146,8 @@ static void __init loaddomainelfimage(st 1.4 dom_imva = __va_ul(page_to_maddr(p)); 1.5 if (filesz > 0) { 1.6 if (filesz >= PAGE_SIZE) 1.7 - memcpy((void *) dom_imva, 1.8 - (void *) elfaddr, 1.9 - PAGE_SIZE); 1.10 + copy_page((void *) dom_imva, 1.11 + (void *) elfaddr); 1.12 else { 1.13 // copy partial page 1.14 memcpy((void *) dom_imva, 1.15 @@ -1166,7 +1165,7 @@ static void __init loaddomainelfimage(st 1.16 } 1.17 else if (memsz > 0) { 1.18 /* always zero out entire page */ 1.19 - memset((void *) dom_imva, 0, PAGE_SIZE); 1.20 + clear_page((void *) dom_imva); 1.21 } 1.22 memsz -= PAGE_SIZE; 1.23 filesz -= PAGE_SIZE; 1.24 @@ -1367,7 +1366,7 @@ int __init construct_dom0(struct domain 1.25 if (start_info_page == NULL) 1.26 panic("can't allocate start info page"); 1.27 si = page_to_virt(start_info_page); 1.28 - memset(si, 0, PAGE_SIZE); 1.29 + clear_page(si); 1.30 snprintf(si->magic, sizeof(si->magic), "xen-%i.%i-ia64", 1.31 xen_major_version(), xen_minor_version()); 1.32 si->nr_pages = max_pages;
2.1 --- a/xen/arch/ia64/xen/xenmem.c Wed Jun 20 15:29:53 2007 +0100 2.2 +++ b/xen/arch/ia64/xen/xenmem.c Wed Jun 20 15:33:14 2007 +0100 2.3 @@ -90,7 +90,7 @@ alloc_dir_page(void) 2.4 panic("Not enough memory for virtual frame table!\n"); 2.5 ++table_size; 2.6 dir = mfn << PAGE_SHIFT; 2.7 - memset(__va(dir), 0, PAGE_SIZE); 2.8 + clear_page(__va(dir)); 2.9 return dir; 2.10 } 2.11
3.1 --- a/xen/arch/x86/apic.c Wed Jun 20 15:29:53 2007 +0100 3.2 +++ b/xen/arch/x86/apic.c Wed Jun 20 15:33:14 2007 +0100 3.3 @@ -817,7 +817,7 @@ void __init init_apic_mappings(void) 3.4 */ 3.5 if (!smp_found_config && detect_init_APIC()) { 3.6 apic_phys = __pa(alloc_xenheap_page()); 3.7 - memset(__va(apic_phys), 0, PAGE_SIZE); 3.8 + clear_page(__va(apic_phys)); 3.9 } else 3.10 apic_phys = mp_lapic_addr; 3.11 3.12 @@ -852,7 +852,7 @@ void __init init_apic_mappings(void) 3.13 } else { 3.14 fake_ioapic_page: 3.15 ioapic_phys = __pa(alloc_xenheap_page()); 3.16 - memset(__va(ioapic_phys), 0, PAGE_SIZE); 3.17 + clear_page(__va(ioapic_phys)); 3.18 } 3.19 set_fixmap_nocache(idx, ioapic_phys); 3.20 apic_printk(APIC_VERBOSE, "mapped IOAPIC to %08lx (%08lx)\n",
4.1 --- a/xen/arch/x86/domain.c Wed Jun 20 15:29:53 2007 +0100 4.2 +++ b/xen/arch/x86/domain.c Wed Jun 20 15:33:14 2007 +0100 4.3 @@ -476,7 +476,7 @@ int arch_domain_create(struct domain *d) 4.4 if ( (d->shared_info = alloc_xenheap_page()) == NULL ) 4.5 goto fail; 4.6 4.7 - memset(d->shared_info, 0, PAGE_SIZE); 4.8 + clear_page(d->shared_info); 4.9 share_xen_page_with_guest( 4.10 virt_to_page(d->shared_info), d, XENSHARE_writable); 4.11 }
5.1 --- a/xen/arch/x86/domain_build.c Wed Jun 20 15:29:53 2007 +0100 5.2 +++ b/xen/arch/x86/domain_build.c Wed Jun 20 15:33:14 2007 +0100 5.3 @@ -505,7 +505,7 @@ int __init construct_dom0( 5.4 v->arch.guest_table = pagetable_from_paddr((unsigned long)l3start); 5.5 #else 5.6 l2start = l2tab = (l2_pgentry_t *)mpt_alloc; mpt_alloc += PAGE_SIZE; 5.7 - memcpy(l2tab, idle_pg_table, PAGE_SIZE); 5.8 + copy_page(l2tab, idle_pg_table); 5.9 l2tab[LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT] = 5.10 l2e_from_paddr((unsigned long)l2start, __PAGE_HYPERVISOR); 5.11 v->arch.guest_table = pagetable_from_paddr((unsigned long)l2start); 5.12 @@ -645,7 +645,7 @@ int __init construct_dom0( 5.13 panic("Not enough RAM for domain 0 PML4.\n"); 5.14 l4start = l4tab = page_to_virt(page); 5.15 } 5.16 - memcpy(l4tab, idle_pg_table, PAGE_SIZE); 5.17 + copy_page(l4tab, idle_pg_table); 5.18 l4tab[l4_table_offset(LINEAR_PT_VIRT_START)] = 5.19 l4e_from_paddr(__pa(l4start), __PAGE_HYPERVISOR); 5.20 l4tab[l4_table_offset(PERDOMAIN_VIRT_START)] = 5.21 @@ -823,7 +823,7 @@ int __init construct_dom0( 5.22 5.23 /* Set up start info area. */ 5.24 si = (start_info_t *)vstartinfo_start; 5.25 - memset(si, 0, PAGE_SIZE); 5.26 + clear_page(si); 5.27 si->nr_pages = nr_pages; 5.28 5.29 si->shared_info = virt_to_maddr(d->shared_info);
6.1 --- a/xen/arch/x86/hvm/svm/svm.c Wed Jun 20 15:29:53 2007 +0100 6.2 +++ b/xen/arch/x86/hvm/svm/svm.c Wed Jun 20 15:33:14 2007 +0100 6.3 @@ -766,8 +766,6 @@ static void svm_init_hypercall_page(stru 6.4 char *p; 6.5 int i; 6.6 6.7 - memset(hypercall_page, 0, PAGE_SIZE); 6.8 - 6.9 for ( i = 0; i < (PAGE_SIZE / 32); i++ ) 6.10 { 6.11 p = (char *)(hypercall_page + (i * 32));
7.1 --- a/xen/arch/x86/hvm/svm/vmcb.c Wed Jun 20 15:29:53 2007 +0100 7.2 +++ b/xen/arch/x86/hvm/svm/vmcb.c Wed Jun 20 15:33:14 2007 +0100 7.3 @@ -56,7 +56,7 @@ struct vmcb_struct *alloc_vmcb(void) 7.4 return NULL; 7.5 } 7.6 7.7 - memset(vmcb, 0, PAGE_SIZE); 7.8 + clear_page(vmcb); 7.9 return vmcb; 7.10 } 7.11 7.12 @@ -72,11 +72,11 @@ struct host_save_area *alloc_host_save_a 7.13 hsa = alloc_xenheap_page(); 7.14 if ( hsa == NULL ) 7.15 { 7.16 - printk(XENLOG_WARNING "Warning: failed to allocate vmcb.\n"); 7.17 + printk(XENLOG_WARNING "Warning: failed to allocate hsa.\n"); 7.18 return NULL; 7.19 } 7.20 7.21 - memset(hsa, 0, PAGE_SIZE); 7.22 + clear_page(hsa); 7.23 return hsa; 7.24 } 7.25
8.1 --- a/xen/arch/x86/hvm/vlapic.c Wed Jun 20 15:29:53 2007 +0100 8.2 +++ b/xen/arch/x86/hvm/vlapic.c Wed Jun 20 15:33:14 2007 +0100 8.3 @@ -934,7 +934,7 @@ int vlapic_init(struct vcpu *v) 8.4 return -ENOMEM; 8.5 } 8.6 8.7 - memset(vlapic->regs, 0, PAGE_SIZE); 8.8 + clear_page(vlapic->regs); 8.9 8.10 vlapic_reset(vlapic); 8.11
9.1 --- a/xen/arch/x86/hvm/vmx/vmcs.c Wed Jun 20 15:29:53 2007 +0100 9.2 +++ b/xen/arch/x86/hvm/vmx/vmcs.c Wed Jun 20 15:33:14 2007 +0100 9.3 @@ -158,7 +158,7 @@ static struct vmcs_struct *vmx_alloc_vmc 9.4 return NULL; 9.5 } 9.6 9.7 - memset(vmcs, 0, PAGE_SIZE); 9.8 + clear_page(vmcs); 9.9 vmcs->vmcs_revision_id = vmcs_revision_id; 9.10 9.11 return vmcs;
10.1 --- a/xen/arch/x86/hvm/vmx/vmx.c Wed Jun 20 15:29:53 2007 +0100 10.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c Wed Jun 20 15:33:14 2007 +0100 10.3 @@ -1070,8 +1070,6 @@ static void vmx_init_hypercall_page(stru 10.4 char *p; 10.5 int i; 10.6 10.7 - memset(hypercall_page, 0, PAGE_SIZE); 10.8 - 10.9 for ( i = 0; i < (PAGE_SIZE / 32); i++ ) 10.10 { 10.11 p = (char *)(hypercall_page + (i * 32));
11.1 --- a/xen/arch/x86/x86_32/traps.c Wed Jun 20 15:29:53 2007 +0100 11.2 +++ b/xen/arch/x86/x86_32/traps.c Wed Jun 20 15:33:14 2007 +0100 11.3 @@ -513,6 +513,7 @@ static void hypercall_page_initialise_ri 11.4 11.5 void hypercall_page_initialise(struct domain *d, void *hypercall_page) 11.6 { 11.7 + memset(hypercall_page, 0xCC, PAGE_SIZE); 11.8 if ( is_hvm_domain(d) ) 11.9 hvm_hypercall_page_initialise(d, hypercall_page); 11.10 else if ( supervisor_mode_kernel )
12.1 --- a/xen/arch/x86/x86_64/traps.c Wed Jun 20 15:29:53 2007 +0100 12.2 +++ b/xen/arch/x86/x86_64/traps.c Wed Jun 20 15:33:14 2007 +0100 12.3 @@ -510,6 +510,7 @@ static void hypercall_page_initialise_ri 12.4 12.5 void hypercall_page_initialise(struct domain *d, void *hypercall_page) 12.6 { 12.7 + memset(hypercall_page, 0xCC, PAGE_SIZE); 12.8 if ( is_hvm_domain(d) ) 12.9 hvm_hypercall_page_initialise(d, hypercall_page); 12.10 else if ( !is_pv_32bit_domain(d) )
13.1 --- a/xen/common/grant_table.c Wed Jun 20 15:29:53 2007 +0100 13.2 +++ b/xen/common/grant_table.c Wed Jun 20 15:33:14 2007 +0100 13.3 @@ -148,7 +148,7 @@ get_maptrack_handle( 13.4 return -1; 13.5 } 13.6 13.7 - memset(new_mt, 0, PAGE_SIZE); 13.8 + clear_page(new_mt); 13.9 13.10 new_mt_limit = lgt->maptrack_limit + MAPTRACK_PER_PAGE; 13.11 13.12 @@ -624,7 +624,7 @@ gnttab_grow_table(struct domain *d, unsi 13.13 { 13.14 if ( (gt->active[i] = alloc_xenheap_page()) == NULL ) 13.15 goto active_alloc_failed; 13.16 - memset(gt->active[i], 0, PAGE_SIZE); 13.17 + clear_page(gt->active[i]); 13.18 } 13.19 13.20 /* Shared */ 13.21 @@ -632,7 +632,7 @@ gnttab_grow_table(struct domain *d, unsi 13.22 { 13.23 if ( (gt->shared[i] = alloc_xenheap_page()) == NULL ) 13.24 goto shared_alloc_failed; 13.25 - memset(gt->shared[i], 0, PAGE_SIZE); 13.26 + clear_page(gt->shared[i]); 13.27 } 13.28 13.29 /* Share the new shared frames with the recipient domain */ 13.30 @@ -1365,7 +1365,7 @@ grant_table_create( 13.31 { 13.32 if ( (t->active[i] = alloc_xenheap_page()) == NULL ) 13.33 goto no_mem_2; 13.34 - memset(t->active[i], 0, PAGE_SIZE); 13.35 + clear_page(t->active[i]); 13.36 } 13.37 13.38 /* Tracking of mapped foreign frames table */ 13.39 @@ -1375,7 +1375,7 @@ grant_table_create( 13.40 memset(t->maptrack, 0, max_nr_maptrack_frames() * sizeof(t->maptrack[0])); 13.41 if ( (t->maptrack[0] = alloc_xenheap_page()) == NULL ) 13.42 goto no_mem_3; 13.43 - memset(t->maptrack[0], 0, PAGE_SIZE); 13.44 + clear_page(t->maptrack[0]); 13.45 t->maptrack_limit = PAGE_SIZE / sizeof(struct grant_mapping); 13.46 for ( i = 0; i < t->maptrack_limit; i++ ) 13.47 t->maptrack[0][i].ref = i+1; 13.48 @@ -1389,7 +1389,7 @@ grant_table_create( 13.49 { 13.50 if ( (t->shared[i] = alloc_xenheap_page()) == NULL ) 13.51 goto no_mem_4; 13.52 - memset(t->shared[i], 0, PAGE_SIZE); 13.53 + clear_page(t->shared[i]); 13.54 } 13.55 13.56 for ( i = 0; i < INITIAL_NR_GRANT_FRAMES; i++ )