Re: [PATCH v2] x86/kvm: Disable KVM_ASYNC_PF_SEND_ALWAYS

From: Paolo Bonzini
Date: Thu Apr 09 2020 - 11:17:43 EST


On 09/04/20 17:03, Andy Lutomirski wrote:
>> No, I think we wouldn't use a paravirt #VE at this point, we would
>> use the real thing if available.
>>
>> It would still be possible to switch from the IST to the main
>> kernel stack before writing 0 to the reentrancy word.
>
> Almost but not quite. We do this for NMI-from-usermode, and itâs
> ugly. But we canât do this for NMI-from-kernel or #VE-from-kernel
> because there might not be a kernel stack. Trying to hack around
> this wonât be pretty.
>
> Frankly, I think that we shouldnât even try to report memory failure
> to the guest if it happens with interrupts off. Just kill the guest
> cleanly and keep it simple. Or inject an intentionally unrecoverable
> IST exception.

But it would be nice to use #VE for all host-side page faults, not just
for memory failure.

So the solution would be the same as for NMIs, duplicating the stack
frame and patching the outer handler's stack from the recursive #VE
(https://lwn.net/Articles/484932/). It's ugly but it's a known ugliness.

Paolo