FreeBSD/src 21c534bsys/riscv/include frame.h, sys/riscv/riscv vm_machdep.c exception.S

riscv: Fix and generalise saving TP (PCPU pointer) whilst in userspace

In cpu_fork, we allocate sizeof(struct pcb) + sizeof(struct trapframe)
space on the stack, then round it for stack alignment. This not only
fails to include the space needed for TP but also doesn't round up the
trapframe allocation to be stack-aligned, yet TF_SIZE does, as is the
expectation of fork_trampoline and cpu_exception_handler. Given that
sizeof(struct pcb) + sizeof(struct trapframe) is a multiple of 16, this
causes the saved TP to be stored in the PCB's pcb_sp (the intended
trapframe padding aliasing pcb_ra), which is probably harmless in
practice as the PCB isn't expected to be current, but definitely not
intended.

In cpu_thread_alloc, we do include the 8 bytes for TP and then stack
align that. This again fails to include the padding for trapframe as
present in TF_SIZE, but sizeof(struct pcb) + sizeof(struct trapframe)
happens to be a multiple of 16, as above, so adding 8 then rounding to
stack alignment (16) includes an extra 8 bytes of padding, giving the
right result for the wrong reason (and could be broken by future struct

    [11 lines not shown]
DeltaFile
+24-11sys/riscv/riscv/vm_machdep.c
+14-0sys/riscv/include/frame.h
+2-2sys/riscv/riscv/exception.S
+3-1sys/riscv/riscv/genassym.c
+1-1sys/riscv/riscv/swtch.S
+44-155 files

FreeBSD/src 3bc8099sys/arm/arm exception.S, sys/arm/mv/armadaxp mptramp.S

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/

Similar commit in current:
(cherry picked from commit 685dc743dc3b)
DeltaFile
+0-3sys/arm64/qoriq/qoriq_dw_pci.c
+0-3sys/dev/ioat/ioat_hw.h
+0-3sys/cam/ctl/ctl_scsi_all.c
+0-3sys/arm/mv/armadaxp/mptramp.S
+0-3sys/arm/arm/exception.S
+0-3sys/arm64/arm64/cpufunc_asm.S
+0-184,033 files not shown
+0-7,9144,039 files

FreeBSD/src 685dc74sys/arm64/qoriq qoriq_dw_pci.c, sys/cam/ctl ctl_scsi_all.h ctl_scsi_all.c

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
DeltaFile
+0-3sys/cam/ctl/ctl_scsi_all.h
+0-3sys/cam/ctl/ctl_scsi_all.c
+0-3sys/arm64/qoriq/qoriq_dw_pci.c
+0-3sys/dev/cxgb/common/cxgb_t3_hw.c
+0-3sys/dev/extres/clk/clk_div.c
+0-3sys/dev/extres/clk/clk_gate.c
+0-183,795 files not shown
+0-7,4523,801 files

FreeBSD/src a89f1cesys/riscv/riscv swtch.S

riscv: remove unused string from swtch.S

MFC after:      3 days
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit f5d39047b094d5164b85ae7e2a6a9a8342269815)
DeltaFile
+0-2sys/riscv/riscv/swtch.S
+0-21 files

FreeBSD/src c32b6c7sys/conf kern.mk, sys/riscv/riscv exec_machdep.c swtch.S

riscv: retire the FPE kernel option

We always build the kernel floating point support. Now that the
riscv64sf userspace variant has been removed the option is required for
correct operation.

Reviewed by:    jhb
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D39851
DeltaFile
+1-14sys/riscv/riscv/exec_machdep.c
+1-13sys/riscv/riscv/swtch.S
+3-4sys/conf/kern.mk
+1-4sys/riscv/riscv/machdep.c
+0-4sys/riscv/riscv/trap.c
+0-2sys/riscv/riscv/identcpu.c
+6-413 files not shown
+6-449 files

FreeBSD/src f5d3904sys/riscv/riscv swtch.S

riscv: remove unused string from swtch.S

MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
DeltaFile
+0-2sys/riscv/riscv/swtch.S
+0-21 files

FreeBSD/src 75dfc66 (r358401)lib/libc/sparc64/fpu fpu_implode.c, libexec/rtld-elf/sparc64 reloc.c

Merge ^/head r358269 through r358399.
DeltaFile
+1,445-154share/misc/pci_vendors
+0-1,120tools/test/testfloat/sparc64/systfloat.S
+0-887libexec/rtld-elf/sparc64/reloc.c
+0-706tools/test/testfloat/sparc64/fpu_util.c
+0-542lib/libc/sparc64/fpu/fpu_implode.c
+54-423sys/dev/mpr/mpr_sas.c
+1,499-3,832784 files not shown
+7,479-16,079790 files

FreeBSD/src 65289c9 (r358292)sys/riscv/riscv swtch.S

Only compile clear_fpu state code when we're building with options FPE.

Soft float kernels build without floating point, and will fail to build if we
try to include floating point code.

Obtained from: kp@
DeltaFile
+1-1sys/riscv/riscv/swtch.S
+1-11 files

FreeBSD/src 02129bf (r349485)sys/conf ldscript.riscv, sys/riscv/include pcpu.h

MFC 348835-348836:
Fix global pointer relaxations in the RISC-V kernel

The gp register is intended to used by the linker as another means of
performing relaxations, and should point to the small data section (.sdata).

Currently gp is being used as the pcpu pointer within the kernel, but the more
appropriate choice for this is the tp register, which is unused.

Swap existing usage of gp with tp within the kernel, and set up gp properly
at boot with the value of __global_pointer$ for all harts.

Approved by:    markj (mentor, implicit)
DeltaFile
+16-17sys/riscv/riscv/exception.S
+6-17sys/riscv/riscv/vm_machdep.c
+13-7sys/riscv/riscv/locore.S
+9-10sys/riscv/riscv/swtch.S
+5-1sys/conf/ldscript.riscv
+2-2sys/riscv/include/pcpu.h
+51-543 files not shown
+54-579 files

FreeBSD/src e532a99 (r349236)contrib/libarchive/libarchive/test test_read_format_rar5_different_window_size.rar.uu, sys/dev/sdio sdiob.c

MFHead @349234

Sponsored by:   The FreeBSD Foundation
DeltaFile
+1,188-0sys/dev/sdio/sdiob.c
+790-0sys/libkern/gsb_crc32.c
+0-789sys/libkern/crc32.c
+675-0contrib/libarchive/libarchive/test/test_read_format_rar5_different_window_size.rar.uu
+296-261sys/vm/vm_map.c
+451-0sys/dev/usb/usb_hub_acpi.c
+3,400-1,050428 files not shown
+12,766-4,712434 files

FreeBSD/src 6ae48dd (r348836)sys/conf ldscript.riscv, sys/riscv/include pcpu.h

Fix global pointer relaxations in the RISC-V kernel

The gp register is intended to used by the linker as another means of
performing relaxations, and should point to the small data section (.sdata).

Currently gp is being used as the pcpu pointer within the kernel, but the more
appropriate choice for this is the tp register, which is unused.

Swap existing usage of gp with tp within the kernel, and set up gp properly
at boot with the value of __global_pointer$ for all harts.

Additionally, remove some cases of accessing tp from the PCB, as it is not
part of the per-thread state. The user's tp and gp should be tracked only
through the trapframe.

Reviewed by:    markj, jhb
Approved by:    markj (mentor)
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D19893
DeltaFile
+6-17sys/riscv/riscv/vm_machdep.c
+16-7sys/riscv/riscv/exception.S
+13-7sys/riscv/riscv/locore.S
+9-10sys/riscv/riscv/swtch.S
+5-1sys/conf/ldscript.riscv
+2-2sys/riscv/include/pcpu.h
+51-443 files not shown
+54-479 files

FreeBSD/src 952d17d (r348646)sys/riscv/include pmap.h, sys/riscv/riscv pmap.c swtch.S

MFC r344108:
Implement per-CPU pmap activation tracking for RISC-V.
DeltaFile
+65-23sys/riscv/riscv/pmap.c
+27-45sys/riscv/riscv/swtch.S
+7-0sys/riscv/include/pmap.h
+4-0sys/riscv/riscv/mp_machdep.c
+0-4sys/riscv/riscv/machdep.c
+0-3sys/riscv/riscv/vm_machdep.c
+103-753 files not shown
+104-779 files

FreeBSD/src 30e009f (r344271)lib/libc/i386/gen getcontextx.c, lib/libc/x86/gen getcontextx.c

MFhead at r344270
DeltaFile
+1,376-263sys/riscv/riscv/pmap.c
+528-1tools/build/mk/OptionalObsoleteFiles.inc
+252-0sys/opencrypto/cbc_mac.c
+226-2tools/tools/crypto/cryptocheck.c
+0-145lib/libc/i386/gen/getcontextx.c
+140-0lib/libc/x86/gen/getcontextx.c
+2,522-411120 files not shown
+3,909-1,092126 files

FreeBSD/src c981cbb (r344178)contrib/libarchive/libarchive archive_ppmd8.c archive_read_support_format_zip.c, contrib/libarchive/libarchive/test test_read_format_zip.c

Merge ^/head r343956 through r344177.
DeltaFile
+1,376-263sys/riscv/riscv/pmap.c
+1,287-0contrib/libarchive/libarchive/archive_ppmd8.c
+780-40contrib/libarchive/libarchive/archive_read_support_format_zip.c
+447-0contrib/libarchive/libarchive/test/test_read_format_zip.c
+288-122sys/netpfil/pf/pf_ioctl.c
+267-1sys/arm/allwinner/axp81x.c
+4,445-426200 files not shown
+7,696-1,693206 files

FreeBSD/src 35c91b0 (r344108)sys/riscv/include pmap.h, sys/riscv/riscv pmap.c swtch.S

Implement per-CPU pmap activation tracking for RISC-V.

This reduces the overhead of TLB invalidations by ensuring that we
only interrupt CPUs which are using the given pmap.  Tracking is
performed in pmap_activate(), which gets called during context switches:
from cpu_throw(), if a thread is exiting or an AP is starting, or
cpu_switch() for a regular context switch.

For now, pmap_sync_icache() still must interrupt all CPUs.

Reviewed by:    kib (earlier version), jhb
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D18874
DeltaFile
+65-23sys/riscv/riscv/pmap.c
+27-45sys/riscv/riscv/swtch.S
+7-0sys/riscv/include/pmap.h
+4-0sys/riscv/riscv/mp_machdep.c
+0-4sys/riscv/riscv/machdep.c
+0-3sys/riscv/riscv/vm_machdep.c
+103-753 files not shown
+104-779 files

FreeBSD/src c9fa6ca (r342090)sys/riscv/include cpufunc.h, sys/riscv/riscv locore.S swtch.S

MFC r341693:
Rename sptbr to satp per v1.10 of the privileged architecture spec.
DeltaFile
+7-0sys/riscv/include/cpufunc.h
+2-2sys/riscv/riscv/locore.S
+2-2sys/riscv/riscv/swtch.S
+1-1sys/riscv/riscv/pmap.c
+12-54 files

FreeBSD/src 67350cb (r341764)contrib/wpa/src/ap wpa_auth_ft.c, contrib/wpa/src/common dpp.c qca-vendor.h

Merge ^/head r340918 through r341763.
DeltaFile
+5,918-3,449sys/dev/sfxge/common/efx_regs_mcdi.h
+7,691-0contrib/wpa/src/common/dpp.c
+4,709-52contrib/wpa/src/common/qca-vendor.h
+3,108-467contrib/wpa/src/ap/wpa_auth_ft.c
+2,934-0sys/dev/sfxge/common/efx_regs_mcdi_aoe.h
+2,613-0contrib/wpa/wpa_supplicant/dpp_supplicant.c
+26,973-3,9681,093 files not shown
+109,524-32,8941,099 files

FreeBSD/src 1f5e341 (r341693)sys/riscv/include cpufunc.h, sys/riscv/riscv locore.S swtch.S

Rename sptbr to satp per v1.10 of the privileged architecture spec.

Add a subroutine for updating satp, for use when updating the
active pmap.  No functional change intended.

Reviewed by:    jhb
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D18462
DeltaFile
+7-0sys/riscv/include/cpufunc.h
+2-2sys/riscv/riscv/locore.S
+2-2sys/riscv/riscv/swtch.S
+1-1sys/riscv/riscv/pmap.c
+12-54 files

FreeBSD/src 01d4e21 (r339201)contrib/mandoc roff.c mdoc.7, contrib/mdocml roff.c mdoc.7

MFH r338661 through r339200.

Sponsored by:   The FreeBSD Foundation
DeltaFile
+3,838-0contrib/mandoc/roff.c
+0-3,748contrib/mdocml/roff.c
+3,244-0contrib/mandoc/mdoc.7
+0-3,231contrib/mdocml/mdoc.7
+2,968-0contrib/mandoc/mdoc_validate.c
+0-2,906contrib/mdocml/mdoc_validate.c
+10,050-9,885761 files not shown
+76,028-72,546767 files

FreeBSD/src ce44d80 (r338988)contrib/mandoc roff.c mdoc.7, contrib/mdocml roff.c mdoc.7

Merge ^/head r338731 through r338987.
DeltaFile
+3,838-0contrib/mandoc/roff.c
+0-3,748contrib/mdocml/roff.c
+3,244-0contrib/mandoc/mdoc.7
+0-3,231contrib/mdocml/mdoc.7
+2,968-0contrib/mandoc/mdoc_validate.c
+0-2,906contrib/mdocml/mdoc_validate.c
+10,050-9,885642 files not shown
+73,523-71,109648 files

FreeBSD/src 232d0b8 (r338814)sys/riscv/include fpe.h, sys/riscv/riscv swtch.S machdep.c

Various fixes for floating point on RISC-V.

- Explicitly load an empty initial state into FP registers when taking
  the fault on the first FP instruction in a thread.  Setting
  SSTATE.FS to INITIAL is just a marker to let context switch restore
  code know that it can load FP registers with zeroes instead of
  memory loads.  It does not imply that the hardware will reset all
  registers to zero on first access.  In addition, set the state to
  CLEAN instead of INITIAL after the first FP instruction.
  cpu_switch() doesn't do anything for INITIAL and only restores from
  the pcb if the state is CLEAN.  We could perhaps change cpu_switch
  to call fpe_state_clear if the state was INITIAL and leave SSTATE.FS
  set to INITIAL instead of CLEAN after the first FP instruction.
  However, adding this complexity to cpu_switch() doesn't seem worth
  the supposed gain.
- Only save the current FPU registers in fill_fpregs() if the request
  is made to save the current thread's registers.  Previously if a
  debugger requested FP registers via ptrace() it was getting a copy
  of the debugger's FP registers rather than the debugee's.

    [14 lines not shown]
DeltaFile
+53-0sys/riscv/riscv/swtch.S
+8-2sys/riscv/riscv/machdep.c
+6-1sys/riscv/riscv/trap.c
+1-0sys/riscv/include/fpe.h
+68-34 files

FreeBSD/src 14b841d (r337608)sys/dev/qlnx/qlnxe ecore_init_values.h reg_addr.h, sys/dev/usb/controller at91dci.c

MFH @ r337607, in preparation for boarding
DeltaFile
+51,685-49,575sys/dev/qlnx/qlnxe/ecore_init_values.h
+10,407-5,984sys/dev/qlnx/qlnxe/reg_addr.h
+2,891-2,449sys/dev/qlnx/qlnxe/ecore_dbg_values.h
+4,961-0sys/dev/qlnx/qlnxe/ecore_sriov.c
+2,041-945sys/dev/qlnx/qlnxe/ecore_dev.c
+0-2,382sys/dev/usb/controller/at91dci.c
+71,985-61,3351,587 files not shown
+127,140-133,2281,593 files

FreeBSD/src bbd7a92 (r337286)sys/amd64/amd64 support.S, sys/cddl/contrib/opensolaris/uts/common/fs/zfs space_map.c vdev_initialize.c

Merge ^/head r336870 through r337285, and resolve conflicts.
DeltaFile
+619-213sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c
+792-0sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_initialize.c
+432-161sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
+398-187sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_removal.c
+537-18sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c
+363-33sys/amd64/amd64/support.S
+3,141-612395 files not shown
+11,245-4,125401 files

FreeBSD/src 84154f4 (r337126)sys/riscv/riscv swtch.S

o Don't overwrite tp in fork_trampoline().
o Save and restore tp in cpu_switch().
o Restore tp in cpu_throw().
o Save tp in savectx().

This makes libthr tests happy. In particular fork_test:fork.

Sponsored by:   DARPA, AFRL
DeltaFile
+4-1sys/riscv/riscv/swtch.S
+4-11 files

FreeBSD/src 87f9acc (r336712)sys/riscv/riscv swtch.S

Remove unused string.

Reported by:    markj@
Sponsored by:   DARPA, AFRL
DeltaFile
+0-2sys/riscv/riscv/swtch.S
+0-21 files

FreeBSD/src fc2a877 (r331254)sys/arm/arm locore-v6.S, sys/conf kmod.mk kern.post.mk

Rename assym.s to assym.inc

assym is only to be included by other .s files, and should never
actually be assembled by itself.

Reviewed by:    imp, bdrewery (earlier)
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D14180
DeltaFile
+4-4sys/conf/kmod.mk
+4-4sys/modules/linux/Makefile
+3-3sys/modules/dtrace/dtrace/Makefile
+3-3sys/conf/kern.post.mk
+3-3sys/modules/linux64/Makefile
+2-2sys/arm/arm/locore-v6.S
+19-1988 files not shown
+109-10994 files

FreeBSD/src 083c8de (r322452)contrib/sqlite3 sqlite3.c shell.c, crypto/openssh ChangeLog

MFhead at r322451
DeltaFile
+15,396-8,833contrib/sqlite3/sqlite3.c
+4,433-0sys/dev/cxgbe/cudbg/cudbg_lib.c
+3,292-495contrib/sqlite3/shell.c
+1,171-2,043crypto/openssh/ChangeLog
+1,310-0sys/dev/cxgbe/cudbg/cudbg_wtp.c
+759-407contrib/sqlite3/sqlite3.h
+26,361-11,778656 files not shown
+39,747-16,486662 files

FreeBSD/src 0275f9d (r322398)contrib/sqlite3 sqlite3.c shell.c, crypto/openssh ChangeLog

Merge ^/head r321383 through r322397.
DeltaFile
+15,396-8,833contrib/sqlite3/sqlite3.c
+4,433-0sys/dev/cxgbe/cudbg/cudbg_lib.c
+3,292-495contrib/sqlite3/shell.c
+1,171-2,043crypto/openssh/ChangeLog
+1,310-0sys/dev/cxgbe/cudbg/cudbg_wtp.c
+141-1,061sys/contrib/dev/acpica/compiler/asltree.c
+25,743-12,4321,276 files not shown
+56,010-27,3111,282 files

FreeBSD/src af19cc5 (r322361)sys/boot/fdt/dts/riscv spike.dts lowrisc.dts, sys/riscv/include sbi.h

Support for v1.10 (latest) of RISC-V privilege specification.

New version is not compatible on supervisor mode with v1.9.1
(previous version).

Highlights:
    o BBL (Berkeley Boot Loader) provides no initial page tables
      anymore allowing us to choose VM, to build page tables manually
      and enable MMU in S-mode.
    o SBI interface changed.
    o GENERIC kernel.
      FDT is now chosen standard for RISC-V hardware description.
      DTB is now provided by Spike (golden model simulator). This
      allows us to introduce GENERIC kernel. However, description
      for console and timer devices is not provided in DTB, so move
      these devices temporary to nexus bus.
    o Supervisor can't access userspace by default. Solution is to
      set SUM (permit Supervisor User Memory access) bit in sstatus
      register.

    [8 lines not shown]
DeltaFile
+116-122sys/riscv/riscv/locore.S
+65-107sys/riscv/riscv/timer.c
+0-111sys/boot/fdt/dts/riscv/spike.dts
+89-21sys/riscv/include/sbi.h
+0-108sys/boot/fdt/dts/riscv/lowrisc.dts
+0-105sys/boot/fdt/dts/riscv/qemu.dts
+270-57429 files not shown
+423-1,01835 files

FreeBSD/src 67bc8c8 (r308842)contrib/amd/doc texinfo.tex, contrib/amd/fsinfo null_lex.c

Merge ^/head r308491 through r308841.
DeltaFile
+17,576-0sys/dev/bnxt/hsi_struct_def.h
+4,326-1,261contrib/amd/doc/texinfo.tex
+2,360-0sys/dev/bnxt/if_bnxt.c
+2,021-43contrib/amd/libamu/xdr_func.c
+1,791-0sys/dev/hyperv/pcib/vmbus_pcib.c
+1,716-0contrib/amd/fsinfo/null_lex.c
+29,790-1,304737 files not shown
+59,355-8,447743 files