]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoMFC r335228-r335231, r335272: stand: efiloader fixes
kevans [Wed, 20 Feb 2019 18:34:20 +0000 (18:34 +0000)]
MFC r335228-r335231, r335272: stand: efiloader fixes

r335228:
Migrate has_keyboard to bool.

r335229:
Provide a more direct interface to tell ZFS what the preferred handle
is. We tell the ZFS code now, and it checks rather than having a
callback to do the checks.

This will allow us to have a more graceful fallback code. In the
future, it's anticipated that we may fallback to a more global search
(or implement a command to do so) when reqeusted by the user, or we
detect a violation of the UEFI Boot Manager protocol severe enough to
warrant this backstop. For now, it just allows us to get rid of img as
a global.

r335230:
Move arg parsing into its own routine for possible later reuse.

r335231:
There's no need to walk through the tables looking for the smbios
table if we're just going to ignore it on arm, so expand, slightly,
the reach of the ifdef. Move the buffer to the inner block so we
don't have a separate #ifdef far away from these lines.

The issue on arm is that smbios_detect does unaligned accesses, which
in the u-boot implementing EFI context causes a crash.

r335272:
Many netboot scenarios don't have /boot/defaults/loader.conf. As
a fallback, also check /boot/kernel/kernel existing as well, since
that's the fallback behavior of the loader.

5 years agoMFC r334412: userboot: Fix bad type-punning
kevans [Wed, 20 Feb 2019 18:30:54 +0000 (18:30 +0000)]
MFC r334412: userboot: Fix bad type-punning

Pass a struct devdesc to the format commands. Use proper type rather
than doing weird type-punning that happened to work because the size
was right. We copied a zfs devdesc into a disk_devdesc and then after
passing through a NULL pointer reinterpreted it as a
zfs_devdesc. Instead, pass the base devdesc around and 'upcase' when
we know the types are right.

This has the happy side effect of fixing a gcc warning about bad
type punning.

5 years agoMFC r344042:
pfg [Wed, 20 Feb 2019 14:12:25 +0000 (14:12 +0000)]
MFC r344042:
UMA: unsign some variables related to allocation in hash_alloc().

As a followup to r343673, unsign some variables related to allocation
since the hashsize cannot be negative. This gives a bit more space to
handle bigger allocations and avoid some implicit casting.

While here also unsign uh_hashmask, it makes little sense to keep it
signed.

Differential Revision: https://reviews.freebsd.org/D19148

5 years agoMFC r335245-r335248, r335254, r335276, r335298, r335398, r335868, r335883
kevans [Tue, 19 Feb 2019 19:16:28 +0000 (19:16 +0000)]
MFC r335245-r335248, r335254, r335276, r335298, r335398, r335868, r335883

r335245:
Correct logic error in biosdisk.c:bd_realstrategy()

The wrong condition is used when evaluating the return of disk_ioctl()
This results in reaching the 'We should not get here' branch in most casts

r335246:
biosdisk.c remove redundant variable

`rdev` and `disk` serve the same purpose, read the partition table without
the `d_offset` or `d_slice` set, so the read is relative to the start of
the disk. Reuse the already initialized `disk` instead of making another
copy later.

r335247:
biosdisk.c: add missing \n to error message

r335248:
biosdisk.c: fix type in debug printf

r335254:
Avoid reading past the end of the disk in zfsboot.c and biosdisk.c

The GELI boot code rounds reads up to 4k, since the encrypted sectors are
4k, and must be decrypted as a unit. With oddball sized disks (almost
always virtual), this can lead to reading past the end of the disk.

r335276:
gptboot, zfsboot, gptzfsboot: Enable the video and serial consoles early

Normally the serial console is not enabled until /boot.config is read and
we know how the serial console should be configured.  Initialize the
consoles early in 'dual' mode (serial & keyboard) with a default serial
rate of 115200. Then serial is re-initialized once the disk is decrypted
and the /boot.config file can be read.

This allows the GELIBoot passphrase to be provided via the serial console.

r335298:
stand/common/disk.c: Update debug printf

This was missed in r330809 because it is compiled out by default

r335398:
Revert r335276

This was causing issues for people booting.
I will likely bring this back as an optional feature, similar to
boot0sio, like gptboot-serial or something.

r335868:
stand/common/disk.c: Read partition table relative to the start of the disk

If a disk is of an oddball size, like the 200mb + 512b used in rootgen.sh,
when disk_open() is called on a GELI encrypted partition, attempts to read
the partition table fail, as they pass through the decryption process which
turns the already plaintext data into jibberish.

When reading the partition table, always pass a slice and partition setting
of -1, and an offset of 0. Setting the slice to -1 prevents a false
positive when checking the slice against the cache of GELI encrypted
slices.

r335883:
stand/common/disk.c: dev->d_offset still needs to be set to 0

With r335868, I thought this was no longer necessary. I was wrong.

5 years agoMFC r335125-r335127, r335148, r335224
kevans [Tue, 19 Feb 2019 18:50:20 +0000 (18:50 +0000)]
MFC r335125-r335127, r335148, r335224

r335125:
libsa: cstyle cleanup for open/close/read/write sources

r335126:
libsa: f_rabuf could be NULL

It is possible that we will not get RA buffer from open(), therefore
we must validate RA.

r335127:
libsa: remobe unneeded check before free()

free() is checking for NULL, remove duplicate check.

r335148:
libsa: open() should use NULL instead of typecasted 0

r335224:
Remove empty directory

5 years agoMFC r335117: stand bootprog_info consolidation
kevans [Tue, 19 Feb 2019 18:48:17 +0000 (18:48 +0000)]
MFC r335117: stand bootprog_info consolidation

bootprog_info is generated in vers.c. Move it's definition to
bootstrap.h and remove all the redundant copies.

5 years agoMFC r335069-r335071, r335110, r335116: stand housecleaning
kevans [Tue, 19 Feb 2019 18:45:40 +0000 (18:45 +0000)]
MFC r335069-r335071, r335110, r335116: stand housecleaning

r335069:
Remove fail: label. It's unused.

r335070:
Remove unused variables.

[kevans@: removed ufs.c modifications; those depend on ufs rewrite bits]

r335071:
Initialize variables we later free so they aren't used
uninitialized in the error path.
Remove unused variables.

r335110:
Remove redundant defs.mk includes. They aren't needed.

r335116:
Use bool for vargood, since it's a boolean.

5 years agoMFC r334868: Add st_mtime, st_ino and st_dev for ufs_stat
kevans [Tue, 19 Feb 2019 18:37:45 +0000 (18:37 +0000)]
MFC r334868: Add st_mtime, st_ino and st_dev for ufs_stat

5 years agoMFC r332557-r332558, r332560, r332565: loader command cleanup-lite
kevans [Tue, 19 Feb 2019 18:34:00 +0000 (18:34 +0000)]
MFC r332557-r332558, r332560, r332565: loader command cleanup-lite

r332557:
loader: make sure we use snprintf() in commands.c

Safeguard against memory corruptions.

r332558:
loader: command_errmsg should be const

Use const char * for command_errmsg.

r332560:
loader: make sure we do not return garbage from help_getnext

Since we do free subtopic and desc in help_getnext(), we need to set them also
NULL, so we make sure we dont get double free().

r332565:
loader: cstyle cleanup of command.c

just clean it up. no functional changes intended.

5 years agoMFC r332555: loader: provide values in help_getnext()
kevans [Tue, 19 Feb 2019 18:32:05 +0000 (18:32 +0000)]
MFC r332555: loader: provide values in help_getnext()

With r328289 we attempt to make sure we free the resources allocated in
help_getnext(), however, it is possible that we get no resources allocated
and help_getnext() will return early.

Make sure we have pointers set to NULL early in help_getnext().

5 years agoMFC r330757: stand/interp_lua: correct errorr => error
kevans [Tue, 19 Feb 2019 18:28:32 +0000 (18:28 +0000)]
MFC r330757: stand/interp_lua: correct errorr => error

5 years agoMFC r344061:
kp [Tue, 19 Feb 2019 18:22:57 +0000 (18:22 +0000)]
MFC r344061:

garp: Fix vnet related panic for gratuitous arp

Gratuitous ARP packets are sent from a timer, which means we don't have a vnet
context set. As a result we panic trying to send the packet.

Set the vnet context based on the interface associated with the interface
address.

To reproduce:
sysctl net.link.ether.inet.garp_rexmit_count=2
ifconfig vtnet1 10.0.0.1/24 up

PR: 235699
Reviewed by: vangyzen@

5 years agoMFC r342114:
trasz [Tue, 19 Feb 2019 10:40:35 +0000 (10:40 +0000)]
MFC r342114:

Add kern.rpc.gss.client_max, to make it possible to bump it easily.
This can drastically lower the load on gssd(8) on large NFS servers.

5 years agovmx(4): add native netmap support
vmaffione [Tue, 19 Feb 2019 10:07:48 +0000 (10:07 +0000)]
vmx(4): add native netmap support

This change adds native netmap support for the vmx(4) adapter
(vmxnet3). Native support comes for free in 12, since the driver has been
ported to iflib. To make it minimally intrusive, the native support is
only enabled if vmxnet3.netmap_native is set at boot (e.g., in loader.conf).

Tested on stable/11 running inside vmplayer.

Submitted by: Giuseppe Lettieri <g.lettieri@iet.unipi.it>
Reviewed by: vmaffione, bryanv
Sponsored by: Sunny Valley Networks
Differential Revision: https://reviews.freebsd.org/D19104

5 years agoMFC r332170, r332173: light cd9660 cleanup
kevans [Mon, 18 Feb 2019 19:16:14 +0000 (19:16 +0000)]
MFC r332170, r332173: light cd9660 cleanup

r332170:
libsa: cd9660: warning: 'lenskip' may be used uninitialized in this function

We better provide value for lenskip in both instances.

r332173:
libsa: name is not used in dirmatch()

Seems like variable 'name' is leftover.

5 years agoMFC r329727-r329728: lualoader ZFS BE Support
kevans [Mon, 18 Feb 2019 19:13:28 +0000 (19:13 +0000)]
MFC r329727-r329728: lualoader ZFS BE Support

r329727:
stand/zfs: Add all bootenvs to environment

For the benefit of lualoader, add all bootenvs to environment when
init_zfs_bootenv is invoked. All of the boot environment logic can then be
implemented in pure lua, rather than going back and forth with C to
implement paging.

This stores all boot environments in bootenvs[idx] and the final count of
bootenvs in bootenvs_count.

While here, make a copy of currdev for init_zfs_bootenv since it will be
modifying it and the caller may not necessarily want that. Some of the logic
was shifted around so that the 'currdev' pointer remains at the beginning of
the string and 'beroot' is moved around as needed to modify it or ultimately
store it in zfs_be_root.

The original zfs_bootenv that this was copied from will be able to go away
only if/when forth eventually goes away.

r329728:
stand/zfs: Unbreak build, 'truct' ~= 'struct'

5 years agoMFC r344023:
brooks [Mon, 18 Feb 2019 18:57:52 +0000 (18:57 +0000)]
MFC r344023:

mdmfs: Fix many bugs in automatic md(4) creation.

This code allocated a correctly sized buffer, read past the end of
the source buffer, writing off the end of the target buffer, and then
writing a '\0' terminator past the end of the target buffer (in the
wrong place). It then leaked the buffer.

Switch to a statically sized buffer on the stack and update the source
pointer and length before use so the correct things are copied.

Fix a logic error in the checks that the format of the line is as
expected and move on out of an assert.

Remove an unneeded close(). fclose() closes the descriptor.

Found with: CheriABI
Obtained from: CheriBSD
Reviewed by: kib, jhb, markj
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D19122

5 years agoMFC r339214:
trasz [Mon, 18 Feb 2019 16:03:48 +0000 (16:03 +0000)]
MFC r339214:

Remove BUGS section from nscd.conf(5) man page.  This was missed in r339194.

Sponsored by: DARPA, AFRL

5 years agoMFC r339194:
trasz [Mon, 18 Feb 2019 16:02:50 +0000 (16:02 +0000)]
MFC r339194:

Remove the BUGS section of nscd(8) man page.  According to bushman@'s
reponse quoted in PR, he no longer maintains it.

PR: 210590
Sponsored by: DARPA, AFRL

5 years agoMFC: r343164
marck [Mon, 18 Feb 2019 10:13:52 +0000 (10:13 +0000)]
MFC: r343164

Clarify error messages a bit.

X-Found-With: r343112
Reviewed by: eugen (implicitly, when r343112 analysis)

5 years agoMFC r343723:
kib [Sun, 17 Feb 2019 10:01:42 +0000 (10:01 +0000)]
MFC r343723:
i386: Do not ever store to other-CPU counter64 slot.

5 years agoMFC r343699:
avos [Sun, 17 Feb 2019 03:21:42 +0000 (03:21 +0000)]
MFC r343699:
net80211: do not setup Tx parameters for unsupported modes.

That should shorten 'ifconfig <wlan> list txparam' output since
unsupported modes will not be shown.

5 years agoMFC r343696:
avos [Sun, 17 Feb 2019 03:12:27 +0000 (03:12 +0000)]
MFC r343696:
net80211: do not setup roaming parameters for unsupported modes.

ifconfig(8) prints per-mode parameters if they are non-zero; since
we have 13 possible modes with 3...5 typically supported this change
should greatly reduce amount of information for 'ifconfig <wlan> list roam'
command.

While here ensure that sta_roam_check() will not use roaming parameters
for unsupported modes (it should not).

This change effectively reverts r188776.

5 years agoMFC r343501:
avos [Sun, 17 Feb 2019 02:58:44 +0000 (02:58 +0000)]
MFC r343501:
Add NO_6_BYTE / NO_SYNC_CACHE quirks for (C|D|E).* Olympus digital cameras

PR: 97472
Submitted by: Fabio Luis Girardi <papelhigienico@gmail.com>
Reviewed by: imp

5 years agoMFC lualoader: r326353, r328440, r328443, r329166-r329167, r329274, r329329,
kevans [Sun, 17 Feb 2019 02:39:17 +0000 (02:39 +0000)]
MFC lualoader: r326353, r328440, r328443, r329166-r329167, r329274, r329329,
r329349-r329352, r329355-r329359, r329366-r329369, r329386-r329387, r329393,
r329413-r329415, r329417, r329424-r329436, r329457, r329473-r329474,
r329496-r329501, r329503-r329504, r329543, r329547-r329551, r329576-r329578,
r329580, r329583, r329585-r329590, r329592-r329596, r329609-r329611,
r329614, r329619, r329621-r329622, r329624, r329626-r329627,
r329629-r329632, r329640-r329641, r329643-r329646, r329649-r329650, r329654,
r329656, r329662, r329669-r329671, r329673-r329674, r329680,
r329684-r329689, r329692-r329693, r329696-r329700, r329709, r329716,
r329731, r329733-r329734, r329747-r329748, r329756, r329779, r329782,
r329784, r329786, r329804, r329806, r329809, r329811, r329836,
r329850-r329852, r329854, r329856-r329858, r329861, r329895,
r329897-r329899, r329901-r329903, r329922-r329924, r329927-r329928,
r329944-r329949, r329986-r329987, r330008-r330010, r330012, r330020,
r330082-r330084, r330087-r330088, r330098-r330101, r330138-r330139,
r330261-r330263, r330267-r330269, r330281-r330284, r330287, r330339-r330342,
r330345-r330346, r330369-r330370, r330434-r330435, r330564, r330616-r330618,
r330620, r330625, r330690, r330701, r330703, r330825, r331211, r331257,
r331259, r331281-r331282, r331304, r331314, r331476-r331477,
r331563-r331564, r331854-r331857, r331859-r331860, r332106, r334723,
r334879, r334891, r334907, r334912, r334939, r334986, r335009, r335371,
r336759, r337711, r337807-r337810, r338054, r338063, r338065-r338067,
r338083, r338085-r338086, r338108, r338167-r338168, r338173, r338203,
r338255, r338259, r338309, r338394, r338438, r338886, r338893, r339173,
r339200, r339218, r339222, r339301, r339307, r339677-r339678, r339702,
r339805, r339831, r339849, r340040, r340152

Some notes for this MFC:
- This is still pre-forth/lua coexistance; that will come shortly-ish so
that forth/lua may be installed together (with forth remaining the default)

- module_blacklist support for lualoader has been MFC'd, but the drm modules
are not blacklisted in this stable branch.

r326353: Import lua 5.3.4 to contrib
r328440: Preserve the original luaconf.h in a convenient place. Clients will
r328443: Gross hack to omit printing hex floating point when the lua number
r329166: Add Lua as a scripting langauge to /boot/loader
r329167: Add the lua scripts from the lua-bootloader SoC
r329274: stand/lua: Exit sub-menus on backspace
r329329: stand/lua: Always boot on 'enter' keypress in menus
r329349: stand/lua: Reduce magic numbers
r329350: stand/lua: Don't descend into an empty kernels submenu
r329351: stand/lua: Set reasonable ACPI default based on presence
r329352: stand/lua: Consistently use semicolons for line endings
r329355: stand/lua: Move kernel selection into main menu
r329356: stand/lua: Allow menu items to not have explicit aliases
r329357: stand/lua: Remove explicit alias from "Back to main menu"
r329358: stand/lua: Say "loader prompt" instead of "lua interpreter"
r329359: stand/lua: Remove a magic number/string (not a trivial literal)
r329366: stand/lua: Set ACPI's default the proper way (setACPI)
r329367: stand/lua: Create a "carousel" menu entry type
r329368: stand/lua: Create/use some MENU_ constants where applicable
r329369: stand/lua: Remove sneaky kernel assignment
r329386: stand/lua: Correct usage and acceptance of BACKSPACE/DELETE keys
r329387: stand/lua: Chop off the decimal for numbers passed to setcursor
r329393: stand/lua: Use escaped dot instead of single character class
r329413: stand/lua: Allow MENU_RETURN items to have func, fix esc. to prompt
r329414: stand/lua: Don't try to divide by 0; do nothing
r329415: stand/lua: Don't reload kernel config if we only have one kernel
r329417: stand/lua: Make CAROUSEL_ENTRY func parameters consistent with name
r329424: stand/lua: Don't set autoboot_delay=NO in menu autoboot sequence
r329425: stand/lua: Enable menu autoboot; it seems to work
r329426: stand/lua: Correct interpretation of autoboot_delay
r329427: stand/lua: Color non-default kernels blue
r329428: stand/lua: Correct some trivial errors in config
r329429: stand/lua: Add debug method to dump modules
r329430: stand/lua: Address some nits
r329431: stand/lua: Correct test sense, this should have been 'not nil'
r329432: stand/lua: Try to load alternate kernels as directories first
r329433: stand/lua: Add optional GELI passphrase prompt
r329434: stand/lua: Check for nil (GELI prompt)
r329435: stand/lua: Style pass
r329436: stand/lua: Debugging string snuck in...
r329457: stand/lua: dumpModules => lsModules
r329473: liblua: Clean up io/loader C module registration
r329474: liblua: Emulate DIR, opendir, fdopendir, closedir
r329496: stand/lua: Fix verbiage and some typos
r329497: stand/lua: Fix module_path handling with multiple kernels
r329498: stand/lua: Remove some debugging bits that snuck in... gr...
r329499: interp_lua: Register io/loader with regular Lua module system
r329500: Lua loader: Add barebones "lfs" module
r329501: lua loader: Auto detect eligible list of kernels to boot
r329503: liblua: Fix missing '}' in lutil.c after r329499
r329504: stand/lua: More style nits, config.lua
r329543: Create style.lua(9)
r329547: stand/lua: Allow menu items to be conditionally (in)visible
r329548: stand/lua: Addres style.lua(9) concern
r329549: stand/lua: Clear the screen before prompting for passwords
r329550: stand/lua: Store the loaded kernel as config.kernel_loaded
r329551: stand/lua: reload previously loaded kernel at config-load/reload
r329576: stand/lua: Defer kernel/module loading until boot or menu escape
r329577: stand/lua: Rename bootserial for clarity
r329578: stand/lua: Menu style.lua(9) nits
r329580: stand/lua: Remove some unused local declarations
r329583: stand/lua: Store menu entries in an "entries" table
r329585: stand/lua: Add core.isSingleUserBoot
r329586: stand/lua: Call menu_entries if it's a function
r329587: stand/lua: Swap single-/multi- user boot entries as needed
r329588: stand/lua: Re-wrap menu.lua now that I've added indentation...
r329589: stand/lua: Track env changes that come in via loader.conf(5)
r329590: stand/lua: Restore environment upon config reload
r329592: stand/lua: Remove inaccurate comment after r329590
r329593: stand/lua: Change boot menu items' names when swapped
r329594: stand/lua: Round up some more style.lua(9) concerns
r329595: stand/lua: Re-order locals after copyright notice; require first
r329596: stand/lua: Add copyright notice in places
r329609: stand/lua: Cache swapped menu, and don't create locals for swapping
r329610: style.lua(9): Note that wrapping at 80-columns is not rigid
r329611: stand/lua: Wrap tuple assignment earlier for readability
r329614: stand/lua: Don't set ACPI off just because we can't detect it.
r329619: stand/lua: Extract menu handlers out into menu.handlers table
r329621: stand/lua: Add and use drawer.menu_name_handlers
r329622: stand/lua: Move drawer.menu_name_handlers further up
r329624: stand/lua: Reduce exposure of the drawer module
r329626: stand/lua: Refactor logos into drawer.logodefs table
r329627: stand/lua: Refactor brands into drawer.branddefs
r329629: stand/lua: Use 'graphic' instead of 'logo' for depicting graphics
r329630: stand/lua: Stick a copyright notice on drawer.lua
r329631: stand/lua: Insert helpful comment for drawer.branddefs
r329632: style.lua(9): Clarify local variable guideline
r329640: stand/lua: Consistently declare local functions at module scope
r329641: stand/lua: Consistently organize modules
r329643: Implement loader.command
r329644: lualoader: Add ability to intercept cli commands
r329645: lualoader: Move carousel storage out into config
r329646: lualoader: Eliminate global namespace pollution in loader.lua
r329649: Lua lfs.attributes: Provide a more consistent error return
r329650: liblua: Add loader.machine and loader.machine_arch properties
r329654: lualoader: Ignore ACPI bits on !i386
r329656: loader.lua: Expose errno table to lua
r329662: lualoader: Replace invalid construct with valid construct
r329669: lualoader: Prefer selected kernel to currently loaded
r329670: lualoader: Don't try so hard to load a kernel
r329671: lualoader: Prepare for interception of "boot" CLI cmd
r329673: lualoader: Intercept boot cli command
r329674: lualoader: Intercept the 'autoboot' cli command
r329680: lualoader: When restoring environment, only restore unchanged vars
r329684: lualoader: Drop terminating semicolons
r329685: lualoader: Drop excessive parenthesizing
r329686: style.lua(9): Drop notes about semicolons
r329687: lualoader: Drop explicit boolean tests; b or not b
r329688: lualoader: Don't return false for failure to open config on silent
r329689: lualoader: Output "Failed to parse" messages
r329692: lualoader: Bring in local.lua module if it exists
r329693: lualoader: Return only argstr if with_kernel not requested
r329696: lualoader: Add "menu.default", initialized to menu.welcome
r329697: lualoader: Drop name requirement for menu separators
r329698: lualoader: Directly reference submenu definition with submenu key
r329699: lualoader: Simplify menu definitions a little further
r329700: lualoader: Allow carousel 'items' to be a table as well
r329709: lualoader: Don't autodetect kernels if 'kernels' is explicitly set
r329716: lualoader: Use the key that interrupts autoboot as a menu choice
r329731: lualoader: Add boot environment support
r329733: lualoader: Make kernel autodetect. contingent on loader.conf(5) var
r329734: lualoader: Don't execute menu.autoboot() for every opened menu
r329747: lualoader: Replace 8-space indentation with a single tab
r329748: lualoader: Drop password length restrictions
r329756: lualoader: Remove nasty hack for not printing out ".0"
r329779: lualoader: Split cli bits out into a cli module
r329782: lualoader: Unbreak 'boot [kernel]' by including config
r329784: lualoader: Pull argument extraction for cli funcs to cli.arguments
r329786: lualoader: Attach cli command functions to cli module
r329804: lualoader: Eliminate some unused locals
r329806: lualoader: Consistently use double quotes
r329809: lualoader: Address some 'luacheck' concerns
r329811: lualoader: Clear up an empty conditional branch
r329836: lualoader: Attend to some 80-col issues, pointed out by luacheck
r329850: lualoader: Drop unused return values; we'll only use the first
r329851: Add SPDX tags to lua files
r329852: Add copyright notice to core.lua
r329854: lualoader: shallowCopyTable => deepCopyTable
r329856: lualoader: Use "local function x()" instead "local x = function()"
r329857: Centralize lua defines
r329858: When the LUA_FLOAT_TYPE != LUA_FLOAT_INT64, we can't ref. float
r329861: lualoader: Track effective line number, use it for drawing
r329895: liblua: Implement write support
r329897: lualoader: Add nextboot support
r329898: lualoader: Plug file handle not properly closed
r329899: lualoader: Correct test and name
r329901: lualoader: Add comment on trailing space, don't operate on nil
r329902: lualoader: Remove unused variable; we now use effective line number
r329903: lualoader: Explain nextboot stuff a little bit more
r329922: lualoader: Split config file I/O out into a separate function
r329923: lualoader: Strip config.parse of its I/O privileges
r329924: lualoader: throw out nextboot's usage of standard config processing
r329927: lualoader: Clean up naming conventions a little bit
r329928: lualoader: Remove inaccurate part of comment
r329944: lualoader: Don't explicitly index tables without reason
r329945: lualoader: menu: Terminate final values in tables with a comma
r329946: lualoader: Clean up menu handling a little bit
r329947: lualoader: Pull menu redrawing specifics out of menu.process
r329948: lualoader: Pull autoboot handling out into menu.run()
r329949: lualoader: Explain deviation from naming guidelines
r329986: lualoader: Invalidate the screen from menu perspective mnu exit
r329987: lualoader: Track the menu currently drawn, instead of validity
r330008: lualoader: A little more general menu cleanup
r330009: lualoader: More argument name expansion, part 2
r330010: lualoader: screen argument fixes
r330012: style.lua(9): Add some additional notes about naming and commas
r330020: lualoader: Re-work menu skipping bits
r330082: lualoader: Add a twiddle at password prompt
r330083: lualoader: Remove remnants of testing...
r330084: lualoader: Replace instances of \027 with KEYSTR_ESCAPE
r330087: lualoader: Convert instances of KEYSTR_ESCAPE .. "[" -> KEYSTR_CSI
r330088: lualoader: Correct test sense, comments, and add some more comments
r330098: lualoader: Re-do twiddle
r330099: lualoader: Further screen cleanup
r330100: lualoader: Remove debug function
r330101: lualoader: Add note that \027 is a decimal representation
r330138: lualoader: Dedup these "Return to main menu" entries
r330139: lualoader: config: Pull some messages out into constants
r330261: lualoader: Fix some lint-mentioned errors
r330262: lualoader: Use #str instead of tracking length with 'n'
r330263: lualoader: Use string literal \xNN instead of string.char()
r330267: Add core.lua(8), but do not add to distribution
r330268: Add menu.lua(8), but do not add to distribution
r330269: core.lua(8): Add missing note about core.KEYSTR_CSI
r330281: lualoader: Steamroll the box-drawing
r330282: lualoader: Register loader.printc as global printc
r330283: lualoader: Use global printc instead of loader.printc
r330284: liblua: Use putc instead of printf for printc
r330287: lualoader: Reset the cursor position after the menu is drawn
r330339: liblua: Add loader.interpret
r330340: lualoader: Execute menu_timeout_command at the end of menu autoboot
r330341: lualoader: Respect loader_menu_title, prepare for align
r330342: lualoader: Respect loader_menu_title_align
r330345: lualoader: Tweak positioning and fix an off-by-one
r330346: lualoader: Shift menu+brand even for logo=none with customized pos
r330369: lualoader: Return meaningful value in cli_execute
r330370: lualoader: logdef -> logodef typo
r330434: lualoader: Add note about importance of including cli module early
r330435: lualoader: Use FILESDIR instead of BINDIR
r330564: lualoader: Only loadelf before boot/autoboot if no kernel loaded
r330616: lualoader: Expose loader.parse and add cli_execute_unparsed
r330617: lualoader: Fix name, cli.execute_unparsed -> cli_execute_unparsed
r330618: lualoader: Use cli_execute_unparsed instead of loader.interpret
r330620: lualoader: Use cli_execute_unparsed for commands via loader.conf
r330625: lualoader: Return status in cli_execute_unparsed properly
r330690: stand: Fix copy-paste-o, unbreaks libi386 lualoader build
r330701: lualoader: Don't redraw the autoboot message every .05s
r330703: lualoader: Cache kernel list
r330825: lualoader: Sprinkle some verbose_loading salt
r331211: lualoader: Setup default color scheme if we're using colors
r331257: lualoader: Reset attributes and color scheme with color.highlight()
r331259: lualoader: Use less atomic options for resetting colors/attributes
r331281: lualoader: Add primitive hook module to untangle bogus reference
r331282: core.lua(8): Update to reflect recently added function
r331304: lualoader: Clear up some possible naming confusion
r331314: lualoader: Use printc when we expect ANSI escape sequences
r331476: lualoader: Make config env-related bits private API
r331477: lualoader: Privatize some more config.lua bits
r331563: lualoader: Implement try_include and use it for including local
r331564: lualoader: Actually re-raise error in try_include
r331854: lualoader: Do case-insensitive comparison of "yes"
r331855: lualoader: Don't assume that {module}_load is set
r331856: lualoader: revert whitespace change that snuck in
r331857: lualoader: Simplify some expressions
r331859: lualoader: Split logodefs out into logo-* files
r331860: lualoader: Don't try to lookup a nil logo
r332106: lualoader: Fix menu skipping with loader.conf(5) vars
r334723: lualoader: Add a loaded hook for others to execute upon config load
r334879: lualoader: Add hook.lua(8) to tree
r334891: lualoader: Add cli.lua(8) to the tree
r334907: lualoader: Process loader_conf_files properly
r334912: lualoader: Support variable substitution in env var settings
r334939: lualoader: Allow brand-*.lua for adding new brands
r334986: lualoader: More black-on-white fixes
r335009: lualoader: Match Forth module-loading behavior w.r.t flags
r335371: lualoader: Correct kernel_options handling
r336759: lualoader: "nextboot_file" should be spelled "nextboot_conf"
r337711: lualoader: Fix parsing of negative number loader.conf(5) variables
r337807: Prevent a wanring about checkdp being unused.
r337808: When the LUA floating point model is INT64, we don't need to do the
r337809: For our INT64 implementation, we can compare integers and numbers
r337810: MFV r337586: lua: Update to 5.3.5
r338054: Add config.lua(8) to the tree
r338063: lualoader: Stop exporting drawer.draw
r338065: lualoader: Hide most of the internal drawing functions
r338066: lualoader: Hide the rest of the private interfaces
r338067: lualoader: Add drawer-exported variables for default logodefs
r338083: Add drawer.lua(8)
r338085: Add color.lua(8), password.lua(8), and screen.lua(8)
r338086: lualoader: Install all manpages
r338108: Serial console menus for lua.
r338167: lualoader: Just compare expression directly
r338168: lualoader: Refactor config line expressions
r338173: lualoader: Fix loader.conf(5) EOL validation for 'exec' lines
r338203: Turn off LOADER_GELI and LOADER_LUA for sparc64, until functional
r338255: lualoader: Fix (add) Xen support
r338259: lualoader: Accept that people use unquoted values in loader.conf
r338309: lualoader: Fix override of module_path on loader prompt
r338394: lualoader: fix color usage
r338438: lualoader: Handle comma-separated kernels as well
r338886: Improve loader passwords:
r338893: Set the default loader for powerpc(32- and 64-bit) back to to forth
r339173: Set the default loader for powerpc64 back to to forth too.
r339200: lualoader: Don't draw loader menu with autoboot_delay=-1
r339218: lualoader: Create a module blacklist, add DRM modules to it
r339222: lualoader: Honor boot_* variables at lua init
r339301: Loader GELI support, like lua loader, seems to be broken on PowerPC
r339307: lualoader: Provide a 'menu' command to redraw the menu at prompt
r339677: lualoader: unload upon kernel change if a kernel was loaded
r339678: menu.lua: Abort autoboot sequence on failed command
r339702: lualoader: Improve module loading diagnostics
r339805: lualoader: Always return a proper dictionary for blacklist
r339831: Move LUA_ROOT to /boot/lua
r339849: lualoader: Fix try_include error handling
r340040: lualoader: Implement boot-conf
r340152: lualoader: Add chainload menu entry

Relnotes: yes ("lualoader has been merged to stable/11, off by
default, to facilitate testing")

5 years agoMFC r344112:
dim [Sat, 16 Feb 2019 19:49:12 +0000 (19:49 +0000)]
MFC r344112:

Pull in r353907 from upstream llvm trunk (by Reid Kleckner):

  [MC] Make symbol version errors non-fatal

  We stil don't have a source location, which is pretty lame, but at
  least we won't tell the user to file a clang bug report anymore.

  Fixes PR40712

This will make errors for symbols with @@ versions that are not defined
non-fatal.  For example:

  void f(void)
  {
    __asm__(".symver foo,bar@@baz");
  }

will now result in:

  error: versioned symbol bar@@baz must be defined

instead of clang crashing with a diagnostic report.

PR: 234671
Upstream PR: https://bugs.llvm.org/show_bug.cgi?id=40712

5 years agoMerge clang 7.0.1 and several follow-up changes
dim [Sat, 16 Feb 2019 15:57:29 +0000 (15:57 +0000)]
Merge clang 7.0.1 and several follow-up changes

MFC r318594:

Add libc++experimental.a for std::experimental support

This adds a separate library for supporting std::experimental features.
It is purposefully static, and must be explicitly linked into programs
using -lc++experimental.

PLEASE NOTE: there is NO WARRANTY as to any stability or continuing
existence of the features in the std::experimental parts of the C++
library!

Reviewed by: ed
Differential Revision: https://reviews.freebsd.org/D10840

MFC r318598:

Add PICFLAG to build libc++experimental.a, so it can be used in all
situations.

Noticed by: kib

r336969 | emaste | 2018-07-31 16:12:09 +0200 (Tue, 31 Jul 2018) | 13 lines

llvm: [ELF][ARM] Add Arm ABI names for float ABI ELF Header flags

The ELF for the Arm architecture document defines, for EF_ARM_EABI_VER5
and above, the flags EF_ARM_ABI_FLOAT_HARD and EF_ARM_ABI_FLOAT_SOFT.
These have been defined to be compatible with the existing
EF_ARM_VFP_FLOAT and EF_ARM_SOFT_FLOAT used by gcc for
EF_ARM_EABI_UNKNOWN.

This patch adds the flags in addition to the existing ones so that any
code depending on the old names will still work.

Obtained from: llvm r338370 by Peter Smith

r336970 | emaste | 2018-07-31 16:14:41 +0200 (Tue, 31 Jul 2018) | 9 lines

llvm: [ARM] Complete enumeration values for Tag_ABI_VFP_args

The LLD implementation of Tag_ABI_VFP_args needs to check the rarely
seen values of 3 (toolchain specific) and 4 compatible with both Base
and VFP.  Add the missing enumeration values so that LLD can refer to
them without having to use the raw numbers.

Obtained from: llvm r338373 by Peter Smith

r336972 | emaste | 2018-07-31 17:25:03 +0200 (Tue, 31 Jul 2018) | 37 lines

lld: [ELF][ARM] Implement support for Tag_ABI_VFP_args

The Tag_ABI_VFP_args build attribute controls the procedure call
standard used for floating point parameters on ARM. The values are:

0 - Base AAPCS (FP Parameters passed in Core (Integer) registers
1 - VFP AAPCS (FP Parameters passed in FP registers)
2 - Toolchain specific (Neither Base or VFP)
3 - Compatible with all (No use of floating point parameters)

If the Tag_ABI_VFP_args build attribute is missing it has an implicit
value of 0.

We use the attribute in two ways:

* Detect a clash in calling convention between Base, VFP and Toolchain.

we follow ld.bfd's lead and do not error if there is a clash between an
implicit Base AAPCS caused by a missing attribute. Many projects
including the hard-float (VFP AAPCS) version of glibc contain assembler
files that do not use floating point but do not have Tag_ABI_VFP_args.

* Set the EF_ARM_ABI_FLOAT_SOFT or EF_ARM_ABI_FLOAT_HARD ELF header flag

for Base or VFP AAPCS respectively. This flag is used by some ELF
loaders.

References:
* Addenda to, and Errata in, the ABI for the ARM Architecture for
  Tag_ABI_VFP_args
* Elf for the ARM Architecture for ELF header flags

Fixes LLVM PR36009

PR: 229050
Obtained from: llvm r338377 by Peter Smith

r337282 | alc | 2018-08-04 04:30:51 +0200 (Sat, 04 Aug 2018) | 7 lines

Set the default image base on arm64 and i386 to a superpage-aligned
address.

Reviewed by: emaste, markj
Discussed with: dim
Differential Revision: https://reviews.freebsd.org/D16385

r339304 | emaste | 2018-10-11 15:19:17 +0200 (Thu, 11 Oct 2018) | 13 lines

lld: set sh_link and sh_info for .rela.plt sections

ELF spec says that for SHT_REL and SHT_RELA sh_link should reference the
associated string table and sh_info should reference the "section to
which the relocation applies."  ELF Tool Chain's elfcopy / strip use
this (in part) to control whether or not the relocation entry is copied
to the output.

LLVM PR 37538 https://bugs.llvm.org/show_bug.cgi?id=37538

Approved by: re (kib)
Obtained from: llvm r344226 (backported for 6.0)

MFC r341825:

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
the upstream release_70 branch r348686 (effectively, 7.0.1 rc3).  The
release will follow very soon, but no more functional changes are
expected.

Release notes for llvm, clang and lld 7.0.0 are available here:
<http://releases.llvm.org/7.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/7.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/7.0.0/tools/lld/docs/ReleaseNotes.html>

PR: 230240, 230355
Relnotes: yes

MFC r342123:

Update clang, llvm, lld, lldb, compiler-rt and libc++ version number to
7.0.1 release r349250.  There were no functional changes since the 7.0.1
rc3 import.

PR: 230240, 230355
Relnotes: yes

r343429 | emaste | 2019-01-25 15:46:13 +0100 (Fri, 25 Jan 2019) | 16 lines

clang: default to DWARF 4 as of FreeBSD 13

FreeBSD previously defaulted to DWARF 2 because several tools (gdb,
ctfconvert, etc.) did not support later versions.  These have either
been fixed or are deprecated.

Note that gdb 6 still exists but has been moved out of $PATH into
/usr/libexec and is intended only for use by crashinfo(8).  The kernel
build sets the DWARF version explicitly via -gdwarf2, so this should
have no effect there.

PR: 234887 [exp-run]
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17930

MFC r343916:

Pull in r352607 from upstream llvm trunk (by Craig Topper):

  [X86] Add FPSW as a Def on some FP instructions that were missing it.

Pull in r353141 from upstream llvm trunk (by Craig Topper):

  [X86] Connect the default fpsr and dirflag clobbers in inline
  assembly to the registers we have defined for them.

  Summary:
  We don't currently map these constraints to physical register numbers
  so they don't make it to the MachineIR representation of inline
  assembly.

  This could have problems for proper dependency tracking in the
  machine schedulers though I don't have a test case that shows that.

  Reviewers: rnk

  Reviewed By: rnk

  Subscribers: eraman, llvm-commits

  Tags: #llvm

  Differential Revision: https://reviews.llvm.org/D57641

Pull in r353489 from upstream llvm trunk (by Craig Topper):

  [X86] Add FPCW as a register and start using it as an implicit use on
  floating point instructions.

  Summary:
  FPCW contains the rounding mode control which we manipulate to
  implement fp to integer conversion by changing the roudning mode,
  storing the value to the stack, and then changing the rounding mode
  back. Because we didn't model FPCW and its dependency chain, other
  instructions could be scheduled into the middle of the sequence.

  This patch introduces the register and adds it as an implciit def of
  FLDCW and implicit use of the FP binary arithmetic instructions and
  store instructions. There are more instructions that need to be
  updated, but this is a good start. I believe this fixes at least the
  reduced test case from PR40529.

  Reviewers: RKSimon, spatel, rnk, efriedma, andrew.w.kaylor

  Subscribers: dim, llvm-commits

  Tags: #llvm

  Differential Revision: https://reviews.llvm.org/D57735

These should fix a problem in clang 7.0 where it would sometimes emit
long double floating point instructions in a slightly wrong order,
leading to failures in our libm tests.  In particular, the cbrt_test
test case 'cbrtl_powl' and the trig_test test case 'reduction'.

Also bump __FreeBSD_cc_version, to be able to detect this in our test
suite.

Reported by:    lwhsu
PR: 234040
Upstream PR: https://bugs.llvm.org/show_bug.cgi?id=40206

MFC r344056:

Pull in r339734 from upstream llvm trunk (by Eli Friedman):

  [ARM] Make PerformSHLSimplify add nodes to the DAG worklist correctly.

  Intentionally excluding nodes from the DAGCombine worklist is likely
  to lead to weird optimizations and infinite loops, so it's generally
  a bad idea.

  To avoid the infinite loops, fix DAGCombine to use the
  isDesirableToCommuteWithShift target hook before performing the
  transforms in question, and implement the target hook in the ARM
  backend disable the transforms in question.

  Fixes https://bugs.llvm.org/show_bug.cgi?id=38530 . (I don't have a
  reduced testcase for that bug. But we should have sufficient test
  coverage for PerformSHLSimplify given that we're not playing weird
  tricks with the worklist. I can try to bugpoint it if necessary,
  though.)

  Differential Revision: https://reviews.llvm.org/D50667

This should fix a possible hang when compiling sys/dev/nxge/if_nxge.c
(which exists now only in the stable/11 branch) for arm.

5 years agoMFC r343601:
kevans [Sat, 16 Feb 2019 04:49:10 +0000 (04:49 +0000)]
MFC r343601:
install(1): Fix relative path calculation with partial common dest/src

For example, from the referenced PR [1]:

$ mkdir /tmp/lib/ /tmp/libexec
$ touch /tmp/lib/foo.so
$ install -lrs /tmp/lib/foo.so /tmp/libexec/

The common path identification bits terminate src at /tmp/lib/ and the
destination at /tmp/libe. The subsequent backtracking is then incorrect, as
it traverses the destination and backtraces exactly one level while eating
the 'libexec' because it was previously (falsely) identified as common with
'lib'.

The obvious fix would be to make sure we've actually terminated just after
directory separators and rewind a character if we haven't. In the above
example, we would end up rewinding to /tmp/ and subsequently doing the right
thing.

Test case added.

PR: 235330 [1]

5 years agoMFC: r343011
nyan [Sat, 16 Feb 2019 03:18:52 +0000 (03:18 +0000)]
MFC: r343011

  Use ${SRCTOP}/contrib/com_err/com_err.h instead of the installed com_err.h.
  This fixes build when com_err.h is not installed.

PR: 234691

5 years agoMFC r343980:
avos [Sat, 16 Feb 2019 01:05:22 +0000 (01:05 +0000)]
MFC r343980:
ifconfig(8): display 802.11n rates correctly for 'roam:rate' parameter

5 years agoMFC r343112: jail(8): stop crashing with SIGSEGV inside run_command()
eugen [Sat, 16 Feb 2019 00:40:03 +0000 (00:40 +0000)]
MFC r343112: jail(8): stop crashing with SIGSEGV inside run_command()
function while processing not entirely correct jail.conf(5) file
having something like "ip4.addr = 127.0.0.1;" and no "ip4 = ...;"
so extrap variable stays NULL.

Reported by:    marck

5 years agoMFC r343909:
avos [Sat, 16 Feb 2019 00:37:08 +0000 (00:37 +0000)]
MFC r343909:
newkey(8): fix 'tmpname' memory leak (always) and input file descriptor leak
when output file cannot be opened

PR: 201732
Reported by: David Binderman <dcb314@hotmail.com>

5 years agoMFC r343163:
wulf [Fri, 15 Feb 2019 20:46:03 +0000 (20:46 +0000)]
MFC r343163:

psm(4): detect Lenovo top-button clickpads

libinput has special handling for Lenovo ThinkPad *40 series, where it
treats clicks on the top button area as if they came from the TrackPoint:
https://wayland.freedesktop.org/libinput/doc/latest/t440-support.html

Detect these devices and set the corresponding evdev property.

Submitted by: Greg V <greg@unrelenting.technology>
Differential Revision: https://reviews.freebsd.org/D18676

5 years agoMFC r343859:
kib [Fri, 15 Feb 2019 11:36:16 +0000 (11:36 +0000)]
MFC r343859:
Add comment noting that the strange spelling of GenuineIntel is for reason.

5 years agoMFC r343899:
kib [Fri, 15 Feb 2019 11:28:32 +0000 (11:28 +0000)]
MFC r343899:
In null_vptocnp(), cache vp->v_mount and use it for null_nodeget() call.

PR: 235549

5 years agoMFC r343897, r343898:
kib [Fri, 15 Feb 2019 11:27:21 +0000 (11:27 +0000)]
MFC r343897, r343898:
Some style for nullfs_mount().
Before using VTONULL(), check that the covered vnode belongs to nullfs.

5 years agoMFC r343905:
hselasky [Fri, 15 Feb 2019 09:21:16 +0000 (09:21 +0000)]
MFC r343905:
Improve Bluetooth device discovery support for Android and Microsoft devices.

Tested using the virtual_bt_speaker(8) tool from the virtual_oss(8)
project at github.com.

PR: 210089
Sponsored by: Mellanox Technologies

5 years agoMFC r343480,343482: Silence Clang Scan warning about unsafe use of strcpy.
se [Thu, 14 Feb 2019 15:42:29 +0000 (15:42 +0000)]
MFC r343480,343482: Silence Clang Scan warning about unsafe use of strcpy.

Replace strcpy() by memcpy to the previously allocated range of known size.

5 years agoMFC r343479: Fix potential buffer overflow and undefined behavior.
se [Thu, 14 Feb 2019 15:41:05 +0000 (15:41 +0000)]
MFC r343479: Fix potential buffer overflow and undefined behavior.

The buffer allocated in read_chat() could be 1 element too short, if the
chatstr parameter passed in is 1 or 3 charachters long (e.g. "a" or "a b").
The allocation of the pointer array does not account for the terminating
NULL pointer in that case.

Overlapping source and destination strings are undefined in strcpy().
Instead of moving a string to the left by one character just increment the
char pointer before it is assigned to the results array.

5 years agoMFC r343408: Silence Clang Scan warnings regarding unsafe use of strcp().
se [Thu, 14 Feb 2019 15:39:17 +0000 (15:39 +0000)]
MFC r343408: Silence Clang Scan warnings regarding unsafe use of strcp().

While these warnings are false positives, the use of strdup() instead of
malloc() and strcpy() simplifies and clarifies the code.

A bogus assignment to a variable (whose previous value may be required in
a later block) has also been removed.

5 years agoMFC r343339: Silence Clang Scan warning about use of unitialized variable.
se [Thu, 14 Feb 2019 15:33:04 +0000 (15:33 +0000)]
MFC r343339: Silence Clang Scan warning about use of unitialized variable.

The logic is changed to depend on actual "beep" parameters instead of on a
flag that may be set for invalid parameters.

An embedded literal escape character has been replaced by "\e", since it
could confuse terminals when displaying the affected line.

5 years agoMFC r343868:
avos [Thu, 14 Feb 2019 09:50:59 +0000 (09:50 +0000)]
MFC r343868:
Add ypldap(8)-related files and /var/yp directory to the
OptionalObsoleteFiles.inc.

5 years agoMFC r343591:
cy [Thu, 14 Feb 2019 00:52:03 +0000 (00:52 +0000)]
MFC r343591:

Do not obtain an already held read lock. This causes a witness panic when
ipfs is invoked. This is the second of two panics resolving PR 235110.

PR: 235110
Reported by: David.Boyd49@twc.com

5 years agoMFC: r343372
marius [Wed, 13 Feb 2019 16:02:55 +0000 (16:02 +0000)]
MFC: r343372

ixl(4): Fix handling data passed with ioctl from NVM update tool

From Krzysztof:

Ensure that the entire data buffer passed from the NVM update tool is copied in
to kernel space and copied back out to user space using copyin() and copyout().

PR: 234104
Submitted by: Krzysztof Galazka <krzysztof.galazka@intel.com>
Reported by: Finn <ixbug@riseup.net>
Differential Revision: https://reviews.freebsd.org/D18817

5 years agoMFC: r343203
marius [Wed, 13 Feb 2019 14:28:02 +0000 (14:28 +0000)]
MFC: r343203

ixgbe: this statement may fall through warnings with gcc

The recent gcc versions (7 and 8 at least) can check for switch case
statements for fall through (implicit-fallthrough). When fall through
is intentional, the default method for warning suppression is to place
comment /* FALLTHROUGH */ exactly before next case statement.

Differential Revision: https://reviews.freebsd.org/D18577

5 years agoMFC: r333879, r342749
marius [Wed, 13 Feb 2019 14:25:05 +0000 (14:25 +0000)]
MFC: r333879, r342749

- Even though 64-bit atomics are supported on i386 there are panics
  indicating that the code does not work correctly there. Switch
  to mutex based variant (and fix that while we're here).
  Reported by: pho, kib

- mp_ring: avoid items offset difference between iflib and mp_ring
  on architectures without 64-bit atomics
  Reported by: Augustin Cavalier <waddlesplash@gmail.com>

5 years agoMFC r343871:
avos [Wed, 13 Feb 2019 09:28:48 +0000 (09:28 +0000)]
MFC r343871:
recoverdisk(1): fclose() file supplied via '-r readlist' parameter when
it's no longer needed

PR: 204952
Reported by: David Binderman <dcb314@hotmail.com>

5 years agoMFC r343586: Remove BIO_ORDERED flag from BIO_FLUSH sent by ZFS.
mav [Wed, 13 Feb 2019 00:39:28 +0000 (00:39 +0000)]
MFC r343586: Remove BIO_ORDERED flag from BIO_FLUSH sent by ZFS.

In all cases where ZFS sends BIO_FLUSH, it first waits for all related
writes to complete, so its BIO_FLUSH does not care about strict ordering.
Removal of one makes life much easier at least for NVMe driver, which
hardware has no concept of request ordering, relying completely on software.

5 years agoMFC r343582,r343588:Relax BIO_FLUSH ordering in da(4), respecting BIO_ORDERED.
mav [Wed, 13 Feb 2019 00:38:28 +0000 (00:38 +0000)]
MFC r343582,r343588:Relax BIO_FLUSH ordering in da(4), respecting BIO_ORDERED.

r212160 tightened this from always using MSG_SIMPLE_Q_TAG to always
MSG_ORDERED_Q_TAG.  Since it also marked all BIO_FLUSH requests with
BIO_ORDERED, this commit changes nothing immediately, but it returns
BIO_FLUSH callers ability to actually specify ordering they really
need, alike to other request types.

5 years agoMFC r343585: Only sort requests of types that have concept of offset.
mav [Wed, 13 Feb 2019 00:35:09 +0000 (00:35 +0000)]
MFC r343585: Only sort requests of types that have concept of offset.

Other types, such as BIO_FLUSH or BIO_ZONE, or especially new/unknown ones,
may imply some degree of ordering even if strict ordering is not requested
explicitly.

5 years agoMFC r342598:
ngie [Tue, 12 Feb 2019 23:37:20 +0000 (23:37 +0000)]
MFC r342598:

Remove legacy rc.d infrastructure references from rc(8)

Legacy rc.d scripts (.sh extension) have not been supported since
r193118. Remove the outdated references to the legacy format, as they
are no longer valid.

PR: 193936
Approved by: jtl (mentor)
Differential Revision: https://reviews.freebsd.org/D19157

5 years agoMFC r342946: Remove accessing remote node and domain objects
ram [Tue, 12 Feb 2019 17:05:59 +0000 (17:05 +0000)]
MFC r342946: Remove accessing remote node and domain objects
while processing cam actions.
  Issue:
    ocs_fc(4) driver panics. It's induced by setting the port_state
  sysctl to offline, then online, then offline, then online, and so
  forth and so on in rapid succession.

  Reason:
    While we set the port_state to online fc discovery will start and OS
  is enumerating the target discs by calling ocs_action(),  then set the
  port state to "offline" which deletes domain/sport/nodes.

    In ocs_action()->XPT_GET_TRAN_SETTINGS we are accessing the remote
  node which can be invalid to get the wwpn, wwnn and port.

  Fix:
    Removed accessing of remote node and domain in some ocs_action() cases.
    Populated the required values from ocs_fcport.
    This removes the dependency of node and domain structures while
  processing XPT_PATH_INQ and XPT_GET_TRAN_SETTINGS.
     We will invalidate the target entries after the device lost
  timeout(30 seconds).

Approved by:ken,mav

5 years agoFix PAE modules build on i386.
kib [Tue, 12 Feb 2019 16:56:10 +0000 (16:56 +0000)]
Fix PAE modules build on i386.

Reimplement PAE version of pte_load() by copying/pasting the
atomic_load_acq_64_i586() into it definition. pmap_kextract() is defined
as inline and uses pte_load() in its body, so the pte_load() should be
available when pmap.h is included. On stable/11, the atomic inlines are
not exposed to modules.

This is a direct commit to stable/11.

Reported by: dim
Sponsored by: The FreeBSD Foundation

5 years agoMFC 343548:
marck [Tue, 12 Feb 2019 14:03:39 +0000 (14:03 +0000)]
MFC 343548:

  Allow dashes as a valid character in UFS labels.

5 years agoMFC r343772, r343867
vmaffione [Tue, 12 Feb 2019 09:26:05 +0000 (09:26 +0000)]
MFC r343772, r343867

netmap: refactor logging macros and pipes

Changelist:
    - Replace ND, D and RD macros with nm_prdis, nm_prinf, nm_prerr
      and nm_prlim, to avoid possible naming conflicts.
    - Add netmap_krings_mode_commit() helper function and use that
      to reduce code duplication.
    - Refactor pipes control code to export some functions that
      can be reused by the veth driver (on Linux) and epair(4).
    - Add check to reject API requests with version less than 11.
    - Small code refactoring for the null adapter.

5 years agoMFC r343870:
avos [Tue, 12 Feb 2019 07:03:37 +0000 (07:03 +0000)]
MFC r343870:
ipcs(1): drop obsolete error checking

This code is unreachable since r77551.

PR: 201728

5 years agoMFC r342904:
ngie [Tue, 12 Feb 2019 03:13:10 +0000 (03:13 +0000)]
MFC r342904:

route(8): clarify -prefixlen description

Try to reword -prefixlen section to more clearly and accurately describe how
the -prefixlen modifier works.

While here, fix a word that igor considered a typo: aggregatable addresses is a
valid technical term per RFC-2374, however, it was superseded by the term
"aggregator" in RFC-3587.

Approved by: jtl (mentor)
Differential Revision: https://reviews.freebsd.org/D19156

5 years agoMFC r339343,r343444:
ngie [Tue, 12 Feb 2019 02:57:34 +0000 (02:57 +0000)]
MFC r339343,r343444:

r339343 (by allanjude):

Document that sendfile(2) can return ENOTCAPABLE

PR: 232207

r343444:

Document that `sendfile` will return an invalid value for `sbytes` if provided an invalid address

This is meant to clarify the fact that the system call will not fail
with -1/EFAULT, as one might expect, when reading the sendfile(2)
manpage today.

While here, pet the mandoc linter, when dealing with the section that
describes valid values for `flags`.

PR: 232210
Approved by: jtl (mentor)
Differential Revision: https://reviews.freebsd.org/D19150

5 years agoMFC r343562, r343563: Reimplement BIO_ORDERED handling in nvd(4).
mav [Tue, 12 Feb 2019 00:53:43 +0000 (00:53 +0000)]
MFC r343562, r343563: Reimplement BIO_ORDERED handling in nvd(4).

This fixes BIO_ORDERED semantics while also improving performance by:
 - sleeping also before BIO_ORDERED bio, as defined, not only after;
 - not queueing BIO_ORDERED bio to taskqueue if no other bios running;
 - waking up sleeping taskqueue explicitly rather then rely on polling.

On Samsung SSD 970 PRO this shows sync write latency, measured with
`diskinfo -wS`, reduction from ~2ms to ~1.1ms by not sleeping without
reason till next HZ tick.

On the same device ZFS pool with 8 ZVOLs synchronously writing 4KB blocks
shows ~950 IOPS instead of ~750 IOPS before.  I suspect ZFS does not need
BIO_ORDERED on BIO_FLUSH at all, but that will be next question.

5 years agoMFC r343520:
kp [Mon, 11 Feb 2019 19:08:03 +0000 (19:08 +0000)]
MFC r343520:

pfctl: Point users to net.pf.request_maxcount if large requests are rejected

The kernel will reject very large tables to avoid resource exhaustion
attacks. Some users run into this limit with legitimate table
configurations.

The error message in this case was not very clear:

  pf.conf:1: cannot define table nets: Invalid argument
  pfctl: Syntax error in config file: pf rules not loaded

If a table definition fails we now check the request_maxcount sysctl,
and if we've tried to create more than that point the user at
net.pf.request_maxcount:

  pf.conf:1: cannot define table nets: too many elements.
  Consider increasing net.pf.request_maxcount.
  pfctl: Syntax error in config file: pf rules not loaded

PR: 235076

5 years agoMFC r343921:
bcr [Mon, 11 Feb 2019 17:48:52 +0000 (17:48 +0000)]
MFC r343921:

Add an example to pw.8 about how to add an existing user to a group.

Instead of using pw to modify group membership, users often edit
/etc/group by hand, which is discouraged.  Provide an example of
adding a user to the wheel group, which is a common use case.
I'm using a different user here as in the previous example as that
deleted the user (although the examples don't necessarily have to
be followed in order).

Reviewed by: rgrimes,0mp
Approved by:    0mp
Differential Revision: https://reviews.freebsd.org/D19123

5 years agoMFC r336446: Implemented Device Lost Timer,
ram [Mon, 11 Feb 2019 16:28:04 +0000 (16:28 +0000)]
MFC r336446: Implemented Device Lost Timer,
which is used to give target device the time to recover before marking dead.

Issue: IO fails immediately after doing port-toggle.
Fix: Added LDT(Device Lost Timer)- we wait a specific period of time prior to telling the OS about lost device.

Approved by: ken, mav
Differential Revision: D16196

5 years agoMFC r343727: Use switch instead of chained if/else to improve readability.
mav [Mon, 11 Feb 2019 14:50:12 +0000 (14:50 +0000)]
MFC r343727: Use switch instead of chained if/else to improve readability.

Submitted by: Ryan Moeller <ryan@freqlabs.com>
Sponsored by: iXsystems, Inc.

5 years agoMFC r343728: Check element type before setting LEDs.
mav [Mon, 11 Feb 2019 14:49:10 +0000 (14:49 +0000)]
MFC r343728: Check element type before setting LEDs.

With r319610, sesutil started twiddling the bits of every SES device.
Not everything is a disk slot, there are also fan controllers, temperature
sensors, even power supplies, among other things controlled by SES.

Add a type check to make sure we are only operating on device slot and array
device slot elements.  Other type elements will be skipped, but it would be
simple to add additional cases for controlling the ident LEDs of other
element types (which are not necessarily the same bits).

Rather than doing raw bit manipulation of an unstructured byte array using
unnamed numeric constants, leverage existing code abstractions.

Submitted by:   Ryan Moeller <ryan@freqlabs.com>
Sponsored by:   iXsystems, Inc.

5 years agoMFC r343745, r343752: Add missed tunables/sysctls for some new vdev variables.
mav [Mon, 11 Feb 2019 14:47:26 +0000 (14:47 +0000)]
MFC r343745, r343752: Add missed tunables/sysctls for some new vdev variables.

While there, make few existing sysctls writeable, since there is no reason
not to.

5 years agoMFC r343815:
avos [Mon, 11 Feb 2019 00:31:58 +0000 (00:31 +0000)]
MFC r343815:
iwn(4): plug initialization path vs interrupt handler races

There are few places in interrupt handler where the driver
lock is dropped; ensure that device is still running before
processing remaining ring entries.

PR: 192641

5 years agoMFC r342910:
pfg [Sun, 10 Feb 2019 23:47:37 +0000 (23:47 +0000)]
MFC r342910:
grep(1) outputs NOT-matched lines with multi-byte characters

PR: 113343

5 years agoMFC r343470:
oshogbo [Sun, 10 Feb 2019 22:32:09 +0000 (22:32 +0000)]
MFC r343470:
  zfs: allow to change cache flush sysctl

  There is no reason for this variable to be tunable.
  This variable is used as a barrier in few places.

  Discussed with:       pjd
  MFC after:    2 weeks
  Sponsored by: Fudo Security

5 years agoMFC r343474:
avos [Sun, 10 Feb 2019 21:00:02 +0000 (21:00 +0000)]
MFC r343474:
Remove 2GHz channel list copies from wireless drivers.

Wrap ieee80211_add_channel_list_2ghz into another function
which supplies default (1-14) channel list to it and drop
its copies from drivers.

5 years agoMFC r343698, r343700:
avos [Sun, 10 Feb 2019 20:42:06 +0000 (20:42 +0000)]
MFC r343698, r343700:
ifconfig(8): display management / multicast wlan(4) rates properly

For 11n / 11ac we are still using non-11n rates for management and
multicast traffic by default; check 'MCS rate' bit to determine how
to print them correctly.

PR: 161035

5 years agoMFC r343837:
avos [Sun, 10 Feb 2019 20:25:45 +0000 (20:25 +0000)]
MFC r343837:
net80211(4): validate supplied roam:rate values from ifconfig(8)

5 years agoMFC r343724:
kib [Sun, 10 Feb 2019 05:42:01 +0000 (05:42 +0000)]
MFC r343724:
Do not call PHOLD() while owning the allproc_lock sx.

5 years agoMFC r342592:
dim [Sat, 9 Feb 2019 12:01:10 +0000 (12:01 +0000)]
MFC r342592:

Pull in r342397 from upstream llvm trunk (by Amara Emerson):

  Revert "Revert r342183 "[DAGCombine] Fix crash when store merging
  created an extract_subvector with invalid index.""

  Fixed the assertion failure.

  Differential Revision: https://reviews.llvm.org/D51831

This fixes 'Assertion failed: ((VT.getVectorNumElements() +
N2C->getZExtValue() <= N1.getValueType().getVectorNumElements()) &&
"Extract subvector overflow!"), function getNode' when building the
multimedia/aom port (with AVX2 enabled).

Reported by: jbeich
PR: 234480

5 years agoMFC r343673: Fix integer math overflow in UMA hash_alloc().
mav [Sat, 9 Feb 2019 02:10:03 +0000 (02:10 +0000)]
MFC r343673: Fix integer math overflow in UMA hash_alloc().

512GB of ZFS ABD ARC means abd_chunk zone of 128M 4KB items.  To manage
them UMA tries to allocate 2GB hash table, which size does not fit into
the int variable, causing later allocation failure, which makes ARC shrink
back below the 512GB, not letting it to use more RAM.  With this change I
easily reached >700GB ARC size on 768GB RAM machine.

Sponsored by: iXsystems, Inc.

5 years agoMFC r343604:
avos [Fri, 8 Feb 2019 14:27:25 +0000 (14:27 +0000)]
MFC r343604:
bwn(4): reuse ieee80211_tx_complete function

5 years agoMFC r343603:
avos [Fri, 8 Feb 2019 13:57:28 +0000 (13:57 +0000)]
MFC r343603:
ipw(4): reuse ieee80211_tx_complete function

This should partially fix 'netstat -b -I wlan0' output

5 years agoMFC r343572:
hselasky [Fri, 8 Feb 2019 10:27:02 +0000 (10:27 +0000)]
MFC r343572:
Add support for Audio Sink and Audio Source profiles to sdpd(8).

This allows user-space programs like virtual_oss(8) to act
as a Bluetooth speaker device.

Sponsored by: Mellanox Technologies

5 years agoMFC r343683:
avos [Fri, 8 Feb 2019 04:48:12 +0000 (04:48 +0000)]
MFC r343683:
Do not acquire IEEE80211_LOCK twice in cac_timeout(); reuse
locked function instead.

It is externally visible since r257065.

5 years agoMFC r343808:
kib [Fri, 8 Feb 2019 03:29:17 +0000 (03:29 +0000)]
MFC r343808:
Remove pointless initial value for i386 vm.pmap.pat_works sysctl definition.

5 years agoMFC r337272:
bdrewery [Thu, 7 Feb 2019 23:55:11 +0000 (23:55 +0000)]
MFC r337272:

  Fix some filemon path logging issues.

5 years agoMFC r343633:
bdrewery [Thu, 7 Feb 2019 21:22:01 +0000 (21:22 +0000)]
MFC r343633:

  Shar files may be seen as binary by grep.

5 years agoMFC r343689
vmaffione [Thu, 7 Feb 2019 10:44:53 +0000 (10:44 +0000)]
MFC r343689

netmap: upgrade sync-kloop support

Add SYNC_KLOOP_MODE option, and add support for direct mode, where application
executes the TXSYNC and RXSYNC in the context of the ioeventfd wake up callback.

5 years agoMFC r343748:
dim [Thu, 7 Feb 2019 06:55:26 +0000 (06:55 +0000)]
MFC r343748:

Use NLDT to get number of LDTs on i386

Compiling a GENERIC kernel for i386 with clang 8.0 results in the
following warning:

/usr/src/sys/i386/i386/sys_machdep.c:542:40: error: 'sizeof ((ldt))' will return the size of the pointer, not the array itself [-Werror,-Wsizeof-pointer-div]
        nldt = pldt != NULL ? pldt->ldt_len : nitems(ldt);
                                              ^~~~~~~~~~~
/usr/src/sys/sys/param.h:299:32: note: expanded from macro 'nitems'
#define nitems(x)       (sizeof((x)) / sizeof((x)[0]))
                         ~~~~~~~~~~~ ^

Indeed, 'ldt' is declared as 'union descriptor *', so nitems() is not
the right way to determine the number of LDTs.  Instead, the NLDT define
from sys/x86/include/segments.h should be used.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D19074

5 years agoMFC r343757:
kib [Thu, 7 Feb 2019 01:55:11 +0000 (01:55 +0000)]
MFC r343757:
Update CPUID bits definitions and CPU identification based on changes
in SDM rev. 069.

5 years agoMFC r343549
vmaffione [Wed, 6 Feb 2019 10:00:40 +0000 (10:00 +0000)]
MFC r343549

netmap: add notifications on kloop stop

On sync-kloop stop, send a wake-up signal to the kloop, so that
waiting for the timeout is not needed.
Also, improve logging in netmap_freebsd.c.

5 years agoMFC r343346
vmaffione [Wed, 6 Feb 2019 09:49:42 +0000 (09:49 +0000)]
MFC r343346

netmap: improvements to the netmap kloop (CSB mode)

Changelist:
    - Add the proper memory barriers in the kloop ring processing
      functions.
    - Fix memory barriers usage in the user helpers (nm_sync_kloop_appl_write,
      nm_sync_kloop_appl_read).
    - Fix nm_kr_txempty() helper to look at rhead rather than rcur. This
      is important since the kloop can read a value of rcur which is ahead
      of the value of rhead (see explanation in nm_sync_kloop_appl_write)
    - Remove obsolete ptnetmap_guest_write_kring_csb() and
      ptnet_guest_read_kring_csb().
    - Prepare in advance the arguments for netmap_sync_kloop_[tr]x_ring(),
      to make the kloop faster.
    - Provide kernel and user implementation for nm_ldld_barrier() and
      nm_ldst_barrier()

5 years agoMFC r343344
vmaffione [Wed, 6 Feb 2019 09:38:44 +0000 (09:38 +0000)]
MFC r343344

netmap: fix knote() argument to match the mutex state

The nm_os_selwakeup function needs to call knote() to wake up kqueue(9)
users. However, this function can be called from different code paths,
with different lock requirements.
This patch fixes the knote() call argument to match the relavant lock state.
Also, comments have been updated to reflect current code.

PR:     https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=219846
Reported by:    Aleksandr Fedorov <aleksandr.fedorov@itglobal.com>
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D18876

5 years agoMFC r343682:
avos [Wed, 6 Feb 2019 02:35:56 +0000 (02:35 +0000)]
MFC r343682:
sys/dev/wtap: Check return value from malloc(..., M_NOWAIT) and
drop unneeded cast.

5 years agoMFC r343681:
avos [Wed, 6 Feb 2019 02:18:11 +0000 (02:18 +0000)]
MFC r343681:
run(4): fix allocated memory type for ieee80211_node(4)

PR: 177366

5 years agoMFC r343574:
avos [Wed, 6 Feb 2019 02:06:00 +0000 (02:06 +0000)]
MFC r343574:
Fix compilation with 'option NDISAPI + device ndis' and
without 'device pccard' in the kernel config file.

PR: 171532
Reported by: Robert Bonomi <bonomi@host128.r-bonomi.com>

5 years agoMFC r343697:
avos [Wed, 6 Feb 2019 01:53:01 +0000 (01:53 +0000)]
MFC r343697:
net80211(4): fix rate check when 'roaming' ifconfig(8) option is set to 'auto'

Do not try to clear 'basic rate' bit from roamRate; it cannot be here and,
actually, this operation clears 'MCS rate' bit instead, breaking comparison
for 11n / 11ac modes.

5 years agoMFC r343684:
avos [Wed, 6 Feb 2019 01:47:22 +0000 (01:47 +0000)]
MFC r343684:
Drop unused M_80211_COM malloc(9) type.

It is not used since r287197.

5 years agoMFC r343542:
avos [Wed, 6 Feb 2019 01:42:26 +0000 (01:42 +0000)]
MFC r343542:
upgt(4): unbreak build with UPGT_DEBUG

5 years agoDocument SA-19:01 and SA-19:02.
gjb [Tue, 5 Feb 2019 22:08:49 +0000 (22:08 +0000)]
Document SA-19:01 and SA-19:02.

Sponsored by: The FreeBSD Foundation

5 years agoMFC r343784:
markj [Tue, 5 Feb 2019 17:57:30 +0000 (17:57 +0000)]
MFC r343784:
Avoid leaking fp references when truncating SCM_RIGHTS control messages.

Approved by: so
Security: CVE-2019-5596

5 years agoMFC r343780:
kib [Tue, 5 Feb 2019 17:54:02 +0000 (17:54 +0000)]
MFC r343780:
amd64: clear callee-preserved registers on syscall exit.

Approved by: so
Security: CVE-2019-5595

5 years agonetmap: small cleanup on em, lem, igb, ixgbe
vmaffione [Tue, 5 Feb 2019 10:33:22 +0000 (10:33 +0000)]
netmap: small cleanup on em, lem, igb, ixgbe

Replace D, ND and RD macros with the corresponding nm_pr* ones.

5 years agoMFC r343541:
avos [Tue, 5 Feb 2019 03:01:10 +0000 (03:01 +0000)]
MFC r343541:
Drop some unneeded includes from wireless USB drivers.

5 years agoMFC r342815:
cy [Tue, 5 Feb 2019 02:33:57 +0000 (02:33 +0000)]
MFC r342815:

Remove ipsd (IP Scan Detetor). It is unused and to my knowledge has
never been used on any platform that ipfilter has been on. However
it looks like it could be a useful utility, therefore there are plans
to make it a port one day. It lacks a man page as well.

5 years agoMFC: 332990,337892,343546
bapt [Mon, 4 Feb 2019 08:37:16 +0000 (08:37 +0000)]
MFC: 332990,337892,343546

Update pci_vendors to 2019.01.29