From: Gregory Haskins <ghaskins@novell.com>
To: linux-kernel@vger.kernel.org
Cc: agraf@suse.de, pmullaney@novell.com, pmorreale@novell.com,
anthony@codemonkey.ws, rusty@rustcorp.com.au,
netdev@vger.kernel.org, kvm@vger.kernel.org, avi@redhat.com,
bhutchings@solarflare.com, andi@firstfloor.org, gregkh@suse.de,
herber@gondor.apana.org.au, chrisw@sous-sol.org,
shemminger@vyatta.com
Subject: [RFC PATCH v2 14/19] kvm: add a reset capability
Date: Thu, 09 Apr 2009 12:31:55 -0400 [thread overview]
Message-ID: <20090409163155.32740.50340.stgit@dev.haskins.net> (raw)
In-Reply-To: <20090409155200.32740.19358.stgit@dev.haskins.net>
We need a way to detect if a VM is reset later in the series, so lets
add a capability for userspace to signal a VM reset down to the kernel.
Signed-off-by: Gregory Haskins <ghaskins@novell.com>
---
arch/x86/kvm/x86.c | 1 +
include/linux/kvm.h | 2 ++
include/linux/kvm_host.h | 6 ++++++
virt/kvm/kvm_main.c | 36 ++++++++++++++++++++++++++++++++++++
4 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 758b7a1..9b0a649 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -971,6 +971,7 @@ int kvm_dev_ioctl_check_extension(long ext)
case KVM_CAP_NOP_IO_DELAY:
case KVM_CAP_MP_STATE:
case KVM_CAP_SYNC_MMU:
+ case KVM_CAP_RESET:
r = 1;
break;
case KVM_CAP_COALESCED_MMIO:
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 0424326..7ffd8f5 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -396,6 +396,7 @@ struct kvm_trace_rec {
#ifdef __KVM_HAVE_USER_NMI
#define KVM_CAP_USER_NMI 22
#endif
+#define KVM_CAP_RESET 23
/*
* ioctls for VM fds
@@ -429,6 +430,7 @@ struct kvm_trace_rec {
struct kvm_assigned_pci_dev)
#define KVM_ASSIGN_IRQ _IOR(KVMIO, 0x70, \
struct kvm_assigned_irq)
+#define KVM_RESET _IO(KVMIO, 0x67)
/*
* ioctls for vcpu fds
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index bf6f703..506eca1 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -17,6 +17,7 @@
#include <linux/preempt.h>
#include <linux/marker.h>
#include <linux/msi.h>
+#include <linux/notifier.h>
#include <asm/signal.h>
#include <linux/kvm.h>
@@ -132,6 +133,8 @@ struct kvm {
unsigned long mmu_notifier_seq;
long mmu_notifier_count;
#endif
+
+ struct raw_notifier_head reset_notifier; /* triggers when VM reboots */
};
/* The guest did something we don't support. */
@@ -158,6 +161,9 @@ void kvm_exit(void);
void kvm_get_kvm(struct kvm *kvm);
void kvm_put_kvm(struct kvm *kvm);
+int kvm_reset_notifier_register(struct kvm *kvm, struct notifier_block *nb);
+int kvm_reset_notifier_unregister(struct kvm *kvm, struct notifier_block *nb);
+
#define HPA_MSB ((sizeof(hpa_t) * 8) - 1)
#define HPA_ERR_MASK ((hpa_t)1 << HPA_MSB)
static inline int is_error_hpa(hpa_t hpa) { return hpa >> HPA_MSB; }
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 29a667c..fca2d25 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -868,6 +868,8 @@ static struct kvm *kvm_create_vm(void)
#ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
kvm_coalesced_mmio_init(kvm);
#endif
+ RAW_INIT_NOTIFIER_HEAD(&kvm->reset_notifier);
+
out:
return kvm;
}
@@ -1485,6 +1487,35 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
}
}
+static void kvm_notify_reset(struct kvm *kvm)
+{
+ mutex_lock(&kvm->lock);
+ raw_notifier_call_chain(&kvm->reset_notifier, 0, kvm);
+ mutex_unlock(&kvm->lock);
+}
+
+int kvm_reset_notifier_register(struct kvm *kvm, struct notifier_block *nb)
+{
+ int ret;
+
+ mutex_lock(&kvm->lock);
+ ret = raw_notifier_chain_register(&kvm->reset_notifier, nb);
+ mutex_unlock(&kvm->lock);
+
+ return ret;
+}
+
+int kvm_reset_notifier_unregister(struct kvm *kvm, struct notifier_block *nb)
+{
+ int ret;
+
+ mutex_lock(&kvm->lock);
+ ret = raw_notifier_chain_unregister(&kvm->reset_notifier, nb);
+ mutex_unlock(&kvm->lock);
+
+ return ret;
+}
+
/*
* The vCPU has executed a HLT instruction with in-kernel mode enabled.
*/
@@ -1929,6 +1960,11 @@ static long kvm_vm_ioctl(struct file *filp,
break;
}
#endif
+ case KVM_RESET: {
+ kvm_notify_reset(kvm);
+ r = 0;
+ break;
+ }
default:
r = kvm_arch_vm_ioctl(filp, ioctl, arg);
}
next prev parent reply other threads:[~2009-04-09 16:31 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-09 16:30 [RFC PATCH v2 00/19] virtual-bus Gregory Haskins
2009-04-09 16:30 ` [RFC PATCH v2 01/19] shm-signal: shared-memory signals Gregory Haskins
2009-04-09 16:30 ` [RFC PATCH v2 02/19] vbus: add virtual-bus definitions Gregory Haskins
2009-04-09 16:30 ` [RFC PATCH v2 03/19] vbus: add connection-client helper infrastructure Gregory Haskins
2009-06-04 18:06 ` Michael S. Tsirkin
2009-06-04 18:18 ` Gregory Haskins
2009-06-04 18:24 ` Avi Kivity
2009-06-04 18:30 ` Gregory Haskins
2009-06-04 19:04 ` Avi Kivity
2009-06-04 18:23 ` Avi Kivity
2009-04-09 16:31 ` [RFC PATCH v2 04/19] vbus: add bus-registration notifiers Gregory Haskins
2009-04-09 16:31 ` [RFC PATCH v2 05/19] vbus: add a "vbus-proxy" bus model for vbus_driver objects Gregory Haskins
2009-04-09 16:31 ` [RFC PATCH v2 06/19] ioq: Add basic definitions for a shared-memory, lockless queue Gregory Haskins
2009-04-09 16:31 ` [RFC PATCH v2 07/19] ioq: add vbus helpers Gregory Haskins
2009-04-09 16:31 ` [RFC PATCH v2 08/19] venet: add the ABI definitions for an 802.x packet interface Gregory Haskins
2009-04-09 16:31 ` [RFC PATCH v2 09/19] net: Add vbus_enet driver Gregory Haskins
2009-04-09 16:37 ` Stephen Hemminger
2009-04-09 19:50 ` Greg KH
2009-04-09 16:31 ` [RFC PATCH v2 10/19] venet-tap: Adds a "venet" compatible "tap" device to VBUS Gregory Haskins
2009-04-09 16:31 ` [RFC PATCH v2 11/19] venet: add scatter-gather support Gregory Haskins
2009-04-09 16:31 ` [RFC PATCH v2 12/19] venettap: " Gregory Haskins
2009-04-09 16:31 ` [RFC PATCH v2 13/19] x86: allow the irq->vector translation to be determined outside of ioapic Gregory Haskins
2009-04-09 16:31 ` Gregory Haskins [this message]
2009-04-11 16:56 ` [RFC PATCH v2 14/19] kvm: add a reset capability Avi Kivity
2009-04-09 16:32 ` [RFC PATCH v2 15/19] kvm: add dynamic IRQ support Gregory Haskins
2009-04-11 17:01 ` Avi Kivity
2009-04-13 17:44 ` Gregory Haskins
2009-04-09 16:32 ` [RFC PATCH v2 16/19] kvm: Add VBUS support to the host Gregory Haskins
2009-04-09 16:32 ` [RFC PATCH v2 17/19] kvm: Add guest-side support for VBUS Gregory Haskins
2009-04-09 16:32 ` [RFC PATCH v2 18/19] vbus: add a userspace connector Gregory Haskins
2009-04-09 16:32 ` [RFC PATCH v2 19/19] virtio: add a vbus transport Gregory Haskins
2009-08-09 16:40 ` Anthony Liguori
2009-08-10 15:40 ` Gregory Haskins
2009-04-09 16:48 ` [RFC PATCH v2 00/19] virtual-bus Gregory Haskins
2009-04-11 16:45 ` Avi Kivity
2009-06-04 18:49 ` Gregory Haskins
2009-06-05 4:55 ` Rusty Russell
2009-06-05 5:30 ` Paul E. McKenney
2009-06-05 14:55 ` Rusty Russell
2009-06-05 16:25 ` Paul E. McKenney
2009-06-05 11:56 ` Gregory Haskins
2009-06-05 12:53 ` Avi Kivity
2009-06-05 12:54 ` Gregory Haskins
2009-06-05 14:35 ` Rusty Russell
2009-06-05 14:44 ` Gregory Haskins
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=20090409163155.32740.50340.stgit@dev.haskins.net \
--to=ghaskins@novell.com \
--cc=agraf@suse.de \
--cc=andi@firstfloor.org \
--cc=anthony@codemonkey.ws \
--cc=avi@redhat.com \
--cc=bhutchings@solarflare.com \
--cc=chrisw@sous-sol.org \
--cc=gregkh@suse.de \
--cc=herber@gondor.apana.org.au \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pmorreale@novell.com \
--cc=pmullaney@novell.com \
--cc=rusty@rustcorp.com.au \
--cc=shemminger@vyatta.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).