Commit Graph

1606 Commits

Author SHA1 Message Date
Olivier Houchard
2734050154 arm64: Handle 32bits breakpoint exception.
A different exception is raised when we hit a 32bits breakpoint, rather than
a 64bits one, so handle those as well when COMPAT_FREEBSD32 is defined.
This should fix SIGBUS at least when using breakpoints with thumb2 code.

PR:		256468
MFC After:	1 week
2021-09-21 15:52:42 +02:00
Andrew Turner
5a619ca07a Fix the arm64 L2_BLOCK_MASK definition
It was missing the top 16 bits.

Sponsored by:	The FreeBSD Foundation
2021-09-21 13:47:34 +00:00
Emmanuel Vadot
78bf40e10c arm: rockchip: rk3288: Use the macros that already exists in rk_cru.h 2021-09-15 20:10:42 +02:00
Emmanuel Vadot
548a706608 arm64: rockchip: rk3328: Add watchdog clock
The watchdog clock is controlled by the secure world but we need a clock
to sastify the driver so add a fixed clock for it.

Reported by:   avg
2021-09-15 19:09:56 +02:00
Emmanuel Vadot
cc2f9bbbad arm64: rockchip: rk3328: Finish implementing clocks
This finish (almost) the clocks implementations for the RK3328 SoC.
The clocks are now correctly implemented respecting the clock hiearchy.
The missing clocks are mostly the DDR clocks, implementing those is only
useful for debugging as we will never set them in the kernel.
The ARMCLK still needs to be rewritten so it looks closer to how the
hardware is done.

Tested-on: Rock64
2021-09-15 18:43:10 +02:00
Emmanuel Vadot
deff1fb3dc arm64: rockchip: clk: Add MUXRAW macros
Some clocks in the RK3328 SoC (and possibly others) have registers not in
the CLKSEL_CON range. Add a macros for muxes which lives not in the range
of CLKSEL_CON which just takes a raw offset.
2021-09-15 18:43:07 +02:00
Emmanuel Vadot
731e418bd7 arm64: rockchip: clk_mux: Add support for mux in GRF type clock
Some clocks have their mux register in the GRF and not in the CRU.
Add support for that in the rk_clk_mux clock type.
2021-09-15 18:43:04 +02:00
John Baldwin
857dc1c0ec arm64: Pass the right label to END() for handle_empty_exception.
GNU as reported an error for the argument to .size not being a constant.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D31950
2021-09-15 09:03:18 -07:00
John Baldwin
8753039a8f arm64: Fix a logic bug in is_load_instr().
Logical and ('&&') was used to join two conditions instead of logical
or ('||') causing some store instructions to not be recognized.

Reported by:	GCC 9 -Wparentheses

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D31949
2021-09-15 09:03:18 -07:00
Andrew Turner
1896a00943 Use a 64 bit read to access GICR_TYPER
The GICv3 ITS only needs to implement 32 bit access to the GICR_TYPER
when the CPU implements AArch32. As this may not always be the case
use a 64 bit read when checking if the ITS is enabled on the CPU.

PR:		258217
Reported by:	Olivier Delande <olivier.delande@provenrun.com>
Sponsored by:	The FreeBSD Foundation
2021-09-15 09:13:41 +00:00
Andrew Turner
90f33f34ba Remove a bogus assertion from the gic drivers
When setting a message based interrupt range we set the base and count.
In an earlier the count was implemented as an end value, however the
asserts used to check this value was correct were incorrectly left in.

Reported by:	emaste
Sponsored by:	The FreeBSD Foundation
2021-09-14 19:06:25 +00:00
Andrew Turner
fd860ace3b Remove the DN flag from the initial arm64 fpcr value
This fixes software that expects NaN values to propagate.

Sponsored by:	The FreeBSD Foundation
2021-09-14 12:52:48 +00:00
Andrew Turner
e4d89a633e Add support for gicv2m as a child of gicv3
On some systems, e.g. Parallels set to host a Linux VM under an M1 Mac,
there is a GICv2m as a child of the GICv3. We previously assumed the
GICv2m was always a child of a GICv2. Fix this by adding the needed
support to the GICv3 driver.

PR:		258136
Reported by:	trasz
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31768
2021-09-14 08:24:52 +01:00
Andrew Turner
b029ef7fe6 Restrict spsr updated in the arm64 set_regs*
When using ptrace(2) on arm64 to set registers in a 32-bit program we
need to take care to only set some of the fields. Follow the existing
arm64 path and only let the user set the flags fields. This is also the
case in the arm kernel so fixes a change in behaviour between the two.

While here update set_regs to only set spsr and elr once.

Sponsored by:	The FreeBSD Foundation
2021-09-13 16:32:50 +01:00
Hubert Mazur
ee1b7811a3 e6000sw: Build the driver as a kernel module
Fix detach routine.
Driver was tested on EspressoBin.
Remove it from GENERIC, since now it can be loaded automatically.

Obtained from:		Semihalf
Reviewed by:		manu
Differential revision:	https://reviews.freebsd.org/D31580
2021-09-13 11:42:16 +02:00
Bartlomiej Grzesik
df9c0e88e1 qoriq_dw_pci: Fix typo in link status checking code
On some DesignWare PCIe controllers accessing config registers of slots
whose link is down triggers a SError. Because of that we need to check the
link status before any acceses config space.
Due to a typo link was always reported up.
This fixes a SError that occured during boot on LS1028A-RDB.

Obtained from:		Semihalf
Reviewed by:		wma
Differential revision:	https://reviews.freebsd.org/D31509
2021-08-31 06:22:33 +02:00
Andrew Turner
b792434150 Create sys/reg.h for the common code previously in machine/reg.h
Move the common kernel function signatures from machine/reg.h to a new
sys/reg.h. This is in preperation for adding PT_GETREGSET to ptrace(2).

Reviewed by:	imp, markj
Sponsored by:	DARPA, AFRL (original work)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19830
2021-08-30 12:50:53 +01:00
Mateusz Guzik
d0bc029b4a arm64: retire bcopy
Unused since ba96f37758 ("Use __builtin for various mem* and b* (e.g. bzero)
routines.")

Reviewed by:	andrew
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31651
2021-08-24 11:24:07 +00:00
Mateusz Guzik
d47afcb203 arm64: retire bzero
Reviewed by:	andrew
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31644
2021-08-23 15:22:44 +02:00
Andrew Turner
17b6ee9613 Enable arm64 SError exceptions in the kernel
These are needed to signal to the kernel when a Reliability,
Availability, and Serviceability (RAS) exception has triggered.

Reviewed by:	mhorne
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31477
2021-08-12 08:53:06 +00:00
Andrew Turner
a7fcda1b8c Add the Apple arm64 implementer ID
Sponsored by:	The FreeBSD Foundation
2021-08-12 08:53:06 +00:00
Andrew Turner
29b25b13c7 Sort the arm64 cpu_implementers list by name
We perform a linear search, so make it easier to add new entries in the
correct place.

Sponsored by:	The FreeBSD Foundation
2021-08-12 08:53:06 +00:00
Dmitry Chagin
b356030e67 linux(4): Regen for clone3 system call.
MFC after:		2 weeks
2021-08-12 11:50:22 +03:00
Dmitry Chagin
17913b0b6b linux(4): Implement clone3 system call.
clone3 system call is used by glibc-2.34.

Differential revision:	https://reviews.freebsd.org/D31475
MFC after:		2 weeks
2021-08-12 11:49:36 +03:00
Dmitry Chagin
0a4b664ae8 linux(4): Add struct clone_args for future clone3 system call.
In preparation for clone3 system call add struct clone_args and use it in
clone implementation.
Move all of clone related bits to the newly created linux_fork.h header.

Differential revision:	https://reviews.freebsd.org/D31474
MFC after:		2 weeks
2021-08-12 11:49:01 +03:00
Dmitry Chagin
0c08f34f4d linux(4): Regen for clone syscall.
MFC after:		2 weeks
2021-08-12 11:47:31 +03:00
Dmitry Chagin
f1c450492f linux(4): Change clone syscall definition to match Linux actual one.
Differential revision:	https://reviews.freebsd.org/D31473
MFC after:		2 weeks
2021-08-12 11:46:36 +03:00
Dmitry Chagin
fc37be2460 linux(4): Plug in aarch64 fcntl flags.
Fixes opendir() libc function.

Differential Revision:	https://reviews.freebsd.org/D31357
MFC after:		2 weeks
2021-08-12 11:42:50 +03:00
Dmitry Chagin
bee191e46f linux(4): Regen for faccessat2 system call.
MFC after:		2 weeks
2021-08-12 11:41:35 +03:00
Dmitry Chagin
13d79be995 linux(4): Implement faccessat2 system call.
It's used by bash on arm64 with glibc-2.32.

Reviewed by:		trasz
Differential Revision:	https://reviews.freebsd.org/D31345
MFC after:		2 weeks
2021-08-12 11:40:42 +03:00
Andrew Turner
6b22840ed0 Read the arm64 midr register earlier
We use the midr_el1 register to decode which CPU type we are booting
from. Read it on the secondary CPUs before waiting for the boot CPU
to release us as it will need to use it before the release.

Sponsored by:	The FreeBSD Foundation
2021-08-11 15:15:55 +00:00
Andrew Turner
267d55fa2a Remove an unused arm64 panic string
This was added early in the development of the arm64 port when
cpu_switch was just a stub. It should have been removed when cpu_switch
was implemented, however this didn't seem to be the case, and the '%p'
was added.

As this hasn't been needed in 7 years we can remove it.

Sponsored by:	The FreeBSD Foundation
2021-08-08 21:28:25 +00:00
Andrew Turner
337eb2ab95 Add macros for the arm64 daifset/daifclr flags
Sponsored by:	The FreeBSD Foundation
2021-08-08 21:01:55 +00:00
Andrew Turner
1791a628a1 Clean up the arm64 fork_trampoline
When exiting to userspace the code is similar to the restore_registers
macro in exception.S. Rework it to remove most of the non-style
differences.

Sponsored by:	The FreeBSD Foundation
2021-08-08 21:00:32 +00:00
Ed Maste
9feff969a0 Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights
These ones were unambiguous cases where the Foundation was the only
listed copyright holder (in the associated license block).

Sponsored by:	The FreeBSD Foundation
2021-08-08 10:42:24 -04:00
Dmitry Salychev
d178b1f878 Parse named nodes from IORT ACPI on arm64
Add the ability to map named components from IORT to their
SMMU or ITS node in order to setup interrupts.
It is now possible to find a node by its name (substring) and
resource ID similar to PCI nodes.
This is needed by work on a driver for NXP's Second Generation
Data Path Acceleration Architecture (DPAA2).

Reviewed by:	andrew
MFC after:	2 weeks
Differential Revision::	https://reviews.freebsd.org/D31267
2021-08-07 17:30:38 +00:00
Emmanuel Vadot
589951c76a arm64: conf: std.broadcom: Add dwcotg and smsc
Add the dwcotg and smsc usb to ethernet driver to std.broadcom.
Those are used in RPI3

PR:   257593
2021-08-05 13:16:23 +02:00
Andrew Turner
dcfd605871 Add more arm64 external abort sources
These will be used when we support the Arm Reliability, Availability,
and Serviceability extension.

Sponsored by:	The FreeBSD Foundation
2021-08-04 18:50:42 +00:00
Andrew Turner
8b3bd5a2b5 Only store the arm64 ID registers in the cpu_desc
There is no need to store a pointer to the CPU implementer and part
strings. Switch to load them directly into the sbuf used to print them
on boot.

While here print the machine ID register when we fail to determine the
implementer or part we are booting on.

Reviewed by:	markj, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31346
2021-08-03 01:42:40 +00:00
Andrew Turner
1a78f44cd2 Move setting arm64 HWCAP values to the ID tables
The HWCAPS values are based on the ID registers. Move setting these
to the existing ID register parsing code.

Previously we would need to handle all possible ID field values where
a HWCAP is set, however as most ID fields follow a scheme where when
the field increments it will only add new features meaning we only
need to check if the field is greater than when the HWCAP feature
was added.

While here stop setting HWCAP value that need kernel support, but this
support is missing.

Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31201
2021-08-03 01:42:39 +00:00
Konstantin Belousov
041b7317f7 Add pmap_vm_page_alloc_check()
which is the place to put MD asserts about allocated pages.

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

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D31121
2021-07-31 16:53:42 +03:00
Mark Johnston
a90d053b84 Simplify kernel sanitizer interceptors
KASAN and KCSAN implement interceptors for various primitive operations
that are not instrumented by the compiler.  KMSAN requires them as well.
Rather than adding new cases for each sanitizer which requires
interceptors, implement the following protocol:
- When interceptor definitions are required, define
  SAN_NEEDS_INTERCEPTORS and SANITIZER_INTERCEPTOR_PREFIX.
- In headers that declare functions which need to be intercepted by a
  sanitizer runtime, use SANITIZER_INTERCEPTOR_PREFIX to provide
  declarations.
- When SAN_RUNTIME is defined, do not redefine the names of intercepted
  functions.  This is typically the case in files which implement
  sanitizer runtimes but is also needed in, for example, files which
  define ifunc selectors for intercepted operations.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2021-07-29 21:13:32 -04:00
Andrew Turner
2d6d5f88d1 Add missing arm64 ID registers
These may contain values we export to userpsace.

Sponsored by:	The FreeBSD Foundation
2021-07-28 19:01:30 +00:00
Andrew Turner
c3f2fcf5b9 Sort the arm64 ID_AA64* user registers
Sponsored by:	The FreeBSD Foundation
2021-07-28 19:01:30 +00:00
Dmitry Chagin
f337940144 linux(4): Fix gcc buld.
gcc failed as it didn't inlined the builtins and generates calls to
the libgcc, ld can't find libgcc as cross-toolchain libgcc is not installed.
To avoid this add internal vDSO ffs functions without optimized builtins.

Reported by:		jhb
MFC after:		2 weeks
2021-07-29 09:52:33 +03:00
Andrew Turner
10f6680faa Add macros for arm64 special reg op and CR values
Use these to simplify the definition of the user_regs array.

Reviewed by:	imp, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31333
2021-07-28 01:34:21 +00:00
Andrew Turner
2531f067ea Teach the arm64 kernel to identify the Arm AEM
The Arm Architecture Envelope Model is a simulator that models the
architecture rather than any specific implementation. Add its part ID
macro and add it to the list of Arm CPUs we can decode.

Sponsored by:	The FreeBSD Foundation
2021-07-27 19:33:21 +00:00
Edward Tomasz Napierala
30c6d98219 linux: implement sigaltstack(2) on arm64
... by making it machine-independent.

Reviewed By:	dchagin
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D31286
2021-07-27 13:34:49 +00:00
Edward Tomasz Napierala
ccc510b463 linux: implement signal delivery on arm64
Note that this still uses FreeBSD-style sigframe;
this will be addressed later.

Reviewed By:	dchagin
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D31258
2021-07-25 06:22:57 +00:00
Peter Grehan
bbe80bff7c arm64: HWCAP/HWCAP2 aux args support for 32-bit ARM binaries.
This fixes build/run of golang under COMPAT32 emulation.

PR:	256897
Reviewed by:	andrew, mmel, manu, jhb, cognet, Robert Clausecker
Tested by:	brd, andrew, Robert Clausecker
MFC after:	3 weeks
Relnotes:	yes
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31175
2021-07-25 19:39:32 +10:00