[Qemu-devel] Re: [PATCH 1/6] qemu, kvm: Enable NMI support for user space irqchip

2010-12-10 Thread Lai Jiangshan
On 12/09/2010 03:25 PM, Jan Kiszka wrote:
> Am 09.12.2010 07:58, Lai Jiangshan wrote:
>>
>> 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.
> 
> In that light, the subject is not absolutely correct.
> 

[...]

> 
> 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...
> 


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




[Qemu-devel] Re: [PATCH 1/6] qemu, kvm: Enable NMI support for user space irqchip

2010-12-09 Thread Jan Kiszka
Am 09.12.2010 07:58, Lai Jiangshan wrote:
> 
> 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.

In that light, the subject is not absolutely correct.

> 
> Signed-off-by: Lai Jiangshan 
> ---
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index 7dfc357..c4ebe28 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -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) &&

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

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux