openbsd
17 months agoSimplify OBJ_obj2txt()
tb [Tue, 23 May 2023 11:51:12 +0000 (11:51 +0000)]
Simplify OBJ_obj2txt()

Instead of adding a NUL termination to OBJ_obj2txt(), move the aobj == NULL
or aobj->data == NULL checks to i2t_ASN1_OBJECT_internal(). The only other
caller, i2t_ASN1_OBJECT(), fails on aobj == NULL and aobj->length == 0, and
the latter condition is implied by aobj->data.

Cleaner solution for obj_dat.c r1.52
suggested by/ok jsing

17 months agoAdd empty line for consistency
tb [Tue, 23 May 2023 11:06:52 +0000 (11:06 +0000)]
Add empty line for consistency

17 months agoAdd regress coverage for obj_dat.c r1.52
tb [Tue, 23 May 2023 11:05:09 +0000 (11:05 +0000)]
Add regress coverage for obj_dat.c r1.52

17 months agoAlways NUL terminate buf in OBJ_obj2txt()
tb [Tue, 23 May 2023 11:04:04 +0000 (11:04 +0000)]
Always NUL terminate buf in OBJ_obj2txt()

OBJ_obj2txt() is often called without error checking and is used for
reporting unexpected or malformed objects. As such, we should ensure
buf is a string even on failure. This had long been the case before it
was lost in a recent rewrite. If obj and obj->data are both non-NULL
this is already taken care of by i2t_ASN1_OBJECT_internal(), so many
callers were still safe.

ok miod

17 months agodon't pass state, we get them from the progressmeter
espie [Tue, 23 May 2023 10:02:46 +0000 (10:02 +0000)]
don't pass state, we get them from the progressmeter

17 months agoAdd IBT support to the retpoline PLTs. Since we use retpoline PLTs by
kettenis [Tue, 23 May 2023 09:37:49 +0000 (09:37 +0000)]
Add IBT support to the retpoline PLTs.  Since we use retpoline PLTs by
default on OpenBSD this will give us IBT support by default.  Fixes
indirect function calls for functions in shared libraries.

This doesn't fix retpoline+znow PLTs yet; a fix for that will follow.

ok miod@, guenther@

17 months agoDon't use ibuf_open(0) as test. 0 lenght ibufs make little sense and
claudio [Tue, 23 May 2023 09:32:37 +0000 (09:32 +0000)]
Don't use ibuf_open(0) as test. 0 lenght ibufs make little sense and
result in a malloc(0) call which is no bueno. Use ibuf_open(1) instead.
OK miod@

17 months agoNew counters for LRO packets from hardware TCP offloading.
jan [Tue, 23 May 2023 09:16:16 +0000 (09:16 +0000)]
New counters for LRO packets from hardware TCP offloading.

With tweaks from patrick@ and bluhm@.

OK bluhm@

17 months agocms_asn1.c: zap stray tabs
tb [Tue, 23 May 2023 06:55:31 +0000 (06:55 +0000)]
cms_asn1.c: zap stray tabs

17 months agoConvert ASN1_INTEGER_get() to ASN1_INTEGER_get_uint64()
tb [Tue, 23 May 2023 06:42:08 +0000 (06:42 +0000)]
Convert ASN1_INTEGER_get() to ASN1_INTEGER_get_uint64()

The former is broken by design and should not be used. The latter allows
for unambiguous error checking. Add a few casts to print uint64_t without
the PRIu64 monstrosity.

ok claudio

17 months agoSimplify as_id_parse() using ASN1_INTEGER_get_uint64()
tb [Tue, 23 May 2023 06:39:31 +0000 (06:39 +0000)]
Simplify as_id_parse() using ASN1_INTEGER_get_uint64()

Instead of decoding an ASN1_INTEGER by hand because ASN1_INTEGER_get()
is broken by design and would report an error on LP32 architectures for
the reserved ASid UINT32_MAX, we can simplify this ugliness and use the
ASN1_INTEGER_get_uint64() API, available since LibreSSL 3.6.

ok claudio

17 months agoDrop unused md_prep_fdisk() argument in disk crypto question handler
kn [Mon, 22 May 2023 23:32:31 +0000 (23:32 +0000)]
Drop unused md_prep_fdisk() argument in disk crypto question handler

It takes just one, the disk;  the second snuck from earlier development into
the intial r1.1231 commit.

17 months agoRemove misplaced semicolons in .Fa
tb [Mon, 22 May 2023 19:38:04 +0000 (19:38 +0000)]
Remove misplaced semicolons in .Fa

17 months agoFix TSO for traffic to a local address on a physical interface.
bluhm [Mon, 22 May 2023 16:08:34 +0000 (16:08 +0000)]
Fix TSO for traffic to a local address on a physical interface.

When sending TCP packets with software TSO to the local address of
a physical interface, the TCP checksum was miscalculated.  As the
small MSS is taken from the physical interface, but the large MTU
of the loopback interface is used, large TSO packets are generated,
but sent directly to the loopback interface.  There we need the
regular pseudo header checksum and not the modified without packet
length.

To avoid this confusion, use the same decision for checksum generation
in in_proto_cksum_out() as for using hardware TSO in tcp_if_output_tso().

bug reported and tested by robert@ bket@ Hrvoje Popovski
OK claudio@ jan@

17 months agoBye, bye, horrible reacharounds into libcrypto
tb [Mon, 22 May 2023 15:20:16 +0000 (15:20 +0000)]
Bye, bye, horrible reacharounds into libcrypto

Now that rpki-client no longer uses LibreSSL-specific ASN1_time_* API,
we can get rid of some of the gross hacks needed for testing against
OpenSSL in regress. This simplifies things greatly.

Unfortunately, the unistd.h hack needs to stay until someone unearths
their STACK_OF compat diffs.

17 months agoConvert generalizedtime_to_tm() to ASN1_TIME_to_tm()
tb [Mon, 22 May 2023 15:15:25 +0000 (15:15 +0000)]
Convert generalizedtime_to_tm() to ASN1_TIME_to_tm()

Second step of moving away from ASN1_time_parse(). Being an OpenSSL API,
ASN1_TIME_to_tm() supports a variety of things. In this specific case we
don't really want it to parse anything but a GeneralizedTime expressed in
Zulu time. Unfortunately, OpenSSL make this annoying. So punt on this and
only do checks for the correct type and length. LibreSSL only accepts Zulu
time, so there is no change of behavior.

ok claudio job

17 months agoConvert x509_get_time() to ASN1_TIME_to_tm()
tb [Mon, 22 May 2023 15:07:02 +0000 (15:07 +0000)]
Convert x509_get_time() to ASN1_TIME_to_tm()

Instead of using the LibreSSL-specific ASN1_time_parse(), we can use
OpenSSL's ASN1_TIME_to_tm() which LibreSSL provides since 3.6.0. The
latter has a few API quirks such as silently falling back to being a
timegm() replacement if called with a NULL ASN1_TIME. We don't want
that, so just return an error instead.

rpki-client portable now needs LibreSSL >= 3.6. This is a small price
to pay for rather significant smiplifications in regress and portable
(which will be possible after the next commit).

Also adjust a couple of error strings.

ok claudio job

17 months agoAvoid use of LibreSSL-specific ASN1_time_tm_cmp() API
tb [Mon, 22 May 2023 14:56:00 +0000 (14:56 +0000)]
Avoid use of LibreSSL-specific ASN1_time_tm_cmp() API

We convert these struct tm into time_t in the next few lines, so we can
simply use > instead.

ok claudio job

17 months agoAdd EPYC Embedded 3000 10GbE NIC
denis [Mon, 22 May 2023 13:23:56 +0000 (13:23 +0000)]
Add EPYC Embedded 3000 10GbE NIC

Input by sthen@
OK miod@

17 months agoRemove unused variable kerr.
tobhe [Mon, 22 May 2023 12:53:04 +0000 (12:53 +0000)]
Remove unused variable kerr.

ok bluhm@

17 months agoRemove duplicate entries in kvars.
bluhm [Mon, 22 May 2023 12:37:00 +0000 (12:37 +0000)]
Remove duplicate entries in kvars.
OK tobhe@

17 months agogc unused/old code
espie [Mon, 22 May 2023 12:05:57 +0000 (12:05 +0000)]
gc unused/old code

17 months agofix usage, name arg is optional
kn [Mon, 22 May 2023 09:29:54 +0000 (09:29 +0000)]
fix usage, name arg is optional

17 months agoKeep trying LDAP servers until we get full results from one, rather than
jmatthew [Mon, 22 May 2023 05:59:05 +0000 (05:59 +0000)]
Keep trying LDAP servers until we get full results from one, rather than
just until one accepts the TCP connection. In multi server environments,
this makes ypldap more resilient when some servers are misbehaving.

While here, add the server address to log messages relating to connection
errors to make it easier to identify which server is failing.

ok tb@

17 months agoThe fp_ex_[st]w struct savefpu members were inherited from NetBSD where
guenther [Mon, 22 May 2023 00:39:57 +0000 (00:39 +0000)]
The fp_ex_[st]w struct savefpu members were inherited from NetBSD where
they're used in the 32bit-compat support, which we dropped years ago.
Bye bye!

ok deraadt@

17 months agoNENTRY() doesn't provide an endbr64, so give memmove one in
guenther [Mon, 22 May 2023 00:37:19 +0000 (00:37 +0000)]
NENTRY() doesn't provide an endbr64, so give memmove one in
case it ever gets called through a function pointer (with retpoline
disabled)

ok deraadt@

17 months agoIf an MBR partition start or end can be represented by CHS, set
krw [Sun, 21 May 2023 17:29:33 +0000 (17:29 +0000)]
If an MBR partition start or end can be represented by CHS, set
both CHS and LBA values in the MBR partition.

Restores pre-7.0 initialization of MBR partition start/end, using
slightly less opaque code that retains the slightly different
initialization required by GPT protective MBR's.

Fixes booting from disks >8G on systems where the BIOS uses CHS.

Encountered by Paul de Weerd on his Alix.2 using BIOS 0.99.

Much diagnosis and testing by Paul of various iterations. Thanks!

17 months agoTypo in comment. 'parititon' -> 'partition'.
krw [Sun, 21 May 2023 17:04:22 +0000 (17:04 +0000)]
Typo in comment. 'parititon' -> 'partition'.

17 months agomissed one
espie [Sun, 21 May 2023 16:50:50 +0000 (16:50 +0000)]
missed one

17 months agomove the interface to SharedLibs to be somewhat object oriented
espie [Sun, 21 May 2023 16:07:35 +0000 (16:07 +0000)]
move the interface to SharedLibs to be somewhat object oriented

accordingly, load it "just in time" in State.

Most calls get simplified, and we can save more state for later.

17 months agodocument how this is used... There's nothing that actually uses the
espie [Sun, 21 May 2023 13:44:56 +0000 (13:44 +0000)]
document how this is used... There's nothing that actually uses the
export part, and be explicit about how we call code refs.

17 months ago"fix" for 5.36: pass the possible option value as an extra param
espie [Sun, 21 May 2023 13:44:21 +0000 (13:44 +0000)]
"fix" for 5.36: pass the possible option value as an extra param
instead of defined/undefined, so that the code sub is called with
the right number of parameters.

17 months agoIn sysctl_hwchargestop() check that hw_battery_setchargestop is set
claudio [Sun, 21 May 2023 12:47:54 +0000 (12:47 +0000)]
In sysctl_hwchargestop() check that hw_battery_setchargestop is set
and not hw_battery_setchargestart.
OK kettenis@

17 months agov5.36, trivial move
espie [Sun, 21 May 2023 08:06:03 +0000 (08:06 +0000)]
v5.36, trivial move

17 months agozap extra word and some hyphens; ok guenther
jmc [Sun, 21 May 2023 05:11:38 +0000 (05:11 +0000)]
zap extra word and some hyphens; ok guenther

17 months agotypofix message in previous
kn [Sat, 20 May 2023 20:00:28 +0000 (20:00 +0000)]
typofix message in previous

17 months agoAsk for disk crypto after root disk question
kn [Sat, 20 May 2023 19:10:25 +0000 (19:10 +0000)]
Ask for disk crypto after root disk question

    Encrypt the root disk? (disk, no or '?' for details) [no]
    Which disk is the root disk? ('?' for details) [sdN]
becomes
    Which disk is the root disk? ('?' for details) [sd0]
    Encrypt the root disk? (yes, no or '?' for details) [no]

so that answering 'sd0' at this point during installation behaves the same
as before the new question:  specifying the root disk.

Users no longer deal with two (softraid chunk sd0, root disk sd1), but just
one disk as before, while sdN are dealt with transparently.

Code also gets simpler and should enable more improvements soon.

Feedback OK afresh1

17 months agoecdhtest: Fix indent
tb [Sat, 20 May 2023 16:00:22 +0000 (16:00 +0000)]
ecdhtest: Fix indent

17 months agoRemove a space that I thought I had already deleted.
tb [Sat, 20 May 2023 15:57:40 +0000 (15:57 +0000)]
Remove a space that I thought I had already deleted.

Makes mandoc -Tlint happier

17 months agop_fragblock = DISKLABELV1_FFS_FRAGBLOCK(0, 0) sets p_fragblock to
krw [Sat, 20 May 2023 15:16:47 +0000 (15:16 +0000)]
p_fragblock = DISKLABELV1_FFS_FRAGBLOCK(0, 0) sets p_fragblock to
0. Just use p_fragblock = 0 as in all other initializations of
p_fragblock.

No functional change.

17 months agoDo not grab the `vmmaplk' recursively, prevent a self-deadlock.
mpi [Sat, 20 May 2023 12:48:36 +0000 (12:48 +0000)]
Do not grab the `vmmaplk' recursively, prevent a self-deadlock.

Change the semantic of vm_map_busy() to be able to completely unlock the
`vmmaplk' instead of downgrading it to a read lock in mlock(2).  This is
necessary because uvm_fault_wire() tries to re-grab the same lock.

We now keep track of the thread currently holding the vmmap busy to ensure
it can relock & unbusy the vmmap.  The new pattern becomes:

....vm_map_lock(map);
....vm_map_busy(map); /* prevent other threads to grab an exclusive lock */
....vm_map_unlock(map);
....
..../*
.... * Do some stuff generally requiring a tsleep(9).
.... */
....
....vm_map_lock(map);
....vm_map_unbusy(map); /* allow other threads to make progress after unlock */
....vm_map_unlock(map);

Fix adapted from NetBSD's r1.249 of uvm/uvm_map.c.  Issue reported by
Jacqueline Jolicoeur exposed by a "wallet refresh" of the Monero App.
Panic hand-copied below:

sleep_finish()
rw_enter()
uvmfault_lookup()
uvm_fault_check()
uvm_fault()
uvm_fault_wire()
uvm_map_pageable_wire()
sys_mlock()

This version skips bumping the map's timestamp if the lock is acquired by the
thread marked the VM map busy.  This prevents a KASSERT() reported by bluhm@
triggered by regress/misc/posixtestsuite conformance/interfaces/mmap/18-1

ok kettenis@

17 months agoAdd a slow regress target that runs openssl speed with proper alignment
tb [Sat, 20 May 2023 12:07:21 +0000 (12:07 +0000)]
Add a slow regress target that runs openssl speed with proper alignment
and with an unaligned offset. Let's see if all ciphers on our strict
alignment arches can deal with this.

17 months agoopenssl speed: add an '-unaligned n' option
tb [Sat, 20 May 2023 12:03:02 +0000 (12:03 +0000)]
openssl speed: add an '-unaligned n' option

All hashes and ciphers covered by speed should be able to handle unaligned
input and output. The buffers used in openssl speed are well aligned since
they are large, so will never exercise the more problematic unaligned case.

I wished something like this was available on various occasions. It would
have been useful to point more easily at OpenSSL's broken T4 assembly.
Yesterday there were two independent reasons for wanting it, so I sat down
and did it. It's trivial: make the allocations a bit larger and use buffers
starting at an offset inside these allocations. Despite the trivality, I
managed to have a stupid bug. Thanks miod.

discussed with jsing
ok miod

17 months agoImplement battery charge control.
kettenis [Sat, 20 May 2023 12:02:46 +0000 (12:02 +0000)]
Implement battery charge control.

ok patrick@

17 months agoopenssl speed: minor style nits
tb [Sat, 20 May 2023 11:44:15 +0000 (11:44 +0000)]
openssl speed: minor style nits

This drops a bunch of unnecessary parentheses, makes the strcmp()
checks consistent and moves some "}\n\telse" to "} else".

Makes an upcoming commit smaller

17 months agoDon't bother setting the effective group, it doesn't affect file creation
espie [Sat, 20 May 2023 09:30:57 +0000 (09:30 +0000)]
Don't bother setting the effective group, it doesn't affect file creation
on a BSD system anyhow (duh moment, thx semarie@)

17 months agoopenssl speed: remove binary curve remnants
tb [Sat, 20 May 2023 05:42:57 +0000 (05:42 +0000)]
openssl speed: remove binary curve remnants

This wasn't properly hidden under OPENSSL_NO_EC2M, and all it does now
is producing ugly errors and useless "statistics". While looking at this,
I found that much of speed "has been pilfered from [Eric A. Young's]
libdes speed.c program". Apparently this was an precursor and ingredient
of SSLeay. Unfortunately, it seems that this piece of the history is lost.

ok miod

PS: If anyone is bored, a rewrite from scratch of the speed 'app' would
be a welcome contribution and may be an instructive rainy day project.
The current code was written in about the most stupid way possible so as
to maximize fragility and unmaintainability.

17 months agoAdd qcsmptp(4), a driver to share 32-bit values between (co-)processors.
patrick [Fri, 19 May 2023 21:26:09 +0000 (21:26 +0000)]
Add qcsmptp(4), a driver to share 32-bit values between (co-)processors.

The inbound path is typically used as interrupt controller, e.g. to handle
handover and ready interrupts when a remoteproc boots.  The outbound path
seems to be used to stop cores, but we don't do that yet.

ok kettenis@

17 months agoHave mainbus attach nodes under /reserved-memory, so that qcsmem(4) shows
patrick [Fri, 19 May 2023 21:15:16 +0000 (21:15 +0000)]
Have mainbus attach nodes under /reserved-memory, so that qcsmem(4) shows
up.

ok kettenis@ drahn@

17 months agoAdd qcsmem(4), a driver for the shared memory table on Qualcomm SoCs
patrick [Fri, 19 May 2023 21:13:49 +0000 (21:13 +0000)]
Add qcsmem(4), a driver for the shared memory table on Qualcomm SoCs
used to establish data communication channels with co-processors.

ok kettenis@ drahn@

17 months agoClear interrupt before executing the interrupt handler as we otherwise
patrick [Fri, 19 May 2023 20:54:55 +0000 (20:54 +0000)]
Clear interrupt before executing the interrupt handler as we otherwise
risk losing an interrupt for the same pin.  This can happen when a second
interrupt occurs between the interrupt handler's execution and us clearing
the interrupt.

ok kettenis@

17 months agouvm_coredump(9) was removed in 2015 (commitid dNPv28CJI5BxtRGW) as
guenther [Fri, 19 May 2023 18:43:16 +0000 (18:43 +0000)]
uvm_coredump(9) was removed in 2015 (commitid dNPv28CJI5BxtRGW) as
real processes have been dumped using uvm_coredump_walkmap(9) since
2009-03-05Z19:52:24.  Document the current API.

17 months agoAdd missing rsa_security_bit() handler to the RSA-PSS ASN1_METHOD
tb [Fri, 19 May 2023 17:31:20 +0000 (17:31 +0000)]
Add missing rsa_security_bit() handler to the RSA-PSS ASN1_METHOD

Prompted by a report by Steffen Ullrich on libressl@openbsd.org

ok jsing

17 months agofix markup for `maildir' in smtpd.conf(5)
op [Fri, 19 May 2023 15:18:06 +0000 (15:18 +0000)]
fix markup for `maildir' in smtpd.conf(5)

pathname and junk are both optional, but indipendently so.

ok aisha, millert

17 months agoAdd format for server_sessions, from Magnus Gross.
nicm [Fri, 19 May 2023 07:46:34 +0000 (07:46 +0000)]
Add format for server_sessions, from Magnus Gross.

17 months agomake Paths fully OO, as it makes some things simpler
espie [Fri, 19 May 2023 07:37:11 +0000 (07:37 +0000)]
make Paths fully OO, as it makes some things simpler

17 months agothis parameter does not exist
espie [Fri, 19 May 2023 07:30:40 +0000 (07:30 +0000)]
this parameter does not exist

17 months agoremove indirect calls
espie [Fri, 19 May 2023 07:25:16 +0000 (07:25 +0000)]
remove indirect calls

17 months agoSince waitid(2) shares code with wait4(2) and doesn't expose any
guenther [Fri, 19 May 2023 01:12:23 +0000 (01:12 +0000)]
Since waitid(2) shares code with wait4(2) and doesn't expose any
non-trivial new information or code-paths over wait4(), include
it in pledge("stdio")

discussed with deraadt@

17 months agoMove tcp_info structure to be under '#if __BSD_VISIBLE' to repair
guenther [Fri, 19 May 2023 01:04:39 +0000 (01:04 +0000)]
Move tcp_info structure to be under '#if __BSD_VISIBLE' to repair
compliance with POSIX/SUS restrictions on <netinet/tcp.h>

ok bluhm@
ports testing and ok sthen@

17 months agobackout alignment changes (breaking at least two architectures)
deraadt [Fri, 19 May 2023 00:54:27 +0000 (00:54 +0000)]
backout alignment changes (breaking at least two architectures)

17 months agouser: handle paths with whitespace / metacharacters
millert [Thu, 18 May 2023 18:29:28 +0000 (18:29 +0000)]
user: handle paths with whitespace / metacharacters
Use execv(3) instead of system(3) to run external commands.
This avoids problems with whitespace and shell metacharacters
in path names.  OK op@

17 months agoIf you disable retpolineplt then _dl_bind_start is called with an
guenther [Thu, 18 May 2023 16:33:39 +0000 (16:33 +0000)]
If you disable retpolineplt then _dl_bind_start is called with an
indirect branch, so include an endbr64 Just In Case.

ok deraadt@

17 months agoadjust style to post v5.36 world
espie [Thu, 18 May 2023 16:30:01 +0000 (16:30 +0000)]
adjust style to post v5.36 world

17 months agomemmove() entry point is declared with NENTRY() and isn't consecutive
guenther [Thu, 18 May 2023 16:14:05 +0000 (16:14 +0000)]
memmove() entry point is declared with NENTRY() and isn't consecutive
with an ENTRY(), so it needs its own endbr64 for IBT

ok deraadt@

17 months agoAdd PROTO_NORMAL() declarations for the remaining syscalls, to avoid
guenther [Thu, 18 May 2023 16:11:09 +0000 (16:11 +0000)]
Add PROTO_NORMAL() declarations for the remaining syscalls, to avoid
future, inadvertant PLT entries.  Move the __getcwd and __realpath
declarations to hidden/{stdlib,unistd}.h to consolidate and remove
duplication.

ok tb@ otto@ deraadt@

17 months agoAdd PROTO_NORMAL() declarations for utrace (and ktrace) syscalls
guenther [Thu, 18 May 2023 16:07:12 +0000 (16:07 +0000)]
Add PROTO_NORMAL() declarations for utrace (and ktrace) syscalls
so that the internal call can't be interposed over by the app.

ok tb@ otto@ deraadt@

17 months agoAssert pf lock on interface handling
kn [Thu, 18 May 2023 14:11:18 +0000 (14:11 +0000)]
Assert pf lock on interface handling

Make sure that all hooks into pf's internal list of interfaces do happen
with the pf lock held, i.e. nothing relies on the net lock alone, so that
later unlocking can then rely on it.

Full i386 regress (thanks bluhm) and daily usage are fine
OK sashan

17 months agosc_st_mtx is not sufficient protection to move state around
sashan [Thu, 18 May 2023 12:10:04 +0000 (12:10 +0000)]
sc_st_mtx is not sufficient protection to move state around
pfsync(4) queues. We also need to grab pf_state::mtx to put/remove
state instance safely from pfsync(4) queue. The issue has been
pointed out by bluhm@. Patch survived testing done by hrvoje@

OK dlg@

17 months agoregen
mvs [Thu, 18 May 2023 10:24:28 +0000 (10:24 +0000)]
regen

17 months agoBackout sysctl(2) unlocking. Lock order issue was triggered in UVM
mvs [Thu, 18 May 2023 10:23:19 +0000 (10:23 +0000)]
Backout sysctl(2) unlocking. Lock order issue was triggered in UVM
layer.

17 months agoRevert ip_sysctl() unlocking. Lock order issue was triggered in UVM
mvs [Thu, 18 May 2023 09:59:43 +0000 (09:59 +0000)]
Revert ip_sysctl() unlocking. Lock order issue was triggered in UVM
layer.

17 months agoUse TSO offloading in ix(4).
jan [Thu, 18 May 2023 08:22:37 +0000 (08:22 +0000)]
Use TSO offloading in ix(4).

With a lot of tweaks, improvements and testing from bluhm.

Thanks to Hrvoje Popovski from the University of Zagreb for
his great testing effort to make this happen.

ok bluhm

17 months agoMake two corrections to the vfork(2) stub:
guenther [Thu, 18 May 2023 04:26:06 +0000 (04:26 +0000)]
Make two corrections to the vfork(2) stub:
 * with IBT, it can't return via an indirect jump as that would
   require the *caller* to have an endbr64
 * to support a potential vmspace-sharing implementation, keep the
   retguard value in an arg register across the underlying syscall

ok kettenis@ deraadt@

17 months agoAdd qcmtx(4), a driver for the hardware spinlock on Qualcomm SoCs that
patrick [Wed, 17 May 2023 23:30:58 +0000 (23:30 +0000)]
Add qcmtx(4), a driver for the hardware spinlock on Qualcomm SoCs that
is used to synchronize access to the shared memory table between the
application cores we run on and the co-processors next to us.

ok kettenis@ drahn@

17 months agoAdd a framework for hardware locks.
patrick [Wed, 17 May 2023 23:25:45 +0000 (23:25 +0000)]
Add a framework for hardware locks.

ok kettenis@ drahn@

17 months agoAdd qcipcc(4), a driver for the inter-processor mailbox interface used
patrick [Wed, 17 May 2023 23:18:59 +0000 (23:18 +0000)]
Add qcipcc(4), a driver for the inter-processor mailbox interface used
to inform (and get informed) of changes to shared memory state.

ok kettenis@

17 months agoAdd support for the Peripheral Authentication Service SMC interface.
patrick [Wed, 17 May 2023 23:12:04 +0000 (23:12 +0000)]
Add support for the Peripheral Authentication Service SMC interface.
These are used to authenticate and boot firmware images on the many
coprocessors embedded in Qualcomm SoCs.

ok kettenis@

17 months agoImplement battery management sysctl. This will provide a set of sysctls
kettenis [Wed, 17 May 2023 22:12:51 +0000 (22:12 +0000)]
Implement battery management sysctl.  This will provide a set of sysctls
to control the charging of laptop batteries:

* hw.battery.chargemode (int)

  -1: force discharge
   0: inhibit charge
   1: auto

In auto mode charging may be controlled by:

* hw.battery.chargestop (int)

  Percentage (0-100) of last full capacity at which the battery should
  stop charging.

* hw.battery.chargestart (int)

  Percentage (0-100) of last full capacity at which the battery should
  start charging.

The idea is that with

  hw.battery.chargemode=1
  hw.battery.chargestop=80
  hw.battery.chargestart=75

the battery would be kept charged within the range between 75% and 80%.

Allowable settings and some details of the behavior may differ between
hardware implementations.

Committing this early to easy testing of further diffs that implement this
functionality in acpithinkpad(4) and aplsmc(4).

ok kn@

17 months agoTolerate difference in some of the features advertised by the
kettenis [Wed, 17 May 2023 21:45:41 +0000 (21:45 +0000)]
Tolerate difference in some of the features advertised by the
ID_AA64PFR0_EL1 register across cores.  The CSV2/CSV3 features are handled
on a per-core basis so it is fine if they are different.  And we only
support 64-bit userland so it is fine if the EL0/EL1/EL2/EL3 fields are
different too.

This prevents us from printing a warning on the Rockchip RK3588 SoC which
combines Cortex-A55 with Cortex-A76 that implement a sightly different
feature set.

ok deraadt@, mlarkin@

17 months agofix -n
espie [Wed, 17 May 2023 21:15:03 +0000 (21:15 +0000)]
fix -n

17 months agoLenovo x13s requires a Qualcomm firmware file which is 13.7MB, so increase
patrick [Wed, 17 May 2023 20:23:14 +0000 (20:23 +0000)]
Lenovo x13s requires a Qualcomm firmware file which is 13.7MB, so increase
the limit from 5MB to 15MB.

What does it contain?  A full copy of Windows VM framework?  For now, we
need it to read the battery status...

"go for it" deraadt@

17 months agostop using old-style prototypes except where strictly necessary
espie [Wed, 17 May 2023 15:51:58 +0000 (15:51 +0000)]
stop using old-style prototypes except where strictly necessary
(for try/catch)

signatures will be much more powerful once I move to 5.36

17 months agoactually fix caching for release/stable
espie [Wed, 17 May 2023 15:45:36 +0000 (15:45 +0000)]
actually fix caching for release/stable
$r2 computation was wrong, led to an undef, which autovivification promptly
masked

17 months agoMake function and symmetry obvious by renaming PRT_make() to
krw [Wed, 17 May 2023 12:59:37 +0000 (12:59 +0000)]
Make function and symmetry obvious by renaming PRT_make() to
PRT_prt_to_dp() and PRT_parse() to PRT_dp_to_prt().

No functional change.

17 months agofix stoeplitz_hash_h32.
dlg [Wed, 17 May 2023 10:22:17 +0000 (10:22 +0000)]
fix stoeplitz_hash_h32.

discussed with and ok tb@

17 months agoUse crypto_internal.h's CTASSERT()
tb [Wed, 17 May 2023 07:42:38 +0000 (07:42 +0000)]
Use crypto_internal.h's CTASSERT()

Now that this macro is available in a header, let's use that version
rather than copies in several .c files.

discussed with jsing

17 months agoClean up alignment handling for SHA-512.
jsing [Wed, 17 May 2023 06:37:14 +0000 (06:37 +0000)]
Clean up alignment handling for SHA-512.

All assembly implementations are required to perform their own alignment
handling. In the case of the C implementation, on strict alignment
platforms, unaligned data will be copied into an aligned buffer. However,
most platforms then perform byte-by-byte reads (via the PULL64 macros).

Instead, remove SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA and alignment
handling to sha512_block_data_order() - if the data is aligned then simply
perform 64 bit loads and then do endian conversion via be64toh(). If the
data is unaligned then use memcpy() and be64toh() (in the form of
crypto_load_be64toh()). Overall this reduces complexity and can improve
performance (on aarch64 we get a ~10% performance gain with aligned input
and about ~1-2% gain on armv7), while the same movq/bswapq is generated
for amd64 and movl/bswapl for i386.

ok tb@

17 months agoadd LTESTS_FROM variable to allow skipping of tests up to a specific
djm [Wed, 17 May 2023 05:52:01 +0000 (05:52 +0000)]
add LTESTS_FROM variable to allow skipping of tests up to a specific
point. e.g. "make LTESTS_FROM=t-sftp" will only run the sftp.sh test
and subsequent ones. ok dtucker@

17 months agoAdd support for disassembling CET (including endbr64), XSS, OSPKE,
guenther [Wed, 17 May 2023 01:57:15 +0000 (01:57 +0000)]
Add support for disassembling CET (including endbr64), XSS, OSPKE,
clflushopt, clwb, ptwrite, rdpid, serialize, WAITPKG, and vmfunc
extensions, as well as part of TSX.  tpause and umonitor addr size
handling isn't 100% correct, but good enough to get the instruction
boundary.

Correct decoding of rex64 {fxsave,fxrstor,xsave,xrstor,xsaveopt}
to instead use a '64' suffix, ala "fxsave64".

"good enough" ok kettenis@ deraadt@ mlarkin@

17 months agouseradd: use "cp" instead of "pax" to copy dot files
millert [Tue, 16 May 2023 21:28:46 +0000 (21:28 +0000)]
useradd: use "cp" instead of "pax" to copy dot files
There are some minor semantic differences but nothing that should
affect files in /etc/skel.  OK op@

17 months agoadd net.inet.tcp.tso;
jmc [Tue, 16 May 2023 21:13:19 +0000 (21:13 +0000)]
add net.inet.tcp.tso;
ok jan bluhm

17 months agoAlways set maximum queue length to passed in the IFQCTL_MAXLEN case.
mvs [Tue, 16 May 2023 20:09:27 +0000 (20:09 +0000)]
Always set maximum queue length to passed in the IFQCTL_MAXLEN case.
This is not the fast path, so dropping mq->mq_maxlen check doesn't
introduce any performance impact, but makes code MP consistent.

Discussed with and ok from bluhm@

17 months agoReplace tab by space after #define in PR_* definitions.
mvs [Tue, 16 May 2023 19:44:55 +0000 (19:44 +0000)]
Replace tab by space after #define in PR_* definitions.

ok bluhm@

17 months agoIntroduce temporary PR_MPSYSCTL flag to mark (*pr_sysctl)() handler MP
mvs [Tue, 16 May 2023 19:36:00 +0000 (19:36 +0000)]
Introduce temporary PR_MPSYSCTL flag to mark (*pr_sysctl)() handler MP
safe. We have may of them, so use flag instead of pushing kernel lock
within.

Unlock ip_sysctl(). Still take kernel lock within IPCTL_MRTSTATS case.
It looks like `mrtstat' protection is inconsistent, so keep locking as
it was. Since `mrtstat' are counters, it make sense to rework them into
per CPU counters with separate diffs.

Feedback and ok from bluhm@

17 months agoecdhtest: check malloc() return values
tb [Tue, 16 May 2023 18:41:18 +0000 (18:41 +0000)]
ecdhtest: check malloc() return values

From Ilya Chipitsine

17 months agosome fatal -> fatalx to improved logging
op [Tue, 16 May 2023 17:48:52 +0000 (17:48 +0000)]
some fatal -> fatalx to improved logging

errno doesn't generally contains anything useful after libtls functions,
and in most cases it's explicitly cleared to avoid misuse, so change a
few fatal() calls to fatalx() when logging libtls failures.  Also, add
the real error string, via tls_error() or tls_config_error(), that was
missing before.

ok millert@

17 months agoRRDP snapshots should encode publish elements only once. If encountered
claudio [Tue, 16 May 2023 17:01:31 +0000 (17:01 +0000)]
RRDP snapshots should encode publish elements only once. If encountered
fail the transfer and fall back to rsync.

When more than one publish element for the same file exist the RP does
not know which one to choose. Lets fail the RRDP transfer in this case
and fall back to rsync. CA that publish a file more than once are buggy
and need to be fixed.
OK job@ tb@

17 months agoexplicitly rename internal methods with an _
espie [Tue, 16 May 2023 16:55:32 +0000 (16:55 +0000)]
explicitly rename internal methods with an _

17 months agoclean visible interface a bit: Ustar does not use errsay (but ArcCheck does)
espie [Tue, 16 May 2023 16:45:04 +0000 (16:45 +0000)]
clean visible interface a bit: Ustar does not use errsay (but ArcCheck does)
and having a forwarder for system for ONE use is a bit much !