From patchwork Sat Apr 17 09:20:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 93296 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3H9KxaM006831 for ; Sat, 17 Apr 2010 09:21:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755588Ab0DQJUd (ORCPT ); Sat, 17 Apr 2010 05:20:33 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:49535 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1755465Ab0DQJUd (ORCPT ); Sat, 17 Apr 2010 05:20:33 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 74AC817008D; Sat, 17 Apr 2010 17:20:27 +0800 (CST) Received: from fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id o3H9IoWO012762; Sat, 17 Apr 2010 17:18:50 +0800 Received: from [10.167.141.204] (unknown [10.167.141.204]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 7EB4EDC2A3; Sat, 17 Apr 2010 17:23:21 +0800 (CST) Message-ID: <4BC97D62.2090908@cn.fujitsu.com> Date: Sat, 17 Apr 2010 17:20:34 +0800 From: Lai Jiangshan User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Avi Kivity , Marcelo Tosatti , LKML , kvm@vger.kernel.org Subject: [PATCH 1/2] kvm: simplify kvm_vm_ioctl_set_memory_alias Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 17 Apr 2010 09:21:30 +0000 (UTC) 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;