From patchwork Sat Apr 17 09:28:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 93298 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 o3H9Sk7T008498 for ; Sat, 17 Apr 2010 09:28:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755676Ab0DQJ2X (ORCPT ); Sat, 17 Apr 2010 05:28:23 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:59379 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1755550Ab0DQJ2W (ORCPT ); Sat, 17 Apr 2010 05:28:22 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id DA5E217008D; Sat, 17 Apr 2010 17:28:20 +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 o3H9Qfha016234; Sat, 17 Apr 2010 17:26:41 +0800 Received: from [10.167.141.204] (unknown [10.167.141.204]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 22998DC2A3; Sat, 17 Apr 2010 17:31:13 +0800 (CST) Message-ID: <4BC97F3A.2030003@cn.fujitsu.com> Date: Sat, 17 Apr 2010 17:28:26 +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 2/2] kvm: set new alias directly when old one is not valid 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:28:46 +0000 (UTC) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index db8d7fe..6120e33 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2474,6 +2474,9 @@ static int kvm_vm_ioctl_set_memory_alias(struct kvm *kvm, /* invalidate any gfn reference in case of deletion/shrinking */ memcpy(aliases, kvm->arch.aliases, sizeof(struct kvm_mem_aliases)); + if (!aliases->aliases[alias->slot].npages) + goto set_new_alias; + aliases->aliases[alias->slot].flags |= KVM_ALIAS_INVALID; old_aliases = kvm->arch.aliases; rcu_assign_pointer(kvm->arch.aliases, aliases); @@ -2481,6 +2484,8 @@ static int kvm_vm_ioctl_set_memory_alias(struct kvm *kvm, kvm_mmu_zap_all(kvm); aliases = old_aliases; + +set_new_alias: p = &aliases->aliases[alias->slot]; p->base_gfn = alias->guest_phys_addr >> PAGE_SHIFT; p->npages = alias->memory_size >> PAGE_SHIFT;