Commit Graph

5584 Commits

Author SHA1 Message Date
Mitchell Horne
aba91805aa hwpmc: use kstack_contains()
This existing helper function is preferable to the hand-rolled
calculation of the kstack bounds.

Make some small style improvements while here. Notably, rename every
instance of "r", the return address, to "ra". Tidy the includes in the
affected files.

Reviewed by:	jkoshy
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39909
2023-05-06 14:49:19 -03:00
John Baldwin
6cf4b46197 emac(4): Use bool rather than boolean_t.
This was already using true/false rather than TRUE/FALSE.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D39927
2023-05-04 12:34:02 -07:00
John Baldwin
afdb42987c ofw_cpu_early_foreach: Change callback to return bool instead of boolean_t.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D39926
2023-05-04 12:33:39 -07:00
John Baldwin
407f675718 imgact_elf: Change header_supported to return bool instead of boolean_t.
Reviewed by:	imp, kib, emaste
Differential Revision:	https://reviews.freebsd.org/D39919
2023-05-04 12:29:29 -07:00
Emmanuel Vadot
3416e102c4 arm: Remove TI code from GENERIC
TI support is in a sad state for years.
We haven't been able to keep up with all the breaking changes that
upstream do in the DTS. This requires a lot of new drivers to handle the
new buses that they create and all the new clocks that they expose.
Keep the code for now in case somebody is interested in reviving this
platform but stop bloating GENERIC with code that don't work.

Reviewed by:	imp, mmel
MFC after:	never
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D39843
2023-05-01 08:32:21 +02:00
Konrad Sewiłło-Jopek
d43bf55fc5 armv7: Fix BeagleBone Black panic on system start
There is now assertion which requires all memory allocations of positive size.
Negative and zero-sized allocations lead to panic, so plug them off.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D39846
2023-04-28 22:03:57 +02:00
Elliott Mitchell
d7e3b05b0d arm: remove passing trapframe to intr_ipi_dispatch()
This was needed before INTRNG was in place and handling the push of
curthread->td_intr_frame.  Since INTRNG now handles this, there is no
longer and need for playing around with the frame inside IPI interrupts.
2023-04-26 20:08:30 +01:00
Elliott Mitchell
c7e5e9dc41 arm: remove interrupt nesting by ipi_preempt()/ipi_hardclock()
This was needed when intr_ipi_dispatch() was called by hardware-specific
IPI interrupt routines which didn't save the trap frame.  Now all ARM
interrupts pass through INTRNG which will have already saved the trap
frame and disabled preemption.

Remove the conditional trapframe/argument passing to the handlers.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D37938
2023-04-26 20:08:30 +01:00
Andrew Turner
8bc94f256e Remove redundant data from pci host generic
The bus tag and handle fields are already stored in the resource. Use
this with the bus_read/bus_write helper macros.

Sponsored by:	Arm Ltd
2023-04-24 12:33:50 +01:00
John Baldwin
bf04385521 arm: Use C89 function declaration for db_read_bytes. 2023-04-20 11:00:46 -07:00
Konstantin Belousov
1e0e335b0f amd64: fix PKRU and swapout interaction
When vm_map_remove() is called from vm_swapout_map_deactivate_pages()
due to swapout, PKRU attributes for the removed range must be kept
intact.  Provide a variant of pmap_remove(), pmap_map_delete(), to
allow pmap to distinguish between real removes of the UVA mappings
and any other internal removes, e.g. swapout.

For non-amd64, pmap_map_delete() is stubbed by define to pmap_remove().

Reported by:	andrew
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D39556
2023-04-15 02:53:59 +03:00
Gordon Bergling
26713ad9cf arm: Remove a double word in a comment in setjmp
- s/number number/number/

MFC after:	5 days
2023-04-13 20:37:25 +02:00
Alexander V. Chernikov
3091d980f5 netlink: add NETLINK to the DEFAULTS for each architecture
NETLINK is going to replace rtsock and a number of other ioctl/sysctl interfaces.
In-base utilies such as route(8), netstat(8) and soon ifconfig(8)
 are being converted to use netlink sockets as a transport between
 kernel and userland.
In the current configuration, it still possible have the kernel
 without NETLINK (`nooptions NETLINK`) and use the aforementioned
 utilies by buidling the world with `WITHOUT_NETLINK` src.conf knob.
However, this approach does not cover the cases when person unintentionally
 builds a custom kernel without netlink and tries to use the standard userland.

This change adds `option NETLINK` to the default options for each
 architecture, fixing the custom kernel issue.
For arm, this change uses `std.armv6` and `std.armv7` (netlink already in)
 instead of DEFAULTS.

Reviewed By: imp
Differential Revision: https://reviews.freebsd.org/D39339
2023-04-02 15:27:21 +00:00
David E. O'Brien
daa0b64a22 pmap_mapdev_attr() doesn't use any of its arguments. 2023-03-20 23:09:34 -07:00
Mitchell Horne
c650e19495 arm: nexus code tidy-up
Make a pass at the various nexus implementations, fixing some very minor
style issues, obsolete comments, etc.

The method declaration section has become unwieldy in many respects.
Attempt to tame it by:
 - Using generated method typedefs
 - Grouping methods roughly by category, and then alphabetically.

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D38495
2023-03-20 17:35:47 -03:00
Emmanuel Vadot
949efdaa1d arm: Remove SOCFPGA specific kernel configs
We had GENERIC for a while now so anyone still interested in those boards
should make sure that we can boot on them with it and with upstream DTS files.

Sponsored by:   Beckhoff Automation GmbH & Co. KG
Reviewed by:	br
Differential Revision:	https://reviews.freebsd.org/D39088
2023-03-17 14:49:01 +01:00
Emmanuel Vadot
00e84f52f0 arm: Rename hdmi_if.m to crtc_if.m
There is nothing hdmi related in this interface, it's just a generic interface
for crt controller so rename it.
This also remove the 'hdmi' device used in arm kernel config. 'vt' now controls
if we build this interface (sc(4) isn't supported on arm).

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D39120
2023-03-17 13:34:57 +01:00
Emmanuel Vadot
3bcb469c61 arm: ti: Rename video related devices
device 'hdmi' is too generic (and will be used later in a new device) so rename
the arm TI devices to some proper name.

Sponsored by:   Beckhoff Automation GmbH & Co. KG
Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D39119
2023-03-17 13:34:52 +01:00
Emmanuel Vadot
8574d32f22 arm: imx: Rename video related devices
device 'hdmi' is too generic (and will be used later in a new device) so rename
the arm IMX devices to some proper name.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D39118
2023-03-17 13:34:46 +01:00
Emmanuel Vadot
37531e78df arm: allwinner: Garbage collect a10_hdmi driver
It was disconnected 5 years ago in 4573cd3914
("arm: allwinner: Disconnect A10/A20 HDMI driver") as it wasn't working.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D39117
2023-03-17 13:34:40 +01:00
Emmanuel Vadot
1c4ff02a74 arm: Remove IMX6 kernel config
All devices are in GENERIC and GENERIC is known to boot on those SoCs.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D39090
2023-03-17 13:34:03 +01:00
Emmanuel Vadot
cdb0c2a73d arm: Remove IMX5 specific kernel configs
We had GENERIC for a while now so anyone still interested in those boards
should make sure that we can boot on them with it and with upstream DTS files.

Sponsored by:   Beckhoff Automation GmbH & Co. KG
Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D39089
2023-03-17 13:33:57 +01:00
Emmanuel Vadot
ba9f8eeb47 arm: Remove VYBRID specific kernel config
We had GENERIC for a while now so anyone still interested in those boards
should make sure that we can boot on them with it and with upstream DTS files.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D39087
2023-03-17 13:33:51 +01:00
Emmanuel Vadot
031461b166 arm: Remove kernel config APALIS-IMX6
It reference to a non-existant dts file apalis-imx6.dts so unlikekly to compile.
Aldo IMX6 support is in GENERIC so anyone interested in this board should
make it work with GENERIC kernel (if that's not already the case).

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D39086
2023-03-17 13:33:46 +01:00
Andrew Turner
5c4bd8756f Stop using the rid as an index in the arm timer
The order of the interrupt array doesn't matter. Store the described
interrupts at the start of the array to simplify iterating over them.

Reviewed by:	imp, kevans
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D39094
2023-03-15 15:49:00 +00:00
Andrew Turner
02f3d094ae Use the arm physical timer when able
To allow bhyve manage the virtual timer while in a guest have FreeBSD
use the virtual timer only when bhyve will be unavailable due to not
starting at EL2 where the hypervisor switcher will run.

Reviewed by:	imp, kevans
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D39093
2023-03-15 15:49:00 +00:00
Andrew Turner
b71ef90ec2 Keep per-timer interrupt data together
Eliminate a redundant resource array allow possible use by bhyve later.

Reviewed by:	kevans
Sponsored by:	Arm Ltd
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37424
2023-03-15 11:34:31 +00:00
Andrew Turner
93d574ea95 Always enable the virtual timer for userspace
We always have it, some languages assume it's present, e.g. go
before 1.20. Enable it by default on arm and arm64.

PR:		269070
Reviewed by:	kevans
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D39059
2023-03-14 10:37:36 +00:00
Kyle Evans
91b2da1370 arm: generic_timer: use interrupt-names when available
Offsets for all of thse can be a bit complicated as not all interrupts
will be present, only phys and virt are actually required, and sec-phys
could optionally be specified before phys.  Push idx/name pairs into
a new config struct and maintain the old indices while still getting the
correct timers.

Split fdt/acpi attach out independently and allocate interrupts before
we head into the common attach().  The secure physical timer is also
optional there, so mark it so to avoid erroring out if we run into
problems.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D38911
2023-03-13 19:30:28 -05:00
Justin Hibbits
068f2c0e10 Mechanically convert dwc(4) to IfAPI
Reviewed by:	manu (older)
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37846
2023-03-07 09:49:11 -05:00
Justin Hibbits
6d18b481f2 cpsw(4): Finish conversion to IfAPI
Two ifnet accesses were missed in 2c7bc0f55.

Sponsored by:	Juniper Networks, Inc.
2023-03-07 09:47:01 -05:00
Andrew Turner
cb894f746c Map arm64 pci config memory as non-posted
On arm64 PCI config memory is expected to be mapped with a non-posted
device type. To handle this use the new bus_map_resource support in
arm64 to map memory with the new VM_MEMATTR_DEVICE_NP attribute. This
memory has already been allocated and activated, it just needs to be
mapped.

Reviewed by:	kevans, mmel
Differential Revision:	https://reviews.freebsd.org/D30079
2023-03-05 20:17:21 +00:00
Emmanuel Vadot
0fed8288c3 arm: Tag VHYBRID kernel as NO_UNIVERSE
All drivers are already either in GENERIC or in the other arches LINT
so no need to build this one too.

Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38851
2023-03-02 19:59:28 +01:00
Emmanuel Vadot
79ec3b10b4 arm: Tag SOCFPGA kernel as NO_UNIVERSE
All drivers are already either in GENERIC or in the other arches LINT
so no need to build this one too.

Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38850
2023-03-02 19:59:23 +01:00
Emmanuel Vadot
68f8ac87e0 arm: Tag EFIKA_MX kernel as NO_UNIVERSE
All drivers are already either in GENERIC or in the IMX51 kernel config
so no need to build this one too.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38849
2023-03-02 19:59:16 +01:00
Emmanuel Vadot
f201e3800b arm: Tag ALPINE kernel as NO_UNIVERSE
Specific devices are in LINT so no need to build this one as part
of make universe.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38848
Reviewed by:	imp
2023-03-02 19:59:11 +01:00
Emmanuel Vadot
58d487c301 arm: Add PCI and Annapurna devices drivers to LINT
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38847
Reviewed by:	imp
2023-03-02 19:59:04 +01:00
Mitchell Horne
07ccf71451 bcm_dma: don't dereference NULL softc
This file defines a small API to be used by other drivers. If any of
these functions are called before the bcm_dma device has attached we
should handle the error gracefully. Fix a formatting quirk while here.

Reviewed by:	manu
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D38756
2023-02-24 13:20:40 -04:00
Mark Millard
9873b17169 bcm_dma: attach at an earlier bus pass
The sdhci_bcm driver attach routine relies on bcm_dma already being
attached, in order to allocate a DMA channel. However, both drivers
attached at the default pass so this is not guaranteed. Newer RPI
firmware exposes this assumption, and the result is a NULL-dereference
in bcm_dma_allocate().

To fix this, use BUS_PASS_SUPPORTDEV for bcm_dma.

PR:		268835
Reviewed by:	mhorne
MFC after:	1 week
2023-02-24 13:20:40 -04:00
Mike Karels
91646fe575 arm kernel config: clean up whitespace
Most options in kernel config files use "options<space><tab>OPTION".
This allows the option to be commented out without shifting columns.
A few options had two tabs, and some had spaces.  Make them consistent.
2023-02-24 08:36:28 -06:00
Kornel Dulęba
98c666cf87 arm: Fix initialization of VFP context
Make sure that pcb_vfpsaved is always initialized.
Create a vfp_new_thread helper that is heavily based on the arm64 logic.
While here remove un unnecessary assigment and add an assertion
to make sure that it's been properly initialized before we return
from a VFP exception.

Reported by: Mark Millard <marklmi@yahoo.com>
Tested by: Mark Millard <marklmi@yahoo.com>
Differential Revision: https://reviews.freebsd.org/D38698
2023-02-23 17:50:26 +01:00
Kornel Dulęba
4d2427f2c4 arm: Unbreak debugging programs that use FP instructions
Contrary to arm64, on armv7 get_vfpcontext/set_vfpcontext can be called
from cpu_ptrace. This can be triggered when gdb hits a breakpoint
in a userspace program.
Relax td == currthread assertion to account for that situation.
While here update an outdated comment in vfp_discard.

Reported by: Mark Millard <marklmi@yahoo.com>
Tested by: Mark Millard <marklmi@yahoo.com>
Differential Revision: https://reviews.freebsd.org/D38696
2023-02-23 17:50:26 +01:00
Gordon Bergling
49bf65be44 arm ti: Fix a typo in a kernel message
- s/adress/address/

MFC after:	5 days
2023-02-22 09:43:49 +01:00
Andrew Turner
24abb6b821 When saving a context on arm call the vfp handler
When adding kernel VFP support on arm a comparison instruction was
removed, however the branch to vfp_save_state was still conditional.
Remove the conditional check and always call into vfp_save_state as
it could cause unexpected results otherwise.

Sponsored by:	Arm Ltd
2023-02-20 12:29:56 +00:00
Mateusz Guzik
6b9acd1bfb Exclude MMCCAM kernels from make universe
They don't provide any value and are quite arbitrary.

Note arm64 GENERIC-MMCCAM was already excluded, just not the NODEBUG
variant.

The option is already build-tested with arm64 LINT kernel.

Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D38458
2023-02-16 07:29:53 +00:00
Mitchell Horne
53d5e65eea ofwbus: remove arm64 ifdefs
Rather than using the DEVICE_IDENTIFY method, let's have other
ofwbus-using platforms add ofwbus0 explicitly in nexus, like arm64. This
gives them the same flexibility, e.g. if riscv starts supporting ACPI,
and cleans up the #ifdefs.

We were doing this already on riscv, but adjust the 'order' parameters.

Reviewed by:	andrew, jhb
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D38492
2023-02-13 13:45:01 -04:00
Elliott Mitchell
f9bdaab95e ofwbus: remove handling of resources from ofwbus
The architecture nexus should handle allocation and release of memory and
interrupts. This is to ensure that system-wide resources such as these
are available to all devices, not just children of ofwbus0.

On powerpc this moves the ownership of these resources up one level,
from ofwbus0 to nexus0. Other architectures already have the required
logic in their nexus implementation, so this eliminates the duplication
of resources. An implementation of nexus_adjust_resource() is added for
arm, arm64, and riscv.

As noted by ian@ in the review, resource handling was the main bit of
logic distinguishing ofwbus from simplebus. With some attention to
detail, it should be possible to merge the two in the future.

Co-authored by:	mhorne
MFC after:	1 month
Differential Revision: https://reviews.freebsd.org/D30554
2023-02-08 16:50:46 -04:00
Mitchell Horne
1d03c3578d arm: add an interrupt rman to nexus
Allow the nexus bus to own and manage interrupt resources. Currently,
interrupt resources on this architecture are managed completely by
ofwbus, but it is desirable that system-wide memory and interrupt
resources be managed by the top-level bus.

This is a pre-requisite to moving this resource management out of
ofwbus.

Reviewed By:	ian, Elliott Mitchell <ehem+freebsd@m5p.com>
MFC after:	1 month
Differential Revision: https://reviews.freebsd.org/D32357
2023-02-08 16:50:46 -04:00
Val Packett
4a1c4de232 Allow sysctl hw.machine/hw.machine_arch in capability mode
There's no harm in reading strings like 'amd64'.

Reviewed by: emaste, manu
Sponsored by: https://www.patreon.com/valpackett
Differential Revision: https://reviews.freebsd.org/D28703
2023-02-06 14:00:52 -05:00
Kornel Dulęba
e5d7c5c857 arm: mv: Add missing function prototype
This fixes armv7 kernel build with gcc12.
2023-02-04 20:21:43 +01:00