sparc: make all kernels load at 0xe800.4000. there's not enough KVA for modern netbsd with only not quite 256 MB of total KVA space allocated. i've observed soft angs due to this, that can clear up if apps or kernel consumers free KVA consumption (eg, each lwp is more KVA used.) remove the now obsolete PROM_AT_F0 option, and all the times TEXTADDR=E8004000 is listed in configs since that is now the default. attempt to make the Krups/Mr.Coffee address options probed at boot time, making it slightly closer to sharing these kernels. make mmu_reservemon4m() static (again). Index: sys/arch/sparc/conf/KRUPS =================================================================== RCS file: /cvsroot/src/sys/arch/sparc/conf/KRUPS,v retrieving revision 1.81 diff -p -u -r1.81 KRUPS --- sys/arch/sparc/conf/KRUPS 26 Apr 2019 22:46:04 -0000 1.81 +++ sys/arch/sparc/conf/KRUPS 6 Oct 2023 01:22:41 -0000 @@ -24,10 +24,6 @@ options SUN4M # sun4m - SS10, SS20, Cl # with this option turned on will refuse to work on normal 4m. options MSIIEP # microSPARC-IIep -# XXX: uwe: PROM location conflicts with kernel VA space !!! -options PROM_AT_F0 -makeoptions TEXTADDR=E8004000 - ## System options specific to the sparc machine type Index: sys/arch/sparc/conf/Makefile.sparc =================================================================== RCS file: /cvsroot/src/sys/arch/sparc/conf/Makefile.sparc,v retrieving revision 1.96 diff -p -u -r1.96 Makefile.sparc --- sys/arch/sparc/conf/Makefile.sparc 22 Sep 2018 12:24:03 -0000 1.96 +++ sys/arch/sparc/conf/Makefile.sparc 6 Oct 2023 01:22:41 -0000 @@ -61,7 +61,7 @@ amd7930intr.o bsd_fdintr.o lock_stubs.o: ## ## (5) link settings ## -TEXTADDR?= F0004000 +TEXTADDR?= E8004000 EXTRA_LINKFLAGS= -X KERNLDSCRIPT?= ${SPARC}/conf/kern.ldscript LINKFORMAT= -n Index: sys/arch/sparc/include/bsd_openprom.h =================================================================== RCS file: /cvsroot/src/sys/arch/sparc/include/bsd_openprom.h,v retrieving revision 1.25 diff -p -u -r1.25 bsd_openprom.h --- sys/arch/sparc/include/bsd_openprom.h 24 Dec 2007 15:46:45 -0000 1.25 +++ sys/arch/sparc/include/bsd_openprom.h 6 Oct 2023 01:22:41 -0000 @@ -56,6 +56,9 @@ */ #define OPENPROM_STARTVADDR 0xffd00000 #define OPENPROM_ENDVADDR 0xfff00000 +#define OPENPROM_STARTVADDR_JS 0xf0000000 +#define OPENPROM_ENDVADDR_JS 0xf0080000 +#define OPENPROM_ENDVADDR_KRUPS 0xf0800000 #define OPENPROM_MAGIC 0x10010407 Index: sys/arch/sparc/include/param.h =================================================================== RCS file: /cvsroot/src/sys/arch/sparc/include/param.h,v retrieving revision 1.75 diff -p -u -r1.75 param.h --- sys/arch/sparc/include/param.h 2 Jun 2023 08:51:46 -0000 1.75 +++ sys/arch/sparc/include/param.h 6 Oct 2023 01:22:41 -0000 @@ -70,16 +70,17 @@ extern int nbpg, pgofset, pgshift; #endif -#if !(defined(PROM_AT_F0) || defined(MSIIEP)) -#define KERNBASE 0xf0000000 /* start of kernel virtual space */ -#else /* - * JS1/OF has prom sitting in f000.0000..f007.ffff, modify kernel VA - * layout to work around that. XXX - kernel should live beyond prom on - * those machines. + * SPARC KVA is from KERNBASE until 0xfe00.0000 where the PROM normally + * lives. NetBSD originally used KERNBASE of 0xf000.0000 (except for + * systems like Krups, that put the PROM here), but was switched to + * 0xe800.000 for NetBSD 10.0 as it's quite easy to use more than 224MB + * of KVA on a 512MB system (max for sun4m.) + * + * JS1/OF has prom sitting in f000.0000..f007.ffff, Krups has it from to + * f070.ffff. */ -#define KERNBASE 0xe8000000 -#endif +#define KERNBASE 0xe8000000 /* start of kernel virtual space */ #define KERNEND 0xfe000000 /* end of kernel virtual space */ #define PROM_LOADADDR 0x00004000 /* where the prom loads us */ #define KERNTEXTOFF (KERNBASE+PROM_LOADADDR)/* start of kernel text */ @@ -108,7 +109,7 @@ extern int nbpg, pgofset, pgshift; * logical pages. */ #define NKMEMPAGES_MIN_DEFAULT ((16 * 1024 * 1024) >> PAGE_SHIFT) -#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_DEFAULT ((240 * 1024 * 1024) >> PAGE_SHIFT) #if defined(_KERNEL) || defined(_STANDALONE) #ifndef _LOCORE Index: sys/arch/sparc/sparc/pmap.c =================================================================== RCS file: /cvsroot/src/sys/arch/sparc/sparc/pmap.c,v retrieving revision 1.377 diff -p -u -r1.377 pmap.c --- sys/arch/sparc/sparc/pmap.c 9 Apr 2022 23:38:32 -0000 1.377 +++ sys/arch/sparc/sparc/pmap.c 6 Oct 2023 01:22:41 -0000 @@ -565,8 +565,7 @@ int updatepte4m(vaddr_t, int *, int, in #if defined(SUN4M) || defined(SUN4D) static void mmu_setup4m_L1(int, struct pmap *); static void mmu_setup4m_L2(int, struct regmap *); -static void mmu_setup4m_L3(int, struct segmap *); -/*static*/ void mmu_reservemon4m(struct pmap *); +static void mmu_setup4m_L3(int, struct segmap *); /*static*/ void pmap_changeprot4m(pmap_t, vaddr_t, vm_prot_t, int); /*static*/ void pmap_rmk4m(struct pmap *, vaddr_t, vaddr_t, int, int); @@ -1382,24 +1381,12 @@ srmmu_bypass_read(u_long paddr) * Also installs ROM mappings into the kernel pmap. * NOTE: This also revokes all user-mode access to the mapped regions. */ -void +static void mmu_reservemon4m(struct pmap *kpmap) { unsigned int rom_ctxtbl; int te; -#if !(defined(PROM_AT_F0) || defined(MSIIEP)) - prom_vstart = OPENPROM_STARTVADDR; - prom_vend = OPENPROM_ENDVADDR; -#else /* OBP3/OFW in JavaStations */ - prom_vstart = 0xf0000000; -#if defined(MSIIEP) - prom_vend = 0xf0800000; -#else - prom_vend = 0xf0080000; -#endif -#endif - /* * XXX: although the sun4m can handle 36 bits of physical * address space, we assume that all these page tables, etc @@ -3530,6 +3517,7 @@ pmap_bootstrap4m(void *top) vaddr_t pagetables_start, pagetables_end; paddr_t pagetables_start_pa; vaddr_t va; + bool mr_coffee, krups; #if defined(MULTIPROCESSOR) vsize_t off; size_t cpuinfo_len = sizeof(struct cpu_info); @@ -3766,6 +3754,21 @@ pmap_bootstrap4m(void *top) } } + mr_coffee = strcmp(machine_model, "SUNW,JavaStation-1") == 0; + krups = strcmp(machine_model, "SUNW,JSIIep") == 0; + + if (!mr_coffee && !krups) { + prom_vstart = OPENPROM_STARTVADDR; + prom_vend = OPENPROM_ENDVADDR; + } else { + /* OBP3/OFW in JavaStations */ + prom_vstart = OPENPROM_STARTVADDR_JS; + if (krups) + prom_vend = OPENPROM_ENDVADDR_KRUPS; + else + prom_vend = OPENPROM_ENDVADDR_JS; + } + /* * Preserve the monitor ROM's reserved VM region, so that * we can use L1-A or the monitor's debugger. @@ -3792,13 +3795,12 @@ pmap_bootstrap4m(void *top) &sp->sg_pte[VA_SUN4M_VPG(cpuinfo.vpage[i])]; } -#if !(defined(PROM_AT_F0) || defined(MSIIEP)) - virtual_avail = p; -#elif defined(MSIIEP) - virtual_avail = (vaddr_t)0xf0800000; /* Krups */ -#else - virtual_avail = (vaddr_t)0xf0080000; /* Mr.Coffee/OFW */ -#endif + if (!mr_coffee && !krups) + virtual_avail = p; + else if (krups) + virtual_avail = (vaddr_t)OPENPROM_ENDVADDR_KRUPS; + else + virtual_avail = (vaddr_t)OPENPROM_ENDVADDR_JS; virtual_end = VM_MAX_KERNEL_ADDRESS; p = q; /* retract to first free phys */