Commit Graph

1608 Commits

Author SHA1 Message Date
Mike Karels
184291b0a5 genet: pullup minimum header amount for IPv4
The genet driver (RPi4 Ethernet) had code to pull headers into the
first mbuf if there was only an Ethernet header there.  This was
originally needed for ICMPv6 replies, then for forwarded IPv6/TCP.
Now a situation has been found where it is needed for IPv4, when
using NAT with IPFW.  Generalize to do this for all protocols.
Rather than using an IPv6-related definition for the length, move
the length to a variable that can be set with sysctl
(hw.genet.tx_hdr_min).  Move an old tunable to a new RDTUN variable
with a better name.

PR:		25607
MFC after:	3 days
Reviewers:	emaste
Differential Revision: https://reviews.freebsd.org/D30831
2021-06-26 11:04:02 -05:00
Alan Cox
5dd84e315a arm64: fix a potential KVA leak in pmap_demote_l1()
In the unlikely event that the 1 GB page mapping being demoted is used
to access the L1 page table page containing the 1 GB page mapping and
the vm_page_alloc() to allocate a new L2 page table page fails, we
would leak a page of kernel virtual address space.  Fix this leak.

MFC after:	1 week
2021-06-25 23:01:32 -05:00
Alan Cox
c94249decd arm64: make it possible to define PV_STATS
Remove an #if 0 that results in a compilation error if PV_STATS is
defined.  Aside from this #if 0, there is nothing wrong with the
PV_STATS code.

MFC after:	1 week
2021-06-24 18:32:56 -05:00
Marcin Wojtas
19aa95e4b3 Introduce new driver for NXP Ethernet controller
ENETC it a gigabit Ethernet controller found on the LS1028A board.
It supports basic VLAN offloads - tag extraction, injection and hardware
filtering. Inband MDIO connectivity is used for link status
monitoring through the miibus interface. Fixed-link mode is also
supported, which allows for operation of internal cpu to switch port.
Since no admin interrupts are present in hardware, link status polling
has to be used.
Due to a hardware bug software reset of the NIC results in a external
abort. Because of that most of the hardware initialization is done
during attach. This also means that in the case of an fatal error full
board reset is required.
The enetc_hw.h header was imporoted from Linux. It is dual licensed.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D30729
2021-06-24 13:01:13 +02:00
Colin Percival
ccadcb8f33 arm64: Instrument initarm with TSLOG
The "function entry" needs to be recorded with TSRAW() rather than
TSENTER() since curthread is not yet defined.  (The same approach
is taken in amd64's hammer_time.)
2021-06-23 22:17:55 -07:00
Colin Percival
0acc529dc3 arm64: Disable early printf if TSLOG
The warning message "ERROR loading DTB" (for systems without a device
tree blob) is printed extremely early in the boot process -- among
other things, before curthread or other pcpu data has been set up.
Unfortunately, printf is instrumented with TSLOG, which cannot run
quite this early.

Wrap the printf in #ifndef TSLOG; the situations where the printf
will be useful are not ones where TSLOG would be in use.
2021-06-23 22:10:26 -07:00
Alan Cox
0c188c06c6 arm64: replace pa_to_pvh() with page_to_pvh() in pmap_remove_l2()
Revise pmap_remove_l2() to use the constant-time function page_to_pvh()
instead of the linear-time function pa_to_pvh().

Reviewed by:	kib, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30876
2021-06-23 22:35:46 -05:00
Alan Cox
62ea198e95 arm64: remove an unneeded test from pmap_clear_modify()
The page table entry for a 4KB page mapping must be valid if a PV entry
for the mapping exists, so there is no point in testing each page table
entry's validity when iterating over a PV list.

Reviewed by:	kib, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30875
2021-06-23 14:22:46 -05:00
Alan Cox
6f6a166eaf arm64: Use page_to_pvh() when the vm_page_t is known
When support for a sparse pv_table was added, the implementation of
pa_to_pvh() changed from a simple constant-time calculation to iterating
over the array vm_phys_segs[].  To mitigate this issue, an alternative
function, page_to_pvh(), was introduced that still runs in constant time
but requires the vm_page_t to be known.  However, three cases where the
vm_page_t is known were not converted to page_to_pvh().  This change
converts those three cases.

Reviewed by:	kib, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30832
2021-06-21 17:25:06 -05:00
Dmitry Chagin
c1da89fec2 linux(4): Retire linux_kplatform.
Assuming we can't run on i486, i586 class cpu, retire linux_kplatform var
and use hardcoded 'machine' value in linux_newuname().

I have added linux_kplatform for consistency with linux_platform which is
placed in to vdso to avoid excess copyout it on stack for AT_PLATFORM at
exec time.

This is the first stage of Linuxulator's vdso revision.

Reviewed by:		trasz, imp
Differential Revision:	https://reviews.freebsd.org/D30774
MFC after:		2 weeks
2021-06-22 08:36:21 +03:00
Mike Karels
13604fb0fd genet: Fix potential crash during attach
As pointed out in the bug, the genet driver (RPi4 Ethernet) was
attaching the interrupts before the data structures were fully
initialized, causing a crash if an interrupt came in during the
attach.  Fix by reordering code blocks.

PR:		256334
Reported by:	< ghuckriede at blackberry.com >
Reviewed by:	< ghuckriede at blackberry.com > (informally)
MFC after:	3 days
2021-06-20 11:17:13 -05:00
Edward Tomasz Napierala
a397b55083 linux: implement set_cloned_tls() on arm64
This fixes random segfaults on "git commit --amend".

Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D30508
2021-06-16 10:32:39 +00:00
Edward Tomasz Napierala
e505c3066b linux: implement set_upcall on aarch64
This fixes "git diff" (git-1:2.25.1-1ubuntu3).

Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D30509
2021-06-16 05:13:17 +00:00
Konstantin Belousov
870e197d52 Add quirks for Linux ABI signals handling
Require queueing of the signals with default action, and disable
dequeueing SIGCHLD on wait for live process.

Reported and tested by:	dchagin
Reviewed by:	dchagin, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D30675
2021-06-16 02:01:35 +03: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
Andrew Turner
e7f369b1c1 Use the correct length when copying arm64 vfp registers
We passed the wrong length into memcpy in the arm64 get_fpcontext and
set_fpcontext. This caused us to copy two status registers we didn't
expect to copy.

These are safe as they exist in both the source and destination, although
in a different order, and we copy the correct values after the memcpy.

Obtained from:	CheriBSD
Sponsored by:	Innovate UK
2021-06-14 14:53:10 +00: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
Andriy Gapon
ffc5dc788f rk3328_cru: fix a typo in the SCLK_I2S2 gate definition
MFC after:	4 days
2021-06-09 12:41:52 +03:00
Marcin Wojtas
f0f7b0868a Remove ThunderX PCIe FDT quirks from pci_host_generic_fdt.c
ThunderX is the only board known to use them.
Move them to the ThunderX PCIe driver.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: andrew
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D30179
2021-06-08 17:51:11 +02:00
Mark Johnston
4e4035ef1f arm64: Fix pmap_copy()'s handling of 2MB mappings
When copying mappings from parent to child, we clear the accessed and
dirty bits.  This is done for both 4KB and 2MB PTEs.  However,
pmap_demote_l2() asserts that writable superpages must be dirty.  This
is to avoid races with the MMU setting the dirty bit during promotion
and demotion.  pmap_copy() can create clean, writable superpage
mappings, so it violates this assertion.

Modify pmap_copy() to preserve the accessed and dirty bits when copying
2MB mappings, like we do on amd64.

Fixes:		ca2cae0b4d
Reported by:	Jenkins via mhorne
Reviewed by:	alc, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30643
2021-06-06 16:44:46 -04:00
Mark Johnston
a48f51b3d3 arm64: Use the right PTE when downgrading perms in pmap_promote_l2()
When promoting a run of small mappings to a superpage, we have to
downgrade clean, writable mappings to read-only, to handle the
possibility that the MMU will concurrently mark one of the mappings as
dirty.

The code which performed this operation for the first PTE in the run
used the wrong PTE pointer.  As a result, the comparison would always
fail, aborting the promotion.  This only occurs when promoting writable,
clean mappings.

Fixes:		ca2cae0b4d
Reviewed by:	alc, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30642
2021-06-06 16:44:46 -04:00
Konstantin Belousov
598f6fb49c linuxolator: Add compat.linux.setid_allowed knob
PR:	21463
Reported by:	kris
Reviewed by:	dchagin
Tested by:	trasz
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28154
2021-06-06 21:43:00 +03: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
Bjoern A. Zeeb
002cbc89c3 arm64/rk805: remove RTC Set logging
When ntpd is synchronizing the system time, it also periodically (30m)
syncs the the RTC time.  Remove printf in rk805_settime which triggers
every 30m, as settime_task_func() will log errors under bootverbose.
We leave the RTC Read logging, which should happen only once at boot.

Commit message by:	imp
Reviewed by:		manu, imp
MFC after:		2 weeks
Differential Revision: https://reviews.freebsd.org/D30361
2021-06-05 17:07:56 +00:00
Bjoern A. Zeeb
57af163c8e arm64/rk_pcie_phy: handle assigned-clock*
Nanopi4 based SoCs (NanoPC-T4, NanoPi M4*, and NanoPi Neo4) have
assigned-clock* in the pcie_phy node.  Handle them but only fail
in case clk_set_assigned() returns an error other than
"no assigned-clock*" (as it would for all other SoCs).

Reviewed by:	manu
MFC After:	2 weeks
Differential Revision: https://reviews.freebsd.org/D30363
2021-06-05 16:16:29 +00:00
Edward Tomasz Napierala
b501b2ae52 linux: export AT_HWCAP and AT_HWCAP2 on aarch64
The flag values seem to be the same between Linux and FreeBSD.
Comparing to a Linux VM on the same hardware, we're missing
HWCAP_EVTSTRM, HWCAP_CPUID, HWCAP_DCPOP, HWCAP_USCAT, HWCAP_PACA,
and HWCAP_PACG.

Reviewed By:	mhorne, emaste
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D30540
2021-06-01 13:50:20 +01:00
Dmitry Chagin
19593f775c linux(4); Retire unnecessary __packed attribute from some struct's
definition.

Differential Revision:	https://reviews.freebsd.org/D30482
MFC after:		2 weeks
2021-05-31 21:56:34 +03:00
Edward Tomasz Napierala
83043a741d linux: deduplicate DUMMY() entries
No functional changes.

Reviewed By:	emaste
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D30524
2021-05-29 17:51:36 +00:00
Edward Tomasz Napierala
aa462cab60 linux: fix architecture returned for uname on aarch64
Previously it would return "arm64", which was breaking build
for Linux kernel.  While here, reshuffle entries in the auxv
vector to match real Linux.

Reviewed By:	emaste
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D30500
2021-05-28 23:02:02 +00:00
Edward Tomasz Napierala
023ee5392c linux: make linux64.ko loadable again on aarch64
This should probably get deduplicated; this is a quick fix
just to unbreak things.

Fixes:		6d926e850d
Sponsored By:	EPSRC
2021-05-28 14:20:30 +00:00
Ed Maste
d097687b31 arm64: correct END() copy-pasteo for generic_bs_fault
PR:		256197
Reported by:	Nick Reilly
MFC after:	1 week
Fixes:		95a85c125d ("Add NetBSD compatible bus_space_peek_N()...")
Sponsored by:	The FreeBSD Foundation
2021-05-28 09:10:11 -04:00
Edward Tomasz Napierala
c0f171736a Regen after 6d926e850d.
Sponsored By:	EPSRC
2021-05-28 09:04:17 +01:00
Edward Tomasz Napierala
6d926e850d linux: add new syscall numbers
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D30193
2021-05-28 09:02:16 +01:00
Ruslan Bukin
38e7025a60 o Fix i2c read operation for large transfers (more than 32 bytes).
o Fix slave address setting.

This allows to read the EDID from an HDMI monitor.

Reviewed by:	manu
Sponsored by:	UKRI
Differential Revision: https://reviews.freebsd.org/D27139
2021-05-26 10:55:23 +01:00
Mitchell Horne
6f4bb8ecc2 arm64, riscv: remove reference to fsu_intr_fault
This variable no longer exists.

MFC after:	3 days
2021-05-25 12:26:52 -03:00
Bjoern A. Zeeb
fbf75b113e arm64: log vm_fault error for data_abort
Summary:
Log the vm_fault() error in the data_abort panic so it is easier to
find the reason vm_fault() failed (e.g., invalid address).

Reviewed by:	andrew
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D30362
2021-05-24 21:58:11 +00:00
Andrew Turner
e779604f1d Clean up early arm64 pmap code
Early in the arm64 pmap code we need to translate between a virtual
address and a physical address. Rather than manually walking the page
table we can ask the hardware to do it for us.

Reviewed by:	kib, markj
Sponsored by:	Innovate UK
Differential Revision: https://reviews.freebsd.org/D30357
2021-05-24 09:22:19 +00:00
Emmanuel Vadot
bc1bb80564 arm64: rockchip: gpio: Give friendlier name to gpio
By default name the gpio P<bank><bankpin>
This make it easier to find the gpio when reading schematics or DTS.

Sponsored by:	Diablotin Systems
Differential Revision:	https://reviews.freebsd.org/D30287
2021-05-21 17:35:43 +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
Bjoern A. Zeeb
f0a5e81af4 arm64: rockchip, implement the two rk805/808 clocks
While the xin32k clk was implemented in rk3399_cru as a fixed rate
clock, migrate it to rk805 as we will also need the 2nd clock
'rtc_clko_wifi' for SDIO and BT.
Both clocks remain fixed rate, and while the 1st one is always on
(though that is not expressed in the clk framework), the 2nd one
we can toggle on/off.

Reviewed-by:	manu
Tested-by:	manu
MFC-after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D26870
2021-05-19 11:48:11 +00:00
Marcin Wojtas
f55bd0e579 qoriq_dw_pci: disable LS1028A support
Enabled driver initialization causes an abort
on the NXP LS1028ARDB platform (without any external
endpoints connected). Temporarily disable qoriq_dw_pci
probe, so that to allow successful booting of the OS.

Submitted by: Lukasz Hajec <lha@semihalf.com>
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D30229
2021-05-14 10:50:17 +02:00
Ed Maste
2c9764f36b regen syscall files after d51198d63b63 2021-05-13 14:09:58 -04:00
Marcin Wojtas
4dfb620ea4 Add LS1028A clockgen driver
The new driver provides probe and attach functions for the NXP LS1028A
clockgen and passes configuration information to QorIQ clockgen class.

Submitted by: Lukasz Hajec <lha@semihalf.com>
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D30125
2021-05-07 03:48:53 +02:00
Andrew Turner
2420f6aed9 Enable IPIs on CPU 0 on arm and arm64
Not all interrupt controllers enable IPIs by default as the Arm
GIC specs make it an implementation defined option. As at least two
hypervisors have also previously masked the IPIs on boot.

As we already enable these IPIs on the non-boot CPUs it is expected
this is a safe operation.

Differential Revision:	https://reviews.freebsd.org/D26975
2021-05-02 07:43:34 +00:00
Andrew Turner
fe38224977 Implement bus_map_resource on arm64
This will allow us to allocate an unmapped memory resource, then
later map it with a specific memory attribute.

This is also needed for virtio with the modern PCI attachment.

Reviewed by:	kib (via D29723)
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D29694
2021-05-02 07:35:16 +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
Andrew Turner
2abd4f8581 Add a way to map arm64 non-posted device memory
On arm64 we currently use a non-posted write for device memory, however
we should move to use posted writes. This is expected to work on most
hardware, however we will need to support a non-posted option for some
broken hardware.

Reviewed by:	imp, manu, bcr (manpage)
Differential Revision:	https://reviews.freebsd.org/D29722
2021-05-01 06:01:20 +00:00
Marcin Wojtas
e245ee2774 gicv3_its: Flush cache after allocating ITT memory
It has to be zeroed before committing it to device.
We do that by allocating it with M_ZERO, but there was no
memory barrier or cache flush to ensure its sees it zeroed.
This fixes MSIX on LS1028A SoC.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: andrew
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D30033
2021-05-01 00:58:26 +02:00
Ruslan Bukin
f17c4e38f5 Move IOMMU code to a separate pmap module and switch ARM System MMU
driver to use it.

Add ARM Mali Txxx (Midgard), Gxx (Bifrost) GPU page management code.

Sponsored by: UKRI
2021-04-27 19:16:09 +01:00
Alexander V. Chernikov
6993187a8c Add FIB_ALGO to GENERIC on amd64/arm64.
Option `FIB_ALGO` gates new modular fib lookup functionality,
 enabling more performant routing table lookups and improving
 control plane convergence under the load.

Detailed feature description is available in D27401.

Reviewed By: olivier, gnn
Differential Revision: https://reviews.freebsd.org/D28434
2021-04-24 23:22:58 +00:00
Mitchell Horne
5742f2d89c arm64: adjust comments in dbg_monitor_exit()
These comments were copied from dbg_monitor_enter(), but the intended
modifications weren't made. Update them to reflect what this code
actually does.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2021-04-13 14:41:31 -03:00
Mitchell Horne
a2a8b582bd arm64: clear debug registers after execve(2)
This is both intuitive and required, as any previous breakpoint settings
may not be applicable to the new process.

Reported by:	arichardson
Reviewed by:	kib
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29672
2021-04-13 14:41:03 -03:00
Mark Johnston
f66a1f4074 genet: Use device_t in preference to struct device *
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-04-12 09:31:58 -04:00
Andrew Turner
5998328e55 Clean up the style in the arm64 bus.h
MFC after:	2 weeks
Sponsored by:	Innovate UK
2021-04-08 10:27:11 +00:00
Mitchell Horne
1fd001db9c arm64: clear debug register state on fork
Following the analogous change for amd64 and i386 in 8223717ce6,
ensure that new processes start with these registers inactive.

PR:		254661
Reported by:	Michał Górny
Reviewed by:	kib, emaste
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29630
2021-04-08 09:41:41 -03:00
Andrew Turner
d6a53211a7 Discard the arm64 VFP state before resetting it
When resetting the VFP state we need to discard any old state so we don't
try to save it on a context switch. Move this first so resetting the pcb
is safe to perform outside a critical section.

Reviewed by:	arichardson
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D29401
2021-04-08 07:51:26 +00:00
Greg V
a29bff7a52 smbios: support getting address from EFI
On some systems (e.g. Lenovo ThinkPad X240, Apple MacBookPro12,1)
the SMBIOS entry point is not found in the <0xFFFFF space.

Follow the SMBIOS spec and use the EFI Configuration Table for
locating the entry point on EFI systems.

Reviewed by:	rpokala, dab
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D29276
2021-04-07 14:46:29 -05:00
Justin Hibbits
16e549ebe2 Merge the QorIQ GPIO drivers between arm and powerpc
Summary:
They're nearly identical, so don't use two copies.  Merge the newer
driver into the older one, and move it to a common location.

Add the Semihalf and associated copyrights in addition to mine, since
it's a non-trivial amount of code merged.

Reviewed By: mw
Differential Revision: https://reviews.freebsd.org/D29520
2021-04-05 10:35:15 -05: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
4beb385813 gdb: allow setting/removing hardware watchpoints
Handle the 'z' and 'Z' remote packets for manipulating hardware
watchpoints.

This could be expanded quite easily to support hardware or software
breakpoints as well.

https://sourceware.org/gdb/onlinedocs/gdb/Packets.html

Reviewed by:	cem, markj
MFC after:	3 weeks
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
NetApp PR:	51
Differential Revision:	https://reviews.freebsd.org/D29173
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
3ef68bc62c arm64: implement kdb watchpoint functions
Add wrappers around the debug_monitor interface, to be consumed by MI
kernel debugger code.  Update dbg_setup_watchpoint() and
dbg_remove_watchpoint() to return specific error codes, not just -1.

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:43 -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
Andrew Turner
df7549775c Replace the arm64 initial_fpcr with a macro
This value was never changed from its default value. Replace it with a
macro.

Sponsored by:	Innovate UK
2021-03-23 17:12:43 +00:00
Emmanuel Vadot
6bcba8dac9 arm64: Only check for freebsd,dts-version if we are booted in FDT mode.
Reported by:	  andrew
2021-03-23 16:37:25 +01:00
Emmanuel Vadot
63f344024a arm64: Check dtb version against the one we're expecting to find
Do for arm64 what was done for armv7 in e63faa9ba8
2021-03-23 15:24:53 +01:00
Mark Johnston
3ead60236f Generalize bus_space(9) and atomic(9) sanitizer interceptors
Make it easy to define interceptors for new sanitizer runtimes, rather
than assuming KCSAN.  Lay a bit of groundwork for KASAN and KMSAN.

When a sanitizer is compiled in, atomic(9) and bus_space(9) definitions
in atomic_san.h are used by default instead of the inline
implementations in the platform's atomic.h.  These definitions are
implemented in the sanitizer runtime, which includes
machine/{atomic,bus}.h with SAN_RUNTIME defined to pull in the actual
implementations.

No functional change intended.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2021-03-22 22:21:53 -04: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
John Baldwin
3b57ddb029 Rename linux_set_upcall_kse() to linux_set_upcall().
This matches the rename of cpu_set_upcall_kse() in
5c2cf81845.

Reviewed by:	kib, emaste
MFC after:	1 week
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D29295
2021-03-18 12:14:34 -07:00
Mike Karels
2bdcf62377 genet: Fix problem with forwarding some TCP/IPv6 packets
TCP/IPv6 packets to be forwarded can be laid out with only the Ethernet
header in the first mbuf, and these packets are lost.  There was a
previous hack to pullup ICMPv6 packets with such a layout for the
same reason.  Generalize, and pullup any IPv6 packets with only the
Ethernet header in the first mbuf.  Possibly this should also include
IPv4, but that situation has not been observed to fail.

PR:		254060
Reported by:	denis at h3q.com
MFC after:	3 days
2021-03-17 19:25:43 -05:00
Ed Maste
5be27cbf16 arm64: implement COMPAT_FREEBSD32 fill/set dbregs/fpregs
On FreeBSD/arm fill_fpregs, fill_dbregs are stubs that zero the reg
struct and return success. set_fpregs and set_dbregs do nothing and
return success.

Provide the same implementation for arm64 COMPAT_FREEBSD32.

Reviewed by:	andrew
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29314
2021-03-17 16:46:50 -04:00
John Baldwin
0723b40915 aarch64: Clear TLS registers during exec().
These are not stored in the trapframe so must be cleared explicitly.

This is similar to one of the MIPS changes in 822d2d6ac9.

Reviewed by:	andrew
Obtained from:	CheriBSD
MFC after:	1 week
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D28711
2021-03-17 13:19:04 -07:00
Peter Jeremy
07564e1762 arm64: Add support for the RK805/RK808 RTC
Implement a driver for the RTC embedded in the RK805/RK808 power
management system used for RK3328 and RK3399 SoCs.

Based on experiments on my RK808, setting the time doesn't alter the
internal/inaccessible sub-second counter, therefore there's no point
in calling clock_schedule().

Based on an earlier revision by andrew.

Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D22692
Sponsored by:	Google
MFC after:	1 week
2021-03-13 09:06:04 +11:00
Olivier Houchard
c328f64d81 arm64: Fix COMPAT_FREEBSD32.
The ENTRY() macro was modified by commit
28d945204e to add an optional NOP instruction
at the beginning of the function. It is of course an arm64 instruction, so
unsuitable for the 32bits sigcode. So just use EENTRY() instead for
aarch32_sigcode. This should fix receiving signals when running 32bits
binaries on FreeBSD/arm64.

MFC After: 1 week
2021-03-10 19:06:42 +01:00
Alex Richardson
953a7d7c61 Arch64: Clear VFP state on execve()
I noticed that many of the math-related tests were failing on AArch64.
After a lot of debugging, I noticed that the floating point exception flags
were not being reset when starting a new process. This change resets the
VFP inside exec_setregs() to ensure no VFP register state is leaked from
parent processes to children.

This commit also moves the clearing of fpcr that was added in 65618fdda0
from fork() to execve() since that makes more sense: fork() can retain
current register values, but execve() should result in a well-defined
clean state.

Reviewed By:	andrew
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D29060
2021-03-10 12:44:42 +00:00
Mark Johnston
435c7cfb24 Rename _cscan_atomic.h and _cscan_bus.h to atomic_san.h and bus_san.h
Other kernel sanitizers (KMSAN, KASAN) require interceptors as well, so
put these in a more generic place as a step towards importing the other
sanitizers.

No functional change intended.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29103
2021-03-08 12:39:06 -05:00
Alex Richardson
0072e5e0f3 sys/arm64/arm64/vfp.c: Fix -Wunused and -Wpointer-sign warnings
These are off by default but were flagged by my IDE while adding some
debugging printfs for D29060.
2021-03-04 18:25:44 +00:00
Andrew Turner
23553d6b94 Fix creating the early arm64 level 2 blocks
In 48ba9b2669 we switched from creating level 1 blocks to smaller
level 2 blocks when creating the early arm64 page tables. On issue
was that they had a different meaning for register x7. The former used
it to hold page table attributes, while the latter held just the memory
type. This caused these attributes to be incorrectly shifted.

Fix this by changing the meaning of x7 to hold the block attributes
and fix the only caller that used the old meaning.

Most hardware seems to have handled the bits being off however qemu
failed to boot as reserved bits that should be zero were being set and
qemu fails to clear these when translating from a virtual address to a
physical address.

Sponsored by:	Innovate UK
2021-03-04 14:39:12 +00:00
Andrew Turner
28d945204e Handle functions that use a nop in the arm64 fbt
To trace leaf asm functions we can insert a single nop instruction as
the first instruction in a function and trigger off this.

Reviewed by:	gnn
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D28132
2021-03-03 14:18:03 +00:00
Andrew Turner
48ba9b2669 Use L2 blocks when in the identity map
This reduces the memory mapped to be closer to the minimal memory
needed to enable the MMU.

Reviewed by:	mmel
Sponsored by:	Innovate UK
Differential Revision:://reviews.freebsd.org/D27765
2021-03-03 14:18:03 +00:00
Alex Richardson
0e4ff0acbe AArch64: Don't set flush-subnormals-to-zero flag on startup
This flag has been set on startup since 65618fdda0.
However, This causes some of the math-related tests to fail as they report
zero instead of a tiny number. This fixes at least
/usr/tests/lib/msun/ldexp_test and possibly others.
Additionally, setting this flag prevents printf() from printing subnormal
numbers in decimal form.
See also https://www.openwall.com/lists/musl/2021/02/26/1

PR:		253847
Reviewed By:	mmel
Differential Revision: https://reviews.freebsd.org/D28938
2021-03-01 14:27:30 +00:00
Mitchell Horne
e152c88273 arm64: add definition for IS_SSTEP_TRAP()
arm64 has a distinct exception code for single-step, so we can use this
to detect when an unexpected SS trap is encountered, or when an expected
one is not. See db_stop_at_pc().

Reviewed by:	markj, jhb
MFC after:	5 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28942
2021-03-01 10:04:23 -04:00
Mitchell Horne
bd0b7cbf5a arm64: update kdb_thrctx->pcb_lr with BKPT_SKIP
This value should be kept in sync with updates to kdb_frame->tf_elr,
since it is queried by PC_REGS() in several places.

Reviewed by:	markj, jhb
MFC after:	5 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28943
2021-03-01 10:04:22 -04:00
Mitchell Horne
874635e381 arm64: fix hardware single-stepping from EL1
The main issue is that debug exceptions must to be disabled for the
entire duration that SS bit in MDSCR_EL1 is set. Otherwise, a
single-step exception will be generated immediately. This can occur
before returning from the debugger (when MDSCR is written to) or before
re-entering it after the single-step (when debug exceptions are unmasked
in the exception handler).

Solve this by delaying the unmask to C code for EL1, and avoid unmasking
at all while handling debug exceptions, thus avoiding any recursive
debug traps.

Reviewed by:	markj, jhb
MFC after:	5 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28944
2021-03-01 10:04:22 -04:00
Mark Johnston
17d0f830dd arm64: Include NUMA locality info in the CPU topology
The scheduler uses this topology to try and preserve locality when
migrating threads between CPUs and when performing work stealing.
Ensure that on NUMA systems it will at least take the NUMA topology into
account.

Reviewed by:	mmel
Submitted by:	Klara, Inc.
Sponsored by:	Ampere Computing
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28579
2021-02-18 10:51:38 -05: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
D Scott Phillips
3046eb03cc gicv3_its: Don't restrict target CPUs based on SRAT
ACPI Sec 5.2.16.5 (SRAT, GIC Interrupt Translation Service (ITS)
Affinity Structure) says:

> The GIC ITS Affinity Structure provides the association between
> a GIC ITS and a proximity domain. This enables the OSPM to
> discover the memory that is closest to the ITS, and use that in
> allocating its management tables and command queue.

Previously the ITS driver was using the proximity domain to
restrict which CPUs can be targeted by an LPI. We keep that logic
just for the original dual socket ThunderX which cannot forward
LPIs between sockets.

We also use the SRAT entry for its intended purpose of attempting
to allocate ITS table structures near the ITS.

Reviewed by:	andrew
Sponsored by:	Ampere Computing LLC
Differential Revision:	https://reviews.freebsd.org/D28340
2021-02-17 13:54:51 -08:00
D Scott Phillips
c720435062 gicv3_its: Leave LPI interrupts enabled during handling
This follows the behavior on x86 where edge triggered interrupts are
not disabled when executing the handler. Because the ITS is a shared
resource, contention for the command queue lock can be substantial.

Suggested by:	gallatin
Reviewed by:	andrew
Tested by:	gallatin
Sponsored by:	Ampere Computing LLC
Differential Revision:	https://reviews.freebsd.org/D28709
2021-02-17 14:08:38 -05:00
Mitchell Horne
39df2b5682 arm64: use macros to access special register values 2021-02-17 12:09:45 -04:00
Mitchell Horne
f2583be110 arm64: extend struct db_reg to include watchpoint registers
The motivation is to provide access to these registers from userspace
via ptrace(2) requests PT_GETDBREGS and PT_SETDBREGS.

This change breaks the ABI of these particular requests, but is
justified by the fact that the intended consumers (debuggers) have not
been taught to use them yet. Making this change now enables active
upstream work on lldb to begin using this interface, and take advantage
of the hardware debugging registers available on the platform.

PR:		252860
Reported by:	Michał Górny (mgorny@gentoo.org)
Reviewed by:	andrew, markj (earlier version)
Tested by:	Michał Górny (mgorny@gentoo.org)
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28415
2021-02-17 12:05:00 -04:00
Mitchell Horne
bd012c7159 arm64: handle watchpoint exceptions from EL0
This is a prerequisite to allowing the use of hardware watchpoints for
userspace debuggers.

This is also a slight departure from the x86 behaviour, since `si_addr`
returns the data address that triggered the watchpoint, not the
address of the instruction that was executed. Otherwise, there is no
straightforward way for the application to determine which watchpoint
was triggered. Make a note of this in the siginfo(3) man page.

Reviewed by:	jhb, markj (earlier version)
Tested by:	Michał Górny (mgorny@gentoo.org)
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28561
2021-02-17 12:05:00 -04:00
Mitchell Horne
de2b942280 arm64: validate breakpoint registers
In particular, we want to disallow setting breakpoints on kernel
addresses from userspace. The control register fields are validated or
ignored as appropriate.

Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28560
2021-02-17 12:05:00 -04:00
Mark Johnston
0fc8a79672 linux: Unmap the VDSO page when unloading
linux_shared_page_init() creates an object and grabs and maps a single
page to back the VDSO.  When destroying the VDSO object, we failed to
destroy the mapping and free KVA.  Fix this.

Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28696
2021-02-16 09:40:02 -05:00
Emmanuel Vadot
3b721b4495 arm64: Add a SOC_BRCM_NS2 option
Only compile files needed for this platform if the option is enabled in the
kernel config file.
Add the option to GENERIC.

MFC after:	3 days
2021-02-10 21:15:50 +01:00
Edward Tomasz Napierala
fb8c2f743a arm64: optimize set_syscall_retval()
Microoptimize set_syscall_retval() for arm64 by predicting
the return value to be zero.  This is similar to what has
been done for other architectures

Reviewed By:	emaste, mhorne
Differential Revision: https://reviews.freebsd.org/D26991
2021-02-08 10:46:47 +00:00
Andrew Turner
13ec5a6da0 Add support for arm64 nGnRE device memory
On arm64 we can select how strongly we order device memory. Currently
we use the strongest type of non-Gathering, non-Reordering, no Early
write acknowledgement. This is equivalent to VM_MEMATTR_SO in the 32-bit
arm code.

Create a new memory type to remove the no Early write acknowledgement
option to create a memory attribute that is equivalent to the arm
VM_MEMATTR_DEVICE.

Keep the the old nGnRnE memory as what we provide for VM_MEMATTR_DEVICE
until we can test nGnRE on more hardware. A method for dynamically
switching back may be needed as at least one vendor is known to have
broken nGnRE memory.

Sponsored by:	Innovate UK
2021-02-05 12:25:56 +00:00
Ed Maste
375d797b81 Enable pvscsi and vmx in arm64 GENERIC
FreeBSD pvscsi and vmx work with VMware ESXi Arm "Fling"; provide these
in GENERIC for a convenient out-of-the-box experience.

PR:		253202
Reported by:	Vincent Milum Jr
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2021-02-04 19:21:38 -05:00
Michal Meloun
65618fdda0 arm64: Initialize VFP control register.
The RW fields in this register reset to architecturally unknown values,
so initialize these to the proper rounding and denormal mode.
MFC after:	1 week
2021-02-03 16:27:30 +01:00
Jessica Clarke
05985a7f80 arm64: Improve DDB backtrace support
The existing implementation relies on each trap handler saving a normal
stack frame record, which is a waste of time and space when we're
already saving a trapframe to the stack. It's also wrong as it currently
saves LR not ELR.

Instead of patching it up, rewrite it based on the RISC-V implementation
with inspiration from the amd64 implementation for how to handle
vectored traps to provide an improved implementation. This includes
compressing the information down to one line like other architectures
rather than the highly-verbose old form that repeats itself by printing
LR and FP in one frame only to print them as PC and SP in the next. It
also includes printing out actually useful information about the traps
that occurred, though FAR is not saved in the trapframe so we cannot
print it (in general it can be clobbered between when the trap happened
and now), only ESR.

The AAPCS also allows the stack frame record to be located anywhere in
the frame, not just the top, so the caller's SP is not at a fixed offset
from the callee's FP like on almost all other architectures in
existence. This means there is no way to derive the caller's SP in the
unwinder, and so we have to drop that bit of (unused) state everywhere.

Reviewed by:	jhb, markj
Differential Revision:	https://reviews.freebsd.org/D28026
2021-02-01 14:15:57 +00:00
Allan Jude
f9322ff6ef Enable KERN_TLS by default in ARM64 GENERIC
Sponsored-by:	Ampere Computing
Submitted-by:	Klara, Inc.
2021-01-28 20:48:37 +00:00
Cyprien Laplace
35ebd8d33a gic_v3: add message based interrupts support
Pull Request:	https://github.com/freebsd/freebsd-src/pull/451
2021-01-25 10:08:47 +00:00
Cyprien Laplace
46ca0b903c gic_v3: Use 64-bit writes to GICD_IROUTERn
While 32-bit accesses to GICD_IROUTERn are allowed,
this is a 64-bit register.

Pull Request:	https://github.com/freebsd/freebsd-src/pull/451
2021-01-25 10:07:43 +00:00
Mateusz Guzik
64b1230c03 arm64: fix typo in file name in GENERIC-MMCCAM-NODEBUG 2021-01-22 10:16:57 +00:00
Andrew Turner
8e67b9389d Handle arm64 undefied instructions on msr exceptions
When userspace tries to access a special register that it doesn't have
access to the kernel receives an exception. On most cores this exception
has been observed to be the undefined instruction exception, however on
the Apple M1 under a QEMU based hypervisor it can be the MSR exception.

Handle this second case by also running the undefined exception handler
on these exceptions.

Sponsored by:	Innovate UK
2021-01-20 17:59:38 +00:00
Mark Johnston
3e3eb5f45f arm64, riscv: Set VM_KMEM_SIZE_SCALE to 1
This setting limits the amount of memory that can be allocated to UMA.
On systems with a direct map and ample KVA, however, there is no reason
for VM_KMEM_SIZE_SCALE to be larger than 1.  This appears to have been
inherited from the 32-bit ARM platform definitions.

Also remove VM_KMEM_SIZE_MIN, which is not needed when
VM_KMEM_SIZE_SCALE is defined to be 1.[*]

Reviewed by:	alc, kp, kib
Reported by:	alc [*]
Submitted by:	Klara, Inc.
Sponsored by:	Ampere Computing
Differential Revision:	https://reviews.freebsd.org/D28225
2021-01-19 20:34:36 -05:00
Mark Johnston
089eafaff3 arm64: Stop setting VM_BCACHE_SIZE_MAX
This setting places a (small) limit on the size of the buffer cache,
constraining UFS performance on large servers.  The setting comes from
the initial arm64 implementation and appears to be vestigal.  Remove it.

Reviewed by:	kib
Submitted by:	Klara, Inc.
Sponsored by:	Ampere Computing
Differential Revision:	https://reviews.freebsd.org/D28162
2021-01-19 20:34:35 -05:00
Robert Watson
adc96a51a5 Add a new FreeBSD/arm64 kernel configuration, GENERIC-MMCCAM-NODEBUG,
which is the same as GENERIC-MMCCAM but using a nodebug baseline.

Reviewed by:		andrew, br (earlier version), jrtc27 (earlier version)
Differential revision:	https://reviews.freebsd.org/D28091
2021-01-19 22:26:20 +00:00
John Baldwin
c6e27f5697 arm64: Clear FPU flags in the pcb in cpu_copy_thread().
New threads start off with clean FPU state instead of inheriting state
from the parent thread.

PR:		247945
Sponsored by:	Netflix
2021-01-19 11:05:48 -08:00
John Baldwin
c7f3aa34cf arm64: Trim duplicate code from cpu_fork_kthread_handler().
cpu_fork_kthread_handler() is always called after either cpu_fork() or
cpu_copy_thread().  The arm64 version was duplicating some of the work
already done by both of those functions.

Sponsored by:	Netflix
2021-01-19 11:05:41 -08:00
Michal Meloun
f635cef2a4 arm64 busdma: Fix loading of small bounced buffers.
- Don't oversize the buffer fragment. PAGE_SIZE - (curaddr & PAGE_MASK)
   may be greater than the total length of the buffer.
 - Don't use roundup2(len, alignment) to calculate the buffer fragment
   size. The length of current bounced fragment is not subject to alignment
   restriction, and next fragment should start at the page boundary.

Tested by:	bz, s199p.wa1k9r@gmail.com
2021-01-19 13:09:17 +01: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
Andrew Turner
f64329bcdc Extract the logic from pmap_kextract
This allows us to use it when we only need to check if the virtual address
is valid. For example when checking if an address in the DMAP region is
mapped.

Reviewed by:	kib, markj
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D27621
2021-01-15 19:08:01 +00:00
Emmanuel Vadot
c38fe8789a 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 20:07:19 +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
John Baldwin
074a91f746 Enable accelerated AES-XTS software crypto in GENERIC.
In particular, using GELI on a root filesystem will only use
accelerated software crypto drivers if they are available before the
root filesystem is mounted.  While these modules can be loaded from
the loader, including them in GENERIC provides a better out-of-the-box
experience for users.

Both aesni(4) and armv8crypto(4) provide accelerated implementations
of the default cipher used by GELI (AES-XTS) in addition to other
ciphers.

Reviewed by:	mhorne, allanjude, markj
Differential Revision:	https://reviews.freebsd.org/D28100
2021-01-13 13:13:01 -08:00
Andrew Turner
63c858a04d Switch the arm64 pcpu to a global register variable
This removes an unneeded instruction to move the pointer from x18 to a
temporary register.

Reviewed by:	emaste
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D26971
2021-01-13 16:36:52 +00:00
John Baldwin
c3e77ab43f arm64: Add armv8crpyto and ossl to NOTES.
Reviewed by:	mhorne
Differential Revision:	https://reviews.freebsd.org/D28099
2021-01-11 14:28:46 -08:00
John Baldwin
36a2f5b817 arm64: Don't disable options GDB in LINT.
Reviewed by:	mhorne
Differential Revision:	https://reviews.freebsd.org/D28098
2021-01-11 14:28:46 -08: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
Vladimir Kondratyev
0f0379fa55 hid: Add recently imported drivers to NOTES
Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D28060
2021-01-10 22:17:20 +03:00
mhorne
bbfa199cbc arm64: gdb(4) machine-dependent bits
Everything required for remote kernel debugging over a serial
connection. For FDT-based systems, a debug port can be specified by
setting hw.fdt.dbgport to the desired device tree node in loader.conf.
For example, hw.fdt.dbgport="uart1", or
hw.fdt.dbgport="serial@ff1a0000".

Looks good:	emaste
Tested by:	rwatson
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27727
2021-01-08 14:53:44 -04:00
mhorne
5f66d5a313 arm64: remove pcb_pc
The program counter field in the PCB is written in exactly one place,
makectx(), upon entry to the debugger. For threads other than curthread,
its value will be empty, or bogus. Rather than writing to this field in
more places, it can be removed in favor of using the value in the link
register.

To make this clearer, pcb->pcb_x[30] is renamed to pcb->pcb_lr, similar
to what already exists in struct trapframe. Also, prefer lr to x30 in
assembly, as it better conveys intention.

This improves PC_REGS() for kdb_thread != curthread. It is required for
a functional gdb(4) stub, fixing the output of `info threads`, in
particular.

The space occupied by pcb_pc is retained, for compatibility with kgdb.

Reviewed by:	markj, jhb
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27720
2021-01-08 14:53:44 -04:00
mhorne
e9bb4ce3d0 arm64: don't pass user trapframe to kdb_trap()
This effectively undoes the changes made in r321571. While useful, it is
inconsistent with how other architectures pass trapframes to kdb. This
change is also required to get a working gdb(4) stub on arm64, as
otherwise the backtrace will begin too early.

As of 088a7eef95, this information can still be obtained via
"show registers/u".

Reviewed by:	jhb (slightly earlier version)
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Pull Request:	https://reviews.freebsd.org/D27719
2021-01-08 14:53:20 -04:00
Vladimir Kondratyev
1975878673 hid: Import functions and constants required by new subsystem
This does an import of quirk stubs, debugging macros from USB code and
numerous usage constants used by dependent drivers.

Besides, this change renames some functions to get a better matching
with userland library and NetBSD/OpenBSD HID code. Namely:

- Old hid_report_size() renamed to hid_report_size_max()
- New hid_report_size() calculates size of given report rather than
  maximum size of all reports.
- hid_get_data_unsigned() renamed to hid_get_udata()
- hid_put_data_unsigned() renamed to hid_put_udata()

Compat shim functions are provided in usbhid.h to make possible compile
of legacy code unmodified after this change.

Reviewed by:	manu, hselasky
Differential revision:	https://reviews.freebsd.org/D27887
2021-01-08 02:18:42 +03: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
Ed Maste
f45f9ef051 arm64 GENERIC: sort to match amd64, to ease comparison
No functional change - only moved lines, changed whitespace, and
updated comments.

Reviewed by:	allanjude
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28001
2021-01-07 10:01:48 -05:00
Marcin Wojtas
ca71c7e3bb arm64: QorIQ: gpio: return BUS_PROBE_DEFAULT
There is no reason this driver can't return default probe value.

Submitted by: Artur Rojek <ar@semihalf.com>
Reviewed by: emaste, mmel
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D26869
2021-01-06 22:37:38 +01:00
Marcin Wojtas
39c24889b0 arm64: QorIQ: gpio: Cleanup qoriq_gpio_* helpers
Replace various hw reg bit set/clear helpers with a universal
`qoriq_gpio_set` function.

Submitted by: Artur Rojek <ar@semihalf.com>
Reviewed by: mmel
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D26868
2021-01-06 22:37:21 +01:00
Marcin Wojtas
c76c36f95c arm64: QorIQ: gpio: Style cleanups
Make the code more conformant to style(9) and improve the general
readability.

This patch does not alter the driver logic.

Submitted by: Artur Rojek <ar@semihalf.com>
Reviewed by: mmel
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D26867
2021-01-06 22:37:13 +01:00
Emmanuel Vadot
cb00fc7c4d arm64: genet: Add bcm2711-genet-v5 compatible
Later dtb from the RPI Foundation removed the brcm,genet-v5 compatible
for some unknown reason, add brcm,bcm2711-genet-v5 to the list of compatible
device for if_genet
2021-01-05 20:50:43 +01:00
Emmanuel Vadot
e5df46055a arm64: rockchip: rk_clk_mux: Tell the clk framework if we didn't change the clock
Otherwise the clk framework will not pass the freq change request to the clock
parents.
Fix d03fd8ede2
Reported by:	br
2021-01-04 17:30:00 +01:00
Oleksandr Tymoshenko
d03fd8ede2 rockchip: add audio-related clocks to the CRU driver
- Add I2S and CODEC clocks to CRU driver
- Add support for gate selection to frac clock
- Add setfreq support to mux clock

Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D27831
2021-01-03 16:50:42 -08:00
Ryan Libby
82661227ed arm64: fix mask in atomic_testand{set,clear}_64
These macros generate both the 32- and 64-bit ops, but the mask was hard
coded for 32-bit ops, causing the 64-bit ops always to affect only the
low 32 bits.

PR:		252324
Reported by:	gbe, mmel
Reviewed by:	markj, mmel
Tested by:	mmel, rwatson
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D27886
2021-01-02 12:13:25 -08:00
Michal Meloun
28482babd0 arm64: Use new arm_kernel_boothdr script for generating booti images. 2020-12-30 13:56:11 +01:00
Michal Meloun
509a006205 Tegra210: Connect to GENERIC kernel. 2020-12-30 11:01:47 +01:00
Michal Meloun
30ae416898 Tegra210: Add lost-in-merge fixes:
- misplaced '#ifdef notyet' in max77620.c
 - misnamed 'xusb_gate' clock in tegra210_clk_per.c
2020-12-30 10:53:41 +01:00
Michal Meloun
e903478919 ARM64: Port FreeBSD to Nvidia Jetson TX1 and Nano.
Add support for the Tergra210 SoC and its companion PMIC MAX77620.
2020-12-28 14:12:41 +01:00
Andrew Turner
6270ee0b67 Use the base address for early arm64 page tables
Use the kernel physical base rather than the ttbr0 base when building
the kernel identity map. The latter is correct with current assumptions
but may not always be the case.

Sponsored by:	Innovate UK
2020-12-26 19:04:57 +00:00
Andrew Turner
449ebf135b Move the literal pool to the end of asm functions
This keeps the data at the end of a function, near to where it's used.
Sponsored by:	Innovate UK
2020-12-23 13:57:25 +00:00
Andrew Turner
edb48ff6e7 Mark all arm64 locore functions with ENTRY/LENTRY
It is useful to know where these are within the code, and will be
needed by later changes.

Sponsored by:	Innovate UK
2020-12-23 13:57:25 +00:00
Andrew Turner
6f8866af34 Add LENTRY and LEND to arm64
These allow us to mark local asm functions as a function

Sponsored by:	Innovate UK
2020-12-23 13:57:25 +00:00
Andrew Turner
42f71007d5 Use the new PAGE_SIZE_4K in the GICv3 driver
Stop assuming PAGE_SIZE is 4k in the GICv3 ITS driver. We could use
a 16k or 64k page in the future.

Sponsored by:	Innovate UK
2020-12-23 13:10:26 +00:00
Andrew Turner
3413a8cd81 Rename the arm64 4k PAGE_* macros
These now have a _4K suffix to allow us to be explicit when we mean
to use a 4k page rather than assuming PAGE_SIZE is 4k.

Sponsored by:	Innovate UK
2020-12-23 13:10:26 +00:00
Andrew Turner
166ceb6fd1 More the arm64 early page tables and stack to .bss
This removes 806k from the kernel ELF file that is only needed while
the kernel is running, not in the static file.

Sponsored by:	Innovate UK
2020-12-23 13:10:23 +00:00
Andrew Turner
659f1a6aad Improve address generation in the early arm64 boot
The adr instruction allows for an address of +-1M from the instruction.
If we replace these with an adrp and an add instruction we can generate
an address +-4G. The adrp will get an address of the 4k page the label
is within, and the add uses the :lo12: prefix to add just the low bits
to this address.

This will allow us to move things around with fewer issues than if we
needed to keep them within the +-1MB range.

Sponsored by:	Innovate UK
2020-12-23 07:54:59 +00:00