Page MenuHomeFreeBSD

clear excl monitor on context switches and data aborts
ClosedPublic

Authored by kib on Sep 14 2015, 10:27 PM.
Tags
Referenced Files
Unknown Object (File)
Nov 16 2024, 10:57 AM
Unknown Object (File)
Oct 17 2024, 9:21 AM
Unknown Object (File)
Oct 4 2024, 5:49 AM
Unknown Object (File)
Oct 1 2024, 9:44 PM
Unknown Object (File)
Oct 1 2024, 7:47 AM
Unknown Object (File)
Sep 20 2024, 7:30 AM
Unknown Object (File)
Sep 19 2024, 3:08 PM
Unknown Object (File)
Sep 19 2024, 3:08 PM
Subscribers

Details

Summary

I cannot find a mention in the documentation that ERET automatically clears exclusive monitors. If I am right, not clearing the monitor could result in the aliasing of the stxr success. Practically, this is not a likely outcome since selecting new thread includes taking at least thread locks, but I believe that doing clrex could avoid surprises.

Also, after the data abort handler call, excl monitor is in the undefined state, better clear it.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib retitled this revision from to clear excl monitor on context switches and data aborts.
kib updated this object.
kib edited the test plan for this revision. (Show Details)
kib added a reviewer: andrew.
kib set the repository for this revision to rS FreeBSD src repository - subversion.
kib added a project: arm64.

Ok, so I found a statement that ERET clears the local monitor, but I now think that the reference to ERET in my description is bogus. At least now, it seems that context switch in kernel could happen without neccesary return from the exception frame, e.g. by intr_event_handle()->critical_exit()->mi_switch() path.

So I still think that the change is correct.

sys/arm64/include/cpufunc.h
117 ↗(On Diff #8761)

I don't like the ? in this comment - we don't know?

After discussion with jhb, I was convinced that we always lock a thread when doing context switch. This removes the need for clrex in swtch.S. Still, I think that the data abort handler must clear local monitor.

sys/arm64/include/cpufunc.h
117 ↗(On Diff #8810)

Indeed, I do not know would compiler move the instruction around accesses without the "memory" constraint, which makes the asm block a compiler barrier. I think that it is more likely needed than not.

andrew edited edge metadata.
This revision is now accepted and ready to land.Sep 18 2015, 3:58 PM
sys/arm64/arm64/trap.c
158 ↗(On Diff #8810)

It would pay to add a comment here explaining the exclusive monitor state is unknown on data abort.

This revision was automatically updated to reflect the committed changes.