From patchwork Thu May 17 12:46:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10406731 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0717A60230 for ; Thu, 17 May 2018 12:47:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB2BE28A42 for ; Thu, 17 May 2018 12:47:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF6C628A5B; Thu, 17 May 2018 12:47:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 52F8D28A42 for ; Thu, 17 May 2018 12:47:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Na8c5N4GYom4B62aah0SlXPwvfYeRbYpl4pkPcHWi0Q=; b=O9aR89/4w+9539 Up6TA+ZxGeIeB/5FUSYUCWOPLkvjodu5tKM7fpd23Sjj+kFeShMDPhZ9+zKwrtOhF3JpSrL4WQnSs N6ht4MQ9CosLrPjiqnHihA5D3kSICJes/KEJnMPYfMzshNk3N6UmeCJ/ilTlTdgyu9GDzVFMpezes lwTlaEf1Q9m8iXyVSj0UHosnGrUAxinW+a1Nh485DU/fEG5lXK+TeLajEzecxnQ389w0FOAm9SKSv Zca9qSig+EU04gQ5f5PQCZz3wzdWuvoaVlSnY0zcTQypNF6WTzR/kUJyxCNyAy/8GwcL4m+j0T4Bv N/eBv9BkMeSdGzLN4FPQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJIJV-0002YN-N2; Thu, 17 May 2018 12:47:21 +0000 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJIJR-0002X3-H4 for linux-arm-kernel@lists.infradead.org; Thu, 17 May 2018 12:47:19 +0000 Received: by mail-pl0-x243.google.com with SMTP id c41-v6so2484649plj.10 for ; Thu, 17 May 2018 05:47:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=//J085tko7D45FCXr6w/KtRxV9oW/Je0lZZqDJNF99E=; b=j66rty3JI+TBbQSsPZp5ozsyTexmD+UE5ysbviDS7etPINijic4IsZ3+t//oeYjihz AODEge6jMHIQM3jZXF1oPWblCgEtu7X12ROnibAXIM19ejbVJ6JQEDvLh1dc1ktB7do2 +zuEOlMGBj35O+1P3mA9ux1kg7UqaaFhRe7BJfb7p2dEgWSkA+gsVoaBeoZU2JmZr7sN L/SebyvtXKS+kqYNyq6Jyf1VWfsYWG8QBtKoWU8LmbcAJCV2eEWNMRBbmS0yz760WVWe eSCtc5j16J7onmqLTkr/g+fqI9e80tHn0ngrFgrvUYwhM1XrpvWVkQgWM9mpl5J2xrK3 WpXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=//J085tko7D45FCXr6w/KtRxV9oW/Je0lZZqDJNF99E=; b=OMtw9Gksw8YpoTIvIU+N00aEaBYMjcb8WKAu6Xu1AKG5HK93XZQ1MXO3n+pvtI2P8+ 27/vCaQB8xZPDqRjPlULpKjEwMwWgmjagdy6H9DdRmFFIMydfmo8aLCsGsNmCfP/lH8Z nomAgY3OgZGLO80BxlaYPmSaFtl4tyEYrxYAfxEDZZDlAH59cXp2c35GVhJjsFxEssB1 toQPjkw/43Iq+pVNO5pTDzf/VoXWxRIv2/y8u4seEMpycdYvFHmYv/t/Sl2Ns53lHBax 6dXBGNapnIxEphKC5YpSyTAGAHv3iGY2dLD6DSir5zW+Qgp9QRtBqdBPAyPKD2MbBJUe 8U2A== X-Gm-Message-State: ALKqPwduiNbC1QUWWADHaUkDuhFEB+aLUFBzh3cnnheCF26edVH3GIXE QQapJpq826mbluLkUNx6Uo8= X-Google-Smtp-Source: AB8JxZq8cjUp26MYSlMI2JufxoQsYqjV5mb2z0MyBhJdNV4xwWU5dFyuSpUpCoi8D8VEvItDAHGyyQ== X-Received: by 2002:a17:902:8a82:: with SMTP id p2-v6mr5134675plo.244.1526561226843; Thu, 17 May 2018 05:47:06 -0700 (PDT) Received: from [0.0.0.0] (67.216.217.169.16clouds.com. [67.216.217.169]) by smtp.gmail.com with ESMTPSA id n129-v6sm7504049pga.49.2018.05.17.05.46.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 May 2018 05:47:05 -0700 (PDT) Subject: Re: [PATCH] KVM: arm/arm64: add WARN_ON if size is not PAGE_SIZE aligned in unmap_stage2_range To: Suzuki K Poulose , Christoffer Dall , Marc Zyngier , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu References: <1526537487-14804-1-git-send-email-hejianet@gmail.com> <698b0355-d430-86b8-cd09-83c6d9e566f8@arm.com> From: Jia He Message-ID: Date: Thu, 17 May 2018 20:46:50 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <698b0355-d430-86b8-cd09-83c6d9e566f8@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180517_054717_618712_C2BFCA00 X-CRM114-Status: GOOD ( 19.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrea Arcangeli , linux-mm@kvack.org, Hugh Dickins , linux-kernel@vger.kernel.org, Claudio Imbrenda , jia.he@hxt-semitech.com, Minchan Kim , Mike Rapoport , Arvind Yadav , Andrew Morton , "Paul E. McKenney" , "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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); basically verified in my armv8a server