From patchwork Fri Sep 21 08:22:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10609399 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 43D1514BD for ; Fri, 21 Sep 2018 09:09:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 329432D607 for ; Fri, 21 Sep 2018 09:09:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2632C2D60E; Fri, 21 Sep 2018 09:09:05 +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 CE6042D607 for ; Fri, 21 Sep 2018 09:09:03 +0000 (UTC) Received: from localhost ([::1]:54671 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3HQt-00026h-3l for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 05:09:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3Gi9-00071M-VV for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:22:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3Gi6-0002WV-PX for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:22:49 -0400 Received: from mail-eopbgr70095.outbound.protection.outlook.com ([40.107.7.95]:44383 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 1g3Gi6-0002SR-9M for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:22:46 -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=wN1p1Xr5Kx/LPgFjCj5+vEKWWv+jadY9tsv6qSyIKuE=; b=gF1dBBu0Jc4keWsFJ1MeVoNBxcovxTAXCzTmB/zMaRNfVJt5WPDL1f8TlVDLlOjmue+S0/tOe91W4x+4I8CP5mNJFpZvdBLaSlZZCigV9UdeUEhUMlhV07gPZzZQXwxPqOHksdpYRSL613q0bD9ETb9tNTu8oduHmFwrvwJjads= 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:42 +0000 From: Roman Kagan To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 11:22:16 +0300 Message-Id: <20180921082217.29481-10-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: 3099dd71-67c3-4610-e002-08d61f9b679a 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:fxNOhD4/6VbRVagiDSwNKmPet/UblddNNq2uzvTpXTvzx4L+esTF8/GILW5WDWSEPtW/AbliE/kwbTfhuy8wpUFnXFLkVanroQRaqQFWB4qLk/mp7F5v7PuM3mB4sn7yDHpycCRsPY2fqIv13o3k8Htxz5N0p5+DeT68RvPYDfqkIRatYMdGP/I+nhaaybIjCs5l3hzlXKISc6936sHIZJjKP0tTO6mUMQ0BwArPOdtxN9uowAH7XaptEZpImYO6; 25:3xTvFoD9fJ7aPbLsYR73Snh6kzRUK0ikhRuYABIaizxlmsIdm8aO2crLd7K5AIxBmzhbLJRkVie0kccf9+e8Y4rVO2F26wAICKDckitvkYZhksZ1uTAmGbTJTUd2BwvGDG1QNsGrKmC1mWuUklmB7ak8n1fK8/doA1ROe/OB14aE88R3YEDdTCaRtytxdVuacM6Pb90gqqGv+PcQAC6BS7d7uKMNQA1G/QL1NY9KkvlC5y2X3fMlnf7+p00A0n4Q2Ct46M1/pQ6DMdUmChX/iTp4q/tyN09hpn/2K1iprxvXW/Exzg3+sG9Tj9TmaaXCbvku9jCsA6vHOxdA0l+5iw==; 31:c2rZUleBgsBB4AMVSkQND2hhuYFOPair03xFJKM+BysXdvxDxOfhxKFKFthH326HqLEwn8jlK36P+vF9dNUczArakdZZwZbGTWJsyVPnhuHk/ObqaXTTrIbzpWBSkYIpMN/Ngr4NS+XX3vWhYNzcYceoYZTXoL8wMwJU0fwKjs1pSbPaPcQ0xR9C6DH2s4M3YEkAISkg5Fc72Gh3AsHgdt6SBmtB4rQcmhBBtwELvxk= X-MS-TrafficTypeDiagnostic: AM0PR08MB3588: X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3588; 20:kEeSRZ/LQSPaIGGi1Zf+2LghTjw9/48DA/r3CfMV12rlShXxEG+J5OV5EIvwCzykec0/sajjvCyF5E65iyGUnNuy4GIyqT1AsGpCMCkvBXw5UeQO6jNY/jAPJVgzYivjA8wdmArIRfh4Af2oI3IQy7IggTlKe6Zlxh7QBstlCT660rPnl8OnqHqH1vkv7STPXsZdGCWL0tumrESuVyavRw9JvdR0dYcF1wBjRgEnLkHMKN9HmZ8yBPESbQ98kE7lB4zunQiWlUr8XKcDPtokQPJBtRSu5pomAOH8TCPC2HLXyD6wAK1fMZdmah2nHMRdctjiMYrxQ+bOS551ovjjdeyJ6ibsLzVem/tHRCAmP8q1gpEIJOXRXMO7I7x/3shdpZf9UtuAQ/PhqXB3eUSWJHGoDNBQGPbbh0ZsO6v6JFAJO+XRdUI+xsNu5a3idj5dnraH+zfdypJb/0sEqJSMlhDwklAEZ/rmhhCiLhB+ntNWYFTDphO/OAs8edTww3D0; 4:omDUbcd88KPIOqsnAug+1mB1u5tcnlOK92ojd9kgqR39zOMOplYbnCNgZMWXgAhmoR+oK80rGj/ORLd/PD91ZeNu/F9wKx8H/5Z4+7CvAfW/En3hBNawdtfvU4pZ9dF7/v7fGTyieIQ7JSesnxGsUhJC4E9sxXER8qWTHjbSaX/OvakpsT8pJLPON/P+lyXUQcouyiHZHUXoI7h3hUfN5GuoWvjhHe1Dwf3LKlQoa9CrTATmJdDMvKGdmgzcmagNRSnlJsU8eeyhAzQK/2zlqA== 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:bSWJz3pB+y4TkYEYE+F1SNcLpPoPc5h0fnd+UwE+T?= UCugx/P59IOY8hZ2EW8OVi9tC3YYHMRetSKOO+QMNczNsJRf1V/i9ttXm4g2CGPxDjZB/RaKWzTa4qcJ8aaJ3wh3iasKHnOq7WGH4KJ4dUbrGRbnbLzseH93q63M2qxhPBfx/8InOxh+96SbNUpRXDq5lay6QWwI0VEwu1K3gbT+AgUIIFjd8a7VHw4NHQljjbBA8YlW34Y+RTc2WTNamVmhMTX3XdZFUQXZ1M00zAso15WSgs4BGLGMJsPLap47eh+e8D6XJW+D6lvktvS7gPux7SvBQy0+Kf3YZ4g72/aLFbkAPKDT7JXW5yJy37qGyDXrtcTNtnbyPJupPH3u0tngigt7d+E7JOF65GFCBRbQfC7GIEp/rAUDi8+y0HSvmCG7l43e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XVc/a2J2LrLYt6/XmDbsgVzZcXSN4G3H/T4tbLWEByQkqj+qt9ypw4hI53EMNDIKSlX2uU49Fk96/tqDE239 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3588; 20:puB583PLxKGZ6j6sXEGDuqoEIu+kWqI8cC6oeKDzqSKGYjIrCL5ONlHpVN7Vjp8cg+sTSz8pjnZkH/rOnm6vQALULy7/1jvt2+oTkK7jXjnhjcpmbV/ScV7I79KEKtRJ/ledEsUvKm1DItis3Mdq8nKedsy8y+wLIfJf8O1+GAg= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2018 08:22:42.6852 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3099dd71-67c3-4610-e002-08d61f9b679a 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.95 Subject: [Qemu-devel] [PATCH 09/10] hyperv: process POST_MESSAGE 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 POST_MESSAGE hypercall. For that, add an interface to regsiter a handler for the messages arrived from the guest on a particular connection id (IOW set up a message connection in Hyper-V speak). Signed-off-by: Roman Kagan --- include/hw/hyperv/hyperv.h | 18 ++++++++ hw/hyperv/hyperv.c | 84 ++++++++++++++++++++++++++++++++++++++ target/i386/hyperv.c | 3 ++ 3 files changed, 105 insertions(+) diff --git a/include/hw/hyperv/hyperv.h b/include/hw/hyperv/hyperv.h index df92ed7e66..597381cb01 100644 --- a/include/hw/hyperv/hyperv.h +++ b/include/hw/hyperv/hyperv.h @@ -39,6 +39,18 @@ int hyperv_post_msg(HvSintRoute *sint_route, struct hyperv_message *msg); */ int hyperv_set_event_flag(HvSintRoute *sint_route, unsigned eventno); +/* + * Handler for messages arriving from the guest via HV_POST_MESSAGE hypercall. + * Executed in vcpu context. + */ +typedef uint16_t (*HvMsgHandler)(const struct hyperv_post_message_input *msg, + void *data); +/* + * Associate @handler with the message connection @conn_id, such that @handler + * is called with @data when the guest executes HV_POST_MESSAGE hypercall on + * @conn_id. If @handler is NULL clear the association. + */ +int hyperv_set_msg_handler(uint32_t conn_id, HvMsgHandler handler, void *data); /* * Associate @notifier with the event connection @conn_id, such that @notifier * is signaled when the guest executes HV_SIGNAL_EVENT hypercall on @conn_id. @@ -46,6 +58,12 @@ int hyperv_set_event_flag(HvSintRoute *sint_route, unsigned eventno); */ int hyperv_set_event_flag_handler(uint32_t conn_id, EventNotifier *notifier); +/* + * Process HV_POST_MESSAGE hypercall: parse the data in the guest memory as + * specified in @param, and call the HvMsgHandler associated with the + * connection on the message contained therein. + */ +uint16_t hyperv_hcall_post_message(uint64_t param, bool fast); /* * Process HV_SIGNAL_EVENT hypercall: signal the EventNotifier associated with * the connection as specified in @param. diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c index bf361de6f6..8d70fe7705 100644 --- a/hw/hyperv/hyperv.c +++ b/hw/hyperv/hyperv.c @@ -455,6 +455,14 @@ int hyperv_sint_route_set_sint(HvSintRoute *sint_route) return event_notifier_set(&sint_route->sint_set_notifier); } +typedef struct MsgHandler { + struct rcu_head rcu; + QLIST_ENTRY(MsgHandler) link; + uint32_t conn_id; + HvMsgHandler handler; + void *data; +} MsgHandler; + typedef struct EventFlagHandler { struct rcu_head rcu; QLIST_ENTRY(EventFlagHandler) link; @@ -462,15 +470,91 @@ typedef struct EventFlagHandler { EventNotifier *notifier; } EventFlagHandler; +static QLIST_HEAD(, MsgHandler) msg_handlers; static QLIST_HEAD(, EventFlagHandler) event_flag_handlers; static QemuMutex handlers_mutex; static void __attribute__((constructor)) hv_init(void) { + QLIST_INIT(&msg_handlers); QLIST_INIT(&event_flag_handlers); qemu_mutex_init(&handlers_mutex); } +int hyperv_set_msg_handler(uint32_t conn_id, HvMsgHandler handler, void *data) +{ + int ret; + MsgHandler *mh; + + qemu_mutex_lock(&handlers_mutex); + QLIST_FOREACH(mh, &msg_handlers, link) { + if (mh->conn_id == conn_id) { + if (handler) { + ret = -EEXIST; + } else { + QLIST_REMOVE_RCU(mh, link); + g_free_rcu(mh, rcu); + ret = 0; + } + goto unlock; + } + } + + if (handler) { + mh = g_new(MsgHandler, 1); + mh->conn_id = conn_id; + mh->handler = handler; + mh->data = data; + QLIST_INSERT_HEAD_RCU(&msg_handlers, mh, link); + ret = 0; + } else { + ret = -ENOENT; + } +unlock: + qemu_mutex_unlock(&handlers_mutex); + return ret; +} + +uint16_t hyperv_hcall_post_message(uint64_t param, bool fast) +{ + uint16_t ret; + hwaddr len; + struct hyperv_post_message_input *msg; + MsgHandler *mh; + + if (fast) { + return HV_STATUS_INVALID_HYPERCALL_CODE; + } + if (param & (__alignof__(*msg) - 1)) { + return HV_STATUS_INVALID_ALIGNMENT; + } + + len = sizeof(*msg); + msg = cpu_physical_memory_map(param, &len, 0); + if (len < sizeof(*msg)) { + ret = HV_STATUS_INSUFFICIENT_MEMORY; + goto unmap; + } + if (msg->payload_size > sizeof(msg->payload)) { + ret = HV_STATUS_INVALID_HYPERCALL_INPUT; + goto unmap; + } + + ret = HV_STATUS_INVALID_CONNECTION_ID; + rcu_read_lock(); + QLIST_FOREACH_RCU(mh, &msg_handlers, link) { + if (mh->conn_id == (msg->connection_id & HV_CONNECTION_ID_MASK)) { + ret = mh->handler(msg, mh->data); + break; + } + } + rcu_read_unlock(); + +unmap: + cpu_physical_memory_unmap(msg, len, 0, 0); + return ret; +} + static int set_event_flag_handler(uint32_t conn_id, EventNotifier *notifier) { int ret; diff --git a/target/i386/hyperv.c b/target/i386/hyperv.c index 96b3b5ad7f..b264a28620 100644 --- a/target/i386/hyperv.c +++ b/target/i386/hyperv.c @@ -84,6 +84,9 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit) uint64_t param = exit->u.hcall.params[0]; switch (code) { + case HV_POST_MESSAGE: + exit->u.hcall.result = hyperv_hcall_post_message(param, fast); + break; case HV_SIGNAL_EVENT: exit->u.hcall.result = hyperv_hcall_signal_event(param, fast); break;