On 28/02/20 20:04, Andy Lutomirski wrote: >>> + * We are relying on the interrupted context being sane (valid >>> + * RSP, relevant locks not held, etc.), which is fine as long as >>> + * the the interrupted context had IF=1. >> This is not about IF=0/IF=1; the KVM code is careful about taking >> spinlocks only with IRQs disabled, and async PF is not delivered if the >> interrupted context had IF=0. The problem is that the memory location >> is not reentrant if an NMI is delivered in the wrong window, as you hint >> below. > > If an async PF is delivered with IF=0, then, unless something else > clever happens to make it safe, we are toast. Right, it just cannot happen. kvm_can_do_async_pf is where KVM decides whether a page fault must be handled synchronously, and it does this: bool kvm_can_do_async_pf(struct kvm_vcpu *vcpu) { ... /* * If interrupts are off we cannot even use an artificial * halt state. */ return kvm_x86_ops->interrupt_allowed(vcpu); } The same function is called by kvm_arch_can_inject_async_page_present. Paolo