Page MenuHomeFreeBSD

amd64: prevent KCSan false positives on LAPIC mapping
ClosedPublic

Authored by jah on Sep 8 2020, 12:56 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 28, 8:56 AM
Unknown Object (File)
Dec 23 2023, 8:45 AM
Unknown Object (File)
Nov 10 2023, 10:56 PM
Unknown Object (File)
Nov 10 2023, 2:57 AM
Unknown Object (File)
Nov 8 2023, 8:29 PM
Unknown Object (File)
Nov 8 2023, 10:31 AM
Unknown Object (File)
Nov 7 2023, 6:10 AM
Unknown Object (File)
Oct 9 2023, 9:55 PM
Subscribers

Details

Summary

For configurations without x2APIC support (guests, older hardware), the global
LAPIC MMIO mapping will trigger false-positive KCSan reports as it will appear
that multiple CPUs are concurrently reading and writing the same address.
This isn't actually true, as the underlying physical access will be performed
on the local CPU's APIC. Additionally, because LAPIC access can happen during
event timer configuration, the resulting KCSan printf can produce a panic due
to attempted recursion on event timer resources.

Add a __nosanitizethread preprocessor define to prevent the compiler from
inserting TSan hooks, and apply it to the x86 LAPIC accessors.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 33437
Build 30724: arc lint + arc unit

Event Timeline

jah requested review of this revision.Sep 8 2020, 12:56 AM
jah added inline comments.
sys/x86/x86/local_apic.c
228

I'm not sure if this is the preferred way to prevent TSan instrumentation; I didn't see a blacklist or anything similar in our codebase. I really wanted to annotate lapic_map with __nosanitizethread, but clang seems to only allow the attribute on functions.

This revision is now accepted and ready to land.Sep 8 2020, 10:04 AM

Ideally tools like KSAN should exempt all non-WB memory. The normal race definition is not appropriate there.

Normally non-WB memory would be accessed via bus_space. KCSan will ignore these.

This revision was automatically updated to reflect the committed changes.