Module Name: src Committed By: skrll Date: Sat May 29 06:54:20 UTC 2021
Modified Files: src/sys/arch/aarch64/aarch64: pmap.c src/sys/arch/aarch64/include: cpu.h Log Message: Deal with the pmap limitation of maxproc in a more complete way and recognise CPUs with only 8bit ASIDs. To generate a diff of this commit: cvs rdiff -u -r1.107 -r1.108 src/sys/arch/aarch64/aarch64/pmap.c cvs rdiff -u -r1.35 -r1.36 src/sys/arch/aarch64/include/cpu.h 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/aarch64/aarch64/pmap.c diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.107 src/sys/arch/aarch64/aarch64/pmap.c:1.108 --- src/sys/arch/aarch64/aarch64/pmap.c:1.107 Fri Apr 30 20:07:22 2021 +++ src/sys/arch/aarch64/aarch64/pmap.c Sat May 29 06:54:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.107 2021/04/30 20:07:22 skrll Exp $ */ +/* $NetBSD: pmap.c,v 1.108 2021/05/29 06:54:20 skrll Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu <r...@nerv.org> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.107 2021/04/30 20:07:22 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.108 2021/05/29 06:54:20 skrll Exp $"); #include "opt_arm_debug.h" #include "opt_ddb.h" @@ -554,6 +554,10 @@ pmap_init(void) pool_cache_bootstrap(&_pmap_pv_pool, sizeof(struct pv_entry), 32, 0, PR_LARGECACHE, "pvpl", NULL, IPL_NONE, _pmap_pv_ctor, NULL, NULL); + + int nmaxproc = cpu_maxproc(); + if (maxproc > nmaxproc) + maxproc = nmaxproc; } void @@ -1420,12 +1424,6 @@ pmap_protect(struct pmap *pm, vaddr_t sv pm_unlock(pm); } -/* XXX: due to the current implementation of pmap depends on 16bit ASID */ -int -cpu_maxproc(void) -{ - return 65535; -} void pmap_activate(struct lwp *l) Index: src/sys/arch/aarch64/include/cpu.h diff -u src/sys/arch/aarch64/include/cpu.h:1.35 src/sys/arch/aarch64/include/cpu.h:1.36 --- src/sys/arch/aarch64/include/cpu.h:1.35 Sat May 29 06:37:21 2021 +++ src/sys/arch/aarch64/include/cpu.h Sat May 29 06:54:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.35 2021/05/29 06:37:21 skrll Exp $ */ +/* $NetBSD: cpu.h,v 1.36 2021/05/29 06:54:20 skrll Exp $ */ /*- * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc. @@ -149,7 +149,22 @@ static __inline struct cpu_info *lwp_get #undef curlwp #define curlwp (aarch64_curlwp()) -int cpu_maxproc(void); +static inline int +cpu_maxproc(void) +{ + /* + * the pmap uses PID for ASID. + */ + switch (__SHIFTOUT(reg_id_aa64mmfr0_el1_read(), ID_AA64MMFR0_EL1_ASIDBITS)) { + case ID_AA64MMFR0_EL1_ASIDBITS_8BIT: + return (1U << 8) - 1; + case ID_AA64MMFR0_EL1_ASIDBITS_16BIT: + return (1U << 16) - 1; + default: + return 0; + } +} + void cpu_signotify(struct lwp *l); void cpu_need_proftick(struct lwp *l);