From patchwork Fri Sep 21 08:22:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10609389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3DA9614BD for ; Fri, 21 Sep 2018 09:03:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E29D2DBD5 for ; Fri, 21 Sep 2018 09:03:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 223DD2DBE4; Fri, 21 Sep 2018 09:03:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9B18F2DBD5 for ; Fri, 21 Sep 2018 09:03:33 +0000 (UTC) Received: from localhost ([::1]:54636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3HLZ-0005S6-0m for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 05:03:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3Gi3-0006r7-Dd for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:22:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3Gi0-0002Bw-NU for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:22:43 -0400 Received: from mail-eopbgr70091.outbound.protection.outlook.com ([40.107.7.91]:35048 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3Gi0-00027r-EB for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:22:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aIIgiQo5F7kikKwl6Fy7bkKEpILU9naRbFqsfE2gWYM=; b=X6rc1QkuQPnN/dngLZuSz4GNWHssKINcnWVF5KNfbzKhkjSTUw+OSTPNc7w138TAbgpzk3I9k7HPa8W7J+d8x9sLuE006KP5CQx0PptJSbg8XJqsiJFK0RFKWADLTQoVze8jDbcONWk+1jE++fk5ZELZhc96vsaVAFIP8qQlhwg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; Received: from rkaganb.sw.ru (185.231.240.5) by AM0PR08MB3588.eurprd08.prod.outlook.com (2603:10a6:208:e1::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Fri, 21 Sep 2018 08:22:37 +0000 From: Roman Kagan To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 11:22:13 +0300 Message-Id: <20180921082217.29481-7-rkagan@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921082217.29481-1-rkagan@virtuozzo.com> References: <20180921082217.29481-1-rkagan@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: VI1P193CA0003.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::13) To AM0PR08MB3588.eurprd08.prod.outlook.com (2603:10a6:208:e1::30) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2a739fd5-ba9c-465e-e640-08d61f9b6491 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3588; X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3588; 3:JHA6Ja41BmT5Zhpwm3GpO83S6LLGJWL38mAagV6/S1IOwx/XCVGD0fxP1dgimh/BMxQKGZ9X2PwdMbN5X5uJGLvqd6cTgpzjQTc3ZUWZz0Uy871XujYVFMmyiELvJVNvpsppk/dAtSZ1PuOmThae6hKWIcfdxVTt3duvuFzEy6tfiGxPd/FiScEhqHSG01nEyN90aeu3mtdW/MYLlNL7Kbf0HS5GHiwHBUyGitESpLxz6uGLMj2isK1MVJSrfK7s; 25:wok7aeIS4jsKzTC2+zZ9Ip7GLZSvbJDKA+al0BCgU6oqm0QjnmcEBJjUPZOqRjkdI3coQcgIPB75jMzHbkF1B1M5XgDvuXIQioIuKhvmuGIHg25ahP4O3Byr1aRpW2bkkyQJWuYooKmVcyWp09LWJOf+8mLR+EI/riunxPwyiNOpxf790ctlTpS+BgDXAg728Fp052xozmcN0TDts8hjpzRfjQngAgM5BR6vrVKUWT/WsGzuwj7sBezpB0sKGphQESMkGA2t5V04EDrmgBxk2WFquZ/cXM3nXaS5avloeAB2vGBXjPFdrK2kzuSvWNWgSupl1ZMNVv4hiHJJK/3hQw==; 31:+T7LXBauB+VytmCi7sike3Fk1WJauDPszA3C+rt0a2sRtiww8j5N25qG4na40jVW79AXhn+7noAor1WceXE7I0noyMxEhVnGtSIo1FPQ139w/tHeov/uERiqAXmfwPDDcu9qQqE/UnI+UPdmB3wcQzfcoYDxW7HBWdb7xYUiJ8I5ZvhG+RrxvTAUKozUBuDWdg/oiO2jgOBHMOqvo7/C7RcXhO0kPY1zFCGDJ0K3YPA= X-MS-TrafficTypeDiagnostic: AM0PR08MB3588: X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3588; 20:V7CExiuJbCbIgDlFjjtj932uup+j/rJ3BG8Vn6n3hVCRtRjrumMnbYu6JR4OzHawc1Yh9anBmFmT8iJrAYyXUjtNc7MBUr9ZzFPN6ndQU68o/6aJ/HIlOkvwIIRRJQuuZ/hJQGyjl0CM0SjYLdZqoEfANxOKpW1VQCD/U8iXlPWzFadN8gR8u1snCCydnHs7II0Bm2z6TmI+H1jhAZWDogWjPnwf1AAxFFob0fQ+DtFRaD27ZP7+5NfGcv8HIbBaRRzOds9ywOY8BQ+a3mCAxDIVgQkhwf4HfOVPiOJDdru2WOgu85GcIu6CsilM05RaTTblw2L0QUX1gDQn0K6bv6uOtCSo77pAkbneQH6IiccjOzlgTddzHT6XowTGnwzONkvU7Bs60sB0zdz49JwIUPtvAbBwh/Z+mHri0gLVwsDgh5g6eO68KCPDMh7dZDnQgJx8mNt6aV0LaV/h2mrHVknrBqB96qyJcTQ4zANcUt8LgBMRZgoiFi4yjXL6jpBO; 4:nzwAnxLhQo2bC6OndFUmOGicSesMSfTwL3K98MXMmA3lay86zIRInDCq6lg99ArlZ3D2akNfK5c4utvNbjEAHuY5eTE2AFFoVyxD8F7BWw7JJxdBy1DQk7eXqBSB22a4J8fvy/PyAR2PE1KRyEBtUgDQpDvS7jmiGFEouMijvglMetXAHGl5DWBipTfntXD0/kTpR0/nhufwBWcB0NX81nnqqBJox58iMpzi9l6f7PhZe+Ti4hxHRxEMt7fd76QhtyqiM/SexCtrpcsZYfMxMA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231355)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(201708071742011)(7699051); SRVR:AM0PR08MB3588; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3588; X-Forefront-PRVS: 0802ADD973 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(346002)(136003)(396003)(39850400004)(366004)(376002)(189003)(199004)(6916009)(16526019)(5660300001)(36756003)(3846002)(54906003)(48376002)(6506007)(476003)(486006)(52116002)(446003)(1076002)(76176011)(386003)(51416003)(186003)(6116002)(16586007)(2906002)(66066001)(6512007)(7416002)(50226002)(53936002)(25786009)(106356001)(53416004)(81166006)(47776003)(316002)(956004)(11346002)(2616005)(7736002)(8936002)(305945005)(8676002)(2351001)(105586002)(97736004)(4326008)(86362001)(6666003)(68736007)(478600001)(6486002)(2361001)(50466002)(26005)(69596002)(81156014); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3588; H:rkaganb.sw.ru; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM0PR08MB3588; 23:oQTnBrFAX7v5zKgypIjRlkGotgOpJQvLMZNZpprz0?= gIUNo5keah6A0NDct6YvrEv7CFVqZGrucpuWkC2v+a0m7cks90H8/w5Hwu2ngRqFc4BTWrZNXggq8bUuAe3nBd/zpDhDalth91dy2bVEBAc7LdIwkDnIG7OjAVL0zxwM1ST9a4l3ifzETT8pR9JNm2hmbj5BdrvDGnc6GxKW3wToOj9EeL3OtXNgyzOfcAiMLYCZeRp4BOGfILeisdrs+18Fn7uGh96zOsC2BSJJzjpbcImkZOAOmvJsc8UhjPsw9GHlokGP86ByXRUBtsiAmNWC8fY/EBjEaIGjxltEckLumTJw+GIlmaV+3zDfNdR9R0k6w12Mojt1+1uv/JxwoHGsBukn5ESR7EKwQyTOLEDDbyW/4MDgZnVnLVlar39WltMfjB2QzUp/1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m6PfprDn+cWp4J35iEBb3EBRaqxAQnYjoa6jz+fB6HvX3hrA665oZv/+Xz3F2Fx4PNFVmd1jt1vetVHaq/5rmlJI6RGpxg SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3588; 20:1fRiDyXHPenkQ7TYOqgC4eYoMB05SpNCHO0in+iQLFrFblOkzNUFVBiiwipeRlsEWj12a4MgIcUqkAh3VTF8UarqOTp9zEafiH+t9Sdas+cNPdrvDj46ga4iqo16e1S+DWjsagHpUC9Rnf9axNX1sVFNPmzEa6BPo/GZ4aqL/bg= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2018 08:22:37.6089 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2a739fd5-ba9c-465e-e640-08d61f9b6491 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3588 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.7.91 Subject: [Qemu-devel] [PATCH 06/10] 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: Vijayabhaskar Balakrishna , Eduardo Habkost , Konrad Rzeszutek Wilk , "Michael S. Tsirkin" , Venu Busireddy , Liran Alon , Paolo Bonzini , Si-Wei Liu , Igor Mammedov , Boris Ostrovsky , Karl Heubaum Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- include/hw/hyperv/hyperv.h | 4 ++++ hw/hyperv/hyperv.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/hw/hyperv/hyperv.h b/include/hw/hyperv/hyperv.h index 82d561fc88..757c85eb8f 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); static inline uint32_t hyperv_vp_index(CPUState *cs) { diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c index 21217631dc..0b28e7922c 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" 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_route); } +/* + * Set given event flag for a given sint on a given vcpu, and signal the sint. + */ +int hyperv_set_event_flag(HvSintRoute *sint_route, unsigned eventno) +{ + int ret; + SynICState *synic = 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 = BIT_WORD(eventno); + set_mask = BIT_MASK(eventno); + flags = synic->event_page->slot[sint_route->sint].flags; + + if ((atomic_fetch_or(&flags[set_idx], set_mask) & set_mask) != set_mask) { + memory_region_set_dirty(&synic->event_page_mr, 0, + sizeof(*synic->event_page)); + ret = hyperv_sint_route_set_sint(sint_route); + } else { + ret = 0; + } + return ret; +} + HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint, HvSintMsgCb cb, void *cb_data) {