FreeBSD/src 48a05f8stand/libofw openfirm.c openfirm.h, stand/powerpc/ofw ofwfdt.c

stand/libofw: make OF_hasprop() part of the library

Currently it is only needed by powerpc ofwfdt.c, and defined statically
there. Make it available as part of libofw, mirroring what we have in
the kernel.

Two small tweaks are made to the implementation:
  1. Return type is changed to bool
  2. Return 'true' when OF_getproplen() == 0. This matches the expected
     semantics of the kernel version, described in OF_hasprop(9).

Reviewed by:    manu, imp, adrian
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D56429
DeltaFile
+7-0stand/libofw/openfirm.c
+0-6stand/powerpc/ofw/ofwfdt.c
+1-0stand/libofw/openfirm.h
+8-63 files

FreeBSD/src fa77feclib/libsys/x86 pkru.3

pkru.3: Note that the kernel may not respect PKRU protections

There are cases where the kernel will be able to access memory covered
by a PKRU key which nomially prohibits accesses.  I believe regular
copyin()/copyout() are subject to the contents of PKRU, but memory
accesses via uiomove_fromphys() will not be.  This can arise when
performing fault I/O, for instance.  I didn't test, but I suspect AIO is
another case.

Update the man page to acknowledge this.

Reviewed by:    alc, kib
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D56416
DeltaFile
+10-7lib/libsys/x86/pkru.3
+10-71 files

FreeBSD/src fe6bf73lib/libsys/x86 pkru.3

pkru.3: Remove a qualifier

Now that i386 kernels are deprecated, we don't really need to mention
this limitation.  It's also a bit dated since PKRU is supported with
5-level paging as well.

Reviewed by:    alc, kib
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D56415
DeltaFile
+0-3lib/libsys/x86/pkru.3
+0-31 files

FreeBSD/src 40dacfeusr.sbin/rtadvd config.c

rtadvd: Fix validation of the MTU parameter when parsing config

MFC after:      1 week

(cherry picked from commit 607f6be6ec19f49ff595226afe1c8aa6515c59a0)
DeltaFile
+1-1usr.sbin/rtadvd/config.c
+1-11 files

FreeBSD/src 547d709sys/netinet ip_divert.c

divert: Use a better source identifier for netisr_queue_src() calls

These opaque IDs are used by netisr to distribute work among threads.
The mapping function is simply SourceID % numthreads, so using socket
addresses as source IDs isn't going to distribute packets well due to
alignment.

Use the divert socket's generation number instead, as that suits this
purpose much better.

Reviewed by:    zlei, glebius
MFC after:      1 week
Sponsored by:   OPNsense
Sponsored by:   Klara, Inc.
Differential Revision:  https://reviews.freebsd.org/D55537

(cherry picked from commit 5547a7bb39accd8f151b53e90b41d13b55f84c95)
DeltaFile
+4-2sys/netinet/ip_divert.c
+4-21 files

FreeBSD/src 62fbb17sys/kern imgact_elf.c

imgact_elf: Unconditionally initialize a variable in a note handler

In the sb == NULL case, we are computing the size of the note using a
dummy sbuf drain handler which counts bytes and discards the contents of
the buffer, so the fact that "structsize" is uninitialized doesn't
matter.  But, the compiler may complain about this, so we might as well
just initialize it unconditionally to silence the warning, as other
handlers already do.

PR:             292811
MFC after:      1 week

(cherry picked from commit 8a68c2509c00ae0dbeab64064bb600cfac787a73)
DeltaFile
+1-1sys/kern/imgact_elf.c
+1-11 files

FreeBSD/src b77bd0esys/compat/freebsd32 freebsd32_misc.c

freebsd32: Fix freebsd11_nstat copyout condition

freebsd11_freebsd32_nstat() invoked copyout(2) when
freebsd11_cvtnstat32() failed and skipped copyout on success. This is
backwards.

Fix this to match freebsd11_freebsd32_nlstat() and freebsd11_nstat(),
and only copy the nstat32 result to userspace when conversion succeeds.

Signed-off-by:  Weixie Cui <cuiweixie at gmail.com>
Reviewed by:    mhorne
MFC after:      1 week
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2109

(cherry picked from commit c6224994ac70b4f71ef9e11903bb2e50ed2b1bfe)
DeltaFile
+1-1sys/compat/freebsd32/freebsd32_misc.c
+1-11 files

FreeBSD/src 95d6612share/man/man9 malloc.9

malloc.9: adjust flag table indentation

The current indentation is shorter than all but one of these flags. This
renders much more nicely.

MFC after:      3 days

(cherry picked from commit be79a42275cad21c6087d8bbd6a328735ea813fa)
DeltaFile
+1-1share/man/man9/malloc.9
+1-11 files

FreeBSD/src ce33f96sys/dev/mlx5/mlx5_en mlx5_en_main.c

mlx5e: Ensure rx timestamps are monotonically increasing

The clock calibration routine currently can result in rx timestamps
jumping backwards, which can confuse the TCP stack.
Ensure they are monotonically increasing by estimating what
we'd calculate as the next timestamp and clamp the calibration
so new timestamps are no earlier in time.

Reviewed by: kib, nickbanks_netflix.com
Tested by: nickbanks_netflix.com
Differential Revision: https://reviews.freebsd.org/D56427
Sponsored by: Netflix
DeltaFile
+50-0sys/dev/mlx5/mlx5_en/mlx5_en_main.c
+50-01 files

FreeBSD/src ce6b497sys/arm/broadcom/bcm2835 raspberrypi_virtgpio.c

raspberry_virtgpio: fix OF_hasprop() usage

The function returns a bool. This driver was merged recently (by me) and
I missed this instance.

While here, adjust the ofw_bus_status_okay() call similarly. This
function still returns an int, but this usage is more widely used in our
drivers.

No functional change intended.

MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Fixes:          b60cd486a652 ("ofw: bool-ify OF_hasprop()")
DeltaFile
+2-2sys/arm/broadcom/bcm2835/raspberrypi_virtgpio.c
+2-21 files

FreeBSD/src 47b0ac1share/man/man9 OF_getprop.9

OF_getprop.9: update OF_hasprop() signature

The return type has been converted to a bool.

Reported by:    manu
Sponsored by:   The FreeBSD Foundation
Fixes:          b60cd486a652 ("ofw: bool-ify OF_hasprop()")
DeltaFile
+8-4share/man/man9/OF_getprop.9
+8-41 files

FreeBSD/src 90fc383sys/amd64/amd64 pmap.c, sys/arm/arm pmap-v6.c

pmap: Do not use PMAP_LOCK_INIT with kernel_pmap

The kernel_pmap lock is a bit special: it does not need the DUPOK flag,
and it really belongs to a different lock class.  If it belongs to the
same class as regular pmap locks, then witness may report warnings when
performing UMA allocations under a regular pmap lock, if the allocation
triggers a pmap_growkernel() call.

Replace instances of PMAP_LOCK_INIT(kernel_pmap) with inline mtx_init()
calls to silence some witness warnings for harmless behaviour I see with
some uncommitted test programs.

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

(cherry picked from commit c6a1c1260f02e44b7f44b1e3735ce5dbd785544d)
DeltaFile
+1-1sys/powerpc/booke/pmap.c
+1-1sys/riscv/riscv/pmap.c
+1-1sys/arm64/arm64/pmap.c
+1-1sys/amd64/amd64/pmap.c
+1-1sys/arm/arm/pmap-v6.c
+1-1sys/i386/i386/pmap.c
+6-63 files not shown
+9-99 files

FreeBSD/src 1379cdesys/kern imgact_elf.c

imgact_elf: Unconditionally initialize a variable in a note handler

In the sb == NULL case, we are computing the size of the note using a
dummy sbuf drain handler which counts bytes and discards the contents of
the buffer, so the fact that "structsize" is uninitialized doesn't
matter.  But, the compiler may complain about this, so we might as well
just initialize it unconditionally to silence the warning, as other
handlers already do.

PR:             292811
MFC after:      1 week

(cherry picked from commit 8a68c2509c00ae0dbeab64064bb600cfac787a73)
DeltaFile
+1-1sys/kern/imgact_elf.c
+1-11 files

FreeBSD/src 3f68410sys/compat/freebsd32 freebsd32_misc.c

freebsd32: Fix freebsd11_nstat copyout condition

freebsd11_freebsd32_nstat() invoked copyout(2) when
freebsd11_cvtnstat32() failed and skipped copyout on success. This is
backwards.

Fix this to match freebsd11_freebsd32_nlstat() and freebsd11_nstat(),
and only copy the nstat32 result to userspace when conversion succeeds.

Signed-off-by:  Weixie Cui <cuiweixie at gmail.com>
Reviewed by:    mhorne
MFC after:      1 week
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2109

(cherry picked from commit c6224994ac70b4f71ef9e11903bb2e50ed2b1bfe)
DeltaFile
+1-1sys/compat/freebsd32/freebsd32_misc.c
+1-11 files

FreeBSD/src fb10574sys/arm/broadcom/bcm2835 raspberrypi_virtgpio.c bcm2835_firmware.h, sys/conf files.arm64

bcm2835_virtgpio: Add driver for virtual GPIO controller on some RPi models

This driver enables bcm2835-virtgpio GPIO controller found on RPi3B and
some CM boards. On which, the ACT (green) LED is connected to this
controller. It is essential for FreeBSD to have this driver to control
this LED.

It will be exposed via gpioled(4).

Reviewed by:    mhorne
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D51456

(cherry picked from commit 84c68dbb59df81d5371f0d1eea888d30561d428d)
DeltaFile
+347-0sys/arm/broadcom/bcm2835/raspberrypi_virtgpio.c
+12-0sys/arm/broadcom/bcm2835/bcm2835_firmware.h
+1-0sys/conf/files.arm64
+360-03 files

FreeBSD/src 0a5c457lib/libsys mq_open.2

mq_open(2): document sysctl limit EINVAL and ENFILE conditions

Document two missing error conditions for mq_open(2):

- EINVAL: returned when mq_maxmsg exceeds kern.mqueue.maxmsg or
  mq_msgsize exceeds kern.mqueue.maxmsgsize.
- ENFILE: add kern.mqueue.maxmq sysctl name to the existing entry.

PR:             243209
Reviewed by:    mhorne
MFC after:      1 week
Signed-off-by:  Kit Dallege <xaum.io at gmail.com>
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2098

(cherry picked from commit 3e9f4fd6fc50300d052d5619d82a14d3488483d5)
DeltaFile
+22-1lib/libsys/mq_open.2
+22-11 files

FreeBSD/src 00e0253share/man/man9 malloc.9

malloc.9: adjust flag table indentation

The current indentation is shorter than all but one of these flags. This
renders much more nicely.

MFC after:      3 days

(cherry picked from commit be79a42275cad21c6087d8bbd6a328735ea813fa)
DeltaFile
+1-1share/man/man9/malloc.9
+1-11 files

FreeBSD/src 14b1824sys/conf files.arm64

conf: Mark vchiq as depending on fdt

Fix an ACPI only kernel by only building the vchiq files when FDT is
enabled.

Fixes:  745c4aa5e8f0 ("Make BRCM2837 port conform FreeBSD/ARM64 guidelines")
Sponsored by:   Arm Ltd

(cherry picked from commit 7446569bbcb42c08c650a5e1015f544f13066d7f)
DeltaFile
+9-9sys/conf/files.arm64
+9-91 files

FreeBSD/src 9280919share/man/man4 hwpmc.4

hwpmc.4: correct stale default values and update diagnostics

The default values documented for kern.hwpmc.logbuffersize (4KB) and
kern.hwpmc.nbuffers_pcpu (64) have been incorrect since 2981a3420cb1
(2018), which updated the compiled defaults but did not update the
man page.

- Correct logbuffersize default from 4KB to 256KB, add 16MB maximum
- Correct nbuffers_pcpu default from 64 to 32, document 32MB per-CPU
  product limit with kern.hwpmc.logbuffersize
- Update DIAGNOSTICS section to reflect current warning messages

Reviewed by:    mhorne
MFC after:      1 week
Sponsored by:   NLINK (nlink.com.br)
Differential Revision:  https://reviews.freebsd.org/D56050

(cherry picked from commit 2318ea10a3afb66c51078483f74c1a622811a619)
DeltaFile
+19-6share/man/man4/hwpmc.4
+19-61 files

FreeBSD/src 290a7adsys/dev/hwpmc hwpmc_logging.c, sys/sys pmc.h

hwpmc: improve diagnostic messages for invalid tunables

Replace printf() with log(LOG_WARNING, ...) in pmclog_initialize()
so that tunable validation failures are visible in dmesg and
/var/log/messages rather than only on the early console.

Also improve the messages to report both the invalid value and the
default it resets to, making it easier for users to understand why
their tunable was ignored.

While here, adjust some whitespacing/style.

Reviewed by:    Ali Mashtizadeh <ali at mashtizadeh.com>, mhorne
MFC after:      1 week
Sponsored by:   NLINK (nlink.com.br)
Differential Revision:  https://reviews.freebsd.org/D56029

(cherry picked from commit b3a18736ec2fc2bd097995dedd8d09e79bcb2056)
DeltaFile
+26-9sys/dev/hwpmc/hwpmc_logging.c
+2-0sys/sys/pmc.h
+28-92 files

FreeBSD/src f72a161sys/dev/hwpmc hwpmc_mod.c

hwpmc: Use rdtsc instead of rdtscp for timestamps

No need for a barrier here, we are inside an NMI handler and executing a
number of serializing instructions with stronger semantics. Reducing
this overhead will increase our maximum safe sampling rate.

Tested by:      Paulo Fragoso <paulo at nlink.com.br>
Reviewed by:    mhorne
MFC after:      1 week
Sponsored by:   Netflix
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2076

(cherry picked from commit 39515d8b623a2be39d0c42a537fd9a17c417ff6e)
DeltaFile
+3-5sys/dev/hwpmc/hwpmc_mod.c
+3-51 files

FreeBSD/src 88c2e97. ObsoleteFiles.inc

ObsoleteFiles.inc: remove stale allwinner pages

These were moved out of man/man4/arm into man/man4. Add entries to catch
the stale copies.

Fixes:  15c79c6fa608 ("man4: move allwinner pages and logic to a standard place")

(cherry picked from commit 1c9ca4cf71841d5f6cee070143b9e29d541e4124)
DeltaFile
+9-0ObsoleteFiles.inc
+9-01 files

FreeBSD/src 21a8bd0. ObsoleteFiles.inc

ObsoleteFiles.inc: correct entry for zpfind.9.gz

It needs the .gz suffix.

Fixes:  2ace05b65a2c9 ("pfind(9): follow-up fixes and improvements")

(cherry picked from commit 9c800a103c03dd4a32f1f6ac8f409fe38f304848)
DeltaFile
+1-1ObsoleteFiles.inc
+1-11 files

FreeBSD/src ce4eff1sys/x86/x86 local_apic.c

Xen: Detect Extended Destination ID support

Xen advertises support for the Extended Destination ID standard via
bit 5 (aka XEN_HVM_CPUID_EXT_DEST_ID) of the value returned in the
EAX register when Xen features are queried via CPUID.

MFC after:      3 weeks
Sponsored by:   Amazon
Differential Revision:  https://reviews.freebsd.org/D55429

(cherry picked from commit 9b18ba2c16a0750e6c78f348845368284ef1a704)
DeltaFile
+6-0sys/x86/x86/local_apic.c
+6-01 files

FreeBSD/src f3490b8sys/contrib/xen/arch-x86 cpuid.h

x86/cpuid: add CPUID flag for Extended Destination ID support

Introduce the CPUID flag to be used in order to signal the support for
using an extended destination ID in IO-APIC RTEs and MSI address
fields. Such format expands the maximum target APIC ID from 255 to
32768 without requiring the usage of interrupt remapping.

The design document describing the feature can be found at:

http://david.woodhou.se/15-bit-msi.pdf

Signed-off-by: Roger Pau Monné <roger.pau at citrix.com>
Reviewed-by: Jan Beulich <jbeulich at suse.com>
(cherry picked from commit 8c986d1645312487adf21a9104d667ac1e19c25f)
DeltaFile
+7-0sys/contrib/xen/arch-x86/cpuid.h
+7-01 files

FreeBSD/src 7dfe776sys/dev/hyperv/vmbus/x86 hyperv_reg.h, sys/x86/x86 local_apic.c

Hyper-V: Detect Extended Destination ID support

Hyper-V advertises support for the Extended Destination ID standard via
bit 2 of the value returned in the EAX register when the hypervisor
stack properties are queried via CPUID.

This is based on a commit to the Linux kernel, as there does not seem
to be any other documentation of this feature.

Reviewed by:    Souradeep Chakrabarti
MFC after:      3 weeks
Sponsored by:   Amazon
Differential Revision:  https://reviews.freebsd.org/D55432

(cherry picked from commit 7b6be0014a4eb81943491122bae70914b7fd82b6)
DeltaFile
+9-0sys/x86/x86/local_apic.c
+6-0sys/dev/hyperv/vmbus/x86/hyperv_reg.h
+15-02 files

FreeBSD/src 2b82661sys/x86/x86 local_apic.c

Bhyve: Detect Extended Destination ID support

Bhyve advertises support for the Extended Destination ID standard via
bit 0 (aka CPUID_BHYVE_FEAT_EXT_DEST_ID) of the value returned in the
EAX register when Bhyve features are queried via CPUID.

MFC after:      3 weeks
Sponsored by:   Amazon
Differential Revision:  https://reviews.freebsd.org/D55431

(cherry picked from commit 8dd9a0d52175fbc5dafed851fb95a289a94fb6cd)
DeltaFile
+8-0sys/x86/x86/local_apic.c
+8-01 files

FreeBSD/src 075909esys/amd64/vmm x86.c, sys/x86/include bhyve.h

vmm: Move defines from x86.c to x86/bhyve.h

The values CPUID_BHYVE_FEATURES and CPUID_BHYVE_FEAT_EXT_DEST_ID are
useful for guests, not just hosts; so they belong in a header file in
sys/x86/include rather than simply in the .c file implementing the
bhyve host side.

The original addition of these defines took place without adding a
copyright statement, but since I'm moving them into a new file I've
added the original author's standard copyright (Amazon).

MFC after:      3 weeks
Fixes:  313a68ea20b4 ("bhyve: Add CPUID_BHYVE_FEATURES leaf")
Sponsored by:   Amazon
Differential Revision:  https://reviews.freebsd.org/D55430

(cherry picked from commit 49b6254b3e09ee741f456617111ecb18803459fb)
DeltaFile
+35-0sys/x86/include/bhyve.h
+1-4sys/amd64/vmm/x86.c
+36-42 files

FreeBSD/src fa4faebsys/x86/include kvm.h, sys/x86/x86 local_apic.c

KVM: Detect Extended Destination ID support

KVM advertises support for the Extended Destination ID standard via
bit 15 of the value returned in the EAX register when KVM features
are queried via CPUID.

Tested on:      EC2 r8i.96xlarge
MFC after:      3 weeks
Sponsored by:   Amazon
Differential Revision:  https://reviews.freebsd.org/D55427

(cherry picked from commit 9ab5aa3d4c7879d5518afc7587a864ba880e7ee9)
DeltaFile
+11-0sys/x86/x86/local_apic.c
+1-0sys/x86/include/kvm.h
+12-02 files

FreeBSD/src 0ef872csys/x86/include apicvar.h, sys/x86/x86 io_apic.c

io_apic: Support APIC Extended Destination IDs

If APIC Extended Destination ID support is enabled, use it in APIC RTEs
by allowing APIC IDs up to 2^15 - 1 and encoding the high bits into
Intel "reserved" bits per the standard.

Reviewed by:    kib
MFC after:      3 weeks
Sponsored by:   Amazon
Differential Revision:  https://reviews.freebsd.org/D55889

(cherry picked from commit b0e1b1069d655f12ab69cf3a1dc1904dd35ad1da)
DeltaFile
+7-0sys/x86/x86/io_apic.c
+1-0sys/x86/include/apicvar.h
+8-02 files