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: 10406727 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 B8E4A60155 for ; Thu, 17 May 2018 12:47:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A656628A3B for ; Thu, 17 May 2018 12:47:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98AAA28A5B; Thu, 17 May 2018 12:47:12 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2441028A3B for ; Thu, 17 May 2018 12:47:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6546C6B04D2; Thu, 17 May 2018 08:47:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 605AE6B04E1; Thu, 17 May 2018 08:47:09 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F6436B04E2; Thu, 17 May 2018 08:47:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f69.google.com (mail-pg0-f69.google.com [74.125.83.69]) by kanga.kvack.org (Postfix) with ESMTP id 0FC426B04D2 for ; Thu, 17 May 2018 08:47:09 -0400 (EDT) Received: by mail-pg0-f69.google.com with SMTP id z11-v6so1745683pgu.1 for ; Thu, 17 May 2018 05:47:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding; bh=//J085tko7D45FCXr6w/KtRxV9oW/Je0lZZqDJNF99E=; b=bAaEGG0g1QBTAOG5qlLQTt4kGU8U13UGtN4MnmsVCLBjStCQCeQDbQzSzknmfHpOSo wup49v+THYraG5EA25mHjbqNYI1CmZ+BIit7Yz+nxmzaaZsK3rayfcXa2y1eP843HW8q 8ykJ8peDGd52o5yYSiBOxBKNTzc1LwQ5PUBlUzEBG4tao9+zEzr3uYXVW4gvrPF9j5SD AOLy2D1dEJersUR4VTOQsjKZn+NML9WvPqrKilstmYjWgr1ojtH1byZJvl/7K2QytJpI dw/e4dFInf48oS9r4xxidz09uItANmENufNigb5IOPqtcd2+rPSN75anLSOFYfcWGy4m JP7A== X-Gm-Message-State: ALKqPweOufrtP5vironlGTQ8uvVNF3vycpADH1mAtzGXkImm3SQ8Q9lX waxHyUrusd8cVLgt9R37pkK+JI3gxkUqj5ZJqoTYEJm5UNWXzrGtjn0vwYwkZPlO342K4jyQPwk rkYj1+jvWZA06AlfnaBiFiGlD6d4OKtp4AouK5bSUZXszFewmnPVt8AmqOLt7cfnHrtZISMRlJf 3/+ldyRv4blHFxROIm7bi85hOJO9o5LqyqTFqv/FDhqGQ6h6wnQRoXx4xDa8quj5/cZwhZQdvhG ym+Ez8gKeFUT+ila3SnO/Hf2HAuVh6tOI9vXwBbSKvMeI5WOrM/Q2o0oGAnClFclaPBh0e5R38j DuFJrPjPUWf52tyWwQqg8iaZTLIPYqV8aVigVVa0D/Hm12oMyQ3gRYq9NsXggaSpvQkRDE/sOuF X X-Received: by 2002:a63:6157:: with SMTP id v84-v6mr3918278pgb.299.1526561228675; Thu, 17 May 2018 05:47:08 -0700 (PDT) X-Received: by 2002:a63:6157:: with SMTP id v84-v6mr3918212pgb.299.1526561227116; Thu, 17 May 2018 05:47:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526561227; cv=none; d=google.com; s=arc-20160816; b=FOQjnUaX/1yVgJxNnSmhKn45AuEGVBPjvhtbme2sM5d8ZBIkmk8f3TWIHmWy+A7zrW LZdqfdJ0PSNh/weaApkwv8nhLV3QQMW3yOaoAXk8mWgw7Xg4IloYIKRAC8hW5w/fbf5Y bIkNtLIrK9hoJD5mx0PpTIFGmHWClfYdYCQ2hcSxuevVHo/GMnQcFfTznU8GBureGljJ zHQIKfT/bZsphxLpQOtK9nSFjrjuRZbbwFXRVIRmgjTeFbI7rBiAF+QAXmfU3wAosPLN P9KrTfFMQ6OX4visJGeP02Awmrw8XNtiezfuBXBVlg+FI8KKR8jIvpogtrjqwE7mVmme 9KwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=//J085tko7D45FCXr6w/KtRxV9oW/Je0lZZqDJNF99E=; b=LQ0i1gYkor1ClpAF9PnigtvvM0rBbsDwZZHeH9ytKX03D8ZnhwP8Nrl4K8/d4yKDez 00IBDCkjrIRN7CmKrfLO2bCDCAqiQ+9t4K8bH84wVUF8JT/OFdP1VlnlutNiqksWITBJ aJI1iF16tRre7Owh6wZt6OTRX6deaa/++cS0iFoftsstGKKwZKv4X3AFlujdbJIrqE9l LDQQIjo2YNMkYayXEUrjJTU87lrTtExpDXLH9E3hJB+90Qj3cypwRRZaAfo52AkaC4+l /s5W7Fcr8QoHvaGTfneeiX9vqwOS86i+tfZdE1EfUCIECd2oIQ9draBf0j/l7e/YRpo7 lVXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=j66rty3J; spf=pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hejianet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 5-v6sor3080718pls.47.2018.05.17.05.47.06 for (Google Transport Security); Thu, 17 May 2018 05:47:07 -0700 (PDT) Received-SPF: pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=j66rty3J; spf=pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hejianet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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-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 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: 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-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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