On Wed, Jun 10, 2020 at 03:32:11PM -0400, Vivek Goyal wrote: > On Wed, Jun 10, 2020 at 07:55:32PM +0200, Vitaly Kuznetsov wrote: > > 'Page not present' event may or may not get injected depending on > > guest's state. If the event wasn't injected, there is no need to > > inject the corresponding 'page ready' event as the guest may get > > confused. E.g. Linux thinks that the corresponding 'page not present' > > event wasn't delivered *yet* and allocates a 'dummy entry' for it. > > This entry is never freed. > > > > Note, 'wakeup all' events have no corresponding 'page not present' > > event and always get injected. > > > > s390 seems to always be able to inject 'page not present', the > > change is effectively a nop. > > > > Suggested-by: Vivek Goyal <vgoyal@xxxxxxxxxx> > > Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> > > --- > > arch/s390/include/asm/kvm_host.h | 2 +- > > arch/s390/kvm/kvm-s390.c | 4 +++- > > arch/x86/include/asm/kvm_host.h | 2 +- > > arch/x86/kvm/x86.c | 7 +++++-- > > include/linux/kvm_host.h | 1 + > > virt/kvm/async_pf.c | 2 +- > > 6 files changed, 12 insertions(+), 6 deletions(-) > > > > diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h > > index 3d554887794e..cee3cb6455a2 100644 > > --- a/arch/s390/include/asm/kvm_host.h > > +++ b/arch/s390/include/asm/kvm_host.h > > @@ -978,7 +978,7 @@ bool kvm_arch_can_dequeue_async_page_present(struct kvm_vcpu *vcpu); > > void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu, > > struct kvm_async_pf *work); > > > > -void kvm_arch_async_page_not_present(struct kvm_vcpu *vcpu, > > +bool kvm_arch_async_page_not_present(struct kvm_vcpu *vcpu, > > struct kvm_async_pf *work); > > Hi Vitaly, > > A minor nit. Using return code to figure out if exception was injected > or not is little odd. How about we pass a pointer instead as parameter > and kvm_arch_async_page_not_present() sets it to true if page not > present exception was injected. This probably will be easier to > read. > > If for some reason you don't like above, atleats it warrants a comment > explaining what do 0 and 1 mean. > > Otherwise both the patches look good to me. I tested and I can confirm > that now page ready events are not being delivered to guest if page > not present was not injected. Why does kvm_arch_async_page_not_present() need to "return" anything? It has access to @work, e.g. simply replace "return true" with "work->notpresent_injected = true".