CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Mon Jul 5 16:59:54 UTC 2021 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update status on S7 systems To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.43 src/sys/arch/sparc64/doc/TODO:1.44 --- src/sys/arch/sparc64/doc/TODO:1.43 Fri Jun 25 19:13:12 2021 +++ src/sys/arch/sparc64/doc/TODO Mon Jul 5 16:59:54 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: TODO,v 1.43 2021/06/25 19:13:12 palle Exp $ */ +/* $NetBSD: TODO,v 1.44 2021/07/05 16:59:54 palle Exp $ */ Things to be done: @@ -12,7 +12,7 @@ sun4u: sun4v: - current status - T5 ldom with 2 VCPU and 4GB: + T5 ldom with 2 VCPU and 4GB (primary ldom is Solaris 11.4 SRU30):: - kernel boots from miniroot.fs via ldom fisk (vdsk) - ldom virtual network interface (vnet) is working (verified by exiting sysinst and issuing a ping command) @@ -24,9 +24,8 @@ sun4v: unpacked, but the system hangs afterwards when running the makedev script. T2000 ldom with 8 VCPU and 4GB: - crashes in /sbin/init doing an access() call where %o0 is corrupted (zero) - S7 ldom with 8 VCPU and 16GB (primary ldom is Solaris 11.4 SRU30): - - during autoconfiguration of vnet devices the call to hv_vintr_setenabled() - returns error code 7 (EBADTRAP?) + S7 ldom with 8 VCPU and 16GB (primary ldom is Solaris 11.4 SRU33): + - same status as T5 ldom - 64-bit kernel support - 32-bit kernel support - libkvm
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Sat Jul 3 19:39:07 UTC 2021 Modified Files: src/sys/arch/sparc64/sparc64: autoconf.c Log Message: sun4v: request hypervisor api major version 3 for the interrupt group - should solve issues when setting up interrupts on S7 systems To generate a diff of this commit: cvs rdiff -u -r1.232 -r1.233 src/sys/arch/sparc64/sparc64/autoconf.c 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/sparc64/sparc64/autoconf.c diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.232 src/sys/arch/sparc64/sparc64/autoconf.c:1.233 --- src/sys/arch/sparc64/sparc64/autoconf.c:1.232 Sat Jul 3 19:18:55 2021 +++ src/sys/arch/sparc64/sparc64/autoconf.c Sat Jul 3 19:39:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.232 2021/07/03 19:18:55 palle Exp $ */ +/* $NetBSD: autoconf.c,v 1.233 2021/07/03 19:39:07 palle Exp $ */ /* * Copyright (c) 1996 @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.232 2021/07/03 19:18:55 palle Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.233 2021/07/03 19:39:07 palle Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -189,9 +189,9 @@ void sun4v_set_soft_state(int, const cha char sun4v_soft_state_booting[] __align32 = "NetBSD booting"; char sun4v_soft_state_running[] __align32 = "NetBSD running"; +void sun4v_interrupt_init(void); #if 0 XXX notyet -void sun4v_interrupt_init(void); void sun4v_sdio_init(void); #endif #endif @@ -378,9 +378,9 @@ die_old_boot_loader: if (CPU_ISSUN4V) { sun4v_soft_state_init(); sun4v_set_soft_state(SIS_TRANSITION, sun4v_soft_state_booting); + sun4v_interrupt_init(); #if 0 XXX notyet - sun4v_interrupt_init(); sun4v_sdio_init(); #endif } @@ -570,8 +570,6 @@ sun4v_set_soft_state(int state, const ch printf("soft_state_set: %d\n", err); } -#if 0 -XXX notyet void sun4v_interrupt_init(void) { @@ -582,7 +580,6 @@ sun4v_interrupt_init(void) sun4v_group_interrupt_major = 3; } -#endif #if 0 XXX notyet
CVS commit: src/sys/arch/sparc64
Module Name:src Committed By: palle Date: Sat Jul 3 19:18:56 UTC 2021 Modified Files: src/sys/arch/sparc64/include: hypervisor.h sparc64.h src/sys/arch/sparc64/sparc64: autoconf.c intr.c ofw_machdep.c Log Message: sun4v: add support for hypervisor soft state - from OpenBSD To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sparc64/include/hypervisor.h cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc64/include/sparc64.h cvs rdiff -u -r1.231 -r1.232 src/sys/arch/sparc64/sparc64/autoconf.c cvs rdiff -u -r1.69 -r1.70 src/sys/arch/sparc64/sparc64/intr.c cvs rdiff -u -r1.46 -r1.47 src/sys/arch/sparc64/sparc64/ofw_machdep.c 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/sparc64/include/hypervisor.h diff -u src/sys/arch/sparc64/include/hypervisor.h:1.7 src/sys/arch/sparc64/include/hypervisor.h:1.8 --- src/sys/arch/sparc64/include/hypervisor.h:1.7 Tue Apr 27 19:09:56 2021 +++ src/sys/arch/sparc64/include/hypervisor.h Sat Jul 3 19:18:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.h,v 1.7 2021/04/27 19:09:56 palle Exp $ */ +/* $NetBSD: hypervisor.h,v 1.8 2021/07/03 19:18:55 palle Exp $ */ /* $OpenBSD: hypervisor.h,v 1.14 2011/06/26 17:23:46 kettenis Exp $ */ /* @@ -391,4 +391,15 @@ int64_t hv_rng_data_read(paddr_t raddr, #define H_ETOOMANY 15 #define H_ECHANNEL 16 +#ifndef _LOCORE +extern uint64_t sun4v_group_interrupt_major; +extern uint64_t sun4v_group_sdio_major; + +int64_t sun4v_intr_devino_to_sysino(uint64_t, uint64_t, uint64_t *); +int64_t sun4v_intr_setcookie(uint64_t, uint64_t, uint64_t); +int64_t sun4v_intr_setenabled(uint64_t, uint64_t, uint64_t); +int64_t sun4v_intr_setstate(uint64_t, uint64_t, uint64_t); +int64_t sun4v_intr_settarget(uint64_t, uint64_t, uint64_t); +#endif + #endif /* _HYPERVISOR_H_ */ Index: src/sys/arch/sparc64/include/sparc64.h diff -u src/sys/arch/sparc64/include/sparc64.h:1.13 src/sys/arch/sparc64/include/sparc64.h:1.14 --- src/sys/arch/sparc64/include/sparc64.h:1.13 Sat Sep 6 20:56:39 2014 +++ src/sys/arch/sparc64/include/sparc64.h Sat Jul 3 19:18:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sparc64.h,v 1.13 2014/09/06 20:56:39 palle Exp $ */ +/* $NetBSD: sparc64.h,v 1.14 2021/07/03 19:18:55 palle Exp $ */ /* * Copyright (C) 1996 Wolfgang Solfrank. @@ -59,5 +59,7 @@ int prom_stop_other(u_int); bool prom_has_stop_other(void); void prom_startcpu(u_int, void *, u_long); int prom_startcpu_by_cpuid(u_int, void *, u_long arg); +uint64_t prom_set_sun4v_api_version(uint64_t, uint64_t, uint64_t, uint64_t *); +void prom_sun4v_soft_state_supported(void); #endif /* _MACHINE_SPARC64_H_ */ Index: src/sys/arch/sparc64/sparc64/autoconf.c diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.231 src/sys/arch/sparc64/sparc64/autoconf.c:1.232 --- src/sys/arch/sparc64/sparc64/autoconf.c:1.231 Wed May 12 23:22:33 2021 +++ src/sys/arch/sparc64/sparc64/autoconf.c Sat Jul 3 19:18:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.231 2021/05/12 23:22:33 thorpej Exp $ */ +/* $NetBSD: autoconf.c,v 1.232 2021/07/03 19:18:55 palle Exp $ */ /* * Copyright (c) 1996 @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.231 2021/05/12 23:22:33 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.232 2021/07/03 19:18:55 palle Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -181,6 +181,21 @@ struct intrmap intrmap[] = { { NULL, 0 } }; +#ifdef SUN4V +void sun4v_soft_state_init(void); +void sun4v_set_soft_state(int, const char *); + +#define __align32 __attribute__((__aligned__(32))) +char sun4v_soft_state_booting[] __align32 = "NetBSD booting"; +char sun4v_soft_state_running[] __align32 = "NetBSD running"; + +#if 0 +XXX notyet +void sun4v_interrupt_init(void); +void sun4v_sdio_init(void); +#endif +#endif + int console_node, console_instance; struct genfb_colormap_callback gfb_cb; static void of_set_palette(void *, int, int, int, int); @@ -358,6 +373,18 @@ die_old_boot_loader: get_ncpus(); pmap_bootstrap(KERNBASE, bi_kend->addr); + +#ifdef SUN4V + if (CPU_ISSUN4V) { + sun4v_soft_state_init(); + sun4v_set_soft_state(SIS_TRANSITION, sun4v_soft_state_booting); +#if 0 +XXX notyet + sun4v_interrupt_init(); + sun4v_sdio_init(); +#endif + } +#endif } /* @@ -499,7 +526,79 @@ cpu_configure(void) setpstate(getpstate()|PSTATE_IE); (void)spl0(); + +#ifdef SUN4V + if (CPU_ISSUN4V) + sun4v_set_soft_state(SIS_NORMAL, sun4v_soft_state_running); +#endif +} + +#ifdef SUN4V + +#define HSVC_GROUP_INTERRUPT 0x002 +#define HSVC_GROUP_SOFT_STATE 0x003 +#define HSVC_GROUP_SDIO 0x108 + +int sun4v_soft_state_initialized = 0; + +void +sun4v_soft_state_init(void) +{ + uint64_t minor; + + if (prom_set_sun4v_api_version(HSVC_GROUP_SOFT_STATE, 1, 0, )) + return; + + prom_sun4v_soft_state_supported(); + sun4v_soft_state_initialized = 1; +} + +void +sun4v_set_soft_state(int state,
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Fri Jun 25 19:13:12 UTC 2021 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update TODO file with current sun4v progress To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.42 src/sys/arch/sparc64/doc/TODO:1.43 --- src/sys/arch/sparc64/doc/TODO:1.42 Sun Jun 13 17:02:14 2021 +++ src/sys/arch/sparc64/doc/TODO Fri Jun 25 19:13:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: TODO,v 1.42 2021/06/13 17:02:14 palle Exp $ */ +/* $NetBSD: TODO,v 1.43 2021/06/25 19:13:12 palle Exp $ */ Things to be done: @@ -20,9 +20,8 @@ sun4v: but the process crashes when selecting network installation method. The %i,%l and %o registers are corrupted, after a call to the libcurses wrefresh() function. - If the sysinst insallation source is local directory, an error in the - ldsk device driver is triggered when a DATA/NACK/DRING_DATA event is received. - The current implementation does not hande this exception properly. + If the sysinst insallation source is local directory, the sets are properly + unpacked, but the system hangs afterwards when running the makedev script. T2000 ldom with 8 VCPU and 4GB: - crashes in /sbin/init doing an access() call where %o0 is corrupted (zero) S7 ldom with 8 VCPU and 16GB (primary ldom is Solaris 11.4 SRU30):
CVS commit: src/sys/arch/sparc64/dev
Module Name:src Committed By: palle Date: Fri Jun 25 19:10:50 UTC 2021 Modified Files: src/sys/arch/sparc64/dev: vdsk.c Log Message: sun4v: vdsk - restart the ldc state machine when the ldc endpoint resets the link or a DATA/NACK/DRING_DATA message is received. These changes make the driver more robust. In a ldom with Solaris 11.4 SRU30 as primary domain (T5 host system) frequent resets and NACK messages are observed. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/dev/vdsk.c 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/sparc64/dev/vdsk.c diff -u src/sys/arch/sparc64/dev/vdsk.c:1.6 src/sys/arch/sparc64/dev/vdsk.c:1.7 --- src/sys/arch/sparc64/dev/vdsk.c:1.6 Sat Apr 24 23:36:49 2021 +++ src/sys/arch/sparc64/dev/vdsk.c Fri Jun 25 19:10:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: vdsk.c,v 1.6 2021/04/24 23:36:49 thorpej Exp $ */ +/* $NetBSD: vdsk.c,v 1.7 2021/06/25 19:10:50 palle Exp $ */ /* $OpenBSD: vdsk.c,v 1.46 2015/01/25 21:42:13 kettenis Exp $ */ /* * Copyright (c) 2009, 2011 Mark Kettenis @@ -492,6 +492,7 @@ vdsk_rx_intr(void *arg) break; case LDC_CHANNEL_RESET: DPRINTF(("Rx link reset\n")); + ldc_send_vers(lc); break; } lc->lc_rx_state = rx_state; @@ -773,6 +774,8 @@ vdsk_rx_vio_dring_data(struct vdsk_softc case VIO_SUBTYPE_NACK: DPRINTF(("DATA/NACK/DRING_DATA\n")); + struct ldc_conn *lc = >sc_lc; + ldc_send_vers(lc); break; default:
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Sun Jun 13 17:02:14 UTC 2021 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update TODO file with current sun4v state To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.41 src/sys/arch/sparc64/doc/TODO:1.42 --- src/sys/arch/sparc64/doc/TODO:1.41 Sat Apr 3 17:02:31 2021 +++ src/sys/arch/sparc64/doc/TODO Sun Jun 13 17:02:14 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: TODO,v 1.41 2021/04/03 17:02:31 palle Exp $ */ +/* $NetBSD: TODO,v 1.42 2021/06/13 17:02:14 palle Exp $ */ Things to be done: @@ -17,7 +17,12 @@ sun4v: - ldom virtual network interface (vnet) is working (verified by exiting sysinst and issuing a ping command) - the sysinst tool starts, disk setup is working, - but the process crashes when selecting network installation method (trap 0x34 ALIGN is received) + but the process crashes when selecting network installation method. + The %i,%l and %o registers are corrupted, after a call to the libcurses + wrefresh() function. + If the sysinst insallation source is local directory, an error in the + ldsk device driver is triggered when a DATA/NACK/DRING_DATA event is received. + The current implementation does not hande this exception properly. T2000 ldom with 8 VCPU and 4GB: - crashes in /sbin/init doing an access() call where %o0 is corrupted (zero) S7 ldom with 8 VCPU and 16GB (primary ldom is Solaris 11.4 SRU30):
CVS commit: src/sys/arch/sparc64
Module Name:src Committed By: palle Date: Tue Apr 27 19:09:56 UTC 2021 Modified Files: src/sys/arch/sparc64/include: hypervisor.h src/sys/arch/sparc64/sparc64: hvcall.S Log Message: sun4v: add missing method to set hypervisor api version + add defintion for the interrupt hypervisor api group (to be used) To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/include/hypervisor.h cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/sparc64/hvcall.S 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/sparc64/include/hypervisor.h diff -u src/sys/arch/sparc64/include/hypervisor.h:1.6 src/sys/arch/sparc64/include/hypervisor.h:1.7 --- src/sys/arch/sparc64/include/hypervisor.h:1.6 Fri Feb 10 23:26:23 2017 +++ src/sys/arch/sparc64/include/hypervisor.h Tue Apr 27 19:09:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.h,v 1.6 2017/02/10 23:26:23 palle Exp $ */ +/* $NetBSD: hypervisor.h,v 1.7 2021/04/27 19:09:56 palle Exp $ */ /* $OpenBSD: hypervisor.h,v 1.14 2011/06/26 17:23:46 kettenis Exp $ */ /* @@ -36,7 +36,13 @@ #ifndef _LOCORE int64_t hv_api_get_version(uint64_t api_group, - uint64_t *major_number, uint64_t *minor_number); + uint64_t *major_number, + uint64_t *minor_number); +int64_t hv_api_set_version(uint64_t api_group, + uint64_t major_number, + uint64_t req_minor_number, + uint64_t* actual_minor_number); +#define HV_API_GROUP_INTERRUPT 0x002 #endif /* * Domain services Index: src/sys/arch/sparc64/sparc64/hvcall.S diff -u src/sys/arch/sparc64/sparc64/hvcall.S:1.4 src/sys/arch/sparc64/sparc64/hvcall.S:1.5 --- src/sys/arch/sparc64/sparc64/hvcall.S:1.4 Sun Jun 8 17:33:24 2014 +++ src/sys/arch/sparc64/sparc64/hvcall.S Tue Apr 27 19:09:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: hvcall.S,v 1.4 2014/06/08 17:33:24 palle Exp $ */ +/* $NetBSD: hvcall.S,v 1.5 2021/04/27 19:09:56 palle Exp $ */ /* $OpenBSD: hvcall.S,v 1.10 2011/06/25 20:45:00 kettenis Exp $ */ /* @@ -151,6 +151,13 @@ ENTRY(hv_api_get_version) retl stx %o2, [%o4] +ENTRY(hv_api_set_version) + mov %o3, %o4 + mov API_SET_VERSION, %o5 + ta ST_CORE_TRAP + retl + stx %o1, [%o4] + ENTRY(hv_mach_desc) mov %o1, %o2 ldx [%o2], %o1
CVS commit: src/sys/arch/sparc64/dev
Module Name:src Committed By: palle Date: Mon Apr 5 12:19:22 UTC 2021 Modified Files: src/sys/arch/sparc64/dev: ldc.c Log Message: sun4v: Ignore spurious ldc CTRL/ACK/VERS messages (do not reset the connection anymore). Fixes occationals stalls when vdsk uses the ldc service. Observed on both T2000 and T5 host systems To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/dev/ldc.c 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/sparc64/dev/ldc.c diff -u src/sys/arch/sparc64/dev/ldc.c:1.6 src/sys/arch/sparc64/dev/ldc.c:1.7 --- src/sys/arch/sparc64/dev/ldc.c:1.6 Tue Oct 15 00:13:52 2019 +++ src/sys/arch/sparc64/dev/ldc.c Mon Apr 5 12:19:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ldc.c,v 1.6 2019/10/15 00:13:52 chs Exp $ */ +/* $NetBSD: ldc.c,v 1.7 2021/04/05 12:19:22 palle Exp $ */ /* $OpenBSD: ldc.c,v 1.12 2015/03/21 18:02:58 kettenis Exp $ */ /* * Copyright (c) 2009 Mark Kettenis @@ -76,24 +76,25 @@ ldc_rx_ctrl_vers(struct ldc_conn *lc, st { switch (lp->stype) { case LDC_INFO: - DPRINTF(("CTRL/INFO/VERS\n")); + DPRINTF(("CTRL/INFO/VERS major %d minor %d\n", lp->major, lp->minor)); if (lp->major == LDC_VERSION_MAJOR && lp->minor == LDC_VERSION_MINOR) ldc_send_ack(lc); else { /* XXX do nothing for now. */ + DPRINTF(("CTRL/INFO/VERS unsupported major/minor\n")); } break; case LDC_ACK: + DPRINTF(("CTRL/ACK/VERS\n")); if (lc->lc_state != LDC_SND_VERS) { - DPRINTF(("Spurious CTRL/ACK/VERS: state %d\n", - lc->lc_state)); - ldc_reset(lc); - return; + DPRINTF(("Spurious CTRL/ACK/VERS: state %d major %d minor %d (ignored)\n", + lc->lc_state, lp->major, lp->minor)); + } + else { + ldc_send_rts(lc); } - DPRINTF(("CTRL/ACK/VERS\n")); - ldc_send_rts(lc); break; case LDC_NACK: @@ -263,6 +264,7 @@ ldc_send_vers(struct ldc_conn *lc) lp->ctrl = LDC_VERS; lp->major = 1; lp->minor = 0; + DPRINTF(("ldc_send_vers() major %d minor %d\n", lp->major, lp->minor)); tx_tail += sizeof(*lp); tx_tail &= ((lc->lc_txq->lq_nentries * sizeof(*lp)) - 1); @@ -274,6 +276,7 @@ ldc_send_vers(struct ldc_conn *lc) } lc->lc_state = LDC_SND_VERS; + DPRINTF(("ldc_send_vers() setting lc->lc_state to %d\n", lc->lc_state)); mutex_exit(>lc_txq->lq_mtx); } @@ -309,6 +312,7 @@ ldc_send_ack(struct ldc_conn *lc) } lc->lc_state = LDC_RCV_VERS; + DPRINTF(("ldc_send_ack() setting lc->lc_state to %d\n", lc->lc_state)); mutex_exit(>lc_txq->lq_mtx); } @@ -344,6 +348,7 @@ ldc_send_rts(struct ldc_conn *lc) } lc->lc_state = LDC_SND_RTS; + DPRINTF(("ldc_send_rts() setting lc->lc_state to %d\n", lc->lc_state)); mutex_exit(>lc_txq->lq_mtx); } @@ -379,6 +384,7 @@ ldc_send_rtr(struct ldc_conn *lc) } lc->lc_state = LDC_SND_RTR; + DPRINTF(("ldc_send_rtr() setting lc->lc_state to %d\n", lc->lc_state)); mutex_exit(>lc_txq->lq_mtx); } @@ -414,6 +420,7 @@ ldc_send_rdx(struct ldc_conn *lc) } lc->lc_state = LDC_SND_RDX; + DPRINTF(("ldc_send_rdx() setting lc->lc_state to %d\n", lc->lc_state)); mutex_exit(>lc_txq->lq_mtx); }
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Sat Apr 3 17:02:32 UTC 2021 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: update TODO after cpu_idle() has been improved (sun4v only for now) To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.40 src/sys/arch/sparc64/doc/TODO:1.41 --- src/sys/arch/sparc64/doc/TODO:1.40 Tue Mar 30 20:23:45 2021 +++ src/sys/arch/sparc64/doc/TODO Sat Apr 3 17:02:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: TODO,v 1.40 2021/03/30 20:23:45 palle Exp $ */ +/* $NetBSD: TODO,v 1.41 2021/04/03 17:02:31 palle Exp $ */ Things to be done: @@ -23,7 +23,6 @@ sun4v: S7 ldom with 8 VCPU and 16GB (primary ldom is Solaris 11.4 SRU30): - during autoconfiguration of vnet devices the call to hv_vintr_setenabled() returns error code 7 (EBADTRAP?) -- idle handling - call hypervisor trap (openbsd code...??) - 64-bit kernel support - 32-bit kernel support - libkvm
CVS commit: src/sys/arch/sparc64
Module Name:src Committed By: palle Date: Sat Apr 3 17:01:24 UTC 2021 Modified Files: src/sys/arch/sparc64/include: cpu.h src/sys/arch/sparc64/sparc64: cpu.c genassym.cf locore.s Log Message: Improve cpu_idle() by allowing a platform specific implementaion (same logic as the sparc implementation) - currently only used by sun4v To generate a diff of this commit: cvs rdiff -u -r1.130 -r1.131 src/sys/arch/sparc64/include/cpu.h cvs rdiff -u -r1.138 -r1.139 src/sys/arch/sparc64/sparc64/cpu.c cvs rdiff -u -r1.84 -r1.85 src/sys/arch/sparc64/sparc64/genassym.cf cvs rdiff -u -r1.426 -r1.427 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/include/cpu.h diff -u src/sys/arch/sparc64/include/cpu.h:1.130 src/sys/arch/sparc64/include/cpu.h:1.131 --- src/sys/arch/sparc64/include/cpu.h:1.130 Tue Mar 10 03:49:56 2020 +++ src/sys/arch/sparc64/include/cpu.h Sat Apr 3 17:01:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.130 2020/03/10 03:49:56 christos Exp $ */ +/* $NetBSD: cpu.h,v 1.131 2021/04/03 17:01:24 palle Exp $ */ /* * Copyright (c) 1992, 1993 @@ -212,12 +212,14 @@ struct cpu_info { paddr_t ci_devmq; /* device mondo queue address */ paddr_t ci_cpuset; /* mondo recipient address */ paddr_t ci_mondo; /* mondo message address */ - + /* probe fault in PCI config space reads */ bool ci_pci_probe; bool ci_pci_fault; volatile void *ci_ddb_regs; /* DDB regs */ + + void (*ci_idlespin)(void); }; #endif /* _KERNEL || _KMEMUSER */ @@ -438,6 +440,9 @@ void switchtoctx_usiii(int); void next_tick(long); void next_stick(long); void next_stick_init(void); +#ifdef SUN4V +voidcpu_idle_sun4v(void); +#endif /* trap.c */ void cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t); int rwindow_save(struct lwp *); Index: src/sys/arch/sparc64/sparc64/cpu.c diff -u src/sys/arch/sparc64/sparc64/cpu.c:1.138 src/sys/arch/sparc64/sparc64/cpu.c:1.139 --- src/sys/arch/sparc64/sparc64/cpu.c:1.138 Fri Aug 7 14:20:08 2020 +++ src/sys/arch/sparc64/sparc64/cpu.c Sat Apr 3 17:01:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.138 2020/08/07 14:20:08 fcambus Exp $ */ +/* $NetBSD: cpu.c,v 1.139 2021/04/03 17:01:24 palle Exp $ */ /* * Copyright (c) 1996 @@ -52,7 +52,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.138 2020/08/07 14:20:08 fcambus Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.139 2021/04/03 17:01:24 palle Exp $"); #include "opt_multiprocessor.h" @@ -695,9 +695,22 @@ cpu_attach(device_t parent, device_t dev ci->ci_cpuset = pa; pa += 64; } - + + /* + * cpu_idle setup (currently only necessary for sun4v) + */ + if (CPU_ISSUN4V) { + ci->ci_idlespin = cpu_idle_sun4v; + } } +#ifdef SUN4V +void cpu_idle_sun4v(void) +{ + hv_cpu_yield(); +} +#endif + int cpu_myid(void) { Index: src/sys/arch/sparc64/sparc64/genassym.cf diff -u src/sys/arch/sparc64/sparc64/genassym.cf:1.84 src/sys/arch/sparc64/sparc64/genassym.cf:1.85 --- src/sys/arch/sparc64/sparc64/genassym.cf:1.84 Mon Feb 17 09:09:49 2020 +++ src/sys/arch/sparc64/sparc64/genassym.cf Sat Apr 3 17:01:24 2021 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.84 2020/02/17 09:09:49 skrll Exp $ +# $NetBSD: genassym.cf,v 1.85 2021/04/03 17:01:24 palle Exp $ # # Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -183,6 +183,7 @@ define CI_DEVMQ offsetof(struct cpu_info ifdef MULTIPROCESSOR define CI_IPIEVC offsetof(struct cpu_info, ci_ipi_evcnt[0].ev_count) endif +define CI_IDLESPIN offsetof(struct cpu_info, ci_idlespin) # CPU boot arguments structure define CBA_NODE offsetof(struct cpu_bootargs, cb_node) Index: src/sys/arch/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.426 src/sys/arch/sparc64/sparc64/locore.s:1.427 --- src/sys/arch/sparc64/sparc64/locore.s:1.426 Tue Mar 30 20:03:14 2021 +++ src/sys/arch/sparc64/sparc64/locore.s Sat Apr 3 17:01:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.426 2021/03/30 20:03:14 palle Exp $ */ +/* $NetBSD: locore.s,v 1.427 2021/04/03 17:01:24 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -6619,11 +6619,19 @@ ENTRY(getfp) mov %fp, %o0 /* - * nothing MD to do in the idle loop + * Call optional cpu_idle handler if provided */ ENTRY(cpu_idle) - retl + set CPUINFO_VA, %o0 + LDPTR [%o0 + CI_IDLESPIN], %o1 + tst %o1 + bz 1f + nop + jmp %o1 nop +1: + retl + nop /* * cpu_switchto() switches to an lwp to run and runs it, saving the
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Tue Mar 30 20:23:45 UTC 2021 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update TODO after pcb spill improvements and status when running on a S7 host To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.39 src/sys/arch/sparc64/doc/TODO:1.40 --- src/sys/arch/sparc64/doc/TODO:1.39 Tue Mar 23 19:13:46 2021 +++ src/sys/arch/sparc64/doc/TODO Tue Mar 30 20:23:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: TODO,v 1.39 2021/03/23 19:13:46 palle Exp $ */ +/* $NetBSD: TODO,v 1.40 2021/03/30 20:23:45 palle Exp $ */ Things to be done: @@ -17,11 +17,12 @@ sun4v: - ldom virtual network interface (vnet) is working (verified by exiting sysinst and issuing a ping command) - the sysinst tool starts, disk setup is working, - but the process crashes when selecting network installation method - (the pcbspill function in locore.s incorrectly only spills one register - window even if more than one is are present) + but the process crashes when selecting network installation method (trap 0x34 ALIGN is received) T2000 ldom with 8 VCPU and 4GB: - On this platform it crashes in /sbin/init doing an access() call where %o0 is corrupted (zero) + - crashes in /sbin/init doing an access() call where %o0 is corrupted (zero) + S7 ldom with 8 VCPU and 16GB (primary ldom is Solaris 11.4 SRU30): + - during autoconfiguration of vnet devices the call to hv_vintr_setenabled() + returns error code 7 (EBADTRAP?) - idle handling - call hypervisor trap (openbsd code...??) - 64-bit kernel support - 32-bit kernel support
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Tue Mar 30 20:03:15 UTC 2021 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: handle spill trap properly when trap level is 1 and otherwin is non-zero - ensure that all windows are spilled to the pcb like the sun4u winfixsave code path To generate a diff of this commit: cvs rdiff -u -r1.425 -r1.426 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.425 src/sys/arch/sparc64/sparc64/locore.s:1.426 --- src/sys/arch/sparc64/sparc64/locore.s:1.425 Mon Feb 22 09:56:42 2021 +++ src/sys/arch/sparc64/sparc64/locore.s Tue Mar 30 20:03:14 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.425 2021/02/22 09:56:42 palle Exp $ */ +/* $NetBSD: locore.s,v 1.426 2021/03/30 20:03:14 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -234,7 +234,7 @@ .endm .macro sun4v_tl1_uspill_other - ba,a,pt %xcc, pcbspill_others + ba,a,pt %xcc, pcbspill_other nop .align 128 .endm @@ -3485,6 +3485,77 @@ pcbspill_fail: Debugger() NOTREACHED + +pcbspill_other: + + set CPUINFO_VA, %g6 + ldx [%g6 + CI_CPCB], %g6 + + GET_CTXBUSY %g1 + + ldx [%g1], %g1! kernel pmap is ctx 0 + + srlx %g6, STSHIFT, %g7 + and %g7, STMASK, %g7 + sll %g7, 3, %g7! byte offset into ctxbusy + add %g7, %g1, %g1 + ldxa [%g1] ASI_PHYS_CACHED, %g1 ! Load pointer to directory + + srlx %g6, PDSHIFT, %g7 ! Do page directory + and %g7, PDMASK, %g7 + sll %g7, 3, %g7 + brz,pn %g1, pcbspill_other_fail + add %g7, %g1, %g1 + ldxa [%g1] ASI_PHYS_CACHED, %g1 + srlx %g6, PTSHIFT, %g7 ! Convert to ptab offset + and %g7, PTMASK, %g7 + brz %g1, pcbspill_other_fail + sll %g7, 3, %g7 + add %g1, %g7, %g7 + ldxa [%g7] ASI_PHYS_CACHED, %g7 ! This one is not + brgez %g7, pcbspill_other_fail + srlx %g7, PGSHIFT, %g7 ! Isolate PA part + sll %g6, 32-PGSHIFT, %g6 ! And offset + sllx %g7, PGSHIFT+8, %g7 ! There are 8 bits to the left of the PA in the TTE + srl %g6, 32-PGSHIFT, %g6 + srax %g7, 8, %g7 + or %g7, %g6, %g6! Then combine them to form PA + + wr %g0, ASI_PHYS_CACHED, %asi ! Use ASI_PHYS_CACHED to prevent possible page faults + + lduba [%g6 + PCB_NSAVED] %asi, %g7 ! Fetch current nsaved from the pcb + sllx %g7, 7, %g5! 8+8 registers each 8 bytes = 128 bytes (2^7) + add %g6, %g5, %g5! Offset into pcb_rw +1: + SPILL stxa, %g5 + PCB_RW, 8, %asi ! Store the locals and ins + + add %g5, 16*8, %g5! Next location for saved register windows + + stxa %o6, [%g5 + PCB_RW + (14*8)] %asi ! Save %sp so we can write these all out + + saved ! Increments %cansave and decrements %otherwin + + rdpr %cwp, %g1! shift register window forward + inc %g1 + wrpr %g1, %cwp + + + inc %g7 ! increment number of saved register windows + + rdpr %otherwin, %g1! Check to see if done spill'ing otherwin + brnz,pt %g1, 1b + nop + + stba %g7, [%g6 + PCB_NSAVED] %asi + + retry + NOTREACHED + +pcbspill_other_fail: + Debugger() + NOTREACHED + + spill_normal_to_user_stack: mov %sp, %g6 ! calculate virtual address of destination stack add %g6, BIAS, %g6
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Tue Mar 23 19:13:46 UTC 2021 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update TODO with findings related to crashes in user processes (pcbspill) To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.38 src/sys/arch/sparc64/doc/TODO:1.39 --- src/sys/arch/sparc64/doc/TODO:1.38 Tue Mar 16 20:11:30 2021 +++ src/sys/arch/sparc64/doc/TODO Tue Mar 23 19:13:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: TODO,v 1.38 2021/03/16 20:11:30 palle Exp $ */ +/* $NetBSD: TODO,v 1.39 2021/03/23 19:13:46 palle Exp $ */ Things to be done: @@ -17,8 +17,9 @@ sun4v: - ldom virtual network interface (vnet) is working (verified by exiting sysinst and issuing a ping command) - the sysinst tool starts, disk setup is working, - but the process crashes when selecting network installtion method - (probably due to trashing of user proces registers) + but the process crashes when selecting network installation method + (the pcbspill function in locore.s incorrectly only spills one register + window even if more than one is are present) T2000 ldom with 8 VCPU and 4GB: On this platform it crashes in /sbin/init doing an access() call where %o0 is corrupted (zero) - idle handling - call hypervisor trap (openbsd code...??)
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Tue Mar 16 20:11:30 UTC 2021 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update TODO - update status after hacking on ldom virtual network interfaces To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.37 src/sys/arch/sparc64/doc/TODO:1.38 --- src/sys/arch/sparc64/doc/TODO:1.37 Thu Mar 4 20:00:51 2021 +++ src/sys/arch/sparc64/doc/TODO Tue Mar 16 20:11:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: TODO,v 1.37 2021/03/04 20:00:51 palle Exp $ */ +/* $NetBSD: TODO,v 1.38 2021/03/16 20:11:30 palle Exp $ */ Things to be done: @@ -13,11 +13,12 @@ sun4u: sun4v: - current status T5 ldom with 2 VCPU and 4GB: - The kernel boots and starts userland when booting miniroot.fs. - The sysinst tool starts properly and is functional. - Installation is not possible, since no driver currently exists - for the ldom network interfaces, but openbsd vnet and vsw drivers are - possible to integrate and this work is progressing. + - kernel boots from miniroot.fs via ldom fisk (vdsk) + - ldom virtual network interface (vnet) is working + (verified by exiting sysinst and issuing a ping command) + - the sysinst tool starts, disk setup is working, + but the process crashes when selecting network installtion method + (probably due to trashing of user proces registers) T2000 ldom with 8 VCPU and 4GB: On this platform it crashes in /sbin/init doing an access() call where %o0 is corrupted (zero) - idle handling - call hypervisor trap (openbsd code...??)
CVS commit: src/sys/arch/sparc64/dev
Module Name:src Committed By: palle Date: Mon Mar 15 18:44:05 UTC 2021 Modified Files: src/sys/arch/sparc64/dev: vnet.c Log Message: sun4v: vnet - cleanup of debug code (no functional changes) To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/dev/vnet.c 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/sparc64/dev/vnet.c diff -u src/sys/arch/sparc64/dev/vnet.c:1.4 src/sys/arch/sparc64/dev/vnet.c:1.5 --- src/sys/arch/sparc64/dev/vnet.c:1.4 Sat Mar 13 20:21:37 2021 +++ src/sys/arch/sparc64/dev/vnet.c Mon Mar 15 18:44:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: vnet.c,v 1.4 2021/03/13 20:21:37 palle Exp $ */ +/* $NetBSD: vnet.c,v 1.5 2021/03/15 18:44:04 palle Exp $ */ /* $OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $ */ /* * Copyright (c) 2009, 2015 Mark Kettenis @@ -16,14 +16,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#if 0 -FIXME openbsd -#include "bpfilter.h" -#endif - #include #include #include +#include #include #include #include @@ -31,12 +27,6 @@ FIXME openbsd #include #include #include -#if 0 -FIXME openbsd -#include -#else -#include -#endif #include #include @@ -58,9 +48,6 @@ FIXME openbsd #include #include -#if 1 -#define VNET_DEBUG -#endif #ifdef VNET_DEBUG #define DPRINTF(x) printf x #else @@ -137,12 +124,7 @@ void vnet_dring_free(bus_dma_tag_t, stru struct vnet_soft_desc { int vsd_map_idx; -#if 0 -FIXME openbsd - caddr_t vsd_buf; -#else unsigned char *vsd_buf; -#endif }; struct vnet_softc { @@ -171,12 +153,7 @@ struct vnet_softc { #define VIO_ACK_RDX 0x0400 #define VIO_RCV_RDX 0x0800 -#if 0 -FIXME openbsd - struct timeout sc_handshake_to; -#else struct callout sc_handshake_co; -#endif uint8_t sc_xfer_mode; @@ -284,19 +261,6 @@ vnet_attach(struct device *parent, struc hv_ldc_tx_qconf(ca->ca_id, 0, 0); hv_ldc_rx_qconf(ca->ca_id, 0, 0); -#if 0 -FIXME openbsd - sc->sc_tx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_tx_ino, - IPL_NET, BUS_INTR_ESTABLISH_MPSAFE, vnet_tx_intr, - sc, sc->sc_dv.dv_xname); - sc->sc_rx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_rx_ino, - IPL_NET, BUS_INTR_ESTABLISH_MPSAFE, vnet_rx_intr, - sc, sc->sc_dv.dv_xname); - if (sc->sc_tx_ih == NULL || sc->sc_rx_ih == NULL) { - printf(", can't establish interrupt\n"); - return; - } -#else sc->sc_tx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_tx_ino, IPL_NET, vnet_tx_intr, sc); sc->sc_rx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_rx_ino, @@ -305,7 +269,6 @@ FIXME openbsd printf(", can't establish interrupts\n"); return; } -#endif lc = >sc_lc; lc->lc_id = ca->ca_id; @@ -314,28 +277,10 @@ FIXME openbsd lc->lc_start = vnet_ldc_start; lc->lc_rx_data = vio_rx_data; -#if 0 -FIXME openbsd - timeout_set(>sc_handshake_to, vnet_handshake, sc); -#else callout_init(>sc_handshake_co, 0); -/* netbsd callout do silmilar function...*/ -#endif - sc->sc_peer_state = VIO_DP_STOPPED; -#if OPENBSD_BUSDMA - lc->lc_txq = ldc_queue_alloc(sc->sc_dmatag, VNET_TX_ENTRIES); - if (lc->lc_txq == NULL) { - printf(", can't allocate tx queue\n"); - return; - } + sc->sc_peer_state = VIO_DP_STOPPED; - lc->lc_rxq = ldc_queue_alloc(sc->sc_dmatag, VNET_RX_ENTRIES); - if (lc->lc_rxq == NULL) { - printf(", can't allocate rx queue\n"); - goto free_txqueue; - } -#else lc->lc_txq = ldc_queue_alloc(VNET_TX_ENTRIES); if (lc->lc_txq == NULL) { printf(", can't allocate tx queue\n"); @@ -347,7 +292,6 @@ FIXME openbsd printf(", can't allocate rx queue\n"); goto free_txqueue; } -#endif if (OF_getprop(ca->ca_node, "local-mac-address", sc->sc_macaddr, ETHER_ADDR_LEN) > 0) { @@ -360,63 +304,35 @@ FIXME openbsd /* * Each interface gets its own pool. */ -#if 0 -FIXME openbsd - pool_init(>sc_pool, 2048, 0, IPL_NET, 0, sc->sc_dv.dv_xname, NULL); -#else pool_init(>sc_pool, 2048, 0, 0, 0, sc->sc_dv.dv_xname, NULL, IPL_NET); -#endif ifp = >sc_ethercom.ec_if; ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; -#if 0 - ifp->if_link_state = LINK_STATE_DOWN; -#endif ifp->if_init = vnet_init; ifp->if_ioctl = vnet_ioctl; ifp->if_start = vnet_start; ifp->if_stop = vnet_stop; ifp->if_watchdog = vnet_watchdog; strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ); -#if 0 -FIXME openbsd - ifq_set_maxlen(>if_snd, 31); /* XXX */ -#else - IFQ_SET_MAXLEN(>if_snd, 31); /* XXX */ -#endif + IFQ_SET_MAXLEN(>if_snd, 31); /* XXX */ ifmedia_init(>sc_media, 0, vnet_media_change, vnet_media_status); ifmedia_add(>sc_media, IFM_ETHER | IFM_AUTO, 0, NULL); ifmedia_set(>sc_media, IFM_ETHER | IFM_AUTO); -#if 0 - int error = if_initialize(ifp); - if (error != 0) { - printf(", if_initialize() failed\n"); - return; - } - ether_ifattach(ifp, sc->sc_macaddr); -
CVS commit: src/sys/arch/sparc64/dev
Module Name:src Committed By: palle Date: Sat Mar 13 20:21:37 UTC 2021 Modified Files: src/sys/arch/sparc64/dev: vnet.c Log Message: sun4v: vnet - reception and transmission of eternet frames seems to work now (it is possible to ping 8.8.8.8 from inside a sun4v ldom). Still cleanup of debug code to be done. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc64/dev/vnet.c 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/sparc64/dev/vnet.c diff -u src/sys/arch/sparc64/dev/vnet.c:1.3 src/sys/arch/sparc64/dev/vnet.c:1.4 --- src/sys/arch/sparc64/dev/vnet.c:1.3 Thu Mar 11 19:34:11 2021 +++ src/sys/arch/sparc64/dev/vnet.c Sat Mar 13 20:21:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: vnet.c,v 1.3 2021/03/11 19:34:11 palle Exp $ */ +/* $NetBSD: vnet.c,v 1.4 2021/03/13 20:21:37 palle Exp $ */ /* $OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $ */ /* * Copyright (c) 2009, 2015 Mark Kettenis @@ -221,6 +221,7 @@ void vnet_rx_vio_ver_info(struct vnet_so void vnet_rx_vio_attr_info(struct vnet_softc *, struct vio_msg_tag *); void vnet_rx_vio_dring_reg(struct vnet_softc *, struct vio_msg_tag *); void vnet_rx_vio_rdx(struct vnet_softc *sc, struct vio_msg_tag *); +void vnet_rx_vio_mcast_info(struct vnet_softc *sc, struct vio_msg_tag *); void vnet_rx_vio_data(struct vnet_softc *sc, struct vio_msg *); void vnet_rx_vio_desc_data(struct vnet_softc *sc, struct vio_msg_tag *); void vnet_rx_vio_dring_data(struct vnet_softc *sc, struct vio_msg_tag *); @@ -655,9 +656,15 @@ vnet_rx_vio_ctrl(struct vnet_softc *sc, case VIO_RDX: vnet_rx_vio_rdx(sc, tag); break; + case VNET_MCAST_INFO: + vnet_rx_vio_mcast_info(sc, tag); + break; default: printf("%s: CTRL/0x%02x/0x%04x FIXME\n", __func__, tag->stype, tag->stype_env); +#if 0 + Debugger(); +#endif break; } } @@ -739,7 +746,9 @@ vnet_rx_vio_attr_info(struct vnet_softc DPRINTF(("CTRL/INFO/ATTR_INFO\n")); #endif sc->sc_xfer_mode = ai->xfer_mode; +#if 0 DPRINTF(("sc_xfer_mode %d\n", sc->sc_xfer_mode)); +#endif ai->tag.stype = VIO_SUBTYPE_ACK; ai->tag.sid = sc->sc_local_sid; @@ -893,6 +902,40 @@ FIXME openbsd } void +vnet_rx_vio_mcast_info(struct vnet_softc *sc, struct vio_msg_tag *tag) +{ +#if 0 + DPRINTF(("%s: entry\n", __func__)); +#endif + + switch(tag->stype) { + + case VIO_SUBTYPE_INFO: +#if 0 + DPRINTF(("CTRL/INFO/MCAST_INFO\n")); +#endif + break; + + case VIO_SUBTYPE_ACK: +#if 0 + DPRINTF(("CTRL/ACK/MCAST_INFO\n")); +#endif + break; + + case VIO_SUBTYPE_NACK: +#if 0 + DPRINTF(("CTRL/NACK/MCAST_INFO\n")); +#endif + break; + + default: + printf("%s: CTRL/0x%02x/0x%04x\n", + __func__, tag->stype, tag->stype_env); + break; + } +} + +void vnet_rx_vio_data(struct vnet_softc *sc, struct vio_msg *vm) { #if 0 @@ -1077,7 +1120,7 @@ FIXME openbsd switch(tag->stype) { case VIO_SUBTYPE_INFO: { -#if 0 +#if 0 DPRINTF(("%s: VIO_SUBTYPE_INFO\n", __func__)); #endif struct vnet_desc desc; @@ -1148,9 +1191,9 @@ FIXME openbsd m->m_len = m->m_pkthdr.len = desc.nbytes; #endif nbytes = roundup(desc.nbytes + VNET_ETHER_ALIGN, 8); -#if 1 - DPRINTF(("%s: nbytes %" PRId64 " desc.nbytes %" PRId32 "\n", - __func__, nbytes, desc.nbytes)); +#if 0 + DPRINTF(("%s: RX frame size %" PRId16 "\n", + __func__, (int)nbytes)); uint8_t buf[ETHER_MAX_LEN]; pmap_extract(pmap_kernel(), (vaddr_t)buf, ); err = hv_ldc_copy(lc->lc_id, LDC_COPY_IN, @@ -1161,11 +1204,12 @@ FIXME openbsd } for (int i = 0; i < desc.nbytes; i++) { if (i % 16 == 0) { - printf("\n"); + DPRINTF(("\n")); } - printf("%02x ", buf[i]); + DPRINTF(("%02x ", buf[i])); } - printf("\n"); + DPRINTF(("\n")); + DPRINTF(("\n")); #endif #if 1 pmap_extract(pmap_kernel(), (vaddr_t)m->m_data, ); @@ -1176,6 +1220,7 @@ FIXME openbsd goto skip; } m->m_data += VNET_ETHER_ALIGN; + m_set_rcvif(m, ifp); #if 0 FIXME openbsd @@ -1224,7 +1269,7 @@ FIXME openbd case VIO_SUBTYPE_ACK: { -#if 0 +#if 0 DPRINTF(("%s: VIO_SUBTYPE_ACK\n", __func__)); #endif struct ldc_map *map = sc->sc_lm; @@ -1399,6 +1444,12 @@ vnet_send_attr_info(struct vnet_softc *s ai.addr |= sc->sc_macaddr[i]; } ai.mtu = ETHER_MAX_LEN - ETHER_CRC_LEN; +#if 0 + DPRINTF(("%s: ai.addr %" PRIx64 "\n", + __func__, ai.addr)); + DPRINTF(("%s: ai.mtu %" PRId64 "\n", + __func__, ai.mtu)); +#endif vnet_sendmsg(sc, , sizeof(ai)); sc->sc_vio_state |= VIO_SND_ATTR_INFO; @@ -1407,7 +1458,7 @@ vnet_send_attr_info(struct vnet_softc *s void vnet_send_dring_reg(struct vnet_softc *sc) { -#if 1 +#if 0 DPRINTF(("%s: entry\n", __func__)); #endif @@ -1433,7 +1484,7 @@ vnet_send_dring_reg(struct vnet_softc *s void vio_send_rdx(struct vnet_softc *sc) { -#if 1 +#if 0
CVS commit: src/sys/arch/sparc64/dev
Module Name:src Committed By: palle Date: Thu Mar 11 19:34:11 UTC 2021 Modified Files: src/sys/arch/sparc64/dev: vnet.c Log Message: sun4v: vnet - reception of ethernet frames seems to work now (WIP and code is still full of debug code) To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/dev/vnet.c 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/sparc64/dev/vnet.c diff -u src/sys/arch/sparc64/dev/vnet.c:1.2 src/sys/arch/sparc64/dev/vnet.c:1.3 --- src/sys/arch/sparc64/dev/vnet.c:1.2 Thu Mar 4 20:59:39 2021 +++ src/sys/arch/sparc64/dev/vnet.c Thu Mar 11 19:34:11 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: vnet.c,v 1.2 2021/03/04 20:59:39 palle Exp $ */ +/* $NetBSD: vnet.c,v 1.3 2021/03/11 19:34:11 palle Exp $ */ /* $OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $ */ /* * Copyright (c) 2009, 2015 Mark Kettenis @@ -34,6 +34,8 @@ FIXME openbsd #if 0 FIXME openbsd #include +#else +#include #endif #include @@ -56,6 +58,9 @@ FIXME openbsd #include #include +#if 1 +#define VNET_DEBUG +#endif #ifdef VNET_DEBUG #define DPRINTF(x) printf x #else @@ -169,6 +174,8 @@ struct vnet_softc { #if 0 FIXME openbsd struct timeout sc_handshake_to; +#else + struct callout sc_handshake_co; #endif uint8_t sc_xfer_mode; @@ -230,7 +237,7 @@ void vnet_send_dring_data(struct vnet_so void vnet_start(struct ifnet *); void vnet_start_desc(struct ifnet *); -int vnet_ioctl (struct ifnet *, u_long, void *); +int vnet_ioctl(struct ifnet *, u_long, void *); void vnet_watchdog(struct ifnet *); int vnet_media_change(struct ifnet *); @@ -240,13 +247,14 @@ void vnet_link_state(struct vnet_softc * void vnet_setmulti(struct vnet_softc *, int); -void vnet_init(struct ifnet *); -void vnet_stop(struct ifnet *); +int vnet_init(struct ifnet *); +void vnet_stop(struct ifnet *, int); int vnet_match(device_t parent, cfdata_t match, void *aux) { struct cbus_attach_args *ca = aux; + if (strcmp(ca->ca_name, "network") == 0) return (1); @@ -308,6 +316,9 @@ FIXME openbsd #if 0 FIXME openbsd timeout_set(>sc_handshake_to, vnet_handshake, sc); +#else + callout_init(>sc_handshake_co, 0); +/* netbsd callout do silmilar function...*/ #endif sc->sc_peer_state = VIO_DP_STOPPED; @@ -358,9 +369,13 @@ FIXME openbsd ifp = >sc_ethercom.ec_if; ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; +#if 0 ifp->if_link_state = LINK_STATE_DOWN; +#endif + ifp->if_init = vnet_init; ifp->if_ioctl = vnet_ioctl; ifp->if_start = vnet_start; + ifp->if_stop = vnet_stop; ifp->if_watchdog = vnet_watchdog; strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ); #if 0 @@ -374,6 +389,7 @@ FIXME openbsd ifmedia_add(>sc_media, IFM_ETHER | IFM_AUTO, 0, NULL); ifmedia_set(>sc_media, IFM_ETHER | IFM_AUTO); +#if 0 int error = if_initialize(ifp); if (error != 0) { printf(", if_initialize() failed\n"); @@ -381,7 +397,10 @@ FIXME openbsd } ether_ifattach(ifp, sc->sc_macaddr); if_register(ifp); - +#else + if_attach(ifp); + ether_ifattach(ifp, sc->sc_macaddr); +#endif printf("\n"); return; free_txqueue: @@ -424,7 +443,9 @@ vnet_tx_intr(void *arg) int vnet_rx_intr(void *arg) { +#if 0 DPRINTF(("%s: entry\n", __func__)); +#endif struct vnet_softc *sc = arg; struct ldc_conn *lc = >sc_lc; @@ -433,34 +454,47 @@ vnet_rx_intr(void *arg) int err; err = hv_ldc_rx_get_state(lc->lc_id, _head, _tail, _state); - if (err == H_EINVAL) + if (err == H_EINVAL) { + printf("hv_ldc_rx_get_state failed\n"); return (0); + } if (err != H_EOK) { printf("hv_ldc_rx_get_state %d\n", err); return (0); } +#if 0 + DPRINTF(("%s: rx_state %" PRId64 " head %" PRId64 " tail %" PRId64 "\n", + __func__, rx_state, rx_head, rx_tail)); +#endif if (rx_state != lc->lc_rx_state) { +#if 0 + DPRINTF(("%s: rx_state %" PRId64 " != lc__rx_state %" PRId64 "\n", + __func__, rx_state, lc->lc_rx_state)); +#endif switch (rx_state) { case LDC_CHANNEL_DOWN: - DPRINTF(("%s: Rx link down\n", __func__)); lc->lc_tx_seqid = 0; lc->lc_state = 0; lc->lc_reset(lc); if (rx_head == rx_tail) break; /* Discard and ack pending I/O. */ - DPRINTF(("setting rx qhead to %lld\n", rx_tail)); + DPRINTF(("setting rx qhead to %" PRId64 "\n", rx_tail)); err = hv_ldc_rx_set_qhead(lc->lc_id, rx_tail); if (err == H_EOK) break; printf("%s: hv_ldc_rx_set_qhead %d\n", __func__, err); break; case LDC_CHANNEL_UP: +#if 0 DPRINTF(("%s: Rx link up\n", __func__)); +#endif #if 0 FIXME openbsd timeout_add_msec(>sc_handshake_to, 500); +#else + callout_reset(>sc_handshake_co, hz / 2, vnet_handshake, sc); #endif break; case LDC_CHANNEL_RESET: @@ -471,37 +505,73 @@ FIXME openbsd #if 0 FIXME openbsd
CVS commit: src/sys/arch/sparc64/dev
Module Name:src Committed By: palle Date: Thu Mar 4 20:59:39 UTC 2021 Modified Files: src/sys/arch/sparc64/dev: vnet.c Log Message: sun4v: add vnet driver from openbsd - compiles but probably does not work yet - still WIP (now with NetBSD cvs tag and compiles for 32-bit SUN4U To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc64/dev/vnet.c 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/sparc64/dev/vnet.c diff -u src/sys/arch/sparc64/dev/vnet.c:1.1 src/sys/arch/sparc64/dev/vnet.c:1.2 --- src/sys/arch/sparc64/dev/vnet.c:1.1 Thu Mar 4 20:17:00 2021 +++ src/sys/arch/sparc64/dev/vnet.c Thu Mar 4 20:59:39 2021 @@ -1,3 +1,4 @@ +/* $NetBSD: vnet.c,v 1.2 2021/03/04 20:59:39 palle Exp $ */ /* $OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $ */ /* * Copyright (c) 2009, 2015 Mark Kettenis @@ -265,7 +266,7 @@ vnet_attach(struct device *parent, struc sc->sc_tx_ino = ca->ca_tx_ino; sc->sc_rx_ino = ca->ca_rx_ino; - printf(": ivec 0x%lx, 0x%lx", sc->sc_tx_ino, sc->sc_rx_ino); + printf(": ivec 0x%" PRIx64 ", 0x%" PRIx64, sc->sc_tx_ino, sc->sc_rx_ino); /* * Un-configure queues before registering interrupt handlers, @@ -488,7 +489,7 @@ FIXME openbsd if (rx_head == rx_tail) return (0); - lp = (struct ldc_pkt *)(lc->lc_rxq->lq_va + rx_head); + lp = (struct ldc_pkt *)(uintptr_t)(lc->lc_rxq->lq_va + rx_head); switch (lp->type) { case LDC_CTRL: ldc_rx_ctrl(lc, lp);
CVS commit: src/sys/arch/sparc64
Module Name:src Committed By: palle Date: Thu Mar 4 20:17:00 UTC 2021 Modified Files: src/sys/arch/sparc64/conf: GENERIC files.sparc64 Added Files: src/sys/arch/sparc64/dev: vnet.c Log Message: sun4v: add vnet driver from openbsd - compiles but probably does not work yet - still WIP To generate a diff of this commit: cvs rdiff -u -r1.234 -r1.235 src/sys/arch/sparc64/conf/GENERIC cvs rdiff -u -r1.163 -r1.164 src/sys/arch/sparc64/conf/files.sparc64 cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc64/dev/vnet.c 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/sparc64/conf/GENERIC diff -u src/sys/arch/sparc64/conf/GENERIC:1.234 src/sys/arch/sparc64/conf/GENERIC:1.235 --- src/sys/arch/sparc64/conf/GENERIC:1.234 Sun Jan 31 08:07:25 2021 +++ src/sys/arch/sparc64/conf/GENERIC Thu Mar 4 20:17:00 2021 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.234 2021/01/31 08:07:25 martin Exp $ +# $NetBSD: GENERIC,v 1.235 2021/03/04 20:17:00 palle Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/sparc64/conf/std.sparc64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.234 $" +#ident "GENERIC-$Revision: 1.235 $" maxusers 64 @@ -248,6 +248,7 @@ iic* at jbusi2c? # Virtual devices for sun4v systems. vrtc0 at vbus? vdsk* at cbus? +vnet* at cbus? Serial port configuration Index: src/sys/arch/sparc64/conf/files.sparc64 diff -u src/sys/arch/sparc64/conf/files.sparc64:1.163 src/sys/arch/sparc64/conf/files.sparc64:1.164 --- src/sys/arch/sparc64/conf/files.sparc64:1.163 Wed Oct 21 13:31:52 2020 +++ src/sys/arch/sparc64/conf/files.sparc64 Thu Mar 4 20:17:00 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files.sparc64,v 1.163 2020/10/21 13:31:52 christos Exp $ +# $NetBSD: files.sparc64,v 1.164 2021/03/04 20:17:00 palle Exp $ # @(#)files.sparc64 8.1 (Berkeley) 7/19/93 # sparc64-specific configuration info @@ -332,3 +332,8 @@ file arch/sparc64/dev/ldc.c ldc device vdsk: ldc, scsi attach vdsk at cbus file arch/sparc64/dev/vdsk.c vdsk + +# Virtual network +device vnet: ldc +attach vnet at cbus +file arch/sparc64/dev/vnet.c vnet Added files: Index: src/sys/arch/sparc64/dev/vnet.c diff -u /dev/null src/sys/arch/sparc64/dev/vnet.c:1.1 --- /dev/null Thu Mar 4 20:17:00 2021 +++ src/sys/arch/sparc64/dev/vnet.c Thu Mar 4 20:17:00 2021 @@ -0,0 +1,1889 @@ +/* $OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $ */ +/* + * Copyright (c) 2009, 2015 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#if 0 +FIXME openbsd +#include "bpfilter.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if 0 +FIXME openbsd +#include +#endif + +#include +#include +#include + +#include +#include + +#include +#include + +#if NBPFILTER > 0 +#include +#endif + +#include + +#include +#include +#include + +#ifdef VNET_DEBUG +#define DPRINTF(x) printf x +#else +#define DPRINTF(x) +#endif + +#define VNET_TX_ENTRIES 32 +#define VNET_RX_ENTRIES 32 + +struct vnet_attr_info { + struct vio_msg_tag tag; + uint8_t xfer_mode; + uint8_t addr_type; + uint16_t ack_freq; + uint32_t _reserved1; + uint64_t addr; + uint64_t mtu; + uint64_t _reserved2[3]; +}; + +/* Address types. */ +#define VNET_ADDR_ETHERMAC 0x01 + +/* Sub-Type envelopes. */ +#define VNET_MCAST_INFO 0x0101 + +#define VNET_NUM_MCAST 7 + +struct vnet_mcast_info { + struct vio_msg_tag tag; + uint8_t set; + uint8_t count; + uint8_t mcast_addr[VNET_NUM_MCAST][ETHER_ADDR_LEN]; + uint32_t _reserved; +}; + +struct vnet_desc { + struct vio_dring_hdr hdr; + uint32_t nbytes; + uint32_t ncookies; + struct ldc_cookie cookie[2]; +}; + +struct vnet_desc_msg { + struct vio_msg_tag tag; + uint64_t seq_no; + uint64_t desc_handle; + uint32_t nbytes; + uint32_t ncookies; + struct ldc_cookie cookie[1]; +}; + +struct vnet_dring { + bus_dmamap_t vd_map; + bus_dma_segment_t vd_seg; + struct vnet_desc *vd_desc; + int vd_nentries; +}; + +struct vnet_dring *vnet_dring_alloc(bus_dma_tag_t, int); +void vnet_dring_free(bus_dma_tag_t, struct vnet_dring *); + +/* + * For now, we only support vNet 1.0. + */
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Thu Mar 4 20:00:51 UTC 2021 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update TODO - removed leftover OpenFirmware interface comment and add comment on idle handling To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.36 src/sys/arch/sparc64/doc/TODO:1.37 --- src/sys/arch/sparc64/doc/TODO:1.36 Sat Feb 27 18:29:38 2021 +++ src/sys/arch/sparc64/doc/TODO Thu Mar 4 20:00:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: TODO,v 1.36 2021/02/27 18:29:38 palle Exp $ */ +/* $NetBSD: TODO,v 1.37 2021/03/04 20:00:51 palle Exp $ */ Things to be done: @@ -18,9 +18,9 @@ sun4v: Installation is not possible, since no driver currently exists for the ldom network interfaces, but openbsd vnet and vsw drivers are possible to integrate and this work is progressing. - OpenBoot (properly trashed registers). T2000 ldom with 8 VCPU and 4GB: On this platform it crashes in /sbin/init doing an access() call where %o0 is corrupted (zero) +- idle handling - call hypervisor trap (openbsd code...??) - 64-bit kernel support - 32-bit kernel support - libkvm
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Sat Feb 27 18:29:38 UTC 2021 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update TODO file with OpenFirmware interface related improvements To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.35 src/sys/arch/sparc64/doc/TODO:1.36 --- src/sys/arch/sparc64/doc/TODO:1.35 Sat Feb 27 18:19:57 2021 +++ src/sys/arch/sparc64/doc/TODO Sat Feb 27 18:29:38 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: TODO,v 1.35 2021/02/27 18:19:57 palle Exp $ */ +/* $NetBSD: TODO,v 1.36 2021/02/27 18:29:38 palle Exp $ */ Things to be done: @@ -41,6 +41,19 @@ sun4v: - vdsk and ldc drivers: code maked with OPENBSD_BUSDMA - make the bus_dma stuff work properly - vbus.c: handle prom_getprop() memory leaks - locore.s: rft_user (sun4v specific manaul fill) - seems to work, but is it good enough (compared to openbsds rft_user? +- openfirmware interface +bounce handlng could need rework + - only #if __arch64__ independent for SUN4V, as OF for all ultrasparcs is +plain 32bit code too (and this #if only because the point below becomes +always false otherwise) + - only bounce if the address is >= 1UL<<32 + - perhaps apply the lock to OF calls in general, not only the bounce'd ones +(in other words: let's protect the OF context with the lock, not +only the bounce buffer contents). + - Are there any other bounce-worthy OF calls? If so, apply handling + to all of them now + - consider method used by Solaris/OpenSolaris/Illumos (look for PROM_32BIT_ADDRS in + the Illumos codebase) - platforms tested so far: -- qemu sun4v/niagara - reaches the point where the kernel needs to mount a root fs -- T2000 - mmu fault somewhere
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Sat Feb 27 18:19:57 UTC 2021 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update TODO file with status on sun4v - kernel and userland runs without crashing now - next up is network interfaces To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.34 src/sys/arch/sparc64/doc/TODO:1.35 --- src/sys/arch/sparc64/doc/TODO:1.34 Mon Feb 22 10:30:57 2021 +++ src/sys/arch/sparc64/doc/TODO Sat Feb 27 18:19:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: TODO,v 1.34 2021/02/22 10:30:57 palle Exp $ */ +/* $NetBSD: TODO,v 1.35 2021/02/27 18:19:57 palle Exp $ */ Things to be done: @@ -14,8 +14,10 @@ sun4v: - current status T5 ldom with 2 VCPU and 4GB: The kernel boots and starts userland when booting miniroot.fs. - The sysinst tool starts properly and requests terminal type. - Upon entering characters on the console, a crash occurs inside + The sysinst tool starts properly and is functional. + Installation is not possible, since no driver currently exists + for the ldom network interfaces, but openbsd vnet and vsw drivers are + possible to integrate and this work is progressing. OpenBoot (properly trashed registers). T2000 ldom with 8 VCPU and 4GB: On this platform it crashes in /sbin/init doing an access() call where %o0 is corrupted (zero)
CVS commit: src/sys/arch/sparc/sparc
Module Name:src Committed By: palle Date: Sat Feb 27 18:10:46 UTC 2021 Modified Files: src/sys/arch/sparc/sparc: openfirm.c Log Message: sun4v: add 32/64 bit workaround for the OF_read() call, similar to the one introduced in revision 1.21 To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sparc/sparc/openfirm.c 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/sparc/sparc/openfirm.c diff -u src/sys/arch/sparc/sparc/openfirm.c:1.23 src/sys/arch/sparc/sparc/openfirm.c:1.24 --- src/sys/arch/sparc/sparc/openfirm.c:1.23 Sun Mar 26 12:38:24 2017 +++ src/sys/arch/sparc/sparc/openfirm.c Sat Feb 27 18:10:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: openfirm.c,v 1.23 2017/03/26 12:38:24 martin Exp $ */ +/* $NetBSD: openfirm.c,v 1.24 2021/02/27 18:10:46 palle Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.23 2017/03/26 12:38:24 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.24 2021/02/27 18:10:46 palle Exp $"); #include #include @@ -503,6 +503,15 @@ OF_read(int handle, void *addr, int len) } args; int l, act = 0; +#ifdef SUN4V +#if __arch64__ + void *oaddr = addr; + __cpu_simple_lock(_lock); + if (len > OFBOUNCE_MAXSIZE) + panic("OF_read(len = %d) exceedes bounce buffer\n", len); + addr = ofbounce; +#endif +#endif args.name = ADR2CELL("read"); args.nargs = 3; args.nreturns = 1; @@ -511,18 +520,31 @@ OF_read(int handle, void *addr, int len) for (; len > 0; len -= l) { l = MIN(NBPG, len); args.len = l; - if (openfirmware() == -1) - return -1; + if (openfirmware() == -1) { + act = -1; + goto OF_read_exit; + } if (args.actual > 0) { act += args.actual; } if (args.actual < l) { if (act) -return act; - else -return args.actual; +goto OF_read_exit; + else { +act = args.actual; +goto OF_read_exit; + } } } +OF_read_exit: +#ifdef SUN4V +#if __arch64__ + if (act > 0) { + memcpy(oaddr, addr, act); + } + __cpu_simple_unlock(_lock); +#endif +#endif return act; }
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Mon Feb 22 10:30:57 UTC 2021 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update current status of sun4v To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.33 src/sys/arch/sparc64/doc/TODO:1.34 --- src/sys/arch/sparc64/doc/TODO:1.33 Sun Feb 14 20:30:31 2021 +++ src/sys/arch/sparc64/doc/TODO Mon Feb 22 10:30:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: TODO,v 1.33 2021/02/14 20:30:31 palle Exp $ */ +/* $NetBSD: TODO,v 1.34 2021/02/22 10:30:57 palle Exp $ */ Things to be done: @@ -11,23 +11,14 @@ sun4u: - GENERIC.UP kernel hangs on v445 (missing interrupt?) sun4v: - - current status (verified on T5 ldom with 2 VCPU and 4GB): - The kernel boots and starts userland. - During the execution of the sysinst process, a sub-process crashes. - The crash happens when a call to sysctl from /bin/sh causes a mmu trap. - Part of the TRAP_SETUP() call in sun4v_datatrap issues a 'save' instruction. - Since %cansave is 0 (%canrestore is 6 and %otherwin is 0) a SPILL trap is generated. - The current code ends up in the pcbspill codepath (which is based on code from openbsd). - This code assumes that it is the register window in the OTHERWIN window that must be spilled - to the pcb. - Since %otherwin in this scenario actually is zero, we end up putting incorrect register - window values to the pcb. - So - this code should not save data to the pcb when %otherwin is 0 - it should spill the - values to the stack of the user process. Special care should be taken here, since we - may end up with a mmu fault again if the stack address is not present in the mmu, so - perhaps spilling to the physical address of the stack will work. - Time will show if this is correct... - Status on T2000 ldom with 8 VCPU and 4GB is that is crashes in /sbin/init doing an access() call where %o0 is corrupted (zero) + - current status + T5 ldom with 2 VCPU and 4GB: + The kernel boots and starts userland when booting miniroot.fs. + The sysinst tool starts properly and requests terminal type. + Upon entering characters on the console, a crash occurs inside + OpenBoot (properly trashed registers). + T2000 ldom with 8 VCPU and 4GB: + On this platform it crashes in /sbin/init doing an access() call where %o0 is corrupted (zero) - 64-bit kernel support - 32-bit kernel support - libkvm
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Mon Feb 22 09:56:42 UTC 2021 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: handle spill normal user traps properly when current trap level is 1 - registers are spilled to the PA of the stack to avoid further mmu-related traps, since sun4v only has 2 trap levels To generate a diff of this commit: cvs rdiff -u -r1.424 -r1.425 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.424 src/sys/arch/sparc64/sparc64/locore.s:1.425 --- src/sys/arch/sparc64/sparc64/locore.s:1.424 Sun Dec 20 11:58:58 2020 +++ src/sys/arch/sparc64/sparc64/locore.s Mon Feb 22 09:56:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.424 2020/12/20 11:58:58 palle Exp $ */ +/* $NetBSD: locore.s,v 1.425 2021/02/22 09:56:42 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -228,7 +228,7 @@ .endm .macro sun4v_tl1_uspill_normal - ba,a,pt %xcc, pcbspill_normals + ba,a,pt %xcc, spill_normal_to_user_stack nop .align 128 .endm @@ -3485,6 +3485,58 @@ pcbspill_fail: Debugger() NOTREACHED +spill_normal_to_user_stack: + mov %sp, %g6 ! calculate virtual address of destination stack + add %g6, BIAS, %g6 + + mov CTX_SECONDARY, %g2! Is this context ok or should it be CTX_PRIMARY? XXX + GET_MMU_CONTEXTID %g3, %g2, %g1 + sllx %g3, 3, %g3 ! Make it into an offset into ctxbusy (see below) + + GET_CTXBUSY %g1 + ldx [%g1 + %g3], %g1! Fetch pmap for current context id + + ! Start of code to extract PA + srlx %g6, STSHIFT, %g7 + and %g7, STMASK, %g7 + sll %g7, 3, %g7 ! byte offset into ctxbusy + add %g7, %g1, %g1 + ldxa [%g1] ASI_PHYS_CACHED, %g1 ! Load pointer to directory + srlx %g6, PDSHIFT, %g7 ! Do page directory + and %g7, PDMASK, %g7 + sll %g7, 3, %g7 + brz,pn %g1, spill_normal_to_user_stack_fail + add %g7, %g1, %g1 + + ldxa [%g1] ASI_PHYS_CACHED, %g1 + srlx %g6, PTSHIFT, %g7 ! Convert to ptab offset + and %g7, PTMASK, %g7 + brz %g1, spill_normal_to_user_stack_fail + sll %g7, 3, %g7 + + add %g1, %g7, %g7 + ldxa [%g7] ASI_PHYS_CACHED, %g7 ! This one is not + brgez %g7, spill_normal_to_user_stack_fail + srlx %g7, PGSHIFT, %g7 ! Isolate PA part + + sll %g6, 32-PGSHIFT, %g6 ! And offset + sllx %g7, PGSHIFT+8, %g7 ! There are 8 bits to the left of the PA in the TTE + srl %g6, 32-PGSHIFT, %g6 + srax %g7, 8, %g7 + or %g7, %g6, %g6 ! Then combine them to form PA + ! End of code to extract PA + + wr %g0, ASI_PHYS_CACHED, %asi ! Use ASI_PHYS_CACHED to prevent possible page faults + SPILL stxa, %g6, 8, %asi ! Store the locals and ins + saved + + retry + NOTREACHED + +spill_normal_to_user_stack_fail: + sir + nop + /* * End of traps for sun4v. */
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Sun Feb 14 20:30:31 UTC 2021 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update TODO with status of verified systems(T2000, T5 and qemu) To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.32 src/sys/arch/sparc64/doc/TODO:1.33 --- src/sys/arch/sparc64/doc/TODO:1.32 Sun Jan 31 19:08:05 2021 +++ src/sys/arch/sparc64/doc/TODO Sun Feb 14 20:30:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: TODO,v 1.32 2021/01/31 19:08:05 palle Exp $ */ +/* $NetBSD: TODO,v 1.33 2021/02/14 20:30:31 palle Exp $ */ Things to be done: @@ -11,7 +11,7 @@ sun4u: - GENERIC.UP kernel hangs on v445 (missing interrupt?) sun4v: - - current status: + - current status (verified on T5 ldom with 2 VCPU and 4GB): The kernel boots and starts userland. During the execution of the sysinst process, a sub-process crashes. The crash happens when a call to sysctl from /bin/sh causes a mmu trap. @@ -27,6 +27,7 @@ sun4v: may end up with a mmu fault again if the stack address is not present in the mmu, so perhaps spilling to the physical address of the stack will work. Time will show if this is correct... + Status on T2000 ldom with 8 VCPU and 4GB is that is crashes in /sbin/init doing an access() call where %o0 is corrupted (zero) - 64-bit kernel support - 32-bit kernel support - libkvm @@ -48,6 +49,6 @@ sun4v: - vbus.c: handle prom_getprop() memory leaks - locore.s: rft_user (sun4v specific manaul fill) - seems to work, but is it good enough (compared to openbsds rft_user? - platforms tested so far: - -- qemu sun4v/niagara - crash in init process relaed to fork (stack?) + -- qemu sun4v/niagara - reaches the point where the kernel needs to mount a root fs -- T2000 - mmu fault somewhere -- T5 - stickcmpr is not properly initialized ???
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Sun Jan 31 19:08:05 UTC 2021 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update TODO with analysis of sun4v crashes To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.31 src/sys/arch/sparc64/doc/TODO:1.32 --- src/sys/arch/sparc64/doc/TODO:1.31 Mon Jan 4 15:13:50 2021 +++ src/sys/arch/sparc64/doc/TODO Sun Jan 31 19:08:05 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: TODO,v 1.31 2021/01/04 15:13:50 skrll Exp $ */ +/* $NetBSD: TODO,v 1.32 2021/01/31 19:08:05 palle Exp $ */ Things to be done: @@ -11,9 +11,22 @@ sun4u: - GENERIC.UP kernel hangs on v445 (missing interrupt?) sun4v: - - current status: The kernel boots and starts the init process. - The following processes seem to crash on and on so more debugging to be done... - + - current status: + The kernel boots and starts userland. + During the execution of the sysinst process, a sub-process crashes. + The crash happens when a call to sysctl from /bin/sh causes a mmu trap. + Part of the TRAP_SETUP() call in sun4v_datatrap issues a 'save' instruction. + Since %cansave is 0 (%canrestore is 6 and %otherwin is 0) a SPILL trap is generated. + The current code ends up in the pcbspill codepath (which is based on code from openbsd). + This code assumes that it is the register window in the OTHERWIN window that must be spilled + to the pcb. + Since %otherwin in this scenario actually is zero, we end up putting incorrect register + window values to the pcb. + So - this code should not save data to the pcb when %otherwin is 0 - it should spill the + values to the stack of the user process. Special care should be taken here, since we + may end up with a mmu fault again if the stack address is not present in the mmu, so + perhaps spilling to the physical address of the stack will work. + Time will show if this is correct... - 64-bit kernel support - 32-bit kernel support - libkvm
CVS commit: src/sys/arch/sparc64/dev
Module Name:src Committed By: palle Date: Wed Jan 6 20:04:30 UTC 2021 Modified Files: src/sys/arch/sparc64/dev: psycho.c Log Message: psycho: explicit allocation of memory using kmem(9) instead of using the buffer indirectly allocted in the prom_getprop() function (which is still using malloc(9) for memory allocation To generate a diff of this commit: cvs rdiff -u -r1.129 -r1.130 src/sys/arch/sparc64/dev/psycho.c 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/sparc64/dev/psycho.c diff -u src/sys/arch/sparc64/dev/psycho.c:1.129 src/sys/arch/sparc64/dev/psycho.c:1.130 --- src/sys/arch/sparc64/dev/psycho.c:1.129 Mon Jan 4 14:48:51 2021 +++ src/sys/arch/sparc64/dev/psycho.c Wed Jan 6 20:04:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: psycho.c,v 1.129 2021/01/04 14:48:51 thorpej Exp $ */ +/* $NetBSD: psycho.c,v 1.130 2021/01/06 20:04:30 palle Exp $ */ /* * Copyright (c) 1999, 2000 Matthew R. Green @@ -55,7 +55,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.129 2021/01/04 14:48:51 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.130 2021/01/06 20:04:30 palle Exp $"); #include "opt_ddb.h" @@ -769,7 +769,7 @@ psycho_alloc_chipset(struct psycho_pbm * static struct extent * psycho_alloc_extent(struct psycho_pbm *pp, int node, int ss, const char *name) { - struct psycho_registers *pa = NULL; + struct psycho_registers *pa = kmem_zalloc(sizeof *pa, KM_SLEEP); struct psycho_ranges *pr; struct extent *ex; bus_addr_t baddr, addr;
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Sun Dec 20 11:58:58 UTC 2020 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: add comment in sun4v_tl1_ptbl_miss code path - no functional change To generate a diff of this commit: cvs rdiff -u -r1.423 -r1.424 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.423 src/sys/arch/sparc64/sparc64/locore.s:1.424 --- src/sys/arch/sparc64/sparc64/locore.s:1.423 Wed Jan 8 20:59:20 2020 +++ src/sys/arch/sparc64/sparc64/locore.s Sun Dec 20 11:58:58 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.423 2020/01/08 20:59:20 skrll Exp $ */ +/* $NetBSD: locore.s,v 1.424 2020/12/20 11:58:58 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -3343,6 +3343,8 @@ sun4v_tl1_ptbl_miss: bgeu,pt %xcc, 1f nop + /* We had a miss inside rtf_user_fault_start/rtf_user_fault_end block (FILL) + /* Fixup %cwp. */ rdpr %cwp, %g1 inc %g1
CVS commit: src/sys/kern
Module Name:src Committed By: palle Date: Thu Mar 14 19:51:50 UTC 2019 Modified Files: src/sys/kern: kern_scdebug.c Log Message: syscall debug - fix build when SYSCALL_DEBUG option is present in kernel config file To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/kern/kern_scdebug.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_scdebug.c diff -u src/sys/kern/kern_scdebug.c:1.1 src/sys/kern/kern_scdebug.c:1.2 --- src/sys/kern/kern_scdebug.c:1.1 Fri Sep 14 01:55:19 2018 +++ src/sys/kern/kern_scdebug.c Thu Mar 14 19:51:49 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_scdebug.c,v 1.1 2018/09/14 01:55:19 mrg Exp $ */ +/* $NetBSD: kern_scdebug.c,v 1.2 2019/03/14 19:51:49 palle Exp $ */ /* * Copyright (c) 2015 Matthew R. Green @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_scdebug.c,v 1.1 2018/09/14 01:55:19 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_scdebug.c,v 1.2 2019/03/14 19:51:49 palle Exp $"); #ifdef _KERNEL_OPT #include "opt_syscall_debug.h" @@ -112,9 +112,9 @@ KERNHIST_DEFINE(scdebughist); #define SCDEBUG_KERNHIST_CALLED(a) KERNHIST_CALLED(a) #define SCDEBUG_KERNHIST_LOG(a,b,c,d,e,f) KERNHIST_LOG(a,b,c,d,e,f) #else -#define SCDEBUG_KERNHIST_FUNC(a) /* nothing */ -#define SCDEBUG_KERNHIST_CALLED(a) /* nothing */ -#define SCDEBUG_KERNHIST_LOG(a,b,c,d,e,f) /* nothing */ +#define SCDEBUG_KERNHIST_FUNC(a) {} /* nothing */ +#define SCDEBUG_KERNHIST_CALLED(a) {} /* nothing */ +#define SCDEBUG_KERNHIST_LOG(a,b,c,d,e,f) {} /* nothing */ /* The non-kernhist support version can elide all this code easily. */ #undef SCDEBUG_KERNHIST #define SCDEBUG_KERNHIST 0
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Thu Feb 14 20:09:40 UTC 2019 Modified Files: src/sys/arch/sparc64/sparc64: trap.c Log Message: sun4v: add debug printout for ALIGN trap To generate a diff of this commit: cvs rdiff -u -r1.189 -r1.190 src/sys/arch/sparc64/sparc64/trap.c 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/sparc64/sparc64/trap.c diff -u src/sys/arch/sparc64/sparc64/trap.c:1.189 src/sys/arch/sparc64/sparc64/trap.c:1.190 --- src/sys/arch/sparc64/sparc64/trap.c:1.189 Wed Dec 19 13:57:50 2018 +++ src/sys/arch/sparc64/sparc64/trap.c Thu Feb 14 20:09:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.189 2018/12/19 13:57:50 maxv Exp $ */ +/* $NetBSD: trap.c,v 1.190 2019/02/14 20:09:40 palle Exp $ */ /* * Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved. @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.189 2018/12/19 13:57:50 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.190 2019/02/14 20:09:40 palle Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -717,6 +717,10 @@ dopanic: #ifdef DEBUG if (!CPU_ISSUN4V) { isfsr = ldxa(SFSR, ASI_IMMU); + } else { + paddr_t mmu_fsa_ifa = cpus->ci_mmufsa + + offsetof(struct mmufsa, ifa); + isfsr = ldxa(mmu_fsa_ifa, ASI_PHYS_CACHED); } #endif /* @@ -731,10 +735,34 @@ dopanic: #ifdef DEBUG #define fmt64(x) (u_int)((x)>>32), (u_int)((x)) - printf("Alignment error: pid=%d.%d comm=%s dsfsr=%08x:%08x " - "dsfar=%x:%x isfsr=%08x:%08x pc=%lx\n", - l->l_proc->p_pid, l->l_lid, l->l_proc->p_comm, fmt64(dsfsr), fmt64(dsfar), - fmt64(isfsr), pc); + if (!CPU_ISSUN4V) { + printf("Alignment error: pid=%d.%d comm=%s dsfsr=%08x:%08x " + "dsfar=%x:%x isfsr=%08x:%08x pc=%lx\n", + l->l_proc->p_pid, l->l_lid, l->l_proc->p_comm, fmt64(dsfsr), fmt64(dsfar), + fmt64(isfsr), pc); + } else { + + printf("Alignment error: pid=%d.%d comm=%s pc=%lx\n", + l->l_proc->p_pid, l->l_lid, l->l_proc->p_comm, pc); + paddr_t mmufsa_ift_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, ift); + paddr_t mmufsa_ifa_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, ifa); + paddr_t mmufsa_ifc_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, ifc); + paddr_t mmufsa_dft_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, dft); + paddr_t mmufsa_dfa_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, dfa); + paddr_t mmufsa_dfc_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, dfc); + int64_t ift = ldxa(mmufsa_ift_addr, ASI_PHYS_CACHED); + printf("ift = %016lx\n", ift); + int64_t ifa = ldxa(mmufsa_ifa_addr, ASI_PHYS_CACHED); + printf("ifa = %016lx\n", ifa); + int64_t ifc = ldxa(mmufsa_ifc_addr, ASI_PHYS_CACHED); + printf("ifc = %016lx\n", ifc); + int64_t dft = ldxa(mmufsa_dft_addr, ASI_PHYS_CACHED); + printf("dft = %016lx\n", dft); + int64_t dfa = ldxa(mmufsa_dfa_addr, ASI_PHYS_CACHED); + printf("dfa = %016lx\n", dfa); + int64_t dfc = ldxa(mmufsa_dfc_addr, ASI_PHYS_CACHED); + printf("dfc = %016lx\n", dfc); + } #endif #if defined(DDB) && defined(DEBUG)
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Fri Feb 8 20:34:23 UTC 2019 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: Improve comment for next_stick_init() - no functional changes To generate a diff of this commit: cvs rdiff -u -r1.418 -r1.419 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.418 src/sys/arch/sparc64/sparc64/locore.s:1.419 --- src/sys/arch/sparc64/sparc64/locore.s:1.418 Fri Feb 8 20:14:51 2019 +++ src/sys/arch/sparc64/sparc64/locore.s Fri Feb 8 20:34:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.418 2019/02/08 20:14:51 palle Exp $ */ +/* $NetBSD: locore.s,v 1.419 2019/02/08 20:34:23 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -7513,6 +7513,9 @@ Lstick_ovflw: * Sets the %stick_cmpr register to the value retrieved from %stick so * next_stick() does not spend too much time in the function when called * for the first time. + * This has been observed on (at least) a SPARC-T5 (sun4v) system where + * the %stick_cmpr ends up being less than the %stick value and then + * the stickitr() interrupt is never triggered. */ ENTRY(next_stick_init) rd STICK, %o0
CVS commit: src/sys/arch/sparc64
Module Name:src Committed By: palle Date: Fri Feb 8 20:14:51 UTC 2019 Modified Files: src/sys/arch/sparc64/include: cpu.h src/sys/arch/sparc64/sparc64: clock.c locore.s Log Message: sun4v: initialize %stickcmpr properly when establishing interrupt - fixes issue seen on newer sun4v/SPARC-T5 system where the interrupt never fires. To generate a diff of this commit: cvs rdiff -u -r1.125 -r1.126 src/sys/arch/sparc64/include/cpu.h cvs rdiff -u -r1.120 -r1.121 src/sys/arch/sparc64/sparc64/clock.c cvs rdiff -u -r1.417 -r1.418 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/include/cpu.h diff -u src/sys/arch/sparc64/include/cpu.h:1.125 src/sys/arch/sparc64/include/cpu.h:1.126 --- src/sys/arch/sparc64/include/cpu.h:1.125 Wed Aug 22 01:05:23 2018 +++ src/sys/arch/sparc64/include/cpu.h Fri Feb 8 20:14:50 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.125 2018/08/22 01:05:23 msaitoh Exp $ */ +/* $NetBSD: cpu.h,v 1.126 2019/02/08 20:14:50 palle Exp $ */ /* * Copyright (c) 1992, 1993 @@ -434,6 +434,7 @@ void switchtoctx_us(int); void switchtoctx_usiii(int); void next_tick(long); void next_stick(long); +void next_stick_init(void); /* trap.c */ void cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t); int rwindow_save(struct lwp *); Index: src/sys/arch/sparc64/sparc64/clock.c diff -u src/sys/arch/sparc64/sparc64/clock.c:1.120 src/sys/arch/sparc64/sparc64/clock.c:1.121 --- src/sys/arch/sparc64/sparc64/clock.c:1.120 Thu Jul 7 06:55:38 2016 +++ src/sys/arch/sparc64/sparc64/clock.c Fri Feb 8 20:14:51 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.120 2016/07/07 06:55:38 msaitoh Exp $ */ +/* $NetBSD: clock.c,v 1.121 2019/02/08 20:14:51 palle Exp $ */ /* * Copyright (c) 1992, 1993 @@ -55,7 +55,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.120 2016/07/07 06:55:38 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.121 2019/02/08 20:14:51 palle Exp $"); #include "opt_multiprocessor.h" @@ -406,6 +406,7 @@ stickintr_establish(int pil, int (*fun)( ci->ci_tick_increment = ci->ci_system_clockrate[0] / hz; s = intr_disable(); + next_stick_init(); next_stick(ci->ci_tick_increment); intr_restore(s); } Index: src/sys/arch/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.417 src/sys/arch/sparc64/sparc64/locore.s:1.418 --- src/sys/arch/sparc64/sparc64/locore.s:1.417 Fri Feb 8 19:45:24 2019 +++ src/sys/arch/sparc64/sparc64/locore.s Fri Feb 8 20:14:51 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.417 2019/02/08 19:45:24 palle Exp $ */ +/* $NetBSD: locore.s,v 1.418 2019/02/08 20:14:51 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -7507,6 +7507,21 @@ Lstick_ovflw: retl wr %o2, STICK_CMPR +/* + * next_stick_init() + * + * Sets the %stick_cmpr register to the value retrieved from %stick so + * next_stick() does not spend too much time in the function when called + * for the first time. + */ +ENTRY(next_stick_init) + rd STICK, %o0 + mov 1, %o1 ! Mask off high bits of the register + sllx %o1, 63, %o1 + andn %o0, %o1, %o0 + retl + wr %o0, STICK_CMPR + ENTRY(setjmp) save %sp, -CC64FSZ, %sp ! Need a frame to return to. flushw
CVS commit: src/sys/arch/sparc64/include
Module Name:src Committed By: palle Date: Fri Feb 8 20:09:24 UTC 2019 Modified Files: src/sys/arch/sparc64/include: psl.h Log Message: Introduce getstickcmpr() function To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/sys/arch/sparc64/include/psl.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/sparc64/include/psl.h diff -u src/sys/arch/sparc64/include/psl.h:1.57 src/sys/arch/sparc64/include/psl.h:1.58 --- src/sys/arch/sparc64/include/psl.h:1.57 Wed May 18 07:59:30 2016 +++ src/sys/arch/sparc64/include/psl.h Fri Feb 8 20:09:24 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: psl.h,v 1.57 2016/05/18 07:59:30 nakayama Exp $ */ +/* $NetBSD: psl.h,v 1.58 2019/02/08 20:09:24 palle Exp $ */ /* * Copyright (c) 1992, 1993 @@ -383,6 +383,9 @@ SPARC64_RDCONST64_DEF(rdpr, ver, %ver) SPARC64_RDASR64_DEF(stick, STICK) /* getstick() */ SPARC64_WRASR64_DEF(stick, STICK) /* setstick() */ +/* System Tick Compare Register (ASR 25) */ +SPARC64_RDASR64_DEF(stickcmpr, STICK_CMPR) /* getstickcmpr() */ + /* Some simple macros to check the cpu type. */ #define GETVER_CPU_MASK() ((getver() & VER_MASK) >> VER_MASK_SHIFT) #define GETVER_CPU_IMPL() ((getver() & VER_IMPL) >> VER_IMPL_SHIFT)
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Fri Feb 8 19:55:40 UTC 2019 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update the TODO file noting (at least) some progess with sun4v To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.28 src/sys/arch/sparc64/doc/TODO:1.29 --- src/sys/arch/sparc64/doc/TODO:1.28 Mon Dec 17 20:13:46 2018 +++ src/sys/arch/sparc64/doc/TODO Fri Feb 8 19:55:40 2019 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.28 2018/12/17 20:13:46 palle Exp $ */ + /* $NetBSD: TODO,v 1.29 2019/02/08 19:55:40 palle Exp $ */ Things to be done: @@ -11,14 +11,9 @@ sun4u: - GENERIC.UP kernel hangs on v445 (missing interrupt?) sun4v: - - current status: The kernel boots and starts the init process (pid 1) - which spawns /sbin/sh (pid 2). This is forked as a new /sbin/sh (pid 3) - which crashes, probably due to MMU DPROT issues. - Looks like the user process tries to write to the stack as part of a save - instruction since cansave is zero. This causes a DMMU PROT trap (0x6c) which - calls sun4v_tl0_dtsb_prot which calls sun4v_datatrap which calls TRAP_SETUP(). - This macro has code that does a save instruction, again to the user stack, - which again causes a MMU DPROT trap... + - current status: The kernel boots and starts the init process. + The following processes seem to crash on and on so more debugging to be done... + - 64-bit kernel support - 32-bit kernel support - libkvm
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Fri Feb 8 19:45:24 UTC 2019 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: introduce macros for handling spill traps from userlevevel @ traplevel 1 (from OpenBSD) - spill traps at level 1 from userspace now works better To generate a diff of this commit: cvs rdiff -u -r1.416 -r1.417 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.416 src/sys/arch/sparc64/sparc64/locore.s:1.417 --- src/sys/arch/sparc64/sparc64/locore.s:1.416 Fri Feb 8 19:26:25 2019 +++ src/sys/arch/sparc64/sparc64/locore.s Fri Feb 8 19:45:24 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.416 2019/02/08 19:26:25 palle Exp $ */ +/* $NetBSD: locore.s,v 1.417 2019/02/08 19:45:24 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -227,6 +227,18 @@ LDPTR [\reg + %lo(CPUINFO_VA + CI_TSB_DMMU)], \reg .endm + .macro sun4v_tl1_uspill_normal + ba,a,pt %xcc, pcbspill_normals + nop + .align 128 + .endm + + .macro sun4v_tl1_uspill_other + ba,a,pt %xcc, pcbspill_others + nop + .align 128 + .endm + #endif #if 1 @@ -1155,17 +1167,17 @@ _C_LABEL(trapbase_sun4v): sun4v_trap_entry 56 ! 0x034-0x06b VTRAP(T_FDMMU_PROT, sun4v_tl1_dtsb_prot) ! 0x06c sun4v_trap_entry 19 ! 0x06d-0x07f - SPILL64(uspill8_sun4vt1,ASI_AIUS) ! 0x080 spill_0_normal -- save user windows - SPILL32(uspill4_sun4vt1,ASI_AIUS) ! 0x084 spill_1_normal - SPILLBOTH(uspill8_sun4vt1,uspill4_sun4vt1,ASI_AIUS) ! 0x088 spill_2_normal + sun4v_tl1_uspill_normal ! 0x080 spill_0_normal -- save user windows + sun4v_tl1_uspill_normal ! 0x084 spill_1_normal + sun4v_tl1_uspill_normal ! 0x088 spill_2_normal sun4v_trap_entry_spill_fill_fail 1 ! 0x08c spill_3_normal SPILL64(kspill8_sun4vt1,ASI_N)! 0x090 spill_4_normal -- save supervisor windows SPILL32(kspill4_sun4vt1,ASI_N)! 0x094 spill_5_normal SPILLBOTH(kspill8_sun4vt1,kspill4_sun4vt1,ASI_N) ! 0x098 spill_6_normal sun4v_trap_entry_spill_fill_fail 1 ! 0x09c spill_7_normal - SPILL64(uspillk8_sun4vt1,ASI_AIUS) ! 0x0a0 spill_0_other -- save user windows in nucleus mode - SPILL32(uspillk4_sun4vt1,ASI_AIUS) ! 0x0a4 spill_1_other - SPILLBOTH(uspillk8_sun4vt1,uspillk4_sun4vt1,ASI_AIUS) ! 0x0a8 spill_2_other + sun4v_tl1_uspill_other ! 0x0a0 spill_0_other -- save user windows in nucleus mode + sun4v_tl1_uspill_other ! 0x0a4 spill_1_other + sun4v_tl1_uspill_other ! 0x0a8 spill_2_other sun4v_trap_entry_spill_fill_fail 1 ! 0x0ac spill_3_other sun4v_trap_entry_spill_fill_fail 1 ! 0x0b0 spill_4_other sun4v_trap_entry_spill_fill_fail 1 ! 0x0b4 spill_5_other
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Fri Feb 8 19:26:25 UTC 2019 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: add comment documenting the contents of the %g2 register - no functional changes To generate a diff of this commit: cvs rdiff -u -r1.415 -r1.416 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.415 src/sys/arch/sparc64/sparc64/locore.s:1.416 --- src/sys/arch/sparc64/sparc64/locore.s:1.415 Sun Nov 4 20:02:07 2018 +++ src/sys/arch/sparc64/sparc64/locore.s Fri Feb 8 19:26:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.415 2018/11/04 20:02:07 palle Exp $ */ +/* $NetBSD: locore.s,v 1.416 2019/02/08 19:26:25 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -3034,7 +3034,7 @@ sun4v_tl0_dtsb_prot: # btst SUN4V_TLB_REAL_W|SUN4V_TLB_W, %g4 ! Is it a ref fault? mov 1, %g2 - sllx %g2, 61, %g2 + sllx %g2, 61, %g2 ! %g2 is now SUN4V_TLB_REAL_W or %g2, SUN4V_TLB_W, %g2 btst %g2, %g4 bz,pn %xcc, sun4v_datatrap ! No -- really fault @@ -3263,7 +3263,7 @@ sun4v_tl1_dtsb_prot: # btst SUN4V_TLB_REAL_W|SUN4V_TLB_W, %g4 ! Is it a ref fault? mov 1, %g2 - sllx %g2, 61, %g2 + sllx %g2, 61, %g2 ! %g2 is now SUN4V_TLB_REAL_W or %g2, SUN4V_TLB_W, %g2 btst %g2, %g4 bz,pn %xcc, sun4v_tl1_ptbl_miss ! No -- really fault
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Mon Dec 17 20:13:46 UTC 2018 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: note what causes the kernel to crash To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.27 src/sys/arch/sparc64/doc/TODO:1.28 --- src/sys/arch/sparc64/doc/TODO:1.27 Fri Oct 5 19:53:47 2018 +++ src/sys/arch/sparc64/doc/TODO Mon Dec 17 20:13:46 2018 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.27 2018/10/05 19:53:47 palle Exp $ */ + /* $NetBSD: TODO,v 1.28 2018/12/17 20:13:46 palle Exp $ */ Things to be done: @@ -12,7 +12,13 @@ sun4u: sun4v: - current status: The kernel boots and starts the init process (pid 1) - which spawns /sbin/sh (pid 2). This is forked as a new /sbin/sh (pid 3) which crashes, probably due to MMU DPROT issues. + which spawns /sbin/sh (pid 2). This is forked as a new /sbin/sh (pid 3) + which crashes, probably due to MMU DPROT issues. + Looks like the user process tries to write to the stack as part of a save + instruction since cansave is zero. This causes a DMMU PROT trap (0x6c) which + calls sun4v_tl0_dtsb_prot which calls sun4v_datatrap which calls TRAP_SETUP(). + This macro has code that does a save instruction, again to the user stack, + which again causes a MMU DPROT trap... - 64-bit kernel support - 32-bit kernel support - libkvm
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Thu Nov 29 20:58:36 UTC 2018 Modified Files: src/sys/arch/sparc64/sparc64: pmap.c Log Message: sun4v: fix incorrect calculation of phys addr for the mdesc - now the virtual-devices can (again) be detected (worked previously...) To generate a diff of this commit: cvs rdiff -u -r1.308 -r1.309 src/sys/arch/sparc64/sparc64/pmap.c 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/sparc64/sparc64/pmap.c diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.308 src/sys/arch/sparc64/sparc64/pmap.c:1.309 --- src/sys/arch/sparc64/sparc64/pmap.c:1.308 Sat Jan 27 23:07:36 2018 +++ src/sys/arch/sparc64/sparc64/pmap.c Thu Nov 29 20:58:36 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.308 2018/01/27 23:07:36 chs Exp $ */ +/* $NetBSD: pmap.c,v 1.309 2018/11/29 20:58:36 palle Exp $ */ /* * * Copyright (C) 1996-1999 Eduardo Horvath. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.308 2018/01/27 23:07:36 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.309 2018/11/29 20:58:36 palle Exp $"); #undef NO_VCACHE /* Don't forget the locked TLB in dostart */ #define HWREF @@ -765,7 +765,7 @@ pmap_bootstrap(u_long kernelstart, u_lon m_len = mdesc_get_len(); m_va = kdata_alloc(m_len, 16); - m_pa = kdatap + (m_va - kdata); + m_pa = pmap_kextract(m_va); mdesc_init(m_va, m_pa, m_len); }
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Sun Nov 4 20:02:07 UTC 2018 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: Ensure that the 64-bit condition codes are used instead of the 32-bit condition codes. ok martin@ To generate a diff of this commit: cvs rdiff -u -r1.414 -r1.415 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.414 src/sys/arch/sparc64/sparc64/locore.s:1.415 --- src/sys/arch/sparc64/sparc64/locore.s:1.414 Sat May 26 19:20:21 2018 +++ src/sys/arch/sparc64/sparc64/locore.s Sun Nov 4 20:02:07 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.414 2018/05/26 19:20:21 palle Exp $ */ +/* $NetBSD: locore.s,v 1.415 2018/11/04 20:02:07 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -7453,7 +7453,7 @@ ENTRY(next_stick) andn %o1, %o3, %o1 andn %o2, %o3, %o2 cmp %o1, %o2 ! Did we wrap? (stick < stick_cmpr) - bgt,pt %icc, 1f + bgt,pt %xcc, 1f add %o1, 1000, %o1 ! Need some slack so we don't lose intrs. /*
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Fri Oct 5 19:53:47 UTC 2018 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update TODO with proper path to sh + list tested platforms so far To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.26 src/sys/arch/sparc64/doc/TODO:1.27 --- src/sys/arch/sparc64/doc/TODO:1.26 Wed Apr 11 19:44:47 2018 +++ src/sys/arch/sparc64/doc/TODO Fri Oct 5 19:53:47 2018 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.26 2018/04/11 19:44:47 palle Exp $ */ + /* $NetBSD: TODO,v 1.27 2018/10/05 19:53:47 palle Exp $ */ Things to be done: @@ -12,7 +12,7 @@ sun4u: sun4v: - current status: The kernel boots and starts the init process (pid 1) - which spawns /bin/sh (pid 2). This is forked as a new/bin/sh (pid 3) which crashes, probably due to MMU DPROT issues. + which spawns /sbin/sh (pid 2). This is forked as a new /sbin/sh (pid 3) which crashes, probably due to MMU DPROT issues. - 64-bit kernel support - 32-bit kernel support - libkvm @@ -33,4 +33,7 @@ sun4v: - vdsk and ldc drivers: code maked with OPENBSD_BUSDMA - make the bus_dma stuff work properly - vbus.c: handle prom_getprop() memory leaks - locore.s: rft_user (sun4v specific manaul fill) - seems to work, but is it good enough (compared to openbsds rft_user? - + - platforms tested so far: + -- qemu sun4v/niagara - crash in init process relaed to fork (stack?) + -- T2000 - mmu fault somewhere + -- T5 - stickcmpr is not properly initialized ???
CVS commit: src/tools/compat
Module Name:src Committed By: palle Date: Sun Sep 9 19:17:21 UTC 2018 Modified Files: src/tools/compat: README Log Message: Add instructions for building NetBSD on modern Solaris 11 hosts To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tools/compat/README Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tools/compat/README diff -u src/tools/compat/README:1.12 src/tools/compat/README:1.13 --- src/tools/compat/README:1.12 Tue Apr 5 00:21:22 2005 +++ src/tools/compat/README Sun Sep 9 19:17:21 2018 @@ -1,4 +1,4 @@ -$NetBSD: README,v 1.12 2005/04/05 00:21:22 jmc Exp $ +$NetBSD: README,v 1.13 2018/09/09 19:17:21 palle Exp $ Special notes for cross-hosting a NetBSD build on certain platforms. Only those platforms which have been tested to complete a "build.sh" run @@ -65,6 +65,8 @@ NETBSD (earlier releases): SOLARIS: +(updated instruction for Solaris 11 further below) + * Tested on Solaris/x86 8 (5.8) with gcc 2.95.2 and Solaris/sparc 8 (5.8) with gcc 3.2 (not yet tested with SUNWspro). @@ -85,3 +87,16 @@ SOLARIS: /usr/ucb may optionally be placed before /usr/bin, per your preference, but /usr/ucb *MUST NOT* be before /usr/ccs/bin or before the path to the host C and C++ compilers. + +Solaris 11: + +* Solaris 11.3 + * Set PATH to /usr/xpg6/bin:/usr/xpg4/bin:/usr/bin + * Set HOST_CC to /usr/bin/gcc + +* Solaris 11.4 + * Install gcc-5 since the default installed gcc-7 has issues when compiling + toolchain version of groff (hypot()) + * Set PATH to /usr/xpg7/bin:/usr/xpg6/bin:/usr/xpg4/bin:/usr/bin + * set HOST_CC to /usr/gcc/5/bin/gcc + * set HOST_CXX to /usr/gcc/5/bin/g++
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Sat May 26 19:20:21 UTC 2018 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: next_stick() - fix typy in comment: tick->stick To generate a diff of this commit: cvs rdiff -u -r1.413 -r1.414 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.413 src/sys/arch/sparc64/sparc64/locore.s:1.414 --- src/sys/arch/sparc64/sparc64/locore.s:1.413 Wed Apr 11 19:41:18 2018 +++ src/sys/arch/sparc64/sparc64/locore.s Sat May 26 19:20:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.413 2018/04/11 19:41:18 palle Exp $ */ +/* $NetBSD: locore.s,v 1.414 2018/05/26 19:20:21 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -7452,7 +7452,7 @@ ENTRY(next_stick) sllx %o3, 63, %o3 andn %o1, %o3, %o1 andn %o2, %o3, %o2 - cmp %o1, %o2 ! Did we wrap? (tick < tick_cmpr) + cmp %o1, %o2 ! Did we wrap? (stick < stick_cmpr) bgt,pt %icc, 1f add %o1, 1000, %o1 ! Need some slack so we don't lose intrs.
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Wed Apr 11 19:44:47 UTC 2018 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: Update TODO file with current state of sun4v support To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.25 src/sys/arch/sparc64/doc/TODO:1.26 --- src/sys/arch/sparc64/doc/TODO:1.25 Sat Feb 3 21:45:54 2018 +++ src/sys/arch/sparc64/doc/TODO Wed Apr 11 19:44:47 2018 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.25 2018/02/03 21:45:54 palle Exp $ */ + /* $NetBSD: TODO,v 1.26 2018/04/11 19:44:47 palle Exp $ */ Things to be done: @@ -11,7 +11,8 @@ sun4u: - GENERIC.UP kernel hangs on v445 (missing interrupt?) sun4v: - - current status: The kernel boots and starts the init process (syscalls are done, but crashes...) (*) + - current status: The kernel boots and starts the init process (pid 1) + which spawns /bin/sh (pid 2). This is forked as a new/bin/sh (pid 3) which crashes, probably due to MMU DPROT issues. - 64-bit kernel support - 32-bit kernel support - libkvm @@ -33,39 +34,3 @@ sun4v: - vbus.c: handle prom_getprop() memory leaks - locore.s: rft_user (sun4v specific manaul fill) - seems to work, but is it good enough (compared to openbsds rft_user? - -(*) -The current state of the code crashes in the code path after the init process -(pid 1) does a fork(), starting pid 2. -A new lwp is created and lwp_trampoline() is called which in turn calls -return_from_trap(). Here the code path continues to rft_user(). -A trap (0x68 - this is a Hyper-Priv trap...) occurs in rft_user_fault_start() -where the FILL() macro causes the trap trying to load the local register %l0 -from the stack using ASI AIUS (%o6 contains 0xcd91). -The Hyper-Priv trap 0x68 is transformed to a Priv trap 0x31, causing -sun4v_dtsb_miss() to be called, continuing to sun4v_datatrap(). -Here TRAP_SETUP() is called, -The windows registers are now: %otherwin=0, %cansave=6, canrestore=0. -Part of the TRAP_SETUP() code will do a 'save %g6, 0, %sp', -The windows registers are now: %otherwin=0, %cansave=5, canrestore=1. -TRAP_SETUP() now updates %otherwin with the values of %canrestore and clears -%canrestore, so the windows registers are now: %otherwin=1, %cansave=5, -canrestore=0. -The execution continues to data_access_fault() and further down the call stack -with function calls until %cansave reaches 0 causing a spill trap -(0xa8 - spill_2_other). The contents of the %sp register is 0xe00x. -%wstate is (octal) 26. -The windows registers are now: %otherwin=1, %cansave=0, canrestore=5. -The spill code is using ASI AIUS. spill_2_other is selected since %otherwin is -non-zero, so the index in wstate.other is 2 (spill_2_other). -SPILLBOTH() is invoked, using ASI AIUS. While storing %l0 to %sp+0x7ff -(%sp is 0xcd91) a new trap occurs, 0x68 (Hyper-priv, e.g. 0x31 Priv) -at trap level 2 causing the trap level to go to 3. This is above the mx trap -level for sun4v which is 2... -So... the first access to 0xcd91 causes a cyclic access to -0xcd91 again causing the max trap level to exceed. -hmhow to fix this.. - - - -
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Wed Apr 11 19:41:18 UTC 2018 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: handle MMU-related traps properly when they occur at trap level 1. This fixes issues when user-level LWPs access the user-level stack To generate a diff of this commit: cvs rdiff -u -r1.412 -r1.413 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.412 src/sys/arch/sparc64/sparc64/locore.s:1.413 --- src/sys/arch/sparc64/sparc64/locore.s:1.412 Sat Aug 26 20:25:00 2017 +++ src/sys/arch/sparc64/sparc64/locore.s Wed Apr 11 19:41:18 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.412 2017/08/26 20:25:00 palle Exp $ */ +/* $NetBSD: locore.s,v 1.413 2018/04/11 19:41:18 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -1147,9 +1147,12 @@ _C_LABEL(trapbase_sun4v): ! sun4v_trap_entry 36 ! 0x000-0x023 CLEANWIN1 ! 0x24-0x27 = clean window - sun4v_trap_entry 9 ! 0x028-0x030 - VTRAP(T_DATA_MMU_MISS, sun4v_dtsb_miss) ! 0x031 = data MMU miss - sun4v_trap_entry 58 ! 0x032-0x06b + sun4v_trap_entry 8 ! 0x028-0x02F + VTRAP(T_DATAFAULT, sun4v_tl1_ptbl_miss) ! 0x030 = ??? + VTRAP(T_DATA_MMU_MISS, sun4v_tl1_dtsb_miss) ! 0x031 = data MMU miss + VTRAP(T_DATA_ERROR, sun4v_tl1_ptbl_miss) ! 0x032 = ??? + VTRAP(T_DATA_PROT, sun4v_tl1_ptbl_miss) ! 0x033 = ??? + sun4v_trap_entry 56 ! 0x034-0x06b VTRAP(T_FDMMU_PROT, sun4v_tl1_dtsb_prot) ! 0x06c sun4v_trap_entry 19 ! 0x06d-0x07f SPILL64(uspill8_sun4vt1,ASI_AIUS) ! 0x080 spill_0_normal -- save user windows @@ -2858,6 +2861,79 @@ sun4v_dtsb_miss: retry NOTREACHED +sun4v_tl1_dtsb_miss: + GET_MMFSA %g1! MMU Fault status area + add %g1, 0x48, %g3 + LDPTRA [%g3] ASI_PHYS_CACHED, %g3 ! Data fault address + add %g1, 0x50, %g6 + LDPTRA [%g6] ASI_PHYS_CACHED, %g6 ! Data fault context + + GET_CTXBUSY %g4 + sllx %g6, 3, %g6 ! Make it into an offset into ctxbusy + LDPTR [%g4 + %g6], %g4 ! Load up our page table. + + srax %g3, HOLESHIFT, %g5 ! Check for valid address + brz,pt %g5, 0f! Should be zero or -1 + inc %g5! Make -1 -> 0 + brnz,pn %g5, sun4v_tl1_ptbl_miss ! Error! In hole! +0: + srlx %g3, STSHIFT, %g6 + and %g6, STMASK, %g6 ! Index into pm_segs + sll %g6, 3, %g6 + add %g4, %g6, %g4 + LDPTRA [%g4] ASI_PHYS_CACHED, %g4 ! Load page directory pointer + srlx %g3, PDSHIFT, %g6 + and %g6, PDMASK, %g6 + sll %g6, 3, %g6 + brz,pn %g4, sun4v_tl1_ptbl_miss ! NULL entry? check somewhere else + add %g4, %g6, %g4 + LDPTRA [%g4] ASI_PHYS_CACHED, %g4 ! Load page table pointer + + srlx %g3, PTSHIFT, %g6 ! Convert to ptab offset + and %g6, PTMASK, %g6 + sll %g6, 3, %g6 + brz,pn %g4, sun4v_tl1_ptbl_miss ! NULL entry? check somewhere else + add %g4, %g6, %g6 +1: + LDPTRA [%g6] ASI_PHYS_CACHED, %g4 ! Fetch TTE + brgez,pn %g4, sun4v_tl1_ptbl_miss ! Entry invalid? Punt + or %g4, SUN4V_TLB_ACCESS, %g7 ! Update the access bit + + btst SUN4V_TLB_ACCESS, %g4 ! Need to update access bit? + bne,pt %xcc, 2f + nop + casxa [%g6] ASI_PHYS_CACHED, %g4, %g7 ! and write it out + cmp %g4, %g7 + bne,pn %xcc, 1b + or %g4, SUN4V_TLB_ACCESS, %g4 ! Update the access bit +2: + GET_TSB_DMMU %g2 + + /* Construct TSB tag word. */ + add %g1, 0x50, %g6 + LDPTRA [%g6] ASI_PHYS_CACHED, %g6 ! Data fault context + mov %g3, %g1 ! Data fault address + srlx %g1, 22, %g1 ! 63..22 of virt addr + sllx %g6, 48, %g6 ! context_id in 63..48 + or %g1, %g6, %g1 ! construct TTE tag + srlx %g3, PTSHIFT, %g3 + sethi %hi(_C_LABEL(tsbsize)), %g5 + mov 512, %g6 + ld [%g5 + %lo(_C_LABEL(tsbsize))], %g5 + sllx %g6, %g5, %g5 ! %g5 = 512 << tsbsize = TSBENTS + sub %g5, 1, %g5 ! TSBENTS -> offset + and %g3, %g5, %g3 ! mask out TTE index + sllx %g3, 4, %g3 ! TTE size is 16 bytes + add %g2, %g3, %g2 ! location of TTE in ci_tsb_dmmu + + membar #StoreStore + + STPTR %g4, [%g2 + 8] ! store TTE data + STPTR %g1, [%g2] ! store TTE tag + + retry + NOTREACHED + sun4v_datatrap: GET_MMFSA %g3! MMU Fault status area add %g3, 0x48, %g1
CVS commit: src/sys/arch/sparc/include
Module Name:src Committed By: palle Date: Wed Apr 11 19:37:58 UTC 2018 Modified Files: src/sys/arch/sparc/include: frame.h Log Message: Fix typo in comment To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc/include/frame.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/sparc/include/frame.h diff -u src/sys/arch/sparc/include/frame.h:1.9 src/sys/arch/sparc/include/frame.h:1.10 --- src/sys/arch/sparc/include/frame.h:1.9 Tue Oct 6 20:03:05 2015 +++ src/sys/arch/sparc/include/frame.h Wed Apr 11 19:37:58 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: frame.h,v 1.9 2015/10/06 20:03:05 martin Exp $ */ +/* $NetBSD: frame.h,v 1.10 2018/04/11 19:37:58 palle Exp $ */ /* * Copyright (c) 1992, 1993 @@ -104,7 +104,7 @@ struct frame32 { * of the frame, you must first force the kernel to write any such * windows to the stack. * - * V9 frames have an odd bias, so you can tall a v9 frame from + * V9 frames have an odd bias, so you can tell a v9 frame from * a v8 frame by testing the stack pointer's lsb. */ #if !defined(_LOCORE) && !defined(_LIBC)
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Sat Feb 3 21:45:54 UTC 2018 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: Update TODO with a detailed description of why the kernel crashes when running on sun4v systems. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.24 src/sys/arch/sparc64/doc/TODO:1.25 --- src/sys/arch/sparc64/doc/TODO:1.24 Sun Feb 19 18:30:05 2017 +++ src/sys/arch/sparc64/doc/TODO Sat Feb 3 21:45:54 2018 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.24 2017/02/19 18:30:05 palle Exp $ */ + /* $NetBSD: TODO,v 1.25 2018/02/03 21:45:54 palle Exp $ */ Things to be done: @@ -11,7 +11,7 @@ sun4u: - GENERIC.UP kernel hangs on v445 (missing interrupt?) sun4v: - - current status: The kernel boots and starts the init process (syscalls are done, but crashes...) + - current status: The kernel boots and starts the init process (syscalls are done, but crashes...) (*) - 64-bit kernel support - 32-bit kernel support - libkvm @@ -31,5 +31,41 @@ sun4v: - man pages for drivers imported from OpenBSD lke vpci, vbus, cbus, vdsk, ldc etc. - vdsk and ldc drivers: code maked with OPENBSD_BUSDMA - make the bus_dma stuff work properly - vbus.c: handle prom_getprop() memory leaks -- locore.s: rft_user (sun4v specific manaul fill) - seems to work, but is it good enough (compared to openbsds rft_user +- locore.s: rft_user (sun4v specific manaul fill) - seems to work, but is it good enough (compared to openbsds rft_user? + + +(*) +The current state of the code crashes in the code path after the init process +(pid 1) does a fork(), starting pid 2. +A new lwp is created and lwp_trampoline() is called which in turn calls +return_from_trap(). Here the code path continues to rft_user(). +A trap (0x68 - this is a Hyper-Priv trap...) occurs in rft_user_fault_start() +where the FILL() macro causes the trap trying to load the local register %l0 +from the stack using ASI AIUS (%o6 contains 0xcd91). +The Hyper-Priv trap 0x68 is transformed to a Priv trap 0x31, causing +sun4v_dtsb_miss() to be called, continuing to sun4v_datatrap(). +Here TRAP_SETUP() is called, +The windows registers are now: %otherwin=0, %cansave=6, canrestore=0. +Part of the TRAP_SETUP() code will do a 'save %g6, 0, %sp', +The windows registers are now: %otherwin=0, %cansave=5, canrestore=1. +TRAP_SETUP() now updates %otherwin with the values of %canrestore and clears +%canrestore, so the windows registers are now: %otherwin=1, %cansave=5, +canrestore=0. +The execution continues to data_access_fault() and further down the call stack +with function calls until %cansave reaches 0 causing a spill trap +(0xa8 - spill_2_other). The contents of the %sp register is 0xe00x. +%wstate is (octal) 26. +The windows registers are now: %otherwin=1, %cansave=0, canrestore=5. +The spill code is using ASI AIUS. spill_2_other is selected since %otherwin is +non-zero, so the index in wstate.other is 2 (spill_2_other). +SPILLBOTH() is invoked, using ASI AIUS. While storing %l0 to %sp+0x7ff +(%sp is 0xcd91) a new trap occurs, 0x68 (Hyper-priv, e.g. 0x31 Priv) +at trap level 2 causing the trap level to go to 3. This is above the mx trap +level for sun4v which is 2... +So... the first access to 0xcd91 causes a cyclic access to +0xcd91 again causing the max trap level to exceed. +hmhow to fix this.. + + +
CVS commit: src/sys/arch
Module Name:src Committed By: palle Date: Mon Sep 11 19:25:07 UTC 2017 Modified Files: src/sys/arch/sparc/include: promlib.h src/sys/arch/sparc/sparc: promlib.c src/sys/arch/sparc64/include: autoconf.h src/sys/arch/sparc64/sparc64: autoconf.c cpu.c Log Message: sun4v: Update code to retrieve CPU clock frequency so it can handle (future?) CPU clock frequencies above the 32-bit limit. ok mrg@ To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/arch/sparc/include/promlib.h cvs rdiff -u -r1.45 -r1.46 src/sys/arch/sparc/sparc/promlib.c cvs rdiff -u -r1.32 -r1.33 src/sys/arch/sparc64/include/autoconf.h cvs rdiff -u -r1.211 -r1.212 src/sys/arch/sparc64/sparc64/autoconf.c cvs rdiff -u -r1.131 -r1.132 src/sys/arch/sparc64/sparc64/cpu.c 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/sparc/include/promlib.h diff -u src/sys/arch/sparc/include/promlib.h:1.24 src/sys/arch/sparc/include/promlib.h:1.25 --- src/sys/arch/sparc/include/promlib.h:1.24 Thu Jan 21 11:40:01 2010 +++ src/sys/arch/sparc/include/promlib.h Mon Sep 11 19:25:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: promlib.h,v 1.24 2010/01/21 11:40:01 martin Exp $ */ +/* $NetBSD: promlib.h,v 1.25 2017/09/11 19:25:07 palle Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -137,6 +137,7 @@ void prom_init(void); /* To setup promop /* Utility routines */ int prom_getprop(int, const char *, size_t, int *, void *); int prom_getpropint(int, const char *, int); +uint64_t prom_getpropuint64(int, const char *, uint64_t); char *prom_getpropstring(int, const char *); char *prom_getpropstringA(int, const char *, char *, size_t); void prom_printf(const char *, ...); Index: src/sys/arch/sparc/sparc/promlib.c diff -u src/sys/arch/sparc/sparc/promlib.c:1.45 src/sys/arch/sparc/sparc/promlib.c:1.46 --- src/sys/arch/sparc/sparc/promlib.c:1.45 Fri Apr 1 20:21:45 2016 +++ src/sys/arch/sparc/sparc/promlib.c Mon Sep 11 19:25:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: promlib.c,v 1.45 2016/04/01 20:21:45 palle Exp $ */ +/* $NetBSD: promlib.c,v 1.46 2017/09/11 19:25:07 palle Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.45 2016/04/01 20:21:45 palle Exp $"); +__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.46 2017/09/11 19:25:07 palle Exp $"); #if defined(_KERNEL_OPT) #include "opt_sparc_arch.h" @@ -265,6 +265,22 @@ prom_getpropint(int node, const char *na } /* + * Fetch an unsigned 64-bit integer (or pointer) property. + * The return value is the property, or the default if there was none. + */ +uint64_t +prom_getpropuint64(int node, const char *name, uint64_t deflt) +{ + uint64_t uint64buf, *uint64p = + int len = 2; + + if (prom_getprop(node, name, sizeof(uint64_t), , ) != 0) + return deflt; + + return uint64buf; +} + +/* * Node Name Matching per IEEE 1275, section 4.3.6. */ static int Index: src/sys/arch/sparc64/include/autoconf.h diff -u src/sys/arch/sparc64/include/autoconf.h:1.32 src/sys/arch/sparc64/include/autoconf.h:1.33 --- src/sys/arch/sparc64/include/autoconf.h:1.32 Sat Oct 26 18:47:27 2013 +++ src/sys/arch/sparc64/include/autoconf.h Mon Sep 11 19:25:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.h,v 1.32 2013/10/26 18:47:27 jdc Exp $ */ +/* $NetBSD: autoconf.h,v 1.33 2017/09/11 19:25:07 palle Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ int matchbyname(device_t, cfdata_t, void * `clockfreq' produces a printable representation of a clock frequency * (this is just a frill). */ -char *clockfreq(long); +char *clockfreq(uint64_t); /* Kernel initialization routine. */ void bootstrap(void *, void *, void *, void *, void *); Index: src/sys/arch/sparc64/sparc64/autoconf.c diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.211 src/sys/arch/sparc64/sparc64/autoconf.c:1.212 --- src/sys/arch/sparc64/sparc64/autoconf.c:1.211 Sun Mar 26 12:59:29 2017 +++ src/sys/arch/sparc64/sparc64/autoconf.c Mon Sep 11 19:25:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.211 2017/03/26 12:59:29 martin Exp $ */ +/* $NetBSD: autoconf.c,v 1.212 2017/09/11 19:25:07 palle Exp $ */ /* * Copyright (c) 1996 @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.211 2017/03/26 12:59:29 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.212 2017/09/11 19:25:07 palle Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -521,16 +521,16 @@ cpu_rootconf(void) } char * -clockfreq(long freq) +clockfreq(uint64_t freq) { static char buf[10]; size_t len; freq /= 1000; - len = snprintf(buf, sizeof(buf), "%ld", freq / 1000); + len = snprintf(buf, sizeof(buf), "%" PRIu64, freq / 1000); freq %= 1000; if (freq) - snprintf(buf + len, sizeof(buf) - len, ".%03ld", freq); + snprintf(buf + len, sizeof(buf) - len,
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Sun Aug 27 19:31:44 UTC 2017 Modified Files: src/sys/arch/sparc64/sparc64: cpu.c Log Message: sun4v: Change clk and sclk variables to unsigned type so modern faster systems with CPU frequencies above 2 Ghz are shown correctly. Example is a 3599.910 MHz SPARC T5-2 system that otherwise is shown incorrectly as -695.-57 MHz. Based on code from OpenBSD cpu.c rev. 1.41. Verified on sun4u using qemu and sun4v on SPARC T5-2 To generate a diff of this commit: cvs rdiff -u -r1.130 -r1.131 src/sys/arch/sparc64/sparc64/cpu.c 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/sparc64/sparc64/cpu.c diff -u src/sys/arch/sparc64/sparc64/cpu.c:1.130 src/sys/arch/sparc64/sparc64/cpu.c:1.131 --- src/sys/arch/sparc64/sparc64/cpu.c:1.130 Fri Feb 10 23:26:23 2017 +++ src/sys/arch/sparc64/sparc64/cpu.c Sun Aug 27 19:31:43 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.130 2017/02/10 23:26:23 palle Exp $ */ +/* $NetBSD: cpu.c,v 1.131 2017/08/27 19:31:43 palle Exp $ */ /* * Copyright (c) 1996 @@ -52,7 +52,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130 2017/02/10 23:26:23 palle Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.131 2017/08/27 19:31:43 palle Exp $"); #include "opt_multiprocessor.h" @@ -421,7 +421,7 @@ void cpu_attach(device_t parent, device_t dev, void *aux) { int node; - long clk, sclk = 0; + unsigned int clk, sclk = 0; struct mainbus_attach_args *ma = aux; struct cpu_info *ci; const char *sep;
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Sat Aug 26 20:25:00 UTC 2017 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: Avoid touching the %tick_cmpr register which is not present on never systems (Oracle SPARC Architecture 2011 and beyond). Based on code from OpenBSD locore.s revision 1.177. Tested on both sun4u (qemu and USIII) and sun4v (qemu and T5-2). ok martin@ To generate a diff of this commit: cvs rdiff -u -r1.411 -r1.412 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.411 src/sys/arch/sparc64/sparc64/locore.s:1.412 --- src/sys/arch/sparc64/sparc64/locore.s:1.411 Sat May 6 21:46:31 2017 +++ src/sys/arch/sparc64/sparc64/locore.s Sat Aug 26 20:25:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.411 2017/05/06 21:46:31 palle Exp $ */ +/* $NetBSD: locore.s,v 1.412 2017/08/26 20:25:00 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -5119,9 +5119,6 @@ _C_LABEL(endtrapcode): .align 8 start: dostart: - mov 1, %g1 - sllx %g1, 63, %g1 - wr %g1, TICK_CMPR ! XXX clear and disable %tick_cmpr for now /* * Startup. *
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Sat May 6 21:46:31 UTC 2017 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: The %ver register is not available on sun4v - use GET_MAXCWP introduced in rev. 1.361. Verified using qemu (sun4u and sun4v) and on real sun4v hw (t2000) To generate a diff of this commit: cvs rdiff -u -r1.410 -r1.411 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.410 src/sys/arch/sparc64/sparc64/locore.s:1.411 --- src/sys/arch/sparc64/sparc64/locore.s:1.410 Tue Apr 18 20:02:50 2017 +++ src/sys/arch/sparc64/sparc64/locore.s Sat May 6 21:46:31 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.410 2017/04/18 20:02:50 palle Exp $ */ +/* $NetBSD: locore.s,v 1.411 2017/05/06 21:46:31 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -4936,9 +4936,8 @@ rft_user: bgu,pt %xcc, 3b! Next one? dec 8*16, %g5 - rdpr %ver, %g5 stb %g0, [%g6 + PCB_NSAVED] ! Clear them out so we won't do this again - and %g5, CWP, %g5 + GET_MAXCWP %g5 add %g5, %g7, %g4 dec 1, %g5 ! NWINDOWS-1-1 wrpr %g5, 0, %cansave
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Tue Apr 18 20:02:50 UTC 2017 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: Add handling of trap 0x06c @ trap level 1 - based on code from OpenBSD, but slightly adapted to NetBSD. verified using qemu To generate a diff of this commit: cvs rdiff -u -r1.409 -r1.410 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.409 src/sys/arch/sparc64/sparc64/locore.s:1.410 --- src/sys/arch/sparc64/sparc64/locore.s:1.409 Sun Feb 19 18:25:45 2017 +++ src/sys/arch/sparc64/sparc64/locore.s Tue Apr 18 20:02:50 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.409 2017/02/19 18:25:45 palle Exp $ */ +/* $NetBSD: locore.s,v 1.410 2017/04/18 20:02:50 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -1102,7 +1102,7 @@ _C_LABEL(trapbase_sun4v): HARDINT4V(14) ! 0x04e = level 14 interrupt HARDINT4V(15) ! 0x04f = level 15 interrupt sun4v_trap_entry 28 ! 0x050-0x06b - VTRAP(T_FDMMU_PROT, sun4v_tl0_dtsb_prot) ! 0x6c + VTRAP(T_FDMMU_PROT, sun4v_tl0_dtsb_prot) ! 0x06c sun4v_trap_entry 15 ! 0x06d-0x07b VTRAP(T_CPU_MONDO, sun4v_cpu_mondo) ! 0x07c = cpu mondo VTRAP(T_DEV_MONDO, sun4v_dev_mondo) ! 0x07d = dev mondo @@ -1149,7 +1149,9 @@ _C_LABEL(trapbase_sun4v): CLEANWIN1 ! 0x24-0x27 = clean window sun4v_trap_entry 9 ! 0x028-0x030 VTRAP(T_DATA_MMU_MISS, sun4v_dtsb_miss) ! 0x031 = data MMU miss - sun4v_trap_entry 78 ! 0x032-0x07f + sun4v_trap_entry 58 ! 0x032-0x06b + VTRAP(T_FDMMU_PROT, sun4v_tl1_dtsb_prot) ! 0x06c + sun4v_trap_entry 19 ! 0x06d-0x07f SPILL64(uspill8_sun4vt1,ASI_AIUS) ! 0x080 spill_0_normal -- save user windows SPILL32(uspill4_sun4vt1,ASI_AIUS) ! 0x084 spill_1_normal SPILLBOTH(uspill8_sun4vt1,uspill4_sun4vt1,ASI_AIUS) ! 0x088 spill_2_normal @@ -2952,8 +2954,7 @@ sun4v_tl0_dtsb_prot: 1: LDPTRA [%g6] ASI_PHYS_CACHED, %g4 ! Fetch TTE brgez,pn %g4, sun4v_datatrap ! Entry invalid? Punt - or %g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g7 - ! Update the modified bit + or %g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g7 ! Update the modified bit # btst SUN4V_TLB_REAL_W|SUN4V_TLB_W, %g4 ! Is it a ref fault? mov 1, %g2 @@ -2965,8 +2966,7 @@ sun4v_tl0_dtsb_prot: casxa [%g6] ASI_PHYS_CACHED, %g4, %g7 ! and write it out cmp %g4, %g7 bne,pn %xcc, 1b - or %g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g4 - ! Update the modified bit + or %g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g4 ! Update the modified bit 2: GET_TSB_DMMU %g2 @@ -3146,6 +3146,253 @@ sun4v_texttrap: nop NOTREACHED +sun4v_tl1_dtsb_prot: + GET_MMFSA %g1! MMU Fault status area + add %g1, 0x48, %g3 + LDPTRA [%g3] ASI_PHYS_CACHED, %g3 ! Data fault address + add %g1, 0x50, %g6 + LDPTRA [%g6] ASI_PHYS_CACHED, %g6 ! Data fault context + + GET_CTXBUSY %g4 + sllx %g6, 3, %g6 ! Make it into an offset into ctxbusy + LDPTR [%g4 + %g6], %g4 ! Load up our page table. + + srax %g3, HOLESHIFT, %g5 ! Check for valid address + brz,pt %g5, 0f! Should be zero or -1 + inc %g5! Make -1 -> 0 + brnz,pn %g5, sun4v_tl1_ptbl_miss ! Error! In hole! +0: + srlx %g3, STSHIFT, %g6 + and %g6, STMASK, %g6 ! Index into pm_segs + sll %g6, 3, %g6 + add %g4, %g6, %g4 + LDPTRA [%g4] ASI_PHYS_CACHED, %g4 ! Load page directory pointer + + srlx %g3, PDSHIFT, %g6 + and %g6, PDMASK, %g6 + sll %g6, 3, %g6 + brz,pn %g4, sun4v_tl1_ptbl_miss ! NULL entry? check somewhere else + add %g4, %g6, %g4 + LDPTRA [%g4] ASI_PHYS_CACHED, %g4 ! Load page table pointer + + srlx %g3, PTSHIFT, %g6 ! Convert to ptab offset + and %g6, PTMASK, %g6 + sll %g6, 3, %g6 + brz,pn %g4, sun4v_tl1_ptbl_miss ! NULL entry? check somewhere else + add %g4, %g6, %g6 +1: + LDPTRA [%g6] ASI_PHYS_CACHED, %g4 ! Fetch TTE + brgez,pn %g4, sun4v_tl1_ptbl_miss ! Entry invalid? Punt + or %g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g7 ! Update the modified bit + +# btst SUN4V_TLB_REAL_W|SUN4V_TLB_W, %g4 ! Is it a ref fault? + mov 1, %g2 + sllx %g2, 61, %g2 + or %g2, SUN4V_TLB_W, %g2 + btst %g2, %g4 + bz,pn %xcc, sun4v_tl1_ptbl_miss ! No -- really fault + nop + casxa [%g6] ASI_PHYS_CACHED, %g4, %g7 ! and write it out + cmp %g4, %g7 + bne,pn %xcc, 1b + or %g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g4 ! Update the modified bit +2: + GET_TSB_DMMU %g2 + + mov %g1, %g7 ! save MMFSA + + /* Construct TSB tag word. */ + add %g1, 0x50, %g6 + LDPTRA [%g6] ASI_PHYS_CACHED, %g6 ! Data fault context + mov %g3, %g1 ! Data fault address + srlx %g1, 22, %g1 ! 63..22 of virt addr + sllx %g6, 48, %g6 ! context_id in 63..48 + or %g1, %g6, %g1 ! construct TTE tag + + srlx %g3, PTSHIFT, %g3 + sethi %hi(_C_LABEL(tsbsize)), %g5 + mov 512, %g6 + ld [%g5 +
CVS commit: src/sys/arch/sparc64/dev
Module Name:src Committed By: palle Date: Fri Mar 3 21:09:25 UTC 2017 Modified Files: src/sys/arch/sparc64/dev: ldc.c vdsk.c Log Message: sun4v: Fixed PR 51554 - Avoid unsafe allocation in ldc/vdsk To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/dev/ldc.c \ src/sys/arch/sparc64/dev/vdsk.c 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/sparc64/dev/ldc.c diff -u src/sys/arch/sparc64/dev/ldc.c:1.2 src/sys/arch/sparc64/dev/ldc.c:1.3 --- src/sys/arch/sparc64/dev/ldc.c:1.2 Sat Aug 20 18:21:18 2016 +++ src/sys/arch/sparc64/dev/ldc.c Fri Mar 3 21:09:25 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ldc.c,v 1.2 2016/08/20 18:21:18 nakayama Exp $ */ +/* $NetBSD: ldc.c,v 1.3 2017/03/03 21:09:25 palle Exp $ */ /* $OpenBSD: ldc.c,v 1.12 2015/03/21 18:02:58 kettenis Exp $ */ /* * Copyright (c) 2009 Mark Kettenis @@ -554,6 +554,8 @@ ldc_queue_alloc(int nentries) goto unmap; #else va = (vaddr_t)kmem_zalloc(size, KM_NOSLEEP); + if (va == 0) + goto free; #endif lq->lq_va = (vaddr_t)va; lq->lq_nentries = nentries; @@ -565,6 +567,9 @@ free: bus_dmamem_free(t, >lq_seg, 1); destroy: bus_dmamap_destroy(t, lq->lq_map); +#else +free: + kmem_free(lq, sizeof(struct ldc_queue)); #endif return (NULL); } @@ -637,6 +642,8 @@ ldc_map_alloc(int nentries) } #else va = (vaddr_t)kmem_zalloc(size, KM_NOSLEEP); + if (va == 0) + goto free; #endif lm->lm_slot = (struct ldc_map_slot *)va; lm->lm_nentries = nentries; @@ -650,6 +657,9 @@ free: bus_dmamem_free(t, >lm_seg, 1); destroy: bus_dmamap_destroy(t, lm->lm_map); +#else +free: + kmem_free(lm, sizeof(struct ldc_map)); #endif return (NULL); } Index: src/sys/arch/sparc64/dev/vdsk.c diff -u src/sys/arch/sparc64/dev/vdsk.c:1.2 src/sys/arch/sparc64/dev/vdsk.c:1.3 --- src/sys/arch/sparc64/dev/vdsk.c:1.2 Sat Aug 20 18:21:18 2016 +++ src/sys/arch/sparc64/dev/vdsk.c Fri Mar 3 21:09:25 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vdsk.c,v 1.2 2016/08/20 18:21:18 nakayama Exp $ */ +/* $NetBSD: vdsk.c,v 1.3 2017/03/03 21:09:25 palle Exp $ */ /* $OpenBSD: vdsk.c,v 1.46 2015/01/25 21:42:13 kettenis Exp $ */ /* * Copyright (c) 2009, 2011 Mark Kettenis @@ -969,6 +969,8 @@ vdsk_dring_alloc(int nentries) goto unmap; #else va = (vaddr_t)kmem_zalloc(size, KM_NOSLEEP); + if (va == 0) + goto free; #endif vd->vd_desc = (struct vd_desc *)va; vd->vd_nentries = nentries; @@ -984,6 +986,9 @@ free: bus_dmamem_free(t, >vd_seg, 1); destroy: bus_dmamap_destroy(t, vd->vd_map); +#else +free: + kmem_free(vd, sizeof(struct vdsk_dring)); #endif return (NULL); }
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Sun Feb 19 18:30:05 UTC 2017 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: Update TODO with the status of the sun4v work so far To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.23 src/sys/arch/sparc64/doc/TODO:1.24 --- src/sys/arch/sparc64/doc/TODO:1.23 Sun Feb 19 18:27:12 2017 +++ src/sys/arch/sparc64/doc/TODO Sun Feb 19 18:30:05 2017 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.23 2017/02/19 18:27:12 palle Exp $ */ + /* $NetBSD: TODO,v 1.24 2017/02/19 18:30:05 palle Exp $ */ Things to be done: @@ -11,6 +11,7 @@ sun4u: - GENERIC.UP kernel hangs on v445 (missing interrupt?) sun4v: + - current status: The kernel boots and starts the init process (syscalls are done, but crashes...) - 64-bit kernel support - 32-bit kernel support - libkvm
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Sun Feb 19 18:27:13 UTC 2017 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: Note that the code recently added to locore.s rft_user may not be enough to make things work properly To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.22 src/sys/arch/sparc64/doc/TODO:1.23 --- src/sys/arch/sparc64/doc/TODO:1.22 Sun Feb 19 18:07:12 2017 +++ src/sys/arch/sparc64/doc/TODO Sun Feb 19 18:27:12 2017 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.22 2017/02/19 18:07:12 palle Exp $ */ + /* $NetBSD: TODO,v 1.23 2017/02/19 18:27:12 palle Exp $ */ Things to be done: @@ -30,3 +30,5 @@ sun4v: - man pages for drivers imported from OpenBSD lke vpci, vbus, cbus, vdsk, ldc etc. - vdsk and ldc drivers: code maked with OPENBSD_BUSDMA - make the bus_dma stuff work properly - vbus.c: handle prom_getprop() memory leaks +- locore.s: rft_user (sun4v specific manaul fill) - seems to work, but is it good enough (compared to openbsds rft_user +
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Sun Feb 19 18:25:45 UTC 2017 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: rft_user needs special handling (a manual fill) since the restore instruction may cause the number of trap levels to exceed the maximum for sun4v - inspired by code from the the openbsd rft_user code path - verified using qemu for both sun4u and sun4v To generate a diff of this commit: cvs rdiff -u -r1.408 -r1.409 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.408 src/sys/arch/sparc64/sparc64/locore.s:1.409 --- src/sys/arch/sparc64/sparc64/locore.s:1.408 Fri Feb 10 23:26:23 2017 +++ src/sys/arch/sparc64/sparc64/locore.s Sun Feb 19 18:25:45 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.408 2017/02/10 23:26:23 palle Exp $ */ +/* $NetBSD: locore.s,v 1.409 2017/02/19 18:25:45 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -3145,7 +3145,7 @@ sun4v_texttrap: ba,a,pt %icc, return_from_trap nop NOTREACHED - + /* * End of traps for sun4v. */ @@ -4747,6 +4747,36 @@ rft_user: wrpr %g2, 0, %tpc wrpr %g3, 0, %tnpc wrpr %g1, %g0, %tstate + + /* + * The restore instruction further down may cause the trap level + * to exceede the maximum trap level on sun4v, so a manual fill + * may be necessary. + */ + +#ifdef SUN4V + sethi %hi(cputyp), %g5 + ld [%g5 + %lo(cputyp)], %g5 + cmp %g5, CPU_SUN4V + bne,pt %icc, 1f + nop + + ! Only manual fill if the restore instruction will cause a fill trap + rdpr %canrestore, %g5 + brnz %g5, 1f + nop + + ! Do a manual fill + wr %g0, ASI_AIUS, %asi + rdpr %cwp, %g4 + dec %g4 + wrpr %g4, 0, %cwp + FILL ldxa, %sp+BIAS, 8, %asi + restored + inc %g4 + wrpr %g4, 0, %cwp +1: +#endif restore 6: rdpr %canrestore, %g5
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Sun Feb 19 18:07:12 UTC 2017 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: Note that prom_getprop() leaks memory in vbus.c To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.21 src/sys/arch/sparc64/doc/TODO:1.22 --- src/sys/arch/sparc64/doc/TODO:1.21 Sun Feb 5 20:08:35 2017 +++ src/sys/arch/sparc64/doc/TODO Sun Feb 19 18:07:12 2017 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.21 2017/02/05 20:08:35 palle Exp $ */ + /* $NetBSD: TODO,v 1.22 2017/02/19 18:07:12 palle Exp $ */ Things to be done: @@ -29,4 +29,4 @@ sun4v: - mpt(4) complains: mpt0: Phy 0: Link Status Unknown - man pages for drivers imported from OpenBSD lke vpci, vbus, cbus, vdsk, ldc etc. - vdsk and ldc drivers: code maked with OPENBSD_BUSDMA - make the bus_dma stuff work properly - +- vbus.c: handle prom_getprop() memory leaks
CVS commit: src/sys/arch/sparc64/dev
Module Name:src Committed By: palle Date: Fri Feb 17 20:53:17 UTC 2017 Modified Files: src/sys/arch/sparc64/dev: vbus.c Log Message: sun4v: Fix potential memory leaks - spotted by maxv@ To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/dev/vbus.c 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/sparc64/dev/vbus.c diff -u src/sys/arch/sparc64/dev/vbus.c:1.2 src/sys/arch/sparc64/dev/vbus.c:1.3 --- src/sys/arch/sparc64/dev/vbus.c:1.2 Tue Jun 21 20:36:02 2016 +++ src/sys/arch/sparc64/dev/vbus.c Fri Feb 17 20:53:17 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vbus.c,v 1.2 2016/06/21 20:36:02 palle Exp $ */ +/* $NetBSD: vbus.c,v 1.3 2017/02/17 20:53:17 palle Exp $ */ /* $OpenBSD: vbus.c,v 1.8 2015/09/27 11:29:20 kettenis Exp $ */ /* * Copyright (c) 2008 Mark Kettenis @@ -159,15 +159,15 @@ vbus_intr_map(int node, int ino, uint64_ if (imap_mask == NULL) return (-1); if (OF_getprop(parent, "interrupt-map-mask", imap_mask, len) != len) - return (-1); + goto out; if (prom_getprop(parent, "interrupt-map", sizeof(int), , (void **))) - panic("vbus: can't get interrupt-map"); + panic("vbus: can't get interrupt-map"); if (prom_getprop(node, "reg", sizeof(*reg), , (void **))) - panic("vbus: can't get reg"); + panic("vbus: can't get reg"); if (nreg < address_cells) - return (-1); + goto out; while (nimap >= address_cells + interrupt_cells + 2) { if (vbus_cmp_cells(imap, reg, imap_mask, address_cells) && @@ -180,21 +180,24 @@ vbus_intr_map(int node, int ino, uint64_ reg = NULL; if (prom_getprop(node, "reg", sizeof(*reg), , (void **))) - panic("vbus: can't get reg"); +panic("vbus: can't get reg"); devhandle = reg[0] & 0x0fff; err = hv_intr_devino_to_sysino(devhandle, devino, sysino); if (err != H_EOK) - return (-1); +goto out; KASSERT(*sysino == INTVEC(*sysino)); + free(imap_mask, M_DEVBUF); return (0); } imap += address_cells + interrupt_cells + 2; nimap -= address_cells + interrupt_cells + 2; } +out: + free(imap_mask, M_DEVBUF); return (-1); }
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Sun Feb 12 19:35:54 UTC 2017 Modified Files: src/sys/arch/sparc64/sparc64: trap.c Log Message: sun4v: Revert previous - paddr_t is not a pointer... noted by nakayama@ To generate a diff of this commit: cvs rdiff -u -r1.187 -r1.188 src/sys/arch/sparc64/sparc64/trap.c 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/sparc64/sparc64/trap.c diff -u src/sys/arch/sparc64/sparc64/trap.c:1.187 src/sys/arch/sparc64/sparc64/trap.c:1.188 --- src/sys/arch/sparc64/sparc64/trap.c:1.187 Sat Feb 11 23:41:36 2017 +++ src/sys/arch/sparc64/sparc64/trap.c Sun Feb 12 19:35:54 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.187 2017/02/11 23:41:36 palle Exp $ */ +/* $NetBSD: trap.c,v 1.188 2017/02/12 19:35:54 palle Exp $ */ /* * Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved. @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.187 2017/02/11 23:41:36 palle Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.188 2017/02/12 19:35:54 palle Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -738,8 +738,8 @@ badtrap: if (dsfsr & SFSR_FV) dsfar = ldxa(SFAR, ASI_DMMU); } else { - paddr_t mmu_fsa_dfa = cpus->ci_mmufsa + - (offsetof(struct mmufsa, dfa) / sizeof(paddr_t)); + paddr_t mmu_fsa_dfa = cpus->ci_mmufsa + + offsetof(struct mmufsa, dfa); dsfar = ldxa(mmu_fsa_dfa, ASI_PHYS_CACHED); } #ifdef DEBUG
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Sat Feb 11 23:41:36 UTC 2017 Modified Files: src/sys/arch/sparc64/sparc64: trap.c Log Message: sun4v: Fix calculation of mmu data fault address (pointer arithmetic) To generate a diff of this commit: cvs rdiff -u -r1.186 -r1.187 src/sys/arch/sparc64/sparc64/trap.c 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/sparc64/sparc64/trap.c diff -u src/sys/arch/sparc64/sparc64/trap.c:1.186 src/sys/arch/sparc64/sparc64/trap.c:1.187 --- src/sys/arch/sparc64/sparc64/trap.c:1.186 Sat Feb 11 21:04:29 2017 +++ src/sys/arch/sparc64/sparc64/trap.c Sat Feb 11 23:41:36 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.186 2017/02/11 21:04:29 christos Exp $ */ +/* $NetBSD: trap.c,v 1.187 2017/02/11 23:41:36 palle Exp $ */ /* * Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved. @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.186 2017/02/11 21:04:29 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.187 2017/02/11 23:41:36 palle Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -738,8 +738,8 @@ badtrap: if (dsfsr & SFSR_FV) dsfar = ldxa(SFAR, ASI_DMMU); } else { - paddr_t mmu_fsa_dfa = cpus->ci_mmufsa - + offsetof(struct mmufsa, dfa); + paddr_t mmu_fsa_dfa = cpus->ci_mmufsa + + (offsetof(struct mmufsa, dfa) / sizeof(paddr_t)); dsfar = ldxa(mmu_fsa_dfa, ASI_PHYS_CACHED); } #ifdef DEBUG
CVS commit: src/sys/arch/sparc64
Module Name:src Committed By: palle Date: Fri Feb 10 23:26:23 UTC 2017 Modified Files: src/sys/arch/sparc64/include: cpu.h hypervisor.h src/sys/arch/sparc64/sparc64: cpu.c genassym.cf locore.s pmap.c trap.c Log Message: sun4v: Added handling of trap type 0x034 (address alignment error) + fixed typo mmfsa -> mmufsa. Verified for both sun4u and sun4v using qemu. To generate a diff of this commit: cvs rdiff -u -r1.122 -r1.123 src/sys/arch/sparc64/include/cpu.h cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/include/hypervisor.h cvs rdiff -u -r1.129 -r1.130 src/sys/arch/sparc64/sparc64/cpu.c cvs rdiff -u -r1.80 -r1.81 src/sys/arch/sparc64/sparc64/genassym.cf cvs rdiff -u -r1.407 -r1.408 src/sys/arch/sparc64/sparc64/locore.s cvs rdiff -u -r1.306 -r1.307 src/sys/arch/sparc64/sparc64/pmap.c cvs rdiff -u -r1.184 -r1.185 src/sys/arch/sparc64/sparc64/trap.c 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/sparc64/include/cpu.h diff -u src/sys/arch/sparc64/include/cpu.h:1.122 src/sys/arch/sparc64/include/cpu.h:1.123 --- src/sys/arch/sparc64/include/cpu.h:1.122 Sat Jun 25 13:52:04 2016 +++ src/sys/arch/sparc64/include/cpu.h Fri Feb 10 23:26:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.122 2016/06/25 13:52:04 palle Exp $ */ +/* $NetBSD: cpu.h,v 1.123 2017/02/10 23:26:23 palle Exp $ */ /* * Copyright (c) 1992, 1993 @@ -185,7 +185,7 @@ struct cpu_info { * Will be initialized to the physical address of the bottom of * the interrupt stack. */ - paddr_t ci_mmfsa; + paddr_t ci_mmufsa; /* * sun4v mondo control fields Index: src/sys/arch/sparc64/include/hypervisor.h diff -u src/sys/arch/sparc64/include/hypervisor.h:1.5 src/sys/arch/sparc64/include/hypervisor.h:1.6 --- src/sys/arch/sparc64/include/hypervisor.h:1.5 Wed Sep 24 18:32:10 2014 +++ src/sys/arch/sparc64/include/hypervisor.h Fri Feb 10 23:26:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.h,v 1.5 2014/09/24 18:32:10 palle Exp $ */ +/* $NetBSD: hypervisor.h,v 1.6 2017/02/10 23:26:23 palle Exp $ */ /* $OpenBSD: hypervisor.h,v 1.14 2011/06/26 17:23:46 kettenis Exp $ */ /* @@ -92,6 +92,17 @@ struct tsb_desc { uint64_t td_reserved; }; +struct mmufsa { + uint64_t ift; /* instruction fault type */ + uint64_t ifa; /* instruction fault address */ + uint64_t ifc; /* instruction fault context */ + uint64_t reserved1[5]; /* reserved */ + uint64_t dft; /* data fault type */ + uint64_t dfa; /* data fault address */ + uint64_t dfc; /* data fault context */ + uint64_t reserved2[5]; /* reserved */ +}; + int64_t hv_mmu_tsb_ctx0(uint64_t ntsb, paddr_t tsbptr); int64_t hv_mmu_tsb_ctxnon0(uint64_t ntsb, paddr_t tsbptr); #endif Index: src/sys/arch/sparc64/sparc64/cpu.c diff -u src/sys/arch/sparc64/sparc64/cpu.c:1.129 src/sys/arch/sparc64/sparc64/cpu.c:1.130 --- src/sys/arch/sparc64/sparc64/cpu.c:1.129 Wed Dec 28 19:16:25 2016 +++ src/sys/arch/sparc64/sparc64/cpu.c Fri Feb 10 23:26:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.129 2016/12/28 19:16:25 martin Exp $ */ +/* $NetBSD: cpu.c,v 1.130 2017/02/10 23:26:23 palle Exp $ */ /* * Copyright (c) 1996 @@ -52,7 +52,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.129 2016/12/28 19:16:25 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130 2017/02/10 23:26:23 palle Exp $"); #include "opt_multiprocessor.h" @@ -355,7 +355,7 @@ alloc_cpuinfo(u_int cpu_node) cpi->ci_paddr = pa0; cpi->ci_self = cpi; if (CPU_ISSUN4V) - cpi->ci_mmfsa = pa0; + cpi->ci_mmufsa = pa0; cpi->ci_node = cpu_node; cpi->ci_idepth = -1; memset(cpi->ci_intrpending, -1, sizeof(cpi->ci_intrpending)); Index: src/sys/arch/sparc64/sparc64/genassym.cf diff -u src/sys/arch/sparc64/sparc64/genassym.cf:1.80 src/sys/arch/sparc64/sparc64/genassym.cf:1.81 --- src/sys/arch/sparc64/sparc64/genassym.cf:1.80 Fri Jan 27 21:35:38 2017 +++ src/sys/arch/sparc64/sparc64/genassym.cf Fri Feb 10 23:26:23 2017 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.80 2017/01/27 21:35:38 palle Exp $ +# $NetBSD: genassym.cf,v 1.81 2017/02/10 23:26:23 palle Exp $ # # Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -181,7 +181,7 @@ define CI_TICK_IH offsetof(struct cpu_in define CI_CTXBUSY offsetof(struct cpu_info, ci_ctxbusy) define CI_TSB_DMMU offsetof(struct cpu_info, ci_tsb_dmmu) define CI_TSB_IMMU offsetof(struct cpu_info, ci_tsb_immu) -define CI_MMFSA offsetof(struct cpu_info, ci_mmfsa) +define CI_MMUFSA offsetof(struct cpu_info, ci_mmufsa) define CI_TSB_DESC offsetof(struct cpu_info, ci_tsb_desc) define CI_CPUMQ offsetof(struct cpu_info, ci_cpumq) define CI_DEVMQ offsetof(struct cpu_info, ci_devmq) Index: src/sys/arch/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.407 src/sys/arch/sparc64/sparc64/locore.s:1.408 --- src/sys/arch/sparc64/sparc64/locore.s:1.407 Mon Jan 30 21:24:33 2017 +++ src/sys/arch/sparc64/sparc64/locore.s Fri Feb 10 23:26:23 2017 @@
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Sun Feb 5 20:08:35 UTC 2017 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update TODO list to reflect the current state - TRAP_SETUP() was adapted to handle both sun4u and sun4v systems in version 1.404 of locore.s To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.20 src/sys/arch/sparc64/doc/TODO:1.21 --- src/sys/arch/sparc64/doc/TODO:1.20 Fri Aug 19 19:02:07 2016 +++ src/sys/arch/sparc64/doc/TODO Sun Feb 5 20:08:35 2017 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.20 2016/08/19 19:02:07 palle Exp $ */ + /* $NetBSD: TODO,v 1.21 2017/02/05 20:08:35 palle Exp $ */ Things to be done: @@ -27,7 +27,6 @@ sun4v: - vpci.c/vpcivar.h: cleanup FIXMEs - interrups not handled properly (com at ebus only...) - mpt(4) complains: mpt0: Phy 0: Link Status Unknown -- locore.s: TRAP_SETUP() - sun4u specific ASI_DMMU - man pages for drivers imported from OpenBSD lke vpci, vbus, cbus, vdsk, ldc etc. - vdsk and ldc drivers: code maked with OPENBSD_BUSDMA - make the bus_dma stuff work properly
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Mon Jan 30 21:24:33 UTC 2017 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: Hook up syscall handling to the trap table. Verified using qemu for both sun4u and sun4v. To generate a diff of this commit: cvs rdiff -u -r1.406 -r1.407 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.406 src/sys/arch/sparc64/sparc64/locore.s:1.407 --- src/sys/arch/sparc64/sparc64/locore.s:1.406 Fri Jan 27 21:35:38 2017 +++ src/sys/arch/sparc64/sparc64/locore.s Mon Jan 30 21:24:33 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.406 2017/01/27 21:35:38 palle Exp $ */ +/* $NetBSD: locore.s,v 1.407 2017/01/30 21:24:33 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -1137,7 +1137,7 @@ _C_LABEL(trapbase_sun4v): sun4v_trap_entry_spill_fill_fail 1 ! 0x0f4 fill_5_other sun4v_trap_entry_spill_fill_fail 1 ! 0x0f8 fill_6_other sun4v_trap_entry_spill_fill_fail 1 ! 0x0fc fill_7_other - sun4v_trap_entry 1 ! 0x100 + SYSCALL ! 0x100 = syscall BPT ! 0x101 = pseudo breakpoint instruction sun4v_trap_entry 254 ! 0x102-0x1ff ! @@ -3676,7 +3676,21 @@ syscall_setup: sth %o1, [%sp + CC64FSZ + STKB + TF_TT]! debug #endif - wrpr %g0, PSTATE_KERN, %pstate ! Get back to normal globals + ! Get back to normal globals +#ifdef SUN4V + sethi %hi(cputyp), %g5 + ld [%g5 + %lo(cputyp)], %g5 + cmp %g5, CPU_SUN4V + bne,pt %icc, 1f + nop + NORMAL_GLOBALS_SUN4V + ba 2f + nop +1: +#endif + NORMAL_GLOBALS_SUN4U +2: + stx %g1, [%sp + CC64FSZ + STKB + TF_G + ( 1*8)] mov %g1, %o1 ! code rdpr %tpc, %o2 ! (pc)
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Fri Jan 27 21:35:38 UTC 2017 Modified Files: src/sys/arch/sparc64/sparc64: genassym.cf locore.s Log Message: sun4v: implement missing handling of itsb traps 0x008 and 0x009. Based on code from OpenBSD. Tested using qemu. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/arch/sparc64/sparc64/genassym.cf cvs rdiff -u -r1.405 -r1.406 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/genassym.cf diff -u src/sys/arch/sparc64/sparc64/genassym.cf:1.79 src/sys/arch/sparc64/sparc64/genassym.cf:1.80 --- src/sys/arch/sparc64/sparc64/genassym.cf:1.79 Tue May 17 19:43:28 2016 +++ src/sys/arch/sparc64/sparc64/genassym.cf Fri Jan 27 21:35:38 2017 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.79 2016/05/17 19:43:28 palle Exp $ +# $NetBSD: genassym.cf,v 1.80 2017/01/27 21:35:38 palle Exp $ # # Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -149,6 +149,7 @@ export SUN4U_TTE_P export SUN4U_TTE_EXEC export SUN4V_TLB_ACCESS export SUN4V_TLB_MODIFY +export SUN4V_TLB_EXEC export SUN4V_TLB_W export SUN4V_TLB_TSB_LOCK Index: src/sys/arch/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.405 src/sys/arch/sparc64/sparc64/locore.s:1.406 --- src/sys/arch/sparc64/sparc64/locore.s:1.405 Sat Jan 7 20:19:09 2017 +++ src/sys/arch/sparc64/sparc64/locore.s Fri Jan 27 21:35:38 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.405 2017/01/07 20:19:09 palle Exp $ */ +/* $NetBSD: locore.s,v 1.406 2017/01/27 21:35:38 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -1076,7 +1076,10 @@ _C_LABEL(trapbase_sun4v): ! ! trap level 0 ! - sun4v_trap_entry 36 ! 0x000-0x023 + sun4v_trap_entry 8 ! 0x000-0x007 + VTRAP(T_INST_EXCEPT, sun4v_tl0_itsb_miss) ! 0x008 - inst except + VTRAP(T_TEXTFAULT, sun4v_tl0_itsb_miss) ! 0x009 - inst MMU miss + sun4v_trap_entry 26 ! 0x00a-0x023 CLEANWIN0 ! 0x24-0x27 = clean window sun4v_trap_entry 9 ! 0x028-0x030 VTRAP(T_DATA_MMU_MISS, sun4v_dtsb_miss) ! 0x031 = data MMU miss @@ -2819,7 +2822,7 @@ sun4v_dtsb_miss: btst SUN4V_TLB_ACCESS, %g4 ! Need to update access bit? bne,pt %xcc, 2f nop - casxa [%g6] ASI_PHYS_CACHED, %g4, %g7 ! and write it out + casxa [%g6] ASI_PHYS_CACHED, %g4, %g7 ! and write it out cmp %g4, %g7 bne,pn %xcc, 1b or %g4, SUN4V_TLB_ACCESS, %g4 ! Update the access bit @@ -2845,8 +2848,8 @@ sun4v_dtsb_miss: membar #StoreStore - STPTR %g4, [%g2 + 8] ! store TTE data - STPTR %g1, [%g2] ! store TTE tag + STPTR %g4, [%g2 + 8] ! store TTE data + STPTR %g1, [%g2] ! store TTE tag retry NOTREACHED @@ -3007,6 +3010,139 @@ sun4v_tl0_dtsb_prot: retry NOTREACHED + +sun4v_tl0_itsb_miss: + GET_MMFSA %g1! MMU Fault status area + add %g1, 0x8, %g3 + LDPTRA [%g3] ASI_PHYS_CACHED, %g3 ! Instruction fault address + add %g1, 0x10, %g6 + LDPTRA [%g6] ASI_PHYS_CACHED, %g6 ! Data fault context + + GET_CTXBUSY %g4 + sllx %g6, 3, %g6 ! Make it into an offset into ctxbusy + LDPTR [%g4 + %g6], %g4 ! Load up our page table. + + srax %g3, HOLESHIFT, %g5 ! Check for valid address + brz,pt %g5, 0f! Should be zero or -1 + inc %g5! Make -1 -> 0 + brnz,pn %g5, sun4v_texttrap ! Error! In hole! +0: + srlx %g3, STSHIFT, %g6 + and %g6, STMASK, %g6 ! Index into pm_segs + sll %g6, 3, %g6 + add %g4, %g6, %g4 + LDPTRA [%g4] ASI_PHYS_CACHED, %g4 ! Load page directory pointer + + srlx %g3, PDSHIFT, %g6 + and %g6, PDMASK, %g6 + sll %g6, 3, %g6 + brz,pn %g4, sun4v_texttrap ! NULL entry? check somewhere else + add %g4, %g6, %g4 + LDPTRA [%g4] ASI_PHYS_CACHED, %g4 ! Load page table pointer + + srlx %g3, PTSHIFT, %g6 ! Convert to ptab offset + and %g6, PTMASK, %g6 + sll %g6, 3, %g6 + brz,pn %g4, sun4v_texttrap ! NULL entry? check somewhere else + add %g4, %g6, %g6 +1: + LDPTRA [%g6] ASI_PHYS_CACHED, %g4 ! Fetch TTE + brgez,pn %g4, sun4v_texttrap ! Entry invalid? Punt + or %g4, SUN4V_TLB_ACCESS, %g7 ! Update the access bit + + btst SUN4V_TLB_EXEC, %g4 ! Need to update exec bit? + bz,pn %xcc, sun4v_texttrap + nop + btst SUN4V_TLB_ACCESS, %g4 ! Need to update access bit? + bne,pt %xcc, 2f + nop + casxa [%g6] ASI_PHYS_CACHED, %g4, %g7 ! and write it out + cmp %g4, %g7 + bne,pn %xcc, 1b + or %g4, SUN4V_TLB_ACCESS, %g4 ! Update the modified bit +2: + GET_TSB_DMMU %g2 + + mov %g1, %g7 + /* Construct TSB tag word. */ + add %g1, 0x10, %g6 + LDPTRA [%g6] ASI_PHYS_CACHED, %g6 ! Instruction fault context + mov %g3, %g1 ! Instruction fault address + srlx %g1, 22, %g1 ! 63..22 of virt addr + sllx %g6, 48, %g6 ! context_id in 63..48 + or %g1, %g6, %g1 ! construct TTE tag + + srlx %g3, PTSHIFT, %g3 + sethi %hi(_C_LABEL(tsbsize)), %g5 + mov 512, %g6 + ld [%g5 + %lo(_C_LABEL(tsbsize))], %g5 + sllx %g6, %g5, %g5 ! %g5 = 512 << tsbsize = TSBENTS + sub %g5, 1, %g5
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Sat Jan 7 20:19:09 UTC 2017 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: slowtrap() now selects normal globals properly on both sun4u and sun4v platforms. Verified using qemu for both sun4u and sun4v systems To generate a diff of this commit: cvs rdiff -u -r1.404 -r1.405 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.404 src/sys/arch/sparc64/sparc64/locore.s:1.405 --- src/sys/arch/sparc64/sparc64/locore.s:1.404 Thu Jan 5 20:37:06 2017 +++ src/sys/arch/sparc64/sparc64/locore.s Sat Jan 7 20:19:09 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.404 2017/01/05 20:37:06 palle Exp $ */ +/* $NetBSD: locore.s,v 1.405 2017/01/07 20:19:09 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -3151,7 +3151,20 @@ Lslowtrap_reenter: mov %g2, %o2 ! (pc) sth %o1, [%sp + CC64FSZ + STKB + TF_TT]! debug - wrpr %g0, PSTATE_KERN, %pstate ! Get back to normal globals + ! Get back to normal globals +#ifdef SUN4V + sethi %hi(cputyp), %g5 + ld [%g5 + %lo(cputyp)], %g5 + cmp %g5, CPU_SUN4V + bne,pt %icc, 1f + nop + NORMAL_GLOBALS_SUN4V + ba 2f + nop +1: +#endif + NORMAL_GLOBALS_SUN4U +2: stx %g1, [%sp + CC64FSZ + STKB + TF_G + (1*8)] stx %g2, [%sp + CC64FSZ + STKB + TF_G + (2*8)] add %sp, CC64FSZ + STKB, %o0 ! ()
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Thu Jan 5 20:37:06 UTC 2017 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: TRAP_SETUP() updated to set mmu context id properly for both sun4v and sun4u platforms. Verified using qemu for both sun4u and sun4v systems To generate a diff of this commit: cvs rdiff -u -r1.403 -r1.404 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.403 src/sys/arch/sparc64/sparc64/locore.s:1.404 --- src/sys/arch/sparc64/sparc64/locore.s:1.403 Wed Jan 4 20:19:29 2017 +++ src/sys/arch/sparc64/sparc64/locore.s Thu Jan 5 20:37:06 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.403 2017/01/04 20:19:29 palle Exp $ */ +/* $NetBSD: locore.s,v 1.404 2017/01/05 20:37:06 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -1461,7 +1461,7 @@ intr_setup_msg: wrpr %g0, %g5, %otherwin; \ wrpr %g0, WSTATE_KERN, %wstate; /* Enable kernel mode window traps -- now we can trap again */ \ \ - stxa %g0, [%g7] ASI_DMMU; /* Switch MMU to kernel primary context */ \ + SET_MMU_CONTEXTID %g0, %g7,%g5; /* Switch MMU to kernel primary context */ \ sethi %hi(KERNBASE), %g5; \ flush %g5; /* Some convenient address that won't trap */ \ 1: @@ -1577,7 +1577,7 @@ intr_setup_msg: wrpr %g0, %g5, %otherwin; \ wrpr %g0, WSTATE_KERN, %wstate; /* Enable kernel mode window traps -- now we can trap again */ \ \ - stxa %g0, [%g7] ASI_DMMU; /* Switch MMU to kernel primary context */ \ + SET_MMU_CONTEXTID %g0, %g7, %g5; /* Switch MMU to kernel primary context */ \ sethi %hi(KERNBASE), %g5; \ flush %g5; /* Some convenient address that won't trap */ \ 1:
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Wed Jan 4 20:19:29 UTC 2017 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: make debugging kernel bringup a bit easier by using the slowtrap code path for currently unhandled trap level 1 trap entries 0x00-0x23 and 0x28-0x30 To generate a diff of this commit: cvs rdiff -u -r1.402 -r1.403 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.402 src/sys/arch/sparc64/sparc64/locore.s:1.403 --- src/sys/arch/sparc64/sparc64/locore.s:1.402 Thu Dec 29 20:59:31 2016 +++ src/sys/arch/sparc64/sparc64/locore.s Wed Jan 4 20:19:29 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.402 2016/12/29 20:59:31 palle Exp $ */ +/* $NetBSD: locore.s,v 1.403 2017/01/04 20:19:29 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -1140,9 +1140,9 @@ _C_LABEL(trapbase_sun4v): ! ! trap level 1 ! - sun4v_trap_entry_fail 36! 0x000-0x023 + sun4v_trap_entry 36 ! 0x000-0x023 CLEANWIN1 ! 0x24-0x27 = clean window - sun4v_trap_entry_fail 9 ! 0x028-0x030 + sun4v_trap_entry 9 ! 0x028-0x030 VTRAP(T_DATA_MMU_MISS, sun4v_dtsb_miss) ! 0x031 = data MMU miss sun4v_trap_entry 78 ! 0x032-0x07f SPILL64(uspill8_sun4vt1,ASI_AIUS) ! 0x080 spill_0_normal -- save user windows
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Thu Dec 29 20:59:31 UTC 2016 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: make debugging kernel bringup a bit easier by using the slowtrap code path for currently unhandled trap level 1 trap entries 0x32-0x7f To generate a diff of this commit: cvs rdiff -u -r1.401 -r1.402 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.401 src/sys/arch/sparc64/sparc64/locore.s:1.402 --- src/sys/arch/sparc64/sparc64/locore.s:1.401 Tue Sep 20 08:56:34 2016 +++ src/sys/arch/sparc64/sparc64/locore.s Thu Dec 29 20:59:31 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.401 2016/09/20 08:56:34 nakayama Exp $ */ +/* $NetBSD: locore.s,v 1.402 2016/12/29 20:59:31 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -1144,7 +1144,7 @@ _C_LABEL(trapbase_sun4v): CLEANWIN1 ! 0x24-0x27 = clean window sun4v_trap_entry_fail 9 ! 0x028-0x030 VTRAP(T_DATA_MMU_MISS, sun4v_dtsb_miss) ! 0x031 = data MMU miss - sun4v_trap_entry_fail 78! 0x032-0x07f + sun4v_trap_entry 78 ! 0x032-0x07f SPILL64(uspill8_sun4vt1,ASI_AIUS) ! 0x080 spill_0_normal -- save user windows SPILL32(uspill4_sun4vt1,ASI_AIUS) ! 0x084 spill_1_normal SPILLBOTH(uspill8_sun4vt1,uspill4_sun4vt1,ASI_AIUS) ! 0x088 spill_2_normal
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Tue Aug 23 19:57:01 UTC 2016 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: rework sun4v_datatrap so it works properly when running on a T2-based system like T5120 - for some reason %tl is 0 when entering sun4v_datatrap causing a crash (sir instruction), so ignore the %tl value for now upon entry to sun4v_datatrap - with this fix both T1 and T2 based systems reach the same point - hangs in rft_user after the init process is started To generate a diff of this commit: cvs rdiff -u -r1.399 -r1.400 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.399 src/sys/arch/sparc64/sparc64/locore.s:1.400 --- src/sys/arch/sparc64/sparc64/locore.s:1.399 Mon Jul 18 19:51:06 2016 +++ src/sys/arch/sparc64/sparc64/locore.s Tue Aug 23 19:57:01 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.399 2016/07/18 19:51:06 palle Exp $ */ +/* $NetBSD: locore.s,v 1.400 2016/08/23 19:57:01 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -2851,15 +2851,7 @@ sun4v_dtsb_miss: retry NOTREACHED -sun4v_datatrap: ! branch further based on trap level - rdpr %tl, %g1 - dec %g1 - beq sun4v_datatrap_tl0 - nop - ba sun4v_datatrap_tl1 - nop - -sun4v_datatrap_tl0: +sun4v_datatrap: GET_MMFSA %g3! MMU Fault status area add %g3, 0x48, %g1 LDPTRA [%g1] ASI_PHYS_CACHED, %g1 ! Data fault address @@ -2918,10 +2910,6 @@ sun4v_datatrap_tl0: nop NOTREACHED -sun4v_datatrap_tl1: - /* XXX missing implementaion */ - sir - sun4v_tl0_dtsb_prot: GET_MMFSA %g1! MMU Fault status area add %g1, 0x48, %g3
CVS commit: src/sys/arch/sparc64/dev
Module Name:src Committed By: palle Date: Fri Aug 19 19:40:27 UTC 2016 Added Files: src/sys/arch/sparc64/dev: viovar.h Log Message: sun4v: vdsk and ldc drivers - from OpenBSD, but heavily adapted to NetBSD scsipi - access to a virtual disk served from a ldom primary domain now works To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc64/dev/viovar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/arch/sparc64/dev/viovar.h diff -u /dev/null src/sys/arch/sparc64/dev/viovar.h:1.1 --- /dev/null Fri Aug 19 19:40:27 2016 +++ src/sys/arch/sparc64/dev/viovar.h Fri Aug 19 19:40:27 2016 @@ -0,0 +1,128 @@ +/* $NetBSD: viovar.h,v 1.1 2016/08/19 19:40:27 palle Exp $ */ +/* $OpenBSD: viovar.h,v 1.2 2009/01/12 19:52:39 kettenis Exp $ */ +/* + * Copyright (c) 2009 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Virtual IO device protocol. + */ + +struct vio_msg_tag { + uint8_t type; + uint8_t stype; + uint16_t stype_env; + uint32_t sid; +}; + +struct vio_msg { + uint64_t hdr; + uint8_t type; + uint8_t stype; + uint16_t stype_env; + uint32_t sid; + uint16_t major; + uint16_t minor; + uint8_t dev_class; +}; + +/* Message types. */ +#define VIO_TYPE_CTRL 0x01 +#define VIO_TYPE_DATA 0x02 +#define VIO_TYPE_ERR 0x04 + +/* Sub-Message types. */ +#define VIO_SUBTYPE_INFO 0x01 +#define VIO_SUBTYPE_ACK 0x02 +#define VIO_SUBTYPE_NACK 0x04 + +/* Sub-Type envelopes. */ +#define VIO_VER_INFO 0x0001 +#define VIO_ATTR_INFO 0x0002 +#define VIO_DRING_REG 0x0003 +#define VIO_DRING_UNREG 0x0004 +#define VIO_RDX 0x0005 + +#define VIO_PKT_DATA 0x0040 +#define VIO_DESC_DATA 0x0041 +#define VIO_DRING_DATA 0x0042 + +struct vio_ver_info { + struct vio_msg_tag tag; + uint16_t major; + uint16_t minor; + uint8_t dev_class; + uint8_t _reserved1[3]; + uint64_t _reserved2[5]; +}; + +/* Device types. */ +#define VDEV_NETWORK 0x01 +#define VDEV_NETWORK_SWITCH 0x02 +#define VDEV_DISK 0x03 +#define VDEV_DISK_SERVER 0x04 + +struct vio_dring_reg { + struct vio_msg_tag tag; + uint64_t dring_ident; + uint32_t num_descriptors; + uint32_t descriptor_size; + uint16_t options; + uint16_t _reserved; + uint32_t ncookies; + struct ldc_cookie cookie[1]; +}; + +/* Ring options. */ +#define VIO_TX_RING 0x0001 +#define VIO_RX_RING 0x0002 + +/* Transfer modes. */ +#define VIO_PKT_MODE 0x01 +#define VIO_DESC_MODE 0x02 +#define VIO_DRING_MODE 0x03 + +struct vio_dring_hdr { + uint8_t dstate; + uint8_t ack: 1; + uint16_t _reserved[3]; +}; + +/* Descriptor states. */ +#define VIO_DESC_FREE 0x01 +#define VIO_DESC_READY 0x02 +#define VIO_DESC_ACCEPTED 0x03 +#define VIO_DESC_DONE 0x04 + +struct vio_dring_msg { + struct vio_msg_tag tag; + uint64_t seq_no; + uint64_t dring_ident; + uint32_t start_idx; + uint32_t end_idx; + uint8_t proc_state; + uint8_t _reserved1[7]; + uint64_t _reserved2[2]; +}; + +/* Ring states. */ +#define VIO_DP_ACTIVE 0x01 +#define VIO_DP_STOPPED 0x02 + +struct vio_rdx { + struct vio_msg_tag tag; + uint64_t _reserved[6]; +}; +
CVS commit: src/sys/arch/sparc64
Module Name:src Committed By: palle Date: Fri Aug 19 19:02:07 UTC 2016 Modified Files: src/sys/arch/sparc64/conf: GENERIC files.sparc64 src/sys/arch/sparc64/doc: TODO src/sys/arch/sparc64/sparc64: autoconf.c Added Files: src/sys/arch/sparc64/dev: ldc.c ldcvar.h vdsk.c Log Message: sun4v: vdsk and ldc drivers - from OpenBSD, but heavily adapted to NetBSD scsipi - access to a virtual disk served from a ldom primary domain now works To generate a diff of this commit: cvs rdiff -u -r1.191 -r1.192 src/sys/arch/sparc64/conf/GENERIC cvs rdiff -u -r1.151 -r1.152 src/sys/arch/sparc64/conf/files.sparc64 cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc64/dev/ldc.c \ src/sys/arch/sparc64/dev/ldcvar.h src/sys/arch/sparc64/dev/vdsk.c cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc64/doc/TODO cvs rdiff -u -r1.207 -r1.208 src/sys/arch/sparc64/sparc64/autoconf.c 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/sparc64/conf/GENERIC diff -u src/sys/arch/sparc64/conf/GENERIC:1.191 src/sys/arch/sparc64/conf/GENERIC:1.192 --- src/sys/arch/sparc64/conf/GENERIC:1.191 Wed Jun 22 20:12:59 2016 +++ src/sys/arch/sparc64/conf/GENERIC Fri Aug 19 19:02:07 2016 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.191 2016/06/22 20:12:59 palle Exp $ +# $NetBSD: GENERIC,v 1.192 2016/08/19 19:02:07 palle Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/sparc64/conf/std.sparc64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.191 $" +#ident "GENERIC-$Revision: 1.192 $" maxusers 64 @@ -277,6 +277,7 @@ timer* at mainbus0# sun4c # Virtual devices for sun4v systems. vrtc0 at vbus? +vdsk* at cbus? Serial port configuration Index: src/sys/arch/sparc64/conf/files.sparc64 diff -u src/sys/arch/sparc64/conf/files.sparc64:1.151 src/sys/arch/sparc64/conf/files.sparc64:1.152 --- src/sys/arch/sparc64/conf/files.sparc64:1.151 Wed Jun 22 20:12:59 2016 +++ src/sys/arch/sparc64/conf/files.sparc64 Fri Aug 19 19:02:07 2016 @@ -1,4 +1,4 @@ -# $NetBSD: files.sparc64,v 1.151 2016/06/22 20:12:59 palle Exp $ +# $NetBSD: files.sparc64,v 1.152 2016/08/19 19:02:07 palle Exp $ # @(#)files.sparc64 8.1 (Berkeley) 7/19/93 # sparc64-specific configuration info @@ -325,3 +325,11 @@ file dev/ofw/ofw_subr.c device vrtc attach vrtc at vbus file arch/sparc64/dev/vrtc.c vrtc + +define ldc +file arch/sparc64/dev/ldc.c ldc + +# Virtual disk +device vdsk: ldc, scsi +attach vdsk at cbus +file arch/sparc64/dev/vdsk.c vdsk Index: src/sys/arch/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.19 src/sys/arch/sparc64/doc/TODO:1.20 --- src/sys/arch/sparc64/doc/TODO:1.19 Fri Jun 17 21:52:27 2016 +++ src/sys/arch/sparc64/doc/TODO Fri Aug 19 19:02:07 2016 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.19 2016/06/17 21:52:27 palle Exp $ */ + /* $NetBSD: TODO,v 1.20 2016/08/19 19:02:07 palle Exp $ */ Things to be done: @@ -28,5 +28,6 @@ sun4v: - interrups not handled properly (com at ebus only...) - mpt(4) complains: mpt0: Phy 0: Link Status Unknown - locore.s: TRAP_SETUP() - sun4u specific ASI_DMMU -- man pages for drivers imported from OpenBSD lke vpci, vbus etc. +- man pages for drivers imported from OpenBSD lke vpci, vbus, cbus, vdsk, ldc etc. +- vdsk and ldc drivers: code maked with OPENBSD_BUSDMA - make the bus_dma stuff work properly Index: src/sys/arch/sparc64/sparc64/autoconf.c diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.207 src/sys/arch/sparc64/sparc64/autoconf.c:1.208 --- src/sys/arch/sparc64/sparc64/autoconf.c:1.207 Wed Dec 16 08:01:19 2015 +++ src/sys/arch/sparc64/sparc64/autoconf.c Fri Aug 19 19:02:07 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.207 2015/12/16 08:01:19 jdc Exp $ */ +/* $NetBSD: autoconf.c,v 1.208 2016/08/19 19:02:07 palle Exp $ */ /* * Copyright (c) 1996 @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.207 2015/12/16 08:01:19 jdc Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.208 2016/08/19 19:02:07 palle Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -93,6 +93,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v #include #include #include +#include #include #include @@ -980,6 +981,11 @@ device_register(device_t dev, void *aux) dev_path_drive_match(dev, ofnode, adev->adev_channel*2+ adev->adev_drv_data->drive, 0, 0); return; + } else if (device_is_a(dev, "vdsk")) { + struct cbus_attach_args *ca = aux; + ofnode = ca->ca_node; + /* Ensure that the devices ofnode is stored for later use */ + device_setofnode(dev, ofnode); } if (busdev == NULL) @@ -1317,6 +1323,49 @@ device_register_post_config(device_t dev } } } + + if (CPU_ISSUN4V) { + + /* + * Special sun4v handling in case the kernel is running in a + * secondary logical domain + * + * The bootpath looks something like this: +
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Sun Aug 7 19:35:43 UTC 2016 Modified Files: src/sys/arch/sparc64/sparc64: copy.S Log Message: Make comment more readable - no functional changes To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/sparc64/copy.S 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/sparc64/sparc64/copy.S diff -u src/sys/arch/sparc64/sparc64/copy.S:1.6 src/sys/arch/sparc64/sparc64/copy.S:1.7 --- src/sys/arch/sparc64/sparc64/copy.S:1.6 Sun Nov 22 10:18:14 2015 +++ src/sys/arch/sparc64/sparc64/copy.S Sun Aug 7 19:35:43 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: copy.S,v 1.6 2015/11/22 10:18:14 martin Exp $ */ +/* $NetBSD: copy.S,v 1.7 2016/08/07 19:35:43 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -432,7 +432,7 @@ Lcopyout_start: .empty 0: inc %o0 - ldsb [%o0 - 1], %o4! (++dst)[-1] = *src++; + ldsb [%o0 - 1], %o4 ! (++dst)[-1] = *src++; stba %o4, [%o1] %asi deccc %o2 bge 0b
CVS commit: src/share/man/man9
Module Name:src Committed By: palle Date: Fri Jul 29 19:27:45 UTC 2016 Modified Files: src/share/man/man9: scsipi.9 Log Message: scsipi(9): Removed duplicate "for" To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/share/man/man9/scsipi.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/scsipi.9 diff -u src/share/man/man9/scsipi.9:1.27 src/share/man/man9/scsipi.9:1.28 --- src/share/man/man9/scsipi.9:1.27 Wed Jun 1 08:17:47 2016 +++ src/share/man/man9/scsipi.9 Fri Jul 29 19:27:45 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: scsipi.9,v 1.27 2016/06/01 08:17:47 wiz Exp $ +.\" $NetBSD: scsipi.9,v 1.28 2016/07/29 19:27:45 palle Exp $ .\" .\" .\" Copyright (c) 2001 Manuel Bouyer. @@ -339,7 +339,7 @@ This request is called from the kernel c .Fa arg must be ignored. .It Dv ADAPTER_REQ_SET_XFER_MODE -set the xfer mode for a for I_T Nexus. +set the xfer mode for a I_T Nexus. This will be called once all LUNs of a target have been probed. .Fa arg points to a
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Mon Jul 18 19:51:06 UTC 2016 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: handle device interrupts properly - both legacy (sysino) and cookies To generate a diff of this commit: cvs rdiff -u -r1.398 -r1.399 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.398 src/sys/arch/sparc64/sparc64/locore.s:1.399 --- src/sys/arch/sparc64/sparc64/locore.s:1.398 Sat Jun 4 21:24:41 2016 +++ src/sys/arch/sparc64/sparc64/locore.s Mon Jul 18 19:51:06 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.398 2016/06/04 21:24:41 palle Exp $ */ +/* $NetBSD: locore.s,v 1.399 2016/07/18 19:51:06 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -3826,9 +3826,9 @@ sun4v_dev_mondo: stxa %g2, [%g1] ASI_QUEUE ! ajust head index value membar #Sync - cmp %g5, MAXINTNUM ! out of bounds? - bgeu,pn %xcc, 2f - nop ! no just continue + cmp %g5, MAXINTNUM ! Handle both sun4v legacy (sysino) and cookies. + bgeu,pn %xcc, 1f ! See UltraSPARC Virtual Machine Specification + nop ! version 3 chapter 6 (Interrupt model) sethi %hi(_C_LABEL(intrlev)), %g3 sllx %g5, PTRSHFT, %g5 ! Calculate entry number @@ -3840,8 +3840,7 @@ sun4v_dev_mondo: ba,a 3b ! log if invalid handle nop -2: - sir! out of bounds - crash + /* * Ultra1 and Ultra2 CPUs use soft interrupts for everything. What we do * on a soft interrupt, is we should check which bits in SOFTINT(%asr22) @@ -4646,7 +4645,6 @@ badregs: rdpr %cwp, %g7 ! Find our cur window andn %g1, CWP, %g1 ! Clear it from %tstate wrpr %g1, %g7, %tstate ! Set %tstate with %cwp - mov CTX_SECONDARY, %g1 ! Restore the user context GET_MMU_CONTEXTID %g4, %g1, %g3 mov CTX_PRIMARY, %g2
CVS commit: src/sys/arch/sparc64/dev
Module Name:src Committed By: palle Date: Mon Jul 18 19:32:44 UTC 2016 Modified Files: src/sys/arch/sparc64/dev: cbus.c Log Message: sun4v: reset cbus debug back to zero To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc64/dev/cbus.c 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/sparc64/dev/cbus.c diff -u src/sys/arch/sparc64/dev/cbus.c:1.1 src/sys/arch/sparc64/dev/cbus.c:1.2 --- src/sys/arch/sparc64/dev/cbus.c:1.1 Wed Jun 22 20:13:51 2016 +++ src/sys/arch/sparc64/dev/cbus.c Mon Jul 18 19:32:44 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cbus.c,v 1.1 2016/06/22 20:13:51 palle Exp $ */ +/* $NetBSD: cbus.c,v 1.2 2016/07/18 19:32:44 palle Exp $ */ /* $OpenBSD: cbus.c,v 1.15 2015/09/27 11:29:20 kettenis Exp $ */ /* * Copyright (c) 2008 Mark Kettenis @@ -34,7 +34,7 @@ #ifdef DEBUG #define CBUSDB_AC 0x01 #define CBUSDB_INTR 0x02 -int cbus_debug = 0x00|CBUSDB_INTR; +int cbus_debug = 0x00; #define DPRINTF(l, s) do { if (cbus_debug & l) printf s; } while (0) #else #define DPRINTF(l, s)
CVS commit: src/sys/arch/sparc64/include
Module Name:src Committed By: palle Date: Sat Jun 25 13:52:04 UTC 2016 Modified Files: src/sys/arch/sparc64/include: cpu.h Log Message: sun4v: fix previous fix - no need to protect "struct inthand" with "#if defined(_KERNEL)" + use proper include file name - sparc64/bus_defs.h -> machine/bus_defs.h To generate a diff of this commit: cvs rdiff -u -r1.121 -r1.122 src/sys/arch/sparc64/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/sparc64/include/cpu.h diff -u src/sys/arch/sparc64/include/cpu.h:1.121 src/sys/arch/sparc64/include/cpu.h:1.122 --- src/sys/arch/sparc64/include/cpu.h:1.121 Thu Jun 23 20:32:40 2016 +++ src/sys/arch/sparc64/include/cpu.h Sat Jun 25 13:52:04 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.121 2016/06/23 20:32:40 palle Exp $ */ +/* $NetBSD: cpu.h,v 1.122 2016/06/25 13:52:04 palle Exp $ */ /* * Copyright (c) 1992, 1993 @@ -68,9 +68,9 @@ #include #include #if defined(_KERNEL) +#include #include #include -#include #endif #ifdef SUN4V #include @@ -349,7 +349,6 @@ void cpu_signotify(struct lwp *); * handler into the list. The handler is called with its (single) * argument, or with a pointer to a clockframe if ih_arg is NULL. */ -#if defined(_KERNEL) struct intrhand { int (*ih_fun)(void *); void *ih_arg; @@ -370,7 +369,6 @@ struct intrhand { uint32_t ih_ivec; char ih_name[32]; /* name for the above */ }; -#endif extern struct intrhand *intrhand[]; extern struct intrhand *intrlev[MAXINTNUM];
CVS commit: src/sys/arch/sparc64/include
Module Name:src Committed By: palle Date: Thu Jun 23 20:32:40 UTC 2016 Modified Files: src/sys/arch/sparc64/include: cpu.h Log Message: sun4v: Fix build issue introduced in previous commit - bus stuff is kernel only, so protect this with _KERNEL To generate a diff of this commit: cvs rdiff -u -r1.120 -r1.121 src/sys/arch/sparc64/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/sparc64/include/cpu.h diff -u src/sys/arch/sparc64/include/cpu.h:1.120 src/sys/arch/sparc64/include/cpu.h:1.121 --- src/sys/arch/sparc64/include/cpu.h:1.120 Wed Jun 22 20:13:00 2016 +++ src/sys/arch/sparc64/include/cpu.h Thu Jun 23 20:32:40 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.120 2016/06/22 20:13:00 palle Exp $ */ +/* $NetBSD: cpu.h,v 1.121 2016/06/23 20:32:40 palle Exp $ */ /* * Copyright (c) 1992, 1993 @@ -63,7 +63,6 @@ #include "opt_lockdebug.h" #endif -#include #include #include #include @@ -71,6 +70,7 @@ #if defined(_KERNEL) #include #include +#include #endif #ifdef SUN4V #include @@ -342,12 +342,14 @@ struct clockframe { */ void cpu_signotify(struct lwp *); + /* * Interrupt handler chains. Interrupt handlers should return 0 for * ``not me'' or 1 (``I took care of it''). intr_establish() inserts a * handler into the list. The handler is called with its (single) * argument, or with a pointer to a clockframe if ih_arg is NULL. */ +#if defined(_KERNEL) struct intrhand { int (*ih_fun)(void *); void *ih_arg; @@ -368,6 +370,7 @@ struct intrhand { uint32_t ih_ivec; char ih_name[32]; /* name for the above */ }; +#endif extern struct intrhand *intrhand[]; extern struct intrhand *intrlev[MAXINTNUM];
CVS commit: src/sys/arch/sparc64/dev
Module Name:src Committed By: palle Date: Wed Jun 22 20:13:51 UTC 2016 Added Files: src/sys/arch/sparc64/dev: cbus.c cbusvar.h Log Message: sun4v: add cbus driver - from OpenBSD To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc64/dev/cbus.c \ src/sys/arch/sparc64/dev/cbusvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/arch/sparc64/dev/cbus.c diff -u /dev/null src/sys/arch/sparc64/dev/cbus.c:1.1 --- /dev/null Wed Jun 22 20:13:51 2016 +++ src/sys/arch/sparc64/dev/cbus.c Wed Jun 22 20:13:51 2016 @@ -0,0 +1,314 @@ +/* $NetBSD: cbus.c,v 1.1 2016/06/22 20:13:51 palle Exp $ */ +/* $OpenBSD: cbus.c,v 1.15 2015/09/27 11:29:20 kettenis Exp $ */ +/* + * Copyright (c) 2008 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include + +#ifdef DEBUG +#define CBUSDB_AC 0x01 +#define CBUSDB_INTR 0x02 +int cbus_debug = 0x00|CBUSDB_INTR; +#define DPRINTF(l, s) do { if (cbus_debug & l) printf s; } while (0) +#else +#define DPRINTF(l, s) +#endif + +struct cbus_softc { + device_t sc_dv; + bus_space_tag_t sc_bustag; + bus_dma_tag_t sc_dmatag; + + uint64_t sc_devhandle; + + /* Machine description. */ + int sc_idx; +}; + +int cbus_match(device_t, cfdata_t, void *); +void cbus_attach(device_t, device_t, void *); +int cbus_print(void *, const char *); + +CFATTACH_DECL_NEW(cbus, sizeof(struct cbus_softc), +cbus_match, cbus_attach, NULL, NULL); + + +void *cbus_intr_establish(bus_space_tag_t, int, int, +int (*)(void *), void *, void (*)(void)); +void cbus_intr_ack(struct intrhand *); +bus_space_tag_t cbus_alloc_bus_tag(struct cbus_softc *, bus_space_tag_t); + +int cbus_get_channel_endpoint(struct cbus_softc *, + struct cbus_attach_args *); + +int +cbus_match(device_t parent, cfdata_t match, void *aux) +{ + struct vbus_attach_args *va = aux; + + if (strcmp(va->va_name, "channel-devices") == 0) + return (1); + + return (0); +} + +void +cbus_attach(device_t parent, device_t self, void *aux) +{ +struct cbus_softc *sc = device_private(self); + struct vbus_attach_args *va = aux; + int node; + int reg; + + sc->sc_bustag = cbus_alloc_bus_tag(sc, va->va_bustag); + sc->sc_dmatag = va->va_dmatag; + + if (OF_getprop(va->va_node, "reg", , sizeof(reg)) != sizeof(reg)) + return; + sc->sc_devhandle = reg; + + printf("\n"); + + sc->sc_idx = mdesc_find(va->va_name, va->va_reg[0]); + if (sc->sc_idx == -1) { + DPRINTF(CBUSDB_AC, ("cbus_attach() - no idx\n")); + return; + } + + for (node = OF_child(va->va_node); node; node = OF_peer(node)) { + struct cbus_attach_args ca; + char buf[32]; + + bzero(, sizeof(ca)); + ca.ca_node = node; + if (OF_getprop(node, "name", buf, sizeof(buf)) <= 0) + continue; + DPRINTF(CBUSDB_AC, ("cbus_attach() - buf %s\n", buf)); + ca.ca_name = buf; + ca.ca_bustag = sc->sc_bustag; + ca.ca_dmatag = sc->sc_dmatag; + prom_getprop(node, "reg", sizeof(*ca.ca_reg), + _nreg, (void **)_reg); + int rc = cbus_get_channel_endpoint(sc, ); + DPRINTF(CBUSDB_AC, ("cbus_attach() - cbus_get_channel_endpoint() %d\n", rc)); + if ( rc != 0) { + continue; + } + + config_found(self, , cbus_print); + + } +} + +int +cbus_print(void *aux, const char *name) +{ + struct cbus_attach_args *ca = aux; + DPRINTF(CBUSDB_AC, ("cbus_print() name %s\n", name)); + + if (name) + printf("\"%s\" at %s", ca->ca_name, name); + if (ca->ca_id != -1) + printf(" chan 0x%llx", (long long unsigned int)ca->ca_id); + return (UNCONF); +} + +int +cbus_intr_setstate(bus_space_tag_t t, uint64_t devino, uint64_t state) +{ + struct cbus_softc *sc = t->cookie; + uint64_t devhandle = sc->sc_devhandle; + int err; + + err = hv_vintr_setstate(devhandle, devino, state); + if (err != H_EOK) + return (-1); + + return (0); +} + +int +cbus_intr_setenabled(bus_space_tag_t t, uint64_t devino, uint64_t enabled) +{ + struct cbus_softc *sc = t->cookie; + uint64_t devhandle = sc->sc_devhandle; + int err; + + err = hv_vintr_setenabled(devhandle, devino, enabled); + if (err != H_EOK) + return (-1); + + return (0); +} + +void *
CVS commit: src/sys/arch/sparc64
Module Name:src Committed By: palle Date: Wed Jun 22 20:13:00 UTC 2016 Modified Files: src/sys/arch/sparc64/conf: GENERIC files.sparc64 src/sys/arch/sparc64/include: cpu.h mdesc.h Log Message: sun4v: add cbus driver - from OpenBSD To generate a diff of this commit: cvs rdiff -u -r1.190 -r1.191 src/sys/arch/sparc64/conf/GENERIC cvs rdiff -u -r1.150 -r1.151 src/sys/arch/sparc64/conf/files.sparc64 cvs rdiff -u -r1.119 -r1.120 src/sys/arch/sparc64/include/cpu.h cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/include/mdesc.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/sparc64/conf/GENERIC diff -u src/sys/arch/sparc64/conf/GENERIC:1.190 src/sys/arch/sparc64/conf/GENERIC:1.191 --- src/sys/arch/sparc64/conf/GENERIC:1.190 Fri Jun 17 21:38:09 2016 +++ src/sys/arch/sparc64/conf/GENERIC Wed Jun 22 20:12:59 2016 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.190 2016/06/17 21:38:09 palle Exp $ +# $NetBSD: GENERIC,v 1.191 2016/06/22 20:12:59 palle Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/sparc64/conf/std.sparc64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.190 $" +#ident "GENERIC-$Revision: 1.191 $" maxusers 64 @@ -248,6 +248,7 @@ ebus* at pci? # ebus devices # XXX 'puc's aren't really bridges, but there's no better place for them here puc* at pci? dev ? function ? # PCI "universal" comm. cards vbus0 at mainbus0 +cbus* at vbus? Standard system devices -- all required for a given architecture Index: src/sys/arch/sparc64/conf/files.sparc64 diff -u src/sys/arch/sparc64/conf/files.sparc64:1.150 src/sys/arch/sparc64/conf/files.sparc64:1.151 --- src/sys/arch/sparc64/conf/files.sparc64:1.150 Fri Jun 17 21:38:09 2016 +++ src/sys/arch/sparc64/conf/files.sparc64 Wed Jun 22 20:12:59 2016 @@ -1,4 +1,4 @@ -# $NetBSD: files.sparc64,v 1.150 2016/06/17 21:38:09 palle Exp $ +# $NetBSD: files.sparc64,v 1.151 2016/06/22 20:12:59 palle Exp $ # @(#)files.sparc64 8.1 (Berkeley) 7/19/93 # sparc64-specific configuration info @@ -73,6 +73,10 @@ device vbus {} attach vbus at mainbus file arch/sparc64/dev/vbus.c vbus +device cbus {} +attach cbus at vbus +file arch/sparc64/dev/cbus.c cbus + device clock: mk48txx attach clock at sbus with mkclock_sbus attach clock at ebus with mkclock_ebus Index: src/sys/arch/sparc64/include/cpu.h diff -u src/sys/arch/sparc64/include/cpu.h:1.119 src/sys/arch/sparc64/include/cpu.h:1.120 --- src/sys/arch/sparc64/include/cpu.h:1.119 Tue May 10 19:24:00 2016 +++ src/sys/arch/sparc64/include/cpu.h Wed Jun 22 20:13:00 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.119 2016/05/10 19:24:00 palle Exp $ */ +/* $NetBSD: cpu.h,v 1.120 2016/06/22 20:13:00 palle Exp $ */ /* * Copyright (c) 1992, 1993 @@ -63,6 +63,7 @@ #include "opt_lockdebug.h" #endif +#include #include #include #include @@ -362,6 +363,7 @@ struct intrhand { volatile uint64_t *ih_map; /* Interrupt map reg */ volatile uint64_t *ih_clr; /* clear interrupt reg */ void (*ih_ack)(struct intrhand *); /* ack interrupt function */ + bus_space_tag_t ih_bus; /* parent bus */ struct evcnt ih_cnt; /* counter for vmstat */ uint32_t ih_ivec; char ih_name[32]; /* name for the above */ Index: src/sys/arch/sparc64/include/mdesc.h diff -u src/sys/arch/sparc64/include/mdesc.h:1.4 src/sys/arch/sparc64/include/mdesc.h:1.5 --- src/sys/arch/sparc64/include/mdesc.h:1.4 Sun Sep 6 16:45:09 2015 +++ src/sys/arch/sparc64/include/mdesc.h Wed Jun 22 20:13:00 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: mdesc.h,v 1.4 2015/09/06 16:45:09 martin Exp $ */ +/* $NetBSD: mdesc.h,v 1.5 2016/06/22 20:13:00 palle Exp $ */ /* $OpenBSD: mdesc.h,v 1.3 2014/11/30 22:26:14 kettenis Exp $ */ /* * Copyright (c) 2009 Mark Kettenis @@ -16,6 +16,9 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef _MDESC_H_ +#define _MDESC_H_ + struct md_header { uint32_t transport_version; uint32_t node_blk_sz; @@ -37,6 +40,8 @@ struct md_element { } d; }; +extern vaddr_t mdesc; + #ifdef _KERNEL psize_t mdesc_get_len(void); void mdesc_init(vaddr_t, paddr_t, psize_t); @@ -50,3 +55,5 @@ int mdesc_find_node_by_idx(int, const ch int mdesc_next_node(int); const char *mdesc_name_by_idx(int); #endif + +#endif /* _MDESC_H_ */
CVS commit: src/sys/arch/sparc64/dev
Module Name:src Committed By: palle Date: Tue Jun 21 20:36:02 UTC 2016 Modified Files: src/sys/arch/sparc64/dev: vbus.c Log Message: sun4v: vbus_attach() bugfix - use device_private() To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc64/dev/vbus.c 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/sparc64/dev/vbus.c diff -u src/sys/arch/sparc64/dev/vbus.c:1.1 src/sys/arch/sparc64/dev/vbus.c:1.2 --- src/sys/arch/sparc64/dev/vbus.c:1.1 Fri Jun 17 21:59:06 2016 +++ src/sys/arch/sparc64/dev/vbus.c Tue Jun 21 20:36:02 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vbus.c,v 1.1 2016/06/17 21:59:06 palle Exp $ */ +/* $NetBSD: vbus.c,v 1.2 2016/06/21 20:36:02 palle Exp $ */ /* $OpenBSD: vbus.c,v 1.8 2015/09/27 11:29:20 kettenis Exp $ */ /* * Copyright (c) 2008 Mark Kettenis @@ -72,7 +72,7 @@ vbus_match(device_t parent, cfdata_t mat void vbus_attach(device_t parent, device_t self, void *aux) { - struct vbus_softc *sc = (struct vbus_softc *)self; +struct vbus_softc *sc = device_private(self); struct mainbus_attach_args *ma = aux; int node;
CVS commit: src/sys/arch/sparc64/dev
Module Name:src Committed By: palle Date: Fri Jun 17 21:59:06 UTC 2016 Added Files: src/sys/arch/sparc64/dev: vbus.c vbusvar.h vrtc.c Log Message: sun4v: vbus and vrtc drivers - from OpenBSD To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc64/dev/vbus.c \ src/sys/arch/sparc64/dev/vbusvar.h src/sys/arch/sparc64/dev/vrtc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/arch/sparc64/dev/vbus.c diff -u /dev/null src/sys/arch/sparc64/dev/vbus.c:1.1 --- /dev/null Fri Jun 17 21:59:06 2016 +++ src/sys/arch/sparc64/dev/vbus.c Fri Jun 17 21:59:06 2016 @@ -0,0 +1,273 @@ +/* $NetBSD: vbus.c,v 1.1 2016/06/17 21:59:06 palle Exp $ */ +/* $OpenBSD: vbus.c,v 1.8 2015/09/27 11:29:20 kettenis Exp $ */ +/* + * Copyright (c) 2008 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +#include +extern todr_chip_handle_t todr_handle; + +#ifdef DEBUG +#define VBUS_INTR 0x01 +int vbus_debug = 0x00|VBUS_INTR; +#define DPRINTF(l, s) do { if (vbus_debug & l) printf s; } while (0) +#else +#define DPRINTF(l, s) +#endif + +struct vbus_softc { + device_t sc_dv; + bus_space_tag_t sc_bustag; + bus_dma_tag_t sc_dmatag; +}; +int vbus_cmp_cells(int *, int *, int *, int); +int vbus_match(device_t, cfdata_t, void *); +void vbus_attach(device_t, device_t, void *); +int vbus_print(void *, const char *); + +CFATTACH_DECL_NEW(vbus, sizeof(struct vbus_softc), +vbus_match, vbus_attach, NULL, NULL); + +void *vbus_intr_establish(bus_space_tag_t, int, int, +int (*)(void *), void *, void (*)(void)); +void vbus_intr_ack(struct intrhand *); +bus_space_tag_t vbus_alloc_bus_tag(struct vbus_softc *, bus_space_tag_t); + +int +vbus_match(device_t parent, cfdata_t match, void *aux) +{ + struct mainbus_attach_args *ma = aux; + + if (strcmp(ma->ma_name, "virtual-devices") == 0) + return (1); + + return (0); +} + +void +vbus_attach(device_t parent, device_t self, void *aux) +{ + struct vbus_softc *sc = (struct vbus_softc *)self; + struct mainbus_attach_args *ma = aux; + int node; + + sc->sc_bustag = vbus_alloc_bus_tag(sc, ma->ma_bustag); + sc->sc_dmatag = ma->ma_dmatag; + printf("\n"); + + for (node = OF_child(ma->ma_node); node; node = OF_peer(node)) { + struct vbus_attach_args va; + char buf[32]; + + bzero(, sizeof(va)); + va.va_node = node; + if (OF_getprop(node, "name", buf, sizeof(buf)) <= 0) + continue; + va.va_name = buf; + va.va_bustag = sc->sc_bustag; + va.va_dmatag = sc->sc_dmatag; + prom_getprop(node, "reg", sizeof(*va.va_reg), + _nreg, (void **)_reg); + prom_getprop(node, "interrupts", sizeof(*va.va_intr), + _nintr, (void **)_intr); + config_found(self, , vbus_print); + } + + struct vbus_attach_args va; + bzero(, sizeof(va)); + va.va_name = "rtc"; + config_found(self, , vbus_print); + +} + +int +vbus_print(void *aux, const char *name) +{ + struct vbus_attach_args *va = aux; + + if (name) + printf("\"%s\" at %s", va->va_name, name); + return (UNCONF); +} + +/* + * Compare a sequence of cells with a mask, return 1 if they match and + * 0 if they don't. + */ +int +vbus_cmp_cells(int *cell1, int *cell2, int *mask, int ncells) +{ + int i; + + for (i = 0; i < ncells; i++) { + if (((cell1[i] ^ cell2[i]) & mask[i]) != 0) + return (0); + } + return (1); +} + +int +vbus_intr_map(int node, int ino, uint64_t *sysino) +{ + int *imap = NULL, nimap; + int *reg = NULL, nreg; + int *imap_mask; + int parent; + int address_cells, interrupt_cells; + uint64_t devhandle; + uint64_t devino; + int len; + int err; + + DPRINTF(VBUS_INTR, ("vbus_intr_map(): ino 0x%x\n", ino)); + + parent = OF_parent(node); + + address_cells = prom_getpropint(parent, "#address-cells", 2); + interrupt_cells = prom_getpropint(parent, "#interrupt-cells", 1); + KASSERT(interrupt_cells == 1); + + len = OF_getproplen(parent, "interrupt-map-mask"); + if (len < (address_cells + interrupt_cells) * sizeof(int)) + return (-1); + imap_mask = malloc(len, M_DEVBUF, M_NOWAIT); + if (imap_mask == NULL) + return (-1); + if (OF_getprop(parent, "interrupt-map-mask", imap_mask, len) != len) + return (-1);
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Fri Jun 17 21:52:27 UTC 2016 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: Update sparc64 TODO: sun4u specfic code in TRAP_SETUP() + make a note about importing the man pages for the sun4v specific drivers To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.18 src/sys/arch/sparc64/doc/TODO:1.19 --- src/sys/arch/sparc64/doc/TODO:1.18 Sat Jun 4 21:26:26 2016 +++ src/sys/arch/sparc64/doc/TODO Fri Jun 17 21:52:27 2016 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.18 2016/06/04 21:26:26 palle Exp $ */ + /* $NetBSD: TODO,v 1.19 2016/06/17 21:52:27 palle Exp $ */ Things to be done: @@ -27,4 +27,6 @@ sun4v: - vpci.c/vpcivar.h: cleanup FIXMEs - interrups not handled properly (com at ebus only...) - mpt(4) complains: mpt0: Phy 0: Link Status Unknown -- locore.s: TRAP_SETUP() - sun4u specific ASI_DMMU \ No newline at end of file +- locore.s: TRAP_SETUP() - sun4u specific ASI_DMMU +- man pages for drivers imported from OpenBSD lke vpci, vbus etc. +
CVS commit: src/sys/arch/sparc64/conf
Module Name:src Committed By: palle Date: Fri Jun 17 21:38:09 UTC 2016 Modified Files: src/sys/arch/sparc64/conf: GENERIC files.sparc64 Log Message: sun4v: vbus and vrtc drivers - from OpenBSD To generate a diff of this commit: cvs rdiff -u -r1.189 -r1.190 src/sys/arch/sparc64/conf/GENERIC cvs rdiff -u -r1.149 -r1.150 src/sys/arch/sparc64/conf/files.sparc64 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/sparc64/conf/GENERIC diff -u src/sys/arch/sparc64/conf/GENERIC:1.189 src/sys/arch/sparc64/conf/GENERIC:1.190 --- src/sys/arch/sparc64/conf/GENERIC:1.189 Thu May 26 10:38:07 2016 +++ src/sys/arch/sparc64/conf/GENERIC Fri Jun 17 21:38:09 2016 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.189 2016/05/26 10:38:07 nakayama Exp $ +# $NetBSD: GENERIC,v 1.190 2016/06/17 21:38:09 palle Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/sparc64/conf/std.sparc64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.189 $" +#ident "GENERIC-$Revision: 1.190 $" maxusers 64 @@ -247,6 +247,7 @@ ebus* at mainbus0# ebus devices ebus* at pci? # ebus devices # XXX 'puc's aren't really bridges, but there's no better place for them here puc* at pci? dev ? function ? # PCI "universal" comm. cards +vbus0 at mainbus0 Standard system devices -- all required for a given architecture @@ -273,6 +274,9 @@ rtc* at ebus? ## Timer chip found on 4/300, sun4c, sun4m and (some) sun4u systems. timer* at mainbus0# sun4c +# Virtual devices for sun4v systems. +vrtc0 at vbus? + Serial port configuration ## Zilog 8530 serial chips. Each has two-channels. Index: src/sys/arch/sparc64/conf/files.sparc64 diff -u src/sys/arch/sparc64/conf/files.sparc64:1.149 src/sys/arch/sparc64/conf/files.sparc64:1.150 --- src/sys/arch/sparc64/conf/files.sparc64:1.149 Tue Oct 6 16:40:36 2015 +++ src/sys/arch/sparc64/conf/files.sparc64 Fri Jun 17 21:38:09 2016 @@ -1,4 +1,4 @@ -# $NetBSD: files.sparc64,v 1.149 2015/10/06 16:40:36 martin Exp $ +# $NetBSD: files.sparc64,v 1.150 2016/06/17 21:38:09 palle Exp $ # @(#)files.sparc64 8.1 (Berkeley) 7/19/93 # sparc64-specific configuration info @@ -69,6 +69,10 @@ file arch/sparc64/dev/ebus.c ebus attach ebus at mainbus with ebus_mainbus file arch/sparc64/dev/ebus_mainbus.c ebus_mainbus +device vbus {} +attach vbus at mainbus +file arch/sparc64/dev/vbus.c vbus + device clock: mk48txx attach clock at sbus with mkclock_sbus attach clock at ebus with mkclock_ebus @@ -312,3 +316,8 @@ include "arch/sparc64/conf/majors.sparc6 # OpenFirmware convenience stuff file dev/ofw/ofw_subr.c + +# Virtual rtc +device vrtc +attach vrtc at vbus +file arch/sparc64/dev/vrtc.c vrtc
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Sat Jun 4 21:26:26 UTC 2016 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: Update TODO: note that TRAP_SETUP() is stil sun4u-specific To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.17 src/sys/arch/sparc64/doc/TODO:1.18 --- src/sys/arch/sparc64/doc/TODO:1.17 Tue May 17 19:39:44 2016 +++ src/sys/arch/sparc64/doc/TODO Sat Jun 4 21:26:26 2016 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.17 2016/05/17 19:39:44 palle Exp $ */ + /* $NetBSD: TODO,v 1.18 2016/06/04 21:26:26 palle Exp $ */ Things to be done: @@ -26,4 +26,5 @@ sun4v: - MP support - currently bypassed in pmap_bootstrap() for sun4v - vpci.c/vpcivar.h: cleanup FIXMEs - interrups not handled properly (com at ebus only...) -- mpt(4) complains: mpt0: Phy 0: Link Status Unknown \ No newline at end of file +- mpt(4) complains: mpt0: Phy 0: Link Status Unknown +- locore.s: TRAP_SETUP() - sun4u specific ASI_DMMU \ No newline at end of file
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Sat Jun 4 21:24:41 UTC 2016 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: rtf_user now uses macros GET_MMU_CONTEXTID and SET_MMU_CONTEXTID. Tested on sun4u (QEMU) and sun4v (T2000). Parts from OpenBSD. To generate a diff of this commit: cvs rdiff -u -r1.397 -r1.398 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.397 src/sys/arch/sparc64/sparc64/locore.s:1.398 --- src/sys/arch/sparc64/sparc64/locore.s:1.397 Wed May 18 15:14:08 2016 +++ src/sys/arch/sparc64/sparc64/locore.s Sat Jun 4 21:24:41 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.397 2016/05/18 15:14:08 nakayama Exp $ */ +/* $NetBSD: locore.s,v 1.398 2016/06/04 21:24:41 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -150,6 +150,34 @@ 3: .endm + .macro GET_MMU_CONTEXTID_SUN4U ctxid,ctx + ldxa [\ctx] ASI_DMMU, \ctxid + .endm + +#ifdef SUN4V + .macro GET_MMU_CONTEXTID_SUN4V ctxid,ctx + ldxa [\ctx] ASI_MMU_CONTEXTID, \ctxid + .endm +#endif + + .macro GET_MMU_CONTEXTID ctxid,ctx,scratch +#ifdef SUN4V + sethi %hi(cputyp), \scratch + ld [\scratch + %lo(cputyp)], \scratch + cmp \scratch, CPU_SUN4V + bne,pt %icc, 2f + nop + /* sun4v */ + GET_MMU_CONTEXTID_SUN4V \ctxid,\ctx + ba 3f + nop +2: +#endif + /* sun4u */ + GET_MMU_CONTEXTID_SUN4U \ctxid,\ctx +3: + .endm + #ifdef SUN4V .macro NORMAL_GLOBALS_SUN4V wrpr %g0, 0, %gl! Set globals to level 0 @@ -4619,12 +4647,14 @@ badregs: andn %g1, CWP, %g1 ! Clear it from %tstate wrpr %g1, %g7, %tstate ! Set %tstate with %cwp - wr %g0, ASI_DMMU, %asi ! restore the user context - ldxa [CTX_SECONDARY] %asi, %g4 + mov CTX_SECONDARY, %g1 ! Restore the user context + GET_MMU_CONTEXTID %g4, %g1, %g3 + mov CTX_PRIMARY, %g2 + SET_MMU_CONTEXTID %g4, %g2, %g3 sethi %hi(KERNBASE), %g7 ! Should not be needed due to retry - stxa %g4, [CTX_PRIMARY] %asi membar #Sync! Should not be needed due to retry flush %g7! Should not be needed due to retry + CLRTT #ifdef TRAPSTATS set _C_LABEL(rftudone), %g1
CVS commit: src/sys/kern
Module Name:src Committed By: palle Date: Sat Jun 4 21:10:56 UTC 2016 Modified Files: src/sys/kern: init_main.c Log Message: Added missing "it" to comment in start_init() To generate a diff of this commit: cvs rdiff -u -r1.480 -r1.481 src/sys/kern/init_main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/init_main.c diff -u src/sys/kern/init_main.c:1.480 src/sys/kern/init_main.c:1.481 --- src/sys/kern/init_main.c:1.480 Sun May 22 14:26:09 2016 +++ src/sys/kern/init_main.c Sat Jun 4 21:10:56 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.480 2016/05/22 14:26:09 christos Exp $ */ +/* $NetBSD: init_main.c,v 1.481 2016/06/04 21:10:56 palle Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.480 2016/05/22 14:26:09 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.481 2016/06/04 21:10:56 palle Exp $"); #include "opt_ddb.h" #include "opt_inet.h" @@ -1044,7 +1044,7 @@ start_init(void *arg) goto copyerr; /* - * Now try to exec the program. If can't for any reason + * Now try to exec the program. If it can't for any reason * other than it doesn't exist, complain. */ error = sys_execve(l, , retval);
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Tue May 17 19:43:28 UTC 2016 Modified Files: src/sys/arch/sparc64/sparc64: genassym.cf locore.s Log Message: sun4v: Implement missng MMU protection trap handling - mostly from OpenBSD To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/arch/sparc64/sparc64/genassym.cf cvs rdiff -u -r1.395 -r1.396 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/genassym.cf diff -u src/sys/arch/sparc64/sparc64/genassym.cf:1.78 src/sys/arch/sparc64/sparc64/genassym.cf:1.79 --- src/sys/arch/sparc64/sparc64/genassym.cf:1.78 Mon May 16 20:03:07 2016 +++ src/sys/arch/sparc64/sparc64/genassym.cf Tue May 17 19:43:28 2016 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.78 2016/05/16 20:03:07 palle Exp $ +# $NetBSD: genassym.cf,v 1.79 2016/05/17 19:43:28 palle Exp $ # # Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -148,6 +148,8 @@ export SUN4U_TTE_CV export SUN4U_TTE_P export SUN4U_TTE_EXEC export SUN4V_TLB_ACCESS +export SUN4V_TLB_MODIFY +export SUN4V_TLB_W export SUN4V_TLB_TSB_LOCK export PG_SHIFT4U Index: src/sys/arch/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.395 src/sys/arch/sparc64/sparc64/locore.s:1.396 --- src/sys/arch/sparc64/sparc64/locore.s:1.395 Mon May 16 20:03:07 2016 +++ src/sys/arch/sparc64/sparc64/locore.s Tue May 17 19:43:28 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.395 2016/05/16 20:03:07 palle Exp $ */ +/* $NetBSD: locore.s,v 1.396 2016/05/17 19:43:28 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -1068,7 +1068,9 @@ _C_LABEL(trapbase_sun4v): HARDINT4V(13) ! 0x04d = level 13 interrupt HARDINT4V(14) ! 0x04e = level 14 interrupt HARDINT4V(15) ! 0x04f = level 15 interrupt - sun4v_trap_entry 44 ! 0x050-0x07b + sun4v_trap_entry 28 ! 0x050-0x06b + VTRAP(T_FDMMU_PROT, sun4v_tl0_dtsb_prot) ! 0x6c + sun4v_trap_entry 15 ! 0x06d-0x07b VTRAP(T_CPU_MONDO, sun4v_cpu_mondo) ! 0x07c = cpu mondo VTRAP(T_DEV_MONDO, sun4v_dev_mondo) ! 0x07d = dev mondo sun4v_trap_entry 2 ! 0x07e-0x07f @@ -2891,7 +2893,105 @@ sun4v_datatrap_tl0: sun4v_datatrap_tl1: /* XXX missing implementaion */ sir - + +sun4v_tl0_dtsb_prot: + GET_MMFSA %g1! MMU Fault status area + add %g1, 0x48, %g3 + LDPTRA [%g3] ASI_PHYS_CACHED, %g3 ! Data fault address + add %g1, 0x50, %g6 + LDPTRA [%g6] ASI_PHYS_CACHED, %g6 ! Data fault context + + GET_CTXBUSY %g4 + sllx %g6, 3, %g6 ! Make it into an offset into ctxbusy + LDPTR [%g4 + %g6], %g4 ! Load up our page table. + + srax %g3, HOLESHIFT, %g5 ! Check for valid address + brz,pt %g5, 0f! Should be zero or -1 + inc %g5! Make -1 -> 0 + brnz,pn %g5, sun4v_datatrap ! Error! In hole! +0: + srlx %g3, STSHIFT, %g6 + and %g6, STMASK, %g6 ! Index into pm_segs + sll %g6, 3, %g6 + add %g4, %g6, %g4 + LDPTRA [%g4] ASI_PHYS_CACHED, %g4 ! Load page directory pointer + + srlx %g3, PDSHIFT, %g6 + and %g6, PDMASK, %g6 + sll %g6, 3, %g6 + brz,pn %g4, sun4v_datatrap ! NULL entry? check somewhere else + add %g4, %g6, %g4 + LDPTRA [%g4] ASI_PHYS_CACHED, %g4 ! Load page table pointer + + srlx %g3, PTSHIFT, %g6 ! Convert to ptab offset + and %g6, PTMASK, %g6 + sll %g6, 3, %g6 + brz,pn %g4, sun4v_datatrap ! NULL entry? check somewhere else + add %g4, %g6, %g6 +1: + LDPTRA [%g6] ASI_PHYS_CACHED, %g4 ! Fetch TTE + brgez,pn %g4, sun4v_datatrap ! Entry invalid? Punt + or %g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g7 + ! Update the modified bit + +# btst SUN4V_TLB_REAL_W|SUN4V_TLB_W, %g4 ! Is it a ref fault? + mov 1, %g2 + sllx %g2, 61, %g2 + or %g2, SUN4V_TLB_W, %g2 + btst %g2, %g4 + bz,pn %xcc, sun4v_datatrap ! No -- really fault + nop + casxa [%g6] ASI_PHYS_CACHED, %g4, %g7 ! and write it out + cmp %g4, %g7 + bne,pn %xcc, 1b + or %g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g4 + ! Update the modified bit +2: + GET_TSB_DMMU %g2 + + mov %g1, %g7 ! save MMFSA + + /* Construct TSB tag word. */ + add %g1, 0x50, %g6 + LDPTRA [%g6] ASI_PHYS_CACHED, %g6 ! Data fault context + mov %g3, %g1 ! Data fault address + srlx %g1, 22, %g1 ! 63..22 of virt addr + sllx %g6, 48, %g6 ! context_id in 63..48 + or %g1, %g6, %g1 ! construct TTE tag + + srlx %g3, PTSHIFT, %g3 + sethi %hi(_C_LABEL(tsbsize)), %g5 + mov 512, %g6 + ld [%g5 + %lo(_C_LABEL(tsbsize))], %g5 + sllx %g6, %g5, %g5 ! %g5 = 512 << tsbsize = TSBENTS + sub %g5, 1, %g5 ! TSBENTS -> offset + and %g3, %g5, %g3 ! mask out TTE index + sllx %g3, 4, %g3 ! TTE size is 16 bytes + add %g2, %g3, %g2 ! location of TTE in ci_tsb_dmmu + + membar #StoreStore + + STPTR %g4, [%g2 + 8] ! store TTE data + STPTR %g1, [%g2] ! store TTE tag + + mov %o0, %g1 + mov %o1, %g2 + mov %o2, %g3 + + add %g7, 0x48, %o0 + ldxa [%o0] ASI_PHYS_CACHED, %o0 ! Data fault address + add %g7, 0x50, %o1 + ldxa
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Tue May 17 19:39:44 UTC 2016 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: Update TODO: sun4v_datatrap handling for trap level 0 is working To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.16 src/sys/arch/sparc64/doc/TODO:1.17 --- src/sys/arch/sparc64/doc/TODO:1.16 Tue May 10 19:35:08 2016 +++ src/sys/arch/sparc64/doc/TODO Tue May 17 19:39:44 2016 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.16 2016/05/10 19:35:08 palle Exp $ */ + /* $NetBSD: TODO,v 1.17 2016/05/17 19:39:44 palle Exp $ */ Things to be done: @@ -15,7 +15,7 @@ sun4v: - 32-bit kernel support - libkvm - ofwboot: tlb_init_sun4v() hardcodes number of slots to 64 -- locore.s: sun4v_datatrap missing implementation for trap levels 0 and 1 +- locore.s: sun4v_datatrap missing implementation for trap level 1 - check build without SUN4V defined - replace relevant references to %ver with GET_MAXCWP - pmap_mp_init(): sun4v missing handling
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Mon May 16 20:03:07 UTC 2016 Modified Files: src/sys/arch/sparc64/sparc64: genassym.cf locore.s mp_subr.S Log Message: Avoid assembler-specific defines by using the export keyword in genassym.cf instead To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/arch/sparc64/sparc64/genassym.cf cvs rdiff -u -r1.394 -r1.395 src/sys/arch/sparc64/sparc64/locore.s cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc64/sparc64/mp_subr.S 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/sparc64/sparc64/genassym.cf diff -u src/sys/arch/sparc64/sparc64/genassym.cf:1.77 src/sys/arch/sparc64/sparc64/genassym.cf:1.78 --- src/sys/arch/sparc64/sparc64/genassym.cf:1.77 Tue May 10 19:24:00 2016 +++ src/sys/arch/sparc64/sparc64/genassym.cf Mon May 16 20:03:07 2016 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.77 2016/05/10 19:24:00 palle Exp $ +# $NetBSD: genassym.cf,v 1.78 2016/05/16 20:03:07 palle Exp $ # # Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -136,12 +136,23 @@ define PM_PHYS offsetof(struct pmap, pm define PM_RESIDENT offsetof(struct pmap, pm_stats.resident_count) define PM_WIRED offsetof(struct pmap, pm_stats.wired_count) -# the assembler doesn't grok C constants with LL suffix -define A_SUN4U_TLB_TSB_LOCK SUN4U_TLB_TSB_LOCK -ifdef SUN4V -define A_SUN4V_TLB_ACCESS SUN4V_TLB_ACCESS -define A_SUN4V_TLB_TSB_LOCK SUN4V_TLB_TSB_LOCK -endif +# TLB/TTE defines +export SUN4U_TLB_TSB_LOCK +export SUN4U_TTE_MODIFY +export SUN4U_TTE_ACCESS +export SUN4U_TTE_REAL_W +export SUN4U_TTE_W +export SUN4U_TTE_L +export SUN4U_TTE_CP +export SUN4U_TTE_CV +export SUN4U_TTE_P +export SUN4U_TTE_EXEC +export SUN4V_TLB_ACCESS +export SUN4V_TLB_TSB_LOCK + +export PG_SHIFT4U + +export CTX_MASK # CPU info structure define CI_SELF offsetof(struct cpu_info, ci_self) Index: src/sys/arch/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.394 src/sys/arch/sparc64/sparc64/locore.s:1.395 --- src/sys/arch/sparc64/sparc64/locore.s:1.394 Sun May 15 23:54:58 2016 +++ src/sys/arch/sparc64/sparc64/locore.s Mon May 16 20:03:07 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.394 2016/05/15 23:54:58 nakayama Exp $ */ +/* $NetBSD: locore.s,v 1.395 2016/05/16 20:03:07 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -83,7 +83,6 @@ #include #include #include -#include #include #include #include @@ -2785,15 +2784,15 @@ sun4v_dtsb_miss: 1: LDPTRA [%g6] ASI_PHYS_CACHED, %g4 ! Fetch TTE brgez,pn %g4, sun4v_datatrap ! Entry invalid? Punt - or %g4, A_SUN4V_TLB_ACCESS, %g7 ! Update the access bit + or %g4, SUN4V_TLB_ACCESS, %g7 ! Update the access bit - btst A_SUN4V_TLB_ACCESS, %g4 ! Need to update access bit? + btst SUN4V_TLB_ACCESS, %g4 ! Need to update access bit? bne,pt %xcc, 2f nop casxa [%g6] ASI_PHYS_CACHED, %g4, %g7 ! and write it out cmp %g4, %g7 bne,pn %xcc, 1b - or %g4, A_SUN4V_TLB_ACCESS, %g4 ! Update the access bit + or %g4, SUN4V_TLB_ACCESS, %g4 ! Update the access bit 2: GET_TSB_DMMU %g2 @@ -6441,13 +6440,13 @@ ENTRY(pseg_set_real) cmp %g5, CPU_SUN4V bne,pt %icc, 0f nop - sethi %hh(A_SUN4V_TLB_TSB_LOCK), %g5 + sethi %hh(SUN4V_TLB_TSB_LOCK), %g5 sllx %g5, 32, %g5 ba 1f nop 0: #endif - set A_SUN4U_TLB_TSB_LOCK, %g5 + set SUN4U_TLB_TSB_LOCK, %g5 1: xor %o2, %o5, %o3 ! %o3 - what changed Index: src/sys/arch/sparc64/sparc64/mp_subr.S diff -u src/sys/arch/sparc64/sparc64/mp_subr.S:1.9 src/sys/arch/sparc64/sparc64/mp_subr.S:1.10 --- src/sys/arch/sparc64/sparc64/mp_subr.S:1.9 Mon Jun 15 07:48:08 2015 +++ src/sys/arch/sparc64/sparc64/mp_subr.S Mon May 16 20:03:07 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: mp_subr.S,v 1.9 2015/06/15 07:48:08 martin Exp $ */ +/* $NetBSD: mp_subr.S,v 1.10 2016/05/16 20:03:07 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -72,7 +72,6 @@ #include #include #include -#include #include #include #include
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Fri May 13 21:48:15 UTC 2016 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: add missing implementation of sun4v_datatrap_tl0 so data_access_fault() is called - mostly from OpenBSD To generate a diff of this commit: cvs rdiff -u -r1.392 -r1.393 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.392 src/sys/arch/sparc64/sparc64/locore.s:1.393 --- src/sys/arch/sparc64/sparc64/locore.s:1.392 Fri May 13 21:21:25 2016 +++ src/sys/arch/sparc64/sparc64/locore.s Fri May 13 21:48:15 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.392 2016/05/13 21:21:25 nakayama Exp $ */ +/* $NetBSD: locore.s,v 1.393 2016/05/13 21:48:15 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -2829,9 +2829,66 @@ sun4v_datatrap: ! branch further based nop ba sun4v_datatrap_tl1 nop + sun4v_datatrap_tl0: - /* XXX missing implementaion */ - sir + GET_MMFSA %g3! MMU Fault status area + add %g3, 0x48, %g1 + LDPTRA [%g1] ASI_PHYS_CACHED, %g1 ! Data fault address + add %g3, 0x50, %g2 + LDPTRA [%g2] ASI_PHYS_CACHED, %g2 ! Data fault context + + TRAP_SETUP(-CC64FSZ-TF_SIZE) + or %g1, %g2, %o3 + mov %g1, %o4 + + rdpr %tt, %g4 + rdpr %tstate, %g1 + rdpr %tpc, %g2 + rdpr %tnpc, %g3 + + stx %g1, [%sp + CC64FSZ + BIAS + TF_TSTATE] + mov %g4, %o1 ! (type) + stx %g2, [%sp + CC64FSZ + BIAS + TF_PC] + rd %y, %g5 + stx %g3, [%sp + CC64FSZ + BIAS + TF_NPC] + st %g5, [%sp + CC64FSZ + BIAS + TF_Y] + mov %g2, %o2 ! (pc) + sth %o1, [%sp + CC64FSZ + BIAS + TF_TT]! debug + + cmp %o1, T_FDMMU_PROT + bne,pn %icc, 1f + mov SFSR_FV, %o5 + or %o5, SFSR_W, %o5 + +1: + NORMAL_GLOBALS_SUN4V + + stx %g1, [%sp + CC64FSZ + BIAS + TF_G + (1*8)] + stx %g2, [%sp + CC64FSZ + BIAS + TF_G + (2*8)] + add %sp, CC64FSZ + BIAS, %o0 ! () + stx %g3, [%sp + CC64FSZ + BIAS + TF_G + (3*8)] + stx %g4, [%sp + CC64FSZ + BIAS + TF_G + (4*8)] + stx %g5, [%sp + CC64FSZ + BIAS + TF_G + (5*8)] + rdpr %pil, %g5 + stx %g6, [%sp + CC64FSZ + BIAS + TF_G + (6*8)] + stx %g7, [%sp + CC64FSZ + BIAS + TF_G + (7*8)] + stb %g5, [%sp + CC64FSZ + BIAS + TF_PIL] + stb %g5, [%sp + CC64FSZ + BIAS + TF_OLDPIL] + + /* + * Phew, ready to enable traps and call C code. + */ + wrpr %g0, 0, %tl + + wr %g0, ASI_PRIMARY_NOFAULT, %asi ! Restore default ASI + wrpr %g0, PSTATE_INTR, %pstate ! traps on again + call _C_LABEL(data_access_fault) ! data_acces_fault(tf, type, ...) + nop + + ba,a,pt %icc, return_from_trap + nop + NOTREACHED + sun4v_datatrap_tl1: /* XXX missing implementaion */ sir
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Fri May 13 21:21:43 UTC 2016 Modified Files: src/sys/arch/sparc64/sparc64: trap.c Log Message: Fixed typo in comment + reorder parameters for trap debug output to match function prototype for data_access_fault() To generate a diff of this commit: cvs rdiff -u -r1.182 -r1.183 src/sys/arch/sparc64/sparc64/trap.c 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/sparc64/sparc64/trap.c diff -u src/sys/arch/sparc64/sparc64/trap.c:1.182 src/sys/arch/sparc64/sparc64/trap.c:1.183 --- src/sys/arch/sparc64/sparc64/trap.c:1.182 Sun May 1 19:57:55 2016 +++ src/sys/arch/sparc64/sparc64/trap.c Fri May 13 21:21:43 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.182 2016/05/01 19:57:55 palle Exp $ */ +/* $NetBSD: trap.c,v 1.183 2016/05/13 21:21:43 palle Exp $ */ /* * Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved. @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.182 2016/05/01 19:57:55 palle Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.183 2016/05/13 21:21:43 palle Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -438,7 +438,7 @@ print_trapframe(struct trapframe64 *tf) /* * Called from locore.s trap handling, for non-MMU-related traps. - * (MMU-related traps go through mem_access_fault, below.) + * (MMU-related traps go through data_access_fault, below.) */ void trap(struct trapframe64 *tf, unsigned int type, vaddr_t pc, long tstate) @@ -1053,7 +1053,7 @@ data_access_fault(struct trapframe64 *tf printf("%ld: data_access_fault(%p, %x, %p, %p, %lx, %lx) " "nsaved=%d\n", (long)(curproc?curproc->p_pid:-1), tf, type, - (void *)addr, (void *)pc, + (void *)pc, (void *)addr, sfva, sfsr, (int)curpcb->pcb_nsaved); #ifdef DDB if ((trapdebug & TDB_NSAVED && curpcb->pcb_nsaved))
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Tue May 10 19:35:08 UTC 2016 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: Update TODO: sun4v interrupts works (mostly) + note issue with mpt(4) on sun4v systems To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.15 src/sys/arch/sparc64/doc/TODO:1.16 --- src/sys/arch/sparc64/doc/TODO:1.15 Sun May 1 19:41:01 2016 +++ src/sys/arch/sparc64/doc/TODO Tue May 10 19:35:08 2016 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.15 2016/05/01 19:41:01 palle Exp $ */ + /* $NetBSD: TODO,v 1.16 2016/05/10 19:35:08 palle Exp $ */ Things to be done: @@ -25,4 +25,5 @@ sun4v: - ci_tsb_desc->td_ctxidx: -1 or 1? - MP support - currently bypassed in pmap_bootstrap() for sun4v - vpci.c/vpcivar.h: cleanup FIXMEs -- interrups not handled properly \ No newline at end of file +- interrups not handled properly (com at ebus only...) +- mpt(4) complains: mpt0: Phy 0: Link Status Unknown \ No newline at end of file
CVS commit: src/sys/arch/sparc64
sbus.c,v 1.93 2012/01/30 04:25:15 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.94 2016/05/10 19:23:59 palle Exp $"); #include "opt_ddb.h" @@ -254,8 +254,7 @@ sbus_attach(device_t parent, device_t se iommu_init(name, >sc_is, 0, -1); /* Enable the over temp intr */ - ih = (struct intrhand *) - malloc(sizeof(struct intrhand), M_DEVBUF, M_NOWAIT); + ih = intrhand_alloc(); ih->ih_map = >sc_sysio->therm_int_map; ih->ih_clr = NULL; /* >sc_sysio->therm_clr_int; */ ih->ih_fun = sbus_overtemp; @@ -508,10 +507,7 @@ sbus_intr_establish(bus_space_tag_t t, i int ipl; long vec = pri; - ih = (struct intrhand *) - malloc(sizeof(struct intrhand), M_DEVBUF, M_NOWAIT); - if (ih == NULL) - return (NULL); + ih = intrhand_alloc(); if ((vec & SBUS_INTR_COMPAT) != 0) ipl = vec & ~SBUS_INTR_COMPAT; Index: src/sys/arch/sparc64/dev/schizo.c diff -u src/sys/arch/sparc64/dev/schizo.c:1.35 src/sys/arch/sparc64/dev/schizo.c:1.36 --- src/sys/arch/sparc64/dev/schizo.c:1.35 Fri Nov 27 09:34:36 2015 +++ src/sys/arch/sparc64/dev/schizo.c Tue May 10 19:23:59 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: schizo.c,v 1.35 2015/11/27 09:34:36 martin Exp $ */ +/* $NetBSD: schizo.c,v 1.36 2016/05/10 19:23:59 palle Exp $ */ /* $OpenBSD: schizo.c,v 1.55 2008/08/18 20:29:37 brad Exp $ */ /* @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.35 2015/11/27 09:34:36 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.36 2016/05/10 19:23:59 palle Exp $"); #include #include @@ -588,10 +588,8 @@ schizo_set_intr(struct schizo_softc *sc, DPRINTF(SDB_INTR, (" mapoff %" PRIx64 " clroff %" PRIx64 "\n", mapoff, clroff)); - ih = (struct intrhand *) - kmem_alloc(sizeof(struct intrhand), KM_NOSLEEP); - if (ih == NULL) - return; + ih = intrhand_alloc(); + ih->ih_arg = arg; intrregs = (uintptr_t)bus_space_vaddr(pbm->sp_regt, pbm->sp_intrh); ih->ih_map = (uint64_t *)(uintptr_t)(intrregs + mapoff); @@ -815,9 +813,7 @@ schizo_intr_establish(bus_space_tag_t t, vec = INTVEC(ihandle); ino = INTINO(vec); - ih = kmem_alloc(sizeof *ih, KM_NOSLEEP); - if (ih == NULL) - return (NULL); + ih = intrhand_alloc(); DPRINTF(SDB_INTR, ("\n%s: ihandle %x level %d fn %p arg %p\n", __func__, ihandle, level, handler, arg)); Index: src/sys/arch/sparc64/dev/vpci.c diff -u src/sys/arch/sparc64/dev/vpci.c:1.6 src/sys/arch/sparc64/dev/vpci.c:1.7 --- src/sys/arch/sparc64/dev/vpci.c:1.6 Fri Nov 27 13:51:57 2015 +++ src/sys/arch/sparc64/dev/vpci.c Tue May 10 19:23:59 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vpci.c,v 1.6 2015/11/27 13:51:57 joerg Exp $ */ +/* $NetBSD: vpci.c,v 1.7 2016/05/10 19:23:59 palle Exp $ */ /* * Copyright (c) 2015 Palle Lyckegaard * All rights reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vpci.c,v 1.6 2015/11/27 13:51:57 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vpci.c,v 1.7 2016/05/10 19:23:59 palle Exp $"); #include #include @@ -114,7 +114,7 @@ void vpci_conf_write(pci_chipset_tag_t, static void * vpci_pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level, int (*func)(void *), void *arg); - +void vpci_intr_ack(struct intrhand *); int vpci_intr_map(const struct pci_attach_args *, pci_intr_handle_t *); int vpci_bus_map(bus_space_tag_t, bus_addr_t, bus_size_t, int, vaddr_t, bus_space_handle_t *); @@ -596,9 +596,7 @@ vpci_intr_establish(bus_space_tag_t t, i ino |= INTVEC(ihandle); DPRINTF(VDB_INTR, ("%s: ih %lx; level %d ino %#x\n", __func__, (u_long)ihandle, level, ino)); - ih = malloc(sizeof *ih, M_DEVBUF, M_NOWAIT); - if (ih == NULL) - return (NULL); + ih = intrhand_alloc(); ih->ih_ivec = ihandle; ih->ih_fun = handler; @@ -606,12 +604,44 @@ vpci_intr_establish(bus_space_tag_t t, i ih->ih_pil = level; ih->ih_number = ino; ih->ih_pending = 0; - + ih->ih_ack = vpci_intr_ack; intr_establish(ih->ih_pil, level != IPL_VM, ih); + uint64_t sysino = INTVEC(ihandle); + DPRINTF(VDB_INTR, ("vpci_intr_establish(): sysino 0x%lx\n", sysino)); + + int err; + + err = hv_intr_settarget(sysino, cpus->ci_cpuid); + if (err != H_EOK) + printf("hv_intr_settarget(%lu, %u) failed - err = %d\n", + (long unsigned int)sysino, cpus->ci_cpuid, err); + + /* Clear pending interrupts. */ + err = hv_intr_setstate(sysino, INTR_IDLE); + if (err != H_EOK) + printf("hv_intr_setstate(%lu, INTR_IDLE) failed - err = %d\n", + (long unsigned int)sysino, err); + + err = hv_intr_setenabled(sysino, INTR_ENABLED); + if (err != H_EOK) + printf("hv_intr_setenabled(%lu) failed - err = %d\n", + (long unsigned int)sysino, err); + + DPRINTF(VDB_INTR, ("%s() returning %p\n", __func__, ih)); return (ih); } +void +vpci_intr_ack(struct intrhand *ih) +{ + int er
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Sun May 1 20:12:55 UTC 2016 Modified Files: src/sys/arch/sparc64/sparc64: db_interface.c Log Message: fill_ddb_regs_from_tf() now fetches Local and In registers as well. To generate a diff of this commit: cvs rdiff -u -r1.132 -r1.133 src/sys/arch/sparc64/sparc64/db_interface.c 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/sparc64/sparc64/db_interface.c diff -u src/sys/arch/sparc64/sparc64/db_interface.c:1.132 src/sys/arch/sparc64/sparc64/db_interface.c:1.133 --- src/sys/arch/sparc64/sparc64/db_interface.c:1.132 Thu Sep 12 19:38:59 2013 +++ src/sys/arch/sparc64/sparc64/db_interface.c Sun May 1 20:12:54 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.c,v 1.132 2013/09/12 19:38:59 martin Exp $ */ +/* $NetBSD: db_interface.c,v 1.133 2016/05/01 20:12:54 palle Exp $ */ /* * Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.132 2013/09/12 19:38:59 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.133 2016/05/01 20:12:54 palle Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -232,7 +232,7 @@ fill_ddb_regs_from_tf(struct trapframe64 } /* We should do a proper copyin and xlate 64-bit stack frames, but... */ /* if (tf->tf_tstate & TSTATE_PRIV) { .. } */ - + #if 0 /* make sure this is not causing ddb problems. */ if (tf->tf_out[6] & 1) { @@ -257,6 +257,13 @@ fill_ddb_regs_from_tf(struct trapframe64 DDB_REGS->db_fr.fr_fp = (long)tfr.fr_fp; DDB_REGS->db_fr.fr_pc = tfr.fr_pc; } +#else + int i; + for (i=0; i<8; i++) + DDB_REGS->db_fr.fr_local[i] = tf->tf_local[i]; + for (i=0; i<6; i++) + DDB_REGS->db_fr.fr_arg[i] = tf->tf_in[i]; + /* XXX tp and pc are missing */ #endif DDB_REGS->db_tl = savetstate(_REGS->db_ts[0]); }
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Sun May 1 19:57:55 UTC 2016 Modified Files: src/sys/arch/sparc64/sparc64: trap.c Log Message: print_trapframe() should print out Local and In registers as well To generate a diff of this commit: cvs rdiff -u -r1.181 -r1.182 src/sys/arch/sparc64/sparc64/trap.c 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/sparc64/sparc64/trap.c diff -u src/sys/arch/sparc64/sparc64/trap.c:1.181 src/sys/arch/sparc64/sparc64/trap.c:1.182 --- src/sys/arch/sparc64/sparc64/trap.c:1.181 Sat Feb 28 21:44:33 2015 +++ src/sys/arch/sparc64/sparc64/trap.c Sun May 1 19:57:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.181 2015/02/28 21:44:33 martin Exp $ */ +/* $NetBSD: trap.c,v 1.182 2016/05/01 19:57:55 palle Exp $ */ /* * Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved. @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.181 2015/02/28 21:44:33 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.182 2016/05/01 19:57:55 palle Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -388,14 +388,14 @@ print_trapframe(struct trapframe64 *tf) tf, (u_long)tf->tf_tstate, (u_long)tf->tf_pc, (u_long)tf->tf_npc); printf("fault: %p\ty: %x\t", (void *)(u_long)tf->tf_fault, (int)tf->tf_y); - printf("pil: %d\toldpil: %d\ttt: %x\tGlobals:\n", + printf("pil: %d\toldpil: %d\ttt: %x\nGlobals:\n", (int)tf->tf_pil, (int)tf->tf_oldpil, (int)tf->tf_tt); printf("%08x%08x %08x%08x %08x%08x %08x%08x\n", (u_int)(tf->tf_global[0]>>32), (u_int)tf->tf_global[0], (u_int)(tf->tf_global[1]>>32), (u_int)tf->tf_global[1], (u_int)(tf->tf_global[2]>>32), (u_int)tf->tf_global[2], (u_int)(tf->tf_global[3]>>32), (u_int)tf->tf_global[3]); - printf("%08x%08x %08x%08x %08x%08x %08x%08x\nouts:\n", + printf("%08x%08x %08x%08x %08x%08x %08x%08x\nOuts:\n", (u_int)(tf->tf_global[4]>>32), (u_int)tf->tf_global[4], (u_int)(tf->tf_global[5]>>32), (u_int)tf->tf_global[5], (u_int)(tf->tf_global[6]>>32), (u_int)tf->tf_global[6], @@ -406,11 +406,31 @@ print_trapframe(struct trapframe64 *tf) (u_int)(tf->tf_out[1]>>32), (u_int)tf->tf_out[1], (u_int)(tf->tf_out[2]>>32), (u_int)tf->tf_out[2], (u_int)(tf->tf_out[3]>>32), (u_int)tf->tf_out[3]); - printf("%08x%08x %08x%08x %08x%08x %08x%08x\n", + printf("%08x%08x %08x%08x %08x%08x %08x%08x\nLocals:\n", (u_int)(tf->tf_out[4]>>32), (u_int)tf->tf_out[4], (u_int)(tf->tf_out[5]>>32), (u_int)tf->tf_out[5], (u_int)(tf->tf_out[6]>>32), (u_int)tf->tf_out[6], (u_int)(tf->tf_out[7]>>32), (u_int)tf->tf_out[7]); + printf("%08x%08x %08x%08x %08x%08x %08x%08x\n", + (u_int)(tf->tf_local[0]>>32), (u_int)tf->tf_local[0], + (u_int)(tf->tf_local[1]>>32), (u_int)tf->tf_local[1], + (u_int)(tf->tf_local[2]>>32), (u_int)tf->tf_local[2], + (u_int)(tf->tf_local[3]>>32), (u_int)tf->tf_local[3]); + printf("%08x%08x %08x%08x %08x%08x %08x%08x\nIns:\n", + (u_int)(tf->tf_local[4]>>32), (u_int)tf->tf_local[4], + (u_int)(tf->tf_local[5]>>32), (u_int)tf->tf_local[5], + (u_int)(tf->tf_local[6]>>32), (u_int)tf->tf_local[6], + (u_int)(tf->tf_local[7]>>32), (u_int)tf->tf_local[7]); + printf("%08x%08x %08x%08x %08x%08x %08x%08x\n", + (u_int)(tf->tf_in[0]>>32), (u_int)tf->tf_in[0], + (u_int)(tf->tf_in[1]>>32), (u_int)tf->tf_in[1], + (u_int)(tf->tf_in[2]>>32), (u_int)tf->tf_in[2], + (u_int)(tf->tf_in[3]>>32), (u_int)tf->tf_in[3]); + printf("%08x%08x %08x%08x %08x%08x %08x%08x\n", + (u_int)(tf->tf_in[4]>>32), (u_int)tf->tf_in[4], + (u_int)(tf->tf_in[5]>>32), (u_int)tf->tf_in[5], + (u_int)(tf->tf_in[6]>>32), (u_int)tf->tf_in[6], + (u_int)(tf->tf_in[7]>>32), (u_int)tf->tf_in[7]); #endif }
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Sun May 1 19:41:01 UTC 2016 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: Update TODO: booting from a ISO image on a sun4v system works To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.14 src/sys/arch/sparc64/doc/TODO:1.15 --- src/sys/arch/sparc64/doc/TODO:1.14 Sun Apr 17 19:54:32 2016 +++ src/sys/arch/sparc64/doc/TODO Sun May 1 19:41:01 2016 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.14 2016/04/17 19:54:32 palle Exp $ */ + /* $NetBSD: TODO,v 1.15 2016/05/01 19:41:01 palle Exp $ */ Things to be done: @@ -25,5 +25,4 @@ sun4v: - ci_tsb_desc->td_ctxidx: -1 or 1? - MP support - currently bypassed in pmap_bootstrap() for sun4v - vpci.c/vpcivar.h: cleanup FIXMEs -- "bad magic number in disk label" when booting from an .iso image - interrups not handled properly \ No newline at end of file
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Sun Apr 17 19:54:32 UTC 2016 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: Update sparc64 TODO file: note issue with interrupt handling + issue when booting from iso image To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc64/doc/TODO 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/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.13 src/sys/arch/sparc64/doc/TODO:1.14 --- src/sys/arch/sparc64/doc/TODO:1.13 Sun Sep 6 18:41:34 2015 +++ src/sys/arch/sparc64/doc/TODO Sun Apr 17 19:54:32 2016 @@ -1,4 +1,4 @@ - /* $NetBSD: TODO,v 1.13 2015/09/06 18:41:34 palle Exp $ */ + /* $NetBSD: TODO,v 1.14 2016/04/17 19:54:32 palle Exp $ */ Things to be done: @@ -23,5 +23,7 @@ sun4v: - replace constructs line "wrpr %g0, PSTATE_INTR, %pstate" with ALTERNATE_GOBALS - sun4v tsb no need to lock... per cpu... anyway... - ci_tsb_desc->td_ctxidx: -1 or 1? -- MP support - currently bypassed in cpu_boot_secondary_processors() for sun4v +- MP support - currently bypassed in pmap_bootstrap() for sun4v - vpci.c/vpcivar.h: cleanup FIXMEs +- "bad magic number in disk label" when booting from an .iso image +- interrups not handled properly \ No newline at end of file
CVS commit: src/sys/arch/sparc/sparc
Module Name:src Committed By: palle Date: Thu Apr 7 19:46:39 UTC 2016 Modified Files: src/sys/arch/sparc/sparc: openfirm.c Log Message: Rework locking mechanism introduced in rev. 1.21: use __cpu_simple_lock... instead of mutex_... since this causes issues when LOCKDEBUG is defined To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sparc/sparc/openfirm.c 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/sparc/sparc/openfirm.c diff -u src/sys/arch/sparc/sparc/openfirm.c:1.21 src/sys/arch/sparc/sparc/openfirm.c:1.22 --- src/sys/arch/sparc/sparc/openfirm.c:1.21 Fri Apr 1 20:21:45 2016 +++ src/sys/arch/sparc/sparc/openfirm.c Thu Apr 7 19:46:39 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: openfirm.c,v 1.21 2016/04/01 20:21:45 palle Exp $ */ +/* $NetBSD: openfirm.c,v 1.22 2016/04/07 19:46:39 palle Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,10 +32,11 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.21 2016/04/01 20:21:45 palle Exp $"); +__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.22 2016/04/07 19:46:39 palle Exp $"); #include #include +#include #include #include #include @@ -56,7 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: openfirm.c,v * Use a mutex to protect access to the buffer from multiple threads. * */ -kmutex_t ofcall_mtx; +static __cpu_simple_lock_t ofcall_lock; static char ofbounce[OFBOUNCE_MAXSIZE]; #endif #endif @@ -67,7 +68,7 @@ OF_init(void) #ifdef SUN4V #ifdef __arch64__ KASSERT(((uint64_t) & 0xUL)==(uint64_t)); - mutex_init(_mtx, MUTEX_DEFAULT, IPL_NONE); + __cpu_simple_lock_init(_lock); #endif #endif } @@ -542,7 +543,7 @@ OF_write(int handle, const void *addr, i } #ifdef SUN4V #if __arch64__ - mutex_enter(_mtx); + __cpu_simple_lock(_lock); if (len > OFBOUNCE_MAXSIZE) panic("OF_write(len = %d) exceedes bounce buffer\n", len); memcpy(ofbounce, addr, len); @@ -564,7 +565,7 @@ OF_write(int handle, const void *addr, i } #ifdef SUN4V #if __arch64__ - mutex_exit(_mtx); + __cpu_simple_unlock(_lock); #endif #endif return act;
CVS commit: src/sys/arch/sparc
Module Name:src Committed By: palle Date: Fri Apr 1 20:21:45 UTC 2016 Modified Files: src/sys/arch/sparc/include: openfirm.h src/sys/arch/sparc/sparc: openfirm.c promlib.c Log Message: sun4v: Workaround for OpenBoot feature where a 64-bit address is truncated to a 32-bit address. This happends when a write to the console (/virtual-devices@100/console@1) is done. Avoid this by using a static buffer that is mapped below 4GB. Thanks to Tarl Neustaedter for explaining how OpenBoot works. ok martin@ To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc/include/openfirm.h cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sparc/sparc/openfirm.c cvs rdiff -u -r1.44 -r1.45 src/sys/arch/sparc/sparc/promlib.c 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/sparc/include/openfirm.h diff -u src/sys/arch/sparc/include/openfirm.h:1.9 src/sys/arch/sparc/include/openfirm.h:1.10 --- src/sys/arch/sparc/include/openfirm.h:1.9 Tue Oct 6 20:03:05 2015 +++ src/sys/arch/sparc/include/openfirm.h Fri Apr 1 20:21:45 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: openfirm.h,v 1.9 2015/10/06 20:03:05 martin Exp $ */ +/* $NetBSD: openfirm.h,v 1.10 2016/04/01 20:21:45 palle Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -61,6 +61,7 @@ typedef uint32_t cell_t; #define HDQ2CELL_LO(x) (cell_t)(x) #endif /* __sparc_v9__ */ +void OF_init(void); int OF_test(const char *); int OF_test_method(int, const char *); void OF_set_symbol_lookup(void (*)(void *), void (*)(void *)); Index: src/sys/arch/sparc/sparc/openfirm.c diff -u src/sys/arch/sparc/sparc/openfirm.c:1.20 src/sys/arch/sparc/sparc/openfirm.c:1.21 --- src/sys/arch/sparc/sparc/openfirm.c:1.20 Fri Mar 27 06:10:25 2015 +++ src/sys/arch/sparc/sparc/openfirm.c Fri Apr 1 20:21:45 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: openfirm.c,v 1.20 2015/03/27 06:10:25 nakayama Exp $ */ +/* $NetBSD: openfirm.c,v 1.21 2016/04/01 20:21:45 palle Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.20 2015/03/27 06:10:25 nakayama Exp $"); +__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.21 2016/04/01 20:21:45 palle Exp $"); #include #include @@ -44,6 +44,34 @@ __KERNEL_RCSID(0, "$NetBSD: openfirm.c,v #include #endif +#ifdef SUN4V +#ifdef __arch64__ +#define OFBOUNCE_MAXSIZE 1024 +/* + * Sun4v OpenBoot is not always happy with 64-bit addresses - an example is the + * addr parameter in the OF_write() call which can be truncated to a 32-bit + * value. + * Avoid this behaviour by using a static buffer which is assumed to be mapped + * in on a 32-bit address. + * Use a mutex to protect access to the buffer from multiple threads. + * + */ +kmutex_t ofcall_mtx; +static char ofbounce[OFBOUNCE_MAXSIZE]; +#endif +#endif + +void +OF_init(void) +{ +#ifdef SUN4V +#ifdef __arch64__ + KASSERT(((uint64_t) & 0xUL)==(uint64_t)); + mutex_init(_mtx, MUTEX_DEFAULT, IPL_NONE); +#endif +#endif +} + int OF_peer(int phandle) { @@ -512,6 +540,15 @@ OF_write(int handle, const void *addr, i if (len > 1024) { panic("OF_write(len = %d)\n", len); } +#ifdef SUN4V +#if __arch64__ + mutex_enter(_mtx); + if (len > OFBOUNCE_MAXSIZE) + panic("OF_write(len = %d) exceedes bounce buffer\n", len); + memcpy(ofbounce, addr, len); + addr = ofbounce; +#endif +#endif args.name = ADR2CELL("write"); args.nargs = 3; args.nreturns = 1; @@ -525,6 +562,11 @@ OF_write(int handle, const void *addr, i l = args.actual; act += l; } +#ifdef SUN4V +#if __arch64__ + mutex_exit(_mtx); +#endif +#endif return act; } Index: src/sys/arch/sparc/sparc/promlib.c diff -u src/sys/arch/sparc/sparc/promlib.c:1.44 src/sys/arch/sparc/sparc/promlib.c:1.45 --- src/sys/arch/sparc/sparc/promlib.c:1.44 Wed Mar 26 15:55:43 2014 +++ src/sys/arch/sparc/sparc/promlib.c Fri Apr 1 20:21:45 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: promlib.c,v 1.44 2014/03/26 15:55:43 christos Exp $ */ +/* $NetBSD: promlib.c,v 1.45 2016/04/01 20:21:45 palle Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.44 2014/03/26 15:55:43 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.45 2016/04/01 20:21:45 palle Exp $"); #if defined(_KERNEL_OPT) #include "opt_sparc_arch.h" @@ -1276,6 +1276,8 @@ prom_init_opf(void) node = findchosen(); OF_getprop(node, "stdin", _stdin, sizeof(int)); OF_getprop(node, "stdout", _stdout, sizeof(int)); + + OF_init(); } /*
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Thu Mar 3 20:45:45 UTC 2016 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: rft_kernel should pay attention to the number of register windows that can be restored. We cannot rely on fill traps to occur, since sun4v only has two trap levels available in privileged mode. Based on code from OpenBSD. ok martin@ To generate a diff of this commit: cvs rdiff -u -r1.388 -r1.389 src/sys/arch/sparc64/sparc64/locore.s 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/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.388 src/sys/arch/sparc64/sparc64/locore.s:1.389 --- src/sys/arch/sparc64/sparc64/locore.s:1.388 Sun Feb 14 21:13:33 2016 +++ src/sys/arch/sparc64/sparc64/locore.s Thu Mar 3 20:45:45 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.388 2016/02/14 21:13:33 palle Exp $ */ +/* $NetBSD: locore.s,v 1.389 2016/03/03 20:45:45 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -355,6 +355,35 @@ cputyp: .word CPU_SUN4U ! Default to sun #define CLRTT #endif + +/* + * Some macros to load and store a register window + */ + + .macro SPILL storer,base,size,asi + + .irpc n,01234567 + \storer %l\n, [\base + (\n * \size)] \asi + .endr + .irpc n,01234567 + \storer %i\n, [\base + ((8+\n) * \size)] \asi + .endr + + .endm + + + .macro FILL loader, base, size, asi + + .irpc n,01234567 + \loader [\base + (\n * \size)] \asi, %l\n + .endr + + .irpc n,01234567 + \loader [\base + ((8+\n) * \size)] \asi, %i\n + .endr + + .endm + /* * Here are some oft repeated traps as macros. */ @@ -4079,12 +4108,26 @@ return_from_trap: * */ rft_kernel: - rdpr %tl, %g4! Grab a set of trap registers + rdpr %tl, %g4 ! Grab a set of trap registers inc %g4 wrpr %g4, %g0, %tl wrpr %g3, 0, %tnpc wrpr %g2, 0, %tpc wrpr %g1, 0, %tstate + + rdpr %canrestore, %g2 + brnz %g2, 1f + nop + + wr %g0, ASI_NUCLEUS, %asi + rdpr %cwp, %g1 + dec %g1 + wrpr %g1, %cwp + FILL ldxa, %sp+BIAS, 8, %asi + restored + inc %g1 + wrpr %g1, %cwp +1: restore rdpr %tstate, %g1 ! Since we may have trapped our regs may be toast rdpr %cwp, %g2