Commit Graph

812 Commits

Author SHA1 Message Date
Andrew Turner
5bb9cd6123 Fix the ID_AA64ISAR0_EL1 dot product field shift.
It's 44 in the documentation, use this correct value.

MFC after:	3 days
2018-10-22 15:06:14 +00:00
Andrew Turner
71374d5d99 Correctly set the DAIF bits in new threads
We should only unmask interrupts when creating a new thread and leave the
other exceptions in teh same state as before creating the thread.

Reported by:	jhibbits
Reviewed by:	jhibbits
MFC after:	1 month
Sponsored by:	https://reviews.freebsd.org/D17497
2018-10-22 14:58:59 +00:00
Michael Tuexen
6b45121a6d Address the warning regarding duplicate option 'GEOM_PART_GPT' when
configuring kernels for i386, amd64, and arm64.
The 'GEOM_PART_GPT' option was added to the DEFAULTS configuration
in r337967.

Approved by:		re (kib@)
Reviewed by:		ler@
Differential Revision:	https://reviews.freebsd.org/D17458
Sponsored by:		Netflix, Inc.
2018-10-07 15:54:13 +00:00
Andrew Turner
8696dcdacf Add kernel ifunc support on arm64.
Tested with ifunc resolvers in the kernel and module with calls from
kernel to kernel, module to kernel, and module to module.

Reviewed by:	kib (previous version)
Approved by:	re (gjb)
Differential Revision:	https://reviews.freebsd.org/D17370
2018-10-01 18:51:08 +00:00
Emmanuel Vadot
47d41ab50e arm64: Raise again L3 table for early devmap
The initial raise in r336519 wasn't enough for using big resolution
(1920 x 1200 for example). Raise it again.

Reported by:	bob prohaska <fbsd@www.zefox.net>
Tested by:	bob prohaska <fbsd@www.zefox.net>
Approved by:	re (gjb@)
2018-10-01 14:27:53 +00:00
Andrew Turner
9e024036f5 Export ID_AA64ISAR{0,1}_EL1 to userland.
As with r338962 also export the instruction set attribute register. This
will allow userland to identify optional instructions the hardware
supports, for example in a future ifunc handler to decide which
implementation of a function to return.

Approved by:	re (kib)
2018-09-28 11:57:40 +00:00
Andrew Turner
e3f284eee7 Export ID_AA64PFR0_EL1 to userland
Create a user view of the ID_AA64PFR0_EL1 register with values common
across all CPUs.

Approved by:	re (kib)
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D17301
2018-09-27 13:54:09 +00:00
Andrew Turner
c7637c4d19 Move the undefined instruction handler to identcpu.c so we have access
to the registers from boot.

Approved by:	re (kib)
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D17301
2018-09-27 13:50:57 +00:00
John Baldwin
31ce875385 Clear all of the VFP state in fill_fpregs().
Zero the entire FP register set structure returned for ptrace() if a
thread hasn't used FP registers rather than leaking garbage in the
fp_sr and fp_cr fields.

Reviewed by:	emaste, andrew
Approved by:	re (rgrimes)
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D17140
2018-09-19 22:53:52 +00:00
Bjoern A. Zeeb
6bfb487b6e Set ident for GENERIC-MMCCAM to not announce itself as
GENERIC anymore.

Reviewed by:	andrew
Approved by:	re (gjb)
2018-09-14 15:46:31 +00:00
Mark Johnston
31184bcd68 Exclude the EFI framebuffer from phys_avail[] on arm64.
On the ThunderX the region occupied by the framebuffer is included in
the EFI map, so explicitly add it to the set of regions that aren't
managed by the physical memory allocator.

PR:		231064
Reviewed by:	andrew
Approved by:	re (gjb)
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17073
2018-09-08 21:52:44 +00:00
Konstantin Belousov
50cd0be78f Catch exceptions during EFI RT calls on amd64.
This appeared to be required to have EFI RT support and EFI RTC
enabled by default, because there are too many reports of faulting
calls on many different machines.  The knob is added to leave the
exceptions unhandled to allow to debug the actual bugs.

Reviewed by:	kevans
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Approved by:    re (rgrimes)
Differential revision:	https://reviews.freebsd.org/D16972
2018-09-02 21:37:05 +00:00
Konstantin Belousov
f0165b1ca6 Remove {max/min}_offset() macros, use vm_map_{max/min}() inlines.
Exposing max_offset and min_offset defines in public headers is
causing clashes with variable names, for example when building QEMU.

Based on the submission by:	royger
Reviewed by:	alc, markj (previous version)
Sponsored by:	The FreeBSD Foundation (kib)
MFC after:	1 week
Approved by:	re (marius)
Differential revision:	https://reviews.freebsd.org/D16881
2018-08-29 12:24:19 +00:00
Alan Cox
49bfa624ac Eliminate the arena parameter to kmem_free(). Implicitly this corrects an
error in the function hypercall_memfree(), where the wrong arena was being
passed to kmem_free().

Introduce a per-page flag, VPO_KMEM_EXEC, to mark physical pages that are
mapped in kmem with execute permissions.  Use this flag to determine which
arena the kmem virtual addresses are returned to.

Eliminate UMA_SLAB_KRWX.  The introduction of VPO_KMEM_EXEC makes it
redundant.

Update the nearby comment for UMA_SLAB_KERNEL.

Reviewed by:	kib, markj
Discussed with:	jeff
Approved by:	re (marius)
Differential Revision:	https://reviews.freebsd.org/D16845
2018-08-25 19:38:08 +00:00
Emmanuel Vadot
4ca213c07a a10_timer: Update the driver so we can use it on other SoC
a10_timer is currently use in UP allwinner SoC (A10 and A13).
Those don't have the generic arm timer.
The arm generic timecounter is broken in the A64 SoC, some attempts have
been made to fix the glitch but users still reported some minor ones.
Since the A64 (and all Allwinner SoC) still have this timer controller, rework
the driver so we can use it in any SoC.
Since it doesn't have the 64 bits counter on all SoC, use one of the
generic 32 bits counter as the timecounter source.

PR:	229644
2018-08-23 18:46:05 +00:00
Emmanuel Vadot
668085e884 arm64: GENERIC: Compile allwinner dtbs 2018-08-23 13:25:32 +00:00
Mark Johnston
36716fe2e6 Prepare the kernel linker to handle PC-relative ifunc relocations.
The boot-time ifunc resolver assumes that it only needs to apply
IRELATIVE relocations to PLT entries.  With an upcoming optimization,
this assumption no longer holds, so add the support required to handle
PC-relative relocations targeting GNU_IFUNC symbols.
- Provide a custom symbol lookup routine that can be used in early boot.
  The default lookup routine uses kobj, which is not functional at that
  point.
- Apply all existing relocations during boot rather than filtering
  IRELATIVE relocations.
- Ensure that we continue to apply ifunc relocations in a second pass
  when loading a kernel module.

Reviewed by:	kib
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D16749
2018-08-22 20:44:30 +00:00
Oleksandr Tymoshenko
b14b007818 Add muge(4) to the arm64 GENERIC kernel
muge(4) is the USB ethernet adapter that is used in RPi 3B+. Shipping it
in GENERIC kernel allows using NFS root out of the box instead of either
building custom kernel or modifying loader.conf for early loading of if_muge.ko

No objections:	emaste
2018-08-21 21:30:19 +00:00
Alan Cox
83a90bffd8 Eliminate kmem_malloc()'s unused arena parameter. (The arena parameter
became unused in FreeBSD 12.x as a side-effect of the NUMA-related
changes.)

Reviewed by:	kib, markj
Discussed with:	jeff, re@
Differential Revision:	https://reviews.freebsd.org/D16825
2018-08-21 16:43:46 +00:00
Alan Cox
44d0efb215 Eliminate kmem_alloc_contig()'s unused arena parameter.
Reviewed by:	hselasky, kib, markj
Discussed with:	jeff
Differential Revision:	https://reviews.freebsd.org/D16799
2018-08-20 15:57:27 +00:00
John-Mark Gurney
b060c61dfd use sbuf so that lines are printed together... As aarch64 often
has SMP enabled, lines can get intermixed with other console output
making these lines hard to read...

Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D16689
2018-08-19 21:37:51 +00:00
Emmanuel Vadot
65aee3a872 arm64: allwinner: Add aw_syscon driver to GENERIC
Recent DTS use the syscon for the emac controller.
We support this but since U-Boot is still using old DTS it was never
needed for us to add this support, but this is a problem when using upstream
recent DTS and will be when U-Boot will catch up.

While here add a new compatible to the aw_syscon driver as Linux changed it ...
2018-08-19 18:55:33 +00:00
Alan Cox
94d0f0877d Oops. r338030 didn't eliminate the unused arena argument from all of
kmem_alloc_attr()'s callers.  Correct that mistake.
2018-08-18 22:35:19 +00:00
John Baldwin
8cd385fda0 Make 'device crypto' lines more consistent.
- In configurations with a pseudo devices section, move 'device crypto'
  into that section.
- Use a consistent comment.  Note that other things common in kernel
  configs such as GELI also require 'device crypto', not just IPSEC.

Reviewed by:	rgrimes, cem, imp
Differential Revision:	https://reviews.freebsd.org/D16775
2018-08-18 20:32:08 +00:00
Warner Losh
62ee5bbd73 GPT is standard in x86 and arm64 land. Add it to DEFAULTS with the
others.

Differential Revision: https://reviews.freebsd.org/D16740
2018-08-17 14:47:21 +00:00
Andrew Turner
916e7b1252 Set the Execute Never flags in EFI device memory as required by the ARMv8
spec.

Sponsored by:	DARPA, AFRL
2018-08-15 13:19:15 +00:00
Luiz Otavio O Souza
6f207f5b47 Add support to the Marvell Xenon SDHCI controller.
Tested on Espresso.bin (37x0) and Macchiato.bin (8k) with SD cards and
eMMCs.

Obtained from:	pfSense
Sponsored by:	Rubicon Communications, LLC (Netgate)
2018-08-14 16:33:30 +00:00
Luiz Otavio O Souza
37844eaacf Use the correct PTE when changing the attribute of multiple pages.
Submitted by:	andrew (long time ago)
Sponsored by:	Rubicon Communications, LLC (Netgate)
2018-08-14 15:27:50 +00:00
Andrew Turner
398810619c Support reading from the arm64 ID registers from userspace.
Trap reads to the arm64 ID registers and write a safe value into them. This
will allow us to put more useful values in these later and have userland
check them to find what features the hardware supports.

These are currently safe defaults, but will later be populated with better
values from the hardware.

Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D16533
2018-08-14 11:00:54 +00:00
Kyle Evans
3395e43a04 efirt: Don't enter EFI context early, convert addrs to KVA instead
efi_enter here was needed because efi_runtime dereference causes a fault
outside of EFI context, due to runtime table living in runtime service
space. This may cause problems early in boot, though, so instead access it
by converting paddr to KVA for access.

While here, remove the other direct PHYS_TO_DMAP calls and the explicit DMAP
requirement from efidev.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D16591
2018-08-04 21:41:10 +00:00
Konstantin Belousov
e45b89d23d Add pmap_is_valid_memattr(9).
Discussed with:	alc
Sponsored by:	The FreeBSD Foundation, Mellanox Technologies
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D15583
2018-08-01 18:45:51 +00:00
Emmanuel Vadot
cfe196fbed nvmem: Add nvmem interface and helpers
The nvmem interface helps provider of nvmem data to expose themselves to consumer.
NVMEM is generally present on some embedded board in a form of eeprom or fuses.
The nvmem api are helpers for consumer to read/write the cell data from a provider.

Differential Revision:	https://reviews.freebsd.org/D16419
2018-07-31 19:08:24 +00:00
Andrew Turner
100a6d1905 Use int for the pcpu_ssbd argument. This is included from userland and may
not include the needed headers to get the bool definition.

Reported by:	manu
Pointy hat to:	andrew
Sponsored by:	DARPA, AFRL
2018-07-31 15:08:02 +00:00
Andrew Turner
0594061ee6 Implement the SSBD (CVE-2018-3639) workaround on arm64
This calls into the Arm Trusted Firmware to enable and disable the
workaround for the Speculative Store Bypass Disable (SSBD) issue, also
known as Spectre Variant 4.

As this may have a large performance overhead, and how exploitable SSBD is
is unknown we follow the Linux lead of allowing the administrator to select
between always on, always off, or only enabled in the kernel, with the
latter being the default.

PR:		228955
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D15819
2018-07-31 12:53:27 +00:00
Andrew Turner
9fc89b6017 Enable VIMAGE on arm64 again. A workaround for modules with static VNET
variables has been committed so these should work now.

PR:		223670
Sponsored by:	DARPA, AFRL
2018-07-30 15:57:58 +00:00
Mark Johnston
1d75e87b28 Simplify the arm64 implementation of pmap_mincore().
No functional change intended.

Reviewed by:	alc
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D16427
2018-07-25 15:58:14 +00:00
Alan Cox
1cff4e0108 Eliminate a comment that doesn't apply to this pmap implementation.
Coalesce the variable definitions for PV entry management.

MFC after:	3 weeks
2018-07-21 21:26:38 +00:00
Mark Johnston
398a929f42 Add support for pmap_enter(psind = 1) to the arm64 pmap.
See the commit log messages for r321378 and r336288 for descriptions of
this functionality.

Reviewed by:	alc
Differential Revision:	https://reviews.freebsd.org/D16303
2018-07-20 16:37:04 +00:00
Mark Johnston
7892da07b9 Initialize the L3 page's wire count correctly after a L2 entry demotion.
Reviewed by:	alc
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D16303
2018-07-20 16:31:08 +00:00
Emmanuel Vadot
b32c7d0cf5 arm64: Add vt_efifb to GENERIC
We can now have efifb being setup correctly.
Enjoy video output on some boards when you couldn't before.

Tested-On:  Pine64
Tested-On:  Pine64-LTS
Tested-On:  Pinebook
2018-07-19 21:59:52 +00:00
Emmanuel Vadot
c54fe25dcb Raise the size of L3 table for early devmap on arm64
Some driver (like efifb) needs to map more than the current L2_SIZE
Raise the size so we can map the framebuffer setup by the bootloader.

Reviewed by:	cognet
2018-07-19 21:58:06 +00:00
Mark Johnston
1f15b0e6c0 Port r324665 and r325285 to arm64.
These changes ensure that reclaim_pv_chunk() can be safely be
executed concurrently by multiple threads.

Reviewed by:	alc
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D16304
2018-07-18 17:58:17 +00:00
Warner Losh
9ecd7fdebe Remove VM_FREELIST_ISADMA. It's not needed on these architectures.
Differential Review: https://reviews.freebsd.org/D16290
2018-07-17 21:07:53 +00:00
Marcin Wojtas
ab53b2929f Enable UART support for Xilinx Ultrascale+ SoCs
Xilinx Ultrascale+ are based on Cortex-A53 and use existing
UART driver (uart_dev_cdnc). Enable it in arm64 GENERIC config.

Submitted by: Michal Stanek <mst@semihalf.com>
Obtained from: Semihalf
2018-07-13 19:54:22 +00:00
Wojciech Macek
45e8acf71c ARM64: Add ThunderX2 CPU revision macro. Add ThunderX2 name in identcpu.c
Submitted by:          Patryk Duda <pdk@semihalf.com>
Obtained from:         Semihalf
Sponsored by:          Cavium
2018-07-09 08:41:54 +00:00
Mark Johnston
ae00e67228 Reuse the PV entry when updating a mapping in pmap_enter().
This addresses a problem described in r335784, where memory
pressure forces reclamation of a PV chunk and in rare cases leads to a
use-after-free of a page table page.

Reviewed by:	alc, kib
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D16181
2018-07-08 20:38:46 +00:00
John Baldwin
a9c91abd3b Export a breakpoint() function to userland for arm and arm64.
Enable ptrace() tests using breakpoint() on these architectures.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D15191
2018-07-06 23:49:17 +00:00
Ed Maste
c38eeb8eb0 Regen arm64 linux sysent after r336043 2018-07-06 19:47:09 +00:00
Ed Maste
8b159f50a0 Fix arm64 linuxulator clone() argument order
Linux/arm64 is CLONE_BACKWARDS - i.e., "Architecture has tls passed as
the 4th argument of clone(2), not the 5th one."

The linux clone() syscall has four different permutations of argument
order, depending on architecture - see the #ifdef CONFIG_CLONE_BACKWARDS
maze in Linux's kernel/fork.c.

Sponsored by:	Turing Robotic Industries
2018-07-06 19:44:49 +00:00
Matt Macy
ab3059a8e7 Back pcpu zone with domain correct pages
- Change pcpu zone consumers to use a stride size of PAGE_SIZE.
  (defined as UMA_PCPU_ALLOC_SIZE to make future identification easier)

- Allocate page from the correct domain for a given cpu.

- Don't initialize pc_domain to non-zero value if NUMA is not defined
  There are some misconceptions surrounding this field. It is the
  _VM_ NUMA domain and should only ever correspond to valid domain
  values as understood by the VM.

The former slab size of sizeof(struct pcpu) was somewhat arbitrary.
The new value is PAGE_SIZE because that's the smallest granularity
which the VM can allocate a slab for a given domain. If you have
fewer than PAGE_SIZE/8 counters on your system there will be some
memory wasted, but this is obviously something where you want the
cache line to be coming from the correct domain.

Reviewed by: jeff
Sponsored by: Limelight Networks
Differential Revision:  https://reviews.freebsd.org/D15933
2018-07-06 02:06:03 +00:00
Ed Maste
d01c382e91 Add stub arm64 linuxulator VDSO ldscript
This needs to be revisited with the VDSO implementation, but is
sufficient to allow the linux64 module to build on arm64 for testing
and development.

Sponsored by:	Turing Robotic Industries
2018-06-28 20:36:21 +00:00
Andrew Turner
8e5d76e654 Make cpu_set_syscall_retval common between the existing FreeBSD ABI and
the Linuxulator. We need to translate error values onto Linux errno values
and return them to userspace when a syscall fails. We also need to preserve
x1 as all registers are preserved other than the return value.

Reviewed by:	emaste
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D16008
2018-06-25 22:36:25 +00:00
Ed Maste
3911ee2c92 Initial arm64 linuxulator linux_sysvec
This is sufficient to run Linux arm64 'hello world' and other simple
binaries.

Reviewed by:	andrew
Sponsored by:	Turing Robotic Industries
Differential Revision:	https://reviews.freebsd.org/D15834
2018-06-25 14:12:33 +00:00
Mark Johnston
a8be239d69 Re-count available PV entries after reclaiming a PV chunk.
The call to reclaim_pv_chunk() in reserve_pv_entries() may free a
PV chunk with free entries belonging to the current pmap.  In this
case we must account for the free entries that were reclaimed, or
reserve_pv_entries() may return without having reserved the requested
number of entries.

Reviewed by:	alc, kib
Tested by:	pho (previous version)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D15911
2018-06-23 10:41:52 +00:00
Emmanuel Vadot
78442297f5 Add pmap_mapdev_attr for arm64
This is needed for efifb.
arm and ricv pmap (the two arch with arm64 that uses subr_devmap) have very
different implementation so for now only add this for arm64.

Tested with efifb on Pine64 with a few other patches.

Reviewed by:	cognet
Differential Revision:	https://reviews.freebsd.org/D15294
2018-06-20 16:07:35 +00:00
Emmanuel Vadot
a2d7053188 if_rk_dwc: Disable setting delays for now
The values for tx/rx delays differs accross the different DTS.
Mainline Linux set it to 0x24/0x18
Mostly-Vendor u-boot (the one maintained and developped) to 0x18/0x18
Mostly-Vendor linux (the one maintained and developped) to 0x26/0x11

By experience only 0x18/0x18 works so until the issue is resolved rely on
the bootloader settings.
2018-06-20 15:27:09 +00:00
Emmanuel Vadot
5f35d609c7 rk_gpio: Read the correct register for gpio read
Reported by:	jmcneill
2018-06-20 14:46:07 +00:00
Emmanuel Vadot
e167047518 if_rk_dwc: Fix delays handling
The property are named {t,r}x_delay and not {t,r}-delay.
The upper bits of the register are a mask of which bits is allowed
to be written, set it otherwise we write nothing.
OF_getencprop returns <0 = for an error.

Pointy Hat: myself
Reported by:	jmcneill (delay and mask bits)
2018-06-20 14:45:26 +00:00
Andrew Turner
8214ff0f9e Move common GIC interrupt numbers to the common header. These are the same
across the GICv2 and GICv3 drivers so we only need a single copy of them.

Sponsored by:	Turing Robotic Industries
2018-06-19 16:14:23 +00:00
Ed Maste
1fbaf06eba Introduce arm64 linuxulator stubs
This provides stub implementations of arm64 Linux vdso and machdep,
ptrace, and futex sufficient for executing an arm64 Linux 'hello world'
binary.

Reviewed by:	andrew
Sponsored by:	Turing Robotic Industries
Differential Revision:	https://reviews.freebsd.org/D15832
2018-06-18 19:34:34 +00:00
Ed Maste
c4db0baa34 Regen arm64 linuxulator sysent files after r335323 2018-06-18 18:10:11 +00:00
Ed Maste
2842db3325 arm64 linuxulator: add dup syscall entry
Missed in r333027

Sponsored by:	Turing Robotic Industries Inc.
2018-06-18 18:08:19 +00:00
Ed Maste
42ac144c32 arm64 linuxulator: add linux_dummy.c based on amd64
A later change should deduplicate the multiple copies of this file.

Sponsored by:	Turing Robotic Industries
2018-06-15 19:42:52 +00:00
Ed Maste
e248c23702 arm64: add arm64 linux.h based on i386 linuxulator and Linux headers
Sponsored by:	Turing Robotic Industries
2018-06-15 19:09:17 +00:00
Emmanuel Vadot
3de61a6883 rk_i2c: Add driver for the I2C controller present in RockChip SoC
This controller have a special mode for RX to help with smbus-like transfer
when the controller will automatically send the slave address, register address
and read the data. Use it when possible.
The same mode for TX is describe is the datasheet but is broken and have been
since ~10 years of presence of this controller in RockChip SoCs.

Attach this driver early at we need it to communicate with the PMIC early in the
boot.
Do not hook it to the kernel build for now.
2018-06-14 06:39:33 +00:00
Emmanuel Vadot
e3fc845c91 rk3328: Add support for the i2c clocks 2018-06-14 06:34:27 +00:00
Emmanuel Vadot
3476304a69 if_dwc_rk: Add DesignWare driver for RockChip SoCs.
Add driver for the designware ethernet controller found in some RockChip SoCs.
The driver still rely on a lot of things setup by the bootloader like clocks
and phy mode.
But since netbooting is the only/easiest way to boot rockchip board at the
moment add the driver so other people can test/dev on thoses boards.
2018-06-14 06:28:09 +00:00
Emmanuel Vadot
282d1ef778 rk_armclk: Add the write mask to the register mux value
This was omitted in r334112 and r334996 which cause the PLL to not correctly
reparent, leaving the armclk to be derived from the APLL instead of the NPLL.
The arm core clock is now correctly set to 600Mhz via the assigned-clock present
in the DTB.
2018-06-14 05:46:57 +00:00
Emmanuel Vadot
1e7af4cc7a rk_pll: Add support for mode
RockChip PLL have two modes controlled by a register, a "slow mode" (the
default one) where the frequency is derived from the 24Mhz oscillator on the
board, and a "normal" one when the pll take it's input from the real PLL output.

Default the mode to normal for all the PLLs.
2018-06-14 05:43:45 +00:00
Emmanuel Vadot
b1b521b1d5 rk_pinctrl: Only add gpio subnode
This is the only node we are interested in so do not waste time to test
creating device that will be either unused or fail as most of the nodes
don't have a compatible string.
2018-06-14 05:41:16 +00:00
Andrew Turner
4e050d14e0 Add ThunderX2 to the list of CPUs we need to apply the branch predictor
hardening to.

Sponsored by:	DARPA, AFRL
2018-06-13 15:58:33 +00:00
Andrew Turner
3c4dad8812 Switch to the SMCCC function for branch predictor hardening. The previous
method may not have worked as the firmware checks for the ARCH_WORKAROUND_1
function ID.

Sponsored by:	DARPA, AFRL
2018-06-13 15:56:24 +00:00
Andrew Turner
8b47c1ae54 Rename the ThunderX CPU identification macros to include the X. This is the
name people know the product by, and is consistent with the later SoC ID
macros.

Sponsored by:	DARPA, AFRL
2018-06-13 12:17:11 +00:00
Andrew Turner
0014ef8a04 Add more Cavium CPU part numbers.
While here split the lists by vendor.

Sponsored by:	DARPA, AFRL
2018-06-13 11:58:41 +00:00
Diane Bruce
5bede50958 Add a driver for the BCM2835 Mini-UART as seen on the RPi3
Reviewed by:	andrew
Approved by:	andrew
Differential Revision:	https://reviews.freebsd.org/D15684
2018-06-12 13:26:31 +00:00
Emmanuel Vadot
e34425be26 arm64: rockchip: Correctly set armclk
Parent needs to be the same frequency as the armclk, not twice the freq.
The real divider is incremented by one so write it with - 1
The rate can be at index 0

Pointy Hat To: myself
2018-06-12 11:47:21 +00:00
Andrew Turner
619e50a657 Remove the psci option from arm64. It is now a standard option as it is
required to boot correctly.

Sponsored by:	DARPA, AFRL
2018-06-10 19:42:44 +00:00
Andrew Turner
dc9b99a884 Clean up handling of unexpected exceptions. Previously we would issue a
breakpoint instruction, however this would lose information that may be
useful for debugging.

These are now handled in a similar way to other exceptions, however it
won't exit out of the exception handler until it is known if we can
handle these exceptions in a useful way.

Sponsored by:	DARPA, AFRL
2018-06-10 16:21:21 +00:00
Konstantin Belousov
8d59ab652b Restore release semantic for the old thread unlock on arm64.
With the introduction of pmap_switch(), the DSB instruction on the
address map switch is not necessary executed, which is fixed by
changing the unlock store to release.  Also remove comment which
documented pre-pmap_switch() code.

Reviewed by:	andrew
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2018-06-08 18:32:26 +00:00
Kevin Lo
3fff2af912 Since we don't enable BUF_TRACKING and FULL_BUF_TRACKING buffer debugging
options in GENERIC kernels on arm and arm64, there's no need to disable
them.

Sponsored by:	MSI/FUNTORO
2018-06-05 05:24:42 +00:00
Andrew Turner
c891735cf7 Move the code to print the EFI memory table to a new function and call it
in teh bootverbose path after cninit().

This allows users to see these tables when booting with boot -v.

Sponsored by:	DARPA, AFRL
2018-05-31 12:37:34 +00:00
Andrew Turner
ede605609a Fix the early spelling of bootverbose.
Sponsored by:	DARPA, AFRL
2018-05-31 11:53:46 +00:00
Andrew Turner
5428bb231f Fix the memory attribute for EFI_MD_ATTR_UC on arm64.
This is defined as Device-nGnRnE in the UEFI spec (UEFI 2.4, section
2.3.6.1). This is the VM_MEMATTR_DEVICE type in FreeBSD.

Reported by:	tuexen
Sponsored by:	DARPA, AFRL
2018-05-31 11:11:23 +00:00
Andrew Turner
9b56058160 Remove max_pa, it's unused.
Sponsored by:	DARPA, AFRL
2018-05-30 15:37:09 +00:00
Andrew Turner
e2b8bf0a18 Further limit when we call pmap_fault.
We should only call pmap_fault in the kernel when accessing a userspace
address. As this should always happen through specific functions that set
a fault handler we can use this to limit calls to pmap_fault to when this
is set.

This should help with NULL pointer dereferences when we are unable to sleep
so we fall into the correct case.

Sponsored by:	DARPA, AFRL
2018-05-30 15:25:48 +00:00
Andrew Turner
abf7742a1c Push down the locking in pmap_fault to just be around the calls to
arm64_address_translate_*. There is no need to lock around the switch
statement as we only care about a few cases.

Sponsored by:	DARPA, AFRL
2018-05-30 14:18:19 +00:00
Andrew Turner
463ac3dda0 On ThunderX2 we need to be careful to only map the memory the firmware
lists in the EFI memory map. As such we need to reduce the mappings to
restrict them to not be the full 1G block. For now reduce this to a 2M
block, however this may be further restricted to be 4k page aligned as
other SoCs may require.

This allows ThunderX2 to boot reliably to userspace without performing
any speculative memory accesses to invalid physical memory.

This is a recommit of r334035 now that we can access the EFI Runtime data
through the DMAP region.

Tested by:	tuexen
Sponsored by:	DARPA, AFRL
2018-05-29 13:52:25 +00:00
Emmanuel Vadot
44654b755d arm64: fix atomic_fcmpset_16
newval needs to be uint16_t

Reported by:	andrew
2018-05-28 21:05:00 +00:00
Emmanuel Vadot
e39ce4cafb arm64: Add atomic_fcmpset_8 and atomic_fcmpset_16
Reviewed by:	cognet
2018-05-28 20:29:03 +00:00
Andrew Turner
2dd5ae7a90 Create a new function to walk the EFI memory table & run a callback for
each entry. We can then use this to ensure the RunTime data is mapped in
the DMAP, but not in phys_avail.

Sponsored by:	DARPA, AFRL
2018-05-28 17:09:29 +00:00
Andrew Turner
b50b5555ef Remove physmap from the arm64 machdep.h. This was missed in r334162. 2018-05-24 16:07:47 +00:00
Andrew Turner
9f1a80706c Allow us to read the physmap data into our own array and use this to build
the DMAP region on arm64.

We already have the needed information to build these tables, we just need
to extract it. This significantly simplifies the code.

Obtained from:	ABT Systems Ltd
Sponsored by:	Turing Robotic Industries
2018-05-24 15:32:49 +00:00
Andrew Turner
d5591551a8 Print the physmem tables under a verbose boot.
Obtained from:	ABT Systems Ltd
Sponsored by:	Turing Robotic Industries
2018-05-24 15:07:53 +00:00
Andrew Turner
c602678b57 Exclude memory from the /reserved-memory mappings with the no-map property
set. This memory must not be mapped by the operating system other than
under control of the device driver.

Obtained from:	ABT Systems Ltd
Sponsored by:	Turing Robotic Industries
2018-05-24 14:55:50 +00:00
Emmanuel Vadot
3df266dff9 arm64: rockchip: Add proper armclock support
The core clock (armclk) on RockChip SoC is special.
It can derive it's clock from many PLLs but RockChip recommand to do it
from "apll" on old SoC and "npll" on new SoC. The reason for choosing npll
is that it's have less jitter and is more close to the arm core on the SoC.
r333314 added the core clock as a composite clock but due to it's specials
property we need to deal with it differently.
A new rk_clk_armclk type is added for this and it supports only the "npll"
as we don't run on old RockChip SoC that only have the "apll".
It will always reparent to "npll" and set the frequency according to a rate
table that is known to be good.
For now we set the "npll" to the desired frequency and just set the core clk
divider to 1 as its parent it just used for the core clk.
2018-05-23 19:07:03 +00:00
Mark Johnston
6514b4f061 Add GET_STACK_USAGE() for arm64.
Its absence meant that GEOM direct dispatch was disabled (the service
routines check the current thread's stack usage to determine whether
to hand off the request to a dedicated thread), and this change is
sufficient to enable direct dispatch by default.

Reviewed by:	allanjude
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D15527
2018-05-23 15:43:35 +00:00
Andrew Turner
84cac654ae Revert r334035 for now. It breaks the boot on some boards as er expect to
be able to read UEFI RuntimeData memory via the DMAP region.
2018-05-22 15:52:11 +00:00
Andrew Turner
89b5faf887 On ThunderX2 we need to be careful to only map the memory the firmware
lists in the EFI memory map. As such we need to reduce the mappings to
restrict them to not be the full 1G block. For now reduce this to a 2M
block, however this may be further restricted to be 4k page aligned as
other SoCs may require.

This allows ThunderX2 to boot reliably to userspace without performing
any speculative memory accesses to invalid physical memory.

Sponsored by:	DARPA, AFRL
2018-05-22 11:26:41 +00:00
Andrew Turner
9d0728e04e Stop using the DMAP region to map ACPI memory.
On some arm64 boards we need to access memory in ACPI tables that is not
mapped in the DMAP region. To handle this create the needed mappings in
pmap_mapbios in the KVA space.

Submitted by:	Michal Stanek (mst@semihalf.com)
Sponsored by:	Cavium
Differential Revision:	https://reviews.freebsd.org/D15059
2018-05-22 11:16:45 +00:00
Andrew Turner
79402150c1 Switch arm64 to use the same physmem code as 32-bit arm.
The main advantage of this is to allow us to exclude memory from being
used by the kernel. This may be from the memreserve property, or ranges
marked as no-map under the reserved-memory node.

More work is still needed to remove the physmap array. This is still used
for creating the DMAP region, however other patches need to be committed
before we can remove this.

Obtained from:	ABT Systems Ltd
Sponsored by:	Turing Robotic Industries
2018-05-22 11:07:04 +00:00