public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Izik Eidus <ieidus@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] RFC: alias rework
Date: Mon, 25 Jan 2010 21:57:43 +0200	[thread overview]
Message-ID: <20100125215743.6442b1e4@redhat.com> (raw)
In-Reply-To: <20100125194553.GB20572@amt.cnet>

On Mon, 25 Jan 2010 17:45:53 -0200
Marcelo Tosatti <mtosatti@redhat.com> wrote:

> Izik,
> 
> On Mon, Jan 25, 2010 at 03:53:44PM +0200, Izik Eidus wrote:
> > >From f94dcd1ccabbcdb51ed7c37c5f58f00a5c1b7eec Mon Sep 17 00:00:00 2001
> > From: Izik Eidus <ieidus@redhat.com>
> > Date: Mon, 25 Jan 2010 15:49:41 +0200
> > Subject: [PATCH] RFC: alias rework
> > 
> > This patch remove the old way of aliasing inside kvm
> > and move into using aliasing with the same virtual addresses
> > 
> > This patch is really just early RFC just to know if you guys
> > like this direction, and I need to clean some parts of it
> > and test it more before I feel it ready to be merged...
> > 
> > Comments are more than welcome.
> > 
> > Thanks.
> > 
> > Signed-off-by: Izik Eidus <ieidus@redhat.com>
> > ---
> >  arch/ia64/include/asm/kvm_host.h |    1 +
> >  arch/ia64/kvm/kvm-ia64.c         |    5 --
> >  arch/powerpc/kvm/powerpc.c       |    5 --
> >  arch/s390/include/asm/kvm_host.h |    1 +
> >  arch/s390/kvm/kvm-s390.c         |    5 --
> >  arch/x86/include/asm/kvm_host.h  |   19 ------
> >  arch/x86/include/asm/vmx.h       |    6 +-
> >  arch/x86/kvm/mmu.c               |   19 ++-----
> >  arch/x86/kvm/x86.c               |  114 +++++++++++--------------------------
> >  include/linux/kvm_host.h         |   11 +--
> >  virt/kvm/kvm_main.c              |   80 +++++++++++++++++++-------
> >  11 files changed, 107 insertions(+), 159 deletions(-)
> > 
> 
> > @@ -2661,7 +2611,18 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
> >  		struct kvm_memslots *slots, *old_slots;
> >  
> >  		spin_lock(&kvm->mmu_lock);
> > +		for (i = KVM_MEMORY_SLOTS; i < KVM_MEMORY_SLOTS +
> > +		      KVM_ALIAS_SLOTS; ++i) {
> 
> The plan is to kill KVM_ALIAS_SLOTS (aliases will share the 32 mem
> slots), right?

Hrmm I think we got to have this addition 4 KVM_MEMORY_SLOTS to keep
the same beahivor with old userspaces
beacuse maybe some userspace apps use 32 slots already?

I dont mind remove it if you guys don`t think this is the case.

> 
> > +#ifdef CONFIG_X86
> > +
> > +static void update_alias_slots(struct kvm *kvm, struct kvm_memory_slot *slot)
> > +{
> > +	int i;
> > +
> > +	for (i = KVM_MEMORY_SLOTS; i < KVM_MEMORY_SLOTS + KVM_ALIAS_SLOTS;
> > +	     ++i) {
> > +		struct kvm_memory_slot *alias_memslot =
> > +						&kvm->memslots->memslots[i];
> > +		unsigned long size = slot->npages << PAGE_SHIFT;
> > +
> > +		if (alias_memslot->real_base_gfn >= slot->base_gfn &&
> > +		    alias_memslot->real_base_gfn < slot->base_gfn + size) {
> > +			if (slot->dirty_bitmap) {
> > +				unsigned long bitmap_addr;
> > +				unsigned long dirty_offset;
> > +				unsigned long offset_addr =
> > +						(alias_memslot->real_base_gfn -
> > +	    					slot->base_gfn) << PAGE_SHIFT;
> > +				alias_memslot->userspace_addr = 
> > +					slot->userspace_addr + offset_addr;
> > +
> > +				dirty_offset =
> > +					ALIGN(offset_addr, BITS_PER_LONG) / 8;
> > +				bitmap_addr = (unsigned long) slot->dirty_bitmap;
> > +				bitmap_addr += dirty_offset;
> > +				alias_memslot->dirty_bitmap = (unsigned long *)bitmap_addr;
> > +				alias_memslot->base_gfn = alias_memslot->real_base_gfn;
> > +				alias_memslot->npages = alias_memslot->real_npages;
> > +			} else if (!slot->rmap) {
> > +				alias_memslot->base_gfn = 0;
> > +				alias_memslot->npages = 0;
> > +			}
> > +		}
> > +	}
> > +}
> > +
> > +#endif
> 
> Can't see why is this needed. What is the problem with nuking "child"
> aliases when deleting a real memslot?

The problem is that this memslot still point in the virtual address of the host,
This mean that gfn_to_memslot/page will still work on gfns and will result in
pages that are mapped into the virtual address that the userspace requested to
remove from KVM.

Thanks.


  reply	other threads:[~2010-01-25 19:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-25 13:53 [PATCH] RFC: alias rework Izik Eidus
2010-01-25 19:45 ` Marcelo Tosatti
2010-01-25 19:57   ` Izik Eidus [this message]
2010-01-25 20:20     ` Marcelo Tosatti
2010-01-25 20:40       ` Izik Eidus
2010-01-25 20:49         ` Marcelo Tosatti
2010-01-25 21:51           ` Izik Eidus
2010-01-26 14:14         ` Avi Kivity
2010-01-26 14:29           ` Izik Eidus

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=20100125215743.6442b1e4@redhat.com \
    --to=ieidus@redhat.com \
    --cc=kvm@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