From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Avi Kivity <avi@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
LKML <linux-kernel@vger.kernel.org>,
kvm@vger.kernel.org
Subject: [PATCH 2/2] kvm: set new alias directly when old one is not valid
Date: Sat, 17 Apr 2010 17:28:26 +0800 [thread overview]
Message-ID: <4BC97F3A.2030003@cn.fujitsu.com> (raw)
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;
reply other threads:[~2010-04-17 9:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BC97F3A.2030003@cn.fujitsu.com \
--to=laijs@cn.fujitsu.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox