Re: Kernel crash due to memory corruption with v5.4.26-rt17 and PowerPC e500

From: Mark Marshall
Date: Fri May 29 2020 - 11:38:55 EST

Hi Sebastian & list,

I had assumed that my e-mail had got lost or overlooked, I was meaning to
post a follow up message this week...

All I could find from the debugging and tracing that we added was that
something was going wrong with the mm data structures somewhere in the
exec code. In the end I just spent a week or two pouring over the diffs
of this code between the versions that I new worked and didn't work.

I eventually found the culprit. On the working kernel versions there is
a patch called "mm: Protect activate_mm() by preempt_[disable&enable]_rt()".
This is commit f0b4a9cb253a on the V4.19.82-rt30 branch, for instance.
Although the commit message talks about ARM, it seems that we need this for
PowerPC too (I guess, any PowerPC with the "nohash" MMU?).

Could you please add this commit back to the RT branch? I'm not sure how
to find out the history of this commit. For instance, why has it been
removed from the RT patchset? How are these things tracked, generally?

Best regards,

On Fri, 29 May 2020 at 15:14, Sebastian Andrzej Siewior
<bigeasy@xxxxxxxxxxxxx> wrote:
> On 2020-05-04 11:40:08 [+0200], Mark Marshall wrote:
> > The easiest way we have found to reproduce the crash is to repeatedly
> > insert and then remove a module. The crash then appears to be related
> > to either paging in the module or in exiting the mdev process. (The
> > crash does also happen at other times, but it is hard to reproduce
> > reliably then). This simple script will almost always crash:
> >
> > for i in $(seq 1000) ; do echo $i ; modprobe crc7 ; rmmod crc7 ; done
> So I tried that on 5.6.14-rt7 with the qemu version of e500 (the SMP and
> UP version). No luck. I don't have anything with real hardware.
> Could you share the .config in case this is related?
> > (The crc7 module is chosen as it is small and simple. Any module will
> > work / crash).
> >
> > We have tried kernels v5.0, v5.2 and v5.6. The v5.0 and v5.2 kernels
> > do not show the problem. The v5.6 kernel does show the problem.
> > Switching of RT fixes the problem.
> >
> > I have reduced the functionality in the kernel to a bare minimum
> > (removing networking, USB and PCI, as we have some out-of-tree patches
> > in those areas) and we still get the crash.
> â
> > I have added some debugging code where the mm_struct and
> > vma_area_struct have "poision" values at the start and the end, and
> > this seems to show that the vma_area_struct is getting corrupted, but
> > I'm not able to see where.
> oh.
> > We have switched on all of the debugging that we can, including
> > KASAN, and this shows nothing.
> >
> >
> > Can anyone help us? What can we try next? Is anyone using the e500
> > with the RT kernel? Does anyone have any idea how to debug problems
> > related to the error message "Bad rss-counter state"?
> >
> > Any help or advice would be most gratefully received.
> I don't have any ideas. You could try to apply only a part of the RT
> patch and see if it problem is still there. If you are lucky you find
> the patch that introduces the problem. If not, the problem appears with
> the RT switchâ
> > Many thanks,
> > Mark Marshall and Thomas Graziadei
> Sebastian