From nobody Mon Feb 9 18:00:09 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 1539897116935377.13227846003645; Thu, 18 Oct 2018 14:11:56 -0700 (PDT) Received: from localhost ([::1]:44723 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDFaB-0007BQ-Q9 for importer@patchew.org; Thu, 18 Oct 2018 17:11:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDEyf-0007qF-6l for qemu-devel@nongnu.org; Thu, 18 Oct 2018 16:33:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDEye-0006el-Fz for qemu-devel@nongnu.org; Thu, 18 Oct 2018 16:33:05 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:40231) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDEye-0006eD-9K for qemu-devel@nongnu.org; Thu, 18 Oct 2018 16:33:04 -0400 Received: by mail-wm1-x342.google.com with SMTP id z204-v6so1612001wmc.5 for ; Thu, 18 Oct 2018 13:33:04 -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.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Oct 2018 13:33:02 -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=vFp6Z/8DOHxngKdWxYeLlhUPmR2EJl6drygvUZcPrY4=; b=LVxmRTwAcjZAELVElVQVDqB0tx5oJE6T4I8703UZQL7q8lJvMX34G0XuLl0CZ46s7y 2DFxu0u5qr5y2mIrcwDbE0ioXDp+ZlCNJYNreTI34In1pPYsoJGs+HpdGAKjilG9TXpo vnFQeeDqsrNzidntywZSk3rLyXAwb61k7Cai5DmwL8wDQVGAhr7K/bEHp7zysLvRMVWh 37ieBpjU3jgz4axJ81blJLA/LPlvKsBRQywdxWFD0swFagv396ysma24KaojMrac5jt5 Xur+2k1//bttN+Ppi3jSSpofFR84PDls5gbaML+BGmfLhonhhQNSgbzL41voSdBOju5J eMBw== 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=vFp6Z/8DOHxngKdWxYeLlhUPmR2EJl6drygvUZcPrY4=; b=c2xM0TxPSn7gzWybFeORubbvEYTR7V56v0+homrS/yJ8+jOsjBnAmdPJxriJcqB8Ai 7JehmCMeI7e108aCzzFltDqK6dl2M9osRLHpeOdXfpiwx/g2JFAG4N2OZK2G5nS/azBQ KVxrPQHhArX2r1eirSKfMqy7N9ngfuFKKJ54M1TiD4oRYFQXrnnevzxN9gGFCOSFlj1S QXX7VnL5I9ppxwu1y7gOFJNLxks+UwTCP+f3F8XFb0qFLsmsHHE5Wd9PLGyuH/2Htp4O 4Uo95jHju6+IgzjEYr85TEmrrA7yWrsUClbcFO4u5/OCBLZ70d1nVIkjhPSSLJOBlFSa ImoQ== X-Gm-Message-State: ABuFfojAsRzJjbhgif78uQfpqAsfYrcEKg2+sUTtXWQqkf0sgwWD0OsK 4smsaW+59umIzsH24SWbyY9unC8E X-Google-Smtp-Source: ACcGV60p4jrQTCS7Ktf+M84aGhqzjXeUxguj5yMOqIqfzbJqqP5g3D/2yyfPwXr7RcdfhqvliVuncw== X-Received: by 2002:a1c:b402:: with SMTP id d2-v6mr1899916wmf.37.1539894782963; Thu, 18 Oct 2018 13:33:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 22:32:09 +0200 Message-Id: <1539894735-14232-43-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::342 Subject: [Qemu-devel] [PULL 42/48] hyperv: add synic event flag signaling 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 Add infrastructure to signal SynIC event flags by atomically setting the corresponding bit in the event flags page and firing a SINT if necessary. Signed-off-by: Roman Kagan Message-Id: <20180921082217.29481-7-rkagan@virtuozzo.com> Signed-off-by: Paolo Bonzini --- hw/hyperv/hyperv.c | 32 ++++++++++++++++++++++++++++++++ include/hw/hyperv/hyperv.h | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c index 654ca4f..2b0e593 100644 --- a/hw/hyperv/hyperv.c +++ b/hw/hyperv/hyperv.c @@ -12,6 +12,7 @@ #include "qapi/error.h" #include "exec/address-spaces.h" #include "sysemu/kvm.h" +#include "qemu/bitops.h" #include "hw/hyperv/hyperv.h" =20 typedef struct SynICState { @@ -310,6 +311,37 @@ static void sint_ack_handler(EventNotifier *notifier) aio_bh_schedule_oneshot(qemu_get_aio_context(), sint_msg_bh, sint_rout= e); } =20 +/* + * Set given event flag for a given sint on a given vcpu, and signal the s= int. + */ +int hyperv_set_event_flag(HvSintRoute *sint_route, unsigned eventno) +{ + int ret; + SynICState *synic =3D sint_route->synic; + unsigned long *flags, set_mask; + unsigned set_idx; + + if (eventno > HV_EVENT_FLAGS_COUNT) { + return -EINVAL; + } + if (!synic->enabled || !synic->event_page_addr) { + return -ENXIO; + } + + set_idx =3D BIT_WORD(eventno); + set_mask =3D BIT_MASK(eventno); + flags =3D synic->event_page->slot[sint_route->sint].flags; + + if ((atomic_fetch_or(&flags[set_idx], set_mask) & set_mask) !=3D set_m= ask) { + memory_region_set_dirty(&synic->event_page_mr, 0, + sizeof(*synic->event_page)); + ret =3D hyperv_sint_route_set_sint(sint_route); + } else { + ret =3D 0; + } + return ret; +} + HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint, HvSintMsgCb cb, void *cb_data) { diff --git a/include/hw/hyperv/hyperv.h b/include/hw/hyperv/hyperv.h index 82d561f..757c85e 100644 --- a/include/hw/hyperv/hyperv.h +++ b/include/hw/hyperv/hyperv.h @@ -34,6 +34,10 @@ int hyperv_sint_route_set_sint(HvSintRoute *sint_route); * with the @sint_route; until then no more messages are accepted. */ int hyperv_post_msg(HvSintRoute *sint_route, struct hyperv_message *msg); +/* + * Set event flag @eventno, and signal the SINT if the flag has changed. + */ +int hyperv_set_event_flag(HvSintRoute *sint_route, unsigned eventno); =20 static inline uint32_t hyperv_vp_index(CPUState *cs) { --=20 1.8.3.1