public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Wei Yongjun <yjwei@cn.fujitsu.com>
To: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Cc: avi@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org
Subject: [PATCH] KVM: fix to not use NULL kvm->coalesced_mmio_ring in kvm_vcpu_fault()
Date: Fri, 12 Mar 2010 11:43:04 +0800	[thread overview]
Message-ID: <4B99B848.6000006@cn.fujitsu.com> (raw)
In-Reply-To: <20100312120523.1b147c58.yoshikawa.takuya@oss.ntt.co.jp>

If coalesced_mmio init fail, the kvm->coalesced_mmio_ring will be set
to NULL. If so, we should return VM_FAULT_SIGBUS in kvm_vcpu_fault()
even if vmf->pgoff == KVM_COALESCED_MMIO_PAGE_OFFSET.

Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
---
 virt/kvm/kvm_main.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index e758ef7..0e06a6d 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1253,7 +1253,8 @@ static int kvm_vcpu_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 		page = virt_to_page(vcpu->arch.pio_data);
 #endif
 #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
-	else if (vmf->pgoff == KVM_COALESCED_MMIO_PAGE_OFFSET)
+	else if (vmf->pgoff == KVM_COALESCED_MMIO_PAGE_OFFSET &&
+		 vcpu->kvm->coalesced_mmio_ring)
 		page = virt_to_page(vcpu->kvm->coalesced_mmio_ring);
 #endif
 	else
-- 
1.6.3.3



  parent reply	other threads:[~2010-03-12  3:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-12  3:05 [PATCH] KVM: coalesced_mmio: NULLify the pointers before freeing ring page and dev Takuya Yoshikawa
2010-03-12  3:41 ` Wei Yongjun
2010-03-12  4:15   ` Takuya Yoshikawa
2010-03-12  3:43 ` Wei Yongjun [this message]
2010-03-12  4:22   ` [PATCH] KVM: fix to not use NULL kvm->coalesced_mmio_ring in kvm_vcpu_fault() Takuya Yoshikawa
2010-03-12  7:52 ` [PATCH -v2] KVM: fix kvm_coalesced_mmio_init()'s error handling Takuya Yoshikawa
2010-03-12  7:56   ` Wei Yongjun
2010-03-12  8:00     ` Takuya Yoshikawa
2010-03-12  9:57 ` [PATCH -v3 1/2] KVM: introduce kvm_uninit_mmu_notifier() Takuya Yoshikawa
2010-03-12 10:12   ` Takuya Yoshikawa

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=4B99B848.6000006@cn.fujitsu.com \
    --to=yjwei@cn.fujitsu.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=yoshikawa.takuya@oss.ntt.co.jp \
    /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