Kernel KVM-PPC virtualization development
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 26/27] Enable 32bit dirty log pointers on 64bit host
Date: Tue, 29 Sep 2009 16:42:34 +0000	[thread overview]
Message-ID: <4AC238FA.9020804@redhat.com> (raw)
In-Reply-To: <1254212303-8737-27-git-send-email-agraf@suse.de>

On 09/29/2009 06:29 PM, Alexander Graf wrote:
>
> How about this one? (broken whitespace!)
>
> From c3864a2c5e1fccff7839e47f12c09d9739ca441e Mon Sep 17 00:00:00 2001
> From: Alexander Graf <agraf@suse.de>
> 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@suse.de>
>
> 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;

void __user *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)

Ah, that's much better.  Plus a mental note not to put pointers in 
user-visible structures in the future.  This can serve as a reminder :)

-- 
error compiling committee.c: too many arguments to function


  parent reply	other threads:[~2009-09-29 16:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-29  8:18 [PATCH 26/27] Enable 32bit dirty log pointers on 64bit host Alexander Graf
2009-09-29  9:14 ` Avi Kivity
2009-09-29  9:17 ` Alexander Graf
2009-09-29 13:25 ` Avi Kivity
2009-09-29 14:08 ` Alexander Graf
2009-09-29 16:29 ` Alexander Graf
2009-09-29 16:42 ` Avi Kivity [this message]
2009-09-29 17:09 ` Alexander Graf
2009-09-30 12:04 ` Arnd Bergmann
2009-09-30 13:17 ` Avi Kivity
2009-09-30 13:29 ` Avi Kivity
2009-10-20 10:09 ` Alexander Graf
2009-10-20 13:23 ` Avi Kivity
2009-10-20 13:28 ` Alexander Graf
2009-10-20 13:32 ` Avi Kivity

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=4AC238FA.9020804@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm-ppc@vger.kernel.org \
    /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