Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2236373imm; Thu, 18 Oct 2018 11:09:55 -0700 (PDT) X-Google-Smtp-Source: ACcGV61E4//UgPschkpzW6mBCp+Tewa6N3OLvIj/+3/G5fiT9wGTYVjdC6o2m3Q2MjVuwjzmdECp X-Received: by 2002:a63:924e:: with SMTP id s14-v6mr28827543pgn.141.1539886195559; Thu, 18 Oct 2018 11:09:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539886195; cv=none; d=google.com; s=arc-20160816; b=v2ffLNZkwi3Ll9yz7hPwePNhuejk4ukyqwSPcnToSsxP0geepqvAYsGEF682e1f6wL 6NoFt4Jm3zX4wD4BM7MXvNONoMirBbVsp//xvRyNXG0EKRRJ3Yj+hosO3kpxJCifXAmN XWlO2+q08JwHbO29n6/jLTQztR6Q7bnz3s5DeWfrF4R1dVFl1cNIgEfDCCC4y0weS0ND uB2x13nNmr8elTKydTtewzJU7v+/D1qobddgUbFKZwck5RHWl5i7t9z4SZUA92NuhuoP e6Rhnw773/INle0YWa+5khc92ffCHG1tCYtuXXggWJV4SFahWuuOSmUlDAGYuUh72KUX ArNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rxxLvoG8ZU9SXFFlAI4n0yNb7OcCiY/1fOEUcxJN9S8=; b=AViKvhi2YTPsfAqgN9Ftlur4HBxwJUIBtgKOace2EntqYH24m6Ezqnz9uPNW9nrT4q 4st8SVYLXcxEvQOo4xTT1HM1Ew33lMuVaCb4/jqWohFriTtl0WXAdYzuYoiHqPPE4LnF olwN3S2mt7fcnSicw03LzS+UuaPStQCTymAf2SzwZ8DtKVhYVDncsKpVJRGMFaaZF03K IE4xMcKXRAFrf7PGodgj/uRvA519D23C0rvWalGoHCaTFIvZkTrNcs6/1lX1AMNiItQH qLKbBZBCjMyRnEf96j9iqfqPfR08/MWFRfKezjZeBuokfcnaffRgwq48oddNeQCgoUkG ITjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jp09aiK4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5-v6si21293996pgk.86.2018.10.18.11.09.39; Thu, 18 Oct 2018 11:09:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jp09aiK4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730577AbeJSCJB (ORCPT + 99 others); Thu, 18 Oct 2018 22:09:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:58314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729925AbeJSCJB (ORCPT ); Thu, 18 Oct 2018 22:09:01 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5A9E4204FD; Thu, 18 Oct 2018 18:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539886013; bh=Dc/JuhonEwyxFPxYoRu1Fc+zFKcLZOQY3MUCRSL0ZLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jp09aiK4vSHJFYwlNpus9Z5Sb4sJGf0kWY1w0ejKX70bhtBZxGAwxy/VYgqjmZ7Rd yHrop/yd4axuZL29vrZUF8L5z0DWPmBUZ7/kneAfE1E5ziLNE+cY2GtCEk+WqvrOx5 tiSMyer2qARZDK3aOMBYtoedrLKWUT6EZPRHqmjo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "K. Y. Srinivasan" , Vitaly Kuznetsov , Dexuan Cui Subject: [PATCH 4.4 46/48] Drivers: hv: util: Pass the channel information during the init call Date: Thu, 18 Oct 2018 19:55:21 +0200 Message-Id: <20181018175430.353000104@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181018175427.133690306@linuxfoundation.org> References: <20181018175427.133690306@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: K. Y. Srinivasan commit b9830d120cbe155863399f25eaef6aa8353e767f upstream. Pass the channel information to the util drivers that need to defer reading the channel while they are processing a request. This would address the following issue reported by Vitaly: Commit 3cace4a61610 ("Drivers: hv: utils: run polling callback always in interrupt context") removed direct *_transaction.state = HVUTIL_READY assignments from *_handle_handshake() functions introducing the following race: if a userspace daemon connects before we get first non-negotiation request from the server hv_poll_channel() won't set transaction state to HVUTIL_READY as (!channel) condition will fail, we set it to non-NULL on the first real request from the server. Signed-off-by: K. Y. Srinivasan Reported-by: Vitaly Kuznetsov Signed-off-by: Dexuan Cui Signed-off-by: Greg Kroah-Hartman --- drivers/hv/hv_fcopy.c | 2 +- drivers/hv/hv_kvp.c | 2 +- drivers/hv/hv_snapshot.c | 2 +- drivers/hv/hv_util.c | 1 + include/linux/hyperv.h | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) --- a/drivers/hv/hv_fcopy.c +++ b/drivers/hv/hv_fcopy.c @@ -256,7 +256,6 @@ void hv_fcopy_onchannelcallback(void *co */ fcopy_transaction.recv_len = recvlen; - fcopy_transaction.recv_channel = channel; fcopy_transaction.recv_req_id = requestid; fcopy_transaction.fcopy_msg = fcopy_msg; @@ -323,6 +322,7 @@ static void fcopy_on_reset(void) int hv_fcopy_init(struct hv_util_service *srv) { recv_buffer = srv->recv_buffer; + fcopy_transaction.recv_channel = srv->channel; init_completion(&release_event); /* --- a/drivers/hv/hv_kvp.c +++ b/drivers/hv/hv_kvp.c @@ -640,7 +640,6 @@ void hv_kvp_onchannelcallback(void *cont */ kvp_transaction.recv_len = recvlen; - kvp_transaction.recv_channel = channel; kvp_transaction.recv_req_id = requestid; kvp_transaction.kvp_msg = kvp_msg; @@ -690,6 +689,7 @@ int hv_kvp_init(struct hv_util_service *srv) { recv_buffer = srv->recv_buffer; + kvp_transaction.recv_channel = srv->channel; init_completion(&release_event); /* --- a/drivers/hv/hv_snapshot.c +++ b/drivers/hv/hv_snapshot.c @@ -264,7 +264,6 @@ void hv_vss_onchannelcallback(void *cont */ vss_transaction.recv_len = recvlen; - vss_transaction.recv_channel = channel; vss_transaction.recv_req_id = requestid; vss_transaction.msg = (struct hv_vss_msg *)vss_msg; @@ -340,6 +339,7 @@ hv_vss_init(struct hv_util_service *srv) return -ENOTSUPP; } recv_buffer = srv->recv_buffer; + vss_transaction.recv_channel = srv->channel; /* * When this driver loads, the user level daemon that --- a/drivers/hv/hv_util.c +++ b/drivers/hv/hv_util.c @@ -326,6 +326,7 @@ static int util_probe(struct hv_device * srv->recv_buffer = kmalloc(PAGE_SIZE * 4, GFP_KERNEL); if (!srv->recv_buffer) return -ENOMEM; + srv->channel = dev->channel; if (srv->util_init) { ret = srv->util_init(srv); if (ret) { --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -1179,6 +1179,7 @@ int vmbus_allocate_mmio(struct resource struct hv_util_service { u8 *recv_buffer; + void *channel; void (*util_cb)(void *); int (*util_init)(struct hv_util_service *); void (*util_deinit)(void);