* [PATCH] kvm-userspace: Switch to KVM_CAP_USER_NMI
@ 2008-12-11 15:54 Jan Kiszka
2008-12-14 8:11 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2008-12-11 15:54 UTC (permalink / raw)
To: kvm-devel; +Cc: Avi Kivity, Hollis Blanchard, Zhang, Xiantao
[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,
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kvm-userspace: Switch to KVM_CAP_USER_NMI
2008-12-11 15:54 [PATCH] kvm-userspace: Switch to KVM_CAP_USER_NMI Jan Kiszka
@ 2008-12-14 8:11 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2008-12-14 8:11 UTC (permalink / raw)
To: Jan Kiszka; +Cc: kvm-devel, Hollis Blanchard, Zhang, Xiantao
Jan Kiszka wrote:
> [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.
>
Applied, thanks.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-12-14 8:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-11 15:54 [PATCH] kvm-userspace: Switch to KVM_CAP_USER_NMI Jan Kiszka
2008-12-14 8:11 ` Avi Kivity
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).