]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Add missed barrier for pm_gen/pm_active interaction.
authorKonstantin Belousov <kib@FreeBSD.org>
Mon, 21 May 2018 18:41:16 +0000 (18:41 +0000)
committerKonstantin Belousov <kib@FreeBSD.org>
Mon, 21 May 2018 18:41:16 +0000 (18:41 +0000)
commit0a4b04a616033b881841bc79a5b4d4f922217c5e
tree432c9cb8d1c5f58334a0a291873104af4e8e66c8
parent733efc21c442d2285fea73d77d6234b3bc4a9354
Add missed barrier for pm_gen/pm_active interaction.

When we issue shootdown IPIs, we first assign zero to pm_gens to
indicate the need to flush on the next context switch in case our IPI
misses the context, next we read pm_active. On context switch we set
our bit in pm_active, then we read pm_gen. It is crucial that both
threads see the memory in the program order, otherwise invalidation
thread might read pm_active bit as zero and the context switching
thread might read pm_gen as zero.

IA32 allows CPU for both reads to see zero. We must use the barriers
between write and read. The pm_active bit set is already locked, so
only the invalidation functions need it.

I never saw it in real life, or at least I do not have a good
reproduction case. I found this during code inspection when hunting
for the Xen TLB issue reported by cperciva.

Reviewed by: alc, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D15506
sys/amd64/amd64/pmap.c