From: Carsten Otte <cotte-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
To: Andrea Arcangeli <andrea-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: swapping with MMU Notifiers V2
Date: Tue, 29 Jan 2008 17:14:14 +0100 [thread overview]
Message-ID: <479F50D6.4020005@de.ibm.com> (raw)
In-Reply-To: <20080129145021.GJ7233-lysg2Xt5kKMAvxtiuMwx3w@public.gmane.org>
Andrea Arcangeli wrote:
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index ea4764b..9349160 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -15,6 +15,7 @@
> #include <linux/sched.h>
> #include <linux/mm.h>
> #include <linux/preempt.h>
> +#include <linux/mmu_notifier.h>
> #include <asm/signal.h>
>
> #include <linux/kvm.h>
> @@ -118,6 +119,7 @@ struct kvm {
> struct kvm_io_bus pio_bus;
> struct kvm_vm_stat stat;
> struct kvm_arch arch;
> + struct mmu_notifier mmu_notifier;
> };
>
> /* The guest did something we don't support. */
This should not be in struct kvm, it should go to x86's kvm_arch. This
is x86 specific, we don't need a notifier since the core-vm will just
page out our guest memory like regular userspace mem.
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 8fc12dc..bb4747c 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -165,6 +165,7 @@ static struct kvm *kvm_create_vm(void)
>
> kvm->mm = current->mm;
> atomic_inc(&kvm->mm->mm_count);
> + mmu_notifier_register(&kvm->mmu_notifier, kvm->mm);
> spin_lock_init(&kvm->mmu_lock);
> kvm_io_bus_init(&kvm->pio_bus);
> mutex_init(&kvm->lock);
to kvm_arch_create_vm please
> @@ -1265,7 +1266,11 @@ static int kvm_resume(struct sys_device *dev)
> }
>
> static struct sysdev_class kvm_sysdev_class = {
> +#ifdef set_kset_name
> set_kset_name("kvm"),
> +#else
> + .name = "kvm",
> +#endif
> .suspend = kvm_suspend,
> .resume = kvm_resume,
> };
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 4295623..a67e38f 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -298,7 +299,15 @@ int __kvm_set_memory_region(struct kvm *kvm,
> memset(new.rmap, 0, npages * sizeof(*new.rmap));
>
> new.user_alloc = user_alloc;
> - new.userspace_addr = mem->userspace_addr;
> + /*
> + * hva_to_rmmap() serialzies with the mmu_lock and to be
> + * safe it has to ignore memslots with !user_alloc &&
> + * !userspace_addr.
> + */
> + if (user_alloc)
> + new.userspace_addr = mem->userspace_addr;
> + else
> + new.userspace_addr = 0;
> }
>
> /* Allocate page dirty bitmap if needed */
> @@ -311,14 +320,18 @@ int __kvm_set_memory_region(struct kvm *kvm,
> memset(new.dirty_bitmap, 0, dirty_bytes);
> }
>
> + spin_lock(&kvm->mmu_lock);
> if (mem->slot >= kvm->nmemslots)
> kvm->nmemslots = mem->slot + 1;
>
> *memslot = new;
> + spin_unlock(&kvm->mmu_lock);
>
> r = kvm_arch_set_memory_region(kvm, mem, old, user_alloc);
> if (r) {
> + spin_lock(&kvm->mmu_lock);
> *memslot = old;
> + spin_unlock(&kvm->mmu_lock);
> goto out_free;
> }
>
>
>
This needs to go to arch too.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
next prev parent reply other threads:[~2008-01-29 16:14 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-29 14:50 swapping with MMU Notifiers V2 Andrea Arcangeli
[not found] ` <20080129145021.GJ7233-lysg2Xt5kKMAvxtiuMwx3w@public.gmane.org>
2008-01-29 15:13 ` Izik Eidus
2008-01-29 16:14 ` Carsten Otte [this message]
[not found] ` <479F50D6.4020005-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2008-01-29 16:24 ` Avi Kivity
[not found] ` <479F532C.1020503-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-29 16:31 ` Carsten Otte
2008-01-29 16:35 ` Carsten Otte
[not found] ` <479F55D6.1090807-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2008-01-29 17:02 ` Avi Kivity
[not found] ` <479F5C3C.7070501-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-29 18:13 ` Joerg Roedel
2008-01-29 17:54 ` Andrea Arcangeli
[not found] ` <20080129175420.GR7233-lysg2Xt5kKMAvxtiuMwx3w@public.gmane.org>
2008-01-29 18:05 ` Avi Kivity
[not found] ` <479F6AE0.3080702-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-29 18:34 ` Andrea Arcangeli
2008-01-30 11:26 ` Carsten Otte
[not found] ` <47A05EEF.3010701-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2008-01-30 11:42 ` Andrea Arcangeli
[not found] ` <20080130114206.GG7233-lysg2Xt5kKMAvxtiuMwx3w@public.gmane.org>
2008-01-30 15:01 ` Carsten Otte
[not found] ` <47A09142.4090307-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2008-01-30 15:09 ` Avi Kivity
[not found] ` <47A09342.1040708-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-30 15:14 ` Carsten Otte
2008-01-29 18:19 ` Joerg Roedel
[not found] ` <20080129181918.GA6344-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2008-01-29 18:42 ` Andrea Arcangeli
2008-01-30 9:49 ` Carsten Otte
[not found] ` <47A04816.4090408-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2008-01-30 14:38 ` Joerg Roedel
2008-01-29 16:52 ` Andrea Arcangeli
[not found] ` <20080129165219.GN7233-lysg2Xt5kKMAvxtiuMwx3w@public.gmane.org>
2008-01-29 17:17 ` Carsten Otte
[not found] ` <479F5FBF.40203-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2008-01-29 17:39 ` Andrea Arcangeli
2008-01-29 16:49 ` Andrea Arcangeli
[not found] ` <20080129164954.GM7233-lysg2Xt5kKMAvxtiuMwx3w@public.gmane.org>
2008-01-29 17:04 ` Avi Kivity
[not found] ` <479F5CBB.5060702-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-29 17:49 ` Andrea Arcangeli
[not found] ` <20080129174955.GQ7233-lysg2Xt5kKMAvxtiuMwx3w@public.gmane.org>
2008-01-29 17:53 ` Avi Kivity
2008-01-29 17:17 ` Carsten Otte
2008-01-30 18:57 ` Andrea Arcangeli
[not found] ` <20080130185735.GS7233-lysg2Xt5kKMAvxtiuMwx3w@public.gmane.org>
2008-01-31 6:50 ` Avi Kivity
[not found] ` <47A16F99.8060502-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-31 10:15 ` Andrea Arcangeli
[not found] ` <20080131101519.GG7185-lysg2Xt5kKMAvxtiuMwx3w@public.gmane.org>
2008-01-31 10:34 ` Avi Kivity
[not found] ` <47A1A43D.6020203-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-31 12:58 ` Andrea Arcangeli
[not found] ` <20080131125842.GL7185-lysg2Xt5kKMAvxtiuMwx3w@public.gmane.org>
2008-01-31 18:56 ` Andrea Arcangeli
2008-02-11 8:20 ` Avi Kivity
2008-02-11 11:37 ` Andrea Arcangeli
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=479F50D6.4020005@de.ibm.com \
--to=cotte-ta70fqpds9bqt0dzr+alfa@public.gmane.org \
--cc=andrea-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
--cc=carsteno-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.