From: Jan Kiszka <jan.kiszka@siemens.com>
To: kvm-devel <kvm@vger.kernel.org>
Cc: Avi Kivity <avi@redhat.com>,
Hollis Blanchard <hollisb@us.ibm.com>,
"Zhang, Xiantao" <xiantao.zhang@intel.com>
Subject: [PATCH] kvm-userspace: Switch to KVM_CAP_USER_NMI
Date: Thu, 11 Dec 2008 16:54:57 +0100 [thread overview]
Message-ID: <494137D1.30105@siemens.com> (raw)
[Hope I will not cause troubles to other archs this time.]
Adopt to new KVM_CAP_USER_NMI interface for injecting NMIs from qemu
user space. As this capability is only provided on archs actually
requiring it, we can also drop a lot of empty arch stubs.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
libkvm/libkvm.c | 8 ++++----
libkvm/libkvm.h | 2 ++
qemu/qemu-kvm-ia64.c | 4 ----
qemu/qemu-kvm-powerpc.c | 7 -------
qemu/qemu-kvm-x86.c | 2 ++
qemu/qemu-kvm.c | 9 +++------
user/main-ppc.c | 5 -----
user/main.c | 4 ++++
8 files changed, 15 insertions(+), 26 deletions(-)
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
index f6ddfde..d4b1a73 100644
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -832,9 +832,11 @@ int try_push_interrupts(kvm_context_t kvm)
return kvm->callbacks->try_push_interrupts(kvm->opaque);
}
-void push_nmi(kvm_context_t kvm)
+static inline void push_nmi(kvm_context_t kvm)
{
+#ifdef KVM_CAP_USER_NMI
kvm->callbacks->push_nmi(kvm->opaque);
+#endif /* KVM_CAP_USER_NMI */
}
void post_kvm_run(kvm_context_t kvm, void *env)
@@ -868,9 +870,7 @@ int kvm_run(kvm_context_t kvm, int vcpu, void *env)
struct kvm_run *run = kvm->run[vcpu];
again:
-#ifdef KVM_CAP_NMI
push_nmi(kvm);
-#endif
#if !defined(__s390__)
if (!kvm->irqchip_in_kernel)
run->request_interrupt_window = try_push_interrupts(kvm);
@@ -1032,7 +1032,7 @@ int kvm_has_sync_mmu(kvm_context_t kvm)
int kvm_inject_nmi(kvm_context_t kvm, int vcpu)
{
-#ifdef KVM_CAP_NMI
+#ifdef KVM_CAP_USER_NMI
return ioctl(kvm->vcpu_fd[vcpu], KVM_NMI);
#else
return -ENOSYS;
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
index 963b184..392065b 100644
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -66,7 +66,9 @@ struct kvm_callbacks {
int (*shutdown)(void *opaque, void *env);
int (*io_window)(void *opaque);
int (*try_push_interrupts)(void *opaque);
+#ifdef KVM_CAP_USER_NMI
void (*push_nmi)(void *opaque);
+#endif
void (*post_kvm_run)(void *opaque, void *env);
int (*pre_kvm_run)(void *opaque, void *env);
int (*tpr_access)(void *opaque, int vcpu, uint64_t rip, int is_write);
diff --git a/qemu/qemu-kvm-ia64.c b/qemu/qemu-kvm-ia64.c
index a6b17af..8cd3cff 100644
--- a/qemu/qemu-kvm-ia64.c
+++ b/qemu/qemu-kvm-ia64.c
@@ -57,10 +57,6 @@ int kvm_arch_try_push_interrupts(void *opaque)
return 1;
}
-void kvm_arch_push_nmi(void *opaque)
-{
-}
-
void kvm_arch_update_regs_for_sipi(CPUState *env)
{
}
diff --git a/qemu/qemu-kvm-powerpc.c b/qemu/qemu-kvm-powerpc.c
index fa534ed..bded6cb 100644
--- a/qemu/qemu-kvm-powerpc.c
+++ b/qemu/qemu-kvm-powerpc.c
@@ -188,13 +188,6 @@ int kvm_arch_try_push_interrupts(void *opaque)
return 0;
}
-void kvm_arch_push_nmi(void *opaque)
-{
- /* no nmi irq, so discard that call for now and return success.
- * This might later get mapped to something on powerpc too if we want
- * to support the nmi monitor command somwhow */
-}
-
void kvm_arch_update_regs_for_sipi(CPUState *env)
{
printf("%s: no kvm-powerpc multi processor support yet!\n", __func__);
diff --git a/qemu/qemu-kvm-x86.c b/qemu/qemu-kvm-x86.c
index 2e68ace..616c7c6 100644
--- a/qemu/qemu-kvm-x86.c
+++ b/qemu/qemu-kvm-x86.c
@@ -667,6 +667,7 @@ int kvm_arch_try_push_interrupts(void *opaque)
return (env->interrupt_request & CPU_INTERRUPT_HARD) != 0;
}
+#ifdef KVM_CAP_USER_NMI
void kvm_arch_push_nmi(void *opaque)
{
CPUState *env = cpu_single_env;
@@ -680,6 +681,7 @@ void kvm_arch_push_nmi(void *opaque)
if (r < 0)
printf("cpu %d fail inject NMI\n", env->cpu_index);
}
+#endif /* KVM_CAP_USER_NMI */
void kvm_arch_update_regs_for_sipi(CPUState *env)
{
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 067cf03..e95f656 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -154,11 +154,6 @@ static int try_push_interrupts(void *opaque)
return kvm_arch_try_push_interrupts(opaque);
}
-static void push_nmi(void *opaque)
-{
- kvm_arch_push_nmi(opaque);
-}
-
static void post_kvm_run(void *opaque, void *data)
{
CPUState *env = (CPUState *)data;
@@ -742,7 +737,9 @@ static struct kvm_callbacks qemu_kvm_ops = {
.shutdown = kvm_shutdown,
.io_window = kvm_io_window,
.try_push_interrupts = try_push_interrupts,
- .push_nmi = push_nmi,
+#ifdef KVM_CAP_USER_NMI
+ .push_nmi = kvm_arch_push_nmi,
+#endif
.post_kvm_run = post_kvm_run,
.pre_kvm_run = pre_kvm_run,
#ifdef TARGET_I386
diff --git a/user/main-ppc.c b/user/main-ppc.c
index 71afc9e..fed87ed 100644
--- a/user/main-ppc.c
+++ b/user/main-ppc.c
@@ -90,10 +90,6 @@ static int test_try_push_interrupts(void *opaque)
return 0;
}
-static void test_push_nmi(void *opaque)
-{
-}
-
static void test_post_kvm_run(void *opaque, void *vcpu)
{
}
@@ -182,7 +178,6 @@ static struct kvm_callbacks test_callbacks = {
.halt = test_halt,
.io_window = test_io_window,
.try_push_interrupts = test_try_push_interrupts,
- .push_nmi = test_push_nmi,
.post_kvm_run = test_post_kvm_run,
.pre_kvm_run = test_pre_kvm_run,
.powerpc_dcr_read = test_dcr_read,
diff --git a/user/main.c b/user/main.c
index 55639b5..9ba5b5e 100644
--- a/user/main.c
+++ b/user/main.c
@@ -323,9 +323,11 @@ static int test_try_push_interrupts(void *opaque)
return 0;
}
+#ifdef KVM_CAP_USER_NMI
static void test_push_nmi(void *opaque)
{
}
+#endif
static void test_post_kvm_run(void *opaque, void *vcpu)
{
@@ -373,7 +375,9 @@ static struct kvm_callbacks test_callbacks = {
.halt = test_halt,
.io_window = test_io_window,
.try_push_interrupts = test_try_push_interrupts,
+#ifdef KVM_CAP_USER_NMI
.push_nmi = test_push_nmi,
+#endif
.post_kvm_run = test_post_kvm_run,
.pre_kvm_run = test_pre_kvm_run,
.shutdown = test_shutdown,
next reply other threads:[~2008-12-11 15:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-11 15:54 Jan Kiszka [this message]
2008-12-14 8:11 ` [PATCH] kvm-userspace: Switch to KVM_CAP_USER_NMI 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=494137D1.30105@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=avi@redhat.com \
--cc=hollisb@us.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=xiantao.zhang@intel.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 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.