Skip to content

Commit 9a801af

Browse files
Dylan-Jhongpalmer-dabbelt
authored andcommitted
riscv: mm: Fix incorrect ASID argument when flushing TLB
Currently, we pass the CONTEXTID instead of the ASID to the TLB flush function. We should only take the ASID field to prevent from touching the reserved bit field. Fixes: 3f1e782 ("riscv: add ASID-based tlbflushing methods") Signed-off-by: Dylan Jhong <[email protected]> Reviewed-by: Sergey Matyukevich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 47dd902 commit 9a801af

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

arch/riscv/include/asm/tlbflush.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <asm/errata_list.h>
1313

1414
#ifdef CONFIG_MMU
15+
extern unsigned long asid_mask;
16+
1517
static inline void local_flush_tlb_all(void)
1618
{
1719
__asm__ __volatile__ ("sfence.vma" : : : "memory");

arch/riscv/mm/context.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ DEFINE_STATIC_KEY_FALSE(use_asid_allocator);
2222

2323
static unsigned long asid_bits;
2424
static unsigned long num_asids;
25-
static unsigned long asid_mask;
25+
unsigned long asid_mask;
2626

2727
static atomic_long_t current_version;
2828

arch/riscv/mm/tlbflush.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void __sbi_tlb_flush_range(struct mm_struct *mm, unsigned long start,
4242
/* check if the tlbflush needs to be sent to other CPUs */
4343
broadcast = cpumask_any_but(cmask, cpuid) < nr_cpu_ids;
4444
if (static_branch_unlikely(&use_asid_allocator)) {
45-
unsigned long asid = atomic_long_read(&mm->context.id);
45+
unsigned long asid = atomic_long_read(&mm->context.id) & asid_mask;
4646

4747
if (broadcast) {
4848
sbi_remote_sfence_vma_asid(cmask, start, size, asid);

0 commit comments

Comments
 (0)