Page MenuHomeFreeBSD

Fix r356919.
ClosedPublic

Authored by kib on Jan 23 2020, 11:18 AM.

Details

Summary

Instead of waiting for pc_curthread which is overwritten by init_secondary_tail(), wait for pc_curpcb.
Assert that pc_curpcb is not set too early.

Reported by: rlibby

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

kib created this revision.Jan 23 2020, 11:18 AM
markj added a comment.Jan 23 2020, 1:51 PM

Isn't curpcb set while still on the old stack? We load the new rsp after setting curpcb. In fact, the same is true for curthread, I didn't notice it before.

kib added a comment.Jan 23 2020, 2:03 PM

Isn't curpcb set while still on the old stack? We load the new rsp after setting curpcb. In fact, the same is true for curthread, I didn't notice it before.

You mean that %rsp points to the old stack. cpu_switch does not access it at all after the old thread is unblocked. It must be because old thread might already start executing on another CPU. Interrupts are disabled, and non-maskable interrupts like NMI or MCE use non-zero ist.

markj accepted this revision.Jan 23 2020, 2:07 PM
In D23330#511544, @kib wrote:

Isn't curpcb set while still on the old stack? We load the new rsp after setting curpcb. In fact, the same is true for curthread, I didn't notice it before.

You mean that %rsp points to the old stack. cpu_switch does not access it at all after the old thread is unblocked. It must be because old thread might already start executing on another CPU. Interrupts are disabled, and non-maskable interrupts like NMI or MCE use non-zero ist.

I see, thanks.

This revision is now accepted and ready to land.Jan 23 2020, 2:07 PM
rlibby accepted this revision.Jan 23 2020, 4:56 PM

Looks good. Thanks. I applied this patch and rebooted about ten times and saw no issues (previous frequency for me was maybe 1/3).

This revision was automatically updated to reflect the committed changes.
kib added a commit: rS357054: Fix r356919..