From gonzo at bluezbox.com Mon Aug 10 02:20:34 2009 From: gonzo at bluezbox.com (Oleksandr Tymoshenko) Date: Mon Aug 10 02:20:41 2009 Subject: Diffs to fix L1 cache flush problems In-Reply-To: <153254.15259.qm@web34402.mail.mud.yahoo.com> References: <153254.15259.qm@web34402.mail.mud.yahoo.com> Message-ID: <4A7F7CDB.2030009@bluezbox.com> Neelkanth Natu wrote: > Hi, > > This is a simple change that fixes problems invalidating L1 > data/instruction caches. The problem is that the type of the variable > that holds the size of the instruction/data caches is uint8_t. Clearly > this is going to overflow. > > On the Sibyte with 32KB cache size the uint8_t was causing it to be > truncated to 0. This in turn makes the cache flush routines turn into > no-ops. > > I ran into this when testing kernel loadable modules and have verified that > this change fixes the problem. Thanks, committed. From tinderbox at freebsd.org Fri Aug 14 05:09:03 2009 From: tinderbox at freebsd.org (FreeBSD Tinderbox) Date: Fri Aug 14 05:09:19 2009 Subject: [head tinderbox] failure on mips/mips Message-ID: <20090814050859.BDE357302F@freebsd-current.sentex.ca> TB --- 2009-08-14 04:04:42 - tinderbox 2.6 running on freebsd-current.sentex.ca TB --- 2009-08-14 04:04:42 - starting HEAD tinderbox run for mips/mips TB --- 2009-08-14 04:04:42 - cleaning the object tree TB --- 2009-08-14 04:05:02 - cvsupping the source tree TB --- 2009-08-14 04:05:02 - /usr/bin/csup -z -r 3 -g -L 1 -h localhost -s /tinderbox/HEAD/mips/mips/supfile TB --- 2009-08-14 04:05:09 - building world TB --- 2009-08-14 04:05:09 - MAKEOBJDIRPREFIX=/obj TB --- 2009-08-14 04:05:09 - PATH=/usr/bin:/usr/sbin:/bin:/sbin TB --- 2009-08-14 04:05:09 - TARGET=mips TB --- 2009-08-14 04:05:09 - TARGET_ARCH=mips TB --- 2009-08-14 04:05:09 - TZ=UTC TB --- 2009-08-14 04:05:09 - __MAKE_CONF=/dev/null TB --- 2009-08-14 04:05:09 - cd /src TB --- 2009-08-14 04:05:09 - /usr/bin/make -B buildworld >>> World build started on Fri Aug 14 04:05:11 UTC 2009 >>> Rebuilding the temporary build tree >>> stage 1.1: legacy release compatibility shims >>> stage 1.2: bootstrap tools >>> stage 2.1: cleaning up the object tree >>> stage 2.2: rebuilding the object tree >>> stage 2.3: build tools >>> stage 3: cross tools >>> stage 4.1: building includes >>> stage 4.2: building libraries >>> stage 4.3: make dependencies >>> stage 4.4: building everything [...] ===> usr.sbin/mfiutil (all) cc -O -pipe -EL -msoft-float -G0 -mno-dsp -mabicalls -fno-builtin-strftime -std=gnu99 -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wno-pointer-sign -c /src/usr.sbin/mfiutil/mfiutil.c cc -O -pipe -EL -msoft-float -G0 -mno-dsp -mabicalls -fno-builtin-strftime -std=gnu99 -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wno-pointer-sign -c /src/usr.sbin/mfiutil/mfi_cmd.c cc -O -pipe -EL -msoft-float -G0 -mno-dsp -mabicalls -fno-builtin-strftime -std=gnu99 -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wno-pointer-sign -c /src/usr.sbin/mfiutil/mfi_config.c cc -O -pipe -EL -msoft-float -G0 -mno-dsp -mabicalls -fno-builtin-strftime -std=gnu99 -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wno-pointer-sign -c /src/usr.sbin/mfiutil/mfi_drive.c cc1: warnings being treated as errors /src/usr.sbin/mfiutil/mfi_drive.c: In function 'mfi_lookup_drive': /src/usr.sbin/mfiutil/mfi_drive.c:120: warning: comparison between signed and unsigned *** Error code 1 Stop in /src/usr.sbin/mfiutil. *** Error code 1 Stop in /src/usr.sbin. *** Error code 1 Stop in /src. *** Error code 1 Stop in /src. *** Error code 1 Stop in /src. TB --- 2009-08-14 05:08:59 - WARNING: /usr/bin/make returned exit code 1 TB --- 2009-08-14 05:08:59 - ERROR: failed to build world TB --- 2009-08-14 05:08:59 - 2959.47 user 335.62 system 3856.79 real http://tinderbox.des.no/tinderbox-head-HEAD-mips-mips.full From tinderbox at freebsd.org Fri Aug 14 13:28:52 2009 From: tinderbox at freebsd.org (FreeBSD Tinderbox) Date: Fri Aug 14 13:29:19 2009 Subject: [head tinderbox] failure on mips/mips Message-ID: <20090814132848.1232B7302F@freebsd-current.sentex.ca> TB --- 2009-08-14 12:24:37 - tinderbox 2.6 running on freebsd-current.sentex.ca TB --- 2009-08-14 12:24:37 - starting HEAD tinderbox run for mips/mips TB --- 2009-08-14 12:24:37 - cleaning the object tree TB --- 2009-08-14 12:24:55 - cvsupping the source tree TB --- 2009-08-14 12:24:55 - /usr/bin/csup -z -r 3 -g -L 1 -h localhost -s /tinderbox/HEAD/mips/mips/supfile TB --- 2009-08-14 12:25:04 - building world TB --- 2009-08-14 12:25:04 - MAKEOBJDIRPREFIX=/obj TB --- 2009-08-14 12:25:04 - PATH=/usr/bin:/usr/sbin:/bin:/sbin TB --- 2009-08-14 12:25:04 - TARGET=mips TB --- 2009-08-14 12:25:04 - TARGET_ARCH=mips TB --- 2009-08-14 12:25:04 - TZ=UTC TB --- 2009-08-14 12:25:04 - __MAKE_CONF=/dev/null TB --- 2009-08-14 12:25:04 - cd /src TB --- 2009-08-14 12:25:04 - /usr/bin/make -B buildworld >>> World build started on Fri Aug 14 12:25:05 UTC 2009 >>> Rebuilding the temporary build tree >>> stage 1.1: legacy release compatibility shims >>> stage 1.2: bootstrap tools >>> stage 2.1: cleaning up the object tree >>> stage 2.2: rebuilding the object tree >>> stage 2.3: build tools >>> stage 3: cross tools >>> stage 4.1: building includes >>> stage 4.2: building libraries >>> stage 4.3: make dependencies >>> stage 4.4: building everything [...] ===> usr.sbin/mfiutil (all) cc -O -pipe -EL -msoft-float -G0 -mno-dsp -mabicalls -fno-builtin-strftime -std=gnu99 -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wno-pointer-sign -c /src/usr.sbin/mfiutil/mfiutil.c cc -O -pipe -EL -msoft-float -G0 -mno-dsp -mabicalls -fno-builtin-strftime -std=gnu99 -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wno-pointer-sign -c /src/usr.sbin/mfiutil/mfi_cmd.c cc -O -pipe -EL -msoft-float -G0 -mno-dsp -mabicalls -fno-builtin-strftime -std=gnu99 -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wno-pointer-sign -c /src/usr.sbin/mfiutil/mfi_config.c cc -O -pipe -EL -msoft-float -G0 -mno-dsp -mabicalls -fno-builtin-strftime -std=gnu99 -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wno-pointer-sign -c /src/usr.sbin/mfiutil/mfi_drive.c cc1: warnings being treated as errors /src/usr.sbin/mfiutil/mfi_drive.c: In function 'mfi_lookup_drive': /src/usr.sbin/mfiutil/mfi_drive.c:120: warning: comparison between signed and unsigned *** Error code 1 Stop in /src/usr.sbin/mfiutil. *** Error code 1 Stop in /src/usr.sbin. *** Error code 1 Stop in /src. *** Error code 1 Stop in /src. *** Error code 1 Stop in /src. TB --- 2009-08-14 13:28:47 - WARNING: /usr/bin/make returned exit code 1 TB --- 2009-08-14 13:28:47 - ERROR: failed to build world TB --- 2009-08-14 13:28:47 - 2958.74 user 336.41 system 3850.43 real http://tinderbox.des.no/tinderbox-head-HEAD-mips-mips.full From tinderbox at freebsd.org Wed Aug 19 12:38:55 2009 From: tinderbox at freebsd.org (FreeBSD Tinderbox) Date: Wed Aug 19 12:39:02 2009 Subject: [head tinderbox] failure on mips/mips Message-ID: <200908191238.n7JCcNjC001147@freebsd-current2.sentex.ca> TB --- 2009-08-19 12:30:01 - tinderbox 2.6 running on freebsd-current2.sentex.ca TB --- 2009-08-19 12:30:01 - starting HEAD tinderbox run for mips/mips TB --- 2009-08-19 12:30:01 - mkdir /tinderbox/HEAD/mips TB --- 2009-08-19 12:30:01 - mkdir /tinderbox/HEAD/mips/mips TB --- 2009-08-19 12:30:01 - cleaning the object tree TB --- 2009-08-19 12:30:01 - checking out /src from http://svn.freebsd.org/base/ TB --- 2009-08-19 12:30:01 - cd /tinderbox/HEAD/mips/mips TB --- 2009-08-19 12:30:01 - /usr/local/bin/svn checkout http://svn.freebsd.org/base//head /src TB --- 2009-08-19 12:38:20 - WARNING: /usr/local/bin/svn caught signal 10 TB --- 2009-08-19 12:38:20 - ERROR: unable to check out the source tree TB --- 2009-08-19 12:38:20 - 14.77 user 30.47 system 499.02 real http://tinderbox.des.no/tinderbox-head-HEAD-mips-mips.full From tinderbox at freebsd.org Wed Aug 19 14:05:36 2009 From: tinderbox at freebsd.org (FreeBSD Tinderbox) Date: Wed Aug 19 14:06:16 2009 Subject: [head tinderbox] failure on mips/mips Message-ID: <200908191405.n7JE51hq001160@freebsd-current2.sentex.ca> TB --- 2009-08-19 14:05:01 - tinderbox 2.6 running on freebsd-current2.sentex.ca TB --- 2009-08-19 14:05:01 - starting HEAD tinderbox run for mips/mips TB --- 2009-08-19 14:05:01 - cleaning the object tree TB --- 2009-08-19 14:05:01 - checking out /src from http://svn.freebsd.org/base/ TB --- 2009-08-19 14:05:01 - cd /tinderbox/HEAD/mips/mips TB --- 2009-08-19 14:05:01 - /usr/local/bin/svn update /src TB --- 2009-08-19 14:05:01 - WARNING: /usr/local/bin/svn returned exit code 1 TB --- 2009-08-19 14:05:01 - ERROR: unable to check out the source tree TB --- 2009-08-19 14:05:01 - 0.03 user 0.01 system 0.03 real http://tinderbox.des.no/tinderbox-head-HEAD-mips-mips.full From neelnatu at yahoo.com Thu Aug 20 06:16:11 2009 From: neelnatu at yahoo.com (Neelkanth Natu) Date: Thu Aug 20 06:16:17 2009 Subject: PATCH: fork_trampoline returning to an incorrect address Message-ID: <82309.86773.qm@web34407.mail.mud.yahoo.com> Fix a problem seen when a new process was returning to userland through fork_trampoline. This was caused because we were clearing the SR_INT_IE and setting SR_EXL bits of the status register at the same time. This means that if an interrupt happened while this MTC0 was making its way through the pipeline the exception processing would see the status register with SR_EXL bit set. This in turn would mean that the COP_0_EXC_PC would not be updated so the return from exception would be to an incorrect address. It is easy to verify this fix by a program that forks in a loop and the child just exits: while (1) { pid_t pid = vfork(); if (pid == 0) _exit(0); if (pid != -1) waitpid(pid, NULL, 0); } Affected files ... ... //depot/user/neelnatu/projects_mips_sibyte/src/sys/mips/include/cpuregs.h#2 edit ... //depot/user/neelnatu/projects_mips_sibyte/src/sys/mips/mips/swtch.S#2 edit Differences ... ==== //depot/user/neelnatu/projects_mips_sibyte/src/sys/mips/include/cpuregs.h#2 (text) ==== @@ -106,7 +106,7 @@ #elif defined(CPU_SB1) #define COP0_SYNC ssnop; ssnop; ssnop; ssnop; ssnop; ssnop; ssnop; ssnop; ssnop #else -#define COP0_SYNC /* nothing */ +#define COP0_SYNC nop; nop; nop; nop; nop #endif #define COP0_HAZARD_FPUENABLE nop; nop; nop; nop; ==== //depot/user/neelnatu/projects_mips_sibyte/src/sys/mips/mips/swtch.S#2 (text) ==== @@ -161,25 +161,37 @@ DO_AST -/* - * Since interrupts are enabled at this point, we use a1 instead of - * k0 or k1 to store the PCB pointer. This is because k0 and k1 - * are not preserved across interrupts. - */ - GET_CPU_PCPU(a1) - lw a1, PC_CURPCB(a1) -1: + /* + * Clear the SR_INT_ENAB bit before setting the SR_EXL bit. + * + * The problem with doing them together is if an interrupt happens + * while the change makes its way through the pipeline. + * + * According to the MIPS32 Architecture for Programmers Vol2: + * "an exception or interrupt also clears both execution and + * instruction hazards" + * + * This implies that the exception will see the status register + * with the IE bit clear and EXL bit set. Since the EXL bit is set + * the COP_0_EXC_PC will not be updated and the return from exception + * will be to an incorrect address. + */ + mfc0 v0, COP_0_STATUS_REG + and v0, ~(SR_INT_ENAB) # disable interrupts + mtc0 v0, COP_0_STATUS_REG + COP0_SYNC + + or v0, SR_EXL # set exception level bit + mtc0 v0, COP_0_STATUS_REG + COP0_SYNC - mfc0 v0, COP_0_STATUS_REG # set exeption level bit. - or v0, SR_EXL - and v0, ~(SR_INT_ENAB) - mtc0 v0, COP_0_STATUS_REG # set exeption level bit. - nop - nop - nop - nop + /* + * Since 'k1' is trashed during exception processing its use is safe + * only after the point where we are sure not to be interrupted. + */ .set noat - move k1, a1 + GET_CPU_PCPU(k1) + lw k1, PC_CURPCB(k1) RESTORE_U_PCB_REG(t0, MULLO, k1) RESTORE_U_PCB_REG(t1, MULHI, k1) mtlo t0