Date: Tue, 22 Oct 2019 11:40:36 -0400 From: Mark Johnston <markj@freebsd.org> To: Gleb Smirnoff <glebius@freebsd.org> Cc: Li-Wen Hsu <lwhsu@freebsd.org>, br@freebsd.org, src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>, svn-src-head <svn-src-head@freebsd.org> Subject: Re: svn commit: r353876 - head/sys/kern Message-ID: <20191022154036.GE540@raichu> In-Reply-To: <20191022152913.GJ4086@FreeBSD.org> References: <201910212312.x9LNCEbX052414@repo.freebsd.org> <CAKBkRUzTs%2BSpUr0AFoj%2Bmt2im_0TDDc5bq-E0N5SwAV%2BV7BpEQ@mail.gmail.com> <20191022152913.GJ4086@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Oct 22, 2019 at 08:29:13AM -0700, Gleb Smirnoff wrote: > Li-Wen, > > On Tue, Oct 22, 2019 at 04:28:45PM +0800, Li-Wen Hsu wrote: > L> > Modified: head/sys/kern/subr_epoch.c > L> > ============================================================================== > L> > --- head/sys/kern/subr_epoch.c Mon Oct 21 21:21:34 2019 (r353875) > L> > +++ head/sys/kern/subr_epoch.c Mon Oct 21 23:12:14 2019 (r353876) > L> > @@ -366,9 +366,13 @@ _epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et > L> > struct thread *td; > L> > > L> > MPASS(cold || epoch != NULL); > L> > - INIT_CHECK(epoch); > L> > MPASS(epoch->e_flags & EPOCH_PREEMPT); > L> > td = curthread; > L> > + MPASS((vm_offset_t)et >= td->td_kstack && > L> > + (vm_offset_t)et + sizeof(struct epoch_tracker) < > L> > + td->td_kstack + td->td_kstack_pages * PAGE_SIZE); > L> > + > L> > + INIT_CHECK(epoch); > L> > #ifdef EPOCH_TRACE > L> > epoch_trace_enter(td, epoch, et, file, line); > L> > #endif > L> > L> Hello Gleb, > L> > L> RISC-V boot panics with this message: > L> > L> panic: Assertion (vm_offset_t)et >= td->td_kstack && (vm_offset_t)et + > L> sizeof(struct epoch_tracker) < td->td_kstack + td->td_kstack_pages * > L> PAGE_SIZE failed at /workspace/src/sys/kern/subr_epoch.c:373 > L> > L> Full log: https://ci.freebsd.org/job/FreeBSD-head-riscv64-test/12334/console > L> > L> Can you help check this? > > I need help from RISC-V experts. I suspect the problem is that init_proc0() on several arches does not initialize td_kstack_pages. I will test this patch and commit if it fixes the panic. Note that on arm64 and riscv thread0's kernel stack is statically allocated. diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c index dc0a84404f02..990c3df49328 100644 --- a/sys/arm/arm/machdep.c +++ b/sys/arm/arm/machdep.c @@ -771,6 +771,7 @@ init_proc0(vm_offset_t kstack) { proc_linkup0(&proc0, &thread0); thread0.td_kstack = kstack; + thread0.td_kstack_pages = kstack_pages; thread0.td_pcb = (struct pcb *) (thread0.td_kstack + kstack_pages * PAGE_SIZE) - 1; thread0.td_pcb->pcb_flags = 0; diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index 4356add12aa0..967e1deaa55e 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -745,6 +745,7 @@ init_proc0(vm_offset_t kstack) proc_linkup0(&proc0, &thread0); thread0.td_kstack = kstack; + thread0.td_kstack_pages = KSTACK_PAGES; thread0.td_pcb = (struct pcb *)(thread0.td_kstack) - 1; thread0.td_pcb->pcb_fpflags = 0; thread0.td_pcb->pcb_fpusaved = &thread0.td_pcb->pcb_fpustate; diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c index e01f7e42895d..07113534706e 100644 --- a/sys/riscv/riscv/machdep.c +++ b/sys/riscv/riscv/machdep.c @@ -658,6 +658,7 @@ init_proc0(vm_offset_t kstack) proc_linkup0(&proc0, &thread0); thread0.td_kstack = kstack; + thread0.td_kstack_pages = KSTACK_PAGES; thread0.td_pcb = (struct pcb *)(thread0.td_kstack) - 1; thread0.td_pcb->pcb_fpflags = 0; thread0.td_frame = &proc0_tf;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20191022154036.GE540>