From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH v9 2/2] kvm: x86: hyperv: guest->host event signaling via eventfd Date: Thu, 1 Feb 2018 15:52:19 +0100 Message-ID: <20180201145219.GB26932@flask> References: <20180201134832.17259-1-rkagan@virtuozzo.com> <20180201134832.17259-3-rkagan@virtuozzo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, Paolo Bonzini , "Denis V. Lunev" , Konrad Rzeszutek Wilk , Vitaly Kuznetsov , David Hildenbrand To: Roman Kagan Return-path: Received: from mx1.redhat.com ([209.132.183.28]:44308 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751547AbeBAOwi (ORCPT ); Thu, 1 Feb 2018 09:52:38 -0500 Content-Disposition: inline In-Reply-To: <20180201134832.17259-3-rkagan@virtuozzo.com> Sender: kvm-owner@vger.kernel.org List-ID: 2018-02-01 16:48+0300, Roman Kagan: > In Hyper-V, the fast guest->host notification mechanism is the > SIGNAL_EVENT hypercall, with a single parameter of the connection ID to > signal. > > Currently this hypercall incurs a user exit and requires the userspace > to decode the parameters and trigger the notification of the potentially > different I/O context. > > To avoid the costly user exit, process this hypercall and signal the > corresponding eventfd in KVM, similar to ioeventfd. The association > between the connection id and the eventfd is established via the newly > introduced KVM_HYPERV_EVENTFD ioctl, and maintained in an > (srcu-protected) IDR. > > Signed-off-by: Roman Kagan > Reviewed-by: David Hildenbrand > --- Queued, thanks. > diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt > index fc3ae951bc07..3a3fbcc3377d 100644 > --- a/Documentation/virtual/kvm/api.txt > +++ b/Documentation/virtual/kvm/api.txt > @@ -3449,6 +3449,37 @@ array bounds check and the array access. > These fields use the same bit definitions as the new > H_GET_CPU_CHARACTERISTICS hypercall. > > +4.110 KVM_HYPERV_EVENTFD > + > +Capability: KVM_CAP_HYPERV_EVENTFD > +Architectures: x86 > +Type: vm ioctl > +Parameters: struct kvm_hyperv_eventfd (in) > + > +This ioctl (un)registers an eventfd to receive notifications from the guest on > +the specified Hyper-V connection id through the SIGNAL_EVENT hypercall, without > +causing a user exit. I've added: + SIGNAL_EVENT hypercall with non-zero event flag number + (bits 24-31) still triggers a KVM_EXIT_HYPERV_HCALL VM exit. We might have to extend the interface to optimize this case in the future, but at least it's not going to bug. > diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h > @@ -934,6 +934,7 @@ struct kvm_ppc_resize_hpt { > #define KVM_CAP_S390_AIS_MIGRATION 150 > #define KVM_CAP_PPC_GET_CPU_CHAR 151 > #define KVM_CAP_S390_BPB 152 > +#define KVM_CAP_HYPERV_EVENTFD 153 > > #ifdef KVM_CAP_IRQ_ROUTING > > @@ -1363,6 +1364,8 @@ struct kvm_s390_ucas_mapping { > #define KVM_S390_GET_CMMA_BITS _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log) > #define KVM_S390_SET_CMMA_BITS _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log) > > +#define KVM_HYPERV_EVENTFD _IOW(KVMIO, 0xba, struct kvm_hyperv_eventfd) The hypercall number is 0xbd for now. (Might change until the patches get to kvm/next and the capability number is also prone to changing).