]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
23 months agoAdjust dtrace_unload() definition to avoid clang 15 warning
Dimitry Andric [Tue, 19 Jul 2022 18:48:47 +0000 (20:48 +0200)]
Adjust dtrace_unload() definition to avoid clang 15 warning

With clang 15, the following -Werror warnings is produced:

    In file included from sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c:18440:
    sys/cddl/dev/dtrace/dtrace_unload.c:26:14: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    dtrace_unload()
                 ^
                  void

This is because dtrace_unload() is declared with a (void) argument list,
but defined with an empty argument list. Make the definition match the
declaration.

MFC after: 3 days

23 months agoAdjust dtrace_getf_barrier() definition to avoid clang 15 warning
Dimitry Andric [Tue, 19 Jul 2022 18:46:18 +0000 (20:46 +0200)]
Adjust dtrace_getf_barrier() definition to avoid clang 15 warning

With clang 15, the following -Werror warnings is produced:

    sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c:17019:20: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    dtrace_getf_barrier()
       ^
void

This is because dtrace_getf_barrier() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

23 months agoAdjust profile_unload() definition to avoid clang 15 warning
Dimitry Andric [Tue, 19 Jul 2022 18:42:52 +0000 (20:42 +0200)]
Adjust profile_unload() definition to avoid clang 15 warning

With clang 15, the following -Werror warnings is produced:

    sys/cddl/dev/profile/profile.c:640:15: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    profile_unload()
                  ^
                   void

This is because profile_unload() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

23 months agoAdjust dtnfsclient_unload() definition to avoid clang 15 warning
Dimitry Andric [Tue, 19 Jul 2022 18:41:24 +0000 (20:41 +0200)]
Adjust dtnfsclient_unload() definition to avoid clang 15 warning

With clang 15, the following -Werror warnings is produced:

    sys/fs/nfsclient/nfs_clkdtrace.c:544:19: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    dtnfsclient_unload()
                      ^
                       void

This is because dtnfsclient_unload() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

23 months agoAdjust fbd_list() definition to avoid clang 15 warning
Dimitry Andric [Tue, 19 Jul 2022 18:35:37 +0000 (20:35 +0200)]
Adjust fbd_list() definition to avoid clang 15 warning

With clang 15, the following -Werror warnings is produced:

    sys/dev/fb/fbd.c:205:9: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    fbd_list()
            ^
             void

This is because fbd_list() is declared with a (void) argument list, but
defined with an empty argument list. Make the definition match the
declaration.

MFC after: 3 days

23 months agoAdjust db_flush_line() definition to avoid clang 15 warning
Dimitry Andric [Tue, 19 Jul 2022 18:31:08 +0000 (20:31 +0200)]
Adjust db_flush_line() definition to avoid clang 15 warning

With clang 15, the following -Werror warnings is produced:

    sys/ddb/db_lex.c:94:14: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    db_flush_line()
                 ^
                  void

This is because db_flush_line() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

23 months agoAdjust dtmalloc_unload() definition to avoid clang 15 warning
Dimitry Andric [Tue, 19 Jul 2022 18:24:41 +0000 (20:24 +0200)]
Adjust dtmalloc_unload() definition to avoid clang 15 warning

With clang 15, the following -Werror warnings is produced:

    sys/cddl/dev/dtmalloc/dtmalloc.c:177:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    dtmalloc_unload()
                   ^
                    void

This is because dtmalloc_unload() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

23 months agoAdjust t4_tracer_mod{load,unload}() definitions to avoid clang 15 warnings
Dimitry Andric [Tue, 19 Jul 2022 18:20:21 +0000 (20:20 +0200)]
Adjust t4_tracer_mod{load,unload}() definitions to avoid clang 15 warnings

With clang 15, the following -Werror warnings are produced:

    sys/dev/cxgbe/t4_tracer.c:234:18: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    t4_tracer_modload()
                     ^
                      void
    sys/dev/cxgbe/t4_tracer.c:243:20: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    t4_tracer_modunload()
                       ^
                        void

This is because t4_tracer_modload() and t4_tracer_modunload() are
declared with a (void) argument list, but defined with an empty argument
list. Make the definitions match the declarations.

MFC after: 3 days

23 months agoAdd -S option to veriexec
Simon J. Gerraty [Tue, 19 Jul 2022 15:59:53 +0000 (08:59 -0700)]
Add -S option to veriexec

During software installation, use veriexec -S to strictly
enforce certificate validity checks (notBefore, notAfter).

Otherwise ignore certificate validity period.
It is generally unacceptible for the Internet to stop working
just because someone did not upgrade their infrastructure for a decade.

Sponsored by: Juniper Networks, Inc.

Reviewed by: sebastien.bini_stormshield.eu
Differential Revision: https://reviews.freebsd.org/D35758

23 months agoconsole: add U+276E and U+276F glyphs
Ed Maste [Tue, 19 Jul 2022 15:48:29 +0000 (11:48 -0400)]
console: add U+276E and U+276F glyphs

U+276E Heavy Left-Pointing Angle Quotation Mark Ornament
U+276F Heavy Right-Pointing Angle Quotation Mark Ornament

U+276F is used by zprezto (zsh config package).

For the normal font I used the bold font glyphs for U+003C < and
U+003E >.  The bold font glyphs are new.

PR: 232494
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

23 months agovtfontcvt: improve hex font format validation
Ed Maste [Tue, 19 Jul 2022 15:20:10 +0000 (11:20 -0400)]
vtfontcvt: improve hex font format validation

Previously an EOF would result in sscanf returning -1 leading to a
crash.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

23 months agobacklight(8): Update usage() to match the manual page
Mateusz Piotrowski [Tue, 19 Jul 2022 14:56:27 +0000 (16:56 +0200)]
backlight(8): Update usage() to match the manual page

MFC after: 1 week

23 months agobacklight.8: Show all possible modes in synopsis
Mateusz Piotrowski [Tue, 19 Jul 2022 14:55:25 +0000 (16:55 +0200)]
backlight.8: Show all possible modes in synopsis

MFC after: 1 week

23 months agobacklight.8: Standardize synopsis and improve examples
Mateusz Piotrowski [Tue, 19 Jul 2022 14:49:50 +0000 (16:49 +0200)]
backlight.8: Standardize synopsis and improve examples

MFC after: 1 week

23 months agovtfontcvt(8): Update usage() to match vtfontcvt.8
Mateusz Piotrowski [Tue, 19 Jul 2022 14:34:29 +0000 (16:34 +0200)]
vtfontcvt(8): Update usage() to match vtfontcvt.8

MFC after: 2 weeks

23 months agovtfontcvt.8: Use D1 instead of Ql for readability
Mateusz Piotrowski [Tue, 19 Jul 2022 14:32:41 +0000 (16:32 +0200)]
vtfontcvt.8: Use D1 instead of Ql for readability

MFC after: 2 weeks

23 months agovtfontcvt.8: Sort synopsis
Mateusz Piotrowski [Tue, 19 Jul 2022 14:32:26 +0000 (16:32 +0200)]
vtfontcvt.8: Sort synopsis

MFC after: 2 weeks

23 months agovtfontcvt.8: Improve synopsis and -f documentation
Mateusz Piotrowski [Tue, 19 Jul 2022 14:28:22 +0000 (16:28 +0200)]
vtfontcvt.8: Improve synopsis and -f documentation

MFC after: 2 weeks

23 months agoUpdate Terminus console font to 4.49
Ed Maste [Mon, 18 Jul 2022 17:44:42 +0000 (13:44 -0400)]
Update Terminus console font to 4.49

As in the past Dimitar Zhekov provided a copy of Terminus under a BSD
license for use by our console.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

23 months agoAdd experimental 16k page support on arm64
Andrew Turner [Wed, 23 Mar 2022 17:39:58 +0000 (17:39 +0000)]
Add experimental 16k page support on arm64

Add initial 16k page support on arm64. It is considered experimental,
with no guarantee of compatibility with a userspace or kernel modules
built with the current a 4k page size as code will likely try to pass
in a too small size when working with APIs that take a multiple of a
page, e.g. mmap.

As this is experimental, and because userspace and the kernel need to
have the PAGE_SIZE macro kept in sync there is no kernel option to
enable this. To test a new image should be built with the
PAGE_{SIZE,SHIFT,MASK} macros changed to the 16k versions.

There are currently known issues with loading modules from an old
loader as it can misalign them to load on a non-16k boundary.

Testing has shown good results in kernel workloads that allocate and
free large amounts of memory as only a quarter of the number of calls
into the VM subsystem are needed in the best case.

Reviewed by: markj
Tested by: gallatin
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34793

23 months agoswap_pager: Reduce the scope of the object lock in putpages
Alan Cox [Tue, 19 Jul 2022 03:28:07 +0000 (22:28 -0500)]
swap_pager: Reduce the scope of the object lock in putpages

We don't need to hold the object lock while allocating swap space, so
don't.

Reviewed by: dougm, kib, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D35839

23 months agoipsec: replace SECASVAR mtx by rmlock
Kristof Provost [Thu, 23 Jun 2022 20:35:29 +0000 (22:35 +0200)]
ipsec: replace SECASVAR  mtx by rmlock

This mutex is a significant point of contention in the ipsec code, and
can be relatively trivially replaced by a read-mostly lock.
It does require a separate lock for the replay protection, which we do
here by adding a separate mutex.

This improves throughput (without replay protection) by 10-15%.

MFC after: 3 weeks
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D35763

23 months agox86/iommu: Shrink the critical section in dmar_qi_task()
Alan Cox [Mon, 18 Jul 2022 00:56:39 +0000 (19:56 -0500)]
x86/iommu: Shrink the critical section in dmar_qi_task()

It is safe to test and clear the Invalidation Wait Descriptor
Complete flag before acquiring the DMAR lock in dmar_qi_task(),
rather than waiting until the lock is held.

Reviewed by: kib
MFC after: 2 weeks

23 months agox86: Remove 1 second DELAY from cpu_reset
Colin Percival [Wed, 13 Jul 2022 00:43:07 +0000 (17:43 -0700)]
x86: Remove 1 second DELAY from cpu_reset

On SMP systems, cpu_reset broadcasts a message telling the APs to stop
themselves, and then the BSP waits 1 second before actually resetting
itself; this behaviour dates back to 1998-05-17.

I assume that this delay was added in order to allow the APs to stop
themselves before the BSP resets; but we wait until the APs have all
acknowledged entering the "stopped" state, so it no longer seems to
serve any purpose.

Reviewed by: jhb, kib
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D35797

23 months agoAdd kern.reboot_wait_time sysctl
Colin Percival [Wed, 13 Jul 2022 00:42:26 +0000 (17:42 -0700)]
Add kern.reboot_wait_time sysctl

Historic FreeBSD behaviour (dating back to 1994-04-02) when rebooting
is to print "Rebooting..." and then
/* wait 1 sec for printf's to complete and be read */

Prior to April 1994, there was a 100 ms delay (added 1993-11-12).

Since (a) most users will already be aware that the system is rebooting
and do not need to take time to read an additional message to that
effect, and (b) most FreeBSD systems don't have anyone actively looking
at the console anyway, this delay no longer serves much purpose.

This commit adds a kern.reboot_wait_time sysctl which defaults to 0;
historic behaviour can be regained by setting it to 1.

Reviewed by: imp
Relnotes: FreeBSD now reboots faster; to restore the traditional
wait after printing "Rebooting..." to the console, set
kern.reboot_wait_time=1 (or more).
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D35796

23 months agomac_ddb: add some validation functions
Mitchell Horne [Mon, 18 Jul 2022 21:25:00 +0000 (17:25 -0400)]
mac_ddb: add some validation functions

These global objects are easy to validate, so provide the helper
functions to do so and include these commands in the allow lists.

Reviewed by: markj
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D35372

23 months agomac: add new mac_ddb(4) policy
Mitchell Horne [Mon, 18 Jul 2022 21:24:06 +0000 (17:24 -0400)]
mac: add new mac_ddb(4) policy

Generally, access to the kernel debugger is considered to be unsafe from
a security perspective since it presents an unrestricted interface to
inspect or modify the system state, including sensitive data such as
signing keys.

However, having some access to debugger functionality on production
systems may be useful in determining the cause of a panic or hang.
Therefore, it is desirable to have an optional policy which allows
limited use of ddb(4) while disabling the functionality which could
reveal system secrets.

This loadable MAC module allows for the use of some ddb(4) commands
while preventing the execution of others. The commands have been broadly
grouped into three categories:
 - Those which are 'safe' and will not emit sensitive data (e.g. trace).
   Generally, these commands are deterministic and don't accept
   arguments.
 - Those which are definitively unsafe (e.g. examine <addr>, search
   <addr> <value>)
 - Commands which may be safe to execute depending on the arguments
   provided (e.g. show thread <addr>).

Safe commands have been flagged as such with the DB_CMD_MEMSAFE flag.

Commands requiring extra validation can provide a function to do so.
For example, 'show thread <addr>' can be used as long as addr can be
checked against the system's list of process structures.

The policy also prevents debugger backends other than ddb(4) from
executing, for example gdb(4).

Reviewed by: markj, pauamma_gundo.com (manpages)
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D35371

23 months agomac: kdb/ddb framework hooks
Mitchell Horne [Mon, 18 Jul 2022 21:23:16 +0000 (17:23 -0400)]
mac: kdb/ddb framework hooks

Add three simple hooks to the debugger allowing for a loaded MAC policy
to intervene if desired:
 1. Before invoking the kdb backend
 2. Before ddb command registration
 3. Before ddb command execution

We extend struct db_command with a private pointer and two flag bits
reserved for policy use.

Reviewed by: markj
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D35370

23 months agoddb: tag core commands with DB_CMD_MEMSAFE
Mitchell Horne [Mon, 18 Jul 2022 21:22:36 +0000 (17:22 -0400)]
ddb: tag core commands with DB_CMD_MEMSAFE

Those which are statically defined in db_command.c.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D35584

23 months agoddb: annotate some commands with DB_CMD_MEMSAFE
Mitchell Horne [Mon, 18 Jul 2022 21:21:38 +0000 (17:21 -0400)]
ddb: annotate some commands with DB_CMD_MEMSAFE

This is not completely exhaustive, but covers a large majority of
commands in the tree.

Reviewed by: markj
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D35583

23 months agoddb: add the DB_CMD_MEMSAFE flag for commands
Mitchell Horne [Mon, 18 Jul 2022 20:04:24 +0000 (16:04 -0400)]
ddb: add the DB_CMD_MEMSAFE flag for commands

This flag value can be used to indicate if a command has the property of
being "memory safe". In this instance, memory safe means that the
command does not allow/enable reads or writes of arbitrary memory,
regardless of the arguments passed to it. For example, 'backtrace' is
considered a memory-safe command since its output is deterministic,
while 'show vnode' is not, since it requires a memory address as an
argument and will print the contents beginning at that location.

Apply the flag to the "show all" command macros. It is expected that
commands added to this table will always exhibit this property.

Reviewed by: markj
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D35581

23 months agobge: tell debugnet there are 2 rx rings, not 1,024
Eric van Gyzen [Mon, 18 Jul 2022 18:07:20 +0000 (13:07 -0500)]
bge: tell debugnet there are 2 rx rings, not 1,024

debugnet provides the network stack for netgdb and netdump.  Since it
must operate under panic/debugger conditions and can't rely on dynamic
memory allocation, it preallocates mbufs during boot or network
configuration.  At that time, it does not yet know which interface
will be used for debugging, so it does not know the required size and
quantity of mbufs to allocate.  It takes the worst-case approach by
calculating its requirements from the largest MTU and largest number
of receive queues across all interfaces that support debugnet.

Unfortunately, the bge NIC driver told debugnet that it supports 1,024
receive queues.  It actually supports only 2 queues (with 1,024 slots,
thus the error).  This greatly exaggerated debugnet's preallocation,
so with an MTU of 9000 on any interface, it allocated 600 MB of memory.
A tiny fraction of this memory would be used if netgdb or netdump were
invoked; the rest is completely wasted.

Reviewed by: markj, rlibby
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D35845

23 months agosched_ule: Ensure we hold the thread lock when modifying td_flags
Mark Johnston [Mon, 18 Jul 2022 19:50:45 +0000 (15:50 -0400)]
sched_ule: Ensure we hold the thread lock when modifying td_flags

The load balancer may force a running thread to reschedule and pick a
new CPU.  To do this it sets some flags in the thread running on a
loaded CPU.  But the code assumed that a running thread's lock is the
same as that of the corresponding runqueue, and there are small windows
where this is not true.  In this case, we can end up with non-atomic
modifications to td_flags.

Since this load balancing is best-effort, simply give up if the thread's
lock doesn't match; in this case the thread is about to enter the
scheduler anyway.

Reviewed by: kib
Reported by: glebius
Fixes: e745d729be60 ("sched_ule(4): Improve long-term load balancer.")
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35821

23 months agoi386: fix pmap_trm_arena_last atomic load type
Mateusz Guzik [Mon, 18 Jul 2022 18:42:40 +0000 (18:42 +0000)]
i386: fix pmap_trm_arena_last atomic load type

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

23 months agovtfontcvt: correct usage
Ed Maste [Mon, 18 Jul 2022 17:21:22 +0000 (13:21 -0400)]
vtfontcvt: correct usage

Commit e7fd9688ea97 changed vtfontcvt's command line parsing, but did
not correctly update the usage (it omitted the new -o flag).

Fixes: e7fd9688ea97 ("Move font related data structured to...")
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

23 months agoImplement shared page address randomization
Kornel Dulęba [Tue, 10 May 2022 13:22:55 +0000 (15:22 +0200)]
Implement shared page address randomization

It used to be mapped at the top of the UVA.
If the randomization is enabled any address above .data section will be
randomly chosen and a guard page will be inserted in the shared page
default location.
The shared page is now mapped in exec_map_stack, instead of
exec_new_vmspace. The latter function is called before image activator
has a chance to parse ASLR related flags.
The KERN_PROC_VM_LAYOUT sysctl was extended to provide shared page
address.
The feature is enabled by default for 64 bit applications on all
architectures.
It can be toggled kern.elf64.aslr.shared_page sysctl.

Approved by: mw(mentor)
Sponsored by: Stormshield
Obtained from: Semihalf
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D35349

23 months agoRework how shared page related data is stored
Kornel Dulęba [Thu, 2 Jun 2022 07:58:12 +0000 (09:58 +0200)]
Rework how shared page related data is stored

Store the shared page address in struct vmspace.
Also instead of storing absolute addresses of various shared page
segments save their offsets with respect to the shared page address.
This will be more useful when the shared page address is randomized.

Approved by: mw(mentor)
Sponsored by: Stormshield
Obtained from: Semihalf
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D35393

23 months agoIntroduce the PROC_SIGCODE() macro
Kornel Dulęba [Thu, 2 Jun 2022 08:45:54 +0000 (10:45 +0200)]
Introduce the PROC_SIGCODE() macro

Use a getter macro instead of fetching the sigcode address directly
from a sysent of a given process. It assumes that the sigcode is stored
in the shared page, which is true in all cases, except for a.out
binaries. This will be later useful when the shared page address
randomization is introduced.
No functional change intended.

Approved by: mw(mentor)
Sponsored by: Stormshield
Obtained from: Semihalf
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D35392

23 months agoBump __FreeBSD_version after the removal of OBJT_DEFAULT
Mark Johnston [Mon, 18 Jul 2022 13:44:59 +0000 (09:44 -0400)]
Bump __FreeBSD_version after the removal of OBJT_DEFAULT

Out-of-tree modules which allocate an object of type OBJT_DEFAULT need
to be recompiled.  No other changes are required, however.

23 months agoofed/infiniband: fix ifdefs for new INET changes, fixing LINT-NOIP
Mike Karels [Sat, 16 Jul 2022 21:05:58 +0000 (16:05 -0500)]
ofed/infiniband: fix ifdefs for new INET changes, fixing LINT-NOIP

Some of the ofed/infiniband code has INET and INET6 address handling
code without using ifdefs.  This failed with a recent change to INET,
in which IN_LOOPBACK() started using a VNET variable, and which is not
present if INET is not configured.  Add #ifdef INET, and INET6 for good
measure, in cma_loopback_addr(), along with inclusion of the options
headers in ib_cma.c.

Reviewed by: hselasky rgrimes bz
Differential Revision: https://reviews.freebsd.org/D35835

(cherry picked from commit 752b7632776237f9c071783acdd1136ebf5f287d)

23 months agoblacklistd: Handle 0 sized messages
Ed Maste [Mon, 18 Jul 2022 00:43:52 +0000 (20:43 -0400)]
blacklistd: Handle 0 sized messages

Patch obtained from https://github.com/zoulasc/blocklist commit
ada75856bc6fcabbdd25ffbe08fbad5cf2a2c08a

PR: 264599
MFC after: 1 week

23 months agoarm64, qoriq_therm: fix handling sites on version 1 and 2
Bjoern A. Zeeb [Sun, 10 Jul 2022 13:38:56 +0000 (13:38 +0000)]
arm64, qoriq_therm: fix handling sites on version 1 and 2

For version 2 extend the TMUV2_TMSAR() write loop over all site_ids
registered for a particular SoC and actually use the site_id rather
than always just the first [0] (which for the LX2080 would be a
problem given there is no site0).

Later, while version 2 adds the SITEs to enable to TMSR in bits 0..<n>,
version 1 (e.g., LS1028, LS1046, LS1088) add MSITEs to TMR
bits 16..31 or rather 15..0(16-<n>).  Adjust the loops to only enable
the site_ids listed for the particular SoC for monitoring.  This now
also deals with sparse site_ids (not starting at 0, or not being
contiguous).

MFC after: 1 week
Sponsored by: Traverse Technologies (providing Ten64 HW for testing)
Reviewed by: mmel
Differential Revision: https://reviews.freebsd.org/D35764

23 months agoarm64, qoriq_therm: configure the number of sites base don SoC
Bjoern A. Zeeb [Sat, 9 Jul 2022 00:30:17 +0000 (00:30 +0000)]
arm64, qoriq_therm: configure the number of sites base don SoC

Configure the number of sites (sensors) based on SoC.
This avoids timeouts reading non-existent sensors.

The changes are based on mmel's initial work at:
https://github.com/strejda/freebsd/commit/914e3f0098b090cb5c1492b0d24992012c5c553b

MFC after: 1 week
Sponsored by: Traverse Technologies (providing Ten64 HW for testing)
Reviewed by: mmel
Differential Revision: https://reviews.freebsd.org/D35759

23 months agojail.8: Fix formatting of synopsis and some code examples
Mateusz Piotrowski [Mon, 18 Jul 2022 11:38:00 +0000 (13:38 +0200)]
jail.8: Fix formatting of synopsis and some code examples

MFC after: 3 days

23 months agobeinstall.8: Update example distsites for BSDINSTALL_DISTSITE
Mateusz Piotrowski [Mon, 18 Jul 2022 10:22:42 +0000 (12:22 +0200)]
beinstall.8: Update example distsites for BSDINSTALL_DISTSITE

MFC after: 1 week

23 months agousr.bin/cksum: localize _total variables.
Xin LI [Mon, 18 Jul 2022 00:24:31 +0000 (17:24 -0700)]
usr.bin/cksum: localize _total variables.

23 months agocallout: Simplify the inner loop in callout_process() a bit
Mark Johnston [Fri, 1 Jul 2022 00:16:33 +0000 (20:16 -0400)]
callout: Simplify the inner loop in callout_process() a bit

- Use LIST_FOREACH_SAFE.
- Simplify control flow.

No functional change intended.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

23 months agocallout: Remove a redundant parameter to callout_cc_add()
Mark Johnston [Thu, 30 Jun 2022 17:31:57 +0000 (13:31 -0400)]
callout: Remove a redundant parameter to callout_cc_add()

The passed cpuid is always equal to the one stored in the callout
structure.  No functional change intended.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

23 months agoFix clang 15 warning in cxgbe
Dimitry Andric [Sat, 16 Jul 2022 19:19:51 +0000 (21:19 +0200)]
Fix clang 15 warning in cxgbe

Clang 15 warns:

    sys/dev/cxgbe/cudbg/cudbg_lib.c:2949:6: error: variable 'i' set but not used [-Werror,-Wunused-but-set-variable]
            int i = 0;
                ^

Apparently 'i' was meant as the current retry counter, but '1' was used
in the while loop comparison instead, making the loop potentially
infinite, if 'busy' never gets reset.

MFC after: 3 days
Reviewed by: np
Differential Revision: https://reviews.freebsd.org/D35834

23 months agounbound: Update version strings to 1.16.1
Cy Schubert [Sun, 17 Jul 2022 13:54:32 +0000 (06:54 -0700)]
unbound: Update version strings to 1.16.1

The last number of unbound upgrades failed to manually update the
version strings in usr.sbin/unbound/config.h. This commit fixes that.

Reported by: "Herbert J. Skuhra" <herbert@gojira.at>
Fixes: 0a92a9fca737edafbad03ee5a8efebe302851cff
a39a5a6905612447def27b66ffe73b9d11efd80c
9cf5bc93f6ba1711ae7bf96a982a2b3c8b073a18
273016e836aa378789612e0a0e08d50f28be778e
24e365220007c415f495cf8dcb228ece6002b8b7
5469a9953005a9a4d4aad7be88545d441622e9a0
MFC after: 3 days

2 years agocd9660: Use ANSI (c89) prototypes
Ed Maste [Sun, 17 Jul 2022 12:14:49 +0000 (08:14 -0400)]
cd9660: Use ANSI (c89) prototypes

Sponsored by: The FreeBSD Foundation

2 years agovm_pager: Remove references to KVME_TYPE_DEFAULT in the kernel
Mark Johnston [Sat, 16 Jul 2022 15:31:08 +0000 (11:31 -0400)]
vm_pager: Remove references to KVME_TYPE_DEFAULT in the kernel

Keep the definition around since it's used by userspace.

Reviewed by: alc, imp, kib
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35791

2 years agovm_pager: Remove the default pager
Mark Johnston [Sat, 16 Jul 2022 15:30:19 +0000 (11:30 -0400)]
vm_pager: Remove the default pager

It's unused now.  Keep the OBJ_DEFAULT identifier, but make it an alias
of OBJT_SWAP for the benefit of out-of-tree code.

Reviewed by: alc, imp, kib
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35790

2 years agovm_object: Remove redundant OBJ_SWAP checks
Mark Johnston [Sat, 16 Jul 2022 15:29:53 +0000 (11:29 -0400)]
vm_object: Remove redundant OBJ_SWAP checks

With the removal of OBJT_DEFAULT, OBJ_ANON implies OBJ_SWAP.

Note, this means that vm_object_split() is more expensive than it used
to be, as it holds busy locks until the end of the range is reached,
even if the object has no swap blocks allocated.

Reviewed by: alc, kib
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35789

2 years agovm: Remove handling for OBJT_DEFAULT objects
Mark Johnston [Sat, 16 Jul 2022 15:29:19 +0000 (11:29 -0400)]
vm: Remove handling for OBJT_DEFAULT objects

Now that OBJT_DEFAULT objects can't be instantiated, we can simplify
checks of the form object->type == OBJT_DEFAULT || (object->flags &
OBJ_SWAP) != 0.  No functional change intended.

Reviewed by: alc, kib
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35788

2 years agovm_object: Release object swap charge in the swap pager destructor
Mark Johnston [Sat, 16 Jul 2022 15:28:55 +0000 (11:28 -0400)]
vm_object: Release object swap charge in the swap pager destructor

With the removal of OBJT_DEFAULT, we can simply handle this in
swap_pager_dealloc().  No functional change intended.

Suggested by: alc
Reviewed by: alc, kib
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35787

2 years agoswap_pager: Removing handling for objects with OBJ_SWAP clear
Mark Johnston [Sat, 16 Jul 2022 15:28:09 +0000 (11:28 -0400)]
swap_pager: Removing handling for objects with OBJ_SWAP clear

With the removal of OBJT_DEFAULT, we can assume that pager operations
provide an object with OBJ_SWAP set.  Also, we do not need to convert
objects from type OBJT_DEFAULT.  Thus, remove checks for OBJ_SWAP and
remove code which modifies the object type.  In some places, replace the
check for OBJ_SWAP with a check for whether any swap blocks are
assigned.

Reviewed by: alc, kib
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35786

2 years agovm_object: Modify vm_object_allocate_anon() to return OBJT_SWAP objects
Mark Johnston [Sat, 16 Jul 2022 15:27:27 +0000 (11:27 -0400)]
vm_object: Modify vm_object_allocate_anon() to return OBJT_SWAP objects

With this change, OBJT_DEFAULT objects are no longer allocated.
Instead, anonymous objects are always of type OBJT_SWAP and always have
OBJ_SWAP set.

Modify the page fault handler to check the swap block radix tree in
places where it checked for objects of type OBJT_DEFAULT.  In
particular, there's no need to invoke getpages for an OBJT_SWAP object
with no swap blocks assigned.

Reviewed by: alc, kib
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35785

2 years agostress2: Update the exclude list
Peter Holm [Sun, 17 Jul 2022 07:16:03 +0000 (09:16 +0200)]
stress2: Update the exclude list

2 years agox86/iommu: Eliminate redundant wrappers
Alan Cox [Sat, 16 Jul 2022 04:25:11 +0000 (23:25 -0500)]
x86/iommu: Eliminate redundant wrappers

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

2 years agoRemove unused but set variable in cxgb_sge
Dimitry Andric [Sat, 16 Jul 2022 18:16:36 +0000 (20:16 +0200)]
Remove unused but set variable in cxgb_sge

Clang 15 warns:

    sys/dev/cxgb/cxgb_sge.c:1290:21: error: variable 'txsd' set but not used [-Werror,-Wunused-but-set-variable]
            struct tx_sw_desc *txsd = &txq->sdesc[txqs->pidx];
                               ^

It appears 'txsd' is a leftover from a previous refactoring (see
3f345a5d09b6), but is no longer used for anything, and can be removed
without any functional change.

MFC after: 3 days
Reviewed by: np
Differential Revision: https://reviews.freebsd.org/D35833

2 years agoAdditional check for UFS/FFS superblock integrity checks.
Kirk McKusick [Sat, 16 Jul 2022 17:31:52 +0000 (10:31 -0700)]
Additional check for UFS/FFS superblock integrity checks.

Tested by:   Peter Holm
PR:          265162

2 years agoClarify when GEOM utilities exit with success or failure.
Kirk McKusick [Sat, 16 Jul 2022 17:25:22 +0000 (10:25 -0700)]
Clarify when GEOM utilities exit with success or failure.

Historically, GEOM utilities (gpart(8), gstripe(8), gmirror(8),
etc) used the gctl_error() routine to report errors. If they called
gctl_error() they would exit with EXIT_FAILURE, otherwise they would
return with EXIT_SUCCESS. If they used gctl_error() to output an
informational message, for example when run with the -v (verbose)
option, they would mistakenly exit with EXIT_FAILURE. A further
limitation of the gctl_error() function was that it could only be
called once. Messages from any additional calls to gctl_error()
would be silently discarded.

To resolve these problems a new function, gctl_msg() has been added.
It can be called multiple times to output multiple messages. It
also has an additional errno argument which should be zero if it is
an informational message or an errno value (EINVAL, EBUSY, etc) if
it is an error. When done the gctl_post_messages() function should
be called to indicate that all messages have been posted. If any
of the messages had a non-zero errno, the utility will EXIT_FAILURE.
If only informational messages (with zero errno) were posted, the
utility will EXIT_SUCCESS.

Tested by:   Peter Holm
PR:          265184
MFC after:   1 week

2 years agoWPA_DISTDIR does not need to end in a slash
Dimitry Andric [Sat, 16 Jul 2022 15:45:26 +0000 (17:45 +0200)]
WPA_DISTDIR does not need to end in a slash

Since all uses of the macro also append a slash, this leads to double
slashes.

MFC after: 3 days

2 years agoAdjust agp_find_device() definition in agp.c to avoid clang 15 warning
Dimitry Andric [Sat, 16 Jul 2022 14:46:21 +0000 (16:46 +0200)]
Adjust agp_find_device() definition in agp.c to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/dev/agp/agp.c:910:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    agp_find_device()
                   ^
                    void

This is because agp_find_device() is declared with a (void) argument
list, and defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

2 years agoule: unbreak UP builds
Mateusz Guzik [Sat, 16 Jul 2022 12:45:09 +0000 (12:45 +0000)]
ule: unbreak UP builds

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

2 years agoqat(4): Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 12:26:24 +0000 (14:26 +0200)]
qat(4): Fix a typo in a source code comment

- s/mirco/micro/

Obtained from: NetBSD
MFC after: 3 days

2 years agocommitters-doc.dot: add grahamperrin (Graham Perrin)
Graham Perrin [Sun, 10 Jul 2022 15:25:20 +0000 (16:25 +0100)]
committers-doc.dot: add grahamperrin (Graham Perrin)
Reviewed by:           gjb
Approved by:           gjb
Differential revision: https://reviews.freebsd.org/D35746

2 years agopfctl(8): Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 11:48:30 +0000 (13:48 +0200)]
pfctl(8): Fix a typo in a source code comment

- s/bufer/buffer/

MFC after: 3 days

2 years agoqat(4): Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 11:47:14 +0000 (13:47 +0200)]
qat(4): Fix a typo in a source code comment

- s/bufer/buffer/

Obtained from: NetBSD
MFC after: 3 days

2 years agolinux(4): Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 11:39:17 +0000 (13:39 +0200)]
linux(4): Fix a typo in a source code comment

- s/alredy/already/

MFC after: 3 days

2 years agocxgbe(4): Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 11:38:57 +0000 (13:38 +0200)]
cxgbe(4): Fix a typo in a source code comment

- s/alredy/already/

MFC after: 3 days

2 years agoenetc: Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 11:38:27 +0000 (13:38 +0200)]
enetc: Fix a typo in a source code comment

- s/alredy/already/

MFC after: 3 days

2 years agocrunchide(1): Fix a typo in a comment
Gordon Bergling [Sat, 16 Jul 2022 11:32:47 +0000 (13:32 +0200)]
crunchide(1): Fix a typo in a comment

- s/maek/make/

Obtained from: NetBSD
MFC after: 3 days

2 years agokdump(1): Sort options in alphabetical order.
Dmitry Chagin [Sat, 16 Jul 2022 09:47:54 +0000 (12:47 +0300)]
kdump(1): Sort options in alphabetical order.

Reviewed by: imp (early rev)
Differential Revision: https://reviews.freebsd.org/D35775
MFC after: 2 weeks

2 years agoktrace: Increase precision of timestamps.
Dmitry Chagin [Sat, 16 Jul 2022 09:46:12 +0000 (12:46 +0300)]
ktrace: Increase precision of timestamps.

Replace struct timeval in header with struct timespec.
To differentiate header formats, add a new KTR_VERSIONED flag
set in the header type field similar to the existing KTRDROP flag.

To make it easier to extend ktrace headers in the future,
extend the existing header with a version field (version 0 is
reserved for older records without KTR_VERSIONED) as well as
new fields holding the thread ID and CPU ID.

Reviewed by: jhb, pauamma
Differential Revision: https://reviews.freebsd.org/D35774
MFC after: 2 weeks

2 years agoiommu: Shrink the iommu map entry structure
Alan Cox [Mon, 11 Jul 2022 03:52:52 +0000 (22:52 -0500)]
iommu: Shrink the iommu map entry structure

Eliminate the unroll_entry field from struct iommu_map_entry, shrinking
the struct by 16 bytes on 64-bit architectures.

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

2 years agorelease: Support GNU stat in mkisoimages.sh
Jessica Clarke [Fri, 15 Jul 2022 22:04:48 +0000 (23:04 +0100)]
release: Support GNU stat in mkisoimages.sh

BSD stat and GNU stat differ significantly when it comes to using a
custom format string, both in the option name and in the format string
itself. Handle both here (assuming Linux means GNU stat rather than BSD
stat).

Reviewed by: brooks, gjb
Obtained from: CheriBSD
Differential Revision: https://reviews.freebsd.org/D35814

2 years agoMakefile.inc1 release bsd.own.mk: Introduce and use TAR_CMD
Jessica Clarke [Fri, 15 Jul 2022 22:04:34 +0000 (23:04 +0100)]
Makefile.inc1 release bsd.own.mk: Introduce and use TAR_CMD

Our uses of tar rely on BSDisms, and so do not work in environments
where GNU tar is the default tar. Providing a TAR_CMD variable like
some other commands allows it to be overridden to use bsdtar in such
cases.

Reviewed by: brooks, delphij, gjb
Obtained from: CheriBSD
Differential Revision: https://reviews.freebsd.org/D35813

2 years agoMakefile.inc1: Set LC_COLLATE in distributeworld for glibc compatibility
Jessica Clarke [Fri, 15 Jul 2022 22:04:26 +0000 (23:04 +0100)]
Makefile.inc1: Set LC_COLLATE in distributeworld for glibc compatibility

distributeworld relies on "foo" sorting directly before "foo type=...",
but with glibc both en_US and en_GB have "fooa" sort between "foo" and
"foo z", resulting in some files (in particular, id due to "ident"
sorting before "id type=" but after "id") not being included in the meta
files and thus not included in the dist tarballs. Forcing use of the C
locale ensures this does not occur.

Reviewed by: brooks
Obtained from: CheriBSD
Differential Revision: https://reviews.freebsd.org/D35812

2 years agoetc: Fix distrib-dirs to not rely on a BSDism
Jessica Clarke [Fri, 15 Jul 2022 22:04:16 +0000 (23:04 +0100)]
etc: Fix distrib-dirs to not rely on a BSDism

FreeBSD and macOS have a test that treats == as an alias for =, but
Linux tends to use GNU coreutils (when not a builtin) which does not.
Use the standard syntax instead for compatibility.

Obtained from: CheriBSD
Differential Revision: https://reviews.freebsd.org/D35811

2 years agoMakefile.inc1: Honour DB_FROM_SRC for NO_ROOT distributeworld
Jessica Clarke [Fri, 15 Jul 2022 22:03:49 +0000 (23:03 +0100)]
Makefile.inc1: Honour DB_FROM_SRC for NO_ROOT distributeworld

Currently the host's database files are used, but on non-FreeBSD these
are not necessarily sufficient; in particular, Linux does not have a
wheel group. Instead, use -N to use the in-tree database files when
creating the METALOG entries, as is done for the recursive makes via
IMAKE_MTREE.

Reviewed by: brooks
Obtained from: CheriBSD
Differential Revision: https://reviews.freebsd.org/D35810

2 years agoAdjust parse() definition in boot2 to avoid clang 15 warning
Dimitry Andric [Fri, 15 Jul 2022 19:15:11 +0000 (21:15 +0200)]
Adjust parse() definition in boot2 to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    stand/i386/boot2/boot2.c:358:6: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]

This is because parse() is declared with a (void) argument list, and
defined with an empty argument list. Make the definition match the
declaration.

MFC after: 3 days

2 years agoMerge fix for zfs readmmap test from CheriBSD
Dimitry Andric [Fri, 15 Jul 2022 19:10:09 +0000 (21:10 +0200)]
Merge fix for zfs readmmap test from CheriBSD

Merge commit 1737d8397a0 by Brooks Davis:

  time() is declared in time.h

This fixes a -Werror warning from clang 15:

  tests/sys/cddl/zfs/bin/readmmap.c:97:9: error: call to undeclared function 'time'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

Obtained from: https://github.com/CTSRD-CHERI/cheribsd/commit/1737d8397a0
MFC after: 3 days

2 years agoRemove unnecessary const and volatile qualifiers from __fp_type_select()
Dimitry Andric [Thu, 14 Jul 2022 11:20:52 +0000 (13:20 +0200)]
Remove unnecessary const and volatile qualifiers from __fp_type_select()

Since https://github.com/llvm/llvm-project/commit/ca75ac5f04f2, clang 15
has a new warning about _Generic selection expressions, such as used in
math.h:

    lib/libc/gdtoa/_ldtoa.c:82:10: error: due to lvalue conversion of the controlling expression, association of type 'volatile float' will never be selected because it is qualified [-Werror,-Wunreachable-code-generic-assoc]
            switch (fpclassify(u.e)) {
                    ^
    lib/msun/src/math.h:109:2: note: expanded from macro 'fpclassify'
            __fp_type_select(x, __fpclassifyf, __fpclassifyd, __fpclassifyl)
            ^
    lib/msun/src/math.h:85:14: note: expanded from macro '__fp_type_select'
        volatile float: f(x),                                               \
                 ^

This is because the controlling expression always undergoes lvalue
conversion first, dropping any cv-qualifiers. The 'const', 'volatile',
and 'volatile const' associations will therefore never be used.

MFC after: 1 week
Reviewed by: theraven
Differential Revision: https://reviews.freebsd.org/D35815

2 years agokboot: Pull in constants from Linux's mmap.h api
Warner Losh [Tue, 28 Jun 2022 16:43:42 +0000 (10:43 -0600)]
kboot: Pull in constants from Linux's mmap.h api

Define the usual #defines for mmap(2) (with HOST_ prepended) and use
them instead of hard coding constants.

Sponsored by: Netflix

2 years agokboot: Properly cap number of segments loaded for kexec
Warner Losh [Wed, 29 Jun 2022 22:31:23 +0000 (16:31 -0600)]
kboot: Properly cap number of segments loaded for kexec

Linux has an arbitrary limit of 16 segments. Make sure we don't load too
many.

Sponsored by: Netflix

2 years agokboot: Refinements to host_kexec_load
Warner Losh [Tue, 28 Jun 2022 16:40:04 +0000 (10:40 -0600)]
kboot: Refinements to host_kexec_load

Move kexec_segments to host_syscall.h and pre-pend host_ to it.  Correct
args to host_exec_load.

Sponsored by: Netflix

2 years agokboot: Use #defines for magic reboot constants
Warner Losh [Tue, 28 Jun 2022 14:44:16 +0000 (08:44 -0600)]
kboot: Use #defines for magic reboot constants

Sponsored by: Netflix

2 years agokboot: Implement mount(2)
Warner Losh [Thu, 30 Jun 2022 18:16:46 +0000 (12:16 -0600)]
kboot: Implement mount(2)

Create a wrapper for the mount system call. To ensure a sane early boot
environment and to gather data we need for kexec, we may need to mount
some special filesystems.

Sponsored by: Netflix

2 years agokboot: Implement mkdir(2)
Warner Losh [Thu, 30 Jun 2022 18:09:26 +0000 (12:09 -0600)]
kboot: Implement mkdir(2)

mkdir() may be needed early in boot to create missing
directories. Provide a syscall wrapper for it.

Sponsored by: Netflix

2 years agokboot: Implement dup(2)
Warner Losh [Thu, 30 Jun 2022 18:25:49 +0000 (12:25 -0600)]
kboot: Implement dup(2)

Early in boot, we need to create the normal stdin/out/err env for the
boot loader to run in. To do that, we need to open the console and
duplicate the file descriptors which requires dup(2). Implement a
wrapper as host_dup.

Sponsored by: Netflix

2 years agokboot: Implement symlink(2)
Warner Losh [Thu, 30 Jun 2022 18:22:33 +0000 (12:22 -0600)]
kboot: Implement symlink(2)

Linux's /dev/fd is implemented inside of /proc/self/fd, so we may need
to create a symlink to it early in boot. "/dev/fd" and "/dev/std*" might
not be strictly required for the boot loader, but should be present for
maximum flexibility.

Sponsored by: Netflix

2 years agokboot: Implement getpid(2)
Warner Losh [Thu, 30 Jun 2022 18:12:51 +0000 (12:12 -0600)]
kboot: Implement getpid(2)

Add host_getpid() so we can know if we're running as init(8) or not.  If
we are, we may chose to do early system setup / sanity operations.

Sponsored by: Netflix

2 years agokboot: Implement munmap(2)
Warner Losh [Mon, 27 Jun 2022 23:49:21 +0000 (17:49 -0600)]
kboot: Implement munmap(2)

Define host_munmap so we can use it in the x86 code to find things for
the BIOS/CMS boot path and unmap after we find it.

Sponsored by: Netflix

2 years agokboot: Implement stat(2) and fstat(2) system calls
Warner Losh [Fri, 15 Jul 2022 05:19:18 +0000 (23:19 -0600)]
kboot: Implement stat(2) and fstat(2) system calls

Implement stat(2) and fstat(2) in terms of newfstatat and newfstat
system calls respectively (assume we have a compat #define when
there's no newfstat and just a regular fstat and do so for ppc).

Snag struct kstat (the Linux kernel stat(2), et al interface) from musl
and attribute properly.

Sponsored by: Netflix

2 years agokboot: Add HOST_O_ constants for open, etc
Warner Losh [Fri, 1 Jul 2022 17:57:02 +0000 (11:57 -0600)]
kboot: Add HOST_O_ constants for open, etc

Add the common O_ constants for the open, fcntl, etc system calls. They
are different than FreeBSD's. While they can differ based on
architecture, they are constant for architectures we care about, and
those architectures use the 'generic' version so future architectures
will also work.

Sponsored by: Netflix

2 years agokboot: Enhance kboot_getdev to cope with NULLs
Warner Losh [Fri, 15 Jul 2022 13:32:16 +0000 (07:32 -0600)]
kboot: Enhance kboot_getdev to cope with NULLs

Fallback to currdev when NULL is passed in when 'rootdev' is NULL. Other
getdevs do this. Additional features are needed here still, though.

Sponsored by: Netflix

2 years agokboot: Reimplement older system calls in terms of newer ones
Warner Losh [Thu, 7 Jul 2022 22:58:27 +0000 (16:58 -0600)]
kboot: Reimplement older system calls in terms of newer ones

aarch64 doesn't have open, just openat, etc. Cope.

Sponsored by: Netflix

2 years agokboot: Rework _start
Warner Losh [Thu, 14 Jul 2022 03:41:17 +0000 (21:41 -0600)]
kboot: Rework _start

Split _start into _start and _start_c (inspired by musl and the powerpc
impl is copied from there). This allows us to actually get the command
line arguments on all the platforms. We have a very simplified startup
that supports only static linking.

Sponsored by: Netflix