From patchwork Tue Feb 6 20:30:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 870081 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="icxPs830"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zbbr16tdtz9s7F for ; Wed, 7 Feb 2018 07:37:52 +1100 (AEDT) Received: from localhost ([::1]:59057 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ej9zx-0006yQ-Pa for incoming@patchwork.ozlabs.org; Tue, 06 Feb 2018 15:37:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ej9tr-0000n4-1A for qemu-devel@nongnu.org; Tue, 06 Feb 2018 15:31:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ej9tn-00037I-Lx for qemu-devel@nongnu.org; Tue, 06 Feb 2018 15:31:31 -0500 Received: from mail-eopbgr00097.outbound.protection.outlook.com ([40.107.0.97]:22064 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 1ej9tn-00036m-9T for qemu-devel@nongnu.org; Tue, 06 Feb 2018 15:31:27 -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=u3pnunSeSAby7NuQ3uWuzy2YX/HbHkK1yaVr8pYyo08=; b=icxPs830me7xV1V2NhTM7uucyZqmMGfyT0yNffl4NtMLUmcqeNJ5FZuY8QEusalyDc42RcJ58g3cb9J03gsiglCUYX0CN5Py33llcMLu5YJWMk4DBMnL38JxlPfwKa8kOKY0TI38fWoHXnXXh65FvyaAqD4RlLfdpPpt2sw0KSg= 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:23 +0000 From: Roman Kagan To: qemu-devel@nongnu.org Date: Tue, 6 Feb 2018 23:30:25 +0300 Message-Id: <20180206203048.11096-12-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: a5c9d894-e493-49ff-a2ed-08d56da097a0 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:PhD2A2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aAES2pCXmfYniTzakuk8bjU+aK/Nz235h1THQ0R/oMqoemAQvbS3c57cg1xUlu6FUWeX3EMxNNLSGHoJSDpj+Hei/NZikWT090I1XrxzjJkPltd5aOqrQEx7e699RBPfm6sH6pScaVQEcVcSIMNli8pGv57AgHXeRmPzo5+3wDgWbYCU311yg9TF8xBHsPFYJsmc8vLWT//SEtzuMoYwMqwOCBz2XPZIyucyppKVZ52ZH/D7wv7pLrAqUHmnrzM=; 4:VvVoqltmQTNZkvnvK9mFSUNbCx4d26/ySm0jrkg0jN5PMhgw2MWZoS8Sn6/6NsPbRHEFPN5zP2GqUOQC+rzBEZ0hmKDwfToboOq4CfXxAESBFOuhPIe0dNSk6ZaXzuI34TK2Cp0AUBzPkpVIljyW+UStZN/S907wiLR0yfYmJsxVPsj6hCy4OfM2FZsByWwHt+SGcXFFSPnrpsXCnWj6PZsHQ+750AdLVRUJey+4Nhgz0TiJnN4K/nkazBGx1bIY+y/bfKnmjymfPUwCCuID/g== 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)(15650500001)(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:KazYIv4hbCFoRaCwlF0tgaEGZOAzZPF2rAJrw5n?= GEye3DwGLcPv4GiA0i+81IIBkM1fdmuoKe8zZJyhBpTsX6qUzqwLxGUbgMJHqQnoXmp/kpdj2HBG0px6ow/NP5ZU7N2A4MnRJ/P4KzvcQhF/r2xxEtlzulu+eTq2A5wfYFT8wonOgKr30klnEOHE4B7UU8gpRsULVMpPptIEyTRXVHBR+ac+OEn4FKoiLmQBwVfKv1vfRFFIpzYrlLAveUgw/nyfFgb3detGRVKyI/lt9VFoTU6AEJpzjqzP4QyIXb0QI4EuElAn/EqWrt3eQxMtj29YnrzgXDuC4woIfylCs3YvwsQaVpaJE1uA0I6wAaCyv+j+wFffMB/u8l2AxdNZqDFDPchFrLL7ysBRFtLYox7P4LJP+rEQPdz1b8e9tCi7QCfdtqqk8H8JWpfyDElcyhr0vhOFw1jaJOKZdh31AlAvERlFkpVtGdDwDhVV7yXJkzki5h4Z/JL0gatao2bmu1hNMQn9+Mbo0MSMKyNiAxMXPFWZ+b7mbBXo/7dfL2nYKNjYBvENipVbfuMUxvL10+z8xkOL+alG8N8M83Ris/CuTDx1L/2y9HCFXwPzTeQhTzbrfR4D1IdUFblWupkDdtH7/2Rwtdn8YASNo8e5vRIC3tdhueSxNbRLE219cbJiCqb+c5ngzF4TxW72Isnt/GxIqDi8JqzM/KDQfu8+Vsnbm3yo827KS5jfzIcEXUhjOAmVMCmljuTsLmU31bPBlL43B5eIYPja4RVEDZoH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oNOhfIuD3x8k7Tfj+7V4LkhhpDfE=; 24:JOxTL4yCXTij2B/Fr3rqEKRx0nrJL3mVHpgCnNFDHagYpG94LGeHpkNi1lmndc6F7k8bLWqqcsPnXre7OudkMkXFSTd/HO36OKgZ2rzaej4=; 7:KPS3nLwwdOYZq2w/8B5Ir2655CgOkP/KWdVkq/VU631TOhaGZ1FxCCDuYrtTDCkpQdVMe9hVGom/RdSa43no5FtdcKWdM/H9XkWM6/DfXJYZcy2j62nr2v/j4mBU65ir/NSo9KWa1ikuSXj+UbG61tZFtByL4n7A67LuSFLKfZ2iJemrO4OCwTkZJNDl9h7qjUu9Zm+g6fubV00V6auNSk+05n7dhHNdr4ScEhrcM2K9+3+/9ndI1jqoxwrMOGMy SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1983; 20:pV6fMBVLVIdOPMsOYCwgf2zDeJJYxadx3i99nToKAUkSsrKO73Ha9vzElP4ITEk+X6pL+FA+Kg6itd197D3Bw6CXsoA++zMbthWIP0AJwrdPh5Y6w54xZQJW/iIQv+axJ4XR49moPuIJy18rcfvI9QMeP6OVYHAR1Xy6NhjgAbY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2018 20:31:23.6843 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5c9d894-e493-49ff-a2ed-08d56da097a0 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.97 Subject: [Qemu-devel] [RFC PATCH 11/34] hyperv: add synic message delivery 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add infrastructure to deliver SynIC messages to the guest SynIC message page. Note that KVM also may want to deliver (SynIC timer) messages to the same message slot. The problem is that the access to a SynIC message slot is controlled by the value of its .msg_type field which indicates if the slot is being owned by the hypervisor (zero) or by the guest (non-zero). This leaves no room for synchronizing multiple concurrent producers. The simplest way to deal with this for both KVM and QEMU is to only deliver messages in the vcpu thread. KVM already does this; this patch makes it for QEMU, too. Specifically, - add a function for posting messages, which only copies the message into the staging buffer if its free, and schedules a work on the corresponding vcpu to actually deliver it to the guest slot; - instead of a sint ack callback, set up the sint route with a message status callback. This function is called in a bh whenever there are updates to the message slot status: either the vcpu made definitive progress delivering the message from the staging buffer (succeeded or failed) or the guest issued EOM; the status is passed as an argument to the callback. Signed-off-by: Roman Kagan --- target/i386/hyperv.h | 7 +-- target/i386/hyperv.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 111 insertions(+), 14 deletions(-) diff --git a/target/i386/hyperv.h b/target/i386/hyperv.h index 249bc15232..df17d9c3b7 100644 --- a/target/i386/hyperv.h +++ b/target/i386/hyperv.h @@ -19,13 +19,12 @@ #include "qemu/event_notifier.h" typedef struct HvSintRoute HvSintRoute; -typedef void (*HvSintAckClb)(void *data); +typedef void (*HvSintMsgCb)(void *data, int status); int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit); HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint, - HvSintAckClb sint_ack_clb, - void *sint_ack_clb_data); + HvSintMsgCb cb, void *cb_data); void hyperv_sint_route_ref(HvSintRoute *sint_route); void hyperv_sint_route_unref(HvSintRoute *sint_route); @@ -40,4 +39,6 @@ void hyperv_synic_update(X86CPU *cpu); bool hyperv_synic_usable(void); +int hyperv_post_msg(HvSintRoute *sint_route, struct hyperv_message *msg); + #endif diff --git a/target/i386/hyperv.c b/target/i386/hyperv.c index 514cd27216..918ba26849 100644 --- a/target/i386/hyperv.c +++ b/target/i386/hyperv.c @@ -47,8 +47,20 @@ struct HvSintRoute { int gsi; EventNotifier sint_set_notifier; EventNotifier sint_ack_notifier; - HvSintAckClb sint_ack_clb; - void *sint_ack_clb_data; + + HvSintMsgCb msg_cb; + void *msg_cb_data; + struct hyperv_message *msg; + /* + * the state of the message staged in .msg: + * 0 - the staging area is not in use (after init or message + * successfully delivered to guest) + * -EBUSY - the staging area is being used in vcpu thread + * -EAGAIN - delivery attempt failed due to slot being busy, retry + * -EXXXX - error + */ + int msg_status; + unsigned refcount; }; @@ -119,6 +131,83 @@ static void synic_update(SynICState *synic) synic_update_evt_page_addr(synic); } +static void sint_msg_bh(void *opaque) +{ + HvSintRoute *sint_route = opaque; + int status = sint_route->msg_status; + sint_route->msg_status = 0; + sint_route->msg_cb(sint_route->msg_cb_data, status); + /* drop the reference taken in hyperv_post_msg */ + hyperv_sint_route_unref(sint_route); +} + +/* + * Worker to transfer the message from the staging area into the guest-owned + * message page in vcpu context, which guarantees serialization with both KVM + * vcpu and the guest cpu. + */ +static void cpu_post_msg(CPUState *cs, run_on_cpu_data data) +{ + int ret; + HvSintRoute *sint_route = data.host_ptr; + SynICState *synic = sint_route->synic; + struct hyperv_message *dst_msg; + + if (!synic->enabled || !synic->msg_page_addr) { + ret = -ENXIO; + goto notify; + } + + dst_msg = &synic->msg_page->slot[sint_route->sint]; + + if (dst_msg->header.message_type != HV_MESSAGE_NONE) { + dst_msg->header.message_flags |= HV_MESSAGE_FLAG_PENDING; + ret = -EAGAIN; + } else { + memcpy(dst_msg, sint_route->msg, sizeof(*dst_msg)); + ret = kvm_hv_sint_route_set_sint(sint_route); + } + + memory_region_set_dirty(&synic->msg_page_mr, 0, sizeof(*synic->msg_page)); + +notify: + sint_route->msg_status = ret; + /* notify the msg originator of the progress made; if the slot was busy we + * set msg_pending flag in it so it will be the guest who will do EOM and + * trigger the notification from KVM via sint_ack_notifier */ + if (ret != -EAGAIN) { + aio_bh_schedule_oneshot(qemu_get_aio_context(), sint_msg_bh, + sint_route); + } +} + +/* + * Post a Hyper-V message to the staging area, for delivery to guest in the + * vcpu thread. + */ +int hyperv_post_msg(HvSintRoute *sint_route, struct hyperv_message *src_msg) +{ + int ret = sint_route->msg_status; + + assert(sint_route->msg_cb); + + if (ret == -EBUSY) { + return -EAGAIN; + } + if (ret) { + return ret; + } + + sint_route->msg_status = -EBUSY; + memcpy(sint_route->msg, src_msg, sizeof(*src_msg)); + + /* hold a reference on sint_route until the callback is finished */ + hyperv_sint_route_ref(sint_route); + + async_run_on_cpu(CPU(sint_route->synic->cpu), cpu_post_msg, + RUN_ON_CPU_HOST_PTR(sint_route)); + return 0; +} static void async_synic_update(CPUState *cs, run_on_cpu_data data) { @@ -176,17 +265,20 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit) } } -static void kvm_hv_sint_ack_handler(EventNotifier *notifier) +static void sint_ack_handler(EventNotifier *notifier) { HvSintRoute *sint_route = container_of(notifier, HvSintRoute, sint_ack_notifier); event_notifier_test_and_clear(notifier); - sint_route->sint_ack_clb(sint_route->sint_ack_clb_data); + + if (sint_route->msg_status == -EAGAIN) { + aio_bh_schedule_oneshot(qemu_get_aio_context(), sint_msg_bh, + sint_route); + } } HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint, - HvSintAckClb sint_ack_clb, - void *sint_ack_clb_data) + HvSintMsgCb cb, void *cb_data) { SynICState *synic; HvSintRoute *sint_route; @@ -208,14 +300,16 @@ HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint, goto err; } - ack_notifier = sint_ack_clb ? &sint_route->sint_ack_notifier : NULL; + ack_notifier = cb ? &sint_route->sint_ack_notifier : NULL; if (ack_notifier) { + sint_route->msg = g_new(struct hyperv_message, 1); + r = event_notifier_init(ack_notifier, false); if (r) { goto err_sint_set_notifier; } - event_notifier_set_handler(ack_notifier, kvm_hv_sint_ack_handler); + event_notifier_set_handler(ack_notifier, sint_ack_handler); } gsi = kvm_irqchip_add_hv_sint_route(kvm_state, vp_index, sint); @@ -230,8 +324,8 @@ HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint, goto err_irqfd; } sint_route->gsi = gsi; - sint_route->sint_ack_clb = sint_ack_clb; - sint_route->sint_ack_clb_data = sint_ack_clb_data; + sint_route->msg_cb = cb; + sint_route->msg_cb_data = cb_data; sint_route->synic = synic; sint_route->sint = sint; sint_route->refcount = 1; @@ -244,6 +338,7 @@ err_gsi: if (ack_notifier) { event_notifier_set_handler(ack_notifier, NULL); event_notifier_cleanup(ack_notifier); + g_free(sint_route->msg); } err_sint_set_notifier: event_notifier_cleanup(&sint_route->sint_set_notifier); @@ -274,9 +369,10 @@ void hyperv_sint_route_unref(HvSintRoute *sint_route) &sint_route->sint_set_notifier, sint_route->gsi); kvm_irqchip_release_virq(kvm_state, sint_route->gsi); - if (sint_route->sint_ack_clb) { + if (sint_route->msg_cb) { event_notifier_set_handler(&sint_route->sint_ack_notifier, NULL); event_notifier_cleanup(&sint_route->sint_ack_notifier); + g_free(sint_route->msg); } event_notifier_cleanup(&sint_route->sint_set_notifier); g_free(sint_route);