From patchwork Thu Apr 20 07:38:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Semwal X-Patchwork-Id: 97714 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp667373qgf; Thu, 20 Apr 2017 00:39:00 -0700 (PDT) X-Received: by 10.99.119.195 with SMTP id s186mr6717956pgc.179.1492673940115; Thu, 20 Apr 2017 00:39:00 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k5si5463396pgh.379.2017.04.20.00.38.59; Thu, 20 Apr 2017 00:39:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753574AbdDTHi6 (ORCPT + 6 others); Thu, 20 Apr 2017 03:38:58 -0400 Received: from mail-oi0-f52.google.com ([209.85.218.52]:33405 "EHLO mail-oi0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1764229AbdDTHi5 (ORCPT ); Thu, 20 Apr 2017 03:38:57 -0400 Received: by mail-oi0-f52.google.com with SMTP id y11so6724997oie.0 for ; Thu, 20 Apr 2017 00:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8gREAruLSSzMYFS73pSb0Y+nvCpT16vdZkDiLGlk/jw=; b=Rnkw1Fq+4//MoDCZHcjRSjb8LkHQLI123QFFJbEH9RpIc8WMVG+VdA5HYiQhvxIvCK UyR2In3q+2JtnUTODpNLlFlg0CpK+nLmYm/g2i9dgtzHGG1KG8RZ1TeOrErffk72rO6h eMUAN3ymbgXHDevBb2D1XnHoBOI+5xeS/NqtY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8gREAruLSSzMYFS73pSb0Y+nvCpT16vdZkDiLGlk/jw=; b=U8qJefKCAsZ7uThFY9w4FwM1MSaJgmNf/Qu1zPy1I4B0fmCr6kokTe2YQKApgh7hVt hYEZRIv9Uy+PaRL1NJqzCV6zn/G+6OAu9XCTdwWdnNwDS5UalbORHO1IVWPB9sLZDN2L sZmRr9mXHLD7HeAVzjpCSlsByg7aeerGsyBaTwZ9evxBdfsCe9OKft1C+oZTH3hot6Z5 hlhyJS520Fca6mNUnJpvl72kK81/x+ZV4Q8vm/fr5710xWSm0pAGPUhnR6If4IAZlzTQ rng0tkZ9YoLZ7AF0EU5NyKhHq+D+L5Zi014SpgjBRMgYgookW0pyI7nNaEG2hbJWFSBQ vj1g== X-Gm-Message-State: AN3rC/5hGRxXUP6fN9K6rDWULU3RxZl3QTuKLilzP0oaZsHXT8MP7Qvv mfIglKHr+n8A2o8I X-Received: by 10.84.179.193 with SMTP id b59mr8785456plc.56.1492673936611; Thu, 20 Apr 2017 00:38:56 -0700 (PDT) Received: from phantom.lan ([106.51.225.38]) by smtp.gmail.com with ESMTPSA id t2sm8497717pfl.34.2017.04.20.00.38.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Apr 2017 00:38:55 -0700 (PDT) From: Sumit Semwal To: stable@vger.kernel.org Cc: Vitaly Kuznetsov , "K . Y . Srinivasan" , Greg Kroah-Hartman , Sumit Semwal Subject: [v3 PATCH for-4.4 1/7] Drivers: hv: don't leak memory in vmbus_establish_gpadl() Date: Thu, 20 Apr 2017 13:08:37 +0530 Message-Id: <1492673923-1352-2-git-send-email-sumit.semwal@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492673923-1352-1-git-send-email-sumit.semwal@linaro.org> References: <1492673923-1352-1-git-send-email-sumit.semwal@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Vitaly Kuznetsov [ Upstream commit 7cc80c98070ccc7940fc28811c92cca0a681015d ] In some cases create_gpadl_header() allocates submessages but we never free them. [sumits] Note for stable: Upstream commit 4d63763296ab7865a98bc29cc7d77145815ef89f: (Drivers: hv: get rid of redundant messagecount in create_gpadl_header()) changes the list usage to initialize list header in all cases; that patch isn't added to stable, so the current patch is modified a little bit from the upstream commit to check if the list is valid or not. Signed-off-by: Vitaly Kuznetsov Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sumit Semwal --- drivers/hv/channel.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index 1ef37c7..49d2449 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c @@ -375,7 +375,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer, struct vmbus_channel_gpadl_header *gpadlmsg; struct vmbus_channel_gpadl_body *gpadl_body; struct vmbus_channel_msginfo *msginfo = NULL; - struct vmbus_channel_msginfo *submsginfo; + struct vmbus_channel_msginfo *submsginfo, *tmp; u32 msgcount; struct list_head *curr; u32 next_gpadl_handle; @@ -437,6 +437,13 @@ cleanup: list_del(&msginfo->msglistentry); spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); + if (msgcount > 1) { + list_for_each_entry_safe(submsginfo, tmp, &msginfo->submsglist, + msglistentry) { + kfree(submsginfo); + } + } + kfree(msginfo); return ret; } From patchwork Thu Apr 20 07:38:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Semwal X-Patchwork-Id: 97716 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp667479qgf; Thu, 20 Apr 2017 00:39:22 -0700 (PDT) X-Received: by 10.84.224.12 with SMTP id r12mr8551212plj.69.1492673962640; Thu, 20 Apr 2017 00:39:22 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 203si1845905pgf.183.2017.04.20.00.39.22; Thu, 20 Apr 2017 00:39:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S943102AbdDTHjI (ORCPT + 6 others); Thu, 20 Apr 2017 03:39:08 -0400 Received: from mail-oi0-f43.google.com ([209.85.218.43]:33442 "EHLO mail-oi0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S943086AbdDTHjA (ORCPT ); Thu, 20 Apr 2017 03:39:00 -0400 Received: by mail-oi0-f43.google.com with SMTP id y11so6726561oie.0 for ; Thu, 20 Apr 2017 00:39:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VUlTazfLwAtNvLnPpISqIODlyCBz04IQqWWvZXzyq+U=; b=a3ujJMmu9v+oiQ8gDvpPZdYa8U1Qaymby39syuaFf4d5DxV8cJ2Vi+jquMBW8Ettql UL0XClxv2SmnsvvkShUGuhAv64LKzG8EKmcyNJgJ44UQBZ3oyKDPMZIBZOlMGbDEZXl2 v559d3sDoDh6tvNMcy8Xc34jLVnaX0KceepKY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VUlTazfLwAtNvLnPpISqIODlyCBz04IQqWWvZXzyq+U=; b=LDnpoklasY+/rmAfz0JDuIHaCzrQrUusSVzh5gwjJiVNXIbEu0f0Mcd1qk5CQbNYw9 bvVDPloC2nC7nFzf52ex/cQ32EXYF+/tR50mZTHG1blLOcS/ZAkUHhC/r6dUDoXaBnXr eqzYRIXTx6huxNhkujDsBC2PnpZwxa+6i4aiiEf1fgqB7B7BOTlBGlQTX4s8LXH2taaI rqQu5RX1Yz1BAAvuJC5R2ECAKHLXViPgDfek6FDpiD+1mtciETnISYlW7X5Ltb5IiRMl j8X5bkFpcnivMSC5FxcpNfYLJkDwHGqLnQlMuCpyjU1X35TxS6ZfrUZH8pSjBIr/N74T Y9bA== X-Gm-Message-State: AN3rC/5NTeyZ5nqRyASpjnbwIcLotFRZy74SI2qwI1qNyjGvZ0TVpxyq Fde8+QWrvdPKC5Sd X-Received: by 10.84.229.3 with SMTP id b3mr8719384plk.190.1492673939337; Thu, 20 Apr 2017 00:38:59 -0700 (PDT) Received: from phantom.lan ([106.51.225.38]) by smtp.gmail.com with ESMTPSA id t2sm8497717pfl.34.2017.04.20.00.38.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Apr 2017 00:38:58 -0700 (PDT) From: Sumit Semwal To: stable@vger.kernel.org Cc: Vitaly Kuznetsov , "K . Y . Srinivasan" , Greg Kroah-Hartman , Sumit Semwal Subject: [v3 PATCH for-4.4 2/7] Drivers: hv: get rid of timeout in vmbus_open() Date: Thu, 20 Apr 2017 13:08:38 +0530 Message-Id: <1492673923-1352-3-git-send-email-sumit.semwal@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492673923-1352-1-git-send-email-sumit.semwal@linaro.org> References: <1492673923-1352-1-git-send-email-sumit.semwal@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Vitaly Kuznetsov [ Upstream commit 396e287fa2ff46e83ae016cdcb300c3faa3b02f6 ] vmbus_teardown_gpadl() can result in infinite wait when it is called on 5 second timeout in vmbus_open(). The issue is caused by the fact that gpadl teardown operation won't ever succeed for an opened channel and the timeout isn't always enough. As a guest, we can always trust the host to respond to our request (and there is nothing we can do if it doesn't). Signed-off-by: Vitaly Kuznetsov Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sumit Semwal --- drivers/hv/channel.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) -- 2.7.4 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index 49d2449..d037454 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c @@ -73,7 +73,6 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, void *in, *out; unsigned long flags; int ret, err = 0; - unsigned long t; struct page *page; spin_lock_irqsave(&newchannel->lock, flags); @@ -183,11 +182,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, goto error1; } - t = wait_for_completion_timeout(&open_info->waitevent, 5*HZ); - if (t == 0) { - err = -ETIMEDOUT; - goto error1; - } + wait_for_completion(&open_info->waitevent); spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); list_del(&open_info->msglistentry); From patchwork Thu Apr 20 07:38:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Semwal X-Patchwork-Id: 97715 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp667476qgf; Thu, 20 Apr 2017 00:39:22 -0700 (PDT) X-Received: by 10.99.47.4 with SMTP id v4mr6670892pgv.47.1492673962392; Thu, 20 Apr 2017 00:39:22 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 203si1845905pgf.183.2017.04.20.00.39.21; Thu, 20 Apr 2017 00:39:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934597AbdDTHjE (ORCPT + 6 others); Thu, 20 Apr 2017 03:39:04 -0400 Received: from mail-io0-f169.google.com ([209.85.223.169]:36792 "EHLO mail-io0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S943101AbdDTHjD (ORCPT ); Thu, 20 Apr 2017 03:39:03 -0400 Received: by mail-io0-f169.google.com with SMTP id o22so63352208iod.3 for ; Thu, 20 Apr 2017 00:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nvuryFGNPGCQ0OvrpADpfSou8jt4E6kEASBeHvbi9dE=; b=I20k5yANyqukPgOmAqEBaEs8jxpx2RHGu3TTLmoENzHayj8k2zJXqzuJCil9thFftT aVXjCecBuFbfeJKFS/iIAWGIM2d2IG2iVou8uHX8esYFwxIQF8ibAK+gVb/4vty0VBke 8Z5y2/L5UWIvlhrqnIUoOKIi5dguhpA0vJWsE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nvuryFGNPGCQ0OvrpADpfSou8jt4E6kEASBeHvbi9dE=; b=jpx9Ulb6tOGhs0wOZ7hBnoR1n6kie72e4H4gMUP3vTf5ZmNZt/XP2fu7bonjP50hpr bBLHi3llptFkIs9g7kAsD5MBZk/QT/QevP0bGBqaeXJ4Yi85jYZHkFk/7MbFePbAmOwK oAu7/LK/tKdyERUmgyRkmM0nZl2m2b2WhTGP33Rn5IN7S2OWoVaDrfzHKCR4+Ipb4Lt0 tQDS3ohYpn4ssbExU464ZrCF2xnqCAU4K4nz6cdtRIHkTT6dUD3IyY0MWhJTsCQSHqMd wcL7waJjwS0SYZbzXWS+1hhgXR5iSGGyFxAYMMbncK+tRpFZhEVXFmCc/ApRI6YZvzG7 8WCQ== X-Gm-Message-State: AN3rC/4/HtK8XFosz90a3q1CI2FEmAxLSGKDuyAuTrrGKEd36RvSBV5T 5yTnSWUewGWXPq6o X-Received: by 10.99.188.2 with SMTP id q2mr6851944pge.72.1492673941909; Thu, 20 Apr 2017 00:39:01 -0700 (PDT) Received: from phantom.lan ([106.51.225.38]) by smtp.gmail.com with ESMTPSA id t2sm8497717pfl.34.2017.04.20.00.38.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Apr 2017 00:39:00 -0700 (PDT) From: Sumit Semwal To: stable@vger.kernel.org Cc: "K. Y. Srinivasan" , Greg Kroah-Hartman , Sumit Semwal Subject: [v3 PATCH for-4.4 3/7] Drivers: hv: vmbus: Reduce the delay between retries in vmbus_post_msg() Date: Thu, 20 Apr 2017 13:08:39 +0530 Message-Id: <1492673923-1352-4-git-send-email-sumit.semwal@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492673923-1352-1-git-send-email-sumit.semwal@linaro.org> References: <1492673923-1352-1-git-send-email-sumit.semwal@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: "K. Y. Srinivasan" [ Upstream commit 8de0d7e951826d7592e0ba1da655b175c4aa0923 ] The current delay between retries is unnecessarily high and is negatively affecting the time it takes to boot the system. Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sumit Semwal --- drivers/hv/connection.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index 4fc2e88..2bbc530 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -429,7 +429,7 @@ int vmbus_post_msg(void *buffer, size_t buflen) union hv_connection_id conn_id; int ret = 0; int retries = 0; - u32 msec = 1; + u32 usec = 1; conn_id.asu32 = 0; conn_id.u.id = VMBUS_MESSAGE_CONNECTION_ID; @@ -462,9 +462,9 @@ int vmbus_post_msg(void *buffer, size_t buflen) } retries++; - msleep(msec); - if (msec < 2048) - msec *= 2; + udelay(usec); + if (usec < 2048) + usec *= 2; } return ret; } From patchwork Thu Apr 20 07:38:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Semwal X-Patchwork-Id: 97719 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp667490qgf; Thu, 20 Apr 2017 00:39:24 -0700 (PDT) X-Received: by 10.98.23.23 with SMTP id 23mr6751499pfx.30.1492673964105; Thu, 20 Apr 2017 00:39:24 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 203si1845905pgf.183.2017.04.20.00.39.23; Thu, 20 Apr 2017 00:39:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S943105AbdDTHjV (ORCPT + 6 others); Thu, 20 Apr 2017 03:39:21 -0400 Received: from mail-oi0-f42.google.com ([209.85.218.42]:35914 "EHLO mail-oi0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S943104AbdDTHjU (ORCPT ); Thu, 20 Apr 2017 03:39:20 -0400 Received: by mail-oi0-f42.google.com with SMTP id r203so38485758oib.3 for ; Thu, 20 Apr 2017 00:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pJPpAxTCXAFWsJOMqb2N3RYGj35hZ9PAsgs24tOjD04=; b=e/tduMPmG1E59lCSIa2WuJfcbEunoTrJNzBRXdlBU86VdXWCF77I+4zkHKgX6UIjf7 8gg6NM3liQ1Heknu0d4OZJlMh0AP5qlXkJLTh6WI206iUydlSqS3QPnsUyTnrTKFgS4j QqNLrkMus3NsrmikZDeTwm5h3TRS/O/Bb/76M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pJPpAxTCXAFWsJOMqb2N3RYGj35hZ9PAsgs24tOjD04=; b=Gs3S1lik9x20RYjBqmMq83BmUj/HhEzSvxHWWf8PSDy9Hfd+rhF5O9Plvpoqq6tAPA fg9A5hWuJoSXFI23MVSppK1+Q/gsW4OH+3/zsMvW+xqVcoL/WUblB2EdI5MbnZ61hg7y FfdIluKnxj5/wzySPjTVE3oG0ojKjttAri7sx5sTf2o6I3GfTaWDL+upAyRnty2pD4qz axQhD7n93osk+OY4lowiG+c31J42gRHO8POZGHJDsY0tvgzMh5P3w0V1Y0Ox/tneCa6n ZZ3ldYo7+z3qofFPfhZt3ziY06GpVRZOXdFxVPBILQt4o/idd0yyxONfFQTr/whGESVQ zMrg== X-Gm-Message-State: AN3rC/4Am02gTb6XohOKLrUFsVu+jEj/vhglqDLNMzRfWdzSyUzg6wnC LyjM6l60IfHKnw/u X-Received: by 10.84.215.23 with SMTP id k23mr6880658pli.104.1492673944675; Thu, 20 Apr 2017 00:39:04 -0700 (PDT) Received: from phantom.lan ([106.51.225.38]) by smtp.gmail.com with ESMTPSA id t2sm8497717pfl.34.2017.04.20.00.39.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Apr 2017 00:39:03 -0700 (PDT) From: Sumit Semwal To: stable@vger.kernel.org Cc: Vitaly Kuznetsov , "K . Y . Srinivasan" , Greg Kroah-Hartman , Sumit Semwal Subject: [v3 PATCH for-4.4 4/7] Tools: hv: kvp: ensure kvp device fd is closed on exec Date: Thu, 20 Apr 2017 13:08:40 +0530 Message-Id: <1492673923-1352-5-git-send-email-sumit.semwal@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492673923-1352-1-git-send-email-sumit.semwal@linaro.org> References: <1492673923-1352-1-git-send-email-sumit.semwal@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Vitaly Kuznetsov [ Upstream commit 26840437cbd6d3625ea6ab34e17cd34bb810c861 ] KVP daemon does fork()/exec() (with popen()) so we need to close our fds to avoid sharing them with child processes. The immediate implication of not doing so I see is SELinux complaining about 'ip' trying to access '/dev/vmbus/hv_kvp'. Signed-off-by: Vitaly Kuznetsov Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sumit Semwal --- tools/hv/hv_kvp_daemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index 0d9f48e..bc7adb8 100644 --- a/tools/hv/hv_kvp_daemon.c +++ b/tools/hv/hv_kvp_daemon.c @@ -1433,7 +1433,7 @@ int main(int argc, char *argv[]) openlog("KVP", 0, LOG_USER); syslog(LOG_INFO, "KVP starting; pid is:%d", getpid()); - kvp_fd = open("/dev/vmbus/hv_kvp", O_RDWR); + kvp_fd = open("/dev/vmbus/hv_kvp", O_RDWR | O_CLOEXEC); if (kvp_fd < 0) { syslog(LOG_ERR, "open /dev/vmbus/hv_kvp failed; error: %d %s", From patchwork Thu Apr 20 07:38:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Semwal X-Patchwork-Id: 97717 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp667487qgf; Thu, 20 Apr 2017 00:39:23 -0700 (PDT) X-Received: by 10.99.209.85 with SMTP id c21mr6685213pgj.147.1492673963541; Thu, 20 Apr 2017 00:39:23 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 203si1845905pgf.183.2017.04.20.00.39.22; Thu, 20 Apr 2017 00:39:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S943103AbdDTHjK (ORCPT + 6 others); Thu, 20 Apr 2017 03:39:10 -0400 Received: from mail-oi0-f44.google.com ([209.85.218.44]:34463 "EHLO mail-oi0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S943086AbdDTHjI (ORCPT ); Thu, 20 Apr 2017 03:39:08 -0400 Received: by mail-oi0-f44.google.com with SMTP id x184so38846103oia.1 for ; Thu, 20 Apr 2017 00:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XvfGN4kuV2GaT9V0Hew0AdCq55FIICrp9Uuj/cDy4xQ=; b=DtdAN2joC7m76t5DahpmZGibOTA4ZMmKzQt2vqreRxsI6lmkzbMKlpUPsm7R4RN1TQ BIblDAs6rxyCn13787XAUJmJ9GQOaa+OWoJY5mnmJXC7bGtDJioHf//d/bBjujCiAkiy ucTQJVoQijFo2Wcpa47qa9nK6QrECJDTM20DY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XvfGN4kuV2GaT9V0Hew0AdCq55FIICrp9Uuj/cDy4xQ=; b=AX2qnGcW0rnck8vf4AeF+ejwZjEDy9H3s3mgKkS7VvYy8JQMDkcl5ndD69T2VZ88C0 dJ1xyo84PII64eksqkmtnMpVz1M5b9U5+hg8UTLAAMP4vpTdqlPmxEzZ3OowiISjM18/ N1PJdXDfHNWLAZjQtf0plIzadLppTB8LsJwEE5ZlzqNgJh9yZ7v1IyWkGXMZ9wmaCWT6 e/Fyt9ZyFrb2Q9WOkPYeQVh8Z+0DXZbJQN7tYrnsiZeNbQeTuiw2ZmgsplIAtJoUitE9 lpErQPf7lGmrjQ7h9zLr+7pl1+NQVpuW1wtxIvIjCerr2zETaFSrcxTj3j59M19e4VDT O3uQ== X-Gm-Message-State: AN3rC/4x1FKpo26ZjdAqax6ta5scbii4UZijKQqglaCAQiCi3CS9mshR jD2IYJNp2ky1uRkU X-Received: by 10.84.138.131 with SMTP id 3mr8787622plp.167.1492673947529; Thu, 20 Apr 2017 00:39:07 -0700 (PDT) Received: from phantom.lan ([106.51.225.38]) by smtp.gmail.com with ESMTPSA id t2sm8497717pfl.34.2017.04.20.00.39.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Apr 2017 00:39:06 -0700 (PDT) From: Sumit Semwal To: stable@vger.kernel.org Cc: Vitaly Kuznetsov , "K . Y . Srinivasan" , Greg Kroah-Hartman , Sumit Semwal Subject: [v3 PATCH for-4.4 5/7] Drivers: hv: balloon: keep track of where ha_region starts Date: Thu, 20 Apr 2017 13:08:41 +0530 Message-Id: <1492673923-1352-6-git-send-email-sumit.semwal@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492673923-1352-1-git-send-email-sumit.semwal@linaro.org> References: <1492673923-1352-1-git-send-email-sumit.semwal@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Vitaly Kuznetsov [ Upstream commit 7cf3b79ec85ee1a5bbaaf936bb1d050dc652983b ] Windows 2012 (non-R2) does not specify hot add region in hot add requests and the logic in hot_add_req() is trying to find a 128Mb-aligned region covering the request. It may also happen that host's requests are not 128Mb aligned and the created ha_region will start before the first specified PFN. We can't online these non-present pages but we don't remember the real start of the region. This is a regression introduced by the commit 5abbbb75d733 ("Drivers: hv: hv_balloon: don't lose memory when onlining order is not natural"). While the idea of keeping the 'moving window' was wrong (as there is no guarantee that hot add requests come ordered) we should still keep track of covered_start_pfn. This is not a revert, the logic is different. Signed-off-by: Vitaly Kuznetsov Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sumit Semwal --- drivers/hv/hv_balloon.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index 43af913..1542d89 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -430,13 +430,14 @@ struct dm_info_msg { * currently hot added. We hot add in multiples of 128M * chunks; it is possible that we may not be able to bring * online all the pages in the region. The range - * covered_end_pfn defines the pages that can + * covered_start_pfn:covered_end_pfn defines the pages that can * be brough online. */ struct hv_hotadd_state { struct list_head list; unsigned long start_pfn; + unsigned long covered_start_pfn; unsigned long covered_end_pfn; unsigned long ha_end_pfn; unsigned long end_pfn; @@ -682,7 +683,8 @@ static void hv_online_page(struct page *pg) list_for_each(cur, &dm_device.ha_region_list) { has = list_entry(cur, struct hv_hotadd_state, list); - cur_start_pgp = (unsigned long)pfn_to_page(has->start_pfn); + cur_start_pgp = (unsigned long) + pfn_to_page(has->covered_start_pfn); cur_end_pgp = (unsigned long)pfn_to_page(has->covered_end_pfn); if (((unsigned long)pg >= cur_start_pgp) && @@ -854,6 +856,7 @@ static unsigned long process_hot_add(unsigned long pg_start, list_add_tail(&ha_region->list, &dm_device.ha_region_list); ha_region->start_pfn = rg_start; ha_region->ha_end_pfn = rg_start; + ha_region->covered_start_pfn = pg_start; ha_region->covered_end_pfn = pg_start; ha_region->end_pfn = rg_start + rg_size; } From patchwork Thu Apr 20 07:38:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Semwal X-Patchwork-Id: 97720 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp667491qgf; Thu, 20 Apr 2017 00:39:24 -0700 (PDT) X-Received: by 10.84.222.134 with SMTP id x6mr8716596pls.52.1492673964401; Thu, 20 Apr 2017 00:39:24 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 203si1845905pgf.183.2017.04.20.00.39.24; Thu, 20 Apr 2017 00:39:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S943108AbdDTHjX (ORCPT + 6 others); Thu, 20 Apr 2017 03:39:23 -0400 Received: from mail-yb0-f181.google.com ([209.85.213.181]:36028 "EHLO mail-yb0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S943106AbdDTHjV (ORCPT ); Thu, 20 Apr 2017 03:39:21 -0400 Received: by mail-yb0-f181.google.com with SMTP id s22so21167870ybe.3 for ; Thu, 20 Apr 2017 00:39:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EuLNoZMLfU/22HGDkGMh41LW2mo8H8L2dXXCoH87VFI=; b=NeDPK9dwYf7cWqAdWwgEs8SqvkZo2xgIObpzg6O59SNT+UxAlXgw6UeBmT8vY2BXcB YH6aVELnWf7TOgNCgobQME2gEHxn0KRM1cLtPP6GmOZN/m9jrHMbZVkGrLAyPNRaAL15 z53G8RqE9c7PrU+hgjToF9w0HMvjjDqkTPZ6o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EuLNoZMLfU/22HGDkGMh41LW2mo8H8L2dXXCoH87VFI=; b=g4ORGC/lYW7yHYd8oRCyBMIR3mb+H/USodzPG0f+b/o4OwD0276a3BJQ7duHubL3GL Zi0oSwgwYkuQFJERulIeKpBa3VL0YR7Gv5Cn8AXK/r3kWcwvBNaOAkLaHpKnAIJPX6/h 2annarzNvt6Wbb05657TPFPeQNEJ8Q4thPKjuALKwncVKtusTwxLx/DZvg+acWtrdLTN SJIGC2KTiVPGe8nhh5AtAHMiNhyzc55agYNzamJ35Hyig6T1Ce1r6CA42/1jbfNniQt+ w6LwKz+W4vB732o2jQgqT6xNr1fjAzLJtcpzziLk3ZtHUjqLScGzefqRX1u3OzwJfIdF 8wow== X-Gm-Message-State: AN3rC/5mHOZ4KPFntOVbQdSYajl3LheUJMUvAPT/Jszg05yETpi7myvb Adk3Rn8An7itQPkoY3b2vQ== X-Received: by 10.98.1.22 with SMTP id 22mr6699097pfb.263.1492673950353; Thu, 20 Apr 2017 00:39:10 -0700 (PDT) Received: from phantom.lan ([106.51.225.38]) by smtp.gmail.com with ESMTPSA id t2sm8497717pfl.34.2017.04.20.00.39.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Apr 2017 00:39:09 -0700 (PDT) From: Sumit Semwal To: stable@vger.kernel.org Cc: Vitaly Kuznetsov , "K . Y . Srinivasan" , Greg Kroah-Hartman , Sumit Semwal Subject: [v3 PATCH for-4.4 6/7] Drivers: hv: balloon: account for gaps in hot add regions Date: Thu, 20 Apr 2017 13:08:42 +0530 Message-Id: <1492673923-1352-7-git-send-email-sumit.semwal@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492673923-1352-1-git-send-email-sumit.semwal@linaro.org> References: <1492673923-1352-1-git-send-email-sumit.semwal@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Vitaly Kuznetsov [ Upstream commit cb7a5724c7e1bfb5766ad1c3beba14cc715991cf ] I'm observing the following hot add requests from the WS2012 host: hot_add_req: start_pfn = 0x108200 count = 330752 hot_add_req: start_pfn = 0x158e00 count = 193536 hot_add_req: start_pfn = 0x188400 count = 239616 As the host doesn't specify hot add regions we're trying to create 128Mb-aligned region covering the first request, we create the 0x108000 - 0x160000 region and we add 0x108000 - 0x158e00 memory. The second request passes the pfn_covered() check, we enlarge the region to 0x108000 - 0x190000 and add 0x158e00 - 0x188200 memory. The problem emerges with the third request as it starts at 0x188400 so there is a 0x200 gap which is not covered. As the end of our region is 0x190000 now it again passes the pfn_covered() check were we just adjust the covered_end_pfn and make it 0x188400 instead of 0x188200 which means that we'll try to online 0x188200-0x188400 pages but these pages were never assigned to us and we crash. We can't react to such requests by creating new hot add regions as it may happen that the whole suggested range falls into the previously identified 128Mb-aligned area so we'll end up adding nothing or create intersecting regions and our current logic doesn't allow that. Instead, create a list of such 'gaps' and check for them in the page online callback. Signed-off-by: Vitaly Kuznetsov Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sumit Semwal --- drivers/hv/hv_balloon.c | 131 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 94 insertions(+), 37 deletions(-) -- 2.7.4 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index 1542d89..354da7f 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -441,6 +441,16 @@ struct hv_hotadd_state { unsigned long covered_end_pfn; unsigned long ha_end_pfn; unsigned long end_pfn; + /* + * A list of gaps. + */ + struct list_head gap_list; +}; + +struct hv_hotadd_gap { + struct list_head list; + unsigned long start_pfn; + unsigned long end_pfn; }; struct balloon_state { @@ -596,18 +606,46 @@ static struct notifier_block hv_memory_nb = { .priority = 0 }; +/* Check if the particular page is backed and can be onlined and online it. */ +static void hv_page_online_one(struct hv_hotadd_state *has, struct page *pg) +{ + unsigned long cur_start_pgp; + unsigned long cur_end_pgp; + struct hv_hotadd_gap *gap; + + cur_start_pgp = (unsigned long)pfn_to_page(has->covered_start_pfn); + cur_end_pgp = (unsigned long)pfn_to_page(has->covered_end_pfn); -static void hv_bring_pgs_online(unsigned long start_pfn, unsigned long size) + /* The page is not backed. */ + if (((unsigned long)pg < cur_start_pgp) || + ((unsigned long)pg >= cur_end_pgp)) + return; + + /* Check for gaps. */ + list_for_each_entry(gap, &has->gap_list, list) { + cur_start_pgp = (unsigned long) + pfn_to_page(gap->start_pfn); + cur_end_pgp = (unsigned long) + pfn_to_page(gap->end_pfn); + if (((unsigned long)pg >= cur_start_pgp) && + ((unsigned long)pg < cur_end_pgp)) { + return; + } + } + + /* This frame is currently backed; online the page. */ + __online_page_set_limits(pg); + __online_page_increment_counters(pg); + __online_page_free(pg); +} + +static void hv_bring_pgs_online(struct hv_hotadd_state *has, + unsigned long start_pfn, unsigned long size) { int i; - for (i = 0; i < size; i++) { - struct page *pg; - pg = pfn_to_page(start_pfn + i); - __online_page_set_limits(pg); - __online_page_increment_counters(pg); - __online_page_free(pg); - } + for (i = 0; i < size; i++) + hv_page_online_one(has, pfn_to_page(start_pfn + i)); } static void hv_mem_hot_add(unsigned long start, unsigned long size, @@ -684,26 +722,24 @@ static void hv_online_page(struct page *pg) list_for_each(cur, &dm_device.ha_region_list) { has = list_entry(cur, struct hv_hotadd_state, list); cur_start_pgp = (unsigned long) - pfn_to_page(has->covered_start_pfn); - cur_end_pgp = (unsigned long)pfn_to_page(has->covered_end_pfn); + pfn_to_page(has->start_pfn); + cur_end_pgp = (unsigned long)pfn_to_page(has->end_pfn); - if (((unsigned long)pg >= cur_start_pgp) && - ((unsigned long)pg < cur_end_pgp)) { - /* - * This frame is currently backed; online the - * page. - */ - __online_page_set_limits(pg); - __online_page_increment_counters(pg); - __online_page_free(pg); - } + /* The page belongs to a different HAS. */ + if (((unsigned long)pg < cur_start_pgp) || + ((unsigned long)pg >= cur_end_pgp)) + continue; + + hv_page_online_one(has, pg); + break; } } -static bool pfn_covered(unsigned long start_pfn, unsigned long pfn_cnt) +static int pfn_covered(unsigned long start_pfn, unsigned long pfn_cnt) { struct list_head *cur; struct hv_hotadd_state *has; + struct hv_hotadd_gap *gap; unsigned long residual, new_inc; if (list_empty(&dm_device.ha_region_list)) @@ -718,6 +754,24 @@ static bool pfn_covered(unsigned long start_pfn, unsigned long pfn_cnt) */ if (start_pfn < has->start_pfn || start_pfn >= has->end_pfn) continue; + + /* + * If the current start pfn is not where the covered_end + * is, create a gap and update covered_end_pfn. + */ + if (has->covered_end_pfn != start_pfn) { + gap = kzalloc(sizeof(struct hv_hotadd_gap), GFP_ATOMIC); + if (!gap) + return -ENOMEM; + + INIT_LIST_HEAD(&gap->list); + gap->start_pfn = has->covered_end_pfn; + gap->end_pfn = start_pfn; + list_add_tail(&gap->list, &has->gap_list); + + has->covered_end_pfn = start_pfn; + } + /* * If the current hot add-request extends beyond * our current limit; extend it. @@ -734,19 +788,10 @@ static bool pfn_covered(unsigned long start_pfn, unsigned long pfn_cnt) has->end_pfn += new_inc; } - /* - * If the current start pfn is not where the covered_end - * is, update it. - */ - - if (has->covered_end_pfn != start_pfn) - has->covered_end_pfn = start_pfn; - - return true; - + return 1; } - return false; + return 0; } static unsigned long handle_pg_range(unsigned long pg_start, @@ -785,6 +830,8 @@ static unsigned long handle_pg_range(unsigned long pg_start, if (pgs_ol > pfn_cnt) pgs_ol = pfn_cnt; + has->covered_end_pfn += pgs_ol; + pfn_cnt -= pgs_ol; /* * Check if the corresponding memory block is already * online by checking its last previously backed page. @@ -793,10 +840,8 @@ static unsigned long handle_pg_range(unsigned long pg_start, */ if (start_pfn > has->start_pfn && !PageReserved(pfn_to_page(start_pfn - 1))) - hv_bring_pgs_online(start_pfn, pgs_ol); + hv_bring_pgs_online(has, start_pfn, pgs_ol); - has->covered_end_pfn += pgs_ol; - pfn_cnt -= pgs_ol; } if ((has->ha_end_pfn < has->end_pfn) && (pfn_cnt > 0)) { @@ -834,13 +879,19 @@ static unsigned long process_hot_add(unsigned long pg_start, unsigned long rg_size) { struct hv_hotadd_state *ha_region = NULL; + int covered; if (pfn_cnt == 0) return 0; - if (!dm_device.host_specified_ha_region) - if (pfn_covered(pg_start, pfn_cnt)) + if (!dm_device.host_specified_ha_region) { + covered = pfn_covered(pg_start, pfn_cnt); + if (covered < 0) + return 0; + + if (covered) goto do_pg_range; + } /* * If the host has specified a hot-add range; deal with it first. @@ -852,6 +903,7 @@ static unsigned long process_hot_add(unsigned long pg_start, return 0; INIT_LIST_HEAD(&ha_region->list); + INIT_LIST_HEAD(&ha_region->gap_list); list_add_tail(&ha_region->list, &dm_device.ha_region_list); ha_region->start_pfn = rg_start; @@ -1584,6 +1636,7 @@ static int balloon_remove(struct hv_device *dev) struct hv_dynmem_device *dm = hv_get_drvdata(dev); struct list_head *cur, *tmp; struct hv_hotadd_state *has; + struct hv_hotadd_gap *gap, *tmp_gap; if (dm->num_pages_ballooned != 0) pr_warn("Ballooned pages: %d\n", dm->num_pages_ballooned); @@ -1600,6 +1653,10 @@ static int balloon_remove(struct hv_device *dev) #endif list_for_each_safe(cur, tmp, &dm->ha_region_list) { has = list_entry(cur, struct hv_hotadd_state, list); + list_for_each_entry_safe(gap, tmp_gap, &has->gap_list, list) { + list_del(&gap->list); + kfree(gap); + } list_del(&has->list); kfree(has); } From patchwork Thu Apr 20 07:38:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Semwal X-Patchwork-Id: 97718 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp667489qgf; Thu, 20 Apr 2017 00:39:23 -0700 (PDT) X-Received: by 10.98.159.144 with SMTP id v16mr6636089pfk.57.1492673963819; Thu, 20 Apr 2017 00:39:23 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 203si1845905pgf.183.2017.04.20.00.39.23; Thu, 20 Apr 2017 00:39:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S943086AbdDTHjP (ORCPT + 6 others); Thu, 20 Apr 2017 03:39:15 -0400 Received: from mail-yb0-f181.google.com ([209.85.213.181]:34617 "EHLO mail-yb0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S943104AbdDTHjO (ORCPT ); Thu, 20 Apr 2017 03:39:14 -0400 Received: by mail-yb0-f181.google.com with SMTP id 11so17678925ybw.1 for ; Thu, 20 Apr 2017 00:39:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=b/4EdhaVvM16veNbBlzw6pKOeSID24uDb6DOWoRvntM=; b=RHxj8GKjb/puXrOnTots6qXJynpoA7yNT2RwOlfjSJ3mNGvoIK+m7W7rlk1Cpzam0V UMhV6cg8fAg5KpwNObFjLkvrwQ+lUh3+q7HJgMnZwV2OFOHHXjPA/bcxRuF+GrTe2j+3 DKzaD9H/FqhlbuzyhYupMcTQFRDFKeYjm1M7w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=b/4EdhaVvM16veNbBlzw6pKOeSID24uDb6DOWoRvntM=; b=P3WL6X6y6GBCklfXOrN7nh1ZOmd0FMyMVTJdgiQie5ZlRQDrsqsKh1UzAMqfBS21CK cQtK6VA7inGTbdGW0ARNP7kA5aEjTIQO8rJ14FvCAdA39EEg3YrpMoCnUG3nolrSs2Kn VaTJjeDUPW/bLROmbsYwAY11av8c87BkYgXvWly3lznNyOJGpuf9a6K/f9+sjjYfX8T0 wKIjWAwT3hMtyaIxeG4nx2T5bZ5mNyqiyCzvztnpCzpSqTnVnIIviki1JpYeO/EimATs GOBidE1PsEUj3ceGZEY7c8W6zN1AXwSxAAlYHgxE/aCDcamCi4OTyoln5WNfGswE7tow 4MVw== X-Gm-Message-State: AN3rC/4IMML6OCOA6XWtacQWlaWnUj858Pv82mwhP/u/GIGHWZooFyqf kuYhQDkK3rHyaQ8C X-Received: by 10.98.220.201 with SMTP id c70mr6778574pfl.77.1492673953158; Thu, 20 Apr 2017 00:39:13 -0700 (PDT) Received: from phantom.lan ([106.51.225.38]) by smtp.gmail.com with ESMTPSA id t2sm8497717pfl.34.2017.04.20.00.39.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Apr 2017 00:39:12 -0700 (PDT) From: Sumit Semwal To: stable@vger.kernel.org Cc: Vitaly Kuznetsov , "K . Y . Srinivasan" , Greg Kroah-Hartman , Sumit Semwal Subject: [v3 PATCH for-4.4 7/7] hv: don't reset hv_context.tsc_page on crash Date: Thu, 20 Apr 2017 13:08:43 +0530 Message-Id: <1492673923-1352-8-git-send-email-sumit.semwal@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492673923-1352-1-git-send-email-sumit.semwal@linaro.org> References: <1492673923-1352-1-git-send-email-sumit.semwal@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Vitaly Kuznetsov [ Upstream commit 56ef6718a1d8d77745033c5291e025ce18504159 ] It may happen that secondary CPUs are still alive and resetting hv_context.tsc_page will cause a consequent crash in read_hv_clock_tsc() as we don't check for it being not NULL there. It is safe as we're not freeing this page anyways. Signed-off-by: Vitaly Kuznetsov Signed-off-by: K. Y. Srinivasan Cc: Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sumit Semwal --- drivers/hv/hv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index ddbf7e7..8ce1f2e 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -305,9 +305,10 @@ void hv_cleanup(bool crash) hypercall_msr.as_uint64 = 0; wrmsrl(HV_X64_MSR_REFERENCE_TSC, hypercall_msr.as_uint64); - if (!crash) + if (!crash) { vfree(hv_context.tsc_page); - hv_context.tsc_page = NULL; + hv_context.tsc_page = NULL; + } } #endif }