freebsd-dev/sys/i386
Konstantin Belousov 70a7dd5d5b Fix issues with zeroing and fetching the counters, on x86 and ppc64.
Issues were noted by Bruce Evans and are present on all architectures.

On i386, a counter fetch should use atomic read of 64bit value,
otherwise carry from the increment on other CPU could be lost for the
given fetch, making error of 2^32.  If 64bit read (cmpxchg8b) is not
available on the machine, it cannot be SMP and it is enough to disable
preemption around read to avoid the split read.

On x86 the counter increment is not atomic on purpose, which makes it
possible for the store of the incremented result to override just
zeroed per-cpu slot.  The effect would be a counter going off by
arbitrary value after zeroing.  Perform the counter zeroing on the
same processor which does the increments, making the operations
mutually exclusive.  On i386, same as for the fetching, if the
cmpxchg8b is not available, machine is not SMP and we disable
preemption for zeroing.

PowerPC64 is treated the same as amd64.

For other architectures, the changes made to allow the compilation to
succeed, without fixing the issues with zeroing or fetching.  It
should be possible to handle them by using the 64bit loads and stores
atomic WRT preemption (assuming the architectures also converted from
using critical sections to proper asm).  If architecture does not
provide the facility, using global (spin) mutex would be non-optimal
but working solution.

Noted by:  bde
Sponsored by:	The FreeBSD Foundation
2013-07-01 02:48:27 +00:00
..
acpica Consistently use round_page(x) rather than roundup(x, PAGE_SIZE). There is 2013-02-15 22:43:08 +00:00
bios This isn't functionally identical. In some cases a hint to disable 2012-10-22 13:06:09 +00:00
conf Driver 'aacraid' added. Supports Adaptec by PMC RAID controller families Series 6, 7, 8 and upcoming products. Older Adaptec RAID controller families are supported by the 'aac' driver. 2013-05-24 09:22:43 +00:00
i386 Some clarifications and updates for the comments, mostly retrieved 2013-06-19 05:05:16 +00:00
ibcs2 Merge Capsicum overhaul: 2013-03-02 00:53:12 +00:00
include Fix issues with zeroing and fetching the counters, on x86 and ppc64. 2013-07-01 02:48:27 +00:00
isa - Correct spelling in comments 2013-04-17 11:56:11 +00:00
linux Reduce duplication between i386/linux/linux.h and amd64/linux32/linux.h 2013-01-29 18:41:30 +00:00
pci Remove duplicate code. Reduce diff between amd64 and i386. 2012-12-01 00:56:19 +00:00
svr4 Change some movl's to mov's. Newer GAS no longer accept 'movl' instructions 2009-01-31 11:37:21 +00:00
xbox Move the legacy(4) driver to x86. 2012-03-30 19:10:14 +00:00
xen Adjust i386 Xen PV support for updated Xen interface files. 2013-06-17 01:43:07 +00:00
Makefile Delete duplicate tags entry I introduced in -r223901. 2011-07-15 17:27:26 +00:00