freebsd-dev/sys/mips
Konstantin Belousov 30b3018d48 Provide protection against starvation of the ll/sc loops when accessing userpace.
Casueword(9) on ll/sc architectures must be prepared for userspace
constantly modifying the same cache line as containing the CAS word,
and not loop infinitely.  Otherwise, rogue userspace livelocks the
kernel.

To fix the issue, change casueword(9) interface to return new value 1
indicating that either comparision or store failed, instead of relying
on the oldval == *oldvalp comparison.  The primitive no longer retries
the operation if it failed spuriously.  Modify callers of
casueword(9), all in kern_umtx.c, to handle retries, and react to
stops and requests to terminate between retries.

On x86, despite cmpxchg should not return spurious failures, we can
take advantage of the new interface and just return PSL.ZF.

Reviewed by:	andrew (arm64, previous version), markj
Tested by:	pho
Reported by:	https://xenbits.xen.org/xsa/advisory-295.txt
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D20772
2019-07-12 18:43:24 +00:00
..
atheros Display CPU model in dmesg on mips targets 2019-05-24 01:43:35 +00:00
beri Add SMP support for BERI CPU. 2018-04-12 17:43:19 +00:00
broadcom add snps IP uart support / genaralize UART 2018-08-19 21:10:21 +00:00
cavium octusb: fix detach loop over USB ports 2019-06-01 18:19:16 +00:00
conf Add support for extended descriptor format to Altera mSGDMA driver. 2019-06-27 18:08:18 +00:00
include mips: Implement basic pmap_kenter_device, pmap_kremove_device 2019-05-16 19:10:48 +00:00
ingenic Fix compile errors with the CI20 2019-07-10 17:21:59 +00:00
malta add snps IP uart support / genaralize UART 2018-08-19 21:10:21 +00:00
mediatek sys: Remove DEV_RANDOM device option 2019-06-21 00:16:30 +00:00
mips Provide protection against starvation of the ll/sc loops when accessing userpace. 2019-07-12 18:43:24 +00:00
nlm [mips] Fix error condition check that always evaluates to false 2019-01-25 20:14:28 +00:00