Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3392486imm; Thu, 17 May 2018 08:05:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo29UriszRyjCkqTbsaUFUkMlc0kYaoPLR+RKBIXGYGCeaG8O2jAp9gQjN7Afvgwp7rID/H X-Received: by 2002:a17:902:28a7:: with SMTP id f36-v6mr5540028plb.155.1526569510834; Thu, 17 May 2018 08:05:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526569510; cv=none; d=google.com; s=arc-20160816; b=OlUvioHUC3PJ4ukC2gyPbkXygaHx/EawITYXi8jO3RwFBf6PX6NP3Ps46/OMY4JDTj lhoNdw2Q7Dsa9vu7+hcElB6/GjxRuuU8cb+IsWtbrnzQftNiB2YwoFxvO2WzaFAgGIaX WU4D66hnWY0JXk0nve1kcP2/bVHfThDpH4h9UL7vmvk0HMo+4RVQQ+jhOZwi8WOq9mbk SiXPBMD8qfKVSL8JzoeUSYMqqCP4T3JzMj4xFiwt3VPQg1VGx4TtXZagoHsIIIkvbKCG tmRka+8xCPqJPdnACbfBJbAV1eCcau1B9ycGSVwgcMr5oPNVLQfkzWLhlWdPMvn/YSi4 nhfQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Svqgt4EXjJMHg6CFbYmPprvclEFboFgxJ4nfdsU86HM=; b=YTmm2CunmOojr2/gD549EUjNfC1CLotOLYzMOQUvrSe3l6LaRonp2oUDZBLTgBd3cx GoZ6n2pnSjOeUqUZHdXcLtjUe+Pz0ebChDtmADj0ijBZCNg3aDMaG7Cx8F8EkMTbowDK Y1wGJwEzAlICSCF2DTlT/1dFLki+5AyyqWYyQf3XmPprSI0tClDc3ZUbfuMHb0ZlcvoO RfJYuMUdlBlADsVTVpDDEgoWseJYJNQb+vwFd8uUYUt6QOYEUkaKpGSkcslSI4L3D0qW WCRWkWeqKWnfPAMGCFlOr8tPF2S+HlsqR7yKnZaTPZhXVWtpzvklPpBAP4ZsK78CVjpJ NgKw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v201-v6si4160039pgb.295.2018.05.17.08.04.35; Thu, 17 May 2018 08:05:10 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752504AbeEQPDW (ORCPT + 99 others); Thu, 17 May 2018 11:03:22 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:36984 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751481AbeEQPDV (ORCPT ); Thu, 17 May 2018 11:03:21 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3463F1435; Thu, 17 May 2018 08:03:21 -0700 (PDT) Received: from [10.1.206.73] (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9502F3F25D; Thu, 17 May 2018 08:03:17 -0700 (PDT) Subject: Re: [PATCH] KVM: arm/arm64: add WARN_ON if size is not PAGE_SIZE aligned in unmap_stage2_range To: Jia He , Christoffer Dall , Marc Zyngier , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Cc: Andrew Morton , Andrea Arcangeli , Claudio Imbrenda , Arvind Yadav , "David S. Miller" , Minchan Kim , Mike Rapoport , Hugh Dickins , "Paul E. McKenney" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, jia.he@hxt-semitech.com References: <1526537487-14804-1-git-send-email-hejianet@gmail.com> <698b0355-d430-86b8-cd09-83c6d9e566f8@arm.com> From: Suzuki K Poulose Message-ID: <25dbb8c1-631f-c810-4d75-349a0b291cf8@arm.com> Date: Thu, 17 May 2018 16:03:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/05/18 13:46, Jia He wrote: > Hi Suzuki > > On 5/17/2018 4:17 PM, Suzuki K Poulose Wrote: >> >> Hi Jia, >> >> On 17/05/18 07:11, Jia He wrote: >>> I ever met a panic under memory pressure tests(start 20 guests and run >>> memhog in the host). >> >> Please avoid using "I" in the commit description and preferably stick to >> an objective description. > > Thanks for the pointing > >> >>> >>> The root cause might be what I fixed at [1]. But from arm kvm points of >>> view, it would be better we caught the exception earlier and clearer. >>> >>> If the size is not PAGE_SIZE aligned, unmap_stage2_range might unmap the >>> wrong(more or less) page range. Hence it caused the "BUG: Bad page >>> state" >> >> I don't see why we should ever panic with a "positive" size value. Anyways, >> the unmap requests must be in units of pages. So this check might be useful. >> >> > > good question, > > After further digging, maybe we need to harden the break condition as below? > diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c > index 7f6a944..dac9b2e 100644 > --- a/virt/kvm/arm/mmu.c > +++ b/virt/kvm/arm/mmu.c > @@ -217,7 +217,7 @@ static void unmap_stage2_ptes(struct kvm *kvm, pmd_t *pmd, > > put_page(virt_to_page(pte)); > } > - } while (pte++, addr += PAGE_SIZE, addr != end); > + } while (pte++, addr += PAGE_SIZE, addr < end); I don't think this change is need as stage2_pgd_addr_end(addr, end) must return the smaller of the next entry or end. Thus we can't miss "addr" == "end". Suzuki