Commit 234bb549 authored by Jan Beulich's avatar Jan Beulich Committed by H. Peter Anvin

x86, cleanups: Use clear_page/copy_page rather than memset/memcpy

When operating on whole pages, use clear_page() and copy_page() in
favor of memset() and memcpy(); after all that's what they are
intended for.
Signed-off-by: default avatarJan Beulich <jbeulich@novell.com>
LKML-Reference: <4C7FB8CA0200007800013F51@vpn.id2.novell.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 0f1cf415
...@@ -36,7 +36,7 @@ static int init_one_level2_page(struct kimage *image, pgd_t *pgd, ...@@ -36,7 +36,7 @@ static int init_one_level2_page(struct kimage *image, pgd_t *pgd,
if (!page) if (!page)
goto out; goto out;
pud = (pud_t *)page_address(page); pud = (pud_t *)page_address(page);
memset(pud, 0, PAGE_SIZE); clear_page(pud);
set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE)); set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE));
} }
pud = pud_offset(pgd, addr); pud = pud_offset(pgd, addr);
...@@ -45,7 +45,7 @@ static int init_one_level2_page(struct kimage *image, pgd_t *pgd, ...@@ -45,7 +45,7 @@ static int init_one_level2_page(struct kimage *image, pgd_t *pgd,
if (!page) if (!page)
goto out; goto out;
pmd = (pmd_t *)page_address(page); pmd = (pmd_t *)page_address(page);
memset(pmd, 0, PAGE_SIZE); clear_page(pmd);
set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE)); set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE));
} }
pmd = pmd_offset(pud, addr); pmd = pmd_offset(pud, addr);
......
...@@ -1056,14 +1056,13 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu) ...@@ -1056,14 +1056,13 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu)
vcpu->arch.apic = apic; vcpu->arch.apic = apic;
apic->regs_page = alloc_page(GFP_KERNEL); apic->regs_page = alloc_page(GFP_KERNEL|__GFP_ZERO);
if (apic->regs_page == NULL) { if (apic->regs_page == NULL) {
printk(KERN_ERR "malloc apic regs error for vcpu %x\n", printk(KERN_ERR "malloc apic regs error for vcpu %x\n",
vcpu->vcpu_id); vcpu->vcpu_id);
goto nomem_free_apic; goto nomem_free_apic;
} }
apic->regs = page_address(apic->regs_page); apic->regs = page_address(apic->regs_page);
memset(apic->regs, 0, PAGE_SIZE);
apic->vcpu = vcpu; apic->vcpu = vcpu;
hrtimer_init(&apic->lapic_timer.timer, CLOCK_MONOTONIC, hrtimer_init(&apic->lapic_timer.timer, CLOCK_MONOTONIC,
......
...@@ -67,7 +67,7 @@ static __init void *alloc_low_page(void) ...@@ -67,7 +67,7 @@ static __init void *alloc_low_page(void)
panic("alloc_low_page: ran out of memory"); panic("alloc_low_page: ran out of memory");
adr = __va(pfn * PAGE_SIZE); adr = __va(pfn * PAGE_SIZE);
memset(adr, 0, PAGE_SIZE); clear_page(adr);
return adr; return adr;
} }
...@@ -558,7 +558,7 @@ char swsusp_pg_dir[PAGE_SIZE] ...@@ -558,7 +558,7 @@ char swsusp_pg_dir[PAGE_SIZE]
static inline void save_pg_dir(void) static inline void save_pg_dir(void)
{ {
memcpy(swsusp_pg_dir, swapper_pg_dir, PAGE_SIZE); copy_page(swsusp_pg_dir, swapper_pg_dir);
} }
#else /* !CONFIG_ACPI_SLEEP */ #else /* !CONFIG_ACPI_SLEEP */
static inline void save_pg_dir(void) static inline void save_pg_dir(void)
......
...@@ -293,7 +293,7 @@ static __ref void *alloc_low_page(unsigned long *phys) ...@@ -293,7 +293,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
panic("alloc_low_page: ran out of memory"); panic("alloc_low_page: ran out of memory");
adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE); adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
memset(adr, 0, PAGE_SIZE); clear_page(adr);
*phys = pfn * PAGE_SIZE; *phys = pfn * PAGE_SIZE;
return adr; return adr;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment