freebsd-skq/sys
John Baldwin 2c352feb3b Fix missed posted interrupts in VT-x in bhyve.
When a vCPU is HLTed, interrupts with a priority below the processor
priority (PPR) should not resume the vCPU while interrupts at or above
the PPR should.  With posted interrupts, bhyve maintains a bitmap of
pending interrupts in PIR descriptor along with a single 'pending'
bit.  This bit is checked by a CPU running in guest mode at various
places to determine if it should be checked.  In addition, another CPU
can force a CPU in guest mode to check for pending interrupts by
sending an IPI to a special IDT vector reserved for this purpose.

bhyve had a bug in that it would only notify a guest vCPU of an
interrupt (e.g. by sending the special IPI or by resuming it if it was
idle due to HLT) if an interrupt arrived that was higher priority than
PPR and no interrupts were currently pending.  This assumed that if
the 'pending' bit was set, any needed notification was already in
progress.  However, if the first interrupt sent to a HLTed vCPU was
lower priority than PPR and the second was higher than PPR, the first
interrupt would set 'pending' but not notify the vCPU, and the second
interrupt would not notify the vCPU because 'pending' was already set.
To fix this, track the priority of pending interrupts in a separate
per-vCPU bitmask and notify a vCPU anytime an interrupt arrives that
is above PPR and higher than any previously-received interrupt.

This was found and debugged in the bhyve port to SmartOS maintained by
Joyent.  Relevant SmartOS bugs with more background:

https://smartos.org/bugview/OS-6829
https://smartos.org/bugview/OS-6930
https://smartos.org/bugview/OS-7354

Submitted by:	Patrick Mooney <pmooney@pfmooney.com>
Reviewed by:	tychon, rgrimes
Obtained from:	SmartOS / Joyent
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D19299
2019-03-01 20:43:48 +00:00
..
amd64 Fix missed posted interrupts in VT-x in bhyve. 2019-03-01 20:43:48 +00:00
arm Remove sv_pagesize, originally introduced with r100384. 2019-03-01 16:16:38 +00:00
arm64 Remove sv_pagesize, originally introduced with r100384. 2019-03-01 16:16:38 +00:00
bsm Create new EINTEGRITY error with message "Integrity check failed". 2019-01-17 06:35:45 +00:00
cam Refactor command ordering/blocking mechanism in CTL. 2019-02-27 21:29:21 +00:00
cddl Improve readability of the code by making it explicit where the 'c' variable 2019-03-01 05:54:13 +00:00
compat Remove sv_pagesize, originally introduced with r100384. 2019-03-01 16:16:38 +00:00
conf There is no device atacard but there is device atapccard. 2019-03-01 15:00:13 +00:00
contrib Modularize xz. 2019-02-26 19:55:03 +00:00
crypto Regularize the Netflix copyright 2019-02-04 21:28:25 +00:00
ddb ddb: Print the thread's pcb in 'show thread' 2019-02-09 21:08:19 +00:00
dev Fortuna: push CTR-mode loop down into randomdev hash.h interface 2019-03-01 19:21:45 +00:00
dts Adapt FreeBSD specific DT stub for Jetson TK1 board to be consistent with 2019-02-06 06:03:44 +00:00
fs fuse: Fix a regression introduced in r337165 2019-02-21 02:41:57 +00:00
gdb
geom Modularize xz. 2019-02-26 19:55:03 +00:00
gnu gcov support 2019-02-23 21:14:00 +00:00
i386 Remove sv_pagesize, originally introduced with r100384. 2019-03-01 16:16:38 +00:00
isa
kern Remove sv_pagesize, originally introduced with r100384. 2019-03-01 16:16:38 +00:00
kgssapi * Handle SIGPIPE in gssd 2019-02-21 01:30:37 +00:00
libkern Add non-sleepable strdup variant strdup_flags 2019-02-20 20:48:10 +00:00
mips Remove sv_pagesize, originally introduced with r100384. 2019-03-01 16:16:38 +00:00
modules Add another required header file. 2019-03-01 04:17:43 +00:00
net iflib: Improve return values of interrupt handlers. 2019-02-15 18:51:43 +00:00
net80211 net80211(4): hide casts for 'i_seq' field offset calculation inside 2019-02-10 23:58:56 +00:00
netgraph Remove remnants of byte order manipulation, back when FreeBSD stack 2019-02-09 03:00:00 +00:00
netinet Honor the memory limits provided when processing the IPPROTO_SCTP 2019-03-01 18:47:41 +00:00
netinet6 When dropping a fragment queue count the number of fragments in the queue 2019-02-19 19:57:55 +00:00
netipsec Remove unused argument to priv_check_cred. 2018-12-11 19:32:16 +00:00
netpfil pf: IPv6 fragments with malformed extension headers could be erroneously passed by pf or cause a panic 2019-03-01 07:37:45 +00:00
netsmb Remove unused argument to priv_check_cred. 2018-12-11 19:32:16 +00:00
nfs
nfsclient
nfsserver
nlm
ofed Mechanical cleanup of epoch(9) usage in network stack. 2019-01-09 01:11:19 +00:00
opencrypto Fix another bug introduced during the review process of r344140: 2019-02-25 19:14:16 +00:00
powerpc Remove sv_pagesize, originally introduced with r100384. 2019-03-01 16:16:38 +00:00
riscv Remove sv_pagesize, originally introduced with r100384. 2019-03-01 16:16:38 +00:00
rpc Bump the default kern.rpc.gss.client_max from 128 to 1024. 2019-02-19 11:07:02 +00:00
security Create new EINTEGRITY error with message "Integrity check failed". 2019-01-17 06:35:45 +00:00
sparc64 Remove sv_pagesize, originally introduced with r100384. 2019-03-01 16:16:38 +00:00
sys Remove sv_pagesize, originally introduced with r100384. 2019-03-01 16:16:38 +00:00
teken Attempt to complete fixing programmable function keys for syscons. 2019-02-20 02:14:41 +00:00
tests Regularize the Netflix copyright 2019-02-04 21:28:25 +00:00
tools make_dtb.sh: Use $CPP instead of assuming that cpp is in $PATH 2018-12-14 23:53:28 +00:00
ufs FFS: allow sendfile(2) to work with block sizes greater than the page size 2019-02-26 04:56:10 +00:00
vm vm: remove seq.h inclusion made obsolete by NUMA rewrite 2019-02-27 22:42:29 +00:00
x86 Add usermode helpers for for Intel userspace protection keys feature. 2019-02-20 09:56:23 +00:00
xdr
xen xen: introduce a new way to setup event channel upcall 2019-01-30 11:34:52 +00:00
Makefile