Fwd: arm: cpu_switch() has bug?

Olivier Houchard mlfbsd at ci0.org
Mon Jan 14 14:51:18 UTC 2013


Hi,

> Hi,
> 
> I have doubt if cpu_switch() of arm has a bug.
> 
> In swtch.S:L.334, if newtd->td_pcb (this is in stack pointer for
> kernel) has an address accessed first for the old(current) thread,
> data_abort_fault may occur.
> 
> When data_abort_fault occurs, data_abort_handler() tries to solve this
> address from kernel_map. In this time, curthread and curpcb are
> already updated in swtch.S:L.223-231. As this result,
> data_abort_handler() will occur data_abort_fault in trap.c:L.301, again.
> 
> When I check, in other CPUs, after updating the root pointer of MMU,
> curthread and curpcb are updated.
> 
> Would you please check this?
> 
> Thanks,
>  Kohji Okuno

I don't think it can happen, when we reach cpu_switch(), both the old thread
and the new thread should be swapped in, so the kstack for both will be mapped,
and we won't get a data abort when trying to access it.
I agree however it may come back to hunt us one day, so I'll see if I can not
easily move that later in the process, after we switched the page tables.

Regards,

Olivier


More information about the freebsd-arm mailing list