lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANRm+CyzCEraxX3R9XuxHfjU3ePacFHJUuZCpA4T8eJqjTwwHg@mail.gmail.com>
Date:   Thu, 24 Aug 2017 17:47:09 +0800
From:   Wanpeng Li <kernellwp@...il.com>
To:     Paolo Bonzini <pbonzini@...hat.com>
Cc:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        kvm <kvm@...r.kernel.org>,
        Radim Krčmář <rkrcmar@...hat.com>,
        Wanpeng Li <wanpeng.li@...mail.com>
Subject: Re: [PATCH v3 2/4] KVM: X86: Fix loss of exception which has not yet injected

2017-08-24 17:35 GMT+08:00 Paolo Bonzini <pbonzini@...hat.com>:
> On 24/08/2017 11:13, Wanpeng Li wrote:
>> 2017-08-24 16:57 GMT+08:00 Paolo Bonzini <pbonzini@...hat.com>:
>>> On 24/08/2017 08:52, Wanpeng Li wrote:
>>>>> @@ -6862,6 +6876,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
>>>>>                                 kvm_x86_ops->enable_nmi_window(vcpu);
>>>>>                         if (kvm_cpu_has_injectable_intr(vcpu) || req_int_win)
>>>>>                                 kvm_x86_ops->enable_irq_window(vcpu);
>>>>> +                       WARN_ON(vcpu->arch.exception.pending);
>>>>
>>>> This WARN_ON() is suggested during the review of last version,
>>>> however, there are many cases in inject_pending_event() can result in
>>>> return directly w/ vcpu->arch.exception.pending is true. Actually I
>>>> have already catched the warning several times during the testing. I
>>>> think we should remove it when committing.
>>>
>>> No, it's a good thing that it's failing, because it's finding a bug.
>>> There's no such thing as an "exception window", so at the very least it
>>
>> Good point, the code looks good, I will fold it in next version.
>> However, I still can observe the warning.
>
> In patch 4, vmx_check_nested_events must clear vcpu->ex.pending.

It is true, but I can still observe the warning.


diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 6f88a79..4f97c4f 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -10990,6 +10990,8 @@ static int vmx_check_nested_events(struct
kvm_vcpu *vcpu, bool external_intr)
         if (vmx->nested.nested_run_pending)
             return -EBUSY;

+        vcpu->arch.exception.pending = false;
+        vcpu->arch.exception.injected = true;
         nested_vmx_inject_exception_vmexit(vcpu, exit_qual);
         return 0;
     }
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index b698b2f..77e3031 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6365,14 +6365,20 @@ static int inject_pending_event(struct
kvm_vcpu *vcpu, bool req_int_win)
         return 0;
     }

-    if (vcpu->arch.nmi_injected) {
-        kvm_x86_ops->set_nmi(vcpu);
-        return 0;
-    }
+    /*
+     * Exceptions must be injected immediately, or the exception
+     * frame will have the address of the NMI or interrupt handler.
+     */
+    if (!vcpu->arch.exception.pending) {
+        if (vcpu->arch.nmi_injected) {
+            kvm_x86_ops->set_nmi(vcpu);
+            return 0;
+        }

-    if (vcpu->arch.interrupt.pending) {
-        kvm_x86_ops->set_irq(vcpu);
-        return 0;
+        if (vcpu->arch.interrupt.pending) {
+            kvm_x86_ops->set_irq(vcpu);
+            return 0;
+        }
     }

     if (is_guest_mode(vcpu) && kvm_x86_ops->check_nested_events) {

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ