From: Jason Baron <jbaron@redhat.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: mtosatti@redhat.com, gleb@redhat.com,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH 02/10] kvm: Check userspace_addr when modifying a memory slot
Date: Fri, 7 Dec 2012 13:44:01 -0500 [thread overview]
Message-ID: <20121207184400.GC13053@redhat.com> (raw)
In-Reply-To: <1354905128.3224.98.camel@bling.home>
On Fri, Dec 07, 2012 at 11:32:08AM -0700, Alex Williamson wrote:
> On Fri, 2012-12-07 at 13:17 -0500, Jason Baron wrote:
> > On Thu, Dec 06, 2012 at 03:20:37PM -0700, Alex Williamson wrote:
> > > The API documents that only flags and guest physical memory space can
> > > be modified on an existing slot, but we don't enforce that the
> > > userspace address cannot be modified. Instead we just ignore it.
> > > This means that a user may think they've successfully moved both the
> > > guest and user addresses, when in fact only the guest address changed.
> > > Check and error instead.
> > >
> > > Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> > > ---
> > > virt/kvm/kvm_main.c | 8 +++++++-
> > > 1 file changed, 7 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> > > index e426704..93213e1 100644
> > > --- a/virt/kvm/kvm_main.c
> > > +++ b/virt/kvm/kvm_main.c
> > > @@ -779,13 +779,19 @@ int __kvm_set_memory_region(struct kvm *kvm,
> > >
> > > r = -ENOMEM;
> > >
> > > - /* Allocate if a slot is being created */
> > > + /*
> > > + * Allocate if a slot is being created. If modifying a slot,
> > > + * the userspace_addr cannot change.
> > > + */
> > > if (!old.npages) {
> > > new.user_alloc = user_alloc;
> > > new.userspace_addr = mem->userspace_addr;
> > >
> > > if (kvm_arch_create_memslot(&new, npages))
> > > goto out_free;
> > > + } else if (mem->userspace_addr != old.userspace_addr) {
> > > + r = -EINVAL;
> > > + goto out_free;
> > > }
> > >
> > > /* Allocate page dirty bitmap if needed */
> > >
> >
> > hmmm...does this mean that on a 'destroy', where npages is 0, the user
> > has to set up userspace_addr correctly? If so, that would appear to be
> > an unwanted change in semantics here.
>
> Good point, it does change that. We could make this be (npages &&
> mem->userspace_addr != old.userspace_addr) to avoid that case. Thanks,
>
> Alex
>
Yup, that works for me.
Thanks,
-Jason
next prev parent reply other threads:[~2012-12-07 18:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-06 22:20 [PATCH 00/10] kvm: memory slot cleanups, fix, and increase Alex Williamson
2012-12-06 22:20 ` [PATCH 01/10] kvm: Restrict non-existing slot state transitions Alex Williamson
2012-12-06 22:20 ` [PATCH 02/10] kvm: Check userspace_addr when modifying a memory slot Alex Williamson
2012-12-07 18:17 ` Jason Baron
2012-12-07 18:32 ` Alex Williamson
2012-12-07 18:44 ` Jason Baron [this message]
2012-12-06 22:20 ` [PATCH 03/10] kvm: Fix iommu map/unmap to handle memory slot moves Alex Williamson
2012-12-06 22:20 ` [PATCH 04/10] kvm: Minor memory slot optimization Alex Williamson
2012-12-06 22:20 ` [PATCH 05/10] kvm: Rename KVM_MEMORY_SLOTS -> KVM_USER_MEM_SLOTS Alex Williamson
2012-12-06 22:21 ` [PATCH 06/10] kvm: Make KVM_PRIVATE_MEM_SLOTS optional Alex Williamson
2012-12-06 22:21 ` [PATCH 07/10] kvm: struct kvm_memory_slot.user_alloc -> bool Alex Williamson
2012-12-06 22:21 ` [PATCH 08/10] kvm: struct kvm_memory_slot.flags -> u32 Alex Williamson
2012-12-06 22:21 ` [PATCH 09/10] kvm: struct kvm_memory_slot.id -> short Alex Williamson
2012-12-06 22:21 ` [PATCH 10/10] kvm: Increase user memory slots on x86 to 125 Alex Williamson
2012-12-07 14:02 ` Takuya Yoshikawa
2012-12-07 16:09 ` Alex Williamson
2012-12-10 13:48 ` 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=20121207184400.GC13053@redhat.com \
--to=jbaron@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).