HardenedBSD/hardenedbsd a906febsys/vm vm_unix.c

HBSD: Resolve merge conflict

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
DeltaFile
+0-5sys/vm/vm_unix.c
+0-51 files

HardenedBSD/hardenedbsd 887d9e4lib/libcasper/services/cap_sysctl cap_sysctl.c cap_sysctl.3, lib/libcasper/services/cap_sysctl/tests sysctl_test.c

Merge remote-tracking branch 'origin/freebsd/current/master' into hardened/current/master

Conflicts:
        sys/vm/vm_unix.c (unresolved)

HardenedBSD/hardenedbsd dd0f9ebsys/cddl/contrib/opensolaris/uts/common/fs/zfs zfs_rlock.c vdev_indirect.c, sys/dev/nctgpio nctgpio.c

Merge remote-tracking branch 'freebsd/stable/12' into hardened/12-stable/master

HardenedBSD/hardenedbsd 878f67bsys/riscv/riscv elf_machdep.c

HBSD: Resolve merge conflict

Keep FreeBSD's ASR disabled for RISC-V.

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>

HardenedBSD/hardenedbsd 657ef51share/man/man4 superio.4, share/man/man9 superio.9

Merge remote-tracking branch 'origin/freebsd/12-stable/master' into 
hardened/12-stable/master

Conflicts:
        sys/riscv/riscv/elf_machdep.c (unresolved)

HardenedBSD/hardenedbsd 6357299sys/amd64/linux Makefile, sys/compat/freebsd32 capabilities.conf

Merge remote-tracking branch 'origin/freebsd/12-stable/master' into 
hardened/12-stable/master

Conflicts:
        sys/i386/ibcs2/ibcs2_proto.h (deleted)
        sys/i386/ibcs2/ibcs2_syscall.h (deleted)
        sys/i386/ibcs2/ibcs2_sysent.c (deleted)

HardenedBSD/hardenedbsd 765bf3acontrib/file/magic/Magdir map, contrib/file/src softmagic.c is_json.c

Merge remote-tracking branch 'upstream/master' into hardened/current/master

HardenedBSD/hardenedbsd 2d23330sys/netinet6 in6_pcb.c

It is unclear why in6_pcblookup_local() would require write access
to the PCB hash.  The function doesn't modify the hash. It always
asserted write lock historically, but with epoch conversion this
fails in some special cases.

Reviewed by:    rwatson, bz
Reported-by:    syzbot+0b0488ca537e20cb2429 at syzkaller.appspotmail.com

HardenedBSD/hardenedbsd 1989b56contrib/jemalloc/include/jemalloc/internal size_classes.h, contrib/jemalloc/src jemalloc.c ctl.c

Revert r354605: Update jemalloc to version 5.2.1.

Compilation fails for non-llvm-based platforms.

HardenedBSD/hardenedbsd aaf6329contrib/jemalloc/include/jemalloc/internal size_classes.h, contrib/jemalloc/src jemalloc.c ctl.c

Update jemalloc to version 5.2.1.

HardenedBSD/hardenedbsd 47081c6sys/riscv/riscv plic.c

plic: check for sifive compatible string

The Linux dts for the HiFive Unleashed does not contain the usual
"riscv,plic0" compat string, but our PLIC driver is compatible.

MFC after:      1 week

HardenedBSD/hardenedbsd f85215fsys/riscv/riscv plic.c

plic: fix PLIC_MAX_IRQS

The maximum number of PLIC interrupts is defined in the PLIC spec[1]
as 1024.

[1] https://github.com/riscv/riscv-plic-spec/blob/master/riscv-plic.adoc

MFC after:      1 week

HardenedBSD/hardenedbsd 474b97asys/compat/linprocfs linprocfs.c

linprocfs: Make sure to report -1 as tty when we have no controlling tty.

When reporting a process' stats, we can't just provide the tty as an
unsigned long, as if we have no controlling tty, the tty would be NODEV, or
-1. Instaed, just special-case NODEV.

Submitted by:   Juraj Lutter <otis at sk.FreeBSD.org>
MFC after:      1 week

HardenedBSD/hardenedbsd 0960fffshare/mk bsd.cpu.mk

Consolidate powerpcspe CFLAGS

Don't depend on CPUTYPE to define powerpcspe CFLAGS, they should be set
unconditionally.  This reduces duplication.  Also, set some CFLAGS as
gcc-only, because clang's SPE support always uses the SPE ABI, it's not an
optional feature.

HardenedBSD/hardenedbsd cf10ab0share/mk bsd.cpu.mk

powerpcspe: use -mspe instead of -mspe=yes to enable SPE

-mspe=yes/no was deprecated even before GCC 4.2.1 in favor of
-mspe/-mno-spe.  Clang only supports -mspe/-mno-spe.

HardenedBSD/hardenedbsd 1282739share/man/man4 ntb_transport.4

Some language fixes.

Submitted by:   rpokala@
MFC after:      2 weeks

HardenedBSD/hardenedbsd 9eff214contrib/file/magic/Magdir map, contrib/file/src softmagic.c is_json.c

MFV r354582: file 5.37.

MFC after:      3 days

HardenedBSD/hardenedbsd c496af9stand/libsa/zfs zfsimpl.c

loader: use struct initializer in vdev_probe().

Hopefully it is a bit more clear this way.

HardenedBSD/hardenedbsd 6ad42e8stand/libsa/zfs zfsimpl.c

loader: memory leak in vdev_label_read_config()

We need to free the allocated buffer for label.

HardenedBSD/hardenedbsd 4ca9607sys/amd64/amd64 machdep.c, sys/amd64/include segments.h

amd64: change r_gdt to the local variable in hammer_time().

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week

HardenedBSD/hardenedbsd 9ee6e17sys/amd64/amd64 pmap.c

amd64: Change SFENCE to locked op for synchronizing with CLFLUSHOPT on Intel.

Reviewed by:    cem, jhb
Discussed with: alc, scottph
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D22007
DeltaFile
+11-11sys/amd64/amd64/pmap.c
+11-111 files

HardenedBSD/hardenedbsd 5fc2b3asys/amd64/amd64 mp_machdep.c machdep.c, sys/amd64/include pcpu.h tss.h

amd64: move common_tss into pcpu.

This saves some memory, around 256K I think.  It removes some code,
e.g. KPTI does not need to specially map common_tss anymore.  Also,
common_tss become domain-local.

Reviewed by:    jhb
Tested by:      pho
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D22231

HardenedBSD/hardenedbsd 31e78c0sys/vm uma_core.c

Include cache zones into zone_foreach() where appropriate.

The r354367 is reverted since it is subsumed by this, more complete, approach.

Suggested by:   markj
Reviewed by:    alc. glebius, markj
Tested by:      pho
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D22242
DeltaFile
+12-7sys/vm/uma_core.c
+12-71 files

HardenedBSD/hardenedbsd b4dc595sys/arm64/arm64 pmap.c

Eliminate a redundant pmap_load() from pmap_remove_pages().

There is no reason why the pmap_invalidate_all() in pmap_remove_pages()
must be performed before the final PV list lock release.  Move it past
the lock release.

Eliminate a stale comment from pmap_page_test_mappings().  We implemented
a modified bit in r350004.

MFC after:      1 week

HardenedBSD/hardenedbsd 7ad5aa9sys/powerpc/powernv opal_pci.c opal.h

powerpc64/powernv: Use OPAL call for non-POWER8 PCI TCE reset

According to the OPAL documentation, only the POWER8 (PHB3) should use
the register write TCE reset method.  All others should use the OPAL
call.

On POWER9 the call is semantically identical to the register write, with
a wait for completion.

HardenedBSD/hardenedbsd b0143cfmagic/Magdir map, src softmagic.c is_json.c

Vendor import of file 5.37

HardenedBSD/hardenedbsd ac8a115share/man/man4 ntb_transport.4, sys/dev/ntb ntb_transport.c

Add compact scraptchpad protocol for ntb_transport(4).

Previously ntb_transport(4) required at least 6 scratchpad registers,
plus 2 more for each additional memory window.  That is too much for some
configurations, where several drivers have to share resources of the same
NTB hardware.  This patch introduces new compact version of the protocol,
requiring only 3 scratchpad registers, plus one more for each additional
memory window.  The optimization is based on fact that neither of version,
number of windows or number of queue pairs really need more then one byte
each, and window sizes of 4GB are not very useful now.  The new protocol
is activated automatically when the configuration is low on scratchpad
registers, or it can be activated explicitly with loader tunable.

MFC after:      2 weeks
Sponsored by:   iXsystems, Inc.

HardenedBSD/hardenedbsd 0ae0f3ashare/man/man4 ntb_hw_plx.4, sys/dev/ntb/ntb_hw ntb_hw_plx.c

Allow splitting PLX NTB BAR2 into several memory windows.

Address Lookup Table (A-LUT) being enabled allows to specify separate
translation for each 1/128th or 1/256th of the BAR2.  Previously it was
used only to limit effective window size by blocking access through some
of A-LUT elements.  This change allows A-LUT elements to also point
different memory locations, providing to upper layers several (up to 128)
independent memory windows.  A-LUT hardware allows even more flexible
configurations than this, but NTB KPI have no way to manage that now.

MFC after:      2 weeks
Sponsored by:   iXsystems, Inc.

HardenedBSD/hardenedbsd 28ecf46sys/arm/broadcom/bcm2835 bcm2835_sdhci.c

bcm2835_sdhci: don't panic in DMA interrupt if curcmd went away

This is an exceptional case; generally found during controller errors.
A panic when we attempt to acess slot->curcmd->data is less ideal than
warning, and other verbiage will be emitted to indicate the exact error.

HardenedBSD/hardenedbsd 3c8de67sys/conf files.arm64

Revert premature part of r354577

bcm2835_vcbus.c will be the future home to some I/O address mapping
routines, but it has neither been committed nor reviewed.

HardenedBSD/hardenedbsd 1275770sys/arm64/conf GENERIC, sys/conf files.arm64 options.arm64

arm64: add SOC_BRCM_BCM2838, build it in GENERIC

BCM2838/BCM2711 is the Raspberry Pi 4, which we will soon be able to boot
on once some ports bits are worked out.

HardenedBSD/hardenedbsd 26ac884share/man/man9 VOP_COPY_FILE_RANGE.9

Update the VOP_COPY_FILE_RANGE man page to reflect the semantic change
made by r354574.

This is a content change.

HardenedBSD/hardenedbsd 1aad1dclib/libc/sys copy_file_range.2

Update the copy_file_range man page to reflect the semantic change
done by r354574.

This is a content change.

HardenedBSD/hardenedbsd f9b312bsys/kern vfs_syscalls.c vfs_vnops.c

Update copy_file_range(2) to be Linux5 compatible.

The current linux man page and testing done on a fairly recent linux5.n
kernel have identified two changes to the semantics of the linux
copy_file_range system call.
Since the copy_file_range(2) system call is intended to be linux compatible
and is only currently in head/current and not used by any commands,
it seems appropriate to update the system call to be compatible with
the current linux one.
The first of these semantic changes was changed to be compatible with
linux5.n by r354564.
For the second semantic change, the old linux man page stated that, if
infd and outfd referred to the same file, EBADF should be returned.
Now, the semantics is to allow infd and outfd to refer to the same file
so long as the byte ranges defined by the input file offset, output file offset
and len does not overlap. If the byte ranges do overlap, EINVAL should be
returned.
This patch modifies copy_file_range(2) to be linux5.n compatible for this
semantic change.

HardenedBSD/hardenedbsd f794d42sys/dev/usb/controller generic_ehci_fdt.c

generic_ehci_fdt: Fix compile when EXT_RESOURCES isn't present

HardenedBSD/hardenedbsd b3bc6e0lib/libipsec ipsec_strerror.h ipsec_strerror.c

libipsec: correct a typo

Correct a typo in the ipsec_errlist and replicated in a comment.
No functional changes.

MFC after:      3 weeks

HardenedBSD/hardenedbsd 76b010esys/cam/ata ata_da.c, sys/cam/mmc mmc_da.c

Add GEOM attribute to report physical device name, and report it
via 'diskinfo -v'.  This avoids the need to track it down via CAM,
and should also work for disks that don't use CAM.  And since it's
inherited thru the GEOM hierarchy, in most cases one doesn't need
to walk the GEOM graph either, eg you can use it on a partition
instead of disk itself.

Reviewed by:    allanjude, imp
Sponsored by:   Klara Inc
Differential Revision:  https://reviews.freebsd.org/D22249

HardenedBSD/hardenedbsd 63c1432sys/vm vm_map.c vm_map.h

For vm_map, #defining DIAGNOSTIC to turn on full assertion-based
consistency checking slows performance dramatically. This change
reduces the number of assertions checked by completely walking the
vm_map tree only when the write-lock is released, and only then if the
number of modifications to the tree since the last walk exceeds the
number of tree nodes.

Reviewed by: alc, kib
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D22163
DeltaFile
+59-35sys/vm/vm_map.c
+3-0sys/vm/vm_map.h
+62-352 files

HardenedBSD/hardenedbsd b740365share/man/man9 VOP_COPY_FILE_RANGE.9

Update the VOP_COPY_FILE_RANGE.9 man page to reflect the semantic change
implemented by r354564.

This is a content change.

HardenedBSD/hardenedbsd dd6fa16lib/libc/sys copy_file_range.2

Update the copy_file_range.2 man page to reflect the semantic change
implemented by r354564.

This is a content change.

HardenedBSD/hardenedbsd fd4b12csys/kern vfs_vnops.c

Update copy_file_range(2) to be Linux5 compatible.

The current linux man page and testing done on a fairly recent linux5.n
kernel have identified two changes to the semantics of the linux
copy_file_range system call.
Since the copy_file_range(2) system call is intended to be linux compatible
and is only currently in head/current and not used by any commands,
it seems appropriate to update the system call to be compatible with
the current linux one.
The old linux man page stated that, if the
offset + len exceeded file_size for the input file, EINVAL should be returned.
Now, the semantics is to copy up to at most file_size bytes and return that
number of bytes copied. If the offset is at or beyond file_size, a return
of 0 bytes is done.
This patch modifies copy_file_range(2) to be linux compatible for this
semantic change.
A separate patch will change copy_file_range(2) for the other semantic
change, which allows the infd and outfd to refer to the same file, so
long as the byte ranges do not overlap.
DeltaFile
+15-23sys/kern/vfs_vnops.c
+15-231 files

HardenedBSD/hardenedbsd 33cc4c9sys/arm/broadcom/bcm2835 bcm2835_mbox_prop.h

bcm2835: commit missing constant from r354560

Surgically pulling the patch from my debugging work lead to this slopiness-
my apologies.

HardenedBSD/hardenedbsd 409eb8bsys/conf files

Add new iwm(4) files to sys/conf/files.

Submitted by:   rea
MFC with:       r354504
DeltaFile
+2-0sys/conf/files
+2-01 files

HardenedBSD/hardenedbsd 74fc4e0sys/arm/broadcom/bcm2835 bcm2835_sdhci.c

bcm2835_sdhci: remove unused power_id field

This was once set, but I removed it by the time I committed it because both
configurations use the same POWER_ID. This can be separated back out if the
situation changes.

HardenedBSD/hardenedbsd 03bfdf6sys/arm/broadcom/bcm2835 bcm2835_sdhci.c

bcm2835_sdhci: add some very basic support for rpi4

DMA is currently disabled while I work out why it's broken, but this is
enough for upstream U-Boot + rpi-firmware + our rpi3-psci-monitor to boot
with the right config.

The RPi 4 is still not in a good "supported" state, as we have no
USB/PCI-E/Ethernet drivers, but if air-gapped pies only able to operate over
cereal is your thing, here's your guy.

Submitted by:   Robert Crowston (with modifications)

HardenedBSD/hardenedbsd 8f9b3b5stand/efi/loader main.c

loader.efi: Default to serial if we don't have a ConOut variable

In the EFI implementation in U-Boot no ConOut efi variable is created,
this cause loader to fallback to TERM_EMU implementation which is very
very very slow (and uses the ConOut device in the system table anyway).
The UEFI spec aren't clear as if this variable needs to exists or not.

Reviewed by:    imp, kevans

HardenedBSD/hardenedbsd fd01eadsys/arm64/rockchip/clk rk_clk_fract.c

Remove explicit declaration of rk_clk_fract_set_freq() function
forgotten in r354556.

MFC after:      3 weeks
MFC with:       r354556
Noticed by:     manu

HardenedBSD/hardenedbsd 6f228basys/arm64/rockchip/clk rk_clk_composite.c rk_clk_composite.h

Tidy up Rockchip composite clock.
- add support for log2 based dividers
- use proper write mask when writing to divider register

MFC after:      3 weeks
Reviewed by:    manu
Differential Revision:  https://reviews.freebsd.org/D22283

HardenedBSD/hardenedbsd 5bdc25esys/arm64/rockchip/clk rk_clk_fract.c rk_clk_fract.h, sys/conf files.arm64

Enhance Rockchip clocks implementation.
- add support for fractional dividers
- allow to declare fixed and linked clock

MFC after:      3 weeks
Reviewed by:    manu
Differential Revision:  https://reviews.freebsd.org/D22282

HardenedBSD/hardenedbsd 144319csys/arm64/rockchip/clk rk_clk_pll.c rk_clk_composite.c

Cleanup Rockchip clocks implementation.
- style
- unify dprinf defines
- make dprinf's 32-bit compatible
Not a functional change.

MFC after:      3 weeks
Reviewed by:    manu, imp
Differential Revision:  https://reviews.freebsd.org/D22281