Skip to contentSkip to conversation

linux-next: build failure after merge of the maple tree

PATCH Applied Stephen Rothwell 4 participants 15 messages Feb 17, 2022 – Feb 25, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

After merging the maple tree, today's linux-next build (arm64 defconfig) failed like this:

arch/arm64/kernel/elfcore.c: In function 'elf_core_extra_phdrs':
arch/arm64/kernel/elfcore.c:13:35: error: 'struct mm_struct' has no member named 'mmap'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:69:9: note: in expansion of macro 'for_each_mte_vma'

   69 |         for_each_mte_vma(current, vma)
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c:13:57: error: 'struct vm_area_struct' has no member named 'vm_next'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:69:9: note: in expansion of macro 'for_each_mte_vma'

   69 |         for_each_mte_vma(current, vma)
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c: In function 'elf_core_write_extra_phdrs':
arch/arm64/kernel/elfcore.c:13:35: error: 'struct mm_struct' has no member named 'mmap'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:79:9: note: in expansion of macro 'for_each_mte_vma'

   79 |         for_each_mte_vma(current, vma) {
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c:13:57: error: 'struct vm_area_struct' has no member named 'vm_next'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:79:9: note: in expansion of macro 'for_each_mte_vma'

   79 |         for_each_mte_vma(current, vma) {
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c: In function 'elf_core_extra_data_size':
arch/arm64/kernel/elfcore.c:13:35: error: 'struct mm_struct' has no member named 'mmap'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:104:9: note: in expansion of macro 'for_each_mte_vma'

  104 |         for_each_mte_vma(current, vma)
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c:13:57: error: 'struct vm_area_struct' has no member named 'vm_next'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:104:9: note: in expansion of macro 'for_each_mte_vma'

  104 |         for_each_mte_vma(current, vma)
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c: In function 'elf_core_write_extra_data':
arch/arm64/kernel/elfcore.c:13:35: error: 'struct mm_struct' has no member named 'mmap'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:114:9: note: in expansion of macro 'for_each_mte_vma'

  114 |         for_each_mte_vma(current, vma) {
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c:13:57: error: 'struct vm_area_struct' has no member named 'vm_next'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:114:9: note: in expansion of macro 'for_each_mte_vma'

  114 |         for_each_mte_vma(current, vma) {
      |         ^~~~~~~~~~~~~~~~

Caused by commit

b09e8361a4c3 ("mm: Remove the vma linked list")

interacting with commit

6dd8b1a0b6cb ("arm64: mte: Dump the MTE tags in the core file")

from the arm64 tree.

I have applied the following merge fix patch for today:

From: Stephen Rothwell <[email protected]>
Date: Thu, 17 Feb 2022 19:12:41 +1100
Subject: [PATCH] fix up for "arm64: mte: Dump the MTE tags in the core file"

---
 arch/arm64/kernel/elfcore.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
arch/arm64/kernel/elfcore.c +10 -6
index 3455ee4acc04..35f99088825e 100644
@@ -8,9 +8,9 @@
 #include <asm/cpufeature.h>
 #include <asm/mte.h>
 
-#define for_each_mte_vma(tsk, vma)					\
+#define for_each_mte_vma(mas, vma)					\
 	if (system_supports_mte())					\
-		for (vma = tsk->mm->mmap; vma; vma = vma->vm_next)	\
+		mas_for_each(&mas, vma, ULONG_MAX)			\
 			if (vma->vm_flags & VM_MTE)
 
 static unsigned long mte_vma_tag_dump_size(struct vm_area_struct *vma)
@@ -64,9 +64,10 @@ static int mte_dump_tag_range(struct coredump_params *cprm,
 Elf_Half elf_core_extra_phdrs(void)
 {
 	struct vm_area_struct *vma;
+	MA_STATE(mas, &current->mm->mm_mt, 0, 0);
 	int vma_count = 0;
 
-	for_each_mte_vma(current, vma)
+	for_each_mte_vma(mas, vma)
 		vma_count++;
 
 	return vma_count;
@@ -75,8 +76,9 @@ Elf_Half elf_core_extra_phdrs(void)
 int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
 {
 	struct vm_area_struct *vma;
+	MA_STATE(mas, &current->mm->mm_mt, 0, 0);
 
-	for_each_mte_vma(current, vma) {
+	for_each_mte_vma(mas, vma) {
 		struct elf_phdr phdr;
 
 		phdr.p_type = PT_ARM_MEMTAG_MTE;
@@ -99,9 +101,10 @@ int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
 size_t elf_core_extra_data_size(void)
 {
 	struct vm_area_struct *vma;
+	MA_STATE(mas, &current->mm->mm_mt, 0, 0);
 	size_t data_size = 0;
 
-	for_each_mte_vma(current, vma)
+	for_each_mte_vma(mas, vma)
 		data_size += mte_vma_tag_dump_size(vma);
 
 	return data_size;
@@ -110,8 +113,9 @@ size_t elf_core_extra_data_size(void)
 int elf_core_write_extra_data(struct coredump_params *cprm)
 {
 	struct vm_area_struct *vma;
+	MA_STATE(mas, &current->mm->mm_mt, 0, 0);
 
-	for_each_mte_vma(current, vma) {
+	for_each_mte_vma(mas, vma) {
 		if (vma->vm_flags & VM_DONTDUMP)
 			continue;
 
Signature · 5 lines
2.34.1

-- 
Cheers,
Stephen Rothwell
maintainer
#1 lore raw
Quoted 60 lines · Stephen Rothwell

Hi all,

After merging the maple tree, today's linux-next build (arm64 defconfig) failed like this:

arch/arm64/kernel/elfcore.c: In function 'elf_core_extra_phdrs':
arch/arm64/kernel/elfcore.c:13:35: error: 'struct mm_struct' has no member named 'mmap'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:69:9: note: in expansion of macro 'for_each_mte_vma'

   69 |         for_each_mte_vma(current, vma)
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c:13:57: error: 'struct vm_area_struct' has no member named 'vm_next'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:69:9: note: in expansion of macro 'for_each_mte_vma'

   69 |         for_each_mte_vma(current, vma)
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c: In function 'elf_core_write_extra_phdrs':
arch/arm64/kernel/elfcore.c:13:35: error: 'struct mm_struct' has no member named 'mmap'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:79:9: note: in expansion of macro 'for_each_mte_vma'

   79 |         for_each_mte_vma(current, vma) {
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c:13:57: error: 'struct vm_area_struct' has no member named 'vm_next'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:79:9: note: in expansion of macro 'for_each_mte_vma'

   79 |         for_each_mte_vma(current, vma) {
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c: In function 'elf_core_extra_data_size':
arch/arm64/kernel/elfcore.c:13:35: error: 'struct mm_struct' has no member named 'mmap'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:104:9: note: in expansion of macro 'for_each_mte_vma'

  104 |         for_each_mte_vma(current, vma)
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c:13:57: error: 'struct vm_area_struct' has no member named 'vm_next'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:104:9: note: in expansion of macro 'for_each_mte_vma'

  104 |         for_each_mte_vma(current, vma)
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c: In function 'elf_core_write_extra_data':
arch/arm64/kernel/elfcore.c:13:35: error: 'struct mm_struct' has no member named 'mmap'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:114:9: note: in expansion of macro 'for_each_mte_vma'

  114 |         for_each_mte_vma(current, vma) {
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c:13:57: error: 'struct vm_area_struct' has no member named 'vm_next'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:114:9: note: in expansion of macro 'for_each_mte_vma'

  114 |         for_each_mte_vma(current, vma) {
      |         ^~~~~~~~~~~~~~~~

Caused by commit

Quoted 7 lines

b09e8361a4c3 ("mm: Remove the vma linked list")

interacting with commit

6dd8b1a0b6cb ("arm64: mte: Dump the MTE tags in the core file")

from the arm64 tree.

Yikes, this is quite a mess. Liam -- how would you like to resolve this?

Will

#2 lore raw
Quoted 63 lines · Will Deacon
Quoted 62 lines · Stephen Rothwell

Hi all,

After merging the maple tree, today's linux-next build (arm64 defconfig) failed like this:

arch/arm64/kernel/elfcore.c: In function 'elf_core_extra_phdrs':
arch/arm64/kernel/elfcore.c:13:35: error: 'struct mm_struct' has no member named 'mmap'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:69:9: note: in expansion of macro 'for_each_mte_vma'

   69 |         for_each_mte_vma(current, vma)
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c:13:57: error: 'struct vm_area_struct' has no member named 'vm_next'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:69:9: note: in expansion of macro 'for_each_mte_vma'

   69 |         for_each_mte_vma(current, vma)
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c: In function 'elf_core_write_extra_phdrs':
arch/arm64/kernel/elfcore.c:13:35: error: 'struct mm_struct' has no member named 'mmap'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:79:9: note: in expansion of macro 'for_each_mte_vma'

   79 |         for_each_mte_vma(current, vma) {
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c:13:57: error: 'struct vm_area_struct' has no member named 'vm_next'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:79:9: note: in expansion of macro 'for_each_mte_vma'

   79 |         for_each_mte_vma(current, vma) {
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c: In function 'elf_core_extra_data_size':
arch/arm64/kernel/elfcore.c:13:35: error: 'struct mm_struct' has no member named 'mmap'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:104:9: note: in expansion of macro 'for_each_mte_vma'

  104 |         for_each_mte_vma(current, vma)
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c:13:57: error: 'struct vm_area_struct' has no member named 'vm_next'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:104:9: note: in expansion of macro 'for_each_mte_vma'

  104 |         for_each_mte_vma(current, vma)
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c: In function 'elf_core_write_extra_data':
arch/arm64/kernel/elfcore.c:13:35: error: 'struct mm_struct' has no member named 'mmap'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:114:9: note: in expansion of macro 'for_each_mte_vma'

  114 |         for_each_mte_vma(current, vma) {
      |         ^~~~~~~~~~~~~~~~

arch/arm64/kernel/elfcore.c:13:57: error: 'struct vm_area_struct' has no member named 'vm_next'
13 | for (vma = tsk->mm->mmap; vma; vma = vma->vm_next) \
| ^~
arch/arm64/kernel/elfcore.c:114:9: note: in expansion of macro 'for_each_mte_vma'

  114 |         for_each_mte_vma(current, vma) {
      |         ^~~~~~~~~~~~~~~~

Caused by commit

b09e8361a4c3 ("mm: Remove the vma linked list")

Quoted 7 lines
Quoted 5 lines

interacting with commit

6dd8b1a0b6cb ("arm64: mte: Dump the MTE tags in the core file")

from the arm64 tree.

Yikes, this is quite a mess. Liam -- how would you like to resolve this?

The removal of the vma linked list means tsk->mm->mmap and vma->vm_next are no longer usable. for_each_mte_vma() could be altered to take a vma iterator:

#define for_each_mte_vma(vmi, vma)					\
	if (system_supports_mte())					\
		for_each_vma(vmi, vma)					\
			if (vma->vm_flags & VM_MTE)

Then used as such:
VMA_ITERATOR(vmi, tsk->mm, 0);
...

for_each_mte_vma(vmi, vma) {
...
}

Where might I find a branch containing this patch? Is it a stand alone or part of a larger series?

Liam

#3 lore raw

PATCH 1/1 arm64: Change elfcore for_each_mte_vma() to use VMA iterator

This is an untested fix for the merge conflict of maple tree next and arm64 next.

Instead of using the linked list, use the vma iterator.

---
 arch/arm64/kernel/elfcore.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
arch/arm64/kernel/elfcore.c +10 -6
index 3455ee4acc04..930a0bc4cac4 100644
@@ -8,9 +8,9 @@
 #include <asm/cpufeature.h>
 #include <asm/mte.h>
 
-#define for_each_mte_vma(tsk, vma)					\
+#define for_each_mte_vma(vmi, vma)					\
 	if (system_supports_mte())					\
-		for (vma = tsk->mm->mmap; vma; vma = vma->vm_next)	\
+		for_each_vma(vmi, vma)					\
 			if (vma->vm_flags & VM_MTE)
 
 static unsigned long mte_vma_tag_dump_size(struct vm_area_struct *vma)
@@ -65,8 +65,9 @@ Elf_Half elf_core_extra_phdrs(void)
 {
 	struct vm_area_struct *vma;
 	int vma_count = 0;
+	VMA_ITERATOR(vmi, current->mm, 0);
 
-	for_each_mte_vma(current, vma)
+	for_each_mte_vma(vmi, vma)
 		vma_count++;
 
 	return vma_count;
@@ -75,8 +76,9 @@ Elf_Half elf_core_extra_phdrs(void)
 int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
 {
 	struct vm_area_struct *vma;
+	VMA_ITERATOR(vmi, current->mm, 0);
 
-	for_each_mte_vma(current, vma) {
+	for_each_mte_vma(vmi, vma) {
 		struct elf_phdr phdr;
 
 		phdr.p_type = PT_ARM_MEMTAG_MTE;
@@ -100,8 +102,9 @@ size_t elf_core_extra_data_size(void)
 {
 	struct vm_area_struct *vma;
 	size_t data_size = 0;
+	VMA_ITERATOR(vmi, current->mm, 0);
 
-	for_each_mte_vma(current, vma)
+	for_each_mte_vma(vmi, vma)
 		data_size += mte_vma_tag_dump_size(vma);
 
 	return data_size;
@@ -110,8 +113,9 @@ size_t elf_core_extra_data_size(void)
 int elf_core_write_extra_data(struct coredump_params *cprm)
 {
 	struct vm_area_struct *vma;
+	VMA_ITERATOR(vmi, current->mm, 0);
 
-	for_each_mte_vma(current, vma) {
+	for_each_mte_vma(vmi, vma) {
 		if (vma->vm_flags & VM_DONTDUMP)
 			continue;
 
Signature · 1 line
2.34.1
maintainer Acked-by on v1 1/1
#4 lore raw

Re: [PATCH] arm64: Change elfcore for_each_mte_vma() to use VMA iterator

Quoted 17 lines · Liam Howlett
arch/arm64/kernel/elfcore.c +2 -2
index 3455ee4acc04..930a0bc4cac4 100644
@@ -8,9 +8,9 @@
 #include <asm/cpufeature.h>
 #include <asm/mte.h>
 
-#define for_each_mte_vma(tsk, vma)					\
+#define for_each_mte_vma(vmi, vma)					\
 	if (system_supports_mte())					\
-		for (vma = tsk->mm->mmap; vma; vma = vma->vm_next)	\
+		for_each_vma(vmi, vma)					\
 			if (vma->vm_flags & VM_MTE)
 
 static unsigned long mte_vma_tag_dump_size(struct vm_area_struct *vma)

arch/arm64/kernel/elfcore.c Elf_Half elf_core_extra_phdrs(void) · line 71

Quoted 8 lines
arch/arm64/kernel/elfcore.c +2 -1
@@ -65,8 +65,9 @@ Elf_Half elf_core_extra_phdrs(void)
 {
 	struct vm_area_struct *vma;
 	int vma_count = 0;
+	VMA_ITERATOR(vmi, current->mm, 0);
 
-	for_each_mte_vma(current, vma)
+	for_each_mte_vma(vmi, vma)
 		vma_count++;

I'm fine with the patch but it can't be applied to arm64 for-next/mte branch as it won't build and the maple tree doesn't have the MTE patches. Do you have a stable branch with the for_each_vma() iterator?

Anyway, if you find a way to solve the problem, for this patch:

#5 lore raw

Re: [PATCH] arm64: Change elfcore for_each_mte_vma() to use VMA iterator

Quoted 23 lines · Catalin Marinas
Quoted 22 lines · Liam Howlett
arch/arm64/kernel/elfcore.c +3 -2
index 3455ee4acc04..930a0bc4cac4 100644
@@ -8,9 +8,9 @@
 #include <asm/cpufeature.h>
 #include <asm/mte.h>
 
-#define for_each_mte_vma(tsk, vma)					\
+#define for_each_mte_vma(vmi, vma)					\
 	if (system_supports_mte())					\
-		for (vma = tsk->mm->mmap; vma; vma = vma->vm_next)	\
+		for_each_vma(vmi, vma)					\
 			if (vma->vm_flags & VM_MTE)
 
 static unsigned long mte_vma_tag_dump_size(struct vm_area_struct *vma)
@@ -65,8 +65,9 @@ Elf_Half elf_core_extra_phdrs(void)
 {
 	struct vm_area_struct *vma;
 	int vma_count = 0;
+	VMA_ITERATOR(vmi, current->mm, 0);
 
Quoted 7 lines

arch/arm64/kernel/elfcore.c Elf_Half elf_core_extra_phdrs(void) · line 71

Quoted 3 lines
arch/arm64/kernel/elfcore.c +1 -1
-	for_each_mte_vma(current, vma)
+	for_each_mte_vma(vmi, vma)
 		vma_count++;

I'm fine with the patch but it can't be applied to arm64 for-next/mte branch as it won't build and the maple tree doesn't have the MTE patches. Do you have a stable branch with the for_each_vma() iterator?

The vma iterator uses the maple tree, so this patch would resolve the conflict but both branches are needed.

Quoted 4 lines

Anyway, if you find a way to solve the problem, for this patch:

maintainer
#6 lore raw

Re: [PATCH] arm64: Change elfcore for_each_mte_vma() to use VMA iterator

Quoted 32 lines · Liam Howlett
Quoted 23 lines · Catalin Marinas
Quoted 22 lines · Liam Howlett
arch/arm64/kernel/elfcore.c +3 -2
index 3455ee4acc04..930a0bc4cac4 100644
@@ -8,9 +8,9 @@
 #include <asm/cpufeature.h>
 #include <asm/mte.h>
 
-#define for_each_mte_vma(tsk, vma)					\
+#define for_each_mte_vma(vmi, vma)					\
 	if (system_supports_mte())					\
-		for (vma = tsk->mm->mmap; vma; vma = vma->vm_next)	\
+		for_each_vma(vmi, vma)					\
 			if (vma->vm_flags & VM_MTE)
 
 static unsigned long mte_vma_tag_dump_size(struct vm_area_struct *vma)
@@ -65,8 +65,9 @@ Elf_Half elf_core_extra_phdrs(void)
 {
 	struct vm_area_struct *vma;
 	int vma_count = 0;
+	VMA_ITERATOR(vmi, current->mm, 0);
 
Quoted 7 lines

arch/arm64/kernel/elfcore.c Elf_Half elf_core_extra_phdrs(void) · line 71

Quoted 3 lines
arch/arm64/kernel/elfcore.c +1 -1
-	for_each_mte_vma(current, vma)
+	for_each_mte_vma(vmi, vma)
 		vma_count++;

I'm fine with the patch but it can't be applied to arm64 for-next/mte branch as it won't build and the maple tree doesn't have the MTE patches. Do you have a stable branch with the for_each_vma() iterator?

Quoted 2 lines

The vma iterator uses the maple tree, so this patch would resolve the conflict but both branches are needed.

I'm not really sure what to do here, then. I think the conflict is nasty enough that we should resolve it before the trees reach Linus, but there doesn't seem to be a way forward other than one of us merging the other branch. I'd like to avoid having MTE coredump support depend on the maple tree work.

Is there some way you could provide a branch which implements for_each_vma() using the old vma list, and then the maple tree series could switch that over to the maple tree without breaking things?

Will

maintainer
#7 lore raw

Re: [PATCH] arm64: Change elfcore for_each_mte_vma() to use VMA iterator

Quoted 42 lines · Will Deacon
Quoted 32 lines · Liam Howlett
Quoted 23 lines · Catalin Marinas
Quoted 22 lines · Liam Howlett
arch/arm64/kernel/elfcore.c +3 -2
index 3455ee4acc04..930a0bc4cac4 100644
@@ -8,9 +8,9 @@
 #include <asm/cpufeature.h>
 #include <asm/mte.h>
 
-#define for_each_mte_vma(tsk, vma)					\
+#define for_each_mte_vma(vmi, vma)					\
 	if (system_supports_mte())					\
-		for (vma = tsk->mm->mmap; vma; vma = vma->vm_next)	\
+		for_each_vma(vmi, vma)					\
 			if (vma->vm_flags & VM_MTE)
 
 static unsigned long mte_vma_tag_dump_size(struct vm_area_struct *vma)
@@ -65,8 +65,9 @@ Elf_Half elf_core_extra_phdrs(void)
 {
 	struct vm_area_struct *vma;
 	int vma_count = 0;
+	VMA_ITERATOR(vmi, current->mm, 0);
 
Quoted 7 lines

arch/arm64/kernel/elfcore.c Elf_Half elf_core_extra_phdrs(void) · line 71

Quoted 3 lines
arch/arm64/kernel/elfcore.c +1 -1
-	for_each_mte_vma(current, vma)
+	for_each_mte_vma(vmi, vma)
 		vma_count++;

I'm fine with the patch but it can't be applied to arm64 for-next/mte branch as it won't build and the maple tree doesn't have the MTE patches. Do you have a stable branch with the for_each_vma() iterator?

Quoted 2 lines

The vma iterator uses the maple tree, so this patch would resolve the conflict but both branches are needed.

I'm not really sure what to do here, then. I think the conflict is nasty enough that we should resolve it before the trees reach Linus, but there doesn't seem to be a way forward other than one of us merging the other branch. I'd like to avoid having MTE coredump support depend on the maple tree work.

Quoted 3 lines

Is there some way you could provide a branch which implements for_each_vma() using the old vma list, and then the maple tree series could switch that over to the maple tree without breaking things?

Without a branch, we could apply something like below on top of Liam's patch and revert it once the maple tree is upstream:

arch/arm64/kernel/elfcore.c +7 -0
index 930a0bc4cac4..400ec7a902df 100644
@@ -8,6 +8,13 @@
 #include <asm/cpufeature.h>
 #include <asm/mte.h>
 
+#ifndef VMA_ITERATOR
+#define VMA_ITERATOR(name, mm, addr) \
+	struct mm_struct *name = mm
+#define for_each_vma(vmi, vma) \
+	for (vma = vmi->mmap; vma; vma = vma->vm_next)
+#endif
+
 #define for_each_mte_vma(vmi, vma)					\
 	if (system_supports_mte())					\
 		for_each_vma(vmi, vma)					\
Signature · 1 line
Catalin
#8 lore raw

Re: [PATCH] arm64: Change elfcore for_each_mte_vma() to use VMA iterator

Quoted 59 lines · Catalin Marinas
Quoted 42 lines · Will Deacon
Quoted 32 lines · Liam Howlett
Quoted 23 lines · Catalin Marinas
Quoted 22 lines · Liam Howlett
arch/arm64/kernel/elfcore.c +3 -2
index 3455ee4acc04..930a0bc4cac4 100644
@@ -8,9 +8,9 @@
 #include <asm/cpufeature.h>
 #include <asm/mte.h>
 
-#define for_each_mte_vma(tsk, vma)					\
+#define for_each_mte_vma(vmi, vma)					\
 	if (system_supports_mte())					\
-		for (vma = tsk->mm->mmap; vma; vma = vma->vm_next)	\
+		for_each_vma(vmi, vma)					\
 			if (vma->vm_flags & VM_MTE)
 
 static unsigned long mte_vma_tag_dump_size(struct vm_area_struct *vma)
@@ -65,8 +65,9 @@ Elf_Half elf_core_extra_phdrs(void)
 {
 	struct vm_area_struct *vma;
 	int vma_count = 0;
+	VMA_ITERATOR(vmi, current->mm, 0);
 
Quoted 7 lines

arch/arm64/kernel/elfcore.c Elf_Half elf_core_extra_phdrs(void) · line 71

Quoted 3 lines
arch/arm64/kernel/elfcore.c +1 -1
-	for_each_mte_vma(current, vma)
+	for_each_mte_vma(vmi, vma)
 		vma_count++;

I'm fine with the patch but it can't be applied to arm64 for-next/mte branch as it won't build and the maple tree doesn't have the MTE patches. Do you have a stable branch with the for_each_vma() iterator?

Quoted 2 lines

The vma iterator uses the maple tree, so this patch would resolve the conflict but both branches are needed.

I'm not really sure what to do here, then. I think the conflict is nasty enough that we should resolve it before the trees reach Linus, but there doesn't seem to be a way forward other than one of us merging the other branch. I'd like to avoid having MTE coredump support depend on the maple tree work.

Quoted 3 lines

Is there some way you could provide a branch which implements for_each_vma() using the old vma list, and then the maple tree series could switch that over to the maple tree without breaking things?

Without a branch, we could apply something like below on top of Liam's patch and revert it once the maple tree is upstream:

arch/arm64/kernel/elfcore.c +0 -0
index 930a0bc4cac4..400ec7a902df 100644
@@ -8,6 +8,13 @@
 #include <asm/cpufeature.h>
 #include <asm/mte.h>
 

arch/arm64/kernel/elfcore.c line 20

Quoted 10 lines
arch/arm64/kernel/elfcore.c +7 -0
+#ifndef VMA_ITERATOR
+#define VMA_ITERATOR(name, mm, addr) \
+	struct mm_struct *name = mm
+#define for_each_vma(vmi, vma) \
+	for (vma = vmi->mmap; vma; vma = vma->vm_next)
+#endif
+
 #define for_each_mte_vma(vmi, vma)					\
 	if (system_supports_mte())					\
 		for_each_vma(vmi, vma)					\

Note that the current VMA_ITERATOR takes a new type and not the mm.

Since I am removing the linked list (mm->mmap and vma->vm_next), then the build will fail if this patch and the maple tree branch exist together. The iterator may also not start at the start of the list (but usually does) and may not run through the entire list; see vma_for_each_range() in the patch set.

Once the maple tree is upstream, then you can take the patch I posted. I think this is a situation that Linus could take the fixup?

Thanks,
Liam

maintainer
#9 lore raw

Re: [PATCH] arm64: Change elfcore for_each_mte_vma() to use VMA iterator

Quoted 27 lines · Liam Howlett
Quoted 26 lines · Catalin Marinas
Quoted 10 lines · Will Deacon
Quoted 2 lines · Liam Howlett

The vma iterator uses the maple tree, so this patch would resolve the conflict but both branches are needed.

I'm not really sure what to do here, then. I think the conflict is nasty enough that we should resolve it before the trees reach Linus, but there doesn't seem to be a way forward other than one of us merging the other branch. I'd like to avoid having MTE coredump support depend on the maple tree work.

Quoted 3 lines

Is there some way you could provide a branch which implements for_each_vma() using the old vma list, and then the maple tree series could switch that over to the maple tree without breaking things?

Without a branch, we could apply something like below on top of Liam's patch and revert it once the maple tree is upstream:

arch/arm64/kernel/elfcore.c +0 -0
index 930a0bc4cac4..400ec7a902df 100644
@@ -8,6 +8,13 @@
 #include <asm/cpufeature.h>
 #include <asm/mte.h>
 
Quoted 12 lines

arch/arm64/kernel/elfcore.c line 20

Quoted 10 lines
arch/arm64/kernel/elfcore.c +7 -0
+#ifndef VMA_ITERATOR
+#define VMA_ITERATOR(name, mm, addr) \
+	struct mm_struct *name = mm
+#define for_each_vma(vmi, vma) \
+	for (vma = vmi->mmap; vma; vma = vma->vm_next)
+#endif
+
 #define for_each_mte_vma(vmi, vma)					\
 	if (system_supports_mte())					\
 		for_each_vma(vmi, vma)					\

Note that the current VMA_ITERATOR takes a new type and not the mm.

Well, in you proposed fix, it does take current->mm.

Quoted 5 lines

Since I am removing the linked list (mm->mmap and vma->vm_next), then the build will fail if this patch and the maple tree branch exist together. The iterator may also not start at the start of the list (but usually does) and may not run through the entire list; see vma_for_each_range() in the patch set.

My hack above is only temporary to allow building the arm64 tree on its own (no maple tree branch) and with your patch on top. In -next, when merged with the maple tree branch, the VMA_ITERATOR macro is already defined and the above hack skipped. We'll revert this hack around -rc1.

Note that the hack above is only in the arm64 elfcore.c, not a generic API solution.

Signature · 1 line
Catalin
#10 lore raw

Re: [PATCH] arm64: Change elfcore for_each_mte_vma() to use VMA iterator

Quoted 41 lines · Catalin Marinas
Quoted 27 lines · Liam Howlett
Quoted 26 lines · Catalin Marinas
Quoted 10 lines · Will Deacon
Quoted 2 lines · Liam Howlett

The vma iterator uses the maple tree, so this patch would resolve the conflict but both branches are needed.

I'm not really sure what to do here, then. I think the conflict is nasty enough that we should resolve it before the trees reach Linus, but there doesn't seem to be a way forward other than one of us merging the other branch. I'd like to avoid having MTE coredump support depend on the maple tree work.

Quoted 3 lines

Is there some way you could provide a branch which implements for_each_vma() using the old vma list, and then the maple tree series could switch that over to the maple tree without breaking things?

Without a branch, we could apply something like below on top of Liam's patch and revert it once the maple tree is upstream:

arch/arm64/kernel/elfcore.c +0 -0
index 930a0bc4cac4..400ec7a902df 100644
@@ -8,6 +8,13 @@
 #include <asm/cpufeature.h>
 #include <asm/mte.h>
 
Quoted 12 lines

arch/arm64/kernel/elfcore.c line 20

Quoted 10 lines
arch/arm64/kernel/elfcore.c +7 -0
+#ifndef VMA_ITERATOR
+#define VMA_ITERATOR(name, mm, addr) \
+	struct mm_struct *name = mm
+#define for_each_vma(vmi, vma) \
+	for (vma = vmi->mmap; vma; vma = vma->vm_next)
+#endif
+
 #define for_each_mte_vma(vmi, vma)					\
 	if (system_supports_mte())					\
 		for_each_vma(vmi, vma)					\

Note that the current VMA_ITERATOR takes a new type and not the mm.

Quoted 1 line

Well, in you proposed fix, it does take current->mm.

Sorry. Yes, you are correct. The VMA_ITERATOR() takes the mm. The for each takes the vmi.

Quoted 7 lines
Quoted 6 lines

Since I am removing the linked list (mm->mmap and vma->vm_next), then the build will fail if this patch and the maple tree branch exist together. The iterator may also not start at the start of the list (but usually does) and may not run through the entire list; see vma_for_each_range() in the patch set.

Quoted 7 lines

My hack above is only temporary to allow building the arm64 tree on its own (no maple tree branch) and with your patch on top. In -next, when merged with the maple tree branch, the VMA_ITERATOR macro is already defined and the above hack skipped. We'll revert this hack around -rc1.

Note that the hack above is only in the arm64 elfcore.c, not a generic API solution.

Okay, thanks. This sounds good if it works on your side. Sorry for not getting it earlier.

Liam

maintainer
#11 lore raw

Re: [PATCH] arm64: Change elfcore for_each_mte_vma() to use VMA iterator

In reply to Liam Howlett
Quoted 1 line · Liam Howlett

Once the maple tree is upstream, then you can take the patch I posted.

BTW, on the maple tree branch alone
(https://github.com/oracle/linux-uek.git maple/mainline), I get the warning below and no core file generated. It's not MTE related as it doesn't have my patches.

[   67.887638] WARNING: CPU: 1 PID: 528 at fs/coredump.c:1116 dump_vma_snapshot+0x98/0x18c
[   67.888594] Modules linked in: crct10dif_ce sm3_ce sm3_generic sha3_ce sha3_generic sha512_ce sha512_arm64 drm fuse ip_tables x_tables ipv6
[   67.890017] CPU: 1 PID: 528 Comm: mte-coredump Not tainted 5.17.0-rc4-00071-gc8cf067d6a99 #1
[   67.890494] Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
[   67.891054] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   67.891469] pc : dump_vma_snapshot+0x98/0x18c
[   67.891787] lr : dump_vma_snapshot+0x74/0x18c
[   67.892071] sp : ffff80000839b8f0
[   67.892278] x29: ffff80000839b8f0 x28: ffffd4a81d76255c x27: 0000000000000000
[   67.892894] x26: ffffd4a81da308e0 x25: 0000000000000000 x24: ffff80000839bc78
[   67.893436] x23: ffff00000557cf00 x22: ffff00000557cf60 x21: ffff80000839b9e0
[   67.893922] x20: ffff80000839b9e8 x19: ffff80000839b9dc x18: 0000000000000000
[   67.894497] x17: 0000000000000000 x16: 0000ffff9e8effff x15: 0000000000000000
[   67.895061] x14: 0000000000000000 x13: ffff0000025f9000 x12: ffff000001a2eb94
[   67.895590] x11: ffff80000839b100 x10: ffff80000839b108 x9 : 0000000000000000
[   67.896057] x8 : ffff80000839bb68 x7 : 0000000000000000 x6 : 0000000000896101
[   67.896537] x5 : ffff0000016bf000 x4 : ffff80000839b8b0 x3 : 0000000000000001
[   67.896961] x2 : 0000000000000000 x1 : 0000000000000001 x0 : 0000000000000011
[   67.897493] Call trace:
[   67.897679]  dump_vma_snapshot+0x98/0x18c
[   67.898034]  elf_core_dump+0x50/0xcf0
[   67.898274]  do_coredump+0xbdc/0xfc4
[   67.898553]  get_signal+0x524/0x7f0
[   67.898775]  do_notify_resume+0x224/0x1330
[   67.899046]  el0_da+0x50/0x60
[   67.899431]  el0t_64_sync_handler+0xec/0x130
[   67.899726]  el0t_64_sync+0x1a0/0x1a4
Signature · 1 line
Catalin
#12 lore raw

Re: [PATCH] arm64: Change elfcore for_each_mte_vma() to use VMA iterator

Quoted 27 lines · Catalin Marinas
Quoted 1 line · Liam Howlett

Once the maple tree is upstream, then you can take the patch I posted.

BTW, on the maple tree branch alone
(https://github.com/oracle/linux-uek.git maple/mainline), I get the warning below and no core file generated. It's not MTE related as it doesn't have my patches.

[   67.887638] WARNING: CPU: 1 PID: 528 at fs/coredump.c:1116 dump_vma_snapshot+0x98/0x18c
[   67.888594] Modules linked in: crct10dif_ce sm3_ce sm3_generic sha3_ce sha3_generic sha512_ce sha512_arm64 drm fuse ip_tables x_tables ipv6
[   67.890017] CPU: 1 PID: 528 Comm: mte-coredump Not tainted 5.17.0-rc4-00071-gc8cf067d6a99 #1
[   67.890494] Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
[   67.891054] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   67.891469] pc : dump_vma_snapshot+0x98/0x18c
[   67.891787] lr : dump_vma_snapshot+0x74/0x18c
[   67.892071] sp : ffff80000839b8f0
[   67.892278] x29: ffff80000839b8f0 x28: ffffd4a81d76255c x27: 0000000000000000
[   67.892894] x26: ffffd4a81da308e0 x25: 0000000000000000 x24: ffff80000839bc78
[   67.893436] x23: ffff00000557cf00 x22: ffff00000557cf60 x21: ffff80000839b9e0
[   67.893922] x20: ffff80000839b9e8 x19: ffff80000839b9dc x18: 0000000000000000
[   67.894497] x17: 0000000000000000 x16: 0000ffff9e8effff x15: 0000000000000000
[   67.895061] x14: 0000000000000000 x13: ffff0000025f9000 x12: ffff000001a2eb94
[   67.895590] x11: ffff80000839b100 x10: ffff80000839b108 x9 : 0000000000000000
[   67.896057] x8 : ffff80000839bb68 x7 : 0000000000000000 x6 : 0000000000896101
[   67.896537] x5 : ffff0000016bf000 x4 : ffff80000839b8b0 x3 : 0000000000000001
[   67.896961] x2 : 0000000000000000 x1 : 0000000000000001 x0 : 0000000000000011
[   67.897493] Call trace:
Quoted 9 lines
[   67.897679]  dump_vma_snapshot+0x98/0x18c
[   67.898034]  elf_core_dump+0x50/0xcf0
[   67.898274]  do_coredump+0xbdc/0xfc4
[   67.898553]  get_signal+0x524/0x7f0
[   67.898775]  do_notify_resume+0x224/0x1330
[   67.899046]  el0_da+0x50/0x60
[   67.899431]  el0t_64_sync_handler+0xec/0x130
[   67.899726]  el0t_64_sync+0x1a0/0x1a4

Thank you. I will look into this immediately. Was this with default config for arm64? Was it with a vm or real hardware?

Cheers,
Liam

#13 lore raw

Re: [PATCH] arm64: Change elfcore for_each_mte_vma() to use VMA iterator

Quoted 38 lines · Liam R. Howlett
Quoted 27 lines · Catalin Marinas
Quoted 1 line · Liam Howlett

Once the maple tree is upstream, then you can take the patch I posted.

BTW, on the maple tree branch alone
(https://github.com/oracle/linux-uek.git maple/mainline), I get the warning below and no core file generated. It's not MTE related as it doesn't have my patches.

[   67.887638] WARNING: CPU: 1 PID: 528 at fs/coredump.c:1116 dump_vma_snapshot+0x98/0x18c
[   67.888594] Modules linked in: crct10dif_ce sm3_ce sm3_generic sha3_ce sha3_generic sha512_ce sha512_arm64 drm fuse ip_tables x_tables ipv6
[   67.890017] CPU: 1 PID: 528 Comm: mte-coredump Not tainted 5.17.0-rc4-00071-gc8cf067d6a99 #1
[   67.890494] Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
[   67.891054] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   67.891469] pc : dump_vma_snapshot+0x98/0x18c
[   67.891787] lr : dump_vma_snapshot+0x74/0x18c
[   67.892071] sp : ffff80000839b8f0
[   67.892278] x29: ffff80000839b8f0 x28: ffffd4a81d76255c x27: 0000000000000000
[   67.892894] x26: ffffd4a81da308e0 x25: 0000000000000000 x24: ffff80000839bc78
[   67.893436] x23: ffff00000557cf00 x22: ffff00000557cf60 x21: ffff80000839b9e0
[   67.893922] x20: ffff80000839b9e8 x19: ffff80000839b9dc x18: 0000000000000000
[   67.894497] x17: 0000000000000000 x16: 0000ffff9e8effff x15: 0000000000000000
[   67.895061] x14: 0000000000000000 x13: ffff0000025f9000 x12: ffff000001a2eb94
[   67.895590] x11: ffff80000839b100 x10: ffff80000839b108 x9 : 0000000000000000
[   67.896057] x8 : ffff80000839bb68 x7 : 0000000000000000 x6 : 0000000000896101
[   67.896537] x5 : ffff0000016bf000 x4 : ffff80000839b8b0 x3 : 0000000000000001
[   67.896961] x2 : 0000000000000000 x1 : 0000000000000001 x0 : 0000000000000011
[   67.897493] Call trace:
Quoted 9 lines
[   67.897679]  dump_vma_snapshot+0x98/0x18c
[   67.898034]  elf_core_dump+0x50/0xcf0
[   67.898274]  do_coredump+0xbdc/0xfc4
[   67.898553]  get_signal+0x524/0x7f0
[   67.898775]  do_notify_resume+0x224/0x1330
[   67.899046]  el0_da+0x50/0x60
[   67.899431]  el0t_64_sync_handler+0xec/0x130
[   67.899726]  el0t_64_sync+0x1a0/0x1a4
Quoted 2 lines

Thank you. I will look into this immediately. Was this with default config for arm64? Was it with a vm or real hardware?

I was able to reproduce it and have a fix for tomorrow.

Thanks,
Liam

maintainer Applied
#14 lore raw

Re: [PATCH] arm64: Change elfcore for_each_mte_vma() to use VMA iterator

In reply to Liam Howlett
Quoted 6 lines · Liam Howlett

This is an untested fix for the merge conflict of maple tree next and arm64 next.

Instead of using the linked list, use the vma iterator.

Applied to arm64 (for-next/coredump), thanks!

[1/1] arm64: Change elfcore for_each_mte_vma() to use VMA iterator

      https://git.kernel.org/arm64/c/3a4f7ef4bed5

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev