Skip to contentSkip to conversation

Two minor fixes for BBML2_NOABORT

PATCH Superseded Yang Shi 4 participants 14 messages Oct 13, 2025 – Oct 30, 2025 arm64

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yang Shi

author
#0 lore raw

cover Two minor fixes for BBML2_NOABORT

Yang Shi (2):
arm64: mm: make linear mapping permission update more robust for patial range
arm64: mm: relax VM_ALLOW_HUGE_VMAP if BBML2_NOABORT is supported

 arch/arm64/mm/pageattr.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
author
#1 lore raw

PATCH 1/2 arm64: mm: make linear mapping permission update more robust for patial range

The commit fcf8dda8cc48 ("arm64: pageattr: Explicitly bail out when changing permissions for vmalloc_huge mappings") made permission update for partial range more robust. But the linear mapping permission update still assumes update the whole range by iterating from the first page all the way to the last page of the area.

Make it more robust by updating the linear mapping permission from the page mapped by start address, and update the number of numpages.

Fixes fcf8dda8cc48 ("arm64: pageattr: Explicitly bail out when changing permissions for vmalloc_huge mappings")
---
 arch/arm64/mm/pageattr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/mm/pageattr.c +3 -3
index 5135f2d66958..c21a2c319028 100644
@@ -148,7 +148,6 @@ static int change_memory_common(unsigned long addr, int numpages,
 	unsigned long size = PAGE_SIZE * numpages;
 	unsigned long end = start + size;
 	struct vm_struct *area;
-	int i;
 
 	if (!PAGE_ALIGNED(addr)) {
 		start &= PAGE_MASK;
@@ -184,8 +183,9 @@ static int change_memory_common(unsigned long addr, int numpages,
 	 */
 	if (rodata_full && (pgprot_val(set_mask) == PTE_RDONLY ||
 			    pgprot_val(clear_mask) == PTE_RDONLY)) {
-		for (i = 0; i < area->nr_pages; i++) {
-			__change_memory_common((u64)page_address(area->pages[i]),
+		unsigned long idx = (start - (unsigned long)area->addr) >> PAGE_SHIFT;
+		for (int i = 0; i < numpages; i++) {
+			__change_memory_common((u64)page_address(area->pages[idx++]),
 					       PAGE_SIZE, set_mask, clear_mask);
 		}
 	}
Signature · 1 line
2.47.0
author
#7 lore raw

PATCH 2/2 arm64: mm: relax VM_ALLOW_HUGE_VMAP if BBML2_NOABORT is supported

In reply to Yang Shi

When changing permissions for vmalloc area, VM_ALLOW_HUGE_VMAP area is exclueded because kernel can't split the va mapping if it is called on partial range.
It is no longer true if the machines support BBML2_NOABORT after commit a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full"). So we can relax this restriction and update the comments accordingly.

Fixes a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full")
---
 arch/arm64/mm/pageattr.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
arch/arm64/mm/pageattr.c +7 -6
index c21a2c319028..b4dcae6273a8 100644
@@ -157,13 +157,13 @@ static int change_memory_common(unsigned long addr, int numpages,
 
 	/*
 	 * Kernel VA mappings are always live, and splitting live section
-	 * mappings into page mappings may cause TLB conflicts. This means
-	 * we have to ensure that changing the permission bits of the range
-	 * we are operating on does not result in such splitting.
+	 * mappings into page mappings may cause TLB conflicts on the machines
+	 * which don't support BBML2_NOABORT.
 	 *
 	 * Let's restrict ourselves to mappings created by vmalloc (or vmap).
-	 * Disallow VM_ALLOW_HUGE_VMAP mappings to guarantee that only page
-	 * mappings are updated and splitting is never needed.
+	 * Disallow VM_ALLOW_HUGE_VMAP mappings if the systems don't support
+	 * BBML2_NOABORT to guarantee that only page mappings are updated and
+	 * splitting is never needed on those machines.
 	 *
 	 * So check whether the [addr, addr + size) interval is entirely
 	 * covered by precisely one VM area that has the VM_ALLOC flag set.
@@ -171,7 +171,8 @@ static int change_memory_common(unsigned long addr, int numpages,
 	area = find_vm_area((void *)addr);
 	if (!area ||
 	    end > (unsigned long)kasan_reset_tag(area->addr) + area->size ||
-	    ((area->flags & (VM_ALLOC | VM_ALLOW_HUGE_VMAP)) != VM_ALLOC))
+	    !(area->flags & VM_ALLOC) || ((area->flags & VM_ALLOW_HUGE_VMAP) &&
+	    !system_supports_bbml2_noabort()))
 		return -EINVAL;
 
 	if (!numpages)
Signature · 1 line
2.47.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] arm64: mm: make linear mapping permission update more robust for patial range

In reply to Yang Shi
Quoted 10 lines · Yang Shi

The commit fcf8dda8cc48 ("arm64: pageattr: Explicitly bail out when changing permissions for vmalloc_huge mappings") made permission update for partial range more robust. But the linear mapping permission update still assumes update the whole range by iterating from the first page all the way to the last page of the area.

Make it more robust by updating the linear mapping permission from the page mapped by start address, and update the number of numpages.

Fixes fcf8dda8cc48 ("arm64: pageattr: Explicitly bail out when changing permissions for vmalloc_huge mappings")

I don't think this is the correct commit. I think this theoretical issue was present before that. But it is only theoretical AFAIK? In which case, I'd be inclined to just drop the tag.

Otherwise, LGTM:

Quoted 29 lines
---
 arch/arm64/mm/pageattr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/mm/pageattr.c +3 -3
index 5135f2d66958..c21a2c319028 100644
@@ -148,7 +148,6 @@ static int change_memory_common(unsigned long addr, int numpages,
 	unsigned long size = PAGE_SIZE * numpages;
 	unsigned long end = start + size;
 	struct vm_struct *area;
-	int i;
 
 	if (!PAGE_ALIGNED(addr)) {
 		start &= PAGE_MASK;
@@ -184,8 +183,9 @@ static int change_memory_common(unsigned long addr, int numpages,
 	 */
 	if (rodata_full && (pgprot_val(set_mask) == PTE_RDONLY ||
 			    pgprot_val(clear_mask) == PTE_RDONLY)) {
-		for (i = 0; i < area->nr_pages; i++) {
-			__change_memory_common((u64)page_address(area->pages[i]),
+		unsigned long idx = (start - (unsigned long)area->addr) >> PAGE_SHIFT;
+		for (int i = 0; i < numpages; i++) {
+			__change_memory_common((u64)page_address(area->pages[idx++]),
 					       PAGE_SIZE, set_mask, clear_mask);
 		}
 	}
#8 lore raw

Re: [PATCH 2/2] arm64: mm: relax VM_ALLOW_HUGE_VMAP if BBML2_NOABORT is supported

In reply to Yang Shi
Quoted 6 lines · Yang Shi

When changing permissions for vmalloc area, VM_ALLOW_HUGE_VMAP area is exclueded because kernel can't split the va mapping if it is called on partial range.
It is no longer true if the machines support BBML2_NOABORT after commit a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full"). So we can relax this restriction and update the comments accordingly.

Is there actually any user that benefits from this modified behaviour in the current kernel? If not, then I'd prefer to leave this for Dev to modify systematically as part of his series to enable VM_ALLOW_HUGE_VMAP by default for arm64. I believe he's planning to post that soon.

Thanks,
Ryan

Quoted 40 lines
Fixes a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full")
---
 arch/arm64/mm/pageattr.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
arch/arm64/mm/pageattr.c +7 -6
index c21a2c319028..b4dcae6273a8 100644
@@ -157,13 +157,13 @@ static int change_memory_common(unsigned long addr, int numpages,
 
 	/*
 	 * Kernel VA mappings are always live, and splitting live section
-	 * mappings into page mappings may cause TLB conflicts. This means
-	 * we have to ensure that changing the permission bits of the range
-	 * we are operating on does not result in such splitting.
+	 * mappings into page mappings may cause TLB conflicts on the machines
+	 * which don't support BBML2_NOABORT.
 	 *
 	 * Let's restrict ourselves to mappings created by vmalloc (or vmap).
-	 * Disallow VM_ALLOW_HUGE_VMAP mappings to guarantee that only page
-	 * mappings are updated and splitting is never needed.
+	 * Disallow VM_ALLOW_HUGE_VMAP mappings if the systems don't support
+	 * BBML2_NOABORT to guarantee that only page mappings are updated and
+	 * splitting is never needed on those machines.
 	 *
 	 * So check whether the [addr, addr + size) interval is entirely
 	 * covered by precisely one VM area that has the VM_ALLOC flag set.
@@ -171,7 +171,8 @@ static int change_memory_common(unsigned long addr, int numpages,
 	area = find_vm_area((void *)addr);
 	if (!area ||
 	    end > (unsigned long)kasan_reset_tag(area->addr) + area->size ||
-	    ((area->flags & (VM_ALLOC | VM_ALLOW_HUGE_VMAP)) != VM_ALLOC))
+	    !(area->flags & VM_ALLOC) || ((area->flags & VM_ALLOW_HUGE_VMAP) &&
+	    !system_supports_bbml2_noabort()))
 		return -EINVAL;
 
 	if (!numpages)
author
#3 lore raw

Re: [PATCH 1/2] arm64: mm: make linear mapping permission update more robust for patial range

In reply to Ryan Roberts
Quoted 7 lines · Ryan Roberts
Quoted 6 lines · Yang Shi

The commit fcf8dda8cc48 ("arm64: pageattr: Explicitly bail out when changing permissions for vmalloc_huge mappings") made permission update for partial range more robust. But the linear mapping permission update still assumes update the whole range by iterating from the first page all the way to the last page of the area.

Quoted 7 lines
Quoted 4 lines

Make it more robust by updating the linear mapping permission from the page mapped by start address, and update the number of numpages.

Fixes fcf8dda8cc48 ("arm64: pageattr: Explicitly bail out when changing permissions for vmalloc_huge mappings")

I don't think this is the correct commit. I think this theoretical issue was present before that. But it is only theoretical AFAIK? In which case, I'd be inclined to just drop the tag.

OK, I will drop the tag.

Quoted 4 lines

Otherwise, LGTM:

Thank you.

Yang

Quoted 30 lines
Quoted 30 lines
---
  arch/arm64/mm/pageattr.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/mm/pageattr.c +3 -3
index 5135f2d66958..c21a2c319028 100644
@@ -148,7 +148,6 @@ static int change_memory_common(unsigned long addr, int numpages,
  	unsigned long size = PAGE_SIZE * numpages;
  	unsigned long end = start + size;
  	struct vm_struct *area;
-	int i;
 
  	if (!PAGE_ALIGNED(addr)) {
  		start &= PAGE_MASK;
@@ -184,8 +183,9 @@ static int change_memory_common(unsigned long addr, int numpages,
  	 */
  	if (rodata_full && (pgprot_val(set_mask) == PTE_RDONLY ||
  			    pgprot_val(clear_mask) == PTE_RDONLY)) {
-		for (i = 0; i < area->nr_pages; i++) {
-			__change_memory_common((u64)page_address(area->pages[i]),
+		unsigned long idx = (start - (unsigned long)area->addr) >> PAGE_SHIFT;
+		for (int i = 0; i < numpages; i++) {
+			__change_memory_common((u64)page_address(area->pages[idx++]),
  					       PAGE_SIZE, set_mask, clear_mask);
  		}
  	}
author
#9 lore raw

Re: [PATCH 2/2] arm64: mm: relax VM_ALLOW_HUGE_VMAP if BBML2_NOABORT is supported

In reply to Ryan Roberts
Quoted 11 lines · Ryan Roberts
Quoted 6 lines · Yang Shi

When changing permissions for vmalloc area, VM_ALLOW_HUGE_VMAP area is exclueded because kernel can't split the va mapping if it is called on partial range.
It is no longer true if the machines support BBML2_NOABORT after commit a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full"). So we can relax this restriction and update the comments accordingly.

Is there actually any user that benefits from this modified behaviour in the current kernel? If not, then I'd prefer to leave this for Dev to modify systematically as part of his series to enable VM_ALLOW_HUGE_VMAP by default for arm64. I believe he's planning to post that soon.

I actually just wanted to fix the stale comment about "splitting is never needed" in the first place as we discussed in earlier review, but I realized it doesn't make too much sense to just update the comment itself w/o updating the behavior. Because the skipping VM_ALLOW_HUGE_VMAP behavior was added because va mapping can't be split, so it makes more sense to relax it if va mapping can be split.

I looked at this patch more like a follow-up fix for split kernel page table than an enhancement for VM_ALLOW_HUGE_VMAP. And it also seems like a prerequisite for Dev's series IMHO.

Thanks,
Yang

Quoted 43 lines

Thanks,
Ryan

Quoted 39 lines
Fixes a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full")
---
  arch/arm64/mm/pageattr.c | 13 +++++++------
  1 file changed, 7 insertions(+), 6 deletions(-)
arch/arm64/mm/pageattr.c +7 -6
index c21a2c319028..b4dcae6273a8 100644
@@ -157,13 +157,13 @@ static int change_memory_common(unsigned long addr, int numpages,
 
  	/*
  	 * Kernel VA mappings are always live, and splitting live section
-	 * mappings into page mappings may cause TLB conflicts. This means
-	 * we have to ensure that changing the permission bits of the range
-	 * we are operating on does not result in such splitting.
+	 * mappings into page mappings may cause TLB conflicts on the machines
+	 * which don't support BBML2_NOABORT.
  	 *
  	 * Let's restrict ourselves to mappings created by vmalloc (or vmap).
-	 * Disallow VM_ALLOW_HUGE_VMAP mappings to guarantee that only page
-	 * mappings are updated and splitting is never needed.
+	 * Disallow VM_ALLOW_HUGE_VMAP mappings if the systems don't support
+	 * BBML2_NOABORT to guarantee that only page mappings are updated and
+	 * splitting is never needed on those machines.
  	 *
  	 * So check whether the [addr, addr + size) interval is entirely
  	 * covered by precisely one VM area that has the VM_ALLOC flag set.
@@ -171,7 +171,8 @@ static int change_memory_common(unsigned long addr, int numpages,
  	area = find_vm_area((void *)addr);
  	if (!area ||
  	    end > (unsigned long)kasan_reset_tag(area->addr) + area->size ||
-	    ((area->flags & (VM_ALLOC | VM_ALLOW_HUGE_VMAP)) != VM_ALLOC))
+	    !(area->flags & VM_ALLOC) || ((area->flags & VM_ALLOW_HUGE_VMAP) &&
+	    !system_supports_bbml2_noabort()))
  		return -EINVAL;
 
  	if (!numpages)
Reviewed-by on v1 1/2
#4 lore raw

Re: [PATCH 1/2] arm64: mm: make linear mapping permission update more robust for patial range

In reply to Yang Shi
Quoted 28 lines · Yang Shi

The commit fcf8dda8cc48 ("arm64: pageattr: Explicitly bail out when changing permissions for vmalloc_huge mappings") made permission update for partial range more robust. But the linear mapping permission update still assumes update the whole range by iterating from the first page all the way to the last page of the area.

Make it more robust by updating the linear mapping permission from the page mapped by start address, and update the number of numpages.

Fixes fcf8dda8cc48 ("arm64: pageattr: Explicitly bail out when changing permissions for vmalloc_huge mappings")
---
  arch/arm64/mm/pageattr.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/mm/pageattr.c +0 -1
index 5135f2d66958..c21a2c319028 100644
@@ -148,7 +148,6 @@ static int change_memory_common(unsigned long addr, int numpages,
  	unsigned long size = PAGE_SIZE * numpages;
  	unsigned long end = start + size;
  	struct vm_struct *area;
-	int i;
 
  	if (!PAGE_ALIGNED(addr)) {
  		start &= PAGE_MASK;

arch/arm64/mm/pageattr.c static int change_memory_common(unsigned long addr, int numpages, · line 189

Quoted 9 lines
arch/arm64/mm/pageattr.c +3 -2
@@ -184,8 +183,9 @@ static int change_memory_common(unsigned long addr, int numpages,
  	 */
  	if (rodata_full && (pgprot_val(set_mask) == PTE_RDONLY ||
  			    pgprot_val(clear_mask) == PTE_RDONLY)) {
-		for (i = 0; i < area->nr_pages; i++) {
-			__change_memory_common((u64)page_address(area->pages[i]),
+		unsigned long idx = (start - (unsigned long)area->addr) >> PAGE_SHIFT;
+		for (int i = 0; i < numpages; i++) {
+			__change_memory_common((u64)page_address(area->pages[idx++]),
  					       PAGE_SIZE, set_mask, clear_mask);

Why not just use idx as the iterator in the for loop? Using i and then incrementing idx is confusing.

As noted by Ryan, the fixes commit is wrong. The issues persists from commit c55191e.

After fixing these:

Quoted 2 lines
arch/arm64/mm/pageattr.c +0 -0
  		}
  	}
#10 lore raw

Re: [PATCH 2/2] arm64: mm: relax VM_ALLOW_HUGE_VMAP if BBML2_NOABORT is supported

In reply to Yang Shi
Quoted 37 lines · Yang Shi

When changing permissions for vmalloc area, VM_ALLOW_HUGE_VMAP area is exclueded because kernel can't split the va mapping if it is called on partial range.
It is no longer true if the machines support BBML2_NOABORT after commit a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full"). So we can relax this restriction and update the comments accordingly.

Fixes a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full")
---
  arch/arm64/mm/pageattr.c | 13 +++++++------
  1 file changed, 7 insertions(+), 6 deletions(-)
arch/arm64/mm/pageattr.c +5 -5
index c21a2c319028..b4dcae6273a8 100644
@@ -157,13 +157,13 @@ static int change_memory_common(unsigned long addr, int numpages,
 
  	/*
  	 * Kernel VA mappings are always live, and splitting live section
-	 * mappings into page mappings may cause TLB conflicts. This means
-	 * we have to ensure that changing the permission bits of the range
-	 * we are operating on does not result in such splitting.
+	 * mappings into page mappings may cause TLB conflicts on the machines
+	 * which don't support BBML2_NOABORT.
  	 *
  	 * Let's restrict ourselves to mappings created by vmalloc (or vmap).
-	 * Disallow VM_ALLOW_HUGE_VMAP mappings to guarantee that only page
-	 * mappings are updated and splitting is never needed.
+	 * Disallow VM_ALLOW_HUGE_VMAP mappings if the systems don't support
+	 * BBML2_NOABORT to guarantee that only page mappings are updated and
+	 * splitting is never needed on those machines.
  	 *
  	 * So check whether the [addr, addr + size) interval is entirely
  	 * covered by precisely one VM area that has the VM_ALLOC flag set.

arch/arm64/mm/pageattr.c static int change_memory_common(unsigned long addr, int numpages, · line 178

Quoted 9 lines
arch/arm64/mm/pageattr.c +2 -1
@@ -171,7 +171,8 @@ static int change_memory_common(unsigned long addr, int numpages,
  	area = find_vm_area((void *)addr);
  	if (!area ||
  	    end > (unsigned long)kasan_reset_tag(area->addr) + area->size ||
-	    ((area->flags & (VM_ALLOC | VM_ALLOW_HUGE_VMAP)) != VM_ALLOC))
+	    !(area->flags & VM_ALLOC) || ((area->flags & VM_ALLOW_HUGE_VMAP) &&
+	    !system_supports_bbml2_noabort()))
  		return -EINVAL;
 
  	if (!numpages)

This will conflict with my upcoming vmalloc-huge series, so best to leave it to me, I already have this included :)

author
#5 lore raw

Re: [PATCH 1/2] arm64: mm: make linear mapping permission update more robust for patial range

In reply to Dev Jain
Quoted 36 lines · Dev Jain
Quoted 34 lines · Yang Shi

The commit fcf8dda8cc48 ("arm64: pageattr: Explicitly bail out when changing permissions for vmalloc_huge mappings") made permission update for partial range more robust. But the linear mapping permission update still assumes update the whole range by iterating from the first page all the way to the last page of the area.

Make it more robust by updating the linear mapping permission from the page mapped by start address, and update the number of numpages.

Fixes fcf8dda8cc48 ("arm64: pageattr: Explicitly bail out when changing permissions for vmalloc_huge mappings")

---
  arch/arm64/mm/pageattr.c | 6 +++---

  1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/mm/pageattr.c +0 -1
index 5135f2d66958..c21a2c319028 100644
@@ -148,7 +148,6 @@ static int change_memory_common(unsigned long 
 addr, int numpages,
       unsigned long size = PAGE_SIZE * numpages;
       unsigned long end = start + size;
       struct vm_struct *area;
-    int i;
         if (!PAGE_ALIGNED(addr)) {
           start &= PAGE_MASK;
@@ -184,8 +183,9 @@ static int change_memory_common(unsigned long 
 addr, int numpages,
        */

      if (rodata_full && (pgprot_val(set_mask) == PTE_RDONLY || pgprot_val(clear_mask) == PTE_RDONLY)) { -        for (i = 0; i < area->nr_pages; i++) {
- __change_memory_common((u64)page_address(area->pages[i]),

Quoted 8 lines
Quoted 5 lines

+        unsigned long idx = (start - (unsigned long)area->addr) >> PAGE_SHIFT;
+        for (int i = 0; i < numpages; i++) {
+ __change_memory_common((u64)page_address(area->pages[idx++]), PAGE_SIZE, set_mask, clear_mask);

Why not just use idx as the iterator in the for loop? Using i and then incrementing idx is confusing.

You meant something like:

while (idx < idx + numpages)

It is fine to me.

Quoted 6 lines

As noted by Ryan, the fixes commit is wrong. The issues persists from commit c55191e.

After fixing these:

Thank you.

Yang

Quoted 3 lines
Quoted 3 lines

          }
      }

#6 lore raw

Re: [PATCH 1/2] arm64: mm: make linear mapping permission update more robust for patial range

Quoted 48 lines · Yang Shi
Quoted 36 lines · Dev Jain
Quoted 34 lines · Yang Shi

The commit fcf8dda8cc48 ("arm64: pageattr: Explicitly bail out when changing permissions for vmalloc_huge mappings") made permission update for partial range more robust. But the linear mapping permission update still assumes update the whole range by iterating from the first page all the way to the last page of the area.

Make it more robust by updating the linear mapping permission from the page mapped by start address, and update the number of numpages.

Fixes fcf8dda8cc48 ("arm64: pageattr: Explicitly bail out when changing permissions for vmalloc_huge mappings")

---
  arch/arm64/mm/pageattr.c | 6 +++---

  1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/mm/pageattr.c +0 -1
index 5135f2d66958..c21a2c319028 100644
@@ -148,7 +148,6 @@ static int change_memory_common(unsigned long 
 addr, int numpages,
       unsigned long size = PAGE_SIZE * numpages;
       unsigned long end = start + size;
       struct vm_struct *area;
-    int i;
         if (!PAGE_ALIGNED(addr)) {
           start &= PAGE_MASK;
@@ -184,8 +183,9 @@ static int change_memory_common(unsigned long 
 addr, int numpages,
        */

      if (rodata_full && (pgprot_val(set_mask) == PTE_RDONLY || pgprot_val(clear_mask) == PTE_RDONLY)) { -        for (i = 0; i < area->nr_pages; i++) {
- __change_memory_common((u64)page_address(area->pages[i]),

Quoted 8 lines
Quoted 5 lines

+        unsigned long idx = (start - (unsigned long)area->addr) >> PAGE_SHIFT;
+        for (int i = 0; i < numpages; i++) {
+ __change_memory_common((u64)page_address(area->pages[idx++]), PAGE_SIZE, set_mask, clear_mask);

Why not just use idx as the iterator in the for loop? Using i and then incrementing idx is confusing.

Quoted 5 lines

You meant something like:

while (idx < idx + numpages)

It is fine to me.

for loop is simpler :)

Quoted 16 lines
Quoted 7 lines

As noted by Ryan, the fixes commit is wrong. The issues persists from commit c55191e.

After fixing these:

Thank you.

Yang

Quoted 3 lines
Quoted 3 lines

          }
      }

author
#11 lore raw

Re: [PATCH 2/2] arm64: mm: relax VM_ALLOW_HUGE_VMAP if BBML2_NOABORT is supported

In reply to Dev Jain
Quoted 47 lines · Dev Jain
Quoted 45 lines · Yang Shi

When changing permissions for vmalloc area, VM_ALLOW_HUGE_VMAP area is exclueded because kernel can't split the va mapping if it is called on partial range.
It is no longer true if the machines support BBML2_NOABORT after commit a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full"). So we can relax this restriction and update the comments accordingly.

Fixes a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full")

---
  arch/arm64/mm/pageattr.c | 13 +++++++------

  1 file changed, 7 insertions(+), 6 deletions(-)
arch/arm64/mm/pageattr.c +1 -3
index c21a2c319028..b4dcae6273a8 100644
@@ -157,13 +157,13 @@ static int change_memory_common(unsigned long 
 addr, int numpages,
         /*
        * Kernel VA mappings are always live, and splitting live section
-     * mappings into page mappings may cause TLB conflicts. This means
-     * we have to ensure that changing the permission bits of the range
-     * we are operating on does not result in such splitting.
+     * mappings into page mappings may cause TLB conflicts on the 

machines
+     * which don't support BBML2_NOABORT.
       *
       * Let's restrict ourselves to mappings created by vmalloc (or vmap). -     * Disallow VM_ALLOW_HUGE_VMAP mappings to guarantee that only page -     * mappings are updated and splitting is never needed.
+     * Disallow VM_ALLOW_HUGE_VMAP mappings if the systems don't support
+     * BBML2_NOABORT to guarantee that only page mappings are updated and
+     * splitting is never needed on those machines.
       *
       * So check whether the [addr, addr + size) interval is entirely
       * covered by precisely one VM area that has the VM_ALLOC flag set.

arch/arm64/mm/pageattr.c +0 -0
@@ -171,7 +171,8 @@ static int change_memory_common(unsigned long 
 addr, int numpages,
       area = find_vm_area((void *)addr);

      if (!area ||
          end > (unsigned long)kasan_reset_tag(area->addr) + area->size || -        ((area->flags & (VM_ALLOC | VM_ALLOW_HUGE_VMAP)) != VM_ALLOC))

Quoted 8 lines
Quoted 5 lines

+        !(area->flags & VM_ALLOC) || ((area->flags & VM_ALLOW_HUGE_VMAP) &&
+        !system_supports_bbml2_noabort())) return -EINVAL;
        if (!numpages)

This will conflict with my upcoming vmalloc-huge series, so best to leave it to me, I already have this included :)

My point is that I hope this can be merged as a hotfix for 6.18. I have no strong opinion on either the maintainers take this one or from your series. But if this will go into 6.18 as a hotfix, it should be also a prerequisite patch (standalone)  in your series, and the rest of your series should be based on top of it. Of course this argument will not stand if we don't care to have it fixed for 6.18.

Thanks,
Yang

#12 lore raw

Re: [PATCH 2/2] arm64: mm: relax VM_ALLOW_HUGE_VMAP if BBML2_NOABORT is supported

Quoted 61 lines · Yang Shi
Quoted 49 lines · Dev Jain
Quoted 47 lines · Yang Shi

When changing permissions for vmalloc area, VM_ALLOW_HUGE_VMAP area is exclueded because kernel can't split the va mapping if it is called on partial range.
It is no longer true if the machines support BBML2_NOABORT after commit a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full"). So we can relax this restriction and update the comments accordingly.

Fixes a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full")

---
  arch/arm64/mm/pageattr.c | 13 +++++++------

  1 file changed, 7 insertions(+), 6 deletions(-)
arch/arm64/mm/pageattr.c +0 -2
index c21a2c319028..b4dcae6273a8 100644
@@ -157,13 +157,13 @@ static int change_memory_common(unsigned long 
 addr, int numpages,
         /*
        * Kernel VA mappings are always live, and splitting live section
-     * mappings into page mappings may cause TLB conflicts. This means
-     * we have to ensure that changing the permission bits of the 

range
-     * we are operating on does not result in such splitting. +     * mappings into page mappings may cause TLB conflicts on the machines
+     * which don't support BBML2_NOABORT.
       *
       * Let's restrict ourselves to mappings created by vmalloc (or vmap). -     * Disallow VM_ALLOW_HUGE_VMAP mappings to guarantee that only page
-     * mappings are updated and splitting is never needed.
+     * Disallow VM_ALLOW_HUGE_VMAP mappings if the systems don't support
+     * BBML2_NOABORT to guarantee that only page mappings are updated and
+     * splitting is never needed on those machines.
       *
       * So check whether the [addr, addr + size) interval is entirely
       * covered by precisely one VM area that has the VM_ALLOC flag set.

arch/arm64/mm/pageattr.c +0 -0
@@ -171,7 +171,8 @@ static int change_memory_common(unsigned long 
 addr, int numpages,
       area = find_vm_area((void *)addr);

      if (!area ||
          end > (unsigned long)kasan_reset_tag(area->addr) + area->size || -        ((area->flags & (VM_ALLOC | VM_ALLOW_HUGE_VMAP)) != VM_ALLOC))

Quoted 8 lines
Quoted 5 lines

+        !(area->flags & VM_ALLOC) || ((area->flags & VM_ALLOW_HUGE_VMAP) &&
+        !system_supports_bbml2_noabort())) return -EINVAL;
        if (!numpages)

This will conflict with my upcoming vmalloc-huge series, so best to leave it to me, I already have this included :)

Quoted 1 line

My point is that I hope this can be merged as a hotfix for 6.18. I have no strong opinion on either the maintainers take this one or from your series. But if this will go into 6.18 as a hotfix, it should be also a prerequisite patch (standalone)  in your series, and the rest of your series should be based on top of it. Of course this argument will not stand if we don't care to have it fixed for 6.18.

I see what you mean, but I don't think this patch should be treated as a hotfix. We forgot to relax a

restriction - that's fine. That is not an incorrectness in the linear map series. A fix usually

fixes an incorrectness.

Quoted 5 lines

Thanks,
Yang

maintainer
#13 lore raw

Re: [PATCH 2/2] arm64: mm: relax VM_ALLOW_HUGE_VMAP if BBML2_NOABORT is supported

Quoted 72 lines · Dev Jain
Quoted 64 lines · Yang Shi
Quoted 54 lines · Dev Jain
Quoted 53 lines · Yang Shi

When changing permissions for vmalloc area, VM_ALLOW_HUGE_VMAP area is exclueded because kernel can't split the va mapping if it is called on partial range.
It is no longer true if the machines support BBML2_NOABORT after commit a166563e7ec3 ("arm64: mm: support large block mapping when rodata=full").
So we can relax this restriction and update the comments accordingly.

Fixes a166563e7ec3 ("arm64: mm: support large block mapping

when rodata=full")

---
  arch/arm64/mm/pageattr.c | 13 +++++++------

  1 file changed, 7 insertions(+), 6 deletions(-)
arch/arm64/mm/pageattr.c +0 -2
index c21a2c319028..b4dcae6273a8 100644
@@ -157,13 +157,13 @@ static int change_memory_common(unsigned
 long addr, int numpages,
         /*
        * Kernel VA mappings are always live, and splitting live section
-     * mappings into page mappings may cause TLB conflicts. This means
-     * we have to ensure that changing the permission bits of

the range
-     * we are operating on does not result in such splitting. +     * mappings into page mappings may cause TLB conflicts on the machines
+     * which don't support BBML2_NOABORT.
       *
       * Let's restrict ourselves to mappings created by vmalloc (or vmap).
-     * Disallow VM_ALLOW_HUGE_VMAP mappings to guarantee that only page
-     * mappings are updated and splitting is never needed. +     * Disallow VM_ALLOW_HUGE_VMAP mappings if the systems don't support
+     * BBML2_NOABORT to guarantee that only page mappings are updated and
+     * splitting is never needed on those machines.
       *
       * So check whether the [addr, addr + size) interval is entirely
       * covered by precisely one VM area that has the VM_ALLOC flag set.

arch/arm64/mm/pageattr.c +0 -0
@@ -171,7 +171,8 @@ static int change_memory_common(unsigned
 long addr, int numpages,
       area = find_vm_area((void *)addr);

      if (!area ||
          end > (unsigned long)kasan_reset_tag(area->addr) + area->size ||
-        ((area->flags & (VM_ALLOC | VM_ALLOW_HUGE_VMAP)) != VM_ALLOC)) +        !(area->flags & VM_ALLOC) || ((area->flags &

Quoted 8 lines
Quoted 4 lines

VM_ALLOW_HUGE_VMAP) &&
+        !system_supports_bbml2_noabort()))
          return -EINVAL;
        if (!numpages)

This will conflict with my upcoming vmalloc-huge series, so best to leave it to me,
I already have this included :)

Quoted 6 lines

My point is that I hope this can be merged as a hotfix for 6.18. I have no strong opinion on either the maintainers take this one or from your series. But if this will go into 6.18 as a hotfix, it should be also a prerequisite patch (standalone)  in your series, and the rest of your series should be based on top of it. Of course this argument will not stand if we don't care to have it fixed for 6.18.

Quoted 7 lines

I see what you mean, but I don't think this patch should be treated as a hotfix. We forgot to relax a

restriction - that's fine. That is not an incorrectness in the linear map series. A fix usually

fixes an incorrectness.

Right, unless there's a real functional issue that is affecting people then I don't see the need to take any of this for 6.18.

Will