Module Name: src
Committed By: skrll
Date: Mon Jan 1 17:18:02 UTC 2024
Modified Files:
src/sys/arch/riscv/include: pmap.h
src/sys/arch/riscv/riscv: pmap_machdep.c
Log Message:
risc-v: probe the number of supported ASIDs
Flush the entire TLB if no ASIDs are supported on pmap_activate.
To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/riscv/include/pmap.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/riscv/riscv/pmap_machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/riscv/include/pmap.h
diff -u src/sys/arch/riscv/include/pmap.h:1.22 src/sys/arch/riscv/include/pmap.h:1.23
--- src/sys/arch/riscv/include/pmap.h:1.22 Fri Oct 6 08:48:49 2023
+++ src/sys/arch/riscv/include/pmap.h Mon Jan 1 17:18:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.22 2023/10/06 08:48:49 skrll Exp $ */
+/* $NetBSD: pmap.h,v 1.23 2024/01/01 17:18:02 skrll Exp $ */
/*
* Copyright (c) 2014, 2019, 2021 The NetBSD Foundation, Inc.
@@ -217,7 +217,16 @@ pmap_md_vca_clean(struct vm_page_md *mdp
static inline size_t
pmap_md_tlb_asid_max(void)
{
- return PMAP_TLB_NUM_PIDS - 1;
+ const register_t satp = csr_satp_read();
+ const register_t test = satp | SATP_ASID;
+
+ csr_satp_write(test);
+
+ const register_t ret = __SHIFTOUT(csr_satp_read(), SATP_ASID);
+ csr_satp_write(satp);
+
+ KASSERT(ret < PMAP_TLB_NUM_PIDS);
+ return ret;
}
static inline pt_entry_t *
Index: src/sys/arch/riscv/riscv/pmap_machdep.c
diff -u src/sys/arch/riscv/riscv/pmap_machdep.c:1.19 src/sys/arch/riscv/riscv/pmap_machdep.c:1.20
--- src/sys/arch/riscv/riscv/pmap_machdep.c:1.19 Sun Sep 3 08:48:20 2023
+++ src/sys/arch/riscv/riscv/pmap_machdep.c Mon Jan 1 17:18:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap_machdep.c,v 1.19 2023/09/03 08:48:20 skrll Exp $ */
+/* $NetBSD: pmap_machdep.c,v 1.20 2024/01/01 17:18:02 skrll Exp $ */
/*
* Copyright (c) 2014, 2019, 2021 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
#define __PMAP_PRIVATE
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pmap_machdep.c,v 1.19 2023/09/03 08:48:20 skrll Exp $");
+__RCSID("$NetBSD: pmap_machdep.c,v 1.20 2024/01/01 17:18:02 skrll Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -177,7 +177,8 @@ pmap_md_xtab_activate(struct pmap *pmap,
// UVMHIST_FUNC(__func__); UVMHIST_CALLED(maphist);
// struct cpu_info * const ci = curcpu();
- struct pmap_asid_info * const pai = PMAP_PAI(pmap, cpu_tlb_info(ci));
+ struct pmap_tlb_info * const ti = cpu_tlb_info(ci);
+ struct pmap_asid_info * const pai = PMAP_PAI(pmap, ti);
uint64_t satp =
#ifdef _LP64
@@ -189,6 +190,10 @@ pmap_md_xtab_activate(struct pmap *pmap,
__SHIFTIN(pmap->pm_md.md_ppn, SATP_PPN);
csr_satp_write(satp);
+
+ if (l && !tlbinfo_asids_p(ti)) {
+ tlb_invalidate_all();
+ }
}
void
@@ -329,6 +334,8 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
// XXXNH per cpu?
pmap_tlb_info_init(&pmap_tlb0_info);
+ VPRINTF("ASID max %x ", pmap_tlb0_info.ti_asid_max);
+
#ifdef MULTIPROCESSOR
VPRINTF("kcpusets ");