Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp373429imm; Tue, 19 Jun 2018 23:16:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLyZslwlBBBWAD/mO1+RZIYAGh7XG74KT+e6uwsEaqpKe8aiQ1aWjT8cSXt6MoYx03mKksU X-Received: by 2002:a63:64c5:: with SMTP id y188-v6mr17848888pgb.37.1529475398516; Tue, 19 Jun 2018 23:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529475398; cv=none; d=google.com; s=arc-20160816; b=oNcRzO3MLgZJPETiOZdvIb3rSrGtIep3JSLayQ+3yCoFC3m5c46ezMnrHCJpFJhtrX mMcG6mJxuz4wI0HAayIvFM5ozlrcqlnKFep6S1Ki3hGbjoBi8SxcPZ2vvXuE96TNkwxL bQ1hSi0ZgDSnBc/+7RRi6f/CbLs5ecriD+HNHQEU84mQhlRdLTugLGr47diCWP8eYLCg 7gI7m0ArQzhjEHIWnEMqQ/SaNbRqXaU9xOxcQjgh+tfWM9OQumZekn22YmDiupvopfaX MvT3gUKEWDqeHd31S46s5i6SAWEZMjPVJvDMZ97poElhzz+5ldk+5VN6vLlSNksdKTml X85A== 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=MjJ1LLWIeTAJHRBhS0n+MrY2uHuLfC5cLjmuKtKJAik=; b=KPEyMNhurEPTFcAspjVHKfeGuIFiBSIGqVn/Wj/j+rljknMu0b1nfuxx/qbpMu9arT QFdt9BnzPqM5nbPc2tuaUB4uJB1Yf0Q0kaubyH1nihavbPZcDVplC8cU5tXfVqxuCFFA PbuIcaKzc0cQDgN9F2XXWRpCQDMih6Co7jfn4cZdYnNn50D+hBRsNE+JVcNQcAWOxhN5 rZUzcqVzVmZXG6zfqASHmn6DpskTCqaV5k7jHaMNjQbq77BBSjCjP7Jnf/LTJooVikzU lHAO2DvlkLyi14DOmemFDAvY2xb6TiLmbFdUCbFTCuLtqmY0JCRoq8J/ErJN6O4HpHSC rUWQ== 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 g126-v6si1348743pgc.251.2018.06.19.23.16.24; Tue, 19 Jun 2018 23:16:38 -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 S1754061AbeFTGPV (ORCPT + 99 others); Wed, 20 Jun 2018 02:15:21 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:14815 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751587AbeFTGPQ (ORCPT ); Wed, 20 Jun 2018 02:15:16 -0400 Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Tue, 19 Jun 2018 23:15:11 -0700 Received: from sc2-haas01-esx0118.eng.vmware.com (sc2-haas01-esx0118.eng.vmware.com [10.172.44.118]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 8CAFFB0C25; Tue, 19 Jun 2018 23:15:15 -0700 (PDT) From: Nadav Amit To: Greg Kroah-Hartman CC: Xavier Deguillard , Arnd Bergmann , , Nadav Amit , , Nadav Amit Subject: [PATCH v3 2/7] vmw_balloon: do not use 2MB without batching Date: Tue, 19 Jun 2018 16:00:25 -0700 Message-ID: <20180619230030.112906-3-namit@vmware.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180619230030.112906-1-namit@vmware.com> References: <20180619230030.112906-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. Fixes: 365bd7ef7ec8e ("VMware balloon: Support 2m page ballooning.") Cc: stable@vger.kernel.org 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 28e77ab1e136..60ab83d3d0ef 100644 --- a/drivers/misc/vmw_balloon.c +++ b/drivers/misc/vmw_balloon.c @@ -341,7 +341,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