]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix the PCPU access macros. It was found that the PCPU pointer, when
authormarcel <marcel@FreeBSD.org>
Sat, 6 Sep 2014 22:17:54 +0000 (22:17 +0000)
committermarcel <marcel@FreeBSD.org>
Sat, 6 Sep 2014 22:17:54 +0000 (22:17 +0000)
commit1e706702bd14e7d6c5f41f15ee0b520bd11c4933
treedc3cc8b693f49ed1f3a8b91f4a332f381d0f4403
parent52ea0d605b89848405b35ae619de564ae70badb5
Fix the PCPU access macros. It was found that the PCPU pointer, when
held in register r13, is used outside the bounds of critical_enter()
and critical_exit() by virtue of optimizations performed by the
compiler. The net effect being that address computations of fields
in the PCPU structure could be relative to the PCPU structure of the
CPU on which the address computation was performed and not related
to the CPU that executes the actual load or store operation.
The typical failure mode being that the per-CPU cache of UMA got
corrupted due to accesses from other CPUs.

Adding more volatile decorating to the register expression does not
help. The thinking being that volatile is assumed to work on memory
references and not register references. Thus, the fix is to perform
the address computation using a volatile inline assembly statement.

Additionally, since the reference is fundamentally non-atomic on ia64
by virtue of have a distinct address computation followed by the
actual load or store operation, it is required to wrap the entire
PCPU access in a critical section.

With PCPU_GET and friends requiring curthread now that they're in a
critical section, low-level use of these macros in functions like
cpu_switch() is not possible anymore. Consequently, a second order
set of changes is needed to avoid using PCPU_GET and friends where
curthread is either not set yet, or in the process of being changed.
In those cases, explicit dereferencing of pcpup is needed. In those
cases it is also possible to do that.

This is a direct commit to stable/10.

Approved by: re@ (marius)
sys/ia64/ia64/highfp.c
sys/ia64/ia64/machdep.c
sys/ia64/ia64/mp_machdep.c
sys/ia64/ia64/xtrace.c
sys/ia64/include/pcpu.h