]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoloader: cstyle cleanup of libsa/lseek.c
Toomas Soome [Sun, 1 Aug 2021 07:07:32 +0000 (10:07 +0300)]
loader: cstyle cleanup of libsa/lseek.c

Clean up lseek.c, no functional changes intended. This is pre-patch
for open file list rewrite.

MFC after: 1 week

2 years agoloader.conf(5): mention "efi" option for "console" parameter
Li-Wen Hsu [Sat, 31 Jul 2021 22:41:49 +0000 (06:41 +0800)]
loader.conf(5): mention "efi" option for "console" parameter

PR: 213467
Reviewed by: imp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D31368

2 years agoawk: use awkgram.tab.h consistently
Warner Losh [Sat, 31 Jul 2021 22:17:44 +0000 (16:17 -0600)]
awk: use awkgram.tab.h consistently

yacc makes awkgram.h. However, one true awk includes awkgram.tab.h, so
we link to for the builds. Make sure that we consistently link to it.
Also, restore the awkgram.tab.h dependency to maketab. It should not
have been deleted, despite apparently making meta build on stable/12
work. The important missing arc was proctab.c's dependence on
awkgram.tab.h.

MFC After: 1 day (build breakage)
Fixes: c50c8502cb629571f35089690d6e9a9bc4d60813
Sponsored by: Netflix

2 years agoLinuxKPI: fix bug in le32p_replace_bits()
Bjoern A. Zeeb [Thu, 29 Jul 2021 21:27:21 +0000 (21:27 +0000)]
LinuxKPI: fix bug in le32p_replace_bits()

Fix a bug that slipped in in 90707c4e44de03ea36be183ef2226601c66169cb
using the correct field in le32p_replace_bits().

MFC after: 3 days
Reviewed by: hselasky
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31352

2 years agoawk: Fix dependencies
Warner Losh [Sat, 31 Jul 2021 21:41:29 +0000 (15:41 -0600)]
awk: Fix dependencies

proctab.c is generated from awktab.h, so needs to depend on it.
maketab does not depend on awktab.h, and gets the maketab.c dependency
automatically, so remove them both.

Normally, these don't matter. However, for a meta build, they can cause
us to build maketab twice (once host, once for target) resulting in a
binary that can't run on the host due to proctab.c racing maketab in
parallel legs. In stable/12, this was a reliably lost race, while in
main I've been unable to trigger the race at all (maybe due to dirdep
changes making main more robust).

MFC After: 1 day (build breakage)
Reported by: kp
Sponsored by: Netflix

2 years agoigb: clean up igb_txrx comments
Kevin Bowling [Sat, 31 Jul 2021 15:04:25 +0000 (08:04 -0700)]
igb: clean up igb_txrx comments

Reviewed by: grehan
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D31227

2 years agoigc: sync igc_txrx with igb(4)
Kevin Bowling [Sat, 31 Jul 2021 15:00:16 +0000 (08:00 -0700)]
igc: sync igc_txrx with igb(4)

Reviewed by: grehan
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31227

2 years agoAdd pmap_vm_page_alloc_check()
Konstantin Belousov [Sat, 10 Jul 2021 19:53:41 +0000 (22:53 +0300)]
Add pmap_vm_page_alloc_check()

which is the place to put MD asserts about allocated pages.

On amd64, verify that allocated page does not belong to the kernel
(text, data) or early allocated pages.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31121

2 years agoamd64: do not assume that kernel is loaded at 2M physical
Konstantin Belousov [Sat, 10 Jul 2021 19:48:02 +0000 (22:48 +0300)]
amd64: do not assume that kernel is loaded at 2M physical

Allow any 2M aligned contiguous location below 4G for the staging
area location.  It should still be mapped by loader at KERNBASE.

The assumption kernel makes about loader->kernel handoff with regard to
the MMU programming are explicitly listed at the beginning of hammer_time(),
where kernphys is calculated.  Now kernphys is the variable instead of
symbol designating the physical address.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31121

2 years agoBump the FreeBSD version after making FPU sections thread-safe in the LinuxKPI.
Hans Petter Selasky [Sat, 31 Jul 2021 13:40:35 +0000 (15:40 +0200)]
Bump the FreeBSD version after making FPU sections thread-safe in the LinuxKPI.

Differential Revision: https://reviews.freebsd.org/D29921
MFC after: 1 week
Sponsored by: NVIDIA Networking

2 years agoLinuxKPI: Make FPU sections thread-safe and use the NOCTX flag.
Hans Petter Selasky [Sat, 31 Jul 2021 13:32:52 +0000 (15:32 +0200)]
LinuxKPI: Make FPU sections thread-safe and use the NOCTX flag.

Reviewed by: kib
Submitted by: greg@unrelenting.technology
Differential Revision: https://reviews.freebsd.org/D29921
MFC after: 1 week
Sponsored by: NVIDIA Networking

2 years agoawk: Document deprecated behavior of hex constants and locales.
Warner Losh [Sat, 31 Jul 2021 05:31:00 +0000 (23:31 -0600)]
awk: Document deprecated behavior of hex constants and locales.

FreeBSD will convert "0x12" from hex and print it as 18. Other awks will
convert it to 0. This extension has been removed upstream, and will be
removed in FreeBSD 14.0.

FreeBSD used to set the locale on startup, and make the ranges use that
locale. This lead to weird results like "[A-Z]" matching lower case
characters in some locales. This bug has been fixed.

MFC After: 3 days
Sponsored by: Netflix

2 years agoawk: Flag -Ft as deprecated behavior
Warner Losh [Sat, 31 Jul 2021 05:19:58 +0000 (23:19 -0600)]
awk: Flag -Ft as deprecated behavior

Upstream is poised to deprecate the -Ft wart in one true awk. None of
the other awks do this, and the gawk maintainer says that he's had no
requests for it in gawk in 30 years maintaining it. github can find a
few instances of it in the wild. As such, warn that it's deprecated and
will go away in the future.

MFC After: 3 days
Sponsored by: Netflix

2 years agoacpica: Import ACPICA 20210730
Jung-uk Kim [Sat, 31 Jul 2021 00:05:50 +0000 (20:05 -0400)]
acpica: Import ACPICA 20210730

(cherry picked from commit 34cfdff1f386b2d7bf0a8ea873acf604753991e6)

2 years agoclock_gettime: Add Linux aliases for CLOCK_*
Warner Losh [Fri, 30 Jul 2021 23:11:43 +0000 (17:11 -0600)]
clock_gettime: Add Linux aliases for CLOCK_*

Linux standardized what we call CLOCK_{REALTIME,MONOTONIC}_FAST as
CLOCK_{REALTIME,MONOTONIC}_COARSE. In addition, Linux spells
CLOCK_UPTIME as CLOCK_BOOTTIME.

Add aliases to time.h and document these new aliases in
clock_gettime(2).

Reviewed by: vangyzen, kib (prior), dchagin (prior)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D30988

2 years agotime.h: reduce CLOCK_ namespace pollution, move to _clock_id.h
Warner Losh [Fri, 30 Jul 2021 23:10:56 +0000 (17:10 -0600)]
time.h: reduce CLOCK_ namespace pollution, move to _clock_id.h

Attempt to comply with the strict namespace pollution requirements of
_POSIX_C_SOURCE. Add guards to limit visitbility of CLOCK_ and TIMER_
defines as appropriate. Only define the CLOCK_ variables relevant to the
specific standards. Move all the sharing to sys/_clock_id.h and make
time.h and sys/time.h both include that rather than copy due to the
now large number of clocks and compat defines.

Please note: The old time.h previously used these newer dates:
CLOCK_REALTIME 199506
CLOCK_MONOTONIC 200112
CLOCK_THREAD_CPUTIME_ID 200112
CLOCK_PROCESS_CPUTIME_ID 200112

but glibc defines all of these for 199309. glibc uses this date for all
these values, however, only CLOCK_REALTIME was in IEEE 1003.1b. Add a
comment about this to document it. A large number of programs and
libraries assume that these will be defined for _POSIX_C_SOURCE =
199309.

In addition, leak CLOCK_UPTIME_FAST for the pocl package until it can be
updated to use a simple CLOCK_MONOTONIC.

Reviewed by: kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31056

2 years agoRELNOTES: Put the old descripiton back
Warner Losh [Fri, 30 Jul 2021 23:07:52 +0000 (17:07 -0600)]
RELNOTES: Put the old descripiton back

After looking at the RELNOTES files on the stable branches, restore the
old description and update the file to match the format it's supposed to
have.

Sponsored by: Netflix

2 years agonanobsd: adopt dhcpd to latest conventions
Warner Losh [Fri, 30 Jul 2021 22:55:43 +0000 (16:55 -0600)]
nanobsd: adopt dhcpd to latest conventions

Adopt the dhcpd build to use nanobsd-build top level directory that
other nanobsd builds are using.

Sponsored by: Netflix

2 years agocxgbei: Round up the maximum PDU data length by the MSS for TXDATAPLEN_MAX.
John Baldwin [Thu, 29 Jul 2021 21:17:45 +0000 (14:17 -0700)]
cxgbei: Round up the maximum PDU data length by the MSS for TXDATAPLEN_MAX.

Recent firmware versions round down the value passed here by the MSS
and subsequently mishandle transmitted PDUs larger than the rounded
down value.

Reported by: Jithesh Arakkan @ Chelsio
Sponsored by: Chelsio Communications

2 years agoUPDATING: fix incorrect hash
Kristof Provost [Fri, 30 Jul 2021 18:00:47 +0000 (20:00 +0200)]
UPDATING: fix incorrect hash

Pointed out by: lwhsu

2 years agobus: Convert to the new interceptor scheme
Mark Johnston [Fri, 30 Jul 2021 19:15:27 +0000 (15:15 -0400)]
bus: Convert to the new interceptor scheme

This was missed in commit a90d053b8422.

Fixes: a90d053b8422
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

2 years agoinet6_option_space is deprecated, refer to inet6_opt_init instead
Tom Jones [Fri, 30 Jul 2021 13:23:39 +0000 (14:23 +0100)]
inet6_option_space is deprecated, refer to inet6_opt_init instead

Reviewed by: bz, hrs
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D26273

2 years agoUPDATING: Document the removal of DIOCGETSTATESNV
Kristof Provost [Wed, 14 Jul 2021 13:51:36 +0000 (15:51 +0200)]
UPDATING: Document the removal of DIOCGETSTATESNV

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agopf: remove DIOCGETSTATESNV
Kristof Provost [Tue, 6 Jul 2021 11:13:24 +0000 (13:13 +0200)]
pf: remove DIOCGETSTATESNV

While nvlists are very useful in maximising flexibility for future
extensions their performance is simply unacceptably bad for the
getstates feature, where we can easily want to export a million states
or more.

The DIOCGETSTATESNV call has been MFCd, but has not hit a release on any
branch, so we can still remove it everywhere.

Reviewed by: mjg
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31099

2 years agoipmi(4): Add more watchdog error checks.
Alexander Motin [Fri, 30 Jul 2021 03:39:04 +0000 (23:39 -0400)]
ipmi(4): Add more watchdog error checks.

Add request submission status checks before checking req->ir_compcode,
otherwise it may be zero just because of initialization.

Add checks for req->ir_compcode errors in ipmi_reset_watchdog() and
ipmi_set_watchdog().  In first case explicitly check for 0x80, which
means timer was not previously set, that I found happening after BMC
cold reset.  This change makes watchdog timer to recover instead of
permanently ignoring reset errors after BMC reset or upgraded.

MFC after: 2 weeks
Sponsored by:   iXsystems, Inc.

2 years agocoretemp(4): Switch to smp_rendezvous_cpus().
Alexander Motin [Fri, 30 Jul 2021 03:16:22 +0000 (23:16 -0400)]
coretemp(4): Switch to smp_rendezvous_cpus().

Use of smp_rendezvous_cpus() instead of sched_bind() allows to not
block indefinitely if target CPU is running some thread with higher
priority, while all we need is single rdmsr/wrmsr instruction call.
I guess it should also be much cheaper than full thread migration.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

2 years agoAdd interceptors for atomic operations on userspace memory
Mark Johnston [Fri, 30 Jul 2021 01:05:03 +0000 (21:05 -0400)]
Add interceptors for atomic operations on userspace memory

Implement them for KASAN.  KCSAN interceptors are left unimplemented for
now.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

2 years agoSimplify kernel sanitizer interceptors
Mark Johnston [Mon, 19 Jul 2021 20:09:42 +0000 (16:09 -0400)]
Simplify kernel sanitizer interceptors

KASAN and KCSAN implement interceptors for various primitive operations
that are not instrumented by the compiler.  KMSAN requires them as well.
Rather than adding new cases for each sanitizer which requires
interceptors, implement the following protocol:
- When interceptor definitions are required, define
  SAN_NEEDS_INTERCEPTORS and SANITIZER_INTERCEPTOR_PREFIX.
- In headers that declare functions which need to be intercepted by a
  sanitizer runtime, use SANITIZER_INTERCEPTOR_PREFIX to provide
  declarations.
- When SAN_RUNTIME is defined, do not redefine the names of intercepted
  functions.  This is typically the case in files which implement
  sanitizer runtimes but is also needed in, for example, files which
  define ifunc selectors for intercepted operations.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

2 years agogeom_vfs: Pre-allocate event for g_vfs_destroy.
John Baldwin [Fri, 30 Jul 2021 00:09:23 +0000 (17:09 -0700)]
geom_vfs: Pre-allocate event for g_vfs_destroy.

When an active g_vfs is orphaned due to an underlying disk going away
the destroy is deferred until the filesystem is unmounted in
g_vfs_done().  However, g_vfs_done() is invoked from a non-sleepable
context and cannot use M_WAITOK to allocate the event.  Instead,
allocate the event in g_vfs_orphan() and save it in the softc to be
retrieved by the last call to g_vfs_done().

Reported by: Jithesh Arakkan @ Chelsio
Reviewed by: imp
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D31354

2 years agoUse a more specific type for geom_disk.d_event.
John Baldwin [Thu, 29 Jul 2021 23:34:46 +0000 (16:34 -0700)]
Use a more specific type for geom_disk.d_event.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D31353

2 years agocxgbei: Wait for socket to close in icl_cxgbei_conn_close.
John Baldwin [Thu, 29 Jul 2021 23:34:46 +0000 (16:34 -0700)]
cxgbei: Wait for socket to close in icl_cxgbei_conn_close.

This ensures the TOE has finished processing any in-flight received
data before returning to the caller.  The caller assumes it is safe to
free any open tasks or transfers (and associated buffers) after this
function returns.

Previously, data placed directly via DDP could be written to buffers
after the caller had freed the buffers.

Reported by: Jithesh Arakkan @ Chelsio
Sponsored by: Chelsio Communications

2 years agoClean up orphaned indirdep dependency structures after disk failure.
Kirk McKusick [Thu, 29 Jul 2021 23:31:16 +0000 (16:31 -0700)]
Clean up orphaned indirdep dependency structures after disk failure.

During forcible unmount after a disk failure there is a bug that
causes one or more indirdep dependency structures to fail to be
deallocated. Until we manage to track down why they fail to get
cleaned up, this code tracks them down and eliminates them so that
the unmount can succeed.

Reported by:  Peter Holm
Help from:    kib
Reviewed by:  Chuck Silvers
Tested by:    Peter Holm
MFC after:    7 days
Sponsored by: Netflix

2 years agoDiagnotic improvement to soft dependency structure management.
Kirk McKusick [Thu, 29 Jul 2021 23:11:58 +0000 (16:11 -0700)]
Diagnotic improvement to soft dependency structure management.

The soft updates diagnotic code keeps a list for each type of soft
update dependency. When a new block is allocated for a file it is
initially tracked by a "newblk" dependency. The "newblk" dependency
eventually becomes either an "allocdirect" dependency or an "indiralloc"
dependency. The diagnotic code failed to move the "newblk" from the list
of "newblk"s to its new type list.

No functional change intended.

Reviewed by:  Chuck Silvers (as part of a larger change)
Tested by:    Peter Holm (as part of a larger change)
Sponsored by: Netflix

2 years agoamd64: do not touch low memory in AP startup unless we used legacy boot
Konstantin Belousov [Thu, 29 Jul 2021 13:18:19 +0000 (16:18 +0300)]
amd64: do not touch low memory in AP startup unless we used legacy boot

This fixes several ommisions in 48216088b1157a22b955

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D31343

2 years agoamd64: stop doing special allocation for the AP startup trampoline
Konstantin Belousov [Thu, 29 Jul 2021 00:22:35 +0000 (03:22 +0300)]
amd64: stop doing special allocation for the AP startup trampoline

There is no reason now why do we need to allocate trampoline page very
early in the boot process.  The only requirement for the page is that
it is below 1M to be usable by the real mode during init.  This can be
handled by vm_alloc_contig() when we do the startup.

Also assert that startup trampoline fits into single page.  In principle
we can do multi-page allocation if needed, but it is not.

Move the alloc_ap_trampoline() function and the boot_address variable to
i386/mp_machdep.c.  Keep existing mechanism of early alloc on i386.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D31343

2 years agoawk: Note awk upgrades.
Warner Losh [Thu, 29 Jul 2021 21:41:16 +0000 (15:41 -0600)]
awk: Note awk upgrades.

Note the high level differences with the latest one true awk
import. This list may grow as we learn more troublesome areas.

Updated description of the format fo the file to match the file.

I'll likely merge this change (and any followups) by direct commit to
stable/13 and stable/12 in a couple of weeks.

Sponsored by: Netflix

2 years agoLinuxKPI: bitfield.h cleanup
Bjoern A. Zeeb [Thu, 29 Jul 2021 21:24:35 +0000 (21:24 +0000)]
LinuxKPI: bitfield.h cleanup

Add a missing tab and remove an unnecessary return.
No functional changes.

MFC after: 3 days

2 years agohwpmc: remove static POWER8 definitions
Leandro Lupori [Thu, 29 Jul 2021 17:37:32 +0000 (14:37 -0300)]
hwpmc: remove static POWER8 definitions

After b48a2770d48b, static POWER8 definitions became unnecessary,
as all of them (and much more) are already present in libpmc's
PMU events.

Submitted by: Leonardo Bianconi <leonardo.bianconi@eldorado.org.br> (initial version)
Reviewed by: kbowling, mhorne
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D31334

2 years agox86 __vdso_gettc: add O_CLOEXEC flag to open
Konstantin Belousov [Thu, 29 Jul 2021 01:26:38 +0000 (04:26 +0300)]
x86 __vdso_gettc: add O_CLOEXEC flag to open

of the /dev/hpet and /dev/hv_tsc devices, to not leak internal libc
filedescriptors on exec.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31344

2 years agoamd64: Set GS.base before calling init_secondary() on APs
Mark Johnston [Thu, 29 Jul 2021 14:22:37 +0000 (10:22 -0400)]
amd64: Set GS.base before calling init_secondary() on APs

KMSAN instrumentation requires thread-local storage to track
initialization state for function parameters and return values.  This
buffer is accessed as part of each function prologue.  It is provided by
the KMSAN runtime, which looks up a pointer in the current thread's
structure.

When KMSAN is configured, init_secondary() is instrumented, but this
means that GS.base must be initialized first, otherwise the runtime
cannot safely access curthread.  Work around this by loading GS.base
before calling init_secondary(), so that the runtime can at least check
curthread == NULL and return a pointer to some dummy storage.  Note that
init_secondary() still must reload GS.base after calling lgdt(), which
loads a selector into %gs, which in turn clears the base register.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31336

2 years agoamd64: Set MSR_KGSBASE to 0 during AP startup
Mark Johnston [Thu, 29 Jul 2021 14:14:05 +0000 (10:14 -0400)]
amd64: Set MSR_KGSBASE to 0 during AP startup

There is no reason to initialize it to anything else, and this matches
initialization of the BSP.  No functional change intended.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31336

2 years agolink_elf_obj: Invoke fini callbacks
Mark Johnston [Thu, 29 Jul 2021 13:46:25 +0000 (09:46 -0400)]
link_elf_obj: Invoke fini callbacks

This is required for KASAN: when a module is unloaded, poisoned regions
(e.g., pad areas between global variables) are left as such, so if they
are reused as KLDs are loaded, false positives can arise.

Reported by: pho, Jenkins
Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31339

2 years agolibc/locale: Use O_CLOEXEC when opening locale tables
Mark Johnston [Thu, 29 Jul 2021 13:14:50 +0000 (09:14 -0400)]
libc/locale: Use O_CLOEXEC when opening locale tables

Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agolinux(4): Eliminate a now unused includes after futexes refactoring.
Dmitry Chagin [Thu, 29 Jul 2021 09:56:39 +0000 (12:56 +0300)]
linux(4): Eliminate a now unused includes after futexes refactoring.

MFC after: 2 weeks

2 years agolinux(4): Add a comment about wait/requeue pi operations.
Dmitry Chagin [Thu, 29 Jul 2021 09:55:59 +0000 (12:55 +0300)]
linux(4): Add a comment about wait/requeue pi operations.

MFC after: 2 weeks

2 years agolinux(4): Handle incorrect FUTEX_CLOCK_REALTIME option bit.
Dmitry Chagin [Thu, 29 Jul 2021 09:55:33 +0000 (12:55 +0300)]
linux(4): Handle incorrect FUTEX_CLOCK_REALTIME option bit.

Return ENOSYS if the FUTEX_CLOCK_REALTIME option bit is specified for an
inappropriate futex operation.

MFC after: 2 weeks

2 years agolinux(4): Handle FUTEX_LOCK_PI2 oeration.
Dmitry Chagin [Thu, 29 Jul 2021 09:55:02 +0000 (12:55 +0300)]
linux(4): Handle FUTEX_LOCK_PI2 oeration.

FUTEX_LOCK_PI2 was added to support clock selection as FUTEX_LOCK_PI uses a
CLOCK_REALTIME based absolute value since it was implemented, but it does not
require that the FUTEX_CLOCK_REALTIME bit is set, because that was introduced
later.

MFC after: 2 weeks

2 years agolinux(4): Use variable name not type for sizeof() to calculate storage size.
Dmitry Chagin [Thu, 29 Jul 2021 09:54:32 +0000 (12:54 +0300)]
linux(4): Use variable name not type for sizeof() to calculate storage size.

MFC after: 2 weeks

2 years agolinux(4): Move len variable initialization to the appropriate place.
Dmitry Chagin [Thu, 29 Jul 2021 09:54:16 +0000 (12:54 +0300)]
linux(4): Move len variable initialization to the appropriate place.

MFC after: 2 weeks

2 years agolinux(4): Use linux_tdfind() in get_robust_list.
Dmitry Chagin [Thu, 29 Jul 2021 09:53:59 +0000 (12:53 +0300)]
linux(4): Use linux_tdfind() in get_robust_list.

In the Linux emulation layer linux_tdfind() has a special purpose to
handle glibc specific TID mangling and we should use it instead of tdfind().

MFC after: 2 weeks

2 years agolinux(4): Eliminate unnecessary error initialization.
Dmitry Chagin [Thu, 29 Jul 2021 09:53:41 +0000 (12:53 +0300)]
linux(4): Eliminate unnecessary error initialization.

MFC after: 2 weeks

2 years agolinux(4): Eliminate unnecessary head initialization.
Dmitry Chagin [Thu, 29 Jul 2021 09:53:25 +0000 (12:53 +0300)]
linux(4): Eliminate unnecessary head initialization.

MFC after: 2 weeks

2 years agolinux(4): style, wrap too long line.
Dmitry Chagin [Thu, 29 Jul 2021 09:53:07 +0000 (12:53 +0300)]
linux(4): style, wrap too long line.

MFC after: 2 weeks

2 years agolinux(4): Eliminating remnants of futex sdt.
Dmitry Chagin [Thu, 29 Jul 2021 09:52:36 +0000 (12:52 +0300)]
linux(4): Eliminating remnants of futex sdt.

MFC after: 2 weeks

2 years agolinux(4): Eliminating an accidental comment.
Dmitry Chagin [Thu, 29 Jul 2021 09:51:56 +0000 (12:51 +0300)]
linux(4): Eliminating an accidental comment.

MFC after: 2 weeks

2 years agolinux(4): Handle special case for regular futex in handle_futex_death().
Dmitry Chagin [Thu, 29 Jul 2021 09:51:39 +0000 (12:51 +0300)]
linux(4): Handle special case for regular futex in handle_futex_death().

Handle some races in handle_futex_death() which can prevents a wakeup of
potential waiters which can cause these waiters to block forever.

Differential Revision: https://reviews.freebsd.org/D31280
MFC after: 2 weeks

2 years agolinux(4): Futex address must be 32-bit aligned.
Dmitry Chagin [Thu, 29 Jul 2021 09:50:58 +0000 (12:50 +0300)]
linux(4): Futex address must be 32-bit aligned.

Linux futex documentation explicitly states that EINVAL is returned if
the futex is not 4-byte aligned. Check futex alignment as a Linux do
and return EINVAL.

Differential Revision: https://reviews.freebsd.org/D31279
MFC after: 2 weeks

2 years agolinux(4): Finish cf8d74e3fe63.
Dmitry Chagin [Thu, 29 Jul 2021 09:50:43 +0000 (12:50 +0300)]
linux(4): Finish cf8d74e3fe63.

Add forgotten val3_compare initialization in case of time64 futex.

MFC after: 2 weeks

2 years agolinux(4): Replace casuword32 by casueword32.
Dmitry Chagin [Thu, 29 Jul 2021 09:50:11 +0000 (12:50 +0300)]
linux(4): Replace casuword32 by casueword32.

Follow the r349951 (30b3018d), add check to react to stops and requests
to terminate between retries.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31254
MFC after: 2 weeks

2 years agolinux(4): Implement pi futexes using umtx.
Dmitry Chagin [Thu, 29 Jul 2021 09:49:42 +0000 (12:49 +0300)]
linux(4): Implement pi futexes using umtx.

Differential Revision: https://reviews.freebsd.org/D31240
MFC after: 2 weeks

2 years agolinux(4): Replace copyin() by fueword32() in handle_futex_death().
Dmitry Chagin [Thu, 29 Jul 2021 09:48:59 +0000 (12:48 +0300)]
linux(4): Replace copyin() by fueword32() in handle_futex_death().

According to fetch(9) fueword facility designed to fetch atomically
small amount of data from user space.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31239
MFC after: 2 weeks

2 years agoumtx: Add new pi_futex type.
Dmitry Chagin [Thu, 29 Jul 2021 09:48:34 +0000 (12:48 +0300)]
umtx: Add new pi_futex type.

Differential Revision: https://reviews.freebsd.org/D31250
MFC after: 2 weeks

2 years agoumtx: Split do_unlock_pi on two counterparts.
Dmitry Chagin [Thu, 29 Jul 2021 09:47:39 +0000 (12:47 +0300)]
umtx: Split do_unlock_pi on two counterparts.

The umtx_pi_frop() will be used by Linux emulation layer.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31238
MFC after: 2 weeks

2 years agoumtx: Expose some of the pi umtx structures and API to the rest of the kernel.
Dmitry Chagin [Thu, 29 Jul 2021 09:46:58 +0000 (12:46 +0300)]
umtx: Expose some of the pi umtx structures and API to the rest of the kernel.

Differential Revision: https://reviews.freebsd.org/D31237
MFC after: 2 weeks

2 years agolinux(4): Eliminate unused includes.
Dmitry Chagin [Thu, 29 Jul 2021 09:46:35 +0000 (12:46 +0300)]
linux(4): Eliminate unused includes.

MFC after: 2 weeks

2 years agolinux(4): Reimplement futexes using umtx.
Dmitry Chagin [Thu, 29 Jul 2021 09:43:48 +0000 (12:43 +0300)]
linux(4): Reimplement futexes using umtx.

Differential Revision: https://reviews.freebsd.org/D31236
MFC after: 2 weeks

2 years agoumtx: Add umtxq_requeue Linux emulation layer extension.
Dmitry Chagin [Thu, 29 Jul 2021 09:43:07 +0000 (12:43 +0300)]
umtx: Add umtxq_requeue Linux emulation layer extension.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31235
MFC after: 2 weeks

2 years agoumtx: Add bitset conditional wakeup functionality.
Dmitry Chagin [Thu, 29 Jul 2021 09:42:49 +0000 (12:42 +0300)]
umtx: Add bitset conditional wakeup functionality.

The bitset is a Linux emulation layer extension. This 32-bit mask, in which at
least one bit must be set, is used to select which threads should be woken up.

The bitset is stored in the umtx_q structure, which is used to enqueue the waiter
into the umtx waitqueue. Put the bitset into the hole, that appeared on LP64 due
to data alignment, to prevent the growth of the struct umtx_q.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31234
MFC after: 2 weeks

2 years agoumtx: Expose some of the umtx structures and API to the rest of the kernel.
Dmitry Chagin [Thu, 29 Jul 2021 09:42:17 +0000 (12:42 +0300)]
umtx: Expose some of the umtx structures and API to the rest of the kernel.

Differential Revision: https://reviews.freebsd.org/D31233
MFC after: 2 weeks

2 years agoumtx: Expose struct abs_timeout to the rest of the kernel.
Dmitry Chagin [Thu, 29 Jul 2021 09:41:58 +0000 (12:41 +0300)]
umtx: Expose struct abs_timeout to the rest of the kernel.

Add umtx_ prefix to all abs_timeout facility and add declaration for it.
For consistency with others abs_timeout mark inline abs_timeout_init2.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31249
MFC after: 2 weeks

2 years agoumtx: Split umtx.h on two counterparts.
Dmitry Chagin [Thu, 29 Jul 2021 09:41:29 +0000 (12:41 +0300)]
umtx: Split umtx.h on two counterparts.

To prevent umtx.h polluting by future changes split it on two headers:
umtx.h - ABI header for userspace;
umtxvar.h - the kernel staff.

While here fix umtx_key_match style.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31248
MFC after: 2 weeks

2 years agofreebsd32: Remove the unnecessary spaces.
Dmitry Chagin [Thu, 29 Jul 2021 09:40:36 +0000 (12:40 +0300)]
freebsd32: Remove the unnecessary spaces.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31247
MFC after: 2 weeks

2 years agofreebsd32: Remove unused umtx.h include.
Dmitry Chagin [Thu, 29 Jul 2021 09:40:08 +0000 (12:40 +0300)]
freebsd32: Remove unused umtx.h include.

Differential Revision: https://reviews.freebsd.org/D31246
MFC after: 2 weeks

2 years agofreebsd32: Eliminate spaces at end of line.
Dmitry Chagin [Thu, 29 Jul 2021 09:39:30 +0000 (12:39 +0300)]
freebsd32: Eliminate spaces at end of line.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31245
MFC after: 2 weeks

2 years agoFix mac_veriexec version mismatch
Wojciech Macek [Thu, 29 Jul 2021 09:02:43 +0000 (11:02 +0200)]
Fix mac_veriexec version mismatch

mac_veriexec sets its version to 1, but the mac_veriexec_shaX modules which depend on it expect MAC_VERIEXEC_VERSION = 2.
Be consistent and use MAC_VERIEXEC_VERSION everywhere.
This unbreaks loading of mac_veriexec modules at boot time.

Authored by:  Kornel Duleba <mindal@semihalf.com>
Obtained from:  Semihalf
Sponsored by:  Stormshield
Differential Revision:  https://reviews.freebsd.org/D31268

2 years agoAdd missing arm64 ID registers
Andrew Turner [Wed, 28 Jul 2021 19:00:36 +0000 (19:00 +0000)]
Add missing arm64 ID registers

These may contain values we export to userpsace.

Sponsored by: The FreeBSD Foundation

2 years agoSort the arm64 ID_AA64* user registers
Andrew Turner [Wed, 28 Jul 2021 18:30:09 +0000 (18:30 +0000)]
Sort the arm64 ID_AA64* user registers

Sponsored by: The FreeBSD Foundation

2 years agoMinor language improvements. Note that they can't be changed
David Malone [Thu, 29 Jul 2021 08:23:39 +0000 (09:23 +0100)]
Minor language improvements. Note that they can't be changed
by sysctl (I think they can be changed as a tuneable.)

2 years agovirtio: enable VTNET_LEGACY_TX when ALTQ is enabled.
Luiz Otavio O Souza [Thu, 26 Oct 2017 02:30:54 +0000 (21:30 -0500)]
virtio: enable VTNET_LEGACY_TX when ALTQ is enabled.

ALTQ only works on network drivers which use if_start (rather than
if_transmit). vtnet uses if_start if built with VTNET_LEGACY_TX. Default
to that the kernel is built with ALTQ enabled, to reduce user surprise.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agoUPDATING: document if_bridge MTU changes
Kristof Provost [Thu, 29 Jul 2021 07:36:52 +0000 (09:36 +0200)]
UPDATING: document if_bridge MTU changes

Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agolinux(4): Fix gcc buld.
Dmitry Chagin [Thu, 29 Jul 2021 06:52:33 +0000 (09:52 +0300)]
linux(4): Fix gcc buld.

gcc failed as it didn't inlined the builtins and generates calls to
the libgcc, ld can't find libgcc as cross-toolchain libgcc is not installed.
To avoid this add internal vDSO ffs functions without optimized builtins.

Reported by: jhb
MFC after: 2 weeks

2 years agohexdump: Flush stdout after '*' (repeat) lines.
Poul-Henning Kamp [Thu, 29 Jul 2021 06:37:39 +0000 (06:37 +0000)]
hexdump: Flush stdout after '*' (repeat) lines.

The canonical annoying example being:   hexdump < /dev/zero | less

2 years agolibc qsort(3): Eliminate ambiguous sign comparison
Conrad Meyer [Fri, 23 Jul 2021 18:04:21 +0000 (11:04 -0700)]
libc qsort(3): Eliminate ambiguous sign comparison

The left side of the MIN() expression is the (signed) result of pointer
subtraction (ptrdiff_t).  The right hand side is the also the (signed)
result of pointer subtraction, additionally subtracting the element size
('es'), which is unsigned size_t.  This coerces the right-hand
expression into an unsigned value.  MIN(signed, unsigned) triggers
-Wsign-compare.

Sorting elements of size greater than SSIZE_MAX is nonsensical, so we
can instead treat the element size as ssize_t, leaving the right-hand
result the same signedness as the left.

Reviewed by: arichardson, kib
Differential Revision: https://reviews.freebsd.org/D31292

2 years agokern: remove deprecated makesyscalls.sh
Kyle Evans [Thu, 29 Jul 2021 03:18:13 +0000 (22:18 -0500)]
kern: remove deprecated makesyscalls.sh

makesyscalls was rewritten in Lua and introduced in d3276301ab.  In the
time since, no objections have risen and a warning was introduced long
ago on invocation of makesyscalls.sh that it would be removed before
FreeBSD 13. Belatedly follow through on that.

2 years agocli.lua.8: make the command match the code
Warner Losh [Thu, 29 Jul 2021 02:53:18 +0000 (20:53 -0600)]
cli.lua.8: make the command match the code

It's disable-device, not device-disable

Spotted by: jrtc27
Sponsored by: Netflix

2 years agoRefactor/optimize cpu_search_*().
Alexander Motin [Thu, 29 Jul 2021 01:18:50 +0000 (21:18 -0400)]
Refactor/optimize cpu_search_*().

Remove cpu_search_both(), unused for many years.  Without it there is
less sense for the trick of compiling common cpu_search() into separate
cpu_search_lowest() and cpu_search_highest(), so split them completely,
making code more readable.  While there, split iteration over children
groups and CPUs, complicating code for very small deduplication.

Stop passing cpuset_t arguments by value and avoid some manipulations.
Since MAXCPU bump from 64 to 256, what was a single register turned
into 32-byte memory array, requiring memory allocation and accesses.
Splitting struct cpu_search into parameter and result parts allows to
even more reduce stack usage, since the first can be passed through
on recursion.

Remove CPU_FFS() from the hot paths, precalculating first and last CPU
for each CPU group in advance during initialization.  Again, it was
not a problem for 64 CPUs before, but for 256 FFS needs much more code.

With these changes on 80-thread system doing ~260K uncached ZFS reads
per second I observe ~30% reduction of time spent in cpu_search_*().

MFC after: 1 month

2 years agodebugnet: Fix false-positive assertions for dp_state
Bryan Drewery [Tue, 27 Jul 2021 20:12:37 +0000 (13:12 -0700)]
debugnet: Fix false-positive assertions for dp_state

debugnet_handle_arp:
  An assertion is present to ensure the pcb is only modified when the state is
  DN_STATE_INIT. Because debugnet_arp_gw() is asynchronous it is possible for
  ARP replies to come in after the gateway address is known and the state
  already changed.

debugnet_handle_ip:
  Similarly it is possible for packets to come in, from the expected
  server, during the gateway mac discovery phase.  This can happen from
  testing disconnects / reconnects in quick succession.  This later
  causes some acks to be sent back but hit an assertion because the
  state is wrong.

Reviewed by: cem, debugnet_handle_arp: markj, vangyzen
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D31327

2 years agolua loader: Add disable-device to disable a device.
Warner Losh [Wed, 28 Jul 2021 22:52:38 +0000 (16:52 -0600)]
lua loader: Add disable-device to disable a device.

disable-device fooX will set hint.foo.X.disabled=1 as a way to easily
disable a device attaching during boot.

Reviewed by: tsoome
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31297

2 years agonfscl: Cache an open stateid for the "oneopenown" mount option
Rick Macklem [Wed, 28 Jul 2021 22:48:27 +0000 (15:48 -0700)]
nfscl: Cache an open stateid for the "oneopenown" mount option

For NFSv4.1/4.2, if the "oneopenown" mount option is used,
there is, at most, only one open stateid for each NFS vnode.
When an open stateid for a file is acquired, set a pointer to
the open structure in the NFS vnode.  This pointer can be used to
acquire the open stateid without searching the open linked list
when the following is true:
- No delegations have been issued for the file.  Since delegations
  can outlive an NFS vnode for a file, use the global
  NFSMNTP_DELEGISSUED flag on the mount to determine this.
- No lock stateid has been issued for the file.  To determine
  this, a new NFS vnode flag called NMIGHTBELOCKED is set when a lock
  stateid is issued, which can then be tested.

When this open structure pointer can be used, it avoids the need to
acquire the NFSCLSTATELOCK() and searching the open structure list for
an open.  The NFSCLSTATELOCK() can be highly contended when there are
a lot of opens issued for the NFSv4.1/4.2 mount.

This patch only affects NFSv4.1/4.2 mounts when the "oneopenown"
mount option is used.

MFC after: 2 weeks

2 years agonfscl: Set correct lockowner for "oneopenown" mount option
Rick Macklem [Wed, 28 Jul 2021 22:23:05 +0000 (15:23 -0700)]
nfscl: Set correct lockowner for "oneopenown" mount option

For NFSv4.1/4.2, the client may use either an open, lock or
delegation stateid as the stateid argument for an I/O operation.
RFC 5661 defines an order of preference of delegation, then lock
and finally open stateid for the argument, although NFSv4.1/4.2
servers are expected to handle any stateid type.

For the "oneopenown" mount option, the lock owner was not being
correctly generated and, as such, the I/O operation would use an
open stateid, even when a lock stateid existed.  Although this
did not and should not affect an NFSv4.1/4.2 server's behaviour,
this patch makes the behaviour for "oneopenown" the same as when
the mount option is not specified.

Found during inspection of packet captures.  No failure during
testing against NFSv4.1/4.2 servers of the unpatched code occurred.

MFC after: 2 weeks

2 years agopkgbase: improve pkg --version parsing
Ed Maste [Wed, 28 Jul 2021 20:02:49 +0000 (16:02 -0400)]
pkgbase: improve pkg --version parsing

In some cases `pkg --version` might produce unexpected or additional
output.  Use a regex /^[0-9.]+$/ to match only the line containing the
version number.

Reported by: Michael Butler on freebsd-current@
Fixes: 4e224e4be7c3 ("pkgbase: accommodate pkg < 1.17")
Sponsored by: The FreeBSD Foundation

2 years agoDo not expose to scheduler caches of single CPU.
Alexander Motin [Wed, 28 Jul 2021 20:15:43 +0000 (16:15 -0400)]
Do not expose to scheduler caches of single CPU.

Before this change my dual-Xeon(R) Gold 6242R always reported 3 levels
or topology (root, package/L3 and core/L2).  But with SMT disabled
core/L2 matches thread, so additional topology level only causes more
traversal work.  With this change SMT case is reported same as before,
while non-SMT is reported with only 2 much more simple levels.

MFC after: 2 weeks

2 years agocompilert-rt: build out-of-line LSE atomics helpers for aarch64
Dimitry Andric [Wed, 28 Jul 2021 20:30:04 +0000 (22:30 +0200)]
compilert-rt: build out-of-line LSE atomics helpers for aarch64

Both clang >= 12 and gcc >= 10.1 now default to -moutline-atomics for
aarch64. This requires a bunch of helper functions in libcompiler_rt.a,
to avoid link errors like "undefined symbol: __aarch64_ldadd8_acq_rel".

(Note: of course you can use -mno-outline-atomics as a workaround too,
but this would negate the potential performance benefit of the faster
LSE instructions.)

Bump __FreeBSD_version so ports maintainers can easily detect this.

PR: 257392
MFC after: 2 weeks

2 years agobridge tests: verify that we can't change MTU of bridge member interfaces
Kristof Provost [Mon, 26 Jul 2021 11:51:22 +0000 (13:51 +0200)]
bridge tests: verify that we can't change MTU of bridge member interfaces

Reviewed by: donner
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31305

2 years agonet: disallow MTU changes on bridge member interfaces
Kristof Provost [Mon, 26 Jul 2021 10:18:27 +0000 (12:18 +0200)]
net: disallow MTU changes on bridge member interfaces

if_bridge member interfaces should always have the same MTU as the
bridge itself, so disallow MTU changes on interfaces that are part of an
if_bridge.

Reviewed by: donner
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31304

2 years agobridge tests: test changing the bridge MTU
Kristof Provost [Fri, 23 Jul 2021 15:46:10 +0000 (17:46 +0200)]
bridge tests: test changing the bridge MTU

Changing the bridge MTU will now also change all of the member interface
MTUs. Test this.

Reviewed by: donner
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31289

2 years agoif_bridge: allow MTU changes
Kristof Provost [Fri, 23 Jul 2021 15:22:18 +0000 (17:22 +0200)]
if_bridge: allow MTU changes

if_bridge used to only allow MTU changes if the new MTU matched that of
all member interfaces. This doesn't really make much sense, in that we
really shouldn't be allowed to change the MTU of bridge member in the
first place.

Instead we now change the MTU of all member interfaces. If one fails we
revert all interfaces back to the original MTU.

We do not address the issue where bridge member interface MTUs can be
changed here.

Reviewed by: donner
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31288

2 years agoloader: support.4th resets the read buffer incorrectly
John Hood [Wed, 28 Jul 2021 19:43:02 +0000 (13:43 -0600)]
loader: support.4th resets the read buffer incorrectly

Large nextboot.conf files (over 80 bytes) are not read correctly by the
Forth loader, causing file parsing to abort, and nextboot configuration
fails to apply.

Simple repro:

nextboot -e foo=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
shutdown -r now

That will cause the bug to cause a parse failure but shouldn't otherwise
affect the boot.  Depending on your loader configuration, you may also
have to set beastie_disable and/or reduce the number of modules loaded
to see the error on a small console screen.  12.0 or CURRENT users will
also have to explicitly use the Forth loader instead of the Lua loader.
The error will look something like:

Warning: syntax error on file /boot/loader.conf.local
foo="xxxxxxxxxxxxxxnextboot_enable="YES"
                                    ^
/boot/support.4th has crude file I/O buffering, which uses a buffer
'read_buffer', defined to be 80 bytes by the 'read_buffer_size'
constant.  The loader first tastes nextboot.conf, reading and parsing
the first line in it for nextboot_enable="YES".  If this is true, then
it reopens the file and parses it like other loader .conf files.

Unfortunately, the file I/O buffering code does not fully reset the
buffer state in the reset_line_reading word.  If the last file was read
to the end, that doesn't matter; the file buffer is treated as empty
anyway.  But in the nextboot.conf case, the loader will not read to the
end of file if it is over 80 bytes, and the file buffer may be reused
when reading the next file.  When the file is reread, the corrupt text
may cause file parsing to abort on bad syntax (if the corrupt line has
<>2 quotes in it), the wrong variable to be set, no variable to be set
at all, or (if the splice happens to land at a line ending) something
approximating normal operation.

The bug is very old, dating back to at least 2000 if not before, and is
still present in 12.0 and CURRENT r345863 (though it is now hidden by
the Lua loader by default).

Suggested one-line attached.  This does change the behavior of the
reset_line_reading word, which is exported in the line-reading
dictionary (though the export is not documented in loader man pages).
But repo history shows it was probably exported for the PNP support
code, which was never included in the loader build, and was removed 5
months ago.

One thing that puzzles me: how has this bug gone unnoticed/unfixed for
nearly 2 decades?  I find it hard to believe that nobody's tried to do
something interesting with nextboot, like load a kernel and filesystem,
which is what I'm doing.

Tested by: Gary Jennejohn
PR: 239315
MFC After: 3 weeks
Reviewed by: imp (and correctly applied this time)
Differential Revision: https://reviews.freebsd.org/D31328

2 years agogenoffset: simplify and rewrite in sh
Warner Losh [Wed, 28 Jul 2021 19:47:05 +0000 (13:47 -0600)]
genoffset: simplify and rewrite in sh

genoffset used the fully generic ASSYM macro to generate the offsets
needed for the thread_lite structure. However, since these are offsets
into a structure, they will always be necessarily small and positive. As
such, just create a simple character array of the right size and use a
naming convention such that we can recover the field name, structure
name and type. Use nm -t d and sort -n to sort these into order, then
loop over the resutls to generate the thread_lite structure.

MFC After: 2 weeks
Reviewed by: kib, markj (earlier versions)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31203

2 years agogenassym.sh: Fix two minor issues found by shellcheck
Warner Losh [Wed, 28 Jul 2021 19:42:29 +0000 (13:42 -0600)]
genassym.sh: Fix two minor issues found by shellcheck

o Remove redunant $ in $(( )) expression.
o Quote arg passed to work so paths with spaces, etc will work.

MFC After: 2 weeks
Reviewed by: kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31335