Re: sun4v trap table
Sad Clouds <[email protected]> Mon, 6 Oct 2025 11:41:13 +0100
| Newsgroups | gmane.os.netbsd.ports.sparc64 |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 06 Oct 2025 17:34:42 +1100 matthew green <[email protected]> wrote: > > For sparc64 in locore.s below is the fragment from the sun4v trap table for TL (Trap Level) 0: > > > > SPILL64(uspill8_sun4vt0,ASI_AIUS) ! 0x080 spill_0_normal -- used to save user windows in user mode > > SPILL32(uspill4_sun4vt0,ASI_AIUS) ! 0x084 spill_1_normal > > SPILLBOTH(uspill8_sun4vt0,uspill4_sun4vt0,ASI_AIUS) ! 0x088 spill_2_normal > > sun4v_trap_entry_spill_fill_fail 1 ! 0x08c spill_3_normal > > SPILL64(kspill8_sun4vt0,ASI_N) ! 0x090 spill_4_normal -- used to save supervisor windows > > SPILL32(kspill4_sun4vt0,ASI_N) ! 0x094 spill_5_normal > > SPILLBOTH(kspill8_sun4vt0,kspill4_sun4vt0,ASI_N) ! 0x098 spill_6_normal > > sun4v_trap_entry_spill_fill_fail 1 ! 0x09c spill_7_normal > > > > Does anyone know how the TT (Trap Type) maps to the table entries? For > > example, when TT=0x080 why does the kernel think it needs to use SPILL64() > > and for example, not SPILL32(). Where is this defined? > > > > The architecture manual does not seem to specify the details, so I assume > > it is left up to the OS kernel to decide? Is this correct? > > i thought it was more obvious but it's been almost 30 years since > i wrote some code related to this that eeh implemented as well in > a far more complete form, that also worked :) > > the traptype is composed of 9 bits: > > 8:6 are 010 for spill and 011 for fill. > 5 is if OTHERWIN is not 0. > 4:2 are either WSTATE.OTHER or WSTATE.NORMAL. > > (1:0 is always 0 because these are 4-trap long traps.) > > in the (original) v9 manual this is in 7.5.2.1 > "Trap Type for Spill/Fill Traps". > > so the control is on platform setting %WSTATE -- which is 3 bits for > "other" and "normal". we only use two values for this so, really > only two of the above should be used? it's been a while, and i'm > still a little confused by: > > include/psl.h:264:#define WSTATE_USER 022 > include/psl.h:263:#define WSTATE_KERN 026 > > since they both seem to set OTHER bits, which means that 4:2 in the > trap type will always be 2? so always uses SPILLBOTH()? i think i > am still missing something here... > > > (none of the above is sun4v specific but sparc v9 generic.) > > > .mrg. Window State (WSTATE) register: +-----------+ |Other|Norml| +-----------+ 5 4 3 2 1 0 Trap Type (TT) register: +-----+-+-----+---+ | S/F |O|WType|0 0| +-----+-+-----+---+ 8 7 6 5 4 3 2 1 0 S/F : Spill (010) or Fill (011) O : Other (0 if OTHERWIN=0, 1 if OTHERWIN>0) WType: Window type (if Other==0 then WSTATE.NORMAL else WSTATE.OTHER) NetBSD src/sys/arch/sparc64/include/psl.h 263:#define WSTATE_KERN 026 264:#define WSTATE_USER 022 So in binary: WSTATE_KERN is 010 110 WSTATE_USER is 010 010 TT Hex TT Bin Spill/Fill Window State ---------------------------------------------------------- 0x098 010 0 110 00 S OTHERWIN=0 and WSTATE_KERN 0x0A8 010 1 010 00 S OTHERWIN>0 and WSTATE_KERN 0x088 010 0 010 00 S OTHERWIN=0 and WSTATE_USER 0x0A8 010 1 010 00 S OTHERWIN>0 and WSTATE_USER 0x0D8 011 0 110 00 F OTHERWIN=0 and WSTATE_KERN 0x0E8 011 1 010 00 F OTHERWIN>0 and WSTATE_KERN 0x0C8 011 0 010 00 F OTHERWIN=0 and WSTATE_USER 0x0E8 011 1 010 00 F OTHERWIN>0 and WSTATE_USER ---------------------------------------------------------- So when OTHERWIN>0 both WSTATE_KERN and WSTATE_USER map to the same TTs: 0x0A8 for spill TTs and 0x0E8 for fill TTs. Is it supposed to work like this, or OTHERWIN>0 is never set/used in NetBSD? I thought OTHERWIN was only used for microkernel type OS, which may implement client/server calls between isolated modules and may need to partition window registers between different address spaces.