[Letux-kernel] SMP issue between LX16 and LX20 found...

H. Nikolaus Schaller hns at goldelico.com
Sat Jun 14 19:58:46 CEST 2025



> Am 14.06.2025 um 19:47 schrieb H. Nikolaus Schaller <hns at goldelico.com>:
> 
> Hi Paul,
> 
> now, letux-6.16-rc1 is available and I could dig again into
> some bug.
> 
> I think I have found the issue why the MIPS generic kernel with
> SMP enabled is only running on the LX20 and the LX16 panics
> during boot. It is the sysost driver and its x2000 patchesy.
> 
> It is this line:
> 
> https://git.goldelico.com/?p=letux-kernel.git;a=blob;f=drivers/clocksource/ingenic-sysost.c;h=39f339737ba694081cbbe88db86a65da3a30f246;hb=refs/heads/letux-current#l606
> 
> Apparently it is not allowed to call alloc_percpu() if there
> is only one CPU because IRQ_PER_CPU_DEVID is not set. It
> may also have something to do with enable_percpu_irq() and
> request_percpu_irq() being called only for Xburst2.
> 
> The effect of calling alloc_percpu() is that this allocation
> is released somewhere in the guts of Linux and the
> timer struct passed as opaque type has been overwritten
> when ingenic_ost_cevt_cb() is called. This panics.
> 
> The solution is to conditionally use kmalloc() instead
> for non-X2000 CPUs. What I have not yet tested is if this
> works on the CI20 - which has two CPUs...
> 
> On the other hand I would assume that alloc_percpu() should
> work even in this case and not overwrite memory.
> 
> Especially since the code following the alloc calls
> per_cpu_ptr(ost->timers, cpu). And we are lucky that
> these macros work for plain kmalloc'ed memory area.
> 
> So it may be a workaround for a more fundamental issue.

I think my "workaround" was just hiding the issue better...

I am still randomly getting kernel panics - and it is also
broken now on x2000.

So we have the issue that on x1600, ingenic_ost_cevt_cb()
breaks when doing ost->soc_info->version and the pointer
ost->soc_info is "randomized". This means that ost = timer->ost
memory area is overwritten by someone.

What is the easiest way to find out who overwrites this?

BR,
Nikolaus

Code where it breaks:

https://git.goldelico.com/?p=letux-kernel.git;a=blob;f=drivers/clocksource/ingenic-sysost.c;h=39f339737ba694081cbbe88db86a65da3a30f246;hb=refs/heads/letux-current#l349


More information about the Letux-kernel mailing list