risc-v: probe the number of supported ASIDs

Flush the entire TLB if no ASIDs are supported on pmap_activate.
This commit is contained in:
skrll 2024-01-01 17:18:02 +00:00
parent fbbd98ed5c
commit 686b1ff1b4
2 changed files with 21 additions and 5 deletions

View File

@ -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 *mdpg, vaddr_t va, int op)
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 *

View File

@ -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, struct lwp *l)
// 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, struct lwp *l)
__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 vend)
// XXXNH per cpu?
pmap_tlb_info_init(&pmap_tlb0_info);
VPRINTF("ASID max %x ", pmap_tlb0_info.ti_asid_max);
#ifdef MULTIPROCESSOR
VPRINTF("kcpusets ");