From patchwork Fri Sep 21 08:22:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10609401 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 5E3F514BD for ; Fri, 21 Sep 2018 09:09:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D25A2D607 for ; Fri, 21 Sep 2018 09:09:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4107B2D60E; Fri, 21 Sep 2018 09:09:15 +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 92E0B2D607 for ; Fri, 21 Sep 2018 09:09:14 +0000 (UTC) Received: from localhost ([::1]:54672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3HR3-0002FM-HH for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 05:09:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3Gi6-0006xv-Lo for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:22:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3Gi3-0002Kl-Bv for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:22:46 -0400 Received: from mail-eopbgr70119.outbound.protection.outlook.com ([40.107.7.119]:27680 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 1g3Gi2-0002FC-To for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:22:43 -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=M/ORs6XTTAgnTGUzG+ja1vmx6QNcaXwB/S7aaxRlaxM=; b=RbfBZwZ+NVHb1Abj5ykBMtUvoOx7eTGIagD56ULS1djCqRvtnTJD/ea7OnkOIg6alTC3i7JUSVQn0NkI5x8xMCmoLskp1wiE6UIvnxn3SmtM6CmiYojJ6pnznQF/HWVxIy1welC8NgjTDJOXOBDYYT3KEX/xFzB07MSCsVDLA8E= 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:39 +0000 From: Roman Kagan To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 11:22:14 +0300 Message-Id: <20180921082217.29481-8-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: 46e4ba1b-bfd1-4dd7-d5bb-08d61f9b659c 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:rNmx+0DYw4Hfw50MtdHi6rUsjwwmLDLUqQ/T75IboljK/ilzx6qli9/GsP0DW2GqcEDYkhKfJQn1ZAyGydsS3bDnlRdGx/1Ik9dVaAc6ZYf2MPVrXmo0iJgiKRE5LnSLD30WK3lwllM37rQPDAxokitvghK19hg6k/dGuqGnUhfv0AbIuYBWn8+zlJgg5tmJKCRVZi94Wghmb1/2CtWb/6BVWxj7yWdNqEKR7nYwuYSgcikZ2qvEFbtFOUVcry6v; 25:oHJvMrSjlW0IGC+KIPnEhpKJtXRGf7vs9Xk/KRyeRm5lpmIHuMGoFaHWgLZ6Me58YxF/eciVqHvjL+H1+2daUlRmIPtXAV5UJmummKa5vrq00P7yuMtNLNN5OKy3+mimx8yhLfFv40uBQqqXBwI92NGJh/xaB4sQdZfYQ7gZzPMxz3HHes1Pnb1K6CM1Y8a1Ojx7fIWZhv3c8QHoPA4iBxYZq2GzVgvJqWFHAitL3836zqP1ivbzafI976YO0JvPUjKcW3eg+wDcMt94duzBuguF+cgqhnNZgpPRg2EbjOddk1pyQpZWiFh+B7dI6K+91hPLN4QzmdbNGrgK4cjACQ==; 31:GEa4alUqwlM1VwGqauK+bXGIfHfo0OCA1CEqFDf1lMjjgEaRTEHTFtci1khNFBNCy1h+kNg2434jDO+8Be3TXAFdGoikOFAEXJU/GYMU37LwvUOMl399DzJNuyj4GHnZhsoGylEhaYqWsgmssgHJmaVBfz9hlxq0l9XYlYgY8bRTH3POQgX/dBld2oQz7trvaFUNEBh2Oe3h5seWlI+WGC0WsLC8abgn5lnnpvbr1mE= X-MS-TrafficTypeDiagnostic: AM0PR08MB3588: X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3588; 20:ZACeePlqaNmxauPXJq580FijFWFHxE9woX8rX7BFXv+Y+3AB3PTjMdz+BKx7BcXlqi38SlgRdz8TpHgf6ww48C6HMkja0bl1yRUBCZnTdPEOqhmm131Yu2T/zsW1yYYGVI6KehIYQ87ksKtMpOTqJbEuwWqc6RBPwblr2mZHPy35L0RQfhqz73q9dWss+5mu7HvZsQ5ihzoCL2Ss4+MNM0e8rjO072HqC4xw48h7IqcYsWkO1/wLXPW3nDZ8nPLyu6kby4avavHyL4XZxCqeVDIi9GtyXuMB4PlfdE0hPZQuUh85GAY7uuHfyDz73BFAtwiObDcKU1r34L7vE6+cfgsVgxjEjfNpn69WfOKntSnFvE1T3B4T+wZfBr4HwNbDWIINq5s0e+DQD8jQjLKs5pLOiYD92EcyCP+I1oNrafzMq9oyhhJ3BQJY3JD3+/dFMZJARFKhRtNnOjxRMKlle7lm3psBYGJVNq+ly2ppHUd816BpYMpnppmUAqxaAf32; 4:9aPI8WpacxFfGSLKBrA9Z8et5WAvKR/4YXIrKCuMJwLrK+AkKWHynvrklcIVIZCega0UnHk307upE4ZUK6b4yNLwB2hmCIDlBbFYwtoq7OirODXEtRGH1Ouk+fNbraU9RXEzN+ZUnmNfADxcQsPbx+eIDyJmONWmX10ktKyOhHmRGlhe5MXwK0bKNWKQSLBUAavng8VEnMddcNWn+vLs1LhSd6CPzW7soYuDHADpWrBaBwMumkbZnV75VLmQbSoiB0icikIpYKEoHChvv5yfFw== 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)(14444005)(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:yL9wgCnSxGF4MDQM3aUOnuSNvw30Pz1uCO9kyWjIB?= JDR+qHWAeTYv4uEFH4FZquJWTB1+XM3YnoLtyLLl1HbBC52gfkhWidKgiKZJZC+12yMqDmg5OakgTidnKedHeans+kmJuPh9H3zpnFZt3BlxUBgBH7LFt/mWtOZ4TBHwWE2TPPXSAH26jViBhVJFQ2E8Veoe8IfbjWXo59PAQRU6d7Qp2tKw/SC8zsfS56mFxAaPnw+iIDZxaz894XFGwzADPMyTWSSAeBxhvzTvGiE41XeHNzfA+gYxaMcmp3JcXg1ox1dIMQYTIKO1+E9uQYhXjqFc4iQSP/FOnfGlXbfPgHOyyf9YHTrkfaF20f42PYoKFqF5XwfdA3rG1PujQogeyn/dEBmLjTqvvXpr/vC77kWbdJ8LlkYkImV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HGO4hkiTRSbwnGuM2PMWJAo7ngJ3zAoG+J2zw2co5p0FOlS6occtUJffIcbslZ0IwntBnNYKi6YwELA+moG9ZJLY483otzm SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3588; 20:lLumOwYRymxrdzXUNt9mVYIb7jzdvOWosWaUd67j9pZTXhU81lCEoAMHYT9MGG60IGs3xxbNAzWJPNRYSgZcEHFTsaq99gSi+G6t/N2LanAnQ2y0iUOvbI/MPhapsZl7YXxxgSAVwgaWIe186GWITHJH5ZzXWCTKSl0yeppbvyE= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2018 08:22:39.3426 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 46e4ba1b-bfd1-4dd7-d5bb-08d61f9b659c 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.119 Subject: [Qemu-devel] [PATCH 07/10] hyperv: process SIGNAL_EVENT hypercall 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 handling of SIGNAL_EVENT hypercall. For that, provide an interface to associate an EventNotifier with an event connection number, so that it's signaled when the SIGNAL_EVENT hypercall with the matching connection ID is called by the guest. Support for using KVM functionality for this will be added in a followup patch. Signed-off-by: Roman Kagan --- include/hw/hyperv/hyperv-proto.h | 1 + include/hw/hyperv/hyperv.h | 13 +++++ hw/hyperv/hyperv.c | 93 ++++++++++++++++++++++++++++++++ target/i386/hyperv.c | 10 ++-- 4 files changed, 113 insertions(+), 4 deletions(-) diff --git a/include/hw/hyperv/hyperv-proto.h b/include/hw/hyperv/hyperv-proto.h index 2dc78eeafb..21dc28aee9 100644 --- a/include/hw/hyperv/hyperv-proto.h +++ b/include/hw/hyperv/hyperv-proto.h @@ -21,6 +21,7 @@ #define HV_STATUS_INVALID_ALIGNMENT 4 #define HV_STATUS_INVALID_PARAMETER 5 #define HV_STATUS_INSUFFICIENT_MEMORY 11 +#define HV_STATUS_INVALID_PORT_ID 17 #define HV_STATUS_INVALID_CONNECTION_ID 18 #define HV_STATUS_INSUFFICIENT_BUFFERS 19 diff --git a/include/hw/hyperv/hyperv.h b/include/hw/hyperv/hyperv.h index 757c85eb8f..df92ed7e66 100644 --- a/include/hw/hyperv/hyperv.h +++ b/include/hw/hyperv/hyperv.h @@ -39,6 +39,19 @@ int hyperv_post_msg(HvSintRoute *sint_route, struct hyperv_message *msg); */ int hyperv_set_event_flag(HvSintRoute *sint_route, unsigned eventno); +/* + * Associate @notifier with the event connection @conn_id, such that @notifier + * is signaled when the guest executes HV_SIGNAL_EVENT hypercall on @conn_id. + * If @notifier is NULL clear the association. + */ +int hyperv_set_event_flag_handler(uint32_t conn_id, EventNotifier *notifier); + +/* + * Process HV_SIGNAL_EVENT hypercall: signal the EventNotifier associated with + * the connection as specified in @param. + */ +uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast); + static inline uint32_t hyperv_vp_index(CPUState *cs) { return cs->cpu_index; diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c index 0b28e7922c..5bb5126393 100644 --- a/hw/hyperv/hyperv.c +++ b/hw/hyperv/hyperv.c @@ -13,6 +13,9 @@ #include "exec/address-spaces.h" #include "sysemu/kvm.h" #include "qemu/bitops.h" +#include "qemu/queue.h" +#include "qemu/rcu.h" +#include "qemu/rcu_queue.h" #include "hw/hyperv/hyperv.h" typedef struct SynICState { @@ -450,3 +453,93 @@ int hyperv_sint_route_set_sint(HvSintRoute *sint_route) { return event_notifier_set(&sint_route->sint_set_notifier); } + +typedef struct EventFlagHandler { + struct rcu_head rcu; + QLIST_ENTRY(EventFlagHandler) link; + uint32_t conn_id; + EventNotifier *notifier; +} EventFlagHandler; + +static QLIST_HEAD(, EventFlagHandler) event_flag_handlers; +static QemuMutex handlers_mutex; + +static void __attribute__((constructor)) hv_init(void) +{ + QLIST_INIT(&event_flag_handlers); + qemu_mutex_init(&handlers_mutex); +} + +int hyperv_set_event_flag_handler(uint32_t conn_id, EventNotifier *notifier) +{ + int ret; + EventFlagHandler *handler; + + qemu_mutex_lock(&handlers_mutex); + QLIST_FOREACH(handler, &event_flag_handlers, link) { + if (handler->conn_id == conn_id) { + if (notifier) { + ret = -EEXIST; + } else { + QLIST_REMOVE_RCU(handler, link); + g_free_rcu(handler, rcu); + ret = 0; + } + goto unlock; + } + } + + if (notifier) { + handler = g_new(EventFlagHandler, 1); + handler->conn_id = conn_id; + handler->notifier = notifier; + QLIST_INSERT_HEAD_RCU(&event_flag_handlers, handler, link); + ret = 0; + } else { + ret = -ENOENT; + } +unlock: + qemu_mutex_unlock(&handlers_mutex); + return ret; +} + +uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast) +{ + uint16_t ret; + EventFlagHandler *handler; + + if (unlikely(!fast)) { + hwaddr addr = param; + + if (addr & (__alignof__(addr) - 1)) { + return HV_STATUS_INVALID_ALIGNMENT; + } + + param = ldq_phys(&address_space_memory, addr); + } + + /* + * Per spec, bits 32-47 contain the extra "flag number". However, we + * have no use for it, and in all known usecases it is zero, so just + * report lookup failure if it isn't. + */ + if (param & 0xffff00000000ULL) { + return HV_STATUS_INVALID_PORT_ID; + } + /* remaining bits are reserved-zero */ + if (param & ~HV_CONNECTION_ID_MASK) { + return HV_STATUS_INVALID_HYPERCALL_INPUT; + } + + ret = HV_STATUS_INVALID_CONNECTION_ID; + rcu_read_lock(); + QLIST_FOREACH_RCU(handler, &event_flag_handlers, link) { + if (handler->conn_id == param) { + event_notifier_set(handler->notifier); + ret = 0; + break; + } + } + rcu_read_unlock(); + return ret; +} diff --git a/target/i386/hyperv.c b/target/i386/hyperv.c index 3f76c3e266..96b3b5ad7f 100644 --- a/target/i386/hyperv.c +++ b/target/i386/hyperv.c @@ -79,16 +79,18 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit) return 0; case KVM_EXIT_HYPERV_HCALL: { - uint16_t code; + uint16_t code = exit->u.hcall.input & 0xffff; + bool fast = exit->u.hcall.input & HV_HYPERCALL_FAST; + uint64_t param = exit->u.hcall.params[0]; - code = exit->u.hcall.input & 0xffff; switch (code) { - case HV_POST_MESSAGE: case HV_SIGNAL_EVENT: + exit->u.hcall.result = hyperv_hcall_signal_event(param, fast); + break; default: exit->u.hcall.result = HV_STATUS_INVALID_HYPERCALL_CODE; - return 0; } + return 0; } default: return -1;