On Fri, Sep 26, 2008 at 09:30:47AM +0200, [EMAIL PROTECTED] wrote:
> Properly set GUEST_INTR_STATE_NMI and reset nmi_injected when a
> task-switch vmexit happened due to a task gate being used for handling
> NMIs. Also avoid the false warning about valid vectoring info in
> kvm_handle_exit.
> 
> Based on original patch by Gleb Natapov.
> 
Signed-off-by: Gleb Natapov <[EMAIL PROTECTED]>

> Signed-off-by: Jan Kiszka <[EMAIL PROTECTED]>
> ---
>  arch/x86/kvm/vmx.c |   18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> Index: b/arch/x86/kvm/vmx.c
> ===================================================================
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -2819,6 +2819,7 @@ static int handle_apic_access(struct kvm
>  
>  static int handle_task_switch(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
>  {
> +     struct vcpu_vmx *vmx = to_vmx(vcpu);
>       unsigned long exit_qualification;
>       u16 tss_selector;
>       int reason;
> @@ -2826,6 +2827,15 @@ static int handle_task_switch(struct kvm
>       exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
>  
>       reason = (u32)exit_qualification >> 30;
> +     if (reason == TASK_SWITCH_GATE && vmx->vcpu.arch.nmi_injected &&
> +         (vmx->idt_vectoring_info & VECTORING_INFO_VALID_MASK) &&
> +         (vmx->idt_vectoring_info & VECTORING_INFO_TYPE_MASK)
> +         == INTR_TYPE_NMI_INTR) {
> +             vcpu->arch.nmi_injected = false;
> +             if (cpu_has_virtual_nmis())
> +                     vmcs_set_bits(GUEST_INTERRUPTIBILITY_INFO,
> +                                   GUEST_INTR_STATE_NMI);
> +     }
>       tss_selector = exit_qualification;
>  
>       return kvm_task_switch(vcpu, tss_selector, reason);
> @@ -2998,9 +3008,11 @@ static int kvm_handle_exit(struct kvm_ru
>  
>       if ((vectoring_info & VECTORING_INFO_VALID_MASK) &&
>                       (exit_reason != EXIT_REASON_EXCEPTION_NMI &&
> -                     exit_reason != EXIT_REASON_EPT_VIOLATION))
> -             printk(KERN_WARNING "%s: unexpected, valid vectoring info and "
> -                    "exit reason is 0x%x\n", __func__, exit_reason);
> +                     exit_reason != EXIT_REASON_EPT_VIOLATION &&
> +                     exit_reason != EXIT_REASON_TASK_SWITCH))
> +             printk(KERN_WARNING "%s: unexpected, valid vectoring info "
> +                    "(0x%x) and exit reason is 0x%x\n",
> +                    __func__, vectoring_info, exit_reason);
>       if (exit_reason < kvm_vmx_max_exit_handlers
>           && kvm_vmx_exit_handlers[exit_reason])
>               return kvm_vmx_exit_handlers[exit_reason](vcpu, kvm_run);

--
                        Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to