qemu,kvm: Enable NMI support for user space irqchip
PATCH 1/6 qemu,kvm: Enable NMI support for user space irqchip
Make use of the new KVM_NMI IOCTL to send NMIs into the KVM guest if the user space APIC emulation or some other source raised them.
---
target-i386/kvm.c +8 -0
@@ -1417,6 +1417,14 @@ int kvm_arch_get_registers(CPUState *env)int kvm_arch_pre_run (CPUState *env,struct kvm_run *run) { +#ifdef KVM_CAP_USER_NMI +if (env->interrupt_request &CPU_INTERRUPT_NMI ) { + env->interrupt_request &= ~CPU_INTERRUPT_NMI ; +DPRINTF ("injected NMI\n" ); +kvm_vcpu_ioctl (env,KVM_NMI ); + } +#endif +/* Try to inject an interrupt if the guest can accept it */ if (run->ready_for_interrupt_injection && (env->interrupt_request & CPU_INTERRUPT_HARD) &&
Quoted 3 lines · Lai Jiangshan
Make use of the new
KVM_NMIIOCTL to send NMIs into the KVM guest if the user space APIC emulation or some other source raised them.
In that light, the subject is not absolutely correct.
Quoted 12 lines
Signed-off-by Lai Jiangshan <[email protected]>---
target-i386/kvm.c +1
-0@@ -1417,6 +1417,14 @@ int kvm_arch_get_registers(CPUState *env)int kvm_arch_pre_run (CPUState *env,struct kvm_run *run) { +#ifdef KVM_CAP_USER_NMI
target-i386/kvm.c int kvm_arch_get_registers(CPUState *env) · line 1430
Quoted 10 lines
target-i386/kvm.c +7
-0+if (env->interrupt_request &CPU_INTERRUPT_NMI ) { + env->interrupt_request &= ~CPU_INTERRUPT_NMI ; +DPRINTF ("injected NMI\n" ); +kvm_vcpu_ioctl (env,KVM_NMI ); + } +#endif +/* Try to inject an interrupt if the guest can accept it */ if (run->ready_for_interrupt_injection && (env->interrupt_request & CPU_INTERRUPT_HARD) &&
Actually, we already depend on KVM_CAP_DESTROY_MEMORY_REGION_WORKS which was introduced with 2.6.29 as well. I would suggest to simply extend the static configure check and avoid new #ifdefs in the code.
Thanks for pushing this! Was obviously so trivial that it was forgotten...
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 7 lines · Jan Kiszka
Quoted 3 lines · Lai Jiangshan
Make use of the new
KVM_NMIIOCTL to send NMIs into the KVM guest if the user space APIC emulation or some other source raised them.In that light, the subject is not absolutely correct.
[...]
Quoted 7 lines
Actually, we already depend on
KVM_CAP_DESTROY_MEMORY_REGION_WORKSwhich was introduced with 2.6.29 as well. I would suggest to simply extend the static configure check and avoid new #ifdefs in the code.Thanks for pushing this! Was obviously so trivial that it was forgotten...
Thanks. We want to inject nmi to kvm guest via qemu monitor, that's this path's purpose.
But I can't get you means, what I should do to fix this patch? Just remove the #ifdefs OR use kvm_check_extension(KVM_CAP_USER_NMI) ?
+ static int can_user_nmi = -1;
+
+ if (can_user_nmi == -1)
+ can_user_nmi = kvm_check_extension(kvm_state, KVM_CAP_USER_NMI);
+
+ if (can_user_nmi > 0 && env->interrupt_request & CPU_INTERRUPT_NMI) {
+ env->interrupt_request &= ~CPU_INTERRUPT_NMI;
+ DPRINTF("injected NMI\n");
+ kvm_vcpu_ioctl(env, KVM_NMI);+ }
Thanks,
Lai
PATCH v2 1/1 qemu,kvm: Enable user space NMI injection for kvm guest
In reply to Jan KiszkaMake use of the new KVM_NMI IOCTL to send NMIs into the KVM guest if the user space raised them. (example: qemu monitor's "nmi" command)
---
configure +3 -0
@@ -1646,6 +1646,9 @@ if test "$kvm" != "no" ; then #if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS) #error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS #endif +#if !defined(KVM_CAP_USER_NMI) +#error Missing KVM capability KVM_CAP_USER_NMI +#endif int main(void) { return 0; } EOF if test "$kerneldir" != "" ; then
target-i386/kvm.c +7 -0
@@ -1417,6 +1417,13 @@ int kvm_arch_get_registers(CPUState *env)int kvm_arch_pre_run (CPUState *env,struct kvm_run *run) { +/* Inject NMI */ +if (env->interrupt_request &CPU_INTERRUPT_NMI ) { + env->interrupt_request &= ~CPU_INTERRUPT_NMI ; +DPRINTF ("injected NMI\n" ); +kvm_vcpu_ioctl (env,KVM_NMI ); + } +/* Try to inject an interrupt if the guest can accept it */ if (run->ready_for_interrupt_injection && (env->interrupt_request & CPU_INTERRUPT_HARD) &&
Re: [PATCH V2] qemu,kvm: Enable user space NMI injection for kvm guest
Quoted 11 lines · Lai Jiangshan
Make use of the new
KVM_NMIIOCTL to send NMIs into the KVM guest if the user space raised them. (example: qemu monitor's "nmi" command)Signed-off-by Lai Jiangshan <[email protected]>---
configure +0
-0
configure if test "$kvm" != "no" ; then · line 1654
Quoted 9 lines
configure +3
-0@@ -1646,6 +1646,9 @@ if test "$kvm" != "no" ; then #if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS) #error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS #endif +#if !defined(KVM_CAP_USER_NMI) +#error Missing KVM capability KVM_CAP_USER_NMI +#endif int main(void) { return 0; } EOF if test "$kerneldir" != "" ; then
That's what I meant.
We also have a runtime check for KVM_CAP_DESTROY_MEMORY_REGION_WORKS on kvm init, but IMHO adding the same for KVM_CAP_USER_NMI would be overkill. So...
Quoted 8 lines
target-i386/kvm.c +0
-0@@ -1417,6 +1417,13 @@ int kvm_arch_get_registers(CPUState *env)int kvm_arch_pre_run (CPUState *env,struct kvm_run *run) {
target-i386/kvm.c int kvm_arch_get_registers(CPUState *env) · line 1429
Quoted 10 lines
target-i386/kvm.c +7
-0+/* Inject NMI */ +if (env->interrupt_request &CPU_INTERRUPT_NMI ) { + env->interrupt_request &= ~CPU_INTERRUPT_NMI ; +DPRINTF ("injected NMI\n" ); +kvm_vcpu_ioctl (env,KVM_NMI ); + } +/* Try to inject an interrupt if the guest can accept it */ if (run->ready_for_interrupt_injection && (env->interrupt_request & CPU_INTERRUPT_HARD) &&
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [PATCH V2] qemu,kvm: Enable user space NMI injection for kvm guest
Quoted 34 lines · Jan Kiszka
Quoted 11 lines · Lai Jiangshan
Make use of the new
KVM_NMIIOCTL to send NMIs into the KVM guest if the user space raised them. (example: qemu monitor's "nmi" command)Signed-off-by Lai Jiangshan <[email protected]>---
configure +0
-0configure if test "$kvm" != "no" ; then · line 1654
Quoted 9 lines
configure +3
-0@@ -1646,6 +1646,9 @@ if test "$kvm" != "no" ; then #if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS) #error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS #endif +#if !defined(KVM_CAP_USER_NMI) +#error Missing KVM capability KVM_CAP_USER_NMI +#endif int main(void) { return 0; } EOF if test "$kerneldir" != "" ; thenThat's what I meant.
We also have a runtime check for
KVM_CAP_DESTROY_MEMORY_REGION_WORKSon kvm init, but IMHO adding the same forKVM_CAP_USER_NMIwould be overkill. So...Quoted 6 lines
target-i386/kvm.c +0
-0@@ -1417,6 +1417,13 @@ int kvm_arch_get_registers(CPUState *env)
Quoted 15 lines
target-i386/kvm.c int kvm_arch_get_registers(CPUState *env) · line 1429
Quoted 12 lines
target-i386/kvm.c +7
-0int kvm_arch_pre_run (CPUState *env,struct kvm_run *run) { +/* Inject NMI */ +if (env->interrupt_request &CPU_INTERRUPT_NMI ) { + env->interrupt_request &= ~CPU_INTERRUPT_NMI ; +DPRINTF ("injected NMI\n" ); +kvm_vcpu_ioctl (env,KVM_NMI ); + } +/* Try to inject an interrupt if the guest can accept it */ if (run->ready_for_interrupt_injection && (env->interrupt_request & CPU_INTERRUPT_HARD) &&Acked-by Jan Kiszka <[email protected]>
Hi, Avi
Could you apply this patch or give me any comments/suggest?
Thanks,
Lai
Re: [PATCH V2] qemu,kvm: Enable user space NMI injection for kvm guest
In reply to Jan KiszkaQuoted 49 lines · Jan Kiszka
Quoted 11 lines · Lai Jiangshan
Make use of the new
KVM_NMIIOCTL to send NMIs into the KVM guest if the user space raised them. (example: qemu monitor's "nmi" command)Signed-off-by Lai Jiangshan <[email protected]>---
configure +0
-0configure if test "$kvm" != "no" ; then · line 1654
Quoted 9 lines
configure +3
-0@@ -1646,6 +1646,9 @@ if test "$kvm" != "no" ; then #if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS) #error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS #endif +#if !defined(KVM_CAP_USER_NMI) +#error Missing KVM capability KVM_CAP_USER_NMI +#endif int main(void) { return 0; } EOF if test "$kerneldir" != "" ; thenThat's what I meant.
We also have a runtime check for
KVM_CAP_DESTROY_MEMORY_REGION_WORKSon kvm init, but IMHO adding the same forKVM_CAP_USER_NMIwould be overkill. So...Quoted 8 lines
target-i386/kvm.c +0
-0@@ -1417,6 +1417,13 @@ int kvm_arch_get_registers(CPUState *env)int kvm_arch_pre_run (CPUState *env,struct kvm_run *run) {target-i386/kvm.c int kvm_arch_get_registers(CPUState *env) · line 1429
Quoted 10 lines
target-i386/kvm.c +7
-0+/* Inject NMI */ +if (env->interrupt_request &CPU_INTERRUPT_NMI ) { + env->interrupt_request &= ~CPU_INTERRUPT_NMI ; +DPRINTF ("injected NMI\n" ); +kvm_vcpu_ioctl (env,KVM_NMI ); + } +/* Try to inject an interrupt if the guest can accept it */ if (run->ready_for_interrupt_injection && (env->interrupt_request & CPU_INTERRUPT_HARD) &&Acked-by Jan Kiszka <[email protected]>
Quoted 2 lines
Jan
Hi, Avi,
Could you apply this patch?
Thanks,
Lai
Marcelo Tosatti
AppliedRe: [PATCH V2] qemu,kvm: Enable user space NMI injection for kvm guest
In reply to Lai JiangshanQuoted 5 lines · Lai Jiangshan
Make use of the new
KVM_NMIIOCTL to send NMIs into the KVM guest if the user space raised them. (example: qemu monitor's "nmi" command)Signed-off-by Lai Jiangshan <[email protected]>
Applied to uq/master, thanks.