This allows us to remove a bunch of memsets. Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx> --- lib/alloc.c | 1 + lib/x86/vm.c | 2 -- x86/vmx.c | 6 ------ x86/vmx_tests.c | 9 --------- 4 files changed, 1 insertion(+), 17 deletions(-) diff --git a/lib/alloc.c b/lib/alloc.c index 7687c703f40b..15c96e4ee8a3 100644 --- a/lib/alloc.c +++ b/lib/alloc.c @@ -160,6 +160,7 @@ void *alloc_page(void) p = free_head; free_head = *(void **)free_head; + memset(p, 0, PAGE_SIZE); return p; } diff --git a/lib/x86/vm.c b/lib/x86/vm.c index bba8ccee7dd0..0882e0a478ca 100644 --- a/lib/x86/vm.c +++ b/lib/x86/vm.c @@ -91,8 +91,6 @@ static void setup_mmu(unsigned long len) { unsigned long *cr3 = alloc_page(); - memset(cr3, 0, PAGE_SIZE); - #ifdef __x86_64__ if (len < (1ul << 32)) len = (1ul << 32); /* map mmio 1:1 */ diff --git a/x86/vmx.c b/x86/vmx.c index 411ed3211d4d..65c8583a18db 100644 --- a/x86/vmx.c +++ b/x86/vmx.c @@ -278,7 +278,6 @@ static void split_large_ept_entry(unsigned long *ptep, int level) new_pt = alloc_page(); assert(new_pt); - memset(new_pt, 0, PAGE_SIZE); prototype = pte & ~EPT_ADDR_MASK; if (level == 2) @@ -618,7 +617,6 @@ static void init_vmcs_guest(void) static int init_vmcs(struct vmcs **vmcs) { *vmcs = alloc_page(); - memset(*vmcs, 0, PAGE_SIZE); (*vmcs)->revision_id = basic.revision; /* vmclear first to init vmcs */ if (vmcs_clear(*vmcs)) { @@ -657,7 +655,6 @@ static void init_vmx(void) ulong fix_cr4_set, fix_cr4_clr; vmxon_region = alloc_page(); - memset(vmxon_region, 0, PAGE_SIZE); fix_cr0_set = rdmsr(MSR_IA32_VMX_CR0_FIXED0); fix_cr0_clr = rdmsr(MSR_IA32_VMX_CR0_FIXED1); @@ -687,9 +684,7 @@ static void init_vmx(void) *vmxon_region = basic.revision; guest_stack = alloc_page(); - memset(guest_stack, 0, PAGE_SIZE); guest_syscall_stack = alloc_page(); - memset(guest_syscall_stack, 0, PAGE_SIZE); } static void do_vmxon_off(void *data) @@ -812,7 +807,6 @@ static void test_vmptrst(void) struct vmcs *vmcs1, *vmcs2; vmcs1 = alloc_page(); - memset(vmcs1, 0, PAGE_SIZE); init_vmcs(&vmcs1); ret = vmcs_save(&vmcs2); report("test vmptrst", (!ret) && (vmcs1 == vmcs2)); diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 58736d789bd5..681204238ed9 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -224,7 +224,6 @@ void msr_bmp_init() u32 ctrl_cpu0; msr_bitmap = alloc_page(); - memset(msr_bitmap, 0x0, PAGE_SIZE); ctrl_cpu0 = vmcs_read(CPU_EXEC_CTRL0); ctrl_cpu0 |= CPU_MSR_BITMAP; vmcs_write(CPU_EXEC_CTRL0, ctrl_cpu0); @@ -567,8 +566,6 @@ static int iobmp_init() io_bitmap_a = alloc_page(); io_bitmap_b = alloc_page(); - memset(io_bitmap_a, 0x0, PAGE_SIZE); - memset(io_bitmap_b, 0x0, PAGE_SIZE); ctrl_cpu0 = vmcs_read(CPU_EXEC_CTRL0); ctrl_cpu0 |= CPU_IO_BITMAP; ctrl_cpu0 &= (~CPU_IO); @@ -938,7 +935,6 @@ static int setup_ept() } eptp |= (3 << EPTP_PG_WALK_LEN_SHIFT); pml4 = alloc_page(); - memset(pml4, 0, PAGE_SIZE); eptp |= virt_to_phys(pml4); vmcs_write(EPTP, eptp); support_2m = !!(ept_vpid.val & EPT_CAP_2M_PAGE); @@ -974,8 +970,6 @@ static int ept_init() return VMX_TEST_EXIT; data_page1 = alloc_page(); data_page2 = alloc_page(); - memset(data_page1, 0x0, PAGE_SIZE); - memset(data_page2, 0x0, PAGE_SIZE); *((u32 *)data_page1) = MAGIC_VAL_1; *((u32 *)data_page2) = MAGIC_VAL_2; install_ept(pml4, (unsigned long)data_page1, (unsigned long)data_page2, @@ -1541,9 +1535,6 @@ static int msr_switch_init(struct vmcs *vmcs) exit_msr_store = alloc_page(); exit_msr_load = alloc_page(); entry_msr_load = alloc_page(); - memset(exit_msr_store, 0, PAGE_SIZE); - memset(exit_msr_load, 0, PAGE_SIZE); - memset(entry_msr_load, 0, PAGE_SIZE); entry_msr_load[0].index = MSR_KERNEL_GS_BASE; entry_msr_load[0].value = MSR_MAGIC; -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html