freebsd-nq/sys
Don Lewis cd155b5603 Lower the amd64 shared page, which contains the signal trampoline,
from the top of user memory to one page lower on machines with the
Ryzen (AMD Family 17h) CPU.  This pushes ps_strings and the stack
down by one page as well.  On Ryzen there is some sort of interaction
between code running at the top of user memory address space and
interrupts that can cause FreeBSD to either hang or silently reset.
This sounds similar to the problem found with DragonFly BSD that
was fixed with this commit:
  https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/b48dd28447fc8ef62fbc963accd301557fd9ac20
but our signal trampoline location was already lower than the address
that DragonFly moved their signal trampoline to.  It also does not
appear to be related to SMT as described here:
  https://www.phoronix.com/forums/forum/hardware/processors-memory/955368-some-ryzen-linux-users-are-facing-issues-with-heavy-compilation-loads?p=955498#post955498

  "Hi, Matt Dillon here. Yes, I did find what I believe to be a
   hardware issue with Ryzen related to concurrent operations. In a
   nutshell, for any given hyperthread pair, if one hyperthread is
   in a cpu-bound loop of any kind (can be in user mode), and the
   other hyperthread is returning from an interrupt via IRETQ, the
   hyperthread issuing the IRETQ can stall indefinitely until the
   other hyperthread with the cpu-bound loop pauses (aka HLT until
   next interrupt). After this situation occurs, the system appears
   to destabilize. The situation does not occur if the cpu-bound
   loop is on a different core than the core doing the IRETQ. The
   %rip the IRETQ returns to (e.g. userland %rip address) matters a
   *LOT*. The problem occurs more often with high %rip addresses
   such as near the top of the user stack, which is where DragonFly's
   signal trampoline traditionally resides. So a user program taking
   a signal on one thread while another thread is cpu-bound can cause
   this behavior. Changing the location of the signal trampoline
   makes it more difficult to reproduce the problem. I have not
   been because the able to completely mitigate it. When a cpu-thread
   stalls in this manner it appears to stall INSIDE the microcode
   for IRETQ. It doesn't make it to the return pc, and the cpu thread
   cannot take any IPIs or other hardware interrupts while in this
   state."
since the system instability has been observed on FreeBSD with SMT
disabled.  Interrupts to appear to play a factor since running a
signal-intensive process on the first CPU core, which handles most
of the interrupts on my machine, is far more likely to trigger the
problem than running such a process on any other core.

Also lower sv_maxuser to prevent a malicious user from using mmap()
to load and execute code in the top page of user memory that was made
available when the shared page was moved down.

Make the same changes to the 64-bit Linux emulator.

PR:		219399
Reported by:	nbe@renzel.net
Reviewed by:	kib
Reviewed by:	dchagin (previous version)
Tested by:	nbe@renzel.net (earlier version)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D11780
2017-08-02 01:43:35 +00:00
..
amd64 Lower the amd64 shared page, which contains the signal trampoline, 2017-08-02 01:43:35 +00:00
arm Add the i2c RTC drivers found on various arm systems. 2017-07-30 00:25:29 +00:00
arm64 Pass the last exception trap frame to kdb_trap. This allows show registers 2017-07-26 17:39:10 +00:00
boot Alwinner: nanopi-neo: Remove r_i2c node from DTS as it isn't used on the board 2017-08-01 19:22:00 +00:00
bsm Commit the 64-bit inode project. 2017-05-23 09:29:05 +00:00
cam adaasync(): Set ADA_STATE_WCACHE based on ADA_FLAG_CAN_WCACHE 2017-07-27 07:28:29 +00:00
cddl spa_import_rootpool should be able to handle an imported root pool 2017-07-25 13:17:06 +00:00
compat Remove cycle_t type from the LinuxKPI similar to Linux upstream. 2017-07-31 09:17:54 +00:00
conf Add a driver for the Intersil ISL12xx family of i2c RTC chips. 2017-08-01 04:16:52 +00:00
contrib Merge ena-com 1.1.4.2 2017-08-01 11:00:04 +00:00
crypto Remove register keyword from sys/ and ANSIfy prototypes 2017-05-17 00:34:34 +00:00
ddb Include opt files in the kernel with "" instead of <>. 2017-07-10 05:08:01 +00:00
dev pci: fix write order when sizing BARs 2017-08-01 10:47:44 +00:00
fs Implement proper Linux /dev/fd and /proc/self/fd behavior by adding 2017-08-01 03:40:19 +00:00
gdb
geom Add GEOM::descr attribute for symmetry with GEOM::ident. 2017-07-06 08:36:14 +00:00
gnu Update DTS files from Linux 4.12 2017-07-09 13:53:32 +00:00
i386 Batch updates to v_wire_count when freeing page table pages on x86. 2017-08-01 05:26:30 +00:00
isa Protect access to the AT realtime clock with its own mutex. 2017-07-12 02:42:57 +00:00
kern Amend r321884 to check the refcount and update the class with w_mtx held. 2017-08-01 23:14:38 +00:00
kgssapi
libkern arm64: add ".arch armv8-a+crc" to allow use of crc instructions 2017-06-08 20:06:09 +00:00
mips [ar71xx] get rid of ath_pci - it's built as a module now. 2017-07-28 01:17:38 +00:00
modules Allwinner dtb: Add NanoPi M1 to the build 2017-08-01 20:28:11 +00:00
net Add inpcb pointer to struct ipsec_ctx_data and pass it to the pfil hook 2017-07-31 11:04:35 +00:00
net80211 sys/net8021: Add missing braces in setcurchan(). 2017-08-01 03:13:43 +00:00
netgraph Check return value from soaccept(). 2017-06-14 16:13:20 +00:00
netinet After inpcb route caching was put back in place there is no need for 2017-07-27 13:03:36 +00:00
netinet6 After inpcb route caching was put back in place there is no need for 2017-07-27 13:03:36 +00:00
netipsec Add inpcb pointer to struct ipsec_ctx_data and pass it to the pfil hook 2017-07-31 11:04:35 +00:00
netpfil Fix a couple of typos in a comment. 2017-07-21 03:04:55 +00:00
netsmb
nfs Improve FHA locality control for NFS read/write requests. 2017-07-31 15:23:19 +00:00
nfsclient Add an NFSv4.1 mount option for "use one openowner". 2017-04-13 21:54:19 +00:00
nfsserver
nlm Commit the 64-bit inode project. 2017-05-23 09:29:05 +00:00
ofed Avoid including list.h in LinuxKPI headers. 2017-06-18 16:43:57 +00:00
opencrypto Use const with some read-only buffers in opencrypto APIs. 2017-05-09 18:28:42 +00:00
powerpc Add cpufreq support for P1022 and MPC8536 2017-07-21 03:40:05 +00:00
riscv Clean up MD pollution of bus_dma.h: 2017-07-01 05:35:29 +00:00
rpc Listening sockets improvements. 2017-06-08 21:30:34 +00:00
security Correct bitwise test in mac_bsdextended ugidfw_rule_valid() 2017-06-13 01:17:58 +00:00
sparc64 Clean up MD pollution of bus_dma.h: 2017-07-01 05:35:29 +00:00
sys The blist_meta_* routines that process a subtree take arguments 'radix' and 2017-08-01 03:51:26 +00:00
teken
tests style(9): sort headers 2017-05-09 05:08:47 +00:00
tools make.conf: Add the possibility to use another DTC 2017-06-17 23:34:53 +00:00
ufs Avoid reading a snapshot block when it is already in the cache. 2017-07-31 20:41:45 +00:00
vm Mark pages after EOF as clean after pageout. 2017-07-26 20:07:05 +00:00
x86 Don't trace running threads that have interrupts disabled. 2017-07-31 17:57:54 +00:00
xdr * limit size of buffers to RPC_MAXDATASIZE 2017-06-01 06:12:25 +00:00
xen
Makefile Remove glimpse make target added in r181432 2017-05-22 15:53:30 +00:00