kvm-userspace: Switch to KVM_CAP_USER_NMI
PATCH 1/1 kvm-userspace: Switch to KVM_CAP_USER_NMI
[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 <[email protected]>
---
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(-)
libkvm/libkvm.c +4 -4
@@ -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_NMIpush_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 ;
libkvm/libkvm.h +2 -0
@@ -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);
qemu/qemu-kvm-ia64.c +0 -4
@@ -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) { }
qemu/qemu-kvm-powerpc.c +0 -7
@@ -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__);
qemu/qemu-kvm-x86.c +2 -0
@@ -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) {
qemu/qemu-kvm.c +3 -6
@@ -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
user/main-ppc.c +0 -5
@@ -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,
user/main.c +4 -0
@@ -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,
Avi Kivity
AppliedQuoted 6 lines · Jan Kiszka
[Hope I will not cause troubles to other archs this time.]
Adopt to new
KVM_CAP_USER_NMIinterface 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.
Signature · 1 line
error compiling committee.c: too many arguments to function