public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] kvm: set new alias directly when old one is not valid
@ 2010-04-17  9:28 Lai Jiangshan
  0 siblings, 0 replies; only message in thread
From: Lai Jiangshan @ 2010-04-17  9:28 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti, LKML, kvm


When old one is not valid, we don't need set the flags
KVM_ALIAS_INVALID. Because no one {will use}/{be using} it.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
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;


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-04-17  9:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-17  9:28 [PATCH 2/2] kvm: set new alias directly when old one is not valid Lai Jiangshan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox