Commit Graph

230437 Commits

Author SHA1 Message Date
Kyle Evans
ce4a5da5a9 stand/lua: Restore environment upon config reload
This restores environment to whatever defaults we had coming into lualoader.
2018-02-19 17:01:21 +00:00
Kyle Evans
df8a9d464a stand/lua: Track env changes that come in via loader.conf(5)
This will be used when boot environment support lands to make a good-faith
effort to apply any new loader.conf(5) environment settings atop the default
configuration that we started with.
2018-02-19 16:59:28 +00:00
Kyle Evans
fd2b19b3ee stand/lua: Re-wrap menu.lua now that I've added indentation... 2018-02-19 16:42:06 +00:00
Kyle Evans
303253e55c stand/lua: Swap single-/multi- user boot entries as needed 2018-02-19 16:36:29 +00:00
Kyle Evans
2e716cec23 stand/lua: Call menu_entries if it's a function
If we've fetched menu.entries and it turns out it's a function, call it to
get the actual menu entries.

This will be used to swap multi-/single- user boot options if we're booting
single user by default (boot_single="YES" in loader.conf(5)). It can also be
used fairly easily for other non-standard situations.
2018-02-19 16:35:46 +00:00
Kyle Evans
e07fc39c14 stand/lua: Add core.isSingleUserBoot 2018-02-19 16:34:23 +00:00
Hans Petter Selasky
e44fa94c09 Implement list_safe_reset_next() function macro in the LinuxKPI.
MFC after:	1 week
Submitted by:	Johannes Lundberg <johalun0@gmail.com>
Sponsored by:	Mellanox Technologies
Sponsored by:	Limelight Networks
2018-02-19 16:31:19 +00:00
Kyle Evans
d87577468f stand/lua: Store menu entries in an "entries" table
Instead of directly listing them in menu.welcome and menu.boot_options,
store them at menu.welcome.entries and welcome.boot_options.entries.

This will come into play later when we need to re-order the welcome menu if
boot_single is specified.
2018-02-19 16:25:43 +00:00
Kyle Evans
280e990ba7 stand/lua: Remove some unused local declarations
Menus are actually defined as entries in the 'menu' table. These local
declarations have not been used in the history of our in-tree lua scripts,
so give them the boot.
2018-02-19 15:49:27 +00:00
Nathan Whitehorn
65184f89b6 Set internal error returns for OF_peer(), OF_child(), and OF_parent() to
zero, matching the IEEE 1275 standard. Since these internal error paths
have never, to my knowledge, been taken, behavior is unchanged.

Reported by:	gonzo
MFC after:	2 weeks
2018-02-19 15:49:14 +00:00
Kyle Evans
57099121d5 stand/lua: Menu style.lua(9) nits 2018-02-19 15:47:09 +00:00
Kyle Evans
b140d14b02 stand/lua: Rename bootserial for clarity 2018-02-19 15:42:20 +00:00
Kyle Evans
fa4a2394a7 stand/lua: Defer kernel/module loading until boot or menu escape
Loading the kernel and modules can be really slow. Loading before the menu
draws and every time one changes kernel/boot environment is even more
painful.

Defer loading until we either boot, auto-boot, or escape to loader prompt.
We still need to deal with configuration changes as the boot environment
changes, but this is generally much quicker.

This commit strips all ELF loading out of config.load/config.reload so that
these are purely for configuration. config.loadelf has been created to deal
with kernel/module loads. Unloading logic has been ripped out, as we won't
need to deal with it in the menu anymore.

Discussed in part with:	allanjude
2018-02-19 14:21:56 +00:00
Andrey V. Elsukov
15bf717a93 Remove unused variables and sysctl declaration.
MFC after:	1 week
2018-02-19 12:20:51 +00:00
Andrey V. Elsukov
6ca39da354 Check packet length to do not make out of bounds access. Also save ah_nxt
value to use it later, since ah pointer can become invalid.

Reported by:	Maxime Villard <max at m00nbsd dot net>
MFC after:	5 days
2018-02-19 11:14:38 +00:00
Andriy Gapon
8cebd0e419 relax an assert in zfsctl_snapdir_lookup to match r323578
Since r323578 we may remove the last reference to a covered vnode with
vrele() instead of vput().  So, v_usecount may be decremented before
the vnode is locked and zfsctl_snapdir_lookup may "catch" the vnode
with v_usecount of zero and v_holdcnt of one.

PR:		225795
Reported by:	asomers
MFC after:	1 week
2018-02-19 08:55:22 +00:00
Hans Petter Selasky
0f839f3a6d When stepping the radix tree in the LinuxKPI make sure we
clear the least significant bits, so that no entries are
skipped.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2018-02-19 06:11:58 +00:00
Xin LI
74709ed038 MFV r329552: less v530.
MFC after:	2 weeks
2018-02-19 05:10:22 +00:00
Xin LI
b04073e3ae Vendor import of less v530. 2018-02-19 04:47:31 +00:00
Kyle Evans
27dd7ddf99 stand/lua: reload previously loaded kernel at config-load/reload
r329550 introduced config.kernel_loaded. config.load() doesn't provide a
means of overriding the kernel to load, but that likely isn't necessary as
it will not be a common case. When loading the kernel, just attempt to load
the kernel previously loaded and specified in config.kernel_loaded.

If we haven't loaded a kernel yet, config.kernel_loaded will be unset/nil
and the "default"/first kernel found will be loaded. If we've loaded a
kernel, we'll try to load that same kernel again and fallback to the default
kernel if we need to.

This in also in support of upcoming boot environment support.
2018-02-19 03:59:26 +00:00
Kyle Evans
d45913016b stand/lua: Store the loaded kernel as config.kernel_loaded
'nil' means the 'first kernel found in module_path', which is the same
interpretation as passing 'nil' to loadkernel.

Otherwise, it denotes the name of a kernel that we've successfully loaded.
When reloaded later, we will still need to do the full search again to
locate the actual kernel in case things have changed, so just the name is
good enough.

This is in support of upcoming boot environment support. vfs.root.mountfrom
and currdev will be changed, then we will reload configuration and attempt
to reload the currently chosen kernel unless we shouldn't.
2018-02-19 03:52:02 +00:00
Kyle Evans
40bbffdb11 stand/lua: Clear the screen before prompting for passwords
In the worst case scenario, we have no passwords to prompt for and we end up
just clearing the screen twice before we draw the menu or proceed with boot.

In the best case scenario, we don't try drawing password prompts amidst a
bunch of kernel/module loading.
2018-02-19 02:09:10 +00:00
Kyle Evans
ddb76e073e stand/lua: Addres style.lua(9) concern 2018-02-19 02:01:49 +00:00
Kyle Evans
4a4fb4f8d6 stand/lua: Allow menu items to be conditionally (in)visible
This will be used to conditionally show/hide the boot environment menu.
2018-02-19 01:59:41 +00:00
Ian Lepore
eb69d1f144 Build at45d and mx25l SPI flash drivers as modules. 2018-02-19 01:49:19 +00:00
Ian Lepore
63cdf4affb Add ofw_bus_if.h to SRCS. 2018-02-19 01:39:02 +00:00
Ian Lepore
2aa5d9c4c8 Add modules/spi as a gathering point for SPI-related modules, analagous to
modules/i2c for i2c/iicbus modules.  Build spibus as a module.
2018-02-19 01:32:27 +00:00
Kyle Evans
037f68a994 Create style.lua(9)
This covers the lua style guidelines we've generally agreed on so far. It
will be revised as work continues and we run into more scenarios that need
specified.

Discussed with:	cem, jilles
Differential Revision:	https://reviews.freebsd.org/D14423
2018-02-19 01:25:52 +00:00
Mateusz Guzik
2ca66c1ef5 Fix process exit vs reap race introduced in r329449
The race manifested itself mostly in terms of crashes with "spin lock
held too long".

Relevant parts of respective code paths:

exit:				reap:
PROC_LOCK(p);
PROC_SLOCK(p);
p->p_state == PRS_ZOMBIE
PROC_UNLOCK(p);
				PROC_LOCK(p);
/* exit work */
				if (p->p_state == PRS_ZOMBIE) /* true */
					proc_reap()
					free proc
/* more exit work */
PROC_SUNLOCK(p);

Thus a still exiting process is reaped.

Prior to the change the zombie check was followed by slock/sunlock trip
which prevented the problem.

Even code prior to this commit has a bug: the proc is still accessed for
statistic collection purposes. However, the severity is rather small and
the bug may be fixed in a future commit.

Reported by:	many
Tested by:	allanjude
2018-02-19 00:54:08 +00:00
Ian Lepore
a7e31772e7 Build ofw_iicbus as a module if OPT_FDT is defined. 2018-02-19 00:47:03 +00:00
Mateusz Guzik
d257698833 mtx: add mtx_spin_wait_unlocked
The primitive can be used to wait for the lock to be released. Intended
usage is for locks in structures which are about to be freed.

The benefit is the avoided interrupt enable/disable trip + atomic op to
grab the lock and shorter wait if the lock is held (since there is no
worry someone will contend on the lock, re-reads can be more aggressive).

Briefly discussed with:	 kib
2018-02-19 00:38:14 +00:00
Ian Lepore
747de77cd5 Provide public declarations for ofw_spibus_driver and ofw_spibus_devclass
so other drivers can refer to them in DRIVER_MODULE() decls.
2018-02-18 23:35:23 +00:00
Warner Losh
bbd4852a9b Print more info for -v runs and temp hack for usb vs uhub
Despite best efforts to regularize, there's a few tables in the system
that still report they are for bus usb when they are really for bus
uhub (where usb devices attach). Add a temporary workaround for this
until these places have been eliminated (likely my fault).

Second, when running verbose, describe what we're doing when
searching. This output can be quite long, but says exactly what's
going on (this output is to stdout, so it's useless for scripting).
2018-02-18 23:16:16 +00:00
Ian Lepore
dc027dc6e2 Provide a public function to acquire a gpio pin by giving the property name
and index.  A private function to do exactly that already existed, so this
renames gpio_pin_get_by_ofw_impl() to gpio_pin_get_by_ofw_propidx() and
provides a declaration for it in a public header.

Previously there were functions to get a pin by property name (assuming
there would only be one pin defined for the name), or by index (asuming
the property has the standard name "gpios").  It turns out there are
devicetree bindings that describe properties with names other than "gpios"
which can describe multiple pins.  Hence the need to retrieve the Nth item
from a named property.
2018-02-18 23:08:43 +00:00
Ian Lepore
5e2d748931 Add the MODULE_DEPEND()s needed so that the kernel linker can resolve all
the symbols at load time when iicbus is not compiled into the kernel.
2018-02-18 23:01:33 +00:00
Ian Lepore
adddeaadc4 Add iic_recover_bus.c, now part of iicbus. This should have been added
as part of r320463.
2018-02-18 22:57:04 +00:00
Ian Lepore
c99321621c Arrange SRCS= as 1 file per line, alphabetical, so it's easier to maintain.
Whitespace only, no functional changes.
2018-02-18 22:54:19 +00:00
Mateusz Guzik
7beb60820f exit: get rid of PROC_SLOCK when checking a process to report, take #2
The suspension counter needs synchronisation through slock, but we don't
need it to check if inspecting the counter is necessary to begin with.
In the common case it is not, thus avoid the lock if possible.

Reviewed by:	kib
Tested by:	pho
2018-02-18 21:07:15 +00:00
Ian Lepore
af85a3d172 Give the imx_i2c driver its own name, set up its relationship to ofw_iicbus.
Previously it called itself 'iichb' to link up with the EARLY_DRIVER_MODULE
declaration in ofw_iicbus.c.
2018-02-18 20:08:35 +00:00
Mariusz Zaborski
965cd21173 Fix broken assertion in r329520.
Reported by:	pho@ lwhsu@
2018-02-18 20:04:39 +00:00
Ian Lepore
c5fe9c7b20 Allow i2c hardware drivers to declare their own relationships to ofw_iicbus
rather than relying on a set of canned EARLY_DRIVER_MODULE() statements in
the ofw_iicbus source.  This means hw drivers will no longer be required to
use one of a few predefined driver names.  They will also now be able to
decide themselves if they want to use DRIVER_MODULE or EARLY_DRIVER_MODULE
and to set which pass to attach on for early modules.

Mainly, this adds extern declarations for the driver and devclass variables.
It also renames ofwiicbus_devclass to ofw_iicbus_devclass to be consistant
with the way we use ofw_ prefixes on this stuff.
2018-02-18 19:33:28 +00:00
Brooks Davis
7a095112b2 Correct/improve the descriptions if kern.ipc.(shmsegs,sema,msqids).
The description of kern.ipc.shmsegs was wrong since 2005.  I updated the
others (which were more correct) to match.

PR:		225933
Reviewed by:	cem
MFC after:	3 days
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14391
2018-02-18 19:19:36 +00:00
Hans Petter Selasky
8f294983e9 Optimise xchg() to use atomic_swap_32() and atomic_swap_64().
Suggested by:	kib@
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2018-02-18 18:46:56 +00:00
Hans Petter Selasky
644680491e Fix implementation of xchg() function macro in the LinuxKPI.
The exchange operation must be atomic.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2018-02-18 17:37:23 +00:00
Scott Long
f0779b0452 Improve command lifecycle debugging and detection of problems.
Sponsored by:	Netflix
2018-02-18 16:41:34 +00:00
Mark Johnston
2fb9a51077 Don't include DMAR map entry zone items in kernel dumps.
Such items may be allocated in the I/O path used by the dumper,
potentially causing the dump to fail. Since there is some precedent
in the DMAR driver for avoiding this problem using _NODUMP, apply
this workaround to the zone as well.

Reported and tested by:	mmacy
Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D14422
2018-02-18 16:03:50 +00:00
Mariusz Zaborski
20641651ec Use the fdeget_locked function instead of the fget_locked in the
sys_capability.

Reviewed by:	pjd@ (earlier version)
Discussed with:	mjg@
2018-02-18 15:27:24 +00:00
Hans Petter Selasky
ead15282ae Implement support for radix_tree_for_each_slot() and radix_tree_exception()
in the LinuxKPI and use unsigned long type for the radix tree index.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2018-02-18 12:54:21 +00:00
Emmanuel Vadot
ff727b9a1d efi: Do not pad the efi devpath structure
This solve problem when booting with efi on armv7
Reviewed by:	imp, tsoome
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D14415
2018-02-18 11:17:39 +00:00
Hans Petter Selasky
78d7441913 Implement the KMEM_CACHE() function macro in the LinuxKPI.
MFC after:	1 week
Submitted by:	Johannes Lundberg <johalun0@gmail.com>
Sponsored by:	Mellanox Technologies
Sponsored by:	Limelight Networks
2018-02-18 09:52:30 +00:00