openbsd
23 months agoRemove xy/xd. SMD left with sparc.
krw [Wed, 9 Nov 2022 19:35:23 +0000 (19:35 +0000)]
Remove xy/xd. SMD left with sparc.

ok kn@ deraadt@

23 months agoMove input/output configuration into the correct function.
patrick [Wed, 9 Nov 2022 19:25:50 +0000 (19:25 +0000)]
Move input/output configuration into the correct function.

23 months agoImplement wakeup interrupt support. For now this is only implemented for
kettenis [Wed, 9 Nov 2022 19:18:11 +0000 (19:18 +0000)]
Implement wakeup interrupt support.  For now this is only implemented for
aplintc(4); other arm64 interrupt controllers will follow.

ok patrick@

23 months agoFix up indentation for EVP_PKEY_* defines.
jsing [Wed, 9 Nov 2022 19:18:08 +0000 (19:18 +0000)]
Fix up indentation for EVP_PKEY_* defines.

23 months agonreq could leak a http get request in case a redirect without
mbuhl [Wed, 9 Nov 2022 19:11:14 +0000 (19:11 +0000)]
nreq could leak a http get request in case a redirect without
location header was received.
OK deraadt

23 months agoRevise CBS_strdup() documentation.
jsing [Wed, 9 Nov 2022 19:05:42 +0000 (19:05 +0000)]
Revise CBS_strdup() documentation.

CBS_strdup() now internally checks if the data contains NUL, failing if it
does.

Prompted by beck@

23 months agoIn do_zzz a garbage stack value could be accessed in case a read
mbuhl [Wed, 9 Nov 2022 18:48:11 +0000 (18:48 +0000)]
In do_zzz a garbage stack value could be accessed in case a read
or write in send_command failed.
Found by codechecker.
OK deraadt

23 months agoRemove xy/xd. SMD left with sparc.
krw [Wed, 9 Nov 2022 18:46:04 +0000 (18:46 +0000)]
Remove xy/xd. SMD left with sparc.

ok kn@ deraadt@

23 months agodlopen() with RTLD_NODELETE should also set the object nodelete flag,
deraadt [Wed, 9 Nov 2022 18:44:11 +0000 (18:44 +0000)]
dlopen() with RTLD_NODELETE should also set the object nodelete flag,
so the mapping layer will know it can use mimmutable()

23 months agoSince the introduction of automatic immutable from the kernel, the munmap()
deraadt [Wed, 9 Nov 2022 18:39:35 +0000 (18:39 +0000)]
Since the introduction of automatic immutable from the kernel, the munmap()
of ld.so boot.text region is now (silently) failing because the region is
contained within the text LOAD, which is immutable.  So create a new btext
LOAD with flags PF_X|PF_R|PF_OPENBSD_MUTABLE, and place all boot.text objects
in there.  This LOAD must also be page-aligned so it doesn't skip unmapping
some of the object region, previously it was hilariously unaligned.
ok kettenis and guenther seemed to like it also
This one is for 32-bit arm, tested by phessler

23 months agoClean up EVP_PKEY_METHOD related tables and code.
jsing [Wed, 9 Nov 2022 18:25:36 +0000 (18:25 +0000)]
Clean up EVP_PKEY_METHOD related tables and code.

This is effectively the same as done for EVP_PKEY_ASN1_METHOD, although
this table only has nine entries.

ok tb@

23 months agoError out if a ROA payload contains too many ipAddrBlocks
job [Wed, 9 Nov 2022 18:17:23 +0000 (18:17 +0000)]
Error out if a ROA payload contains too many ipAddrBlocks

The ASN.1 profile in draft-ietf-sidrops-rfc6482bis section 4 specifies
that there must not be more than 2 ipAddrBlocks (one for IPv4, and one
for IPv6). Compatible with all published ROAs.

OK tb@

23 months agoClean up EVP_PKEY_ASN1_METHOD related tables and code.
jsing [Wed, 9 Nov 2022 18:17:16 +0000 (18:17 +0000)]
Clean up EVP_PKEY_ASN1_METHOD related tables and code.

Rather than messing around with an OBJ_bsearch() for a table that contains
16 entries (and a stack find for any application added methods), simply do
a reverse linear scan. This maintains the application method first
behaviour, while removing a chunk of code.

While here rename some variables and do some style clean up.

ok tb@

23 months agoAdd suspend/resume support to aplns(4).
kettenis [Wed, 9 Nov 2022 18:17:00 +0000 (18:17 +0000)]
Add suspend/resume support to aplns(4).

ok dlg@, patrick@

23 months agoSimplify the overly complex VXLOCK handling in spec_close.
claudio [Wed, 9 Nov 2022 18:12:47 +0000 (18:12 +0000)]
Simplify the overly complex VXLOCK handling in spec_close.
The code only needs to know if the vnode is exclusive locked and this
can be done on entry of the function.
OK mpi@

23 months agoAdd tests for boundary conditions of struct tm.
beck [Wed, 9 Nov 2022 18:11:45 +0000 (18:11 +0000)]
Add tests for boundary conditions of struct tm.

Struct tm is limited by it's year being an int.

23 months agondp, route, netstat: adjust ipv6 address width
kn [Wed, 9 Nov 2022 18:00:02 +0000 (18:00 +0000)]
ndp, route, netstat: adjust ipv6 address width

It has been annoying me for too long that fully specififed GUAs
(2001:0db8:3333:4444:5555:6666:7777:8888) mess up alignment.

systat(1)'s netstat is the only view that has a big enough limit and thus
never misaligns.

Unify ndp(8), route(8) and netstat(1) views to always align nicely.

Feedback OK claudio

23 months agovmm(4): treat vcpu lists as immutable, reducing complexity.
dv [Wed, 9 Nov 2022 17:53:12 +0000 (17:53 +0000)]
vmm(4): treat vcpu lists as immutable, reducing complexity.

Since vmm doesn't support hot-plug vcpus we can reduce complexity
by treating the vcpu list per vm as immutable after creation.

As a consequence, we can use the vm reference count to protect the
lifetime of the vcpus, removing the need for reference counting
individual vcpu objects. With an immutable list, we no longer need
a rwlock protecting it either.

Original diff from dlg@ that I reworked and tested.

ok dlg@, mlarkin@

23 months agoRevise ED25519 regress following API changes.
jsing [Wed, 9 Nov 2022 17:49:54 +0000 (17:49 +0000)]
Revise ED25519 regress following API changes.

23 months agoMake X25519_public_from_private() internally reachable.
jsing [Wed, 9 Nov 2022 17:45:55 +0000 (17:45 +0000)]
Make X25519_public_from_private() internally reachable.

23 months agoBefore printing the redirect URI pass it through stravis since it is
claudio [Wed, 9 Nov 2022 17:41:05 +0000 (17:41 +0000)]
Before printing the redirect URI pass it through stravis since it is
untrusted input.
OK tb@ kn@ millert@

23 months agoRename public_value to public_key for consistency.
jsing [Wed, 9 Nov 2022 17:40:51 +0000 (17:40 +0000)]
Rename public_value to public_key for consistency.

ok tb@

23 months agoRework ED25519 API.
jsing [Wed, 9 Nov 2022 17:39:29 +0000 (17:39 +0000)]
Rework ED25519 API.

BoringSSL implemented a compound private key, which includes a copy of the
public key as a performance optimisation for signing. However, this does
not readily match with how EVP works, makes the ED25519 API inconsistent
with the X25519 API, diverges from th RFC and does not align with the
OpenSSL API. Instead, the caller can readily compute the public key and
pass this in to the signing process.

ok tb@

23 months agoAdd some regress coverage for EVP_PKEY_METHOD.
jsing [Wed, 9 Nov 2022 17:15:59 +0000 (17:15 +0000)]
Add some regress coverage for EVP_PKEY_METHOD.

23 months agotimeout(9): remove TIMEOUT_KCLOCK flag
cheloha [Wed, 9 Nov 2022 17:12:50 +0000 (17:12 +0000)]
timeout(9): remove TIMEOUT_KCLOCK flag

I never should have added the TIMEOUT_KCLOCK flag.  It is redundant
and only serves to complicate the timeout(9) logic.  In every place
where we check for the flag we can just use timeout.to_kclock.

So, remove the flag from <sys/timeout.h> and rewrite all affected
logic to use the value of timeout.to_kclock instead.

ok kn@

23 months agoSort EVP_PKEY_METHOD externs.
jsing [Wed, 9 Nov 2022 17:03:53 +0000 (17:03 +0000)]
Sort EVP_PKEY_METHOD externs.

23 months agoStrip spaces at end of header lines and in chunked encoding headers.
claudio [Wed, 9 Nov 2022 16:29:58 +0000 (16:29 +0000)]
Strip spaces at end of header lines and in chunked encoding headers.
HTTP standard allows for spaces in too many places
OK millert@ tb@

23 months agoMake aplpmgr(4) work as a reset controller.
kettenis [Wed, 9 Nov 2022 16:23:51 +0000 (16:23 +0000)]
Make aplpmgr(4) work as a reset controller.

ok patrick@

23 months agoSort EVP_PKEY_ASN1_METHOD externs.
jsing [Wed, 9 Nov 2022 16:14:15 +0000 (16:14 +0000)]
Sort EVP_PKEY_ASN1_METHOD externs.

23 months agoAdd some regress coverage for EVP_PKEY_ASN1_METHOD
jsing [Wed, 9 Nov 2022 16:13:39 +0000 (16:13 +0000)]
Add some regress coverage for EVP_PKEY_ASN1_METHOD

23 months agoInline use of bn_is_prime_bpsw()
tb [Wed, 9 Nov 2022 15:33:13 +0000 (15:33 +0000)]
Inline use of bn_is_prime_bpsw()

Instead of using the BN_is_prime_fasttime_ex() API, use a direct call to
bn_is_prime_bpsw(). This increases readability and simplifies error
handling. Also put a division by two to the natural place now that we no
longer need to do Miller-Rabin rounds.

ok beck jsing

23 months agoUse nitems() instead of a terminating { NULL, NULL } entry.
krw [Wed, 9 Nov 2022 15:17:28 +0000 (15:17 +0000)]
Use nitems() instead of a terminating { NULL, NULL } entry.

23 months agoAdd missin 'e' in comment.
claudio [Wed, 9 Nov 2022 15:01:24 +0000 (15:01 +0000)]
Add missin 'e' in comment.
OK dlg@

23 months agoEnable l3vpn test
claudio [Wed, 9 Nov 2022 14:31:31 +0000 (14:31 +0000)]
Enable l3vpn test

23 months agoProperly handle L3VPN routes in kroute. This got broken while reworking
claudio [Wed, 9 Nov 2022 14:26:14 +0000 (14:26 +0000)]
Properly handle L3VPN routes in kroute. This got broken while reworking
large part of the code.
Issue reported and fix tested by Bars Bars tutbaranov (at) gmail.com
OK tb@

23 months agoFix nlri parsing of L3VPN prefixes in withdrawals.
claudio [Wed, 9 Nov 2022 14:23:53 +0000 (14:23 +0000)]
Fix nlri parsing of L3VPN prefixes in withdrawals.

L3VPN NLRI have different encoding for updates and withdraws. The withdraw
carries one dummy MPLS label that needs to be skipped. The code doing that
did adjust the lenght but did not skip the the label in the buffer and so
the parsed prefix was off by 3 bytes.
OK tb@

23 months agoShow the MPLS label of a L3VPN route in show fib output.
claudio [Wed, 9 Nov 2022 14:20:11 +0000 (14:20 +0000)]
Show the MPLS label of a L3VPN route in show fib output.
OK tb@

23 months agoImplement reading/writing pins on qcpmicgpio(4).
patrick [Wed, 9 Nov 2022 13:46:11 +0000 (13:46 +0000)]
Implement reading/writing pins on qcpmicgpio(4).

23 months agoRecommit r1.669 "Unlock SIOCIFGCLONERS"
kn [Wed, 9 Nov 2022 13:09:30 +0000 (13:09 +0000)]
Recommit r1.669 "Unlock SIOCIFGCLONERS"

OK mvs

23 months agoPush kernel lock from ifioctl() into ifioctl_get()
kn [Wed, 9 Nov 2022 13:08:36 +0000 (13:08 +0000)]
Push kernel lock from ifioctl() into ifioctl_get()

Recommit these two together:
- r1.667 "Push kernel lock into ifioctl_get()"
  locked before the switch() without unlocking in its cases
- r1.668 "Push kernel lock inside ifioctl_get()"
  locked cases individually, as intended

I messed up splitting commits, but of course, Hrvoje managed to test a
CVS checkout right inbetween those two.

OK mpi mvs

23 months agoRemove unnecessary sizeof
joshua [Wed, 9 Nov 2022 12:13:08 +0000 (12:13 +0000)]
Remove unnecessary sizeof

ok jsing@ tb@

23 months agoRemove unnecessary sizeof
joshua [Wed, 9 Nov 2022 12:10:17 +0000 (12:10 +0000)]
Remove unnecessary sizeof

ok jsing@ tb@

23 months agoNext pass of bn_prime.c cleanup
tb [Wed, 9 Nov 2022 11:31:51 +0000 (11:31 +0000)]
Next pass of bn_prime.c cleanup

Garbage collect a few pointless variables and remove a loop that wasn't
really a loop. Simplify BN_CTX handling and drop some stupid comments.

ok jsing miod

23 months agoreplace SRP with SMR in the if_idxmap.
dlg [Wed, 9 Nov 2022 10:41:18 +0000 (10:41 +0000)]
replace SRP with SMR in the if_idxmap.

when i first wrote if_idxmap i didn't realise (and no one thought
to tell me) that index 0 was special and means "no interface", so
while here use the 0th slot in the interface map to store the length
of the map instead of prepending the map with a length field.
if_get() now special cases index 0 and returns NULL directly. this
also means the size of the map is now always a power of 2, which
is a nicer fit with what the kernel malloc aprovides.

tweaks and ok visa@

23 months agoregen
mpi [Wed, 9 Nov 2022 10:27:01 +0000 (10:27 +0000)]
regen

23 months agogpt_get_fstype() doesn't modify its parameter so make said
krw [Wed, 9 Nov 2022 10:26:37 +0000 (10:26 +0000)]
gpt_get_fstype() doesn't modify its parameter so make said
parameter const.

23 months agoMark sched_yield(2) as NOLOCK.
mpi [Wed, 9 Nov 2022 10:26:28 +0000 (10:26 +0000)]
Mark sched_yield(2) as NOLOCK.

All the fields accessed in this syscall are protected by the SCHED_LOCK()
so it isn't necessary to wait for another CPU to release the KERNEL_LOCK()
before that.

ok claudio@

23 months agoadd an example for adding a cloning host route to reach a gateway which is
sthen [Wed, 9 Nov 2022 10:23:01 +0000 (10:23 +0000)]
add an example for adding a cloning host route to reach a gateway which is
outside the subnet, some hosting providers use this. info from Eric JACQUOT
ok florian kn phessler

23 months agovmm on !MULTIPROCESSOR kernels should still mark vpus with pending intrs.
dlg [Wed, 9 Nov 2022 10:19:20 +0000 (10:19 +0000)]
vmm on !MULTIPROCESSOR kernels should still mark vpus with pending intrs.

the #ifdef MULTIPROCESSOR was a little broad.

still grateful to anton and stsp for unbreaking the tree though.

23 months agodocument '=' as a pkgspec
espie [Wed, 9 Nov 2022 10:10:53 +0000 (10:10 +0000)]
document '=' as a pkgspec

23 months agotranslate Fn+(1-10,-,=) keys to F1-F12 on M1 laptops with a touchbar
robert [Wed, 9 Nov 2022 10:05:18 +0000 (10:05 +0000)]
translate Fn+(1-10,-,=) keys to F1-F12 on M1 laptops with a touchbar

ok kettenis@, miod@

23 months agoregen
robert [Wed, 9 Nov 2022 10:03:22 +0000 (10:03 +0000)]
regen

23 months agoadd a USB ID for WELLSPRINGM1_J293 to be used by aplhidev(4) to identify
robert [Wed, 9 Nov 2022 10:03:04 +0000 (10:03 +0000)]
add a USB ID for WELLSPRINGM1_J293 to be used by aplhidev(4) to identify
M1 laptops with touchbars

23 months agoFix typo in fatal error message. Patch from vapier at chromium.org.
dtucker [Wed, 9 Nov 2022 09:04:12 +0000 (09:04 +0000)]
Fix typo in fatal error message.  Patch from vapier at chromium.org.

23 months agoRemove errant colon and simplify format string in error messages.
dtucker [Wed, 9 Nov 2022 09:01:52 +0000 (09:01 +0000)]
Remove errant colon and simplify format string in error messages.
Patch from vapier at chromium.org.

23 months agoRemove old-style eeprom mentions and relevant leftover code; ok kettenis@
miod [Wed, 9 Nov 2022 07:20:12 +0000 (07:20 +0000)]
Remove old-style eeprom mentions and relevant leftover code; ok kettenis@

23 months agoMinor cleanups:
miod [Wed, 9 Nov 2022 07:11:30 +0000 (07:11 +0000)]
Minor cleanups:
- remove unused pmap_vp_remove function.
- remove obviously not-applying-to-this-situation comment in
  _pmap_kenter_pa(), copied from pmap_enter() (where it is legit).
- make the PTED_xxx accessors inline.
- actually use PTED_WIRED() rather than inlining it everywhere.

ok mpi@ kettenis@

23 months agouse Fn; from josiah frentsos
jmc [Wed, 9 Nov 2022 06:48:29 +0000 (06:48 +0000)]
use Fn; from josiah frentsos

23 months agounbreak GENERIC build on amd64; patch by anton@
stsp [Wed, 9 Nov 2022 06:32:58 +0000 (06:32 +0000)]
unbreak GENERIC build on amd64; patch by anton@

vmm.c:900:3: error: implicit declaration of function 'x86_send_ipi' is
invalid in C99 [-Werror,-Wimplicit-function-declaration]

23 months agoDrop some dead code
tb [Wed, 9 Nov 2022 02:01:13 +0000 (02:01 +0000)]
Drop some dead code

ok jsing

23 months agorename client_global_hostkeys_private_confirm() to
djm [Wed, 9 Nov 2022 01:37:44 +0000 (01:37 +0000)]
rename client_global_hostkeys_private_confirm() to
client_global_hostkeys_prove_confirm(), as it handles the
"hostkeys-prove00@openssh.com" message; no functional change

23 months agoFix possible memory leak in BN_mpi2bn() if BN_bin2bn() fails.
tobhe [Wed, 9 Nov 2022 01:05:45 +0000 (01:05 +0000)]
Fix possible memory leak in BN_mpi2bn() if BN_bin2bn() fails.

found with CodeChecker
feedback from millert@
ok tb@

23 months agotypo in comment
djm [Wed, 9 Nov 2022 00:15:59 +0000 (00:15 +0000)]
typo in comment

23 months agoIn case lh_OBJ_NAME_insert returns NULL due to a failed malloc, onp
mbuhl [Tue, 8 Nov 2022 23:19:09 +0000 (23:19 +0000)]
In case lh_OBJ_NAME_insert returns NULL due to a failed malloc, onp
is leaked in OBJ_NAME_add.
ok tb
Found by CodeChecker.

23 months agoRevert lock changes inside ifioctl_get()
kn [Tue, 8 Nov 2022 21:07:33 +0000 (21:07 +0000)]
Revert lock changes inside ifioctl_get()

WITNESS isn't happy with r1.667 "Push kernel lock into ifioctl_get()", so
revert it (including r1.668 and r1.669 depending on it):

witness: userret: returning with the following locks held:
exclusive kernel_lock &kernel_lock r = 0 (0xffffffff82455f58)
#0  witness_lock+0x311
#1  ifioctl_get+0x2e
#2  sys_ioctl+0x2c4
#3  syscall+0x384
#4  Xsyscall+0x128
panic: witness_warn
Stopped at      db_enter+0x10:  popq    %rbp
    TID    PID    UID     PRFLAGS     PFLAGS  CPU  COMMAND
* 70588  52613      0         0x3          0    4K pfctl

So back to the drawing board while leaving documentation bits (r1.670).
Thanks Hrvoje.

23 months agoKNF/whitespace - no code change
mlarkin [Tue, 8 Nov 2022 20:41:36 +0000 (20:41 +0000)]
KNF/whitespace - no code change

23 months agoTedu spmi bus definition that moved over to the fdt files.
patrick [Tue, 8 Nov 2022 19:52:40 +0000 (19:52 +0000)]
Tedu spmi bus definition that moved over to the fdt files.

23 months agoHook up all those Qualcomm SoC SPMI devices.
patrick [Tue, 8 Nov 2022 19:49:34 +0000 (19:49 +0000)]
Hook up all those Qualcomm SoC SPMI devices.

23 months agoAdd qcrtc(4), a driver for the RTC found on Qualcomm PMICs. Unfortunately
patrick [Tue, 8 Nov 2022 19:47:05 +0000 (19:47 +0000)]
Add qcrtc(4), a driver for the RTC found on Qualcomm PMICs.  Unfortunately
on the Lenovo x13s it does not seem to contain the offset from 1970.  Also
we are not allowed to write to the RTC.

I was told that the offset I need to calculate the actual date is sorted in
an UEFI variable, which can be accessed over a secure channel.  So as long
as we don't have that channel, this driver is useless.  Good start though.

ok kettenis@

23 months agoAdd qcpon(4), a driver for the Qualcomm PMIC block that hosts the powerkey
patrick [Tue, 8 Nov 2022 19:44:28 +0000 (19:44 +0000)]
Add qcpon(4), a driver for the Qualcomm PMIC block that hosts the powerkey
and reset input.  With this I can use the power button on my x13s to power
off the machine.

ok kettenis@

23 months agoAdd qcpmicgpio(4), a driver for the GPIO block inside the Qualcomm PMICs.
patrick [Tue, 8 Nov 2022 19:42:10 +0000 (19:42 +0000)]
Add qcpmicgpio(4), a driver for the GPIO block inside the Qualcomm PMICs.

This driver is not completed yet, but good enough to be worked on in-tree.

ok kettenis@

23 months agoAdd qcpmic(4), a driver for the SPMI-connected PMICs found on Qualcomm SoCs,
patrick [Tue, 8 Nov 2022 19:40:08 +0000 (19:40 +0000)]
Add qcpmic(4), a driver for the SPMI-connected PMICs found on Qualcomm SoCs,
which are used on the Lenovo x13s.

This is mostly a shim.  The work for the actual blocks inside the PMICs
occurs in the children.

ok kettenis@

23 months agodon't keep track of how many vcpus are currently running.
dlg [Tue, 8 Nov 2022 19:38:34 +0000 (19:38 +0000)]
don't keep track of how many vcpus are currently running.

the number is never read anywhere, and i'm not sure what value that
number has anyway.

mlarkin@ agrees

23 months agoAdd qcspmi(4), a driver for the SPMI PMIC Arbiter found on Qualcomm SoCs,
patrick [Tue, 8 Nov 2022 19:34:54 +0000 (19:34 +0000)]
Add qcspmi(4), a driver for the SPMI PMIC Arbiter found on Qualcomm SoCs,
which is used on the Lenovo x13s.

As soon as we gain a driver for the Power Domain Controller (PDC) that acts
as a shim towards the GIC, we can switch out the timeout for proper IRQs.

ok kettenis@

23 months agoRename out to err to conform with standard naming scheme.
tobhe [Tue, 8 Nov 2022 19:19:08 +0000 (19:19 +0000)]
Rename out to err to conform with standard naming scheme.

23 months agofurther speed up delivery of interrupts to a running vcpu.
dlg [Tue, 8 Nov 2022 19:18:47 +0000 (19:18 +0000)]
further speed up delivery of interrupts to a running vcpu.

this records which physical cpu a vcpu is running on. this is used
by the code that marks a vcpu as having a pending interrupt to check
if the vcpu is currently running. if it thinks the vcpu is running,
it sends a nop IPI to the physical cpu it is running on to trigger
a vmexit, which in turn runs interrupt handling in the guest.

ok mlarkin@

23 months agoallow the KERN_AUTOCONF_SERIAL sysctl in pledge'd processes
robert [Tue, 8 Nov 2022 19:17:58 +0000 (19:17 +0000)]
allow the KERN_AUTOCONF_SERIAL sysctl in pledge'd processes

ok deraadt@

23 months agoFix leak of pk if EVP_PKEY_set1_DSA() fails.
tobhe [Tue, 8 Nov 2022 19:17:05 +0000 (19:17 +0000)]
Fix leak of pk if EVP_PKEY_set1_DSA() fails.

Found with CodeChecker
ok jsing@

23 months agotimeout(9): remove unused, undocumented timeout_in_nsec() interface
cheloha [Tue, 8 Nov 2022 19:09:53 +0000 (19:09 +0000)]
timeout(9): remove unused, undocumented timeout_in_nsec() interface

The kernel is not quite ready for timeout_in_nsec().  Remove it and
kclock_nanotime().  Both are unused.

Prompted by jsg@.

ok kn@

23 months agoEnable gpiobl(4)
tobhe [Tue, 8 Nov 2022 19:07:34 +0000 (19:07 +0000)]
Enable gpiobl(4)

23 months agoAdd gpiobl(4), a driver for gpio controlled display backlights. This will
tobhe [Tue, 8 Nov 2022 19:06:57 +0000 (19:06 +0000)]
Add gpiobl(4), a driver for gpio controlled display backlights. This will
allow us to turn off the screen on Apple Silicon laptops until we have a
proper display controller driver.

ok kettenis@ patrick@

23 months agoUse four spaces not tabs on line break
kn [Tue, 8 Nov 2022 18:47:58 +0000 (18:47 +0000)]
Use four spaces not tabs on line break

23 months agoDocument ifc_list immutability
kn [Tue, 8 Nov 2022 18:43:22 +0000 (18:43 +0000)]
Document ifc_list immutability

Move up to comment explaining different locks to account for all structs.

OK millert mvs

23 months agoImplement alternative mailbox handling mechanism required by newer firmware.
kettenis [Tue, 8 Nov 2022 18:28:10 +0000 (18:28 +0000)]
Implement alternative mailbox handling mechanism required by newer firmware.

ok patrick@

23 months agotc_setclock: don't print a warning if tc_windup() rejects inittodr(9) time
cheloha [Tue, 8 Nov 2022 18:17:51 +0000 (18:17 +0000)]
tc_setclock: don't print a warning if tc_windup() rejects inittodr(9) time

During resume, it isn't necessarily a problem if the UTC time we get
from inittodr(9) lags behind the system UTC clock.  In particular, if
the active timecounter's frequency is low enough, tc_delta() might not
overflow across a brief suspend.

Remove the misleading warning message.  The code is behaving as
intended, just not in a way I anticipated when I added the warning
message a few years ago.

Discovered by kettenis@.  Root cause isolated with kettenis@.

Link: https://marc.info/?l=openbsd-tech&m=166790845619897&w=2
ok mlarkin@ kettenis@

23 months agovmm(4): remove locking in vmm_intr_pending
mlarkin [Tue, 8 Nov 2022 18:08:43 +0000 (18:08 +0000)]
vmm(4): remove locking in vmm_intr_pending

Removes a lock around an atomic write; this lock was causing slowdowns
since the lock being requested is nearly always unavailable because it
is held while the VM is running.

Noticed by claudio@, help from mpi@, dlg@ and claudio@.

ok dv

23 months agoUnlock SIOCIFGCLONERS
kn [Tue, 8 Nov 2022 17:57:47 +0000 (17:57 +0000)]
Unlock SIOCIFGCLONERS

ifconfig(8) -C is the only user in base and the if_clone_attach() comment
explains how this list is being built during autoconf(9).

After that it is only ever read.  Multiple threads may traverse the list in
parallel and reading the `int' count is atomic.

OK mvs

23 months agoPush kernel lock inside ifioctl_get()
kn [Tue, 8 Nov 2022 17:57:14 +0000 (17:57 +0000)]
Push kernel lock inside ifioctl_get()

After this mechanical move, I can unlock the individual SIOCG* in there.

OK mvs

23 months agoarm64: switch to clockintr(9)
cheloha [Tue, 8 Nov 2022 17:56:38 +0000 (17:56 +0000)]
arm64: switch to clockintr(9)

Switch arm64 to the clockintr(9) subsystem.

- Remove the custom per-CPU clock interrupt schedule from agtimer(4).
- Remove the custom randomized statclock() pieces from agtimer(4).
- Add agtimer_rearm(), agtimer_trigger(), and wire up agtimer_intrclock.

There is one wart:

- The AArch64 spec says that a value written to CNTV_TVAL_EL0 is
  "treated as a signed 32-bit integer" [1].  kettenis@ doesn't know
  what to make of this.  I'm capping the value at INT32_MAX for
  now.  It's possible I am misreading this, though.

Tested by kettenis@ on his Apple M1 mini.  Tested by me on my
Raspberry Pi 4B.

Link: https://marc.info/?l=openbsd-tech&m=166776342503304&w=2
[1] "Arm Architecture Reference Manual for A-profile architecture"
    issue I.a, section D17.11.27 ("CNTV_TVAL_EL0").

ok kettenis@

23 months agofix indent
kn [Tue, 8 Nov 2022 17:53:01 +0000 (17:53 +0000)]
fix indent

23 months agoNuke unused variable 'freesectors'.
krw [Tue, 8 Nov 2022 17:52:11 +0000 (17:52 +0000)]
Nuke unused variable 'freesectors'.

23 months agoamd64: switch to clockintr(9)
cheloha [Tue, 8 Nov 2022 17:34:12 +0000 (17:34 +0000)]
amd64: switch to clockintr(9)

Switch amd64 to the clockintr(9) subsystem.  There are lots of little
changes, but the bigs ones are listed here.

When using the local apic timer:

- Run the timer in one-shot mode.
- lapic_delay() is gone.  We can't use it to delay(9) when running
  the timer in one-shot mode.
- Add a randomized statclock(); stathz = hz.
- Add support for switching to profhz when profiling is enabled;
  profhz = stathz * 10.

When using the i8254/mc146818:

- i8254's clockintr() no longer has a monopoly on hardclock().
- mc146818's rtcintr() no longer has a monopoly on statclock().
- In profiling mode, the statclock() will drift very slightly
  because (profhz = 1024) does not divide evenly into one billion.
  We could avoid this by setting (profhz = 512) instead and
  programming the RTC to run at that rate.

Early revisions reviewed by mlarkin@.  Extensively tested by mlarkin@
on a variety of physical and virtual hardware.  Additional testing
from dv@ and jmc@.

Link: https://marc.info/?l=openbsd-tech&m=166776339203279&w=2
ok kettenis@ mlarkin@

23 months agoRefactor/split ED25519_keypair.
jsing [Tue, 8 Nov 2022 17:07:17 +0000 (17:07 +0000)]
Refactor/split ED25519_keypair.

This brings in ED25519_keypair_from_seed() from BoringSSL commit
c034e2d3ce16, which ED25519_keypair then wraps. This reduces differences
between us and BoringSSL.

23 months agoChange function argument to reduce differences with BoringSSL.
jsing [Tue, 8 Nov 2022 17:01:57 +0000 (17:01 +0000)]
Change function argument to reduce differences with BoringSSL.

23 months agoExtent the current suspend/resume implementation to include support for
kettenis [Tue, 8 Nov 2022 16:53:40 +0000 (16:53 +0000)]
Extent the current suspend/resume implementation to include support for
parking CPUs in a WFE/WFI loop.

ok deraadt@, mlarkin@

23 months agoRemove pointless loops.
jsing [Tue, 8 Nov 2022 16:50:29 +0000 (16:50 +0000)]
Remove pointless loops.

From BoringSSL 997c706d43504.

23 months agoAvoid signed integer overflow in i2c_ASN1_BIT_STRING()
tb [Tue, 8 Nov 2022 16:48:28 +0000 (16:48 +0000)]
Avoid signed integer overflow in i2c_ASN1_BIT_STRING()

If the length of the bitstring is INT_MAX, adding 1 to it is undefined
behavior, so error out before doing so.

Based on BoringSSL eeb3333f by davidben

ok beck joshua

23 months agoThis diff fixes panic tripped by KASSERT(st->sync_state == PFSYNC_S_NONE)
sashan [Tue, 8 Nov 2022 16:20:26 +0000 (16:20 +0000)]
This diff fixes panic tripped by KASSERT(st->sync_state == PFSYNC_S_NONE)
found in pfsync_insert_state(). It is caused by two packets which happen
to belong to the same session. Think of UDP stream or two TCP SYN packets
transmitted almost simultaneously. The first such packet wins a state lock
and inserts state to table. The second packet waits for state lock
as a reader. As soon as the first packet is done with state creation
it drops the lock and is going to sent S_INS message to its peer via
pfsync. The second update meanwhile obtains the state lock as a reader.
It finds a state created by the first packet. Later the second packet
also finds out the state needs to be updated, because sync_state
is still set to PFSYNC_S_NONE. The second packet puts state to snapshot
list marking it as S_UPD. All this happens before the first packet has
a chance to make a progress. Think of the first packet loses cpu after
dropping a write lock. Once the first packet gets running again it
trips KASSERT() because sync_state is set to S_UPD.

tested by hrvoje@

OK dlg@

23 months agoPush kernel lock into ifioctl_get()
kn [Tue, 8 Nov 2022 15:20:24 +0000 (15:20 +0000)]
Push kernel lock into ifioctl_get()

Another mechanical diff without semantic changes to avoid churn in actual
unlocking diffs.

OK mpi

23 months agoacpihpet(4): disable/reenable acpihpet_delay() during suspend/resume
cheloha [Tue, 8 Nov 2022 14:54:47 +0000 (14:54 +0000)]
acpihpet(4): disable/reenable acpihpet_delay() during suspend/resume

We can't use the HPET to delay(9) after we halt it during suspend.
Disable acpihpet_delay() before we halt the HPET and reenable it after
we restart the HPET during resume.

ok mlarkin@