Skip to contentSkip to conversation

riscv: mm: Fix prototype to avoid discarding const

PATCH Applied Samuel Holland 4 participants 4 messages Mar 1, 2024 – Mar 26, 2024 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: mm: Fix prototype to avoid discarding const

__flush_tlb_range() does not modify the provided cpumask, so its cmask parameter can be pointer-to-const. This avoids the unsafe cast of cpu_online_mask.

Fixes 54d7431af73e ("riscv: Add support for BATCHED_UNMAP_TLB_FLUSH")

---

 arch/riscv/mm/tlbflush.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/mm/tlbflush.c +2 -2
index 893566e004b7..07d743f87b3f 100644
@@ -99,7 +99,7 @@ static void __ipi_flush_tlb_range_asid(void *info)
 	local_flush_tlb_range_asid(d->start, d->size, d->stride, d->asid);
 }
 
-static void __flush_tlb_range(struct cpumask *cmask, unsigned long asid,
+static void __flush_tlb_range(const struct cpumask *cmask, unsigned long asid,
 			      unsigned long start, unsigned long size,
 			      unsigned long stride)
 {
@@ -200,7 +200,7 @@ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
 
 void flush_tlb_kernel_range(unsigned long start, unsigned long end)
 {
-	__flush_tlb_range((struct cpumask *)cpu_online_mask, FLUSH_TLB_NO_ASID,
+	__flush_tlb_range(cpu_online_mask, FLUSH_TLB_NO_ASID,
 			  start, end - start, PAGE_SIZE);
 }
 
Signature · 1 line
2.43.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 36 lines · Samuel Holland

__flush_tlb_range() does not modify the provided cpumask, so its cmask parameter can be pointer-to-const. This avoids the unsafe cast of cpu_online_mask.

Fixes 54d7431af73e ("riscv: Add support for BATCHED_UNMAP_TLB_FLUSH")

---

 arch/riscv/mm/tlbflush.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/mm/tlbflush.c +2 -2
index 893566e004b7..07d743f87b3f 100644
@@ -99,7 +99,7 @@ static void __ipi_flush_tlb_range_asid(void *info)
 	local_flush_tlb_range_asid(d->start, d->size, d->stride, d->asid);
 }
 
-static void __flush_tlb_range(struct cpumask *cmask, unsigned long asid,
+static void __flush_tlb_range(const struct cpumask *cmask, unsigned long asid,
 			      unsigned long start, unsigned long size,
 			      unsigned long stride)
 {
@@ -200,7 +200,7 @@ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
 
 void flush_tlb_kernel_range(unsigned long start, unsigned long end)
 {
-	__flush_tlb_range((struct cpumask *)cpu_online_mask, FLUSH_TLB_NO_ASID,
+	__flush_tlb_range(cpu_online_mask, FLUSH_TLB_NO_ASID,
 			  start, end - start, PAGE_SIZE);
 }
 
Signature · 1 line
2.43.1
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Samuel Holland

Hi Samuel,

Quoted 25 lines · Samuel Holland

__flush_tlb_range() does not modify the provided cpumask, so its cmask parameter can be pointer-to-const. This avoids the unsafe cast of cpu_online_mask.

Fixes 54d7431af73e ("riscv: Add support for BATCHED_UNMAP_TLB_FLUSH")

---

  arch/riscv/mm/tlbflush.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/mm/tlbflush.c +1 -1
index 893566e004b7..07d743f87b3f 100644
@@ -99,7 +99,7 @@ static void __ipi_flush_tlb_range_asid(void *info)
  	local_flush_tlb_range_asid(d->start, d->size, d->stride, d->asid);
  }
 
-static void __flush_tlb_range(struct cpumask *cmask, unsigned long asid,
+static void __flush_tlb_range(const struct cpumask *cmask, unsigned long asid,
  			      unsigned long start, unsigned long size,
  			      unsigned long stride)
  {

arch/riscv/mm/tlbflush.c void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, · line 206

Quoted 8 lines
arch/riscv/mm/tlbflush.c +1 -1
@@ -200,7 +200,7 @@ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
 
  void flush_tlb_kernel_range(unsigned long start, unsigned long end)
  {
-	__flush_tlb_range((struct cpumask *)cpu_online_mask, FLUSH_TLB_NO_ASID,
+	__flush_tlb_range(cpu_online_mask, FLUSH_TLB_NO_ASID,
  			  start, end - start, PAGE_SIZE);
  }
 

Thanks,

Alex

#3 lore raw
In reply to Samuel Holland
This patch was applied to riscv/linux.git (fixes) by Palmer Dabbelt <[email protected]>:

Hello:

This patch was applied to riscv/linux.git (fixes)
by Palmer Dabbelt <[email protected]>:

Quoted 8 lines · On Fri, 1 Mar 2024 12:18:32 -0800 you wrote:

__flush_tlb_range() does not modify the provided cpumask, so its cmask parameter can be pointer-to-const. This avoids the unsafe cast of cpu_online_mask.

Fixes 54d7431af73e ("riscv: Add support for BATCHED_UNMAP_TLB_FLUSH")

[...]

Here is the summary with links:
- riscv: mm: Fix prototype to avoid discarding const

    https://git.kernel.org/riscv/c/674bc0168e6b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html