Skip to contentSkip to conversation

FAILED: patch "[PATCH] iommu/io-pgtable-arm: Ensure we free the final level on" failed to apply to 4.4-stable tree

PATCH [email protected] 2 participants 5 messages Jan 27, 2016 – Feb 14, 2016

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

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 <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

Quoted 1 line

From 12c2ab09571e8aae3a87da2a4a452632a5fac1e5 Mon Sep 17 00:00:00 2001

From: Will Deacon <[email protected]>
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.

drivers/iommu/io-pgtable-arm.c +6 -5
index 937ba23e48d7..8bbcbfe7695c 100644
@@ -404,17 +404,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 = ARM_LPAE_GRANULE(data);
 
 	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++;
#1 lore raw

Hi Greg,

Quoted 5 lines · On Tue, Jan 26, 2016 at 10:48:23PM -0800, [email protected] 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 <[email protected]>.

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.

Will

Quoted 49 lines

------------------ original commit in Linus's tree ------------------

From 12c2ab09571e8aae3a87da2a4a452632a5fac1e5 Mon Sep 17 00:00:00 2001
From: Will Deacon <[email protected]>
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.

drivers/iommu/io-pgtable-arm.c +6 -5
index 937ba23e48d7..8bbcbfe7695c 100644
@@ -404,17 +404,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 = ARM_LPAE_GRANULE(data);
 
 	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++;
author maintainer
#2 lore raw
Quoted 11 lines · Will Deacon

Hi Greg,

Quoted 5 lines · On Tue, Jan 26, 2016 at 10:48:23PM -0800, [email protected] 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 <[email protected]>.

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?

thanks,

greg k-h

#3 lore raw
Quoted 32 lines · Greg KH
Quoted 9 lines · Will Deacon
Quoted 5 lines · On Tue, Jan 26, 2016 at 10:48:23PM -0800, [email protected] 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 <[email protected]>.

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

Quoted 1 line

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

Quoted 1 line

From 5ac63eeb89e736553a1fd728645d61abdfb04c72 Mon Sep 17 00:00:00 2001

From: Will Deacon <[email protected]>
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.

---
 drivers/iommu/io-pgtable-arm.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/iommu/io-pgtable-arm.c +6 -5
index 7df97777662d..dad768caa9c5 100644
@@ -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++;
Signature · 1 line
2.1.4
author maintainer
#4 lore raw
Quoted 33 lines · Will Deacon
Quoted 32 lines · Greg KH
Quoted 9 lines · Will Deacon
Quoted 5 lines · On Tue, Jan 26, 2016 at 10:48:23PM -0800, [email protected] 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 <[email protected]>.

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

Quoted 6 lines
Quoted 1 line

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.

Thanks, that worked.

greg k-h