lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <4BC97D62.2090908@cn.fujitsu.com>
Date:	Sat, 17 Apr 2010 17:20:34 +0800
From:	Lai Jiangshan <laijs@...fujitsu.com>
To:	Avi Kivity <avi@...hat.com>, Marcelo Tosatti <mtosatti@...hat.com>,
	LKML <linux-kernel@...r.kernel.org>, kvm@...r.kernel.org
Subject: [PATCH 1/2] kvm: simplify kvm_vm_ioctl_set_memory_alias


It's just time waste if we free a object and allocate it immediately.

Signed-off-by: Lai Jiangshan <laijs@...fujitsu.com>
---
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 24cd0ee..db8d7fe 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2479,15 +2479,8 @@ static int kvm_vm_ioctl_set_memory_alias(struct kvm *kvm,
 	rcu_assign_pointer(kvm->arch.aliases, aliases);
 	synchronize_srcu_expedited(&kvm->srcu);
 	kvm_mmu_zap_all(kvm);
-	kfree(old_aliases);
-
-	r = -ENOMEM;
-	aliases = kzalloc(sizeof(struct kvm_mem_aliases), GFP_KERNEL);
-	if (!aliases)
-		goto out_unlock;
-
-	memcpy(aliases, kvm->arch.aliases, sizeof(struct kvm_mem_aliases));
 
+	aliases = old_aliases;
 	p = &aliases->aliases[alias->slot];
 	p->base_gfn = alias->guest_phys_addr >> PAGE_SHIFT;
 	p->npages = alias->memory_size >> PAGE_SHIFT;
@@ -2505,7 +2498,6 @@ static int kvm_vm_ioctl_set_memory_alias(struct kvm *kvm,
 	kfree(old_aliases);
 	r = 0;
 
-out_unlock:
 	mutex_unlock(&kvm->slots_lock);
 out:
 	return r;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ