diff mbox

KVM: mips: use id_to_memslot correctly

Message ID 1431936859-19955-1-git-send-email-pbonzini@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Paolo Bonzini May 18, 2015, 8:14 a.m. UTC
The argument to KVM_GET_DIRTY_LOG is a memslot id; it may not
match the position in the memslots array, which is sorted by
gfn.

Cc: stable@vger.kernel.org
Cc: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/mips/kvm/mips.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Hogan May 18, 2015, 10:15 a.m. UTC | #1
Hi Paolo,

On 18/05/15 09:14, Paolo Bonzini wrote:
> The argument to KVM_GET_DIRTY_LOG is a memslot id; it may not
> match the position in the memslots array, which is sorted by
> gfn.
> 
> Cc: stable@vger.kernel.org
> Cc: James Hogan <james.hogan@imgtec.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: James Hogan <james.hogan@imgtec.com>

(I have the same patch in my pile).

Thanks
James

> ---
>  arch/mips/kvm/mips.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
> index bb68e8d520e8..52f205ae1281 100644
> --- a/arch/mips/kvm/mips.c
> +++ b/arch/mips/kvm/mips.c
> @@ -982,7 +982,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log)
>  
>  	/* If nothing is dirty, don't bother messing with page tables. */
>  	if (is_dirty) {
> -		memslot = &kvm->memslots->memslots[log->slot];
> +		memslot = id_to_memslot(kvm->memslots, log->slot);
>  
>  		ga = memslot->base_gfn << PAGE_SHIFT;
>  		ga_end = ga + (memslot->npages << PAGE_SHIFT);
>
diff mbox

Patch

diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index bb68e8d520e8..52f205ae1281 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -982,7 +982,7 @@  int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log)
 
 	/* If nothing is dirty, don't bother messing with page tables. */
 	if (is_dirty) {
-		memslot = &kvm->memslots->memslots[log->slot];
+		memslot = id_to_memslot(kvm->memslots, log->slot);
 
 		ga = memslot->base_gfn << PAGE_SHIFT;
 		ga_end = ga + (memslot->npages << PAGE_SHIFT);