252719 Commits

Author SHA1 Message Date
ozaki-r
89a45bc13c Fix deadlock between key_sendup_mbuf called from key_acquire and localcount_drain
If we call key_sendup_mbuf from key_acquire that is called on packet
processing, a deadlock can happen like this:
- At key_acquire, a reference to an SP (and an SA) is held
- key_sendup_mbuf will try to take key_so_mtx
- Some other thread may try to localcount_drain to the SP with
  holding key_so_mtx in say key_api_spdflush
- In this case localcount_drain never return because key_sendup_mbuf
  that has stuck on key_so_mtx never release a reference to the SP

Fix the deadlock by deferring key_sendup_mbuf to the timer
(key_timehandler).
2017-08-09 04:29:36 +00:00
ozaki-r
14719bf46b Fix locking notes of SAD 2017-08-09 03:41:11 +00:00
ginsbach
7333bec30e Make use of the defined YP errors when ypbind encounters one rather than
just returning an empty (successful) RPC result.

Don't exit when allocating memory for a new bound domain received via a RPC.
2017-08-09 01:56:42 +00:00
nat
a6753d2018 If the harware ring is starved of data...Insert silence into the mix ring
so mix_write can function properly.
2017-08-08 22:21:35 +00:00
maxv
421d2ed25f Mmh, don't overwrite tf_err and tf_trapno. Looks like it can be used to
exploit the intel sysret vulnerability once again.
2017-08-08 17:27:34 +00:00
maxv
0eb9d81edc Remove dumb debug code and outdated comment. 2017-08-08 17:00:42 +00:00
maxv
c778810068 Remove compat_svr4, compat_svr4_32 and compat_ibcs2 from the list of
autoloaded modules. These options are disabled everywhere (except ibcs2
on Vax, but Vax does not support kernel modules, so doesn't matter),
therefore there is no issue in removing them from the list. Interested
users will now have to do a 'modload' first, or uncomment the entries in
GENERIC.
2017-08-08 16:57:32 +00:00
maya
79b25548dc Build the loongson kernels with all the binutils loongson2f errata workarounds
From Zhang Fuxin via https://sourceware.org/ml/binutils/2009-11/msg00387.html

  - The NOP issue

"The nature of the erratum is deeply related to the microarchitecture of
Loongson-2. It uses roughly a 4-way superscalar dynamically scheduled core,
instructions are excuted as much as possible in parallel with technics like
branch prediction etc. We use a 8-entry internal branch prediction queue to
keep track of each predicted branches, if some branches are proved to be
wrongly predicted, all the instructions following it will be cancelled,together
with the resources used by them, including the registers used for renaming, and
the queue entry will be freeed. There is a bug that might cause a hang when the
queue is full(some resources might been leaked due to conflict branch entries),
the workaround is to reduce the possiblity of branch queue full by using
renaming registers(they are also limited, can prevent too many simutaneos
branches). In theory this is still not enough to fully eliminate possible
hangs, but the possiblity is extremely low now and hard to be hit in real
code."

  - The JUMP instructions issue

"The Loongson-2 series processors have quite complex micro-architecture, it will
try to execute instructions from the predicated branch of coming instruction
stream before they are confirmed to be run, if the predication of branch
direction is proved wrong later, the instructions will be cancelled, but if the
instructions is a read from memory, the read action might not be cancelled(but
the changes to register will) to enable some prefetch. This will lead to some
problems when compining with some chipsets. E.g. the AMD CS5536 used in
Yeeloong/Fuloong will hang if it gets an address in the physical address range
of 0x100000-0x200000(might be more other ranges). Speculative reads can perform
read at any address in theory(due to wrong prediction of branch directions and
the use of branch target buffer), thus in very few occasions they might cause a
hard lock of the machine.

To prevent this, we need to prevent some addresses from entering branch
target buffers. A way to do this is that to modify all jump targets, e.g.,
     calulations of t9
     ...
     jalr t9  =>
     calculations of t9
     or t9, t9, 0x80000000;  // to make sure t9 is in kseg0
     jalr t9
Of course, we have to consider 64/32bit, and modules addresses etc.

This only need to be performed on kernel code, because only there we can have
accesses not translated/limited by TLB. For user code, it is impossible to
generate accesses to unwanted physical address. So it is safe.

Also, to prevent addresses generated by user mode code to be used by the
kernel, we add a few empty jumps to flush the BTB upon entrance to kernel."
2017-08-08 12:22:21 +00:00
ozaki-r
95878956a6 Fix KASSERT(solocked(sb->sb_so)) failure in sbappendaddr that is called eventually from key_sendup_mbuf
If key_sendup_mbuf isn't passed a socket, the assertion fails.
Originally in this case sb->sb_so was softnet_lock and callers
held softnet_lock so the assertion was magically satisfied.
Now sb->sb_so is key_so_mtx and also softnet_lock isn't always
held by callers so the assertion can fail.

Fix it by holding key_so_mtx if key_sendup_mbuf isn't passed a socket.

Reported by knakahara@
Tested by knakahara@ and ozaki-r@
2017-08-08 10:41:33 +00:00
maya
e2fa3888a5 Remove whitespace I just introduced 2017-08-08 09:34:59 +00:00
maya
3d9ef277ea In working around loongson errata clear BTB and RAS, same as
other operating systems.

15 Errata: Issue of Out-of-order in loongson (translated)

In loongson 2F, because of the branch prediction, sometimes the CPU
may fetch the instructions from some unexpected area (for example I/O
space). It is an invalid operation. There are two ways for the CPU to
choose the branch target. The first one is predicting the branch
target according to the branch target history. The second one is
calculating the branch target by the ALU. There are most 8
instructions in the instruction window at the same time in loongson2f
(Remember the loongson 2f is superscalar, right?). Hence, the
branch target of an indirect branch(such as jr) could be got(may be
predicted by the branch target history) earlier and the instrctions of
the branch target could be prefetched even if there are branch
instructions before it. As a result, it is possible to fetch the
instructions from I/O region( say out-of the physical address range of
[0- 0x100000]) in kernel model because of the instruction prefetch of
the branch target.

There are some suggestions to prevent prefetching instructions from
the I/O region in kernel mode.

(1) When switching from user model to kernel model, you should flush
the branch target history such as BTB and RAS.
(2) Doing some tricks to the indirect branch target to make sure that
the indirect branch target can not be in the I/O region.
2017-08-08 09:33:41 +00:00
ozaki-r
484f5de35e Destroy sav only in the loop for DEAD sav 2017-08-08 08:24:34 +00:00
ozaki-r
1e13a4d5ce Introduce key_sa_refcnt and replace sav->refcnt with it (NFC) 2017-08-08 08:23:10 +00:00
maxv
1d68b497f2 Remove compat_freebsd from the list of autoloaded modules. Interested users
will now have to type 'modload' to use it, or uncomment the entry in
GENERIC. I should have removed it when I disabled COMPAT_FREEBSD by
default, sorry about that.
2017-08-08 08:12:14 +00:00
maxv
0f16c35db3 Move freebsd_machdep.h into sys/compat/freebsd, and don't install it. Now,
the compat_freebsd files are all contained in sys/compat/freebsd.
2017-08-08 08:04:05 +00:00
isaki
3ae232220b Remove dead codes. chan will never be NULL in SIMPLEQ_FOREACH. 2017-08-08 05:58:12 +00:00
isaki
79ce44505a Introduce audio_destroy_pfilters()/audio_destroy_rfilters()
and use it.
2017-08-08 05:54:14 +00:00
isaki
213f2c71be Add missing initialization of sc_rfilters in audioattach(). 2017-08-08 05:46:23 +00:00
isaki
5d2d921a12 Remove a duplicated line. 2017-08-08 05:42:30 +00:00
ozaki-r
8f8fa6eb6c MP-ify SAD (key_sad.sahlist and sah entries)
localcount(9) is used to protect key_sad.sahlist and sah entries
as well as SPD (and will be used for SAD sav).

Please read the locking notes of SAD for more details.
2017-08-08 04:17:34 +00:00
isaki
08587dfc8e s/tail queue/simple queue/ in SIMPLE QUEUES section. 2017-08-08 03:58:43 +00:00
knakahara
038b619438 fix leak when encap_attach() fails twice.
XXX need pullup to -8 branch
2017-08-08 03:14:50 +00:00
ozaki-r
708290e277 Fix setkey -D -P outputs
The outputs were tweaked (by me), but I forgot updating libipsec
in my local ATF environment...
2017-08-08 02:27:03 +00:00
ozaki-r
ef1cdec9e6 Add missing mutex_exit 2017-08-08 01:56:49 +00:00
ozaki-r
067687eba3 Tweak wording (pserialize critical section => pserialize read section)
Suggested by riastradh@
2017-08-08 01:56:10 +00:00
ozaki-r
5b98256fe4 Add __read_mostly to key_psz
Suggested by riastradh@
2017-08-08 01:55:17 +00:00
uwe
8b26d4cb93 XXX: On hpcsh only - bring back old incorrect hpckbd_keymap_setup()
fixed in 1.31.  The old one with UNCONST does work on hpcsh b/c the
kernel is directly mapped.  The new one does not work on hpcsh b/c it
calls consinit() very early when malloc() is not yet available.

The real fix for this is to fix the constness of wscons keymap
structures that is self-contradictory.
2017-08-07 23:57:40 +00:00
uwe
ffcff5241d Don't reschedule the callout in the scanning function itself, as that
conflicts with using the same function for polled console.

Makes early ddb work with wscons console again on my Jornada 690.
2017-08-07 23:42:11 +00:00
uwe
feec5ded24 Use NULL instead of 0 for null pointer. 2017-08-07 22:08:12 +00:00
jmcneill
70cf8a2c37 h3_codec_pr_write: clear write mode bit after setting it; fixes an issue with output being mutex when skipping tracks in mpg123 2017-08-07 21:50:34 +00:00
maxv
50e4ac7faf Fix GCC warning on NET4501, PR/52451. 2017-08-07 17:31:11 +00:00
maxv
dba130a823 Remove incorrect KASSERT, only the allocation is protected by cpu_lock. 2017-08-07 17:10:09 +00:00
isaki
1e5a0d99e1 Fix typo in comment. 2017-08-07 13:30:51 +00:00
hkenken
5a40d81280 Add support Microchip SST25VF016B.
- Fixed imxspi send and receive bugs.
2017-08-07 09:24:43 +00:00
hkenken
11af610cd2 Clean up IOPORT settings. 2017-08-07 08:54:54 +00:00
ozaki-r
4004fa59a1 Hold key_sad.lock on SAVLIST_WRITER_INSERT_TAIL 2017-08-07 07:45:45 +00:00
dholland
db6ae02331 Tidy up ufs_readdir. First step only; there's plenty more that could be
done to improve this code.
2017-08-07 06:53:48 +00:00
mrg
6247ed7a27 don't build apm, ark or glint on cats for xorg-server 1.18. 2017-08-07 06:51:13 +00:00
ozaki-r
392014b83c Describe constraints of key_sp_ref and key_sp_unref
Requested by riastradh@
2017-08-07 03:30:45 +00:00
ozaki-r
bb5008f6c6 Update the locking notes
- Add locking order
- Add locking notes for misc lists such as reglist
- Mention pserialize, key_sp_ref and key_sp_unref on SP operations

Requested by riastradh@
2017-08-07 03:28:31 +00:00
ozaki-r
e465076bc8 Move locking notes 2017-08-07 03:22:33 +00:00
ozaki-r
f457240f04 Assemble global lists and related locks into cache lines (NFCI)
Also rename variable names from *tree to *list because they are
just lists, not trees.

Suggested by riastradh@
2017-08-07 03:21:58 +00:00
ozaki-r
bb844bd7e6 Use KDASSERT instead of KASSERT for mutex_ownable
Because mutex_ownable is too heavy to run in a fast path
even for DIAGNOSTIC + LOCKDEBUG.

Suggested by riastradh@
2017-08-07 03:20:02 +00:00
ozaki-r
684f351df7 Remove out-of-date log output
Pointed out by riastradh@
2017-08-07 03:18:32 +00:00
jmcneill
439749db35 Enable H3 audio support 2017-08-06 17:16:02 +00:00
jmcneill
e8ba4a22da Add support for Allwinner H3 audio codec. 2017-08-06 17:15:45 +00:00
jmcneill
ecf6125350 Add support for H3 audio PLL and digital audio part. 2017-08-06 17:14:37 +00:00
jmcneill
474ad04648 Fix burst field encoding, and add a helper function to dump registers
from ddb.
2017-08-06 17:13:15 +00:00
christos
6a0af68498 Turn on DIAGNOSTIC and DEBUG. 2017-08-06 11:50:21 +00:00
nat
1d6a52b591 Ensure to call mix write if inserting silence into the hw ring.
Addresses PR kern/52459.

Patch provided and tested by isaki@.
2017-08-06 10:07:31 +00:00