From nobody Mon Feb 9 16:34:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539898819715850.3085875807953; Thu, 18 Oct 2018 14:40:19 -0700 (PDT) Received: from localhost ([::1]:44903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDG1i-0006Vh-LK for importer@patchew.org; Thu, 18 Oct 2018 17:40:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDEyh-0007t2-Gr for qemu-devel@nongnu.org; Thu, 18 Oct 2018 16:33:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDEyg-0006gZ-PR for qemu-devel@nongnu.org; Thu, 18 Oct 2018 16:33:07 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:41688) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDEyg-0006fw-Gz for qemu-devel@nongnu.org; Thu, 18 Oct 2018 16:33:06 -0400 Received: by mail-wr1-x442.google.com with SMTP id q7-v6so7267051wrr.8 for ; Thu, 18 Oct 2018 13:33:06 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-231-174.clienti.tiscali.it. [78.12.231.174]) by smtp.gmail.com with ESMTPSA id a12-v6sm14270952wrr.71.2018.10.18.13.33.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Oct 2018 13:33:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=oyn64lGyGVgvvvzaMFhf2Q5Z5Ewc9fa5jWvtrY5hbpA=; b=JF0wwh14tI0b9G3QDb9znHHsCfany9GCECYQMu3IPHU+yG4W1fh0i7F3Hgh4VtXE86 X+zwu0bsLTHfO6keH1B6sVsUOgnMHoj6w6UA2tW+QqTagYK9D+W1gh+vUmc3ZcCMy0Pq 82Bq8vw6BqlWDEFJZMYH1Vogb5k3KIuJY5K1GNZANM6CtiIEBnygKlgmsWAivgthniv9 Ko9Yr9SZZOONvWcuviqQ/MAyTbYolDbjVAimMXppIiCmDbKeVX4UeAF0ScWA4yu1a8bc 066uut7K9L8EIZTIySqz1z3qfM7NSXtZFPxXApqTT2AXnPE+Y+77Bofz/m+bEUwlzT4F UVqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=oyn64lGyGVgvvvzaMFhf2Q5Z5Ewc9fa5jWvtrY5hbpA=; b=FBSSKiYMXYxjia39J1W5GLcXb4+Ft78SC2BaWpNFkENN0F9vy9KVqT8dp5Gyrp/gLy dyPa+D/Lz2LUQuXVpjgRB+ci8JbcTtoqEcOVQ/5F6mTNiupFSSHdoPFf2e2etbXAqqxn fxbJMAwUsdvSPOCShL1RPybJMvDFdmPZqOHfIhUYzQGY2DZoMWRFFXeYzcY2Z4cnCZVS lMLe98JCWZ9eIwgiqTnc/Dg65fghXyFOizA+ok3u2fueE0KLWBCaXI6mOgzq1KtRIrRI 2WjPZMffe6eaIkLVH5olryWqEIFsCypdPDs/eOMOio5q/hFr7w2gq072YLoQ1WoZDZw+ kTQw== X-Gm-Message-State: ABuFfohQg1LEMTWfhL1G5pGI3pFx8vsoWeWNzyIoeJKrYPgvsAB3ibEB uZ0KJqdTfkn088DybYKEptxZVfnQ X-Google-Smtp-Source: ACcGV60LPTdPeDevPWaQgTPI4Tpf2EF65/aQYnHWf4pRJdbN/itO8MwO2GrNd4fPj85rB8AuaojUug== X-Received: by 2002:a5d:6a11:: with SMTP id m17-v6mr31435732wru.192.1539894785228; Thu, 18 Oct 2018 13:33:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 22:32:11 +0200 Message-Id: <1539894735-14232-45-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1539894735-14232-1-git-send-email-pbonzini@redhat.com> References: <1539894735-14232-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PULL 44/48] hyperv: add support for KVM_HYPERV_EVENTFD X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Kagan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Roman Kagan When setting up a notifier for Hyper-V event connection, try to use the KVM-assisted one first, and fall back to userspace handling of the hypercall if the kernel doesn't provide the requested feature. Signed-off-by: Roman Kagan Message-Id: <20180921082217.29481-9-rkagan@virtuozzo.com> Signed-off-by: Paolo Bonzini --- hw/hyperv/hyperv.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c index d745016..7a1c1bb 100644 --- a/hw/hyperv/hyperv.c +++ b/hw/hyperv/hyperv.c @@ -13,6 +13,7 @@ #include "exec/address-spaces.h" #include "sysemu/kvm.h" #include "qemu/bitops.h" +#include "qemu/error-report.h" #include "qemu/queue.h" #include "qemu/rcu.h" #include "qemu/rcu_queue.h" @@ -470,7 +471,7 @@ static void __attribute__((constructor)) hv_init(void) qemu_mutex_init(&handlers_mutex); } =20 -int hyperv_set_event_flag_handler(uint32_t conn_id, EventNotifier *notifie= r) +static int set_event_flag_handler(uint32_t conn_id, EventNotifier *notifie= r) { int ret; EventFlagHandler *handler; @@ -503,6 +504,30 @@ unlock: return ret; } =20 +static bool process_event_flags_userspace; + +int hyperv_set_event_flag_handler(uint32_t conn_id, EventNotifier *notifie= r) +{ + if (!process_event_flags_userspace && + !kvm_check_extension(kvm_state, KVM_CAP_HYPERV_EVENTFD)) { + process_event_flags_userspace =3D true; + + warn_report("Hyper-V event signaling is not supported by this kern= el; " + "using slower userspace hypercall processing"); + } + + if (!process_event_flags_userspace) { + struct kvm_hyperv_eventfd hvevfd =3D { + .conn_id =3D conn_id, + .fd =3D notifier ? event_notifier_get_fd(notifier) : -1, + .flags =3D notifier ? 0 : KVM_HYPERV_EVENTFD_DEASSIGN, + }; + + return kvm_vm_ioctl(kvm_state, KVM_HYPERV_EVENTFD, &hvevfd); + } + return set_event_flag_handler(conn_id, notifier); +} + uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast) { uint16_t ret; --=20 1.8.3.1