Commit Graph

115897 Commits

Author SHA1 Message Date
Roger Pau Monné
41716b8d51 xenstore: fix suspension when using the xenstore device
Lock the xenstore request mutex when suspending user-space processes, in order
to prevent any process from holding this lock when going into suspension, or
else the xenstore suspend process is going to deadlock.

Submitted by:		Liuyingdong <liuyingdong@huawei.com>
Reviewed by:		royger
MFC after:		2 weeks
Differential revision:	https://reviews.freebsd.org/D9638
2017-03-07 09:17:48 +00:00
Roger Pau Monné
8dee0e9bd6 xen: add support for canceled suspend
When running on Xen, it's possible that a suspend request to the hypervisor
fails (return from HYPERVISOR_suspend different than 0). This means that the
suspend hasn't succeed, and the resume procedure needs to properly handle this
case.

First of all, when such situation happens there's no need to reset the vector
callback, hypercall page, shared info, event channels or grant table, because
it's state is preserved. Also, the PV drivers don't need to be reset to the
initial state, since the connection with the backed has not been interrupted.

Submitted by:		Liuyingdong <liuyingdong@huawei.com>
Reviewed by:		royger
MFC after:		2 weeks
Differential revision:	https://reviews.freebsd.org/D9635
2017-03-07 09:16:51 +00:00
Andriy Voskoboinyk
acd63c37d6 iwn: deduplicate (RXON + txpower + broadcast node) command sequence.
Was previously applied to wpi(4) as a part of r278366.

Tested with Intel 6205, STA / MONITOR modes.
2017-03-07 07:49:25 +00:00
Hiren Panchasara
f41b2de716 Fix the KASSERT check from r314813.
len being 0 is valid.

Submitted by:	ngie
Reported by:	ngie (via jenkins test run)
Sponsored by:	Limelight Networks
2017-03-07 06:46:38 +00:00
Dexuan Cui
0d0fae3406 loader.efi: fix an off-by-one bug in efi_verify_staging_size()
Also remove the warning message: it may not be unusual to see
the memory range containing 2MB is not of EfiConventionalMemory.

MFC after:	2 weeks2 weeks
Sponsored by:	Microsoft
2017-03-07 03:35:50 +00:00
Navdeep Parhar
1081f354af cxgbe/iw_cxgbe: Abort connection if there is an error during c4iw_modify_qp.
Submitted by:	KrishnamRaju ErapaRaju @ Chelsio
MFC after:	3 days
Sponsored by:	Chelsio Communications
2017-03-07 01:13:26 +00:00
Hiren Panchasara
b5b023b91e We've found a recurring problem where some userland process would be
stuck spinning at 100% cpu around sbcut_internal(). Inside
sbflush_internal(), sb_ccc reached to about 4GB and before passing it
to sbcut_internal(), we type-cast it from uint to int making it -ve.

The root cause of sockbuf growing this large is unknown. Correct fix
is also not clear but based on mailing list discussions, adding
KASSERTs to panic instead of looping endlessly.

Reviewed by:		glebius
Sponsored by:		Limelight Networks
2017-03-07 00:20:01 +00:00
Andrey V. Elsukov
22986c6740 Introduce the concept of IPsec security policies scope.
Currently are defined three scopes: global, ifnet, and pcb.
Generic security policies that IKE daemon can add via PF_KEY interface
or an administrator creates with setkey(8) utility have GLOBAL scope.
Such policies can be applied by the kernel to outgoing packets and checked
agains inbound packets after IPsec processing.
Security policies created by if_ipsec(4) interfaces have IFNET scope.
Such policies are applied to packets that are passed through if_ipsec(4)
interface.
And security policies created by application using setsockopt()
IP_IPSEC_POLICY option have PCB scope. Such policies are applied to
packets related to specific socket. Currently there is no way to list
PCB policies via setkey(8) utility.

Modify setkey(8) and libipsec(3) to be able distinguish the scope of
security policies in the `setkey -DP` listing. Add two optional flags:
'-t' to list only policies related to virtual *tunneling* interfaces,
i.e. policies with IFNET scope, and '-g' to list only policies with GLOBAL
scope. By default policies from all scopes are listed.

To implement this PF_KEY's sadb_x_policy structure was modified.
sadb_x_policy_reserved field is used to pass the policy scope from the
kernel to userland. SADB_SPDDUMP message extended to support filtering
by scope: sadb_msg_satype field is used to specify bit mask of requested
scopes.

For IFNET policies the sadb_x_policy_priority field of struct sadb_x_policy
is used to pass if_ipsec's interface if_index to the userland. For GLOBAL
policies sadb_x_policy_priority is used only to manage order of security
policies in the SPDB. For IFNET policies it is not used, so it can be used
to keep if_index.

After this change the output of `setkey -DP` now looks like:
# setkey -DPt
0.0.0.0/0[any] 0.0.0.0/0[any] any
	in ipsec
	esp/tunnel/87.250.242.144-87.250.242.145/unique:145
	spid=7 seq=3 pid=58025 scope=ifnet ifname=ipsec0
	refcnt=1
# setkey -DPg
::/0 ::/0 icmp6 135,0
	out none
	spid=5 seq=1 pid=872 scope=global
	refcnt=1

No objection from:	#network
Obtained from:	Yandex LLC
MFC after:	2 weeks
Sponsored by:	Yandex LLC
Differential Revision:	https://reviews.freebsd.org/D9805
2017-03-07 00:13:53 +00:00
Marius Strobl
b440e965da o Another round fixes for mmc(4), mmcsd(4) and sdhci(4) regarding
comments, marking unused parameters as such, style(9), whitespace,
  etc.
o In the mmc(4) bridges and sdhci(4) (bus) front-ends:
  - Remove redundant assignments of the default bus_generic_print_child
    device method (I've whipped these out of the tree as part of r227843
    once, but they keep coming back ...),
  - use DEVMETHOD_END,
  - use NULL instead of 0 for pointers.
o Trim/adjust includes.
2017-03-06 23:47:59 +00:00
Kristof Provost
98a9874f7b pf: Fix a crash in low-memory situations
If the call to pf_state_key_clone() in pf_get_translation() fails (i.e. there's
no more memory for it) it frees skp. This is wrong, because skp is a
pf_state_key **, so we need to free *skp, as is done later in the function.
Getting it wrong means we try to free a stack variable of the calling
pf_test_rule() function, and we panic.
2017-03-06 23:41:23 +00:00
Gleb Smirnoff
6cf0c1db55 Fix compilation of r314784 on 32 bit. 2017-03-06 22:32:56 +00:00
Alexander Motin
0656476aa6 Import mpr(4) driver P12 to P14 diff from vendor site.
This is mostly a version bump to stay in version number sync with firmware.
The only change there was cosmetic:  Display degraded speed message upon
receiving Active Cable Exception Event with DEGRADED reason code.

Discussed with:	slm@
MFC after:	1 week
2017-03-06 19:39:31 +00:00
Gleb Smirnoff
f2498877c9 In panic() print current timestamp, which matches timestamp in the dump
header.  This will help to correlate console server logs with dump files,
no matter how precise is clock on a console server appliance, and how
buggy the appliance is.
2017-03-06 19:14:08 +00:00
Mahdi Mokhtari
881b1219aa Regenerated Linuxulator syscall tables for r314782
Approved by:	dchagin
MFC after:	1 month
2017-03-06 18:20:37 +00:00
Mahdi Mokhtari
8049c6bfb8 Add UNIMPLEMENTED() placeholder macro for
the syscalls that are not implemented in Linux kernel itself.
Cleanup DUMMY() macros.

Reviewed by:	dchagin, trasz
Approved by:	dchagin
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D9804
2017-03-06 18:11:38 +00:00
Hans Petter Selasky
def277d3ef Implement add_timer_on() function in the LinuxKPI.
Obtained from:		kmacy @
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-06 14:56:57 +00:00
Konstantin Belousov
aaadc41f6c Instead of direct use of vm_map_insert(), call vm_map_fixed(MAP_CHECK_EXCL).
This KPI explicitely indicates the intent of creating the mapping at
the fixed address, and incorporates the map locking into the callee.

Suggested and reviewed by:	alc
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-03-06 14:09:54 +00:00
Hans Petter Selasky
19bf8ef562 Implement DECLARE_RWSEM() macro in the LinuxKPI to initialize a
Read-Write semaphore during module init time.

MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-06 12:22:05 +00:00
Hans Petter Selasky
684bcfec89 Give LinuxKPI Read-Write semaphores better debug names when
WITNESS_ALL is defined. The lock name is based on the filename and
line number where the initialisation happens.

MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-06 12:20:56 +00:00
Dexuan Cui
f4531c91ab loader.efi: fix recent UEFI-boot regression on physical machines
This patch fixes my recent patch
"loader.efi: reduce the size of the staging area if necessary", which
causes EFI-boot failure on physical machines since Mar 2:
on the host there is a 1MB LoaderData memory range, which splits
the big Conventional Memory range into a small one (15MB) and a
big one: the small one is too small to hold the staging area.

We can actually use the LoaderData range safely, because when
amd64_tramp -> efi_copy_finish() starts to run, we're almost at
the very end of the efi loader code and we're going to "return"
to the kernel entry, so we're pretty sure we won't access any loader
data any more.

For people who are interested in the details: please see
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211746#c22

PS, some people also reported the regression happened to FreeBSD VM
running on Bhyve in EFI mode. This patch should resolve it too,
though I don't have such a setup to test.

Reviewed by:	sephe
Approved by:	sephe (mentor)
MFC after:	2 weeks
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D9904
2017-03-06 09:34:31 +00:00
Ian Lepore
a57e9aade2 Build the dtb files for the revb1 versions of wandboard. 2017-03-06 04:16:35 +00:00
Ermal Luçi
dce33a45c9 The patch provides the same socket option as Linux IP_ORIGDSTADDR.
Unfortunately they will have different integer value due to Linux value being already assigned in FreeBSD.

The patch is similar to IP_RECVDSTADDR but also provides the destination port value to the application.

This allows/improves implementation of transparent proxies on UDP sockets due to having the whole information on forwarded packets.

Reviewed by:	adrian, aw
Approved by:	ae (mentor)
Sponsored by:	rsync.net
Differential Revision:	D9235
2017-03-06 04:01:58 +00:00
Pedro F. Giffuni
25ef829b03 Revert r314669, r314670:
Bring back the i486 option in GENERIC by default.

The code related to i386 CPU variants configuration has received many
changes in the last years: most of the features are detected automatically,
so there are no performance penalties from keeping the 486 support enabled.

Re-instate the 486 support: while the general configuration could still be
cleaned a bit, there is no advantage in removing it.

Differential Revision:	https://reviews.freebsd.org/D9879
2017-03-06 03:52:15 +00:00
Andrey V. Elsukov
53de37f8ca Fix the build. Use new ipfw_lookup_table() in the nat64 too.
Reported by:	cy
MFC after:	2 weeks
2017-03-06 00:41:59 +00:00
Alan Cox
28e8da6517 Style and punctuation fixes.
Reviewed by:	kib
MFC after:	3 days
2017-03-05 23:59:04 +00:00
Andrey V. Elsukov
54e5669d8c Add IPv6 support to O_IP_DST_LOOKUP opcode.
o check the size of O_IP_SRC_LOOKUP opcode, it can not exceed the size of
  ipfw_insn_u32;
o rename ipfw_lookup_table_extended() function into ipfw_lookup_table() and
  remove old ipfw_lookup_table();
o use args->f_id.flow_id6 that is in host byte order to get DSCP value;
o add SCTP ports support to 'lookup src/dst-port' opcode;
o add IPv6 support to 'lookup src/dst-ip' opcode.

PR:		217292
Reviewed by:	melifaro
MFC after:	2 weeks
Sponsored by:	Yandex LLC
Differential Revision:	https://reviews.freebsd.org/D9873
2017-03-05 23:48:24 +00:00
Andrey V. Elsukov
c750a56914 Reject invalid object types that can not be used with specific opcodes.
When we doing reference counting of named objects in the new rule,
for existing objects check that opcode references to correct object,
otherwise return EINVAL.

PR:		217391
MFC after:	1 week
Sponsored by:	Yandex LLC
2017-03-05 22:19:43 +00:00
Michal Meloun
d457839bc8 Add support for card detect and write protect gpio pins to Tegra SDHCI. 2017-03-05 15:34:32 +00:00
Andriy Gapon
c1ad4beb32 mca: fix up couple of issues introduced with amd thresholding in r314636
1. There a was a typo in one place where the processor family is
   checked (16 vs 0x16).  Now the checks are consolidated in a single
   function.
2. Instead of an array of struct amd_et_state objects the code allocated
   an array of pointers.  That was no problem on amd64 where the sizes
   are the same, but could be a problem on i386.

Reported by:	tuexen and others
Tested by:	tuexen (earlier version of the fix)
Pointyhat to:	avg
MFC after:	5 days
X-MFC with:	r314636
2017-03-05 07:46:48 +00:00
Emmanuel Vadot
c1b014c51c Export a sysctl dev.<clkdom>.<unit>.clocks for each clock domain containing
all the clocks that they provide.
Each clocks are exported under the node 'clock.<clkname>' and have the following
children nodes :
- frequency
- parent (The selected parent, if any)
- parents (The list of parents, if any)
- childrens (The list of childrens, if any)
- enable_cnt (The enabled counter)

This give us the possibility to examine clocks at runtime and make graph of
the clock flow.

Reviewed by:	mmel
MFC after:	2 month
Differential Revision:	https://reviews.freebsd.org/D9833
2017-03-05 07:13:29 +00:00
Eric Badger
99b14d9f1b remove procfs ctl interface
This interface has no in-tree consumers and has been more or less
non-functional for several releases.

Remove manpage note that the procfs special file 'mem' is grouped to
kmem. This hasn't been true since r81107.

Remove procfs' README file. It is an out of date duplication of the manpage
(quoth the README: "since the bsd kernel is single-processor...").

Reviewed by:	vangyzen, bcr (manpage)
Approved by:	des (procfs maintainer), vangyzen (mentor)
Differential Revision:	https://reviews.freebsd.org/D9802
2017-03-05 03:05:24 +00:00
Andriy Voskoboinyk
6977499ccf iwn: drop 'channel' parameter from iwn*_set_txpower()
For 4965 just extract 'is_chan_5ghz' flag from the RXON structure
(like it was done in r281287); for others it was never used.

Tested with Intel 6205, STA mode.
2017-03-04 23:07:54 +00:00
Ian Lepore
ac0577afe9 Reconfigure the fifo watermark levels on the pl011 uart to interrupt when
the fifos are 3/4 full (rc) or empty (tx).
2017-03-04 22:00:05 +00:00
Ian Lepore
752e8c08fb Fix bugs exposed by the recent enabling of FIFOs in the pl011 uart. These
have been in the code all along, but were masked by having a fifo depth of
one byte at the hardware level, so everything kinda worked by accident.

The hardware interrupts when the TX fifo is half empty, so set
sc->sc_txfifosz to 8 bytes (half the hardware fifo size) to match.  This
eliminates dropped characters on output.

Restructure the read loop to consume all the bytes in the fifo by using
the "rx fifo empty" bit of the flags register rather than the "rx ready"
bit of the interrupt status register.  The rx-ready interrupt is cleared
when the number of bytes in the fifo fall below the interrupt trigger
level, leaving the fifo half full every time receive routine was called.
Now it loops until the fifo is completely empty every time (including
when the function is called due to a receive timeout as well as for
fifo-full).
2017-03-04 21:47:43 +00:00
Hans Petter Selasky
e0db0ddb39 Remove duplicate prototype in the LinuxKPI to fix compilation warning.
Reported by:		emaste @
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-04 20:06:47 +00:00
Oleksandr Tymoshenko
f1f425aea0 [rpi] rpi3 should use the same cpufreq logic as rpi2, not rpi-b
RPi3 cpufreq is more like that on RPi2. Setting arm frequency
above min (say, "sysctl hw.cpufreq.arm_freq=600000001") turns on
turbo mode, and the firmware automatically raises voltage, sets
frequency to max 1200MHz, and throttle when overheat, etc.

Swap if/else parts and use SOC_BCM2835 def so RPi3 can share the
same cpufreq logic as RPi2, instead of falling to that for RPi.

Submitted by:	Jia-Shiun Li <jiashiun@gmail.com>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D9640
2017-03-04 17:34:36 +00:00
Pedro F. Giffuni
a5730cc510 Drop i486 from the default i386 GENERIC kernel configuration.
80486 production was stopped by Intel on September 2007. Dropping the 486
configuration option from the GENERIC kernel improves performance
slightly.

Removing I486_CPU is consistent at this time: we don't support any
processor without a FPU and the PC-98 arch, which frequently involved i486
CPUs, is also gone so we don't test such platforms anymore.

Relnotes:	yes
MFC after:	2 weeks
https://reviews.freebsd.org/D9879
2017-03-04 15:04:17 +00:00
Andriy Gapon
1a1406212b ioat: don't specify inline for function with variable argument list
Modern GCC and Clang simply ignore the qualifier, while the old base GCC
produces a warning (treated as an error in the kernel build).

Approved by:	cem
MFC after:	5 days
2017-03-04 12:51:57 +00:00
Enji Cooper
193d9e768b sys/modules: normalize .CURDIR-relative paths to SRCTOP
This simplifies make output/logic

Tested with:	`cd sys/modules; make ALL_MODULES=` on amd64
MFC after:	1 month
Sponsored by:	Dell EMC Isilon
2017-03-04 10:10:17 +00:00
Dmitry Chagin
8042c504f5 Style(9).
MFC after:	1 month
2017-03-04 08:59:21 +00:00
Dmitry Chagin
e45e3698ae Remove attribute __packed from some IPC struct definition since
Linuxulator is x86 only.
The only notable differences in algnment for an LP64 64-bit system
when compared to a 32-bit system is an eight or large byte types
alignment.

MFC after:	1 month
2017-03-04 08:57:39 +00:00
Bruce Evans
53f40ddc8e Implement ec_putc() (emergency kernel [syscons] console putc()) and use
it in emergency in sc_cnputc().

Locking fixes in sc_cnputc() previously turned off normal output in
near-deadlock conditions and added deferred output which might never
be completed.  Emergency output goes to the frame buffer using
sufficiently atomic non-blocking writes if the console is in text
mode (in graphics mode, nothing is done, modulo races setting the
graphics mode bit).  Screen updates overwrite the emergency output
if the emergency condition clears enough to reach them.

ec_putc() also works for "early" console output in normal x86 text
mode as soon as this mode is initialized (if ever).  This uses a
hard-coded x86 frame buffer address before cninit() and a hopefully
MI address after cninit().  But non-x86 is more likely to not support
text mode, when ec_putc() will be null.  ec_putc() has no dependencies
of syscons before cninit(), and only has them later to track syscons'
mode changes.  This commit doesn't attach ec_putc() for early use.

To test emergency use, put a breakpoint in central syscons output code
like sc_puts() and do some user output.  The system used to race or
deadlock in ddb output soon after entry to ddb.  The locking fixes
deferred the output until after leaving ddb, so ddb was unusable and
you had to try typing c[ontinue] blindly until it exited, or better use
a serial console in parallel.  Now the output goes to a window in the
middle 2/3 of the screen.  Scrolling is circular and there is no cursor,
but otherwise ec_putc() provides full dumb terminal functionality and
very fast output that hides artificates from dumb overwrites.
2017-03-04 08:47:31 +00:00
Enji Cooper
ee13e70e4f Fix "make depend" with nvme.ko: add opt_cam.h to SRCS
MFC after:	1 week
X-MFC with:	r301778
Sponsored by:	Dell EMC Isilon
2017-03-04 08:46:57 +00:00
Enji Cooper
38ede98e9a Fix "make depend" with geom_uzip.ko: add opt_geom.h to SRCS
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-04 08:28:33 +00:00
Dmitry Chagin
c1c8a12139 Hide Linux socketcall constants under corresponding #ifdef since
they are used only in i386 Linuxulator.

MFC after:	1 week
2017-03-04 06:54:05 +00:00
Bruce Evans
0a743c0957 Colorize syscons kernel console output according to a table indexed
by the CPU number.

This was originally for debugging near-deadlock conditions where
multiple CPUs either deadlock or scramble each other's output trying
to report the problem, but I found it interesting and sometimes
useful for ordinary kernel messages.  Ordinary kernel messages
shouldn't be interleaved, but if they are then the colorization
makes them readable even if the interleaving is for every character
(provided the CPU printing each message doesn't change).

The default colors are 8-15 starting at 15 (bright white on black)
for CPU 0 and repeating every 8 CPUs.  This works best with 8 CPUs.
Non-bright colors and nonzero background colors need special
configuration to avoid unreadable and ugly combinations so are not
configured by default.  The next bright color after 15 is 8 (bright
black = dark gray) is not very readable but is the only other color
used with 2 CPUs.  After that the next bright color is 9 (bright
blue) which is not much brighter than bright black, but is used with
3+ CPUs.  Other bright colors are brighter.

Colorization is configured by default so that it gets tested.  It can
only be turned off by configuring SC_KERNEL_CONS_ATTR to anything other
than FG_WHITE.  After booting, all colors can be changed using the
syscons.kattr sysctl.  This is a SYSCTL_OPAQUE, and no utility is
provided to change it (sysctl only displays it).

The default colors work in all VGA modes that I could test.  In 2-color
graphics modes, all 8 bright colors are displayed as bright white, so
the colorization has no effect, but anything with a nonzero background
gives white on white unless the foreground is zero.  I don't have an
mono or VGA grayscale hardware to test on.  Support for mono mode seems
to have never worked right in syscons (I think bright white gives white
underline with either bold or bright), but VGA grayscale should work
better than 2-color graphics.
2017-03-04 06:19:12 +00:00
Andriy Gapon
f5aac9074a add a module that provides support for DRAM ECC error injection on AMD CPUs
I imagine that the module would be useful only to a very limited number
of developers, so that's my excuse for not writing any documentation.
On a more serious note, please see DRAM Error Injection section of BKDGs
for families 10h - 16h.  E.g. section 2.13.3.1 of  BKDG for AMD Family 15h
Models 00h-0Fh Processors.

Many thanks to kib for his suggestions and comments.

Discussed with:	kib
MFC after:	3 weeks
Differential Revision: https://reviews.freebsd.org/D9824
2017-03-03 22:51:04 +00:00
Andriy Gapon
7abf460488 MCA: add AMD Error Thresholding support
Currently the feature is implemented only for a subset of errors
reported via Bank 4.  The subset includes only DRAM-related errors.

The new code builds upon and reuses the Intel CMC (Correctable MCE
Counters) support code.  However, the AMD feature is quite different
and, unfortunately, much less regular.

For references please see AMD BKDGs for models 10h - 16h.
Specifically, see MSR0000_0413 NB Machine Check Misc (Thresholding)
Register (MC4_MISC0).
http://developer.amd.com/resources/developer-guides-manuals/

Reviewed by:	jhb
MFC after:	1 month
Differential Revision: https://reviews.freebsd.org/D9613
2017-03-03 22:42:43 +00:00
Eric van Gyzen
8a8bea603c Fix grammar in some comments in subr_sleepqueue.c
While I'm here, remove trailing whitespace.

Reviewed by:	kib, mostly, as part of a larger review
MFC after:	3 days
2017-03-03 21:03:28 +00:00
Mark Johnston
7813302434 Fix a ticks comparison in sched_pctcpu_update().
We may fail to reset the %CPU tracking window if a thread does not run
for over half of the ticks rollover period, resulting in a bogus %CPU
value for the thread until ticks fully rolls over. Handle this by comparing
the unsigned difference ticks - ts_ltick with SCHED_TICK_TARG instead.

Reviewed by:	cem, jeff
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-03 20:57:40 +00:00