Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp983272imm; Wed, 13 Jun 2018 11:22:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI1Inyd/0pPWjhn0FhG7fUgM6pBPYwBuKGiuQ30SuaHIHFw7/ogZXlPqZv8EhfYYLGuQ6hF X-Received: by 2002:a63:24c4:: with SMTP id k187-v6mr4962656pgk.434.1528914165251; Wed, 13 Jun 2018 11:22:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528914165; cv=none; d=google.com; s=arc-20160816; b=FVCT08twwJLBIBZgqQeFuDrBORjzd3wjS9bDx4oEiPNVcqWu/6yneqMtIQUt+vnJ7K fruyGkkaYYzxhntoOPfjRxx9pXLiflD/A9F0Xiy7Nvo/jQLB4c7u28Mzuj54TQQwJ2Xz olUOozcLhnjBJ8tie52aMUwTu4AtJd14swfrsz3zTqY7lHQS9NiZLRWMFltjS43VeINF h0iPYubcUdCgNf3w1DCjGkReTsCMTExfQNSAcVx+7Ul3Gt6JKvA9w9lpLDGWlB+gPB2e Avd3dE/6hnvIlxycNnsnZXt4lgiF29aN0KVncvlZg3sdRhSRihksHU31ziQZwDIlmFSX IsEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=qgiCH8/IPuYYNY0tizpoWDlbAUe/WAeyaSJ5H3kDJXo=; b=Ox4k05HP2YDVw9XshIgPg49rI/DUUVS6198OyV7tBpwoWSN36YsAW630DNtx+oJ0Fg DZcY3hO6j+tbuvnHKeMpT0qTWRrEZRIB9Hj2//vT1A1FD4is2yf0liTOireuOUqBQ1XU d98dAQxWKuvT410rRBu6V6zZrvQpdGRoqG+PSO/AvHLwhXoPT7veU6fnisoaD6dhvl/q 0ag1MXodXAQex6xL8NiyR9Mnqrqs80JzTOiP2vAoToN1vWgrERIW4N643yNKYa7ZLhVI UW97LHYcwkLZ8ug9GvniBAL3ZYrk2NmfTCvXisM1iPTZYGujBnEbysaHxR1u0iSgxacZ fUvA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s9-v6si3402560plr.332.2018.06.13.11.22.30; Wed, 13 Jun 2018 11:22:45 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935695AbeFMSTx (ORCPT + 99 others); Wed, 13 Jun 2018 14:19:53 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:19857 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935478AbeFMSS4 (ORCPT ); Wed, 13 Jun 2018 14:18:56 -0400 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Wed, 13 Jun 2018 11:18:50 -0700 Received: from sc2-haas01-esx0118.eng.vmware.com (sc2-haas01-esx0118.eng.vmware.com [10.172.44.118]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 8F355409BF; Wed, 13 Jun 2018 11:18:54 -0700 (PDT) From: Nadav Amit To: Greg Kroah-Hartman CC: Xavier Deguillard , , Arnd Bergmann , Nadav Amit , Nadav Amit Subject: [PATCH 4/7] vmw_balloon: do not use 2MB without batching Date: Wed, 13 Jun 2018 04:03:56 -0700 Message-ID: <20180613110359.109033-5-namit@vmware.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180613110359.109033-1-namit@vmware.com> References: <20180613110359.109033-1-namit@vmware.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: None (EX13-EDG-OU-002.vmware.com: namit@vmware.com does not designate permitted sender hosts) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the hypervisor sets 2MB batching is on, while batching is cleared, the balloon code breaks. In this case the legacy mechanism is used with 2MB page. The VM would report a 2MB page is ballooned, and the hypervisor would only take the first 4KB. While the hypervisor should not report such settings, make the code more robust by not enabling 2MB support without batching. Reviewed-by: Xavier Deguillard Signed-off-by: Nadav Amit --- drivers/misc/vmw_balloon.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c index 496607a9046a..db3cf91a515d 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -339,7 +339,13 @@ static bool vmballoon_send_start(struct vmballoon *b, unsigned long req_caps) success = false; } - if (b->capabilities & VMW_BALLOON_BATCHED_2M_CMDS) + /* + * 2MB pages are only supported with batching. If batching is for some + * reason disabled, do not use 2MB pages, since otherwise the legacy + * mechanism is used with 2MB pages, causing a failure. + */ + if ((b->capabilities & VMW_BALLOON_BATCHED_2M_CMDS) && + (b->capabilities & VMW_BALLOON_BATCHED_CMDS)) b->supported_page_sizes = 2; else b->supported_page_sizes = 1; -- 2.17.0