From c74dddb3ef03fa6edf841461d36c09391c733271 Mon Sep 17 00:00:00 2001 From: Rin Okuyama Date: Thu, 5 Nov 2026 18:47:21 +0900 Subject: [PATCH 1/5] sparc: Let KERNBASE tunable by kernel config files --- sys/arch/sparc/include/param.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/arch/sparc/include/param.h b/sys/arch/sparc/include/param.h index 60917753577..55dc5c40711 100644 --- a/sys/arch/sparc/include/param.h +++ b/sys/arch/sparc/include/param.h @@ -75,15 +75,15 @@ extern int nbpg, pgofset, pgshift; #if defined(_MODULE) extern const vaddr_t kernbase; #define KERNBASE kernbase /* start of kernel virtual space */ -#elif !(defined(PROM_AT_F0) || defined(MSIIEP)) -#define KERNBASE 0xf0000000 -#else +#elif defined(PROM_AT_F0) || defined(MSIIEP) /* * 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. */ #define KERNBASE 0xe8000000 +#elif !defined(KERNBASE) +#define KERNBASE 0xf0000000 #endif #define KERNEND 0xfe000000 /* end of kernel virtual space */ #define PROM_LOADADDR 0x00004000 /* where the prom loads us */ -- 2.55.0 From 3b4fce95334f26df5807e0c1cb9e9df1e6522f1f Mon Sep 17 00:00:00 2001 From: Rin Okuyama Date: Thu, 5 Nov 2026 18:59:57 +0900 Subject: [PATCH 2/5] sparc: locore: XXX: Work around GAS bug with KERNBASE == 0x80000000 Otherwise, we end up with: ``` /tmp/cc9YX73W.s: Assembler messages: ../../../../arch/sparc/sparc/locore.s:4317: Warning: set: number not in -2147483648..4294967295 range /tmp/cc9YX73W.s: Error: 1 warning, treating warnings as errors ``` Note that this does not result in performance regression; this sequence of insns is executed only once during boot. --- sys/arch/sparc/sparc/locore.s | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/arch/sparc/sparc/locore.s b/sys/arch/sparc/sparc/locore.s index 44ab30459ef..577dd17d20c 100644 --- a/sys/arch/sparc/sparc/locore.s +++ b/sys/arch/sparc/sparc/locore.s @@ -4314,7 +4314,12 @@ startmap_done: sethi %hi(_C_LABEL(u0) + PCB_WIM), %g2 st %g1, [%g2 + %lo(_C_LABEL(u0) + PCB_WIM)] +#if 0 /* XXXGAS */ set USRSTACK - CCFSZ, %fp ! as if called from user code +#else + set USRSTACK, %fp ! as if called from user code + sub %fp, CCFSZ, %fp +#endif set estack0 - CCFSZ - 80, %sp ! via syscall(boot_me_up) or somesuch rd %psr, %l0 wr %l0, PSR_ET, %psr -- 2.55.0 From 0757f08d0d3cd3f99c3f991af42502cba6c2bdd6 Mon Sep 17 00:00:00 2001 From: Rin Okuyama Date: Thu, 5 Nov 2026 18:53:00 +0900 Subject: [PATCH 3/5] sparc: boot: For sun4m/4d, let PROM map 2+extra MB memory in addition to that for kernel image. This allows us to construct kernel page table for ~ 2 GB KVA space. --- sys/arch/sparc/stand/boot/boot.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/arch/sparc/stand/boot/boot.c b/sys/arch/sparc/stand/boot/boot.c index 9040bdf0557..2c647da90b8 100644 --- a/sys/arch/sparc/stand/boot/boot.c +++ b/sys/arch/sparc/stand/boot/boot.c @@ -193,8 +193,16 @@ loadk(char *kernel, u_long *marks) * is enough for the kernel to work with. */ size += BOOTINFO_SIZE; - if (!compatmode) - size += 512 * 1024; + if (!compatmode) { + if (CPU_ISSUN4 || CPU_ISSUN4C) { + size += 512 * 1024; + } else { + /* + * Allocate more for ~ 2 GB KVA space. + */ + size += (2048 + 256) * 1024; + } + } /* Get a physical load address */ pa = getphysmem(size); -- 2.55.0 From 65eae968d2b68f2710eea13bc639bf7a562ba1d5 Mon Sep 17 00:00:00 2001 From: Rin Okuyama Date: Thu, 5 Nov 2026 18:51:30 +0900 Subject: [PATCH 4/5] sparc: Add EKVA{,.MP} kernel for sun4m/d machines with ~ 2 GB KVA space --- sys/arch/sparc/conf/EKVA | 6 ++++++ sys/arch/sparc/conf/EKVA.MP | 6 ++++++ sys/arch/sparc/conf/EKVA.common | 10 ++++++++++ 3 files changed, 22 insertions(+) create mode 100644 sys/arch/sparc/conf/EKVA create mode 100644 sys/arch/sparc/conf/EKVA.MP create mode 100644 sys/arch/sparc/conf/EKVA.common diff --git a/sys/arch/sparc/conf/EKVA b/sys/arch/sparc/conf/EKVA new file mode 100644 index 00000000000..b61038fb0c0 --- /dev/null +++ b/sys/arch/sparc/conf/EKVA @@ -0,0 +1,6 @@ +# $NetBSD$ +# +# sun4m and sun4d machine description file with extended KVA space + +include "arch/sparc/conf/GENERIC" +include "arch/sparc/conf/EKVA.common" diff --git a/sys/arch/sparc/conf/EKVA.MP b/sys/arch/sparc/conf/EKVA.MP new file mode 100644 index 00000000000..e06a24d7efa --- /dev/null +++ b/sys/arch/sparc/conf/EKVA.MP @@ -0,0 +1,6 @@ +# $NetBSD$ +# +# sun4m and sun4d MP machine description file with extended KVA space + +include "arch/sparc/conf/GENERIC.MP" +include "arch/sparc/conf/EKVA.common" diff --git a/sys/arch/sparc/conf/EKVA.common b/sys/arch/sparc/conf/EKVA.common new file mode 100644 index 00000000000..ca622372a46 --- /dev/null +++ b/sys/arch/sparc/conf/EKVA.common @@ -0,0 +1,10 @@ +# $NetBSD$ +# +# Extend KVA space to ~ 2GB for sun4m and sun4d machines + +options KERNBASE=0x80000000 +makeoptions TEXTADDR=80004000 + +no options SUN4 +no options SUN4C +no options SUN4_MMU3L -- 2.55.0 From 84619b7cbf571638eac49943f8c953d48e56df5f Mon Sep 17 00:00:00 2001 From: Rin Okuyama Date: Thu, 5 Nov 2026 18:56:53 +0900 Subject: [PATCH 5/5] etc.sparc: Build EKVA{,.MP} kernels --- etc/etc.sparc/Makefile.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/etc.sparc/Makefile.inc b/etc/etc.sparc/Makefile.inc index 41619c4a1d9..16f43132ed8 100644 --- a/etc/etc.sparc/Makefile.inc +++ b/etc/etc.sparc/Makefile.inc @@ -8,6 +8,7 @@ KERNEL_SETS= GENERIC GENERIC_SCSI3 GENERIC_SUN4U GENERIC.MP \ MRCOFFEE_OFW MRCOFFEE KRUPS +KERNEL_SETS+= EKVA EKVA.MP BUILD_KERNELS= INSTALL -- 2.55.0