From patchwork Tue Feb 6 20:30:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10204071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 354D3601A1 for ; Tue, 6 Feb 2018 20:46:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2994428896 for ; Tue, 6 Feb 2018 20:46:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E68D28947; Tue, 6 Feb 2018 20:46:02 +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=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, 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 8910C28896 for ; Tue, 6 Feb 2018 20:46:01 +0000 (UTC) Received: from localhost ([::1]:59832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejA7s-0007N2-HC for patchwork-qemu-devel@patchwork.kernel.org; Tue, 06 Feb 2018 15:46:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ej9tu-0000qu-8J for qemu-devel@nongnu.org; Tue, 06 Feb 2018 15:31:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ej9tq-00038T-Tf for qemu-devel@nongnu.org; Tue, 06 Feb 2018 15:31:34 -0500 Received: from mail-eopbgr00096.outbound.protection.outlook.com ([40.107.0.96]:29741 helo=EUR02-AM5-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 1ej9tq-00037n-3k for qemu-devel@nongnu.org; Tue, 06 Feb 2018 15:31:30 -0500 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; bh=QUdUAVNLoRlGXHLt+wNoTVjjPBIRVw6gHkv0l+GKd0w=; b=YIXTDglFLO0VQxavtaV3BHSYCsIZsgNPlqItOTJky0dZAIXa6wDH0QLgyRGNXxgxU7MSlQ3vyzIYUfgdPr+dTJg2N2xHxvvVL0asW8rnoYjz7hHBjrZnQ329yFdMiJ++AChy04wV6POuYTfJ/9qkKvthC7tikME1uyRLSgAj1OQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; Received: from rkaganb.sw.ru (195.214.232.6) by VI1PR0801MB1983.eurprd08.prod.outlook.com (2603:10a6:800:8a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.464.11; Tue, 6 Feb 2018 20:31:25 +0000 From: Roman Kagan To: qemu-devel@nongnu.org Date: Tue, 6 Feb 2018 23:30:26 +0300 Message-Id: <20180206203048.11096-13-rkagan@virtuozzo.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180206203048.11096-1-rkagan@virtuozzo.com> References: <20180206203048.11096-1-rkagan@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR0301CA0008.eurprd03.prod.outlook.com (2603:10a6:3:76::18) To VI1PR0801MB1983.eurprd08.prod.outlook.com (2603:10a6:800:8a::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5c8b3981-69e6-4b38-f965-08d56da098b9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:VI1PR0801MB1983; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1983; 3:aiUgFP6sSIoze7Fiux26hzMW0SEfb7JUO4nJOrw0jmaHO14ZUYR5sSDhG85gA2SarE57m9N3aUjrOZBLlFg7M2ijuCmXxnQ/thH4DVkfsmskoCgCS7HHy69ZbHsfOIS7r9U76Mk/JFHIrrQOzyD+DKAnbJF3QORJyyep3N6n+L1ARbmfZuFZNsl74LSSSnGoDkkbgIx3WMclsvzLqjXFYXROL3a6Jts5vPYLgaJUg+wL0I+PKLfryYv7G0pY52hh; 25:JKTVcqn1RzEHECFybREUQ+e6fM5DmC8awAGSJegIY4qnzsw0+PtftyowCPlooXmFsZEqslMrIkAMJWDOPLCEFNbx/oWrigb+wLPv2EdeX38yRwUlCtCxBbf1FBB44NvpleOKrmnX9RSrU3gBrLFgHQPbOwKKj1OyI3TCetuPZwDuHzJ0eZS3nPaRZEWQt6IbLdwuOwJHJMz/ud4EBgcPp/kNg06Cms0x7eP9KpzNkjgztbdwEXryyaHOEa4jvUbTecxkE7yt7Cy1KkYMC35MKRA+YY9WvpGBAqb13jwEISCLkOuv2WVlnWP1UfzwoJ1mT5otaSGYyzB2lQBw0/XFpg==; 31:keE3Oe5jrOa85tWb/ZntDtzfA7I37KFmcfEi4FAIjpCvSks9SS4fwKgQB++WRuZfuKk8yH72zPgyBb1I5uhKrOKAqkQ8BaFzKq6QYfqR24VoI4JNzY9cqcAcR2MTIzFYSV9A2O6grOfCI0cIO/SBs3VTl08dmtu7E37sPVVimlaXw0V69T9DaEWE3biFYtjWxkAFGu6YBD46QP0Rs3vMZLkuD2hB2eRjFBhl+CUqsY8= X-MS-TrafficTypeDiagnostic: VI1PR0801MB1983: X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1983; 20:X+weAq4M5xpH2a+Ww9saJ3x/91amcWCN9pACz53kUIC++fw4/SxYX2sWt3VP4yAdJ7wJ6KGSFvWtB7FRWusyHS/n9QBtI6PHO5W0yMlKeBqVdgjdZ09Jj+YDLafQHhAUxKBqCen0pMTgC5wSXAR1F+qzAiFDES1gXWZnKe7WSbxRhSXl0ElQKtrYbDjpH05fWWpMJsjS+qfHJfNttHqz3kUpDIpYhNY8m8is1oeNxhMXPZ0YhDeodKtGfPZTu/7+4xO0OlmWIl97espE920y9fr4PVmhJt8mAnDXMaNwpM++WbetOtOA8Zv0xlvNz6tLvp/1Z6GGsPcLE1KbXeSpPY8GMWCUdzOxH2Bie3ix23qg2t+9PcXmkcMNLU3fTuhUSMkGqKWYihRcnQ4PiL3b6NTdkdJQktWHi5b+mlI6Txg=; 4:PAHy9Mqv1UNb+c+8n1G1zVsY7qk2rzVYcuutM/3iry18nn3hFBNv+UpxGtPM+cNRC7VDk3wjDj9oJiq2PFcMC0cJXKhbI7Djpet1uokQCebTjy5QTzyeaPRl5Wk+hr+6nm+DW6SjiHiJRKeaYbbFq0/Wvy5wo0y8zlexx7sl3Jh6QrHMYjeYiAQ34NWtZtxuXB39h1TbH9rbQil75ZT0ztHwRuIyckvCR10pCjNv6Q1kZr+WJFcVev8LY83+YAeOe2n3qxXz9fpPXdQI12D1pA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231101)(2400082)(944501161)(10201501046)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(6072148)(201708071742011); SRVR:VI1PR0801MB1983; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0801MB1983; X-Forefront-PRVS: 0575F81B58 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(366004)(376002)(39380400002)(39850400004)(346002)(189003)(199004)(16586007)(53936002)(305945005)(54906003)(7736002)(3846002)(316002)(105586002)(2361001)(106356001)(2351001)(6116002)(1076002)(50226002)(8936002)(81156014)(5660300001)(8676002)(81166006)(7416002)(2950100002)(6916009)(76176011)(86362001)(68736007)(66066001)(16526019)(47776003)(50466002)(4326008)(97736004)(26005)(6512007)(51416003)(2906002)(52116002)(386003)(6506007)(59450400001)(48376002)(55236004)(36756003)(53416004)(69596002)(6486002)(478600001)(186003)(25786009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0801MB1983; H:rkaganb.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0801MB1983; 23:POo3XV6tGiDGFUJHzLXPLcPFQgkyaeLE28bUzl/?= =?us-ascii?Q?66URHtI1mNEscGOL+joJJuBuDyTpAfR0ei7HItNbI2mS3UGpYmqsTknKQV+W?= =?us-ascii?Q?lAwsc7b1+OTo+YTL4c+XiRsVhhSWuP6s10iD4rnMF/iwMW12Jvhi85Qwze2Q?= =?us-ascii?Q?UkWPpik5hPOrCx98HDBKEP61SDDjWnpjI4bkkZ1vl/4QddHEdbSI2tQDi5qI?= =?us-ascii?Q?bxFhwm3i80pj1i2U8PbWLfWUxjc4BDfzvQN6oUe2Czk1sc0pfkMiQh/zhHYF?= =?us-ascii?Q?svgu/cYJlyhzzP+inHqinBODC7R1EBzY9pX6uMeQHE+ZpvC2IXLDh2k35oNb?= =?us-ascii?Q?AwOMl1KL8SutQtmRAYgvNFbVmJZHZk7rX3C7zYd34C/qlveqJ4oN5T4qPM/c?= =?us-ascii?Q?49UJ6ytAiL2qmU0nW0k6KtL7v7Sa0UwwqBL5l/09LUf86VnhzvG+35pqDTix?= =?us-ascii?Q?9S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801MB1983; 6:+XV8LvF6ssv/IkcfvMisM6K45Ssvtea2g4xLYNMpuClJ8u5oFpE4QfjJj2/UcYQKSmnmysfQENIMDs64cap5hkIeItBK4Y6M3/iYlXo1Yv087V6UEoRapiesT2pVtV+90QzuA0RLA8HHkAmnkWu0WSSDdzUHWCwfejEVslh2FrCb3YoroWtGp2Mblt6kKvpRJno+gKU+fTo2siUccH99KQGk1ypVdcXUWPlZL7Yq1rS9G9O3BJHTTkCnwr0oJZxu3Os1Yk8vuBL+Q3KbB/y9wLfLEMT9bSQmtfkHVR193y85KHxxoaRW5MXWP9TSIjMKUig/NR98oX8YO/SDZhvnEx95q8AOAxE95sbETiK+yDo=; 5:1mBSlGeAVqHz9SS4JHM72m7pGFlXG4mwOgbjKXJrHTPX9R6rcSYp27JscmyzQubLvolOMZ85JzoDHcl+Zft1dmcuWctIuDbwSSsDpR7HzyVNWsc0TU38gjPOBHtEgLxFRd0xsNgi33s+SdJGfbxqGemC+SjDdiv9xhvTg+jWvNc=; 24:vVrmTVjpZSFRxezok6h48yeYW20Y3uXH/BlD8GIH7FKomHFkXkxbzMlVJ+SxjQ1rPJ+lhTCX/DShiJ5O/I5+F3BzixbANsT8dIL5fY7GHi0=; 7:YritMpXdXQFVp2UBeEX55gOVrDXLfMT6TSuh5/NO4m95y02MedFAJflUQUMgoFsEuNNaFMHElS2QA+e7+7XLij46/2vchEeVNUWec2iHa1MJKBwWrYY6T1KrPF9xWto952v3voJGZGyrPg3D9BkfiC/8/Y6NwuEnOtQ1jkNS09fmOVn0MEBoBBDc5rGbMNYm/u0T1qYrXWK7UaLsDoWLkJ02cFrXBmXm3RoOejGoMSFejYAbjqmAew/1mknkSoEK SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1983; 20:nE3gFzONcskGpyLy1qHlD57bx0X20kyHEpJApd4nwYJ1XngwneUf84lmQ4rjwqBoIQjtIgDJq2H5JtX7OgdEYKN6KgG5+PLYsOyWHv+qWFjoqkCwNzm/V6E9OoywVMF6hmVZKRCVQD5HckJntrxu+CUW7ZjOLrxtcRdX6DHkZuM= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2018 20:31:25.2156 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c8b3981-69e6-4b38-f965-08d56da098b9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1983 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.0.96 Subject: [Qemu-devel] [RFC PATCH 12/34] 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: Ben Warren , Konrad Rzeszutek Wilk , Krish Sadhukhan , "Marcos E. Matsunaga" , Jan Dakinevich , Vadim Rozenfeld , "Denis V. Lunev" , si-wei liu , Paolo Bonzini , Vitaly Kuznetsov , Cathy Avery 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 --- target/i386/hyperv.h | 2 ++ target/i386/hyperv.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/target/i386/hyperv.h b/target/i386/hyperv.h index df17d9c3b7..3d942e5524 100644 --- a/target/i386/hyperv.h +++ b/target/i386/hyperv.h @@ -41,4 +41,6 @@ bool hyperv_synic_usable(void); int hyperv_post_msg(HvSintRoute *sint_route, struct hyperv_message *msg); +int hyperv_set_evt_flag(HvSintRoute *sint_route, unsigned evtno); + #endif diff --git a/target/i386/hyperv.c b/target/i386/hyperv.c index 918ba26849..b557cd5d5d 100644 --- a/target/i386/hyperv.c +++ b/target/i386/hyperv.c @@ -18,6 +18,7 @@ #include "hw/qdev-properties.h" #include "exec/address-spaces.h" #include "sysemu/cpus.h" +#include "qemu/bitops.h" #include "migration/vmstate.h" #include "hyperv.h" #include "hyperv-proto.h" @@ -209,6 +210,37 @@ int hyperv_post_msg(HvSintRoute *sint_route, struct hyperv_message *src_msg) return 0; } +/* + * Set given event flag for a given sint on a given vcpu, and signal the sint. + */ +int hyperv_set_evt_flag(HvSintRoute *sint_route, unsigned evtno) +{ + int ret; + SynICState *synic = sint_route->synic; + unsigned long *flags, set_mask; + unsigned set_idx; + + if (evtno > HV_EVENT_FLAGS_COUNT) { + return -EINVAL; + } + if (!synic->enabled || !synic->evt_page_addr) { + return -ENXIO; + } + + set_idx = BIT_WORD(evtno); + set_mask = BIT_MASK(evtno); + flags = synic->evt_page->slot[sint_route->sint].flags; + + if ((atomic_fetch_or(&flags[set_idx], set_mask) & set_mask) != set_mask) { + memory_region_set_dirty(&synic->evt_page_mr, 0, + sizeof(*synic->evt_page)); + ret = kvm_hv_sint_route_set_sint(sint_route); + } else { + ret = 0; + } + return ret; +} + static void async_synic_update(CPUState *cs, run_on_cpu_data data) { SynICState *synic = data.host_ptr;