freebsd-dev/sys/sparc64/include
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
..
_align.h
_bus.h
_inttypes.h Sync licenses and the corresponding RCS IDs with NetBSD, mainly switching 2011-03-12 14:33:32 +00:00
_limits.h Fix types of some values in machine/_limits.h. 2011-01-08 11:13:34 +00:00
_stdint.h Make the wchar_t type machine dependent. 2012-06-24 04:15:58 +00:00
_types.h Make the wchar_t type machine dependent. 2012-06-24 04:15:58 +00:00
asi.h Add support for SPARC64 V (and where it already makes sense for other 2010-05-02 19:38:17 +00:00
asm.h Add macros for alternate entry points. 2010-09-15 21:11:29 +00:00
asmacros.h - Use atomic operations rather than sched_lock for safely assigning pm_active 2011-10-06 11:01:31 +00:00
atomic.h Remove conflicting macros from SPARC64's atomic(9) header. 2013-06-15 08:23:53 +00:00
bus_common.h - Add macros for the states of the interrupt clear registers. 2009-12-22 21:48:18 +00:00
bus_dma.h Reform the busdma API so that new types may be added without modifying 2013-02-12 16:57:20 +00:00
bus_private.h Make sparc64 compatible with NEW_PCIB and enable it: 2011-10-02 23:22:38 +00:00
bus.h Make sparc64 compatible with NEW_PCIB and enable it: 2011-10-02 23:22:38 +00:00
cache.h - For Cheetah- and Zeus-class CPUs don't flush all unlocked entries from 2011-07-02 11:14:54 +00:00
ccr.h
clock.h Now that we have a working OF_printf() since r230631 and a OF_panic() 2012-01-27 23:21:54 +00:00
cmt.h - Assert that HEAPSZ is a multiple of PAGE_SIZE as at least the firmware 2010-02-13 14:13:39 +00:00
counter.h Fix issues with zeroing and fetching the counters, on x86 and ppc64. 2013-07-01 02:48:27 +00:00
cpu.h Mark cpu_{halt,reset}() as __dead2 as appropriate. 2012-01-27 22:04:43 +00:00
cpufunc.h Correct spelling in comments. 2011-04-22 09:31:40 +00:00
db_machdep.h
dcr.h Correct the DCR_IPE macro to refer to the right bit. Also improve the 2010-04-10 11:13:51 +00:00
elf.h Reserve AT_TIMEKEEP auxv entry for providing usermode the pointer to 2012-06-22 06:38:31 +00:00
endian.h Add casts to __uint16_t to the __bswap16() macros on all arches which 2012-03-09 20:34:31 +00:00
exec.h
fireplane.h - Assert that HEAPSZ is a multiple of PAGE_SIZE as at least the firmware 2010-02-13 14:13:39 +00:00
float.h Add C11 macros describing subnormal numbers to float.h. 2012-01-23 06:36:41 +00:00
floatingpoint.h
fp.h
frame.h
fsr.h Add a global MD macro for the VIS block size instead of duplicating 2012-08-31 11:15:01 +00:00
gdb_machdep.h
idprom.h
ieee.h
ieeefp.h People porting FreeBSD to new architectures ought not have to 2011-10-21 06:41:46 +00:00
in_cksum.h MFp4 bz_ipv6_fast: 2012-05-24 22:00:48 +00:00
instr.h
intr_machdep.h - Give PIL_PREEMPT the lowest priority just above low/stray interrupts. 2012-10-20 12:07:48 +00:00
iommureg.h Fix typos - remove duplicate "the". 2011-02-21 09:01:34 +00:00
iommuvar.h Sync licenses and the corresponding RCS IDs with NetBSD, mainly switching 2011-03-12 14:33:32 +00:00
jbus.h - Assert that HEAPSZ is a multiple of PAGE_SIZE as at least the firmware 2010-02-13 14:13:39 +00:00
kdb.h
kerneldump.h
ktr.h - Implement run-time expansion of the KTR buffer via sysctl. 2012-11-15 00:51:57 +00:00
limits.h
lsu.h Update for UltraSPARC-IV{,+} and SPARC64 V, VI, VII and VIIIfx CPUs. 2010-04-11 15:35:17 +00:00
mcntl.h Add support for SPARC64 V (and where it already makes sense for other 2010-05-02 19:38:17 +00:00
md_var.h For sparc64 also adjust the geometry of da(4) driven disks to not overflow 2011-11-27 15:43:40 +00:00
memdev.h Add reader/writer lock around mem_range_attr_get() and mem_range_attr_set(). 2011-01-17 22:58:28 +00:00
metadata.h
nexusvar.h - Add the 'cmp' and 'core' pseudo-busses which are used to group CPU cores 2010-02-13 18:51:49 +00:00
ofw_machdep.h - Now that we have a working OF_printf() since r230631, use it for 2012-01-27 22:35:53 +00:00
ofw_mem.h
ofw_nexus.h Sync licenses and the corresponding RCS IDs with NetBSD, mainly switching 2011-03-12 14:33:32 +00:00
param.h Rename VM_NDOMAIN into MAXMEMDOM and move it into machine/param.h in 2013-05-07 22:46:24 +00:00
pcb.h Add a convenience macro for the returns_twice attribute, and apply it to 2012-04-29 11:04:31 +00:00
pcpu.h Merge from projects/counters: 2013-04-08 19:19:10 +00:00
pmap.h Rework the known rwlock to benefit about staying on their own 2012-11-03 23:03:14 +00:00
pmc_mdep.h
proc.h Remove unused define. 2011-10-07 16:09:44 +00:00
profile.h
pstate.h
ptrace.h
reg.h
reloc.h
resource.h
runq.h
sc_machdep.h
setjmp.h
sf_buf.h
sigframe.h
signal.h
smp.h Revert the part of r239864 which removed obtaining the SMP mutex around 2013-01-23 22:52:20 +00:00
stack.h
stdarg.h
sysarch.h
tick.h - Wrap exchanging td_intr_frame and calling the event timer callback in 2010-10-19 19:44:05 +00:00
tlb.h - For Cheetah- and Zeus-class CPUs don't flush all unlocked entries from 2011-07-02 11:14:54 +00:00
trap.h
tsb.h On machines where we don't need to lock the kernel TSB into the dTLB and 2011-06-21 20:48:14 +00:00
tstate.h
tte.h - Add TTE and context register bits for the additional page sizes supported 2010-03-17 20:23:14 +00:00
ucontext.h
upa.h - Search the whole OFW device tree instead of only the children of the 2010-02-13 16:52:33 +00:00
utrap.h
varargs.h Remove the advertising clause from the UCB license according to the 2011-03-13 13:42:43 +00:00
vdso.h Implement mechanism to export some kernel timekeeping data to 2012-06-22 07:06:40 +00:00
ver.h Add macros for the VER.impl of SPARC64 II to VIIIfx. 2010-03-17 21:00:39 +00:00
vm.h
vmparam.h Rename VM_NDOMAIN into MAXMEMDOM and move it into machine/param.h in 2013-05-07 22:46:24 +00:00
watch.h
wstate.h - The firmware of Sun Fire V1280 has a misfeature of setting %wstate to 2010-03-21 13:09:54 +00:00