* [PATCH rework] KVM: coalesced_mmio: fix kvm_coalesced_mmio_init()'s error handling
@ 2010-03-15 13:13 Takuya Yoshikawa
2010-03-17 19:08 ` Marcelo Tosatti
0 siblings, 1 reply; 2+ messages in thread
From: Takuya Yoshikawa @ 2010-03-15 13:13 UTC (permalink / raw)
To: avi, mtosatti; +Cc: kvm
kvm_coalesced_mmio_init() keeps to hold the addresses of a coalesced
mmio ring page and dev even after it has freed them.
Also, if this function fails, though it might be rare, it seems to be
suggesting the system's serious state: so we'd better stop the works
following the kvm_creat_vm().
This patch clears these problems.
We move the coalesced mmio's initialization out of kvm_create_vm().
This seems to be natural because it includes a registration which
can be done only when vm is successfully created.
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
---
virt/kvm/coalesced_mmio.c | 2 ++
virt/kvm/kvm_main.c | 12 ++++++++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/virt/kvm/coalesced_mmio.c b/virt/kvm/coalesced_mmio.c
index 5169736..11776b7 100644
--- a/virt/kvm/coalesced_mmio.c
+++ b/virt/kvm/coalesced_mmio.c
@@ -119,8 +119,10 @@ int kvm_coalesced_mmio_init(struct kvm *kvm)
return ret;
out_free_dev:
+ kvm->coalesced_mmio_dev = NULL;
kfree(dev);
out_free_page:
+ kvm->coalesced_mmio_ring = NULL;
__free_page(page);
out_err:
return ret;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index bcd08b8..c7053aa 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -418,9 +418,6 @@ static struct kvm *kvm_create_vm(void)
spin_lock(&kvm_lock);
list_add(&kvm->vm_list, &vm_list);
spin_unlock(&kvm_lock);
-#ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
- kvm_coalesced_mmio_init(kvm);
-#endif
out:
return kvm;
@@ -1748,12 +1745,19 @@ static struct file_operations kvm_vm_fops = {
static int kvm_dev_ioctl_create_vm(void)
{
- int fd;
+ int fd, r;
struct kvm *kvm;
kvm = kvm_create_vm();
if (IS_ERR(kvm))
return PTR_ERR(kvm);
+#ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
+ r = kvm_coalesced_mmio_init(kvm);
+ if (r < 0) {
+ kvm_put_kvm(kvm);
+ return r;
+ }
+#endif
fd = anon_inode_getfd("kvm-vm", &kvm_vm_fops, kvm, O_RDWR);
if (fd < 0)
kvm_put_kvm(kvm);
--
1.6.3.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH rework] KVM: coalesced_mmio: fix kvm_coalesced_mmio_init()'s error handling
2010-03-15 13:13 [PATCH rework] KVM: coalesced_mmio: fix kvm_coalesced_mmio_init()'s error handling Takuya Yoshikawa
@ 2010-03-17 19:08 ` Marcelo Tosatti
0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2010-03-17 19:08 UTC (permalink / raw)
To: Takuya Yoshikawa; +Cc: avi, kvm
On Mon, Mar 15, 2010 at 10:13:30PM +0900, Takuya Yoshikawa wrote:
> kvm_coalesced_mmio_init() keeps to hold the addresses of a coalesced
> mmio ring page and dev even after it has freed them.
>
> Also, if this function fails, though it might be rare, it seems to be
> suggesting the system's serious state: so we'd better stop the works
> following the kvm_creat_vm().
>
> This patch clears these problems.
>
> We move the coalesced mmio's initialization out of kvm_create_vm().
> This seems to be natural because it includes a registration which
> can be done only when vm is successfully created.
>
> Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
> ---
> virt/kvm/coalesced_mmio.c | 2 ++
> virt/kvm/kvm_main.c | 12 ++++++++----
> 2 files changed, 10 insertions(+), 4 deletions(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-03-17 19:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-15 13:13 [PATCH rework] KVM: coalesced_mmio: fix kvm_coalesced_mmio_init()'s error handling Takuya Yoshikawa
2010-03-17 19:08 ` Marcelo Tosatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox