252741 Commits

Author SHA1 Message Date
ozaki-r
fbb0de677c Update
ipsec(4), opencrypto(9) and vlan(4) are now MP-safe.
2017-08-10 09:08:54 +00:00
ozaki-r
6b225a2f87 Use pool_cache(9) instead of pool(9) for tdb_crypto objects
The change improves network throughput especially on multi-core systems.
2017-08-10 06:33:51 +00:00
ozaki-r
64e641680f Add per-CPU rtcache to ipsec_reinject_ipstack
It reduces route lookups and also reduces rtcache lock contentions
when NET_MPSAFE is enabled.
2017-08-10 06:11:24 +00:00
ozaki-r
f26d4ea4c4 Simplify ipsec_reinject_ipstack (NFC) 2017-08-10 06:08:59 +00:00
ryo
1581658c21 Add support IP_PKTINFO for sendmsg(2).
The source address or output interface can be specified by adding IP_PKTINFO
to the control part of the message on a SOCK_DGRAM or SOCK_RAW socket.

Reviewed by ozaki-r@ and christos@. thanks.
2017-08-10 04:31:58 +00:00
maya
7db80fab74 evbmips can "boot root FFSv2"
It typically uses a non-NetBSD bootloader (PMON, u-boot...) and those
don't differentiate from v1 from v2 - both are unsupported and it requires
a separate boot partition.
2017-08-09 23:01:06 +00:00
maxv
9a2e177474 Remove references to svr4 and ibcs2, they are not supported here. 2017-08-09 19:18:59 +00:00
maxv
e40a481868 Remove several dead entries from the x86 makefiles. Looks like people (me
included) regularly forget to take care of this.
2017-08-09 19:11:13 +00:00
maxv
b9b94af2bc Remove ibcs2_machdep.h on i386, and don't install it. 2017-08-09 18:58:51 +00:00
maxv
9f479233db Remove __i386__. 2017-08-09 18:52:00 +00:00
maxv
47d0937ef0 Remove references to compat_ibcs2. 2017-08-09 18:48:53 +00:00
maxv
bd36ac747c Remove compat_ibcs2 from i386. After a discussion on port-vax, it turns
out that compat_ibcs2 does not implement the iBCS2 standard - which is
x86-specific - but rather SVR3. Our real iBCS2 implementation was a
mixture of compat_ibcs2 and compat_svr4, and was only partial. Keeping
support for this in i386 is totally irrelevant today. I also asked on
port-i386 but didn't wait long.

The main issue is that compat_ibcs2 should have been called compat_svr3.
But CVS does not support renaming files, and moving things around is both
painful and tiring, even more so when no one seems to be interested in
doing this work or in the feature at all. For now compat_ibcs2 is available
on Vax and will stay, until someone (not me) cleans it up.
2017-08-09 18:45:30 +00:00
joerg
493a7561e4 If a DF_1_NODELETE DSO has been removed from the DAG list, it still
needs to be able to resolve relocations against itself. As such, search
the referencing object explicitly last, if it hasn't been searched
before.
2017-08-09 18:44:32 +00:00
christos
a2c4fad4b4 PR/52472: Edgar Fuss: Document handling of scoped IPv6 addresses by embedding
ASCII art from:
	IPv6 Core Protocols Implementation
	By Qing Li, Tatuya Jinmei, Keiichi Shima
	Page 56, Figure 2.12
2017-08-09 17:20:44 +00:00
mlelstv
5b68a5ee6d While ld(4) is MP safe, many backends are not.
Add a flag for backends that are MP safe. Take KERNEL_LOCK when calling
into a backend that doesn't have the flag set. Do the same for the
discard routine.

Fixes PR 52462.
2017-08-09 16:44:39 +00:00
mlelstv
fd946ab215 Don't wait for allocation in polling mode. 2017-08-09 16:09:16 +00:00
ozaki-r
b2da0132b5 MP-ify SAD (savlist)
localcount(9) is used to protect savlist of sah. The basic design is
similar to MP-ifications of SPD and SAD sahlist. Please read the
locking notes of SAD for more details.
2017-08-09 09:48:11 +00:00
ozaki-r
b02651a11c Limit the number of mbufs queued for deferred key_sendup_mbuf
It's easy to be queued hundreds of mbufs on the list under heavy
network load.
2017-08-09 08:30:54 +00:00
knakahara
5e20be26d9 Add counter check to vlan(4) ATF. Implemented by s-yamaguchi@IIJ, thanks. 2017-08-09 06:19:56 +00:00
knakahara
29967db593 Fix vlan(4) obytes counter. Implemented by s-yamaguchi@IIJ, thanks. 2017-08-09 06:17:23 +00:00
ozaki-r
29764387a9 Fix that prev isn't cleared on retry 2017-08-09 06:04:41 +00:00
msaitoh
3c99b9a436 - Sprinkle static and const. No functional change.
- Print chip ID in hexadecimal instead of octal in def_match().
2017-08-09 04:45:38 +00:00
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