From patchwork Wed Jan 27 18:28:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 60639 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp10096lbb; Wed, 27 Jan 2016 10:28:52 -0800 (PST) X-Received: by 10.98.44.66 with SMTP id s63mr44864059pfs.2.1453919332084; Wed, 27 Jan 2016 10:28:52 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f6si10963487pfj.104.2016.01.27.10.28.51; Wed, 27 Jan 2016 10:28:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934925AbcA0S2n (ORCPT + 2 others); Wed, 27 Jan 2016 13:28:43 -0500 Received: from foss.arm.com ([217.140.101.70]:54689 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934573AbcA0S2k (ORCPT ); Wed, 27 Jan 2016 13:28:40 -0500 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 9204849; Wed, 27 Jan 2016 10:27:58 -0800 (PST) Received: from arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6811A3F24D; Wed, 27 Jan 2016 10:28:39 -0800 (PST) Date: Wed, 27 Jan 2016 18:28:37 +0000 From: Will Deacon To: Greg KH Cc: stable@vger.kernel.org, zhangbo_a@xiaomi.com Subject: Re: FAILED: patch "[PATCH] iommu/io-pgtable-arm: Ensure we free the final level on" failed to apply to 4.4-stable tree Message-ID: <20160127182837.GC25545@arm.com> References: <14538773031129@kroah.com> <20160127115900.GG2390@arm.com> <20160127175736.GD22700@kroah.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160127175736.GD22700@kroah.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Wed, Jan 27, 2016 at 09:57:36AM -0800, Greg KH wrote: > On Wed, Jan 27, 2016 at 11:59:01AM +0000, Will Deacon wrote: > > On Tue, Jan 26, 2016 at 10:48:23PM -0800, gregkh@linuxfoundation.org wrote: > > > > > > The patch below does not apply to the 4.4-stable tree. > > > If someone wants it applied there, or to any other stable or longterm > > > tree, then please email the backport, including the original git commit > > > id to . > > > > Do you have the conflict handy? It applies to 4.4 here, so I guess its > > somehow conflicting with another -stable patch, but I couldn't spot it. > > The whole thing fails to apply: > > Applying iommu-io-pgtable-arm-ensure-we-free-the-final-level-on-teardown.patch to linux-4.4.y > Applying patch iommu-io-pgtable-arm-ensure-we-free-the-final-level-on-teardown.patch > patching file drivers/iommu/io-pgtable-arm.c > Hunk #1 FAILED at 404. > 1 out of 1 hunk FAILED -- rejects in file drivers/iommu/io-pgtable-arm.c > > It also doesn't apply to a clean 4.4 tree for me either: > > ~/linux/stable $ git clone -s linux-4.4.y/ x > Cloning into 'x'... > done. > Checking out files: 100% (52221/52221), done. > ~/linux/stable $ cd x > ~/linux/stable/x $ git show --pretty=email 12c2ab09571e8aae3a87da2a4a452632a5fac1e5 > x.patch > ~/linux/stable/x $ patch -p1 --dry-run < x.patch > checking file drivers/iommu/io-pgtable-arm.c > Hunk #1 FAILED at 404. > 1 out of 1 hunk FAILED > > How are you applying this? $ git cherry-pick 12c2ab09571e8aae3a87da2a4a452632a5fac1e5 It looks like there's a small change in context that patch doesn't like. Updated patch below. Will --->8 >From 5ac63eeb89e736553a1fd728645d61abdfb04c72 Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Tue, 15 Dec 2015 16:08:12 +0000 Subject: [PATCH] iommu/io-pgtable-arm: Ensure we free the final level on teardown When tearing down page tables, we return early for the final level since we know that we won't have any table pointers to follow. Unfortunately, this also means that we forget to free the final level, so we end up leaking memory. Fix the issue by always freeing the current level, but just don't bother to iterate over the ptes if we're at the final level. Cc: Reported-by: Zhang Bo Signed-off-by: Will Deacon --- drivers/iommu/io-pgtable-arm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index 7df97777662d..dad768caa9c5 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -405,17 +405,18 @@ static void __arm_lpae_free_pgtable(struct arm_lpae_io_pgtable *data, int lvl, arm_lpae_iopte *start, *end; unsigned long table_size; - /* Only leaf entries at the last level */ - if (lvl == ARM_LPAE_MAX_LEVELS - 1) - return; - if (lvl == ARM_LPAE_START_LVL(data)) table_size = data->pgd_size; else table_size = 1UL << data->pg_shift; start = ptep; - end = (void *)ptep + table_size; + + /* Only leaf entries at the last level */ + if (lvl == ARM_LPAE_MAX_LEVELS - 1) + end = ptep; + else + end = (void *)ptep + table_size; while (ptep != end) { arm_lpae_iopte pte = *ptep++;