Commit Graph

5584 Commits

Author SHA1 Message Date
Mark Johnston
706f4a81a8 exec: Introduce the PROC_PS_STRINGS() macro
Rather than fetching the ps_strings address directly from a process'
sysentvec, use this macro.  With stack address randomization the
ps_strings address is no longer fixed.

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33704
2022-01-17 16:11:54 -05:00
Mark Johnston
3fc21fdd5f sysent: Add a sv_psstringssz field to struct sysentvec
The size of the ps_strings structure varies between ABIs, so this is
useful for computing the address of the ps_strings structure relative to
the top of the stack when stack address randomization is enabled.

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33704
2022-01-17 11:42:07 -05:00
Brooks Davis
0910a41ef3 Revert "syscallarg_t: Add a type for system call arguments"
Missed issues in truss on at least armv7 and powerpcspe need to be
resolved before recommit.

This reverts commit 3889fb8af0.
This reverts commit 1544e0f5d1.
2022-01-12 23:29:20 +00:00
Brooks Davis
1544e0f5d1 syscallarg_t: Add a type for system call arguments
This more clearly differentiates system call arguments from integer
registers and return values. On current architectures it has no effect,
but on architectures where pointers are not integers (CHERI) and may
not even share registers (CHERI-MIPS) it is necessiary to differentiate
between system call arguments (syscallarg_t) and integer register values
(register_t).

Obtained from:	CheriBSD

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D33780
2022-01-12 22:51:25 +00:00
Andrew Turner
e7961ccd9f Remove Arm barriers for pre-armv6 CPUs
Remove the macros that define the Arm barriers on Armv5 and earlier. We
don't support these CPUs.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33807
2022-01-11 11:22:29 +00:00
Andrew Turner
ac795a774c Remove old arm CPU macros
The _ARM_ARCH_* and _HAVE_ARMv*_INSTRUCTIONS macros are FreeBSD
specific. Remove them as they are unused in the base system.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33806
2022-01-11 11:22:29 +00:00
John Baldwin
7def1e10b3 bus_dma: Deduplicate locking helper functions.
- Move busdma_lock_mutex to subr_bus_dma.c.

- Move _busdma_lock_dflt to subr_bus_dma.c.  This function was named a
  couple of different things previously.  It is not a public API but
  an internal helper used in place of a NULL pointer.  The prototype
  is in <sys/bus_dma.h> as not all backends include
  <sys/bus_dma_internal.h>.

Reviewed by:	kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D33694
2022-01-05 13:50:40 -08:00
John Baldwin
85b4607324 Deduplicate bus_dma bounce code.
Move mostly duplicated code in various MD bus_dma backends to support
bounce pages into sys/kern/subr_busdma_bounce.c.  This file is
currently #include'd into the backends rather than compiled standalone
since it requires access to internal members of opaque bus_dma
structures such as bus_dmamap_t and bus_dma_tag_t.

Reviewed by:	kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D33684
2022-01-05 13:50:40 -08:00
Hubert Mazur
f21c469dbc Add driver for marvell, a37x0 peripheral clocks
Add driver for Marvell, Armada-37xx peripheral clock.
Register clocks for various peripheral devices in
north bridge or south bridge domain. Dump clock's
domain while verbose boot.

Reviewed by:
Obtained from:		Semihalf
Differential revision:	https://reviews.freebsd.org/D32294
2022-01-04 13:26:35 +01:00
Hubert Mazur
127e4d9524 Add driver for armada, 37x0-tbg-clock
Driver for tbg clocks. Read reference frequency from parent
and modify it depending on parameters read from register.

Reviewed by:		manu
Obtained from:		Semihalf
Differential revision:	https://reviews.freebsd.org/D32293
2022-01-04 13:26:34 +01:00
Hubert Mazur
01b9c59fd2 Add driver for marvell, armada-3700 oscillator
Driver registers new clock device. Clock frequency is set depending
on tenth bit's value obtained from syscon register. Full information
about the clock is dumped if bootverbose is enabled.

Driver was tested on EspressoBin.

Reviewed by:		manu
Obtained from:		Semihalf
Differential revision:	https://reviews.freebsd.org/D32292
2022-01-04 13:26:34 +01:00
Doug Moore
f1e7a532d1 busdma: _bus_dmamap_addseg repaired
A recent change introduced a one-off error into a test allowing
coalescing chunks into segments.  This fixes that error.

broke a check in _bus_dmamap_addseg on many architectures. This change makes it clear that it is not a particular range that is being boundary-checked, but the proposed union of the two adjacent ranges.
Reported by:	se
Reviewed by:	se
Fixes:	c606ab59e7 vm_extern: use standard address checkers everywhere
Differential Revision:	https://reviews.freebsd.org/D33715
2022-01-02 12:37:05 -06:00
Doug Moore
c606ab59e7 vm_extern: use standard address checkers everywhere
Define simple functions for alignment and boundary checks and use them
everywhere instead of having slightly different implementations
scattered about. Define them in vm_extern.h and use them where
possible where vm_extern.h is included.

Reviewed by:	kib, markj
Differential Revision:	https://reviews.freebsd.org/D33685
2021-12-30 22:09:08 -06:00
Andrew Turner
6e1be96fd2 Add the missing terminator to the bcm_xhci methods
Sponsored by:	The FreeBSD Foundation
2021-12-29 12:20:01 +00:00
John Baldwin
254e4e5b77 Simplify swi for bus_dma.
When a DMA request using bounce pages completes, a swi is triggered to
schedule pending DMA requests using the just-freed bounce pages.  For
a long time this bus_dma swi has been tied to a "virtual memory" swi
(swi_vm).  However, all of the swi_vm implementations are the same and
consist of checking a flag (busdma_swi_pending) which is always true
and if set calling busdma_swi.  I suspect this dates back to the
pre-SMPng days and that the intention was for swi_vm to serve as a
mux.  However, in the current scheme there's no need for the mux.

Instead, remove swi_vm and vm_ih.  Each bus_dma implementation that
uses bounce pages is responsible for creating its own swi (busdma_ih)
which it now schedules directly.  This swi invokes busdma_swi directly
removing the need for busdma_swi_pending.

One consequence is that the swi now works on RISC-V which had previously
failed to invoke busdma_swi from swi_vm.

Reviewed by:	imp, kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D33447
2021-12-28 13:51:25 -08:00
Adrian Chadd
c7f93ee5cc ipq4018_usb_phy: remove old debugging routine
This isn't needed anymore, I know that these work!
2021-12-27 18:33:06 -08:00
Adrian Chadd
777963afb5 qcom_dwc3: add initial Qualcomm SoC DWC3 controller glue
This adds some very simple DWC3 glue for the IPQ4018/IPQ4019.
Other chipsets introduce reset line iteration, some further
clock line iteration and some customisations; I'll look at adding
those later.

This is enough to finally bring up USB 3.0 on my IPQ4018 ASUS
RT-58U router.
2021-12-27 18:25:32 -08:00
Adrian Chadd
86f0c3ec13 ipq4018_usb_phy: add USB 2.0 and 3.0 PHY support
This adds the USB 2.0 and 3.0 PHY support for the IPQ4018/IPQ4019.

All it really needs to do is gate the relevant clocks on/off in the
right order with the right delays.
2021-12-27 18:21:36 -08:00
Adrian Chadd
d11f81afd5 qcom_tcsr: add initial top control and status register (TCSR) support
The Qualcomm TCSR is some top level glue between multiple IP blocks,
both for doing configuration of said IP blocks, some IPC between
them (mostly between multiple execution environments - eg trustzone
and non-TZ), and interrupt status bits for them.

However, for the IPQ4018/IPQ4019, it only is used as a small subset
of IP block configuration.  As for what it actually gets used as
for other Qualcomm chipsets?  Well, that'll have to wait.

It's a bit of a mess in linux and openwrt.  See, every different
SoC support branch ends up with some different TCSR code for it.

So instead, I'm going to land a single TCSR driver that I'm going
to use for the IPQ4018/IPQ4019.  When I add the next chipset, I'll
figure out how to organise things so there's a single TCSR driver
that works for multiple platforms.
2021-12-27 15:56:28 -08:00
Adrian Chadd
d27ba30884 qcom_qup: add initial v1/v2 QUP SPI driver
The Qualcomm Universal Peripherals Engine (QUP) is a unified SPI and I2C
peripheral that ships with a variety of Qualcomm SoCs.

It supports three transfer modes - single PIO, block PIO and DMA.

This driver only supports the single PIO mode, which is enough to
bootstrap the rest of the SPI NAND/NOR support and means I can do
things like read the Wifi calibration data from NOR.  It has some
hardware support code for the other transfer modes as well as
some support for split transfers (ie, transfers with no read or
write phase), but I haven't yet implemented those.

This driver is based on four sources - the linux driver, the u-boot
driver, some initial work done for APQ8064 by mmel@, and the APQ8064
Technical Reference Manual which is surprisingly free and open to
read.  The linux and u-boot drivers approach a variety of things
completely differently, from how PIO is done, the hardware support
for re-ordering bytes in a transfer word and how the CS lines
are used.

Tested:

* IPQ4018, SPI to NAND/NOR flash, PIO only
2021-12-27 15:27:29 -08:00
Adrian Chadd
7b36da4843 qca: add cpufreq into the build
Now that the clock drivers are in the tree, the cpufreq driver will
"just work".

Tested:

* IPQ4018, testing performance of dd from /dev/zero->/dev/null at
  each frequency step.
2021-12-27 13:13:38 -08:00
Adrian Chadd
cd32ac640b Add support for qualcomm clock nodes the the IPQ4018/IPQ4019 clock tree.
Summary: I've tested this with cpufreq_dt, SPI and USB.  They all seem to work fine.

Test Plan: * IPQ4018, boot

Subscribers: imp, andrew

Differential Revision: https://reviews.freebsd.org/D33665
2021-12-27 13:02:31 -08:00
Adrian Chadd
e34a491b35 qcom_clk: add the qualcomm clock nodes for the IPQ4018
These clock nodes are used by the IPQ4018/IPQ4019 and derivatives.
They're also used by other 32 and 64 bit qualcomm parts; so it's
best to put these nodes here in a single qcom_clk driver and add
to it as we grow new Qualcomm SoC support.

Tested:

* IPQ4018, boot

Differential Revision: https://reviews.freebsd.org/D33665
2021-12-27 13:02:30 -08:00
Michal Meloun
6e9119768d tegra/ahci: do not advertise enclosure management facility
It is not implemented in HW.

MFC after:	1 week
2021-12-24 20:36:46 +01:00
Michal Meloun
be01656fa4 tegra124: Implement new get_gate method for tegra124 clocks.
MFC after:	1 week
2021-12-24 20:16:24 +01:00
Adrian Chadd
95a70e9ea8 qca: add the TLMM code into the build
This adds the IPQ4018 TLMM code into the IPQ4018 build.

Differential Revision: https://reviews.freebsd.org/D33554
2021-12-23 10:42:00 -08:00
Adrian Chadd
4abe6533e9 qcom_tlmm: add initial gpio/pinmux controller (TLMM)
The qualcomm TLMM (top level mode manager) is their gpio/pinmux hardware
controller.

Although the pinmux is generic enough to use for the IPQ/APQ series
chips, I'm directly calling the IPQ4018 routines to expedite bring-up.

Notably, I'm not yet implementing the interrupt support - it's not
required at this stage of bring-up.

Differential Revision: https://reviews.freebsd.org/D33554
2021-12-23 10:41:41 -08:00
Andriy Gapon
08ff54dc5b aw_spi: improve I/O stability
This driver does not use DMA at the moment, so some care is needed to
prevent TX FIFO underruns and RX FIFO overflows.
Several improvements are done in oder to minimize chances of those.

First, the interrupt handling is moved to a filter to minimize latency.
Second, FIFO trigger thresholds are configured for both FIFOs.
The TX FIFO threshold is set to 3/4-th of its size and the RX FIFO
threshold is set to 1/4-th of its size.
The interrupt conditions are changed from the empty FIFO and full FIFO
for the TX and RX correspondingly to going below and above the thresholds.

While here I renamed AW_SPI_IER_RF_ERQ to AW_SPI_IER_RF_RDY which is
closer to what the documentation uses, RF_RDY_INT_EN in the interrupt
control register and RX_RDY in the interrupt status register.

Reviewed by:	manu
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D33558
2021-12-20 12:40:17 +02:00
Hans Petter Selasky
48014c6679 Try to fix syntax of "strht" instruction so that clang is happy.
This fixes compilation of usb(4) after 0ec590d24e .

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-12-19 13:52:36 +01:00
Hans Petter Selasky
516df15582 Implement suword16() for the 32-bit ARMv6/v7 architecture.
This fixes compilation of usb(4) after 0ec590d24e .

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-12-19 12:21:21 +01:00
Andrew Turner
36499dc789 Fix a set but not used warning in the arm GIC driver
Sponsored by:	Innovate UK
2021-12-10 13:29:11 +00:00
Alexander Motin
8493918868 busdma: Remove outdated comments about Giant.
MFC after:	2 weeks
2021-12-09 22:18:53 -05:00
John Baldwin
1a62e9bc00 Add <machine/tls.h> header to hold MD constants and helpers for TLS.
The header exports the following:

- Definition of struct tcb.
- Helpers to get/set the tcb for the current thread.
- TLS_TCB_SIZE (size of TCB)
- TLS_TCB_ALIGN (alignment of TCB)
- TLS_VARIANT_I or TLS_VARIANT_II
- TLS_DTV_OFFSET (bias of pointers in dtv[])
- TLS_TP_OFFSET (bias of "thread pointer" relative to TCB)

Note that TLS_TP_OFFSET does not account for if the unbiased thread
pointer points to the start of the TCB (arm and x86) or the end of the
TCB (MIPS, PowerPC, and RISC-V).

Note also that for amd64, the struct tcb does not include the unused
tcb_spare field included in the current structure in libthr.  libthr
does not use this field, and the existing calls in libc and rtld that
allocate a TCB for amd64 assume it is the size of 3 Elf_Addr's (and
thus do not allocate room for tcb_spare).

A <sys/_tls_variant_i.h> header is used by architectures using
Variant I TLS which uses a common struct tcb.

Reviewed by:	kib (older version of x86/tls.h), jrtc27
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33351
2021-12-09 13:17:13 -08:00
Mateusz Guzik
793c74e415 arm/freescale: remove FBIOSCURSOR
Unbreaks building EFIKA_MX

Fixes:	b9d3b253e2 ("fb: Remove unused cursors ioctls")
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-12-09 17:00:43 +00:00
Brooks Davis
547566526f Make struct syscall_args machine independent
After a round of cleanups in late 2020, all definitions are
functionally identical.

This removes a rotted __aligned(8) on arm. It was added in
b7112ead32 and was intended to align the
args member so that 64-bit types (off_t, etc) could be safely read on
armeb compiled with clang. With the removal of armev, this is no
longer needed (armv7 requires that 32-bit aligned reads of 64-bit
values be supported and we enable such support on armv6).  As further
evidence this is unnecessary, cleanups to struct syscall_args have
resulted in args being 32-bit aligned on 32-bit systems.  The sole
effect is to bloat the struct by 4 bytes.

Reviewed by:	kib, jhb, imp
Differential Revision:	https://reviews.freebsd.org/D33308
2021-12-08 18:45:33 +00:00
Gordon Bergling
b86066a15e omap4: Fix a few typos in source code comments
- s/addresss/address/

MFC after:	3 days
2021-12-04 12:13:27 +01:00
Mitchell Horne
0d2224733e Implement GET_STACK_USAGE on remaining archs
This definition enables callers to estimate remaining space on the
kstack, and take action on it. Notably, it enables optimizations in the
GEOM and netgraph subsystems to directly dispatch work items when there
is sufficient stack space, rather than queuing them for a worker thread.

Implement it for riscv, arm, and mips. Remove the #ifdefs, so it will
not go unimplemented elsewhere.

PR:		259157
Reviewed by:	mav, kib, markj (previous version)
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32580
2021-11-30 11:15:56 -04:00
Leandro Lupori
b9f3b63ab2 vt: export RGB offsets with FBIO_GETRGBOFFS
Add a new ioctl to vt to make it possible to export RGB offsets
set by vt drivers. This is needed to fix colors on X and Mesa
on some machines, especially on modern PowerPC64 BE ones.

With the appropriate changes in SCFB, to use this ioctl to find
out the correct RGB offsets, this fixes wrong colors on Talos II
and Blackbird, when used with their built-in video cards.

Reviewed by:		alfredo
Sponsored by:		Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D29000
2021-11-25 16:39:25 -03:00
Mark Johnston
ecbbe83144 netinet: Deduplicate most in_cksum() implementations
in_cksum() and related routines are implemented separately for each
platform, but only i386 and arm have optimized versions.  Other
platforms' copies of in_cksum.c are identical except for style
differences and support for big-endian CPUs.

Deduplicate the implementations for the rest of the platforms.  This
will make it easier to implement in_cksum() for unmapped mbufs.  On arm
and i386, define HAVE_MD_IN_CKSUM to mean that the MI implementation is
not to be compiled.

No functional change intended.

Reviewed by:	kp, glebius
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33095
2021-11-24 13:31:16 -05:00
Warner Losh
b57e0aa4ef arm: Make machine/reg.h self-contained
Allow inclusion of sys/reg.h w/o pre-requisites by making arm's machine/reg.h
self-contained.

Sponsored by:		Netflix
2021-11-23 21:21:17 -07:00
Mitchell Horne
10fe6f80a6 minidump: Use the provided dump bitset
When constructing the set of dumpable pages, use the bitset provided by
the state argument, rather than assuming vm_page_dump invariably. For
normal kernel minidumps this will be a pointer to vm_page_dump, but when
dumping the live system it will not.

To do this, the functions in vm_dumpset.h are extended to accept the
desired bitset as an argument. Note that this provided bitset is assumed
to be derived from vm_page_dump, and therefore has the same size.

Reviewed by:	kib, markj, jhb
MFC after:	2 weeks
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D31992
2021-11-19 15:05:52 -04:00
Mitchell Horne
1d2d1418b4 minidump: Use provided msgbuf pointer
Don't assume we are dumping the global message buffer, but use the one
provided by the state argument. While here, drop superfluous
cast to char *.

Reviewed by:	markj, jhb
MFC after:	2 weeks
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D31991
2021-11-19 15:05:52 -04:00
Mitchell Horne
681bd71047 minidump: reduce the amount direct accesses to page tables
During a live dump, we may race with updates to the kernel page tables.
This is generally okay; we accept that the state of the system while
dumping may be somewhat inconsistent with its state when the dump was
invoked. However, when walking the kernel page tables, it is important
that we load each PDE/PTE only once while operating on it. Otherwise, it
is possible to have the relevant PTE change underneath us. For example,
after checking the valid bit, but before reading the physical address.

Convert the loads to atomics, and add some validation around the
physical addresses, to ensure that we do not try to dump a non-existent
or non-canonical physical address.

Similarly, don't read kernel_vm_end more than once, on the off chance
that pmap_growkernel() is called between the two page table walks.

Reviewed by:	kib, markj
MFC after:	2 weeks
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D31990
2021-11-19 15:05:52 -04:00
Mitchell Horne
1adebe3cd6 minidump: Parameterize minidumpsys()
The minidump code is written assuming that certain global state will not
change, and rightly so, since it executes from a kernel debugger
context. In order to support taking minidumps of a live system, we
should allow copies of relevant global state that is likely to change to
be passed as parameters to the minidumpsys() function.

This patch does the work of parameterizing this function, by adding a
struct minidumpstate argument. For now, this struct allows for copies of
the kernel message buffer, and the bitset that tracks which pages should
be dumped (vm_page_dump). Follow-up changes will actually make use of
these arguments.

Notably, dump_avail[] does not need a snapshot, since it is not expected
to change after system initialization.

The existing minidumpsys() definitions are renamed, and a thin MI
wrapper is added to kern_dump.c, which handles the construction of
the state struct. Thus, calling minidumpsys() remains as simple as
before.

Reviewed by:	kib, markj, jhb
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D31989
2021-11-19 15:05:52 -04:00
Gordon Bergling
8b11850f9d TWL: Fix a typo in a source code comment
- s/maxium/maximum/

MFC after:	3 days
2021-11-19 19:26:34 +01:00
Elyes HAOUAS
9097ac9af4 Fix typo on "Celsius"
"Celcius" --> "Celsius"

Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Pull Request: https://github.com/freebsd/freebsd-src/pull/551/files
2021-11-18 23:05:32 -07:00
Kristof Provost
4e85b64890 Add a COMPAT_FREEBSD13 kernel option
Use it wherever COMPAT_FREEBSD11 is currently specified.

Reviewed by:	jhb (previous version)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33005
2021-11-17 03:08:40 +01:00
Warner Losh
7e3c9ec906 tcp: better congestion control defaults
Define CC_NEWRENO in all the appropriate DEFAULTS and std.* config
files. It's the default congestion control algorithm.  Add code to cc.c
so that CC_DEFAULT is "newreno" if it's not overriden in the config
file.

Sponsored by: Netflix
Fixes: b8d60729de ("tcp: Congestion control cleanup.")
Revired by: manu, hselasky, jhb, glebius, tuexen
Differential Revision:	https://reviews.freebsd.org/D32964
2021-11-12 12:16:11 -07:00
Randall Stewart
b8d60729de tcp: Congestion control cleanup.
NOTE: HEADS UP read the note below if your kernel config is not including GENERIC!!

This patch does a bit of cleanup on TCP congestion control modules. There were some rather
interesting surprises that one could get i.e. where you use a socket option to change
from one CC (say cc_cubic) to another CC (say cc_vegas) and you could in theory get
a memory failure and end up on cc_newreno. This is not what one would expect. The
new code fixes this by requiring a cc_data_sz() function so we can malloc with M_WAITOK
and pass in to the init function preallocated memory. The CC init is expected in this
case *not* to fail but if it does and a module does break the
"no fail with memory given" contract we do fall back to the CC that was in place at the time.

This also fixes up a set of common newreno utilities that can be shared amongst other
CC modules instead of the other CC modules reaching into newreno and executing
what they think is a "common and understood" function. Lets put these functions in
cc.c and that way we have a common place that is easily findable by future developers or
bug fixers. This also allows newreno to evolve and grow support for its features i.e. ABE
and HYSTART++ without having to dance through hoops for other CC modules, instead
both newreno and the other modules just call into the common functions if they desire
that behavior or roll there own if that makes more sense.

Note: This commit changes the kernel configuration!! If you are not using GENERIC in
some form you must add a CC module option (one of CC_NEWRENO, CC_VEGAS, CC_CUBIC,
CC_CDG, CC_CHD, CC_DCTCP, CC_HTCP, CC_HD). You can have more than one defined
as well if you desire. Note that if you create a kernel configuration that does not
define a congestion control module and includes INET or INET6 the kernel compile will
break. Also you need to define a default, generic adds 'options CC_DEFAULT=\"newreno\"
but you can specify any string that represents the name of the CC module (same names
that show up in the CC module list under net.inet.tcp.cc). If you fail to add the
options CC_DEFAULT in your kernel configuration the kernel build will also break.

Reviewed by: Michael Tuexen
Sponsored by: Netflix Inc.
RELNOTES:YES
Differential Revision: https://reviews.freebsd.org/D32693
2021-11-11 06:28:18 -05:00
Edward Tomasz Napierala
65e485014b Remove unfinished ARM Linuxulator support
This was never made to work, and given that 32-bit ARM support
is quickly becoming irrelevant, there is no point in keeping it
in the tree.

Sponsored By:	EPSRC
Reviewed By:	emaste
Differential Revision:	https://reviews.freebsd.org/D32918
2021-11-09 14:40:44 +00:00
Kyle Evans
6a8ea6d174 sched: split sched_ap_entry() out of sched_throw()
sched_throw() can no longer take a NULL thread, APs enter through
sched_ap_entry() instead.  This completely removes branching in the
common case and cleans up both paths.  No functional change intended.

Reviewed by:	kib, markj
Differential Revision:	https://reviews.freebsd.org/D32829
2021-11-05 15:45:51 -05:00
Adrian Chadd
cfd0698702 ipq4018: add qcom-gcc-ipq4018 and dependencies into the build
* add the extres stuff into the build, I'm going to end up leveraging
  all of it

* include the qcom-gcc-ipq4018 driver which currently implements the hwreset
  side of the API.

Reviewed by: andrew, manu, imp
Differential Revision: https://reviews.freebsd.org/D32723
2021-11-04 09:02:43 -07:00
Adrian Chadd
b12a863a1e ipq4018: add initial reset driver support for the clock/reset controller.
This implements the "reset controller" side of the clock/reset controller.
It's a simple array of registers and bits to set.

The register table itself comes from Linux; the rest of the code is a
reimplementation.

It doesn't yet implement or expose the clock side - I have a lot of
reverse engineering to do before that!

Reviewed by: andrew, manu, imp
Differential Revision: https://reviews.freebsd.org/D32723

Obtained from: Linux (registers)
2021-11-04 09:02:41 -07:00
Adrian Chadd
bc06496744 ipq401x: flip on SMP for the ASUS AC1300
This actually enables SMP and yes it boots.

Reviewed by: andrew, manu, imp
Differential Revision: https://reviews.freebsd.org/D32723
2021-11-04 09:02:38 -07:00
Adrian Chadd
d3514c2942 ipq401x: add MP core start-up path for the CPU regulator/clock gate used
This code implements the "kpssv2" flavour of CPU regulator/clock gating
in Linux.  It's used by at least the ipq4018/4019 to power on and off
CPU cores.

This is based on the Linux implementation - the register definitions
and values are from Linux and I've reverse engineered the sequencing
requirements.

The MP bring-up is:

* set cold boot address via an SCM call - this is the address used
  by the bootloader/TZ firmware to jump to when the CPUs boot

* power down the LDO feeding the CPU core and wait for it to settle

* program in the right set of LDO and power tree configuration for
  the CPU regulator to power up the core.  Unfortunately these are
  magic numbers that I've not found documented anywhere.

* (I think) power up the shared L2 cache connect if it isn't.

* Clamp the power into the core down; put the core into reset

* Unclamp the power rail; release reset; and then set the core to boot.

The MP core will then boot the bootloader/TZ firmware and then
will wait until an incoming interrupt kicks it to start @ mpentry.

Tested:

* IPQ4019, 4 CPUs

Release APs
CPU(3) applied BP hardening: not necessary
CPU(1) applied BP hardening: not necessary
CPU(2) applied BP hardening: not necessary

Reviewed by: andrew, manu, imp
Differential Revision: https://reviews.freebsd.org/D32723
2021-11-04 09:02:36 -07:00
Adrian Chadd
960e65d23a qcom: add initial SCM legacy API
This is a very simple implementation of Qualcomm's SCM API.

It is just the structure/field definitions and the atomic SCM
call which doesn't use the structs yet - it uses the field
definitions inside registers.

I've tested that setting the cold boot address via the atomic
API is fine - Linux does the same thing.  But not all SCM calls
can be done via the legacy API.

This is a reimplementation based on the Linux qualcomm SCM legacy
code and definitions.

Tested:

* Qualcomm IPQ4018 AP, as part of other changes for doing SMP bring-up

Reviewed by: andrew, manu, imp
Differential Revision: https://reviews.freebsd.org/D32723
2021-11-04 09:02:33 -07:00
Adrian Chadd
a516ccc4ae ipq4018: add SoC reset and qcom_rnd driver
Summary:
This is enough to allow this ASUS router to reboot successfully.
I tried the watchdog path and although it fires, it isn't rebooting!
It's just hanging, likely somewhere in TZ.

This is the MVP required to initialise and consume random data from
the QCA PRNG hardware found on the IPQ401x.

Test Plan: * ASUS RT-AC58U router, IPQ4019

Subscribers: imp, andrew

Differential Revision: https://reviews.freebsd.org/D32723
2021-11-04 09:02:30 -07:00
Adrian Chadd
6325f105aa ipq4018: toggle ps-hold to allow SoC reset
This is enough to allow this ASUS router to reboot successfully.
I tried the watchdog path and although it fires, it isn't rebooting!
It's just hanging, likely somewhere in TZ.

Tested:

* ASUS RT-AC58U router, IPQ4019

Reviewed by: andrew, manu, imp
Differential Revision: https://reviews.freebsd.org/D32723
2021-11-04 09:02:21 -07:00
Kyle Evans
589aed00e3 sched: separate out schedinit_ap()
schedinit_ap() sets up an AP for a later call to sched_throw(NULL).

Currently, ULE sets up some pcpu bits and fixes the idlethread lock with
a call to sched_throw(NULL); this results in a window where curthread is
setup in platforms' init_secondary(), but it has the wrong td_lock.
Typical platform AP startup procedure looks something like:

- Setup curthread
- ... other stuff, including cpu_initclocks_ap()
- Signal smp_started
- sched_throw(NULL) to enter the scheduler

cpu_initclocks_ap() may have callouts to process (e.g., nvme) and
attempt to sched_add() for this AP, but this attempt fails because
of the noted violated assumption leading to locking heartburn in
sched_setpreempt().

Interrupts are still disabled until cpu_throw() so we're not really at
risk of being preempted -- just let the scheduler in on it a little
earlier as part of setting up curthread.

Reviewed by:	alfredo, kib, markj
Triage help from:	andrew, markj
Smoke-tested by:	alfredo (ppc), kevans (arm64, x86), mhorne (arm)
Differential Revision:	https://reviews.freebsd.org/D32797
2021-11-03 15:54:59 -05:00
Warner Losh
c47a4a2375 arm: Remove unused items
Remote detritis copied, apparently, from sparc. utrap has never been
used on arm, so it's safe to just remove it.

Sponsored by:		Netflix
2021-11-03 13:54:36 -06:00
Ruslan Bukin
4bb6991531 arm/pmu: add ACPI attachment.
This makes hwpmc(4) sampling work on ACPI-based AArch64 systems.
Tested on ARM Neoverse N1.

Submitted by: Greg V <greg@unrelenting.technology>
Reviewed by: jrtc27, mhorne
Differential Revision: https://reviews.freebsd.org/D24423
2021-11-02 19:35:29 +00:00
Michal Meloun
a670e1c13a arm: Fix handling of undefined instruction aborts in THUMB2 mode.
Correctly recognize NEON/SIMD and VFP instructions in THUMB2 mode and pass
these to the appropriate handler. Note that it is not necessary to filter
all undefined instruction variant or register combinations, this is a job
for given handler.

Reported by:	Robert Clausecker <fuz@fuz.su>
PR:		259187
MFC after:	2 weks
2021-11-02 11:11:44 +01:00
Warner Losh
aa15f7df64 arm: Remove obsolete comments
FreeBSD has never supported arm26, so remove comments about what
trapframes look like for that platform.

Noticed by:		kevans
Sponsored by:		Netflix
2021-10-27 09:44:58 -06:00
Mateusz Guzik
e2493f4912 arm: fix a typo in nvidia/drm2/tegra_bo.c
Unbreaks building TEGRA124

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-10-25 18:42:10 +00:00
Mark Johnston
84c3922243 Convert consumers to vm_page_alloc_noobj_contig()
Remove now-unneeded page zeroing.  No functional change intended.

Reviewed by:	alc, hselasky, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32006
2021-10-19 21:22:56 -04:00
Mark Johnston
a4667e09e6 Convert vm_page_alloc() callers to use vm_page_alloc_noobj().
Remove page zeroing code from consumers and stop specifying
VM_ALLOC_NOOBJ.  In a few places, also convert an allocation loop to
simply use VM_ALLOC_WAITOK.

Similarly, convert vm_page_alloc_domain() callers.

Note that callers are now responsible for assigning the pindex.

Reviewed by:	alc, hselasky, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31986
2021-10-19 21:22:56 -04:00
Adrian Chadd
015ff812d6 ipq4018: add initial IPQ4018/IPQ4019 support
Summary:
This adds required IPQ4018/IPQ4019 SoC support to boot.
It also includes support for disabling the ARMv7 hardware
breakpoint / debug stuff at compile time as this is
required for the IPQ SoCs, and printing out the undefined
instruction itself.

Test Plan: * compiled/booted on an IPQ4019 SoC AP

Reviewers: #core_team!

Subscribers: imp, andrew

Differential Revision: https://reviews.freebsd.org/D32538
2021-10-18 19:19:06 +00:00
Adrian Chadd
fb7a007728 arm: add a std.qca for 32 bit armv7 platforms
This is the minimal config required to boot on the IPQ4018 SoC
and likely future ones as well in this family.
2021-10-18 19:19:03 +00:00
Adrian Chadd
02438ce5fd ipq4018: add initial IPQ4018/IPQ4019 support
This is for the Qualcomm Atheros quad-core ARMv7 SoC with built-in
2x2 2GHz and 5GHz ath10k devices.

It's enough (with an upcoming set of config files) to netboot
on an ASUS router I have here and get to a single core mountroot
prompt.
2021-10-18 19:19:00 +00:00
Adrian Chadd
c29c0e6876 arm: allow the debug stuff in CP14 to be disabled at compile time
The upcoming QCA ipq401x support detects the CP14 debug features,
but any attempt to use it causes an undefined instruction error.
It apparently needs a specific TZ image loaded by the early bootloader
(SBL) in order to enable these kinds of features.

So add a new kernel option that explicitly disables this in the
arm code - the debugger works fine without it.
2021-10-18 19:18:56 +00:00
Adrian Chadd
8398d52d65 arm: print out the undefined instruction upon an undefined instruction panic
It's SUPER useful to be able to see the actual undefined instruction
when we hit said undefined instruction.
2021-10-18 19:18:52 +00:00
Konstantin Belousov
e81e77c5a0 Enable PPS_SYNC on amd64, arm64 and armv7
Remove the option from NOTES/LINT, and add to NOTES for powerpc and
riscv.

PR:	259036
Requested by:	John Hay <john@sanren.ac.za>
Discussed with:	ian, imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-10-10 22:34:40 +03:00
Mitchell Horne
17f790f49f arm, arm64, riscv: adjust top-level nexus comment
These platforms don't manage resources for DMA request lines or I/O
ports, this is specific to x86. Remove the references from the comments.

Reviewed by:	imp, jhb
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32358
2021-10-08 14:16:32 -03:00
Konstantin Belousov
dfaf65023e arm: move signal delivery code to exec_machdep.c
Reviewed by:	emaste, imp
Discussed with:	jrtc27
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32310
2021-10-08 03:20:42 +03:00
Andrew Turner
507a22be38 Add the missing license to gic_if.m
Sponsored by:	The FreeBSD Foundation
2021-10-04 13:21:21 +01:00
Tom Hukins
202692b1a7 arm64: Spell BeagleBone correctly in config file.
Pull Request:		https://github.com/freebsd/freebsd-src/pull/545
2021-10-02 10:30:14 -06:00
Gordon Bergling
42dfad2ef1 ti(4): Fix a typo in an error message
- s/chanels/channels/

MFC after:	1 week
2021-10-02 10:51:29 +02:00
Andrew Turner
18c2139495 Add a gic interface to allocate MSI interrupts
The previous update to handle the gicv2m as a child of the gicv3 driver
assumed there was only a single gicv2m child. On some hardware there
are multiple children. Support this by removing the mbi ivars and
adding a new interface to handle MSI allocation in a given range.

Tested by:	mw, trasz
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32224
2021-10-01 11:27:33 +01:00
Mitchell Horne
ab4ed843a3 minidump: De-duplicate the progress bar
The implementation of the progress bar is simple, but duplicated for
most minidump implementations. Extract the common bits to kern_dump.c.
Ensure that the bar is reset with each subsequent dump; this was only
done on some platforms previously.

Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D31885
2021-09-29 16:42:21 -03:00
Mitchell Horne
31991a5a45 minidump: De-duplicate is_dumpable()
The function is identical in each minidump implementation, so move it to
vm_phys.c. The only slight exception is powerpc where the function was
public, for use in moea64_scan_pmap().

Reviewed by:	kib, markj, imp (earlier version)
MFC after:	2 weeks
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D31884
2021-09-29 16:41:52 -03:00
Andrew Turner
f3aa0098a8 Use mtx_lock_spin in the gic driver
The mutex was changed to a spin lock when the MSI/MSI-X handling was
moved from the gicv2m to the gic driver. Update the calls to lock
and unlock the mutex to the spin variant.

Submitted by:	jrtc27 ("Change all the mtx_(un)lock(&sc->mutex) to be the _spin versions.")
Reported by:	mw, antranigv@freebsd.am
Sponsored by:	The FreeBSD Foundation
2021-09-28 12:42:06 +01:00
Olivier Houchard
a342ecd326 arm: Handle thumb2 thread entry point.
In cpu_set_upcall(), if the thread startup routine is a thumb routine, make
sure to set PSR_T, so that the CPU will run in thumb mode.

MFC After:      1 week
2021-09-21 23:20:27 +02:00
Konstantin Belousov
cf0ee8738e Drop cloudabi
According to https://github.com/NuxiNL/cloudlibc:
CloudABI is no longer being maintained. It was an awesome experiment,
but it never got enough traction to be sustainable.

There is no reason to keep it in FreeBSD.

Approved by:	ed (private mail)
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D31923
2021-09-22 00:18:44 +03:00
Mitchell Horne
806ebc9eba bcm2835_sdhci: don't use DMA for kernel dumps
When handling a data irq, the sdhci driver calls the
sdhci_platform_will_handle() method, to determine if it should allow the
platform driver to handle the transfer or fall back to programmed I/O.
While dumping, the data irq path may be invoked directly (not from an
interrupt context), which the bcm2835_sdhci DMA code is not prepared to
handle. Return early in this case, to force the fallback to PIO.

Otherwise, the KASSERT that follows will be triggered, and the dump will
fail. On non-INVARIANTS kernels, the system will hang, waiting for a DMA
interrupt that will never arrive.

Reviewed by:	kevans
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31893
2021-09-21 10:08:39 -03:00
Bartlomiej Grzesik
8a8166e5bc mmc: switch mmc_helper to device_ api
Add generic mmc_helper which uses newly introduced device_*_property
api. Thanks to this change the sd/mmc drivers will be capable
of parsing both DT and ACPI description.

Ensure backward compatibility for all mmc_fdt_helper users.

Reviewed by: manu, mw
Sponsored by: Semihalf
Differential revision: https://reviews.freebsd.org/D31598
2021-09-20 17:18:02 +02:00
Andrew Turner
90f33f34ba Remove a bogus assertion from the gic drivers
When setting a message based interrupt range we set the base and count.
In an earlier the count was implemented as an end value, however the
asserts used to check this value was correct were incorrectly left in.

Reported by:	emaste
Sponsored by:	The FreeBSD Foundation
2021-09-14 19:06:25 +00:00
Andrew Turner
c6f3076d44 Move the GICv2m msi handling to the parent
This is in preperation for adding support for the GICv2m driver as a
child of the GICv3 driver.

PR:             258136
Reported by:    trasz
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31767
2021-09-14 08:24:52 +01:00
Kevin Bowling
5647f85ade Revert "arm: Bump KSTACK_PAGES default to match i386/amd64"
This reverts commit b684d812fc.

It causes an issue on a pfsense routing workload where memory
fragmentation prevents the necessary consecutive pages from being
readily available.

Reported by:	pfsense (mjg, scottl)
Approved by:	ian
MFC after:	1 day
Differential Revision:	https://reviews.freebsd.org/D31244
2021-09-01 13:13:27 -07:00
Andrew Turner
b792434150 Create sys/reg.h for the common code previously in machine/reg.h
Move the common kernel function signatures from machine/reg.h to a new
sys/reg.h. This is in preperation for adding PT_GETREGSET to ptrace(2).

Reviewed by:	imp, markj
Sponsored by:	DARPA, AFRL (original work)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19830
2021-08-30 12:50:53 +01:00
Gordon Bergling
5bdf58e196 Fix some common typos in source code comments
- s/priviledged/privileged/
- s/funtion/function/
- s/doens't/doesn't/
- s/sychronization/synchronization/

MFC after:	3 days
2021-08-28 18:57:23 +02:00
Mateusz Guzik
80b1995bb5 arm: export actlr as sysctl hw.cpu.quirks.actlr_value
Reviewed by:	cognet
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-08-24 14:21:39 +00:00
Mateusz Guzik
a121115621 arm: retire bzero
Same as bcopy.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-08-23 15:23:42 +02:00
Mateusz Guzik
aec8ad8a9e arm: hide busdma statistics behind ifdef ARM_BUSDMA_MAPLOAD_STATS
Stat collection using counter(9) is quite expensive on this platform and
these counters are normally not needed.

In particular we see about 1.5% bump in packet rate using Cortex-A9

Reviewed by:	ian
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Different Revision:	https://reviews.freebsd.org/D31592
2021-08-18 17:24:53 +02:00
Gordon Bergling
a1581cd735 Fix a common typo in source code comments
- s/aligment/alignment/

MFC after:	5 days
2021-08-14 14:17:48 +02:00
Dmitry Chagin
0c08f34f4d linux(4): Regen for clone syscall.
MFC after:		2 weeks
2021-08-12 11:47:31 +03:00
Dmitry Chagin
f1c450492f linux(4): Change clone syscall definition to match Linux actual one.
Differential revision:	https://reviews.freebsd.org/D31473
MFC after:		2 weeks
2021-08-12 11:46:36 +03:00
Ed Maste
9feff969a0 Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights
These ones were unambiguous cases where the Foundation was the only
listed copyright holder (in the associated license block).

Sponsored by:	The FreeBSD Foundation
2021-08-08 10:42:24 -04:00
Warner Losh
e94f1a0a37 Revert "arm: remove fslsdma from GENERIC"
The firmware was already in the tree when I did this commit, and I
missed the message. The bug was obsolete.

This reverts commit 9e3761d126.

PR:		237466
Sponsored by:	Netflix
2021-08-03 20:10:32 -06:00
Konstantin Belousov
041b7317f7 Add pmap_vm_page_alloc_check()
which is the place to put MD asserts about allocated pages.

On amd64, verify that allocated page does not belong to the kernel
(text, data) or early allocated pages.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D31121
2021-07-31 16:53:42 +03:00
Emmanuel Vadot
12faeba995 allwinner: rsb: Set the PMIC to RSB mode
With recent ATF (v2.5) the PMIC is reset to I2C mode.
Without a PMIC no regulators can be changed/enabled/disabled
This fixes cpufreq on A64 (at least) and anything else that needs
regulators handled by the PMIC.

MFC after:	3 days
Sponsored by:	Diablotin Systems
2021-07-24 17:46:25 +02:00
Emmanuel Vadot
bce17068ac arm: allwinner: cir: Reduce verbosity
IR can be noisy in dmesg if it "receive" some unwanted data.
Add a tunable hw.aw_cir.debug to enable those message that are
only useful if one wants to debug the driver.

Sponsored by:	Diablotin Systems
Differential Revision:	  https://reviews.freebsd.org/D30972
Reviewed by: 		  ganbold
MFC after:		  1 month
2021-07-22 14:55:03 +02:00
Kevin Bowling
b684d812fc arm: Bump KSTACK_PAGES default to match i386/amd64
See 3f6867ef63 for additional context.

It is also needed for OpenZFS performance and stability.

Reviewed by:	ian (arm), imp
Differential Revision:	https://reviews.freebsd.org/D31244
2021-07-20 18:35:54 -07:00
Kornel Duleba
986bbba9a6 arm/mv: Don't rely on firmware MSI mapping in ICU
On Armada8k boards various peripherals (e.g. USB) have interrupt lines
connected to on of the ICU interrupt controllers.
After an interrupt is detected it triggers MSI to a given address,
with a programmed value. This in turn triggers an SPI interrupt.
Normally MSI vector should be allocated by ICUs parent and set
during interrupt allocation.
Instead of doing that we relied on the ICU being pre-configured in firmware.
This worked with EDK2 and older versions of U-Boot, but in the newer
ones that is no longer the case.
Extend ICU msi-parents - GICP and SEI to support MSI interface
and use it during interrupt allocation.
This allows us to boot on Armada 7k/8k SoCs independent from the
firmware configuration and successfully use modern U-Boot + device tree.

For SATA interrupts we need to apply a WA previously done in firmware.
We have two SATA ports connected to one controller.
Each ports gets its own interrupt, but only one of them is
described in dts, also ahci_generic driver expects only one irq too.
Fix it by mapping both interrupts to the same MSI when one of them
is allocated, which allows us to use both SATA ports.

Reviewed by: mmel, mw
Obtained from: Semihalf
Sponsored by: Marvell
Differential Revision: https://reviews.freebsd.org/D28803
2021-07-20 23:24:42 +02:00
Mateusz Guzik
78e3a16861 arm: dedup counter(9) address calculation
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-07-19 10:46:25 +00:00
Mateusz Guzik
6799c73d1e arm: retire bcopy
It is obsolete since ba96f37758 ("Use __builtin for various mem*
and b* (e.g. bzero) routines.")

Discussed with:	cognet
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-07-19 09:53:02 +00:00
Mateusz Guzik
9ef5b65085 arm: bcmp -> memcmp
The bcmp symbol is not used, at the same time memcmp as pulled from
libkern does byte-by-byte comparison.

So happens bcmp as found in support.S is in fact renamed memcmp, rename
it back.

Discussed with:	cognet
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-07-19 09:52:23 +00:00
Oskar Holmlund
8cdb4491c9 arm: TI AM335x fix gpio_pin numbers in lookup table.
gpio_pin are calculated as [GPIO_BANK]*32 + GPIO_PIN.
gpio_pin are wrong for these pins.
As a consequence wrong pins are acquired and used.

Approved by: manu (mentor)
Reported by: Martin Zakardissnehf
(martin.zakardissnehf@se.abb.com)
Differential revision: https://reviews.freebsd.org/D31164
2021-07-18 13:06:26 +02:00
David Chisnall
cf98bc28d3 Pass the syscall number to capsicum permission-denied signals
The syscall number is stored in the same register as the syscall return
on amd64 (and possibly other architectures) and so it is impossible to
recover in the signal handler after the call has returned.  This small
tweak delivers it in the `si_value` field of the signal, which is
sufficient to catch capability violations and emulate them with a call
to a more-privileged process in the signal handler.

This reapplies 3a522ba1bc with a fix for
the static assertion failure on i386.

Approved by:	markj (mentor)

Reviewed by:	kib, bcr (manpages)

Differential Revision: https://reviews.freebsd.org/D29185
2021-07-16 18:06:44 +01:00
David Chisnall
d2b558281a Revert "Pass the syscall number to capsicum permission-denied signals"
This broke the i386 build.

This reverts commit 3a522ba1bc.
2021-07-10 20:26:01 +01:00
David Chisnall
3a522ba1bc Pass the syscall number to capsicum permission-denied signals
The syscall number is stored in the same register as the syscall return
on amd64 (and possibly other architectures) and so it is impossible to
recover in the signal handler after the call has returned.  This small
tweak delivers it in the `si_value` field of the signal, which is
sufficient to catch capability violations and emulate them with a call
to a more-privileged process in the signal handler.

Approved by:	markj (mentor)

Reviewed by:	kib, bcr (manpages)

Differential Revision: https://reviews.freebsd.org/D29185
2021-07-10 17:19:52 +01:00
MIHIRA Sanpei Yoshiro
9e3761d126 arm: remove fslsdma from GENERIC
The fslsdma device requires sdma_fw, but that's not included in
GENERIC. That firmware is not in the FreeBSD tree at the moment, but
could easily be.

The license for the firmware can be found in the linux firmware repo:
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/commit/?id=3123d78e09d2f815de4d94aa35c07b3c0469c80e
and looks to be a BSD license + no reverse engineer.

We can add this back after the firmware is imported, made a port, or
whose automatic loading can be made to happen.

Reviewed by:		imp (with ian finding the license)
PR:			237466
MFC after:		1 week
2021-07-09 11:21:40 -06:00
Konstantin Belousov
28a66fc3da Do not call FreeBSD-ABI specific code for all ABIs
Use sysentvec hooks to only call umtx_thread_exit/umtx_exec, which handle
robust mutexes, for native FreeBSD ABI.  Similarly, there is no sense
in calling sigfastblock_clear() for non-native ABIs.

Requested by:	dchagin
Reviewed by:	dchagin, markj (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D30987
2021-07-07 14:12:07 +03:00
Emmanuel Vadot
48687f733f armv7: allwinner: Add aw_r_intc driver
This is also needed after the 5.13 dts update.

Sponsored by:	Diablotin Systems
Reported by:	Mark Millard <marklmi@yahoo.com>
2021-07-05 11:38:23 +02:00
Ferhat Gecdogan
8df71ea1aa tegra_pcie: use switch instead of if in tegra_pcib_pex_ctrl
Simplify obtaining per-port data in tegra_pcib_pex_ctrl() routine.

Reviewed by:    imp, mw
Pull Request:   https://github.com/freebsd/freebsd-src/pull/481
2021-07-01 20:09:46 +02:00
Emmanuel Vadot
993e8236c3 arm64: allwinner: Add r_intc driver
The r intc interrupt controller seems to do a lot of things :
- It can handle the NMI interrupt
- It have local interrupts for some device that also can be muxed with GIC
- It can serve as an forwarder for the GIC

It's mostly used for deepsleep/wakeup if I understood correctly and we do not
support this on arm64.

For now just forward everything to the GIC so interrupts works again for device
which now have this interrupts controller set since dts v5.12

Sponsored by:	Diablotin Systems
2021-07-01 18:46:38 +02:00
Olivier Houchard
8c3bd133dd arm: Make sure we can handle a thumb entry point.
Similarly to what's been done on arm64 with commit
712c060c94, when executing a binary, if the
entry point is a thumb symbol, then make sure we set the PSL_T flag, otherwise
the CPU will interpret it in ARM mode, and that will likely leads to an
undefined instruction.

PR:	256899
MFC after: 	1 week
2021-06-30 22:56:50 +02:00
Olivier Houchard
c1da17a86c arm: Garbage collect _arm_memcpy/_arm_bzero.
Remove any attempt to use _arm_memcpy and _arm_bzero. It was used by some
xscale platforms to provide functions to use the DMA engine for big
zeroing/copying work, but those platforms are long gone, and it's unlikely
anything else will use those.
2021-06-30 14:53:57 +02:00
Edward Tomasz Napierala
435754a59e Add infrastructure required for Linux coredump support
This adds `sv_elf_core_osabi`, `sv_elf_core_abi_vendor`,
and `sv_elf_core_prepare_notes` fields to `struct sysentvec`,
and modifies imgact_elf.c to make use of them instead
of hardcoding FreeBSD-specific values.  It also updates all
of the ABI definitions to preserve current behaviour.

This makes it possible to implement non-native ELF coredump
support without unnecessary code duplication.  It will be used
for Linux coredumps.

Reviewed By:	kib
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D30921
2021-06-29 08:49:12 +01:00
Warner Losh
ddfc9c4c59 newbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location} with sbuf
Now that the upper layers all go through a layer to tie into these
information functions that translates an sbuf into char * and len. The
current interface suffers issues of what to do in cases of truncation,
etc. Instead, migrate all these functions to using struct sbuf and these
issues go away. The caller is also in charge of any memory allocation
and/or expansion that's needed during this process.

Create a bus_generic_child_{pnpinfo,location} and make it default. It
just returns success. This is for those busses that have no information
for these items. Migrate the now-empty routines to using this as
appropriate.

Document these new interfaces with man pages, and oversight from before.

Reviewed by:		jhb, bcr
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D29937
2021-06-22 20:52:06 -06:00
Dmitry Chagin
8fe8bb7cb5 linux(4): Regen for linux_poll system call.
MFC after:	2 weeks
2021-06-22 08:09:55 +03:00
Dmitry Chagin
2eff670fde linux(4): Implement poll system call via linux_common_ppol()
for the sake of converting events to/from native.

MFC after:	2 weeks
2021-06-22 08:07:46 +03:00
Emmanuel Vadot
6bc8fe8a9f arm: allwinner: Add mmc_pwrseq support
If a pwrseq is found, set power accordingly.

Sponsored by:	Diablotin Systems
2021-06-14 20:47:37 +02:00
Alex Richardson
9bb8a4091c Reduce code duplication in machine/_types.h
Many of these typedefs are the same across all architectures or can
be set based on an architecture-independent compiler-provided macro
(e.g. __SIZEOF_SIZE_T__). These macros have been available since GCC 4.6
and Clang sometime before 3.0 (godbolt.org does not have any older clang
versions installed).

I originally considered using the compiler-provided `__FOO_TYPE__` directly.
However, in order to do so we have to check that those match the previous
typedef exactly (not just that they have the same size) since any change
would be an ABI break. For example, changing `long` to `long long` results
in different C++ name mangling. Additionally, Clang and GCC disagree on
the underlying type for some of (u)int*_fast_t types, so this change
only moves the definitions that are identical across all architectures
and does not touch those types.

This de-deduplication will allow us to have a smaller diff downstream in
CheriBSD: we only have to only change the (u)intptr_t definition in
sys/_types.h in CheriBSD instead of having to change machine/_types.h for
all CHERI-enabled architectures (currently RISC-V, AArch64 and MIPS).

Reviewed By: imp, kib
Differential Revision: https://reviews.freebsd.org/D29895
2021-06-14 16:30:16 +01:00
Andrew Turner
15fa52a564 Add more GIC and GICv3 registers
These aren't used by either driver, however they will be needed by
bhyve on arm64 to emulate a GICv3 interrupt controller.

Sponsored by:	Innovate UK
2021-06-14 14:53:11 +00:00
Oskar Holmlund
ac6dcaf8f4 arm: TI am335x ehrpwm fix bitmask
Bitfield HSPCLKDIV and CLKDIV are 3 bit wide.
Chapter 15.2.4.1 https://www.ti.com/lit/ug/spruh73q/spruh73q.pdf

Approved by: manu (mentor)
Reported by: Stefan Forsberg
Differential revision: https://reviews.freebsd.org/D30746
2021-06-14 10:38:06 +02:00
Oskar Holmlund
e7424879e3 arm: ti am335x ehrpwm add support for flags (PWM_POLARITY_INVERTED)
Add support for invert the polarity of the PWM signal.
Cleanup and add comments in the initialization code.
Add and fix register defines.

Approved by: manu (mentor)
Differential revision: https://reviews.freebsd.org/D29547
2021-06-12 10:54:31 +02:00
Oskar Holmlund
dbaf4b6539 arm: ti am335x ehrpwm remove sysctl interface
To minimize the maintenance time of this driver when new features
are added the legacy sysctl interface has to go.

Approved by: manu (mentor)
Reviewed by: Dr. Rolf Jansen (freebsd-rj_obsigna.com)
Differential revision: https://reviews.freebsd.org/D29546
2021-06-12 10:24:55 +02:00
Oleksandr Tymoshenko
cb25a94558 arm64: allwinner: Add i2s and codec support
Differential Revision:	https://reviews.freebsd.org/D27830
2021-06-11 21:06:08 +02:00
Dmitry Chagin
ee64d98204 linux(4): Regen for futex system call.
MFC after:	2 weeks
2021-06-10 14:16:40 +03:00
Dmitry Chagin
3c1de151e3 linux(4): Change Linux futex syscall definition to match Linux actual one.
MFC after:	2 weeks
2021-06-10 14:00:00 +03:00
Mark Johnston
62ba0def55 arm: Remove last_fault_code
It is unused since the removal of pmap-v4.c in commit b88b275145.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-06-06 16:44:47 -04:00
Dmitry Chagin
e29ea22f70 Regen for ('0f8dab45404f347752470579feccc6d2739b9570') Linux
rt_sigtimedwait system call.

MFC after:	2 weeks
2021-06-07 05:39:29 +03:00
Dmitry Chagin
0f8dab4540 linux(4): Fix timeout parameter of rt_sigtimedwait syscall, which is
timespec not a timeval.

MFC after:	2 weeks
2021-06-07 05:35:35 +03:00
Emmanuel Vadot
25593adbc1 arm: allwinner: Add clock driver for Display Engine to the build
This is needed for drm
2021-06-02 10:17:16 +02:00
Emmanuel Vadot
2d926ed71e arm: SOCFPGA: Add ext_resources driver
mmc_fdt_helpers needs clock and regulators.
Add all the ext_resources driver to SOCFPGA conf file to fix the build

Reported by:    mjg
2021-05-31 19:08:08 +02:00
Emmanuel Vadot
ac1d7397bf arm64: allwinner: clk: Test with the current parent freq first
Even if the clock is flagged with AW_CLK_SET_PARENT the current parent
freq might be enough to get a correct divisor.
So test first if we can get the expected freq before changing the parent
freq.
2021-05-31 14:10:24 +02:00
Emmanuel Vadot
996afd401c arm: RPI-B: Add ext_resources driver
mmc_fdt_helpers needs clock and regulators.
Add all the ext_resources driver to RPI-B conf file to fix the build

Reported by:	mjg
2021-05-24 12:53:00 +02:00
Emmanuel Vadot
115e71a457 arm: allwinner: aw_mmc: Check regulators status before enabling/disabling them
Sponsored by:	Diablotin Systems
Differential Revision:	https://reviews.freebsd.org/D30294
2021-05-21 17:39:47 +02:00
Emmanuel Vadot
182717da88 arm64: allwinner: axp81x: Add support for regnode_status
This method is used to know if a regulator is enabled or not.

Sponsored by:	Diablotin Systems
Differential Revision:	https://reviews.freebsd.org/D30290
2021-05-21 17:37:37 +02:00
Marcin Wojtas
240429103c Rename ofwpci.c to ofw_pcib.c
It's a class0 driver that implements some pcib methods and creates
a pci bus as its children.
The "ofw_pci" name will be used by a new driver that will be a subclass
of the pci bus.
No functional changes intended.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: andrew
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D30226
2021-05-20 11:22:25 +02:00
Ceri Davies
c1a148873d sys/*/conf/*, docs: fix links to handbook
While here, fix all links to older en_US.ISO8859-1 documentation
in the src/ tree.

PR:             255026
Reported by:    Michael Büker <freebsd@michael-bueker.de>
Reviewed by:    dbaio
Approved by:    blackend (mentor), re (gjb)
MFC after:      10 days
Differential Revision: https://reviews.freebsd.org/D30265
2021-05-20 09:27:10 +01:00
Ed Maste
2c9764f36b regen syscall files after d51198d63b63 2021-05-13 14:09:58 -04:00
Juraj Lutter
c2c9ef3ced rpi_ft5406: Recognize raspberrypi,firmware-ts touchscreen
- Recognize raspberrypi,firmware-ts touchscreen
- Move the driver from ofwbus to simplebus

Reviewed by:	manu
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D30169
2021-05-09 12:13:19 +02:00
Andrew Turner
0ec205197b Also enable IPIs on 32-bit arm
This was missed in 2420f6a

Reported by:	tuexen, imp
2021-05-03 08:36:57 +00:00
Andrew Turner
c78ad207ba Switch the EFI virtual address to a uint64_t
It is defined as a uint64_t in the UEFI spec. As it's not used as a
pointer by the kernel follow this and define it as the same in the
kernel.

Reviewed by:	kib, manu, imp
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D29759
2021-05-01 06:01:20 +00:00
Emmanuel Vadot
2671bdb540 allwinner: aw_mmc: Convert driver to use the mmc_sim interface
A lot more generic cam related things are done in mmc_sim so this simplify
the driver a lot.

Differential Revision:	https://reviews.freebsd.org/D27486
Reviewed by:	imp
2021-04-27 19:00:42 +02:00
Emmanuel Vadot
0c80ad2dc6 arm: Add no-cftconvert for sdma-imx6 files
Fixes a warning when building kernel:
ctfconvert: file.c: Couldn't read ehdr: Invalid argument

MFC after:	3 days
2021-04-14 15:43:37 +02:00
Andrew Turner
3da5983889 Remove versatile support
It was used for testing armv6 under QEMU, however since then we added
support for the QEMU virt platform.

Reviewed by:	imp, manu
Differential Revision:	https://reviews.freebsd.org/D29707
2021-04-12 06:16:31 +00:00
Mitchell Horne
7c13440845 arm: add options GDB to std.armv6 and std.armv7
There are now options for specifying the debug port via tunable
(hw.fdt.dbgport) and device tree (/chosen/freebsd-dbgpath), so this can
be usefully included in GENERIC.

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D29152
2021-03-30 12:04:24 -03:00
Mitchell Horne
7446b0888d gdb: report specific stop reason for watchpoints
The remote protocol allows for implementations to report more specific
reasons for the break in execution back to the client [1]. This is
entirely optional, so it is only implemented for amd64, arm64, and i386
at the moment.

[1] https://sourceware.org/gdb/current/onlinedocs/gdb/Stop-Reply-Packets.html

Reviewed by:	jhb
MFC after:	3 weeks
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
NetApp PR:	51
Differential Revision:	https://reviews.freebsd.org/D29174
2021-03-30 11:36:41 -03:00
Mitchell Horne
9d81dd5404 ddb: replace watchpoint set/clear functions
Use the new kdb variants. Print more specific error messages.

Reviewed by:	jhb, markj
MFC after:	3 weeks
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D29156
2021-03-29 12:05:44 -03:00
Mitchell Horne
5a2933d0bf arm: implement kdb watchpoint functions
Implement wrappers around the existing debug_monitor interface, to be
consumed by MI kernel debugger code.

For now, the various db_printf() calls in this code remain. In the
future, they could be converted to printf() or removed altogether, to
properly decouple the DDB and GDB options.

Reviewed by:	jhb, kib, markj
MFC after:	3 weeks
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D29155
2021-03-29 12:05:44 -03:00
Mitchell Horne
720dc6bcb5 Consolidate machine/endian.h definitions
This change serves two purposes.

First, we take advantage of the compiler provided endian definitions to
eliminate some long-standing duplication between the different versions
of this header. __BYTE_ORDER__ has been defined since GCC 4.6, so there
is no need to rely on platform defaults or e.g. __MIPSEB__ to determine
endianness. A new common sub-header is added, but there should be no
changes to the visibility of these definitions.

Second, this eliminates the hand-rolled __bswapNN() routines, again in
favor of the compiler builtins. This was done already for x86 in
e6ff6154d2. The benefit here is that we no longer have to maintain our
own implementations on each arch, and can instead rely on the compiler
to emit appropriate instructions or libcalls, as available. This should
result in equivalent or better code generation. Notably 32-bit arm will
start using the `rev` instruction for these routines, which is available
on armv6+.

PR:		236920
Reviewed by:	arichardson, imp
Tested by:	bdragon (BE powerpc)
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D29012
2021-03-26 19:00:22 -03:00
Jason A. Harmening
d22883d715 Remove PCPU_INC
e4b8deb222 removed the last in-tree uses of PCPU_INC().  Its
potential benefit is also practically nonexistent.  Non-x86
platforms already implement it as PCPU_ADD(..., 1), and according
to [0] there are no recent x86 processors for which the 'inc'
instruction provides a performance benefit over the equivalent
memory-operand form of the 'add' instruction.  The only remaining
benefit of 'inc' is smaller instruction size, which in this case
is inconsequential given the limited number of per-CPU data consumers.

[0]: https://www.agner.org/optimize/instruction_tables.pdf

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D29308
2021-03-20 19:23:59 -07:00
Michal Meloun
01c6d79189 mvebu_gpio: Fix settings of gpio pin direction.
Data Output Enable Control register is inverted – 0 means output direction.
Reflect this fact in code.

MFC after:	3 weeks
2021-03-07 11:41:30 +01:00
Gordon Bergling
e797dc58bd arm64: Add support for bcm2838 RNG
The hardware random number generator of the RPi4 differs slightly
from the version found on the RPi3.

This commit extends the existing bcm2835_rng driver to function on the RPi4.

Submitted by:	James Mintram <me at jamesrm dot com>
Reviewed by:	markm, cem, delphij
Approved by:	csprng(cem, markm)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D22493
2021-03-06 12:28:35 +01:00
Michal Meloun
a5dce53b75 mvebu_gpio: Multiple fixes.
- gpio register access primitives
- locking in interrupt path
- cleanup

In cooperation with: mw
Reviewed by:	mw (initial version)
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D29044
Differential Revision:	https://reviews.freebsd.org/D28911
2021-03-04 17:54:40 +01:00
Zyta Szpak
622d17da46 arm64: mv_ap806_gicp: Fix spi_ranges_cnt
Previously the spi_ranges_cnt stored the table size in bytes
instead of the number of elements. Fix that.

Reviewed by: mmel
Submitted by: Zyta Szpak <zr@semihalf.com>
Obtained from: Semihalf
Sponsored by: Marvell
2021-03-03 17:08:12 +01:00
Marcin Wojtas
819760b35f mvebu_gpio: fix interrupt cause register configuration
According to Armada 8k documentation, the interrupt cause register
(at offset 0x14) is RW0C. Update the configuration in attach and
the mvebu_gpio_isrc_eoi() to follow the description.

Reviewed by: mmel
Obtained from: Semihalf
Sponsored by: Marvell
Differential Revision: https://reviews.freebsd.org/D29013
2021-03-03 00:22:42 +01:00
Andrew Turner
d765b21138 Remove __XSCALE__ checks from the arm code
XScale support was removed over 2 years ago, remove the last __XSCALE__
checks from the arm MD code.

Sponsored by:	Innovate UK
2021-02-19 15:31:26 +00:00
John Baldwin
67932460c7 Add a VA_IS_CLEANMAP() macro.
This macro returns true if a provided virtual address is contained
in the kernel's clean submap.

In CHERI kernels, the buffer cache and transient I/O map are allocated
as separate regions.  Abstracting this check reduces the diff relative
to FreeBSD.  It is perhaps slightly more readable as well.

Reviewed by:	kib
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D28710
2021-02-17 16:32:11 -08:00
Emmanuel Vadot
2551d92850 arm64: rpi4: gpio: Add brcm,bcm2711-gpio compatible
Looks like we never enabled the main gpio controller on the RPI4 board.
Now gpio are usable.

MFC after:	3 days
2021-02-17 13:18:26 +01:00
Emmanuel Vadot
1cf2823631 arm64: rpi4: firmware: Attach at BUS_PASS_BUS + BUS_PASS_ORDER_LATE
The node have now a compatible with simple-mfd so we need to attach
at the same pass so the specific driver will be used.

MFC after:	3 days
PR:		252971
2021-02-17 13:18:21 +01:00
Michal Meloun
ec090f4a67 arm32: Align arguments of sync_icache() syscall to cacheline size.
Otherwise, we may miss synchronization of the last cacheline.
MFC after:	3 days
2021-02-09 12:53:09 +01:00
Andrew Turner
4e76e4c301 Remove obsolete code gated on _ARM_ARCH_*
This is all code only run on ARMv4 and ARMv5. Support for these have
been dropped from FreeBSD.

Differential Revision:	https://reviews.freebsd.org/D28314
2021-01-28 10:41:45 +00:00
Andrew Turner
dd6c1c2a6c Remove redundantcy from the arm GIC softc
A struct recource already contains the bus_space_tag_t and
bus_space_handle_t. There is no neec to read them and store them again
in the drivers softc. Remove them and use the struct resource directly
with bus_read_* and bus_write_*.

Reviewed by:	mmel
Differential Revision:	https://reviews.freebsd.org/D28339
2021-01-27 19:03:39 +00:00
Andrew Turner
2be9ff2d65 Remove old Marvell drivers
These have probe functions that can only match device tree files that
have been removed because the boards they describe are unsupported.

Reviewed by:	imp, manu
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D28366
2021-01-27 10:02:02 +00:00
Marcin Wojtas
a86b0839d7 marvell: ap806_clock: add missing frequency modes
In the driver init routine the CPU clock frequency
value is obtained from a dedicated register. Until now
only part of the values were handled by the mv_ap806_clock
driver. Fix that by adding missing cases.

Submitted by: Zyta Szpak <zr@semihalf.com>
MFC after: 1 week
Obtained from: Semihalf
Sponsored by: Marvell
2021-01-26 14:04:22 +01:00
Mark Johnston
519b64e27f Revert "Define PNP info after defining driver modules"
This reverts commit aa37baf3d7.

The reverted commit was motivated by a problem observed on stable/12,
but it turns out that a better solution was committed in r348309 but not
MFCed.  So, revert this change since it is unnecessary and not really
correct: it assumes that the order in which module metadata records is
defined determines their order in the output linker set.  While this
seems to hold in my testing, it is not guaranteed.

Reported by:	cem
Discussed with:	imp
MFC after:	3 days
2021-01-23 10:59:41 -05:00
Mark Johnston
aa37baf3d7 Define PNP info after defining driver modules
PNP info definitions currently have an unfortunate requirement in that
they must follow the associated module definition in the module metadata
linker set.  Otherwise devmatch can segfault while processing the linker
hints file since kldxref maintains the order in the linker set.

A number of drivers violate this requirement.  In some cases this can
cause devmatch(8) to segfault when processing the linker hints file.
Work around the problem for now simply by adjusting the drivers.

Reviewed by:	imp
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D28260
2021-01-21 14:30:18 -05:00
Oleksandr Tymoshenko
248f0cabca make maximum interrupt number tunable on ARM, ARM64, MIPS, and RISC-V
Use a machdep.nirq tunable intead of compile-time constant NIRQ
as a value for maximum number of interrupts. It allows keep a system
footprint small by default with an option to increase the limit
for large systems like server-grade ARM64

Reviewd by:	mhorne
Differential Revision:	https://reviews.freebsd.org/D27844
Submitted by:	Klara, Inc.
Sponsored by:	Ampere Computing
2021-01-18 16:36:39 -08:00
Emmanuel Vadot
8a7a4683b0 arm: arm64: Directly use #include <dt-binding/...>
We have it in the includes path and this will help the transition to the
new device-tree import in sys/contrib
2021-01-15 14:17:03 +01:00
Andrew Turner
6eebda3bba Split out the NODEBUG options to a common file
This is the superset of the nooptions found in the -DEBUG kernels.

Reviewed by:	emaste, manu
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D28152
2021-01-14 16:57:53 +00:00
Thomas Skibo
facdd1cd20 cgem: add 64-bit support
Add 64-bit address support to Cadence CGEM Ethernet driver for use in
other SoCs such as the Zynq UltraScale+ and SiFive HighFive Unleashed.

Reviewed by:	philip, 0mp (manpages)
Differential Revision: https://reviews.freebsd.org/D24304
2021-01-10 16:51:52 -04:00
Kyle Evans
da77382f55 arm: revert MAXDSIZ change from 202aea9c82
This imposes a fairly severe limitation on space available for mmap that
was not noticed prior to commit. Unfixed mmap will only map from
[data + MAXSIZE, end of user VA space], bringing the amount of usable space
down way too low for non-trivial link jobs (for instance).

Reported by:	mmel
2021-01-09 14:14:00 -06:00
Vladimir Kondratyev
67de2db262 Factor-out hardware-independent part of USB HID support to new module
It will be used by the upcoming HID-over-i2C implementation.  Should be
no-op, except hid.ko module dependency is to be added to affected drivers.

Reviewed by:	hselasky, manu
Differential revision:	https://reviews.freebsd.org/D27867
2021-01-08 02:18:42 +03:00
Vladimir Kondratyev
5af73ad51b evdev: Remove useless "initial value" parameter from evdev_support_abs()
It can not be used for setting of state of multitouch events.
If necessary, use evdev_push_event() instead of it.
2021-01-08 02:18:41 +03:00
Alan Cox
7beeacb27b Honor the vm page's PG_NODUMP flag on arm and i386.
Reviewed by:	kib, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D27949
2021-01-04 16:15:42 -06:00
Ryan Libby
486580c44c arm: fix atomic_testand{set,clear}_64 for ops on high bits
The fix in bd03acedb8 worked for 32-bit
ops, and for 64-bit ops for bit arguments of 0 - 95, but then was broken
for operations on the high 32 bits after that.

Reviewed by:	markj, mmel
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D27897
2021-01-02 18:09:37 -08:00
Mitchell Horne
65d1a4cfda Handle KDB_WHY_TRAP return on arm and mips
Upon exit from the debugger, checking the return code of kdb_trap()
allows one to retry the fatal page fault. This matches what is done on
all other architectures.

Reviewed by:	jhb (earlier version)
Differential Revision:	https://reviews.freebsd.org/D27535
2021-01-02 19:07:04 -04:00
Michal Meloun
bd03acedb8 arm: Fix atomic_testand{set,clear}_32(). According to atomic (9), the bit position argument should be a modulo operand size. While I'm in, add missing implementation of atomic_testandclear_64(). For more details see https://reviews.freebsd.org/D27886
Discused with:	rlibby
MFC after:	3 weeks
2021-01-02 20:53:11 +01:00
Kyle Evans
202aea9c82 arm: tune vmparam.h towards a little more modern
An 8MB max stack size is quite limiting in today's world, and in-fact is
the *default* stack size for almost every other arch (including mips).

Raise the default to 4MB (should be pretty reasonable) and the max to 64MB.
NetBSD made a similar move back in 2015 and raised MAXDSIZ to 1856 at the
same time, so let's just roll that in as well. They later lowered it, but
eventually raised it back to 1856 in order to build rust.

This was noticed while looking at qemu-bsd-user's default stack sizes and
growth behavior (or lack thereof).

Reviewed by:	ian
Differential Revision:	https://reviews.freebsd.org/D27218
2020-12-31 11:13:13 -06:00
Andrew Turner
80062279f7 Add pmu.h missed in 5e78bbb74a
Reported by:	rlibby
Sponsored by:	Innovate UK
2020-12-31 10:12:34 +00:00
Andrew Turner
5e78bbb74a Split out the FDT arm pmu attachment
This will allow us to add an ACPI attachment.

Submitted by:	Greg V <greg@unrelenting.technology> (earlier version)
Sponsored by:	Innovate UK
2020-12-30 16:11:02 +00:00
Michal Meloun
b9cbd68d1c ARM: Enhance common Nvidia Tegra drivers by support for Tegra210 SoC.
MFC after:	4 weeks
2020-12-26 19:13:10 +01:00
Michal Meloun
aa76f0c397 PMC: remove now orphaned PMC for INTEL XScale processors.
Support for XScale architecture has been deleted in FreeBSD 13.
2020-12-25 15:21:53 +01:00
Emmanuel Vadot
33ab8d095a arm: Remove samsung exnynos port
Remove the exynos SoC support, this haven't been updated in a while,
isn't present in GENERIC and nobody is motivated to resurect it.

Differential Revision:	https://reviews.freebsd.org/D24444
2020-12-17 17:09:43 +00:00
Michal Meloun
cad703dc09 Remove unused functions and variables in cpufunc.[ch]. 2020-12-14 14:00:54 +00:00
Michal Meloun
a527975133 Finish implementation of ARM PMU interrupts.
The ARM PMU may use single per-core interrupt or may use multiple generic
interrupts, one per core. In this case, special attention must be paid to
the correct identification of the physical location of the core, its order
in the external database (FDT) and the associated cpuid.

Also keep in mind that a SoC can have multiple different PMUs
(usually one per cluster)
2020-12-14 13:10:19 +00:00
Mark Johnston
8bf82b340e arm: Let the GDB stub write to SP, LR and GP registers
This can be handy if gdb's stack unwinder fails, for example because of
a bug in kgdb's trap frame unwinder.

PR:		251463
Submitted by:	Dmitry Salychev <dsl@mcusim.org>
MFC after:	1 week
2020-12-07 15:09:28 +00:00
Michal Meloun
6844eecfed Add basic support for Freescale LX2160A SoC.
All peripherals but the network processor are supported.
2020-12-05 12:08:37 +00:00
Michal Meloun
0f9a385a3a Connect RK3288 to GENERIC kernel. 2020-12-05 10:10:25 +00:00
Michal Meloun
b0352107f1 Add support for RK3288 SoC. 2020-12-04 16:24:44 +00:00
Mark Johnston
b957b18594 Always use 64-bit physical addresses for dump_avail[] in minidumps
As of r365978, minidumps include a copy of dump_avail[].  This is an
array of vm_paddr_t ranges.  libkvm walks the array assuming that
sizeof(vm_paddr_t) is equal to the platform "word size", but that's not
correct on some platforms.  For instance, i386 uses a 64-bit vm_paddr_t.

Fix the problem by always dumping 64-bit addresses.  On platforms where
vm_paddr_t is 32 bits wide, namely arm and mips (sometimes), translate
dump_avail[] to an array of uint64_t ranges.  With this change, libkvm
no longer needs to maintain a notion of the target word size, so get rid
of it.

This is a no-op on platforms where sizeof(vm_paddr_t) == 8.

Reviewed by:	alc, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27082
2020-12-03 17:12:31 +00:00
Michal Meloun
d06e999c2a Fix r368153. Wrong branch of #ifdef __ARMEB__ was deleted. 2020-12-02 08:14:56 +00:00
Michal Meloun
8bbe6af949 Remove duplicated SV_ASLR from the elf flags.
Reported by:	lattera
2020-12-01 09:18:18 +00:00
Emmanuel Vadot
020df50904 arm: allwinner: aw_mmc: Add a sysctl for debuging
Add a new hw.aw_mmc.debug sysctl to help debugging the driver.
Bit 0 will debug card changes (removal, insertion, power up/down)
Bit 1 will debug ios changes
Bit 2 will debug interrupts received
Bit 3 will debug commands sent
2020-11-30 14:48:50 +00:00
Michal Meloun
bd89101586 Store MPIDR register in pcpu.
MPIDR represents physical locality of given core and it should be used as
the only viable/robust connection between cpuid (which have zero relation to
cores topology) and external description (for example  in FDT).  It can be
used for determining which interrupt is associated to given per-CPU PMU
or by scheduler for determining big/little core or cluster topology.

MFC after: 3 weeks
2020-11-29 18:59:01 +00:00
Michal Meloun
7c6c12ebcd Remove unused options.
Marvell files and their related SOC_MV_<foo> options should be cleaned up
in another pass.
2020-11-29 17:42:32 +00:00
Michal Meloun
f72366f927 _ARM_ARCH_5E is always defined, we not support older CPUs. 2020-11-29 16:44:22 +00:00
Michal Meloun
b842cbbc01 Remove orphaned configs. 2020-11-29 15:39:54 +00:00
Michal Meloun
13a3f95057 Remove remaining fragments of code for older already ceased ARM versions. 2020-11-29 15:24:00 +00:00
Michal Meloun
0879a64283 Remove remaining support of big endian byte order.
Big endian support was ceased by removing ARMv4 sub architecture.
2020-11-29 15:04:39 +00:00
Michal Meloun
5c2967f66f Remove the pre-ARMv6 and pre-INTRNG code.
ARM has required ARMV6+ and INTRNg for some time now, so remove
always false #ifdefs and unconditionally do always true #ifdefs.
2020-11-29 08:40:12 +00:00
Michal Meloun
b88b275145 Remove now unused armv4 and not-INTRNG files. 2020-11-28 15:00:08 +00:00
Mark Johnston
a92526f3f1 arm: Correctly report the size of FPA registers to GDB
Modern ARM systems do not have an FPA unit but GDB reserves register
indices for FPA registers and expects the stub to know their sizes.

PR:		251022
Submitted by:	Dmitry Salychev <dsl@mcusim.org>
MFC after:	2 weeks
2020-11-27 16:35:43 +00:00
Emmanuel Vadot
978a8cccd8 arm: allwinner: a23 timer functions are only used for arm64 2020-11-26 17:19:47 +00:00
Emmanuel Vadot
e7d11d07e0 arm: tegra: Remove unused variable 2020-11-26 17:19:30 +00:00
Emmanuel Vadot
3c5e248d9d arm: mv: Remove unused code 2020-11-26 17:19:13 +00:00
Emmanuel Vadot
8704ae04f4 arm: ti: Remove unused function ti_first_gpio_bank 2020-11-26 17:18:54 +00:00
Ian Lepore
a7623790fb Add the firmware blob required to use the sdma hardware in the imx6
processor, and its associated license text (which is similar to a
bsd-3-clause, but with a prohibition against decompiling).  Install a copy
of the license in /usr/share/doc/legal/imx, to comply with the license terms
that requires a copy of the license to be delivered along with the firmware.

Obtained from:	https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/imx/sdma/sdma-imx6q.bin https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/LICENSE.sdma_firmware
2020-11-26 01:40:04 +00:00
Ian Lepore
2814e68675 Extend the imx6 gpc->gic interrupt controller fixup of fdt data at runtime
to work with the pmu and tempmon nodes as well as the soc node.  This allows
interrupts to work on the pmu and tempmon devices even though we don't have
a driver for the low-power gpc interrupt controller (which is not a problem
because we also don't have support for entering deep power-down modes where
it gets used).
2020-11-25 20:05:05 +00:00
Ian Lepore
0ffeeb414f Convert the imx6_snvs RTC driver to access registers via the syscon device.
This is required for it to work correctly in the GENERIC kernel.
2020-11-25 19:10:20 +00:00
Ian Lepore
253dde678e Add the standard extres pseudo devices to the IMX6 kernel config.
Some imx6 drivers are being converted to use features that weren't available
when they were first written (such as accessing shared device registers via
the syscon pseudo-device), so imx6 custom kernels that reference those
devices will now need this infrastructure in place.
2020-11-25 19:08:22 +00:00
Ian Lepore
4b7ae525a8 A couple small fixes for the imx6_sdma driver...
Attach after interrupt controllers, since the attach function tries to
set up an interrupt handler.

Check for the availability of the required firmware early in the attach
code (before allocating resources).  If the firmware is not available, set
a static var to remember that, so that if the device is re-probed on later
passes it won't repeatedly try to attach and then complain again about
missing firmware.
2020-11-25 18:09:01 +00:00
Ian Lepore
ddd30dd82b Only attach the ti_scm_syscon driver when running on a compatible TI chip.
This prevents attaching on non-TI systems in the GENERIC kernel.

Reviewed by:	manu@, mmel@
2020-11-25 15:45:20 +00:00
Emmanuel Vadot
f442e2fcf9 arm: allwinner: aw_rtc: Add H6 compatible 2020-11-25 11:20:04 +00:00
Emmanuel Vadot
4fbcbfe809 arm64: allwinner: H6: Fix pll 4x clocks
The clock configured by the registers are the 4x version not the 1x.
2020-11-25 11:19:42 +00:00
Emmanuel Vadot
a2a0878362 arm: Remove old amlogic support
Remove the port for aml8726.
Kernel config was removed in r346096 and this port was never migrated
to GENERIC.
It is also impossible to obtain such hardware nowadays.

Reviewed by:	imp
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D27281
2020-11-24 17:51:10 +00:00
Emmanuel Vadot
48cfe64b83 arm: Remove old rockchip support
Remove the port for rk30xx.
Kernel config was removed in r346096 and this port was never migrated
to GENERIC.
It is also impossible to obtain such hardware nowadays and this code
don't provide anything beside booting.

Reviewed by:	imp
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D27280
2020-11-24 17:50:22 +00:00
Emmanuel Vadot
354cb625ee if_awg: Add a awg_dma_start_tx function that trigger dma engine
No functional changes intended
2020-11-20 11:30:44 +00:00
Emmanuel Vadot
5fba90649a if_awg: Reorder functions and sort them by usage
No functional changes intended
2020-11-20 11:29:37 +00:00
Emmanuel Vadot
a19071cea2 if_awg: Add awg_stop_dma and use it in awg_stop
No functional changes intended
2020-11-20 11:28:23 +00:00
Emmanuel Vadot
16790d8f79 if_awg: Add a function to enable/disable the mac tx/rx
No functional changes intended
2020-11-20 11:27:26 +00:00
Emmanuel Vadot
612a1b8d69 if_awg: Split init code into sub function
Be clear of what we enable or init.

No functional changes intended
2020-11-20 11:26:20 +00:00
Emmanuel Vadot
e65794334b if_awg: Remove the taskqueue for miibus_statchg
I guess it was added so we can obtain the device lock but we already
have it when the function is called.

No functional changes intended
2020-11-20 11:25:54 +00:00
Mark Johnston
a28c28e6ef Remove NO_EVENTTIMERS support
The arm configs that required it have been removed from the tree.
Removing this option makes the callout code easier to read and
discourages developers from adding new configs without eventtimer
drivers.

Reviewed by:	ian, imp, mav
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27270
2020-11-19 02:50:48 +00:00
Emmanuel Vadot
891ea2d7b4 arm64: allwinner: Init the Display Engine clock
In case u-boot was compiled without video support set the PLL
to 432Mhz (which allow us to use most of the HDMI resolution for
tcon) and set it as the parent for the DE clock.
2020-11-17 14:58:30 +00:00
Emmanuel Vadot
b7d31bf5ee arm: allwinner: Add DE2 Clock support for H3 SoC
While here also enable the clock and deassert the reset
2020-11-17 14:57:34 +00:00
Edward Tomasz Napierala
6998d5b1c8 Remove the 'nap' field from ARM's 'struct syscall_args', to bring it
in sync with (most) other architectures.  No functional changes.

Reviewed by:	manu
Tested by:	mmel
MFC after:	2 weeks
Sponsored by:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D26604
2020-11-05 18:10:03 +00:00
Mitchell Horne
ce4900bc8a Simplify preload_dump() condition
Hiding this feature behind RB_VERBOSE is gratuitous. The tunable is enough
to limit its use to only those who explicitly request it.

Suggested by:	kevans
2020-10-15 20:21:15 +00:00
Konstantin Belousov
6f3b523c9a Avoid dump_avail[] redefinition.
Move dump_avail[] extern declaration and inlines into a new header
vm/vm_dumpset.h.  This fixes default gcc build for mips.

Reviewed by:	alc, scottph
Tested by:	kevans (previous version)
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D26741
2020-10-14 22:51:40 +00:00
Conrad Meyer
f8e8a06d23 random(4) FenestrasX: Push root seed version to arc4random(3)
Push the root seed version to userspace through the VDSO page, if
the RANDOM_FENESTRASX algorithm is enabled.  Otherwise, there is no
functional change.  The mechanism can be disabled with
debug.fxrng_vdso_enable=0.

arc4random(3) obtains a pointer to the root seed version published by
the kernel in the shared page at allocation time.  Like arc4random(9),
it maintains its own per-process copy of the seed version corresponding
to the root seed version at the time it last rekeyed.  On read requests,
the process seed version is compared with the version published in the
shared page; if they do not match, arc4random(3) reseeds from the
kernel before providing generated output.

This change does not implement the FenestrasX concept of PCPU userspace
generators seeded from a per-process base generator.  That change is
left for future discussion/work.

Reviewed by:	kib (previous version)
Approved by:	csprng (me -- only touching FXRNG here)
Differential Revision:	https://reviews.freebsd.org/D22839
2020-10-10 21:52:00 +00:00
Emmanuel Vadot
e63faa9ba8 arm: Check dtb version against the one we're expecting to find
Reviewed by:	imp, emaste, mmel
Differential Revision:	https://reviews.freebsd.org/D26725
2020-10-10 07:20:59 +00:00
Warner Losh
7e46dafa58 Create in-tree LINT files
Now that config(8) has supported include for 19 years, transition to
including the NOTES files. include support didn't exist at the time,
nor did the envvar stuff recently added. Now that it does, eliminate
the building of LINT files by just including everything you need.

Note: This may cause conflicts with updating in some cases.
	find sys -name LINT\* -rm
is suggested across this commit to remove the generated LINT
files.

Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D26540
2020-10-09 01:48:14 +00:00
Mitchell Horne
22e6a67086 Add a routine to dump boot metadata
The boot metadata (also referred to as modinfo, or preload metadata)
provides information about the size and location of the kernel,
pre-loaded modules, and other metadata (e.g. the EFI framebuffer) to be
consumed during by the kernel during early boot. It is encoded as a
series of type-length-value entries and is usually constructed by
loader(8) and passed to the kernel. It is also faked on some
architectures when booted by other means.

Although much of the module information is available via kldstat(8),
there is no easy way to debug the metadata in its entirety. Add some
routines to parse this data and allow it to be printed to the console
during early boot or output via a sysctl.

Since the output can be lengthly, printing to the console is gated
behind the debug.dump_modinfo_at_boot kenv variable as well as the
BOOTVERBOSE flag. The sysctl to print the metadata is named
debug.dump_modinfo.

Reviewed by:	tsoome
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D26687
2020-10-08 18:02:05 +00:00
Mitchell Horne
8481aab1ac Print symbol index for unsupported relocation types
It is unlikely, but possible, that an unrecognized or unsupported
relocation type is encountered while trying to load a kernel module. If
this occurs we should offer the symbol index as a hint to the user.

While here, fix some small style issues.

Reviewed by:	markj, kib (amd64 part, in D26701)
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
2020-10-07 18:48:10 +00:00
Emmanuel Vadot
90b8c0ea10 Fix LINT: Add backlight to NOTES 2020-10-02 20:52:09 +00:00
Edward Tomasz Napierala
1e2521ffae Get rid of sa->narg. It serves no purpose; use sa->callp->sy_narg instead.
Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26458
2020-09-27 18:47:06 +00:00
Michal Meloun
2e3294cd04 Don't send a signal with uninitialized 'sig' and 'code' fields.
We have a few shortcuts in the arm trap code to speed up obvious "must fail"
cases. In these situations, make sure that we fill in the "sig" and "code"
fields of the generated signal.

MFC after:	3 weeks
2020-09-27 11:37:17 +00:00
Edward Tomasz Napierala
0c5bd5f993 Regen after r366145.
Sponsored by:	DARPA
2020-09-25 10:05:38 +00:00
Andriy Gapon
e08dc44162 aw_pwm: add a check and some comments related to long periods
The hardware supports periods as long as 196 seconds[*] when using the
maximal prescaling of 72000 and maximum cycle count of 2^16.

But the code becomes incorrect when the period length approaches 1 second.
That's because of things like NS_PER_SEC / period.

[*] At the same time I must note that the KPI provides for maximum
period of about 4 seconds (2^32 nanoseconds).

MFC after:	2 weeks
2020-09-25 07:41:51 +00:00
Andriy Gapon
6957a14075 aw_pwm: ensure sane configuration, just in case
Make sure that the hardware is configured to cycle mode and that the
bypass is disabled.

MFC after:	2 weeks
2020-09-25 07:40:56 +00:00
Andriy Gapon
fc1ec731c8 aw_pwm: fix programming of the period
The programmed value is biased by one: 0 means 1 cycle,
1 means 2 cycles, etc.

MFC after:	3 weeks
2020-09-25 07:40:26 +00:00
Andriy Gapon
1c2c602a17 aw_pwm: fix selection of the prescaler
Prescaling divides the frequency, not multiplies it.

MFC after:	2 weeks
2020-09-25 07:40:02 +00:00
Andriy Gapon
108d235ae6 aw_pwm: remove the busy bit check
The bit seems to always be set on my hardware, H3.
However, programming the hardware seems to work just fine.

MFC after:	3 weeks
2020-09-25 07:39:41 +00:00
Andriy Gapon
b1dbb66d49 aw_pwm: trivially add H3 support
MFC after:	2 weeks
2020-09-25 07:39:14 +00:00
Mark Johnston
78257765f2 Add a vmparam.h constant indicating pmap support for large pages.
Enable SHM_LARGEPAGE support on arm64.

Reviewed by:	alc, kib
Sponsored by:	Juniper Networks, Inc., Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D26467
2020-09-23 19:34:21 +00:00
D Scott Phillips
00e6614750 Sparsify the vm_page_dump bitmap
On Ampere Altra systems, the sparse population of RAM within the
physical address space causes the vm_page_dump bitmap to be much
larger than necessary, increasing the size from ~8 Mib to > 2 Gib
(and overflowing `int` for the size).

Changing the page dump bitmap also changes the minidump file
format, so changes are also necessary in libkvm.

Reviewed by:	jhb
Approved by:	scottl (implicit)
MFC after:	1 week
Sponsored by:	Ampere Computing, Inc.
Differential Revision:	https://reviews.freebsd.org/D26131
2020-09-21 22:21:59 +00:00
D Scott Phillips
ab041f713a Move vm_page_dump bitset array definition to MI code
These definitions were repeated by all architectures, with small
variations. Consolidate the common definitons in machine
independent code and use bitset(9) macros for manipulation. Many
opportunities for deduplication remain in the machine dependent
minidump logic. The only intended functional change is increasing
the bit index type to vm_pindex_t, allowing the indexing of pages
with address of 8 TiB and greater.

Reviewed by:	kib, markj
Approved by:	scottl (implicit)
MFC after:	1 week
Sponsored by:	Ampere Computing, Inc.
Differential Revision:	https://reviews.freebsd.org/D26129
2020-09-21 22:20:37 +00:00