Commit Graph

1016 Commits

Author SHA1 Message Date
Mark Johnston
abe476d083 Fix a typo in r353895.
Reported by:	andrew
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2019-10-31 14:22:54 +00:00
Andrew Turner
077dcd8347 Set the userspace execute never bit on kernel mappings.
Arm64 allows us to create execute only mappings. To make sure userspace is
unable to accidentally execute kernel code set the user execute never
bit in the kernel page tables.

MFC after:	1 week
Sponsored by:	DARPA, AFRL
2019-10-30 17:32:35 +00:00
Justin Hibbits
c7bb190966 ARM64: Treat alignment faults as bus errors
Summary:
ARM64 currently treats all data abort exceptions as page faults.  This
can cause infinite loops on non-page fault faults, such as alignment faults.

Since kernel-side alignment faults should be avoided, this adds support directly
to the el0 fault handler, instead of the data_abort() handler.

Test Plan: Tested on rpi3, with a misaligned ldm test.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D22133
2019-10-30 15:30:40 +00:00
Andrew Turner
739e4482b8 Allow exceptions to be masked when in userspace
We may want to mask exceptions when in userspace. This was previously
impossible as threads are created with all exceptions unmasked and
signals expected userspace to mask any. Fix these by copying the
mask state on thread creation and allow exceptions to be masked on
signal return, as long as they don't change.

Sponsored by:	DARPA, AFRL
2019-10-30 14:05:50 +00:00
Andrew Turner
e68508e172 Allow the userspace ID register fields to be read from the kernel
To allow consistent values to be used in both the kernel and userspace
create a function for these to be read from the kernel. They use a newly
created macro with the name of the ID register to read. For now there is
redundant information in the user_regs array as it still holds the CRm and
Op2 values, however this will be fixed in a later change.

This will be used by ptrace to allow hardware breakpoints in userspace.

Sponsored by:	DARPA, AFRL
2019-10-30 13:45:40 +00:00
Andrew Turner
fc232b89ad Use a lowercase name for arm64 special registers so they don't conflict
with macros of the same name.

Sponsored by:	DARPA, AFRL
2019-10-30 12:47:00 +00:00
Andrew Turner
cb5343c278 Move the MRS instruction decode macros to armreg.h
These instructions are used to access the registers described in armreg.h,
and will be used in a future change to create a per-register identification
macro.

Sponsored by:	DARPA, AFRL
2019-10-30 12:33:36 +00:00
Andrew Turner
a5d295e2a7 Update the debug monitor handling to work after userspace has started
The debug monitor register state is now stored in a struct and updated
when required. Currently there is only a kernel state, however a
per-process state will be added in a future change.

Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D22128
2019-10-30 10:51:24 +00:00
Andrew Turner
acd6f4bee7 Use an array of handlers in the data and instruction aborts
Previously we would call data_abort on all data and instruction aborts
however this is incorrect for most abort types. Move to use an array
of function pointers to allow for more handlers to be easily added.

Reviewed by:	jhibbits
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D22170
2019-10-30 10:42:52 +00:00
Andrew Turner
d57791bec2 Add two files missed in r354170
Sponsored by:	DARPA, AFRL
2019-10-30 10:13:14 +00:00
Andrew Turner
44e446a1b3 Rename the macros to extract a single arm64 ID field.
Because of the previous naming scheme the old ID_AA64PFR0_EL1 macro
collided with a potential macro for the register of the same name. To fix
this collision rename these macros.

Sponsored by:	DARPA, AFRL
2019-10-30 10:06:57 +00:00
Emmanuel Vadot
62de73eaf1 arm64: rockchip: typec_phy: Rename timeout to retry
Declare retry in the function scope.
Rename it to retry as there is a timeout function which was
causing to code to compile.

Reported by:	jhibbits
MFC after:	1 month
X-MFC-WITH:	r354089
2019-10-29 18:36:16 +00:00
Oleksandr Tymoshenko
aea1c841f4 arm64: rk3399: add SPI driver and include it in GENERIC config
SPI driver for Rockchip's RK3399 SoC. Implements PIO mode, CS selection,
SPI mode and frequency configuration.

Reviewed by:	manu
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D22148
2019-10-25 21:38:38 +00:00
Oleksandr Tymoshenko
145bad4026 arm64: rk3399: Add clock and gate for SPI clocks
MFC after:	1 month
2019-10-25 21:21:21 +00:00
Peter Jeremy
5dae892735 Fix use of uninitialised variable.
The RK805 regs array was being allocated before it's required size was
known, causing the driver to use memory it didn't own.  That memory
was subsequently allocated and used elsewhere causing later fatal data
aborts in rk805_map().

Whilst I'm here, add a sanity check to catch unsupported PMICs (this
shouldn't ever get hit because the probe should have failed).

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	Google
2019-10-25 19:38:02 +00:00
Emmanuel Vadot
ecd9fdeb46 arm64: rockchip: Add RK3399 TypeC phy driver
This is a driver for the USB3 PHY present in the RK3399.
While the phy support DP (Display Port) the driver doesn't has we have
no driver to test this with for now.
All the lane and pll configuration is just magic values from rockchip.
While the manual have some info on those registers it's really hard to
understand how to calculate those values (if there is a way).

MFC after:	1 month
2019-10-25 18:10:02 +00:00
Emmanuel Vadot
7d888a5b2b arm64: rockchip: Add rk_dwc3 driver
This is a simplebus like driver that attaches the dwc3 child node and
enable the clocks needed for the module.

MFC after:	1 month
2019-10-25 18:08:59 +00:00
Emmanuel Vadot
f5be484b45 arm64: rk3399: Add clock and gate for usb3 clocks
MFC after:	1 month
2019-10-25 18:08:25 +00:00
Andrew Turner
6c1633e18a Remove the arm4 ID register masks, they are not needed after r353641.
Sponsored by:	DARPA, AFRL
2019-10-25 14:46:09 +00:00
Andrew Turner
a3b4443c72 Make special register names lowercase so they don't conflict with future
ID register macros.

MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2019-10-25 14:30:27 +00:00
Ed Maste
4ad0475f03 arm64: enable options NUMA in GENERIC
As with amd64 NUMA is required for reasonable operation on big-iron
arm64 systems and is expected to have no significant impact on small
systems.  Enable it now for wider testing in advance of FreeBSD 13.0.

You can use the 'vm.ndomains' sysctl to see if multiple domains are in
use - for example (from Cavium/Marvell ThunderX2):

# sysctl vm.ndomains
vm.ndomains: 2

No objection:	manu
Sponsored by:	The FreeBSD Foundation
2019-10-23 19:35:26 +00:00
Andrew Turner
9d0a6b83ca Stop enabling interrupts when reentering kdb on arm64
When we raise a data abort from the kernel we need to enable interrupts,
however we shouldn't be doing this when in the kernel debugger. In this
case interrupts can lead to a further panic as they don't expect to be
run from such a context.

MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2019-10-23 13:21:15 +00:00
Mark Johnston
86a994d653 Apply r353893 to arm64.
Reported by:	Jenkins (hardware CI lab)
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2019-10-22 17:22:10 +00:00
Michal Meloun
4b84206b7f Update Armada 8k drivers to cover newly imported DT and latest changes
in simple multifunction driver.
- follow interrupt changes in DT. Split old ICU driver to function oriented
  parts and add drivers for newly defined parts (system error interrupts).
- Many drivers are children of simple multifunction driver. But after r349596
  simple MF driver doesn't longer exports memory resources, and all children
  must use syscon interface to access their registers. Adapt affected
  drivers to this fact.

MFC after:	3 weeks
2019-10-20 10:48:27 +00:00
Yuri Pankov
a161fba992 linux: futex_mtx should follow futex_list
Move futex_mtx to linux_common.ko for amd64 and aarch64 along
with respective list/mutex init/destroy.

PR:		240989
Reported by:	Alex S <iwtcex@gmail.com>
2019-10-18 12:25:33 +00:00
Conrad Meyer
7790c8c199 Split out a more generic debugnet(4) from netdump(4)
Debugnet is a simplistic and specialized panic- or debug-time reliable
datagram transport.  It can drive a single connection at a time and is
currently unidirectional (debug/panic machine transmit to remote server
only).

It is mostly a verbatim code lift from netdump(4).  Netdump(4) remains
the only consumer (until the rest of this patch series lands).

The INET-specific logic has been extracted somewhat more thoroughly than
previously in netdump(4), into debugnet_inet.c.  UDP-layer logic and up, as
much as possible as is protocol-independent, remains in debugnet.c.  The
separation is not perfect and future improvement is welcome.  Supporting
INET6 is a long-term goal.

Much of the diff is "gratuitous" renaming from 'netdump_' or 'nd_' to
'debugnet_' or 'dn_' -- sorry.  I thought keeping the netdump name on the
generic module would be more confusing than the refactoring.

The only functional change here is the mbuf allocation / tracking.  Instead
of initiating solely on netdump-configured interface(s) at dumpon(8)
configuration time, we watch for any debugnet-enabled NIC for link
activation and query it for mbuf parameters at that time.  If they exceed
the existing high-water mark allocation, we re-allocate and track the new
high-water mark.  Otherwise, we leave the pre-panic mbuf allocation alone.
In a future patch in this series, this will allow initiating netdump from
panic ddb(4) without pre-panic configuration.

No other functional change intended.

Reviewed by:	markj (earlier version)
Some discussion with:	emaste, jhb
Objection from:	marius
Differential Revision:	https://reviews.freebsd.org/D21421
2019-10-17 16:23:03 +00:00
Mark Johnston
01cef4caa7 Remove page locking from pmap_mincore().
After r352110 the page lock no longer protects a page's identity, so
there is no purpose in locking the page in pmap_mincore().  Instead,
if vm.mincore_mapped is set to the non-default value of 0, re-lookup
the page after acquiring its object lock, which holds the page's
identity stable.

The change removes the last callers of vm_page_pa_tryrelock(), so
remove it.

Reviewed by:	kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21823
2019-10-16 22:03:27 +00:00
Andrew Turner
e8709d7d42 Use tables to store the information to decode the arm64 ID registers.
Arm updates these with each new architecture revision. To help keep them
updated use a collection of tables to hold the needed information to
decode these registers.

Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D22020
2019-10-16 13:30:28 +00:00
Jeff Roberson
638f867814 (6/6) Convert pmap to expect busy in write related operations now that all
callers hold it.

This simplifies pmap code and removes a dependency on the object lock.

Reviewed by:    kib, markj
Tested by:      pho
Sponsored by:   Netflix, Intel
Differential Revision:	https://reviews.freebsd.org/D21596
2019-10-15 03:51:46 +00:00
Jeff Roberson
205be21d99 (3/6) Add a shared object busy synchronization mechanism that blocks new page
busy acquires while held.

This allows code that would need to acquire and release a very large number
of page busy locks to use the old mechanism where busy is only checked and
not held.  This comes at the cost of false positives but never false
negatives which the single consumer, vm_fault_soft_fast(), handles.

Reviewed by:    kib
Tested by:      pho
Sponsored by:   Netflix, Intel
Differential Revision:	https://reviews.freebsd.org/D21592
2019-10-15 03:41:36 +00:00
Emmanuel Vadot
ce607eeb9d arm64: Add Synopsys DWC3 driver
This add a driver for the Synopsys DWC3 driver found on multiple SoCs.
It only supports host mode for now.

MFC after:	1 month
2019-10-14 22:27:33 +00:00
Emmanuel Vadot
26b0cd3a95 arm64: allwinner: Add aw_dwc3 driver
This is a simplebus like driver that just deal with clocks and resets
and attach the dwc3 child node.

MFC after:	1 month
2019-10-14 22:22:19 +00:00
Emmanuel Vadot
6c4464cb74 arm64: allwinner: Add Allwinner H6 Support
This adds support for H6 SoC.
Add a CCU driver for H6 that support all PLLs and most of the clocks
that we are intersted in for now (i2c, mmc, usb, etc ...)

MFC after:	1 month
2019-10-14 21:53:53 +00:00
Andrew Turner
f4d43d7928 Sort the id_aa64*_fields arrays to be in alphanumerical order.
Sponsored by:	DARPA, AFRL
2019-10-14 09:29:56 +00:00
Justin Hibbits
26517dcf60 gcore: Add aarch64 32-bit core support
Summary: Add trivial 32-bit arm cores on aarch64 support for gcore.  This
doesn't handle fpregs.

Reviewed by:	#arm, andrew
Sponsored by:	Juniper Networks, Inc
Differential Revision:	https://reviews.freebsd.org/D21947
2019-10-11 14:15:50 +00:00
Alan Cox
bc285d6a8f Eliminate an unused declaration. The variable in question is only defined
and used on sparc64.

MFC after:	1 week
2019-10-07 04:22:03 +00:00
Alan Cox
e227f09282 Eliminate a redundant bzero(). The l0 page table page was already zeroed
by efi_1t1_page().

MFC after:	1 week
2019-10-07 03:37:28 +00:00
Emmanuel Vadot
c36e2d14ac arm64: rockchip: usb2phy: Add set/get mode
We only support host mode so those functions are just added so
we won't panic when generic-{e,o}hci will set the phy to host mode.

MFC after:	1 month
X-MFC-With:	r353062
2019-10-05 17:36:33 +00:00
Alan Cox
f4ddd49973 The implementation of arm64_tlb_flushID_SE() was removed from cpufunc_asm.S
in r313347.  Eliminate its declaration from this file.

MFC after:	1 week
2019-10-04 03:55:53 +00:00
John Baldwin
b1e0d0db25 Remove aw_ehci from NOTES to fix LINT kernel builds after r353063.
Reported by:	Jenkins
2019-10-03 21:37:01 +00:00
Emmanuel Vadot
29ee738052 allwinner: Remove a10_ehci driver
We have generic-ehci since r353062 so use it.

MFC after:	1 month
X-MFC-With:	r353062
2019-10-03 18:58:15 +00:00
Emmanuel Vadot
361a394828 arm64: rockchip: rk805: Switch to iicdev_{readfrom,writeto}
This simpify the code a bit.
2019-10-01 18:30:06 +00:00
Alan Cox
ff7a11a2c7 In short, pmap_enter_quick_locked("user space", ..., VM_PROT_READ) doesn't
work.  More precisely, it doesn't set ATTR_AP(ATTR_AP_USER) in the page
table entry, so any attempt to read from the mapped page by user space
generates a page fault.  This problem has gone unnoticed because the page
fault handler, vm_fault(), will ultimately call pmap_enter(), which
replaces the non-working page table entry with one that has
ATTR_AP(ATTR_AP_USER) set.

This change reduces the number of page faults during a "buildworld" by
about 19.4%.

Reviewed by:	andrew, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D21841
2019-10-01 15:33:47 +00:00
Emmanuel Vadot
6e5eac8cc0 arm64: rockchip: rk_clk_pll: Check mode on recalc
If the pll is in slow or deep slow mode return the correct frequency.
2019-09-30 15:01:09 +00:00
Emmanuel Vadot
d46c04051d arm64: rockchip: correct reset value
If bit is 0 the reset is not asserted.
Also register our self as a reset provider, this was commented
in r352850

Reported by:	mmel
2019-09-30 15:00:22 +00:00
Emmanuel Vadot
c3e25952b2 arm64: rockchip: Add usb2phy driver
This driver is for the usb phy present on rockchip SoC.
It only support RK3399 and host mode for now.
The driver expose the usb clock needed by the usb controller.
2019-09-28 22:25:21 +00:00
Emmanuel Vadot
2a5509bf25 arm64: rockchip: Fix map_gpio
The map_gpio function wasn't correct, the first element is the pin
and not the phandle.
2019-09-28 22:21:16 +00:00
Emmanuel Vadot
78a2a6b613 arm64: rockchip: Implement resets
Module resets where not implemented when rockchip clocks were commited.
Implement them.
Since all resets registers are contiguous a driver only need to give
the start offset and the number of resets. This avoid to have to declare
every resets.
2019-09-28 22:19:52 +00:00
Emmanuel Vadot
4b1d162d96 arm64: rockchip: rk3399: Add usb2 clocks 2019-09-28 22:17:26 +00:00
Alan Cox
0432618600 Eliminate redundant calls to critical_enter() and critical_exit() from
pmap_update_entry().  It suffices that interrupts are blocked.

Reviewed by:	andrew, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D21753
2019-09-28 17:16:03 +00:00