[PATCH] KVM: fix to not use NULL kvm-coalesced_mmio_ring in kvm_vcpu_fault()

2010-03-11 Thread Wei Yongjun
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 yj...@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


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] KVM: fix to not use NULL kvm-coalesced_mmio_ring in kvm_vcpu_fault()

2010-03-11 Thread Takuya Yoshikawa

Wei Yongjun wrote:

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 yj...@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


Btw, I am not certain if we can continue the normal path even if
kvm_coalesced_mmio_init() fails.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html