OpenBSD cvs log

created 2022-11-13T02:45:48Z
begin 2022-11-08T00:00:00Z
end 2022-11-09T00:00:00Z
path src/sys
commits 38

date 2022-11-08T11:05:57Z
author mpi
files src/sys/kern/syscalls.master log diff annotate
message Mark mmap(2), munmap(2) and mprotect(2) as NOLOCK.

Accesses to data structures used by these syscalls are serialized by the
VM map lock with the exception of file mappings which are still protected
by the KERNEL_LOCK().

Unlocking this set of syscalls improves most of userland workloads.

Tested by many including robert@ (since 2 years), mlarkin@, kn@, sdk@,
jca@, aoyama@, naddy@, Scott Bennett and others. Thanks to all!

Joint work with kn@.

ok robert@, aja@, kettenis@, kn@, deraadt@, beck@

date 2022-11-08T11:06:41Z
author mpi
files src/sys/kern/init_sysent.c log diff annotate
src/sys/kern/syscalls.c log diff annotate
src/sys/sys/syscall.h log diff annotate
src/sys/sys/syscallargs.h log diff annotate
message Regen

date 2022-11-08T11:25:01Z
author kn
files src/sys/kern/sys_socket.c log diff annotate
src/sys/net/if.c log diff annotate
message Push kernel lock down into ifioctl()

This is a mechanical diff without semantical changes, locking ioctls
individually inside ifioctl() rather than all of them around it.

This allows us to unlock ioctls one by one.

OK mpi

date 2022-11-08T11:40:47Z
author kettenis
files src/sys/arch/arm64/dev/aplintc.c log diff annotate
message Sprinkle some #ifdef MULTIPROCESSOR to make non-MP kernels build again.

date 2022-11-08T11:51:34Z
author patrick
files src/sys/dev/fdt/qcgpio_fdt.c log diff annotate
message Implement reading/writing/configuring pins in qcgpio(4). The code has
mostly been there, it only needed to be hooked up to our infrastructure.
With this I can e.g. correctly see the lid state on the x13s.

ok kettenis@

date 2022-11-08T14:01:13Z
author kettenis
files src/sys/arch/arm64/dev/aplintc.c log diff annotate
src/sys/arch/arm64/include/armreg.h log diff annotate
message Move definitions for CNTV_CTL_EL0 to armreg.h.

ok mpi@, jsg@, phessler@, patrick@

date 2022-11-08T14:46:51Z
author cheloha
files src/sys/arch/amd64/amd64/machdep.c log diff annotate
src/sys/arch/amd64/include/cpu.h log diff annotate
message amd64: add delay_fini()

Not all of the clocks with a delay(9) implementation necessarily keep
ticking across suspend/resume. We need a clean way to reverse
delay_init() during suspend when those clocks stop ticking.

Hence, delay_fini(). delay_fini() resets delay_func() to
i8254_delay() if the given function pointer is the active delay(9)
implementation.

ok mlarkin@

date 2022-11-08T14:49:20Z
author cheloha
files src/sys/arch/i386/i386/machdep.c log diff annotate
src/sys/arch/i386/include/cpu.h log diff annotate
message i386: add delay_fini()

Not all of the clocks with a delay(9) implementation necessarily keep
ticking across suspend/resume. We need a clean way to reverse
delay_init() during suspend when those clocks stop ticking.

Hence, delay_fini(). delay_fini() resets delay_func() to
i8254_delay() if the given function pointer is the active delay(9)
implementation.

ok mlarkin@

date 2022-11-08T14:54:47Z
author cheloha
files src/sys/dev/acpi/acpihpet.c log diff annotate
message 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@

date 2022-11-08T15:20:24Z
author kn
files src/sys/net/if.c log diff annotate
message Push kernel lock into ifioctl_get()

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

OK mpi

date 2022-11-08T16:20:26Z
author sashan
files src/sys/net/pf.c log diff annotate
message 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@

date 2022-11-08T16:53:40Z
author kettenis
files src/sys/arch/arm64/arm64/cpu.c log diff annotate
message Extent the current suspend/resume implementation to include support for
parking CPUs in a WFE/WFI loop.

ok deraadt@, mlarkin@

date 2022-11-08T17:34:12Z
author cheloha
files src/sys/arch/amd64/amd64/acpi_machdep.c log diff annotate
message 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@

date 2022-11-08T17:34:13Z
author cheloha
files src/sys/arch/amd64/amd64/cpu.c log diff annotate
src/sys/arch/amd64/amd64/lapic.c log diff annotate
src/sys/arch/amd64/include/_types.h log diff annotate
src/sys/arch/amd64/include/cpu.h log diff annotate
src/sys/arch/amd64/isa/clock.c log diff annotate
message 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@

date 2022-11-08T17:53:01Z
author kn
files src/sys/dev/audio.c log diff annotate
message fix indent

date 2022-11-08T17:56:38Z
author cheloha
files src/sys/arch/arm64/dev/agtimer.c log diff annotate
src/sys/arch/arm64/include/_types.h log diff annotate
src/sys/arch/arm64/include/cpu.h log diff annotate
message 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@

date 2022-11-08T17:57:14Z
author kn
files src/sys/net/if.c log diff annotate
message Push kernel lock inside ifioctl_get()

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

OK mvs

date 2022-11-08T17:57:47Z
author kn
files src/sys/net/if.c log diff annotate
message 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

date 2022-11-08T18:08:43Z
author mlarkin
files src/sys/arch/amd64/amd64/vmm.c log diff annotate
message 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

date 2022-11-08T18:17:51Z
author cheloha
files src/sys/kern/kern_tc.c log diff annotate
message 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@

date 2022-11-08T18:28:10Z
author kettenis
files src/sys/dev/pci/if_bwfm_pci.c log diff annotate
src/sys/dev/pci/if_bwfm_pci.h log diff annotate
message Implement alternative mailbox handling mechanism required by newer firmware.

ok patrick@

date 2022-11-08T18:43:22Z
author kn
files src/sys/net/if.c log diff annotate
src/sys/net/if_var.h log diff annotate
message Document ifc_list immutability

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

OK millert mvs

date 2022-11-08T18:47:58Z
author kn
files src/sys/net/if.c log diff annotate
message Use four spaces not tabs on line break

date 2022-11-08T19:06:57Z
author tobhe
files src/sys/dev/fdt/files.fdt log diff annotate
src/sys/dev/fdt/gpiobl.c log diff annotate
message 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@

date 2022-11-08T19:07:34Z
author tobhe
files src/sys/arch/arm64/conf/GENERIC log diff annotate
message Enable gpiobl(4)

date 2022-11-08T19:09:53Z
author cheloha
files src/sys/kern/kern_timeout.c log diff annotate
src/sys/sys/timeout.h log diff annotate
message 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@

date 2022-11-08T19:17:58Z
author robert
files src/sys/kern/kern_pledge.c log diff annotate
message allow the KERN_AUTOCONF_SERIAL sysctl in pledge'd processes

ok deraadt@

date 2022-11-08T19:18:47Z
author dlg
files src/sys/arch/amd64/amd64/vmm.c log diff annotate
src/sys/arch/amd64/include/vmmvar.h log diff annotate
message 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@

date 2022-11-08T19:34:54Z
author patrick
files src/sys/dev/fdt/qcspmi.c log diff annotate
message 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@

date 2022-11-08T19:38:34Z
author dlg
files src/sys/arch/amd64/amd64/vmm.c log diff annotate
message 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

date 2022-11-08T19:40:08Z
author patrick
files src/sys/dev/fdt/qcpmic.c log diff annotate
message 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@

date 2022-11-08T19:42:10Z
author patrick
files src/sys/dev/fdt/qcpmicgpio.c log diff annotate
message 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@

date 2022-11-08T19:44:28Z
author patrick
files src/sys/dev/fdt/qcpon.c log diff annotate
message 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@

date 2022-11-08T19:47:05Z
author patrick
files src/sys/dev/fdt/qcrtc.c log diff annotate
message 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@

date 2022-11-08T19:49:34Z
author patrick
files src/sys/arch/arm64/conf/GENERIC log diff annotate
src/sys/arch/arm64/conf/RAMDISK log diff annotate
src/sys/dev/fdt/files.fdt log diff annotate
message Hook up all those Qualcomm SoC SPMI devices.

date 2022-11-08T19:52:40Z
author patrick
files src/sys/arch/arm64/conf/files.arm64 log diff annotate
message Tedu spmi bus definition that moved over to the fdt files.

date 2022-11-08T20:41:36Z
author mlarkin
files src/sys/arch/arm64/include/cpu.h log diff annotate
message KNF/whitespace - no code change

date 2022-11-08T21:07:33Z
author kn
files src/sys/net/if.c log diff annotate
message 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.