tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Check in cpu_switchto triggering crash with PARANOIA on



Oh I see. Thanks for the help.

Looks like the check should be spl < IPL_SCHED instead of spl != IPL_SCHED. Seems it's just that the check is bad after all.

Index: arch/mips/mips/locore.S
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/mips/locore.S,v
retrieving revision 1.226
diff -u -r1.226 locore.S
--- arch/mips/mips/locore.S     26 Sep 2020 08:21:10 -0000      1.226
+++ arch/mips/mips/locore.S     22 Feb 2021 09:49:27 -0000
@@ -224,7 +224,7 @@
        PTR_L   v0, L_CPU(MIPS_CURLWP)
        INT_L   v1, CPU_INFO_CPL(v0)
 #if __mips >= 32
-       tnei    v1, IPL_SCHED
+       tltiu   v1, IPL_SCHED
 #else
        li      v0, IPL_SCHED
 10:    bne     v0, v1, 10b

On Sun, Feb 21, 2021 at 11:22 PM Nick Hudson <nick.hudson%gmx.co.uk@localhost> wrote:
On 22/02/2021 04:15, Alan Fisher wrote:
> Hello,
>
> I've been trying to get the evbmips port working on a new chip recently,
> and in the process I've tried building the kernel with PARANOIA enabled.
> This has resulted in a crash on startup, and I am wondering if it is
> surfacing a bug. Here is what's happening:
>
> Some code under an #ifdef PARANOIA in cpu_switchto checks whether the
> IPL is IPL_SCHED, and if not, throws a trap. According to the manpage
> for cpu_switchto(9), the current IPL level being IPL_SCHED is a
> precondition for cpu_switchto(), so this check seems to make sense. The
> callstack looks like this:
>
> cpu_switchto  - this causes a trap when the check fails - manpage says
> IPL must be IPL_SCHED
> mi_switch - manpage says IPL must be IPL_SCHED
> yield - manpage doesn't say anything about IPL_SCHED, and IPL is not
> changed in this routine


     276 yield(void)
     277 {
     278        struct lwp *l = curlwp;
     279
     280        KERNEL_UNLOCK_ALL(l, &l->l_biglocks);
     281        lwp_lock(l);

lwp_lock will raise the IPL to IPL_SCHED. spc_{lock,mutex} are used by
lwp_lock (maybe others)
HTH,

Nick


Home | Main Index | Thread Index | Old Index