Re: [PATCH 26/27] Enable 32bit dirty log pointers on 64bit host

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 29.09.2009, at 15:25, Avi Kivity wrote:

On 09/29/2009 11:17 AM, Alexander Graf wrote:

On 29.09.2009, at 11:14, Avi Kivity wrote:

On 09/29/2009 10:18 AM, Alexander Graf wrote:
With big endian userspace, we can't quite figure out if a pointer
is 32 bit (shifted>> 32) or 64 bit when we read a 64 bit pointer.

This is what happens with dirty logging. To get the pointer interpreted
correctly, I just make it bounce twice, but admittedly that is not
ideal.

I'm open for suggestions here.



How about adding a new union member to struct kvm_dirty_log:

__u64 dirty_bitmap_virt;

And modifying userspace to write to that one?


Yes - old userspace will still build and work (we don't remove the old field) on little endian or BE32, new userspace will work on all flavours. We need new userspace anyway to take advantage of dirty logging.

How about this one? (broken whitespace!)

From c3864a2c5e1fccff7839e47f12c09d9739ca441e Mon Sep 17 00:00:00 2001
From: Alexander Graf <agraf@xxxxxxx>
Date: Thu, 23 Jul 2009 21:05:57 +0200
Subject: [PATCH] Enable 32bit dirty log pointers on 64bit host

With big endian userspace, passing a pointer from 32-bit userspace to
64-bit kernel space breaks.

This is what happens with dirty logging. To get the pointer interpreted
correctly, we can just check the guest's 32bit flag and treat the pointer
as 32 bits then.

Signed-off-by: Alexander Graf <agraf@xxxxxxx>

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index e27b7a9..00f2c59 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -703,6 +703,7 @@ int kvm_get_dirty_log(struct kvm *kvm,
        int r, i;
        int n;
        unsigned long any = 0;
+       void *target_bm;

        r = -EINVAL;
        if (log->slot >= KVM_MEMORY_SLOTS)
@@ -718,8 +719,15 @@ int kvm_get_dirty_log(struct kvm *kvm,
        for (i = 0; !any && i < n/sizeof(long); ++i)
                any = memslot->dirty_bitmap[i];

+#if defined(__BIG_ENDIAN) && defined(CONFIG_64BIT)
+       /* Need to convert user pointers */
+       if (test_thread_flag(TIF_32BIT))
+               target_bm = (void*)((u64)log->dirty_bitmap >> 32);
+       else
+#endif
+       target_bm = log->dirty_bitmap;
        r = -EFAULT;
-       if (copy_to_user(log->dirty_bitmap, memslot->dirty_bitmap, n))
+       if (copy_to_user(target_bm, memslot->dirty_bitmap, n))
                goto out;

        if (any)
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM Development]     [KVM ARM]     [KVM ia64]     [Linux Virtualization]     [Linux USB Devel]     [Linux Video]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux