Commit Graph

74 Commits

Author SHA1 Message Date
Andrew Turner
4027d3d62a Teach the GICv2 driver about the Qualcomm GICv2 compatible string.
Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2015-07-21 18:08:10 +00:00
Zbigniew Bodek
3ed97a1a52 Add some more explanation to r285752
Add brief commentary to vendor-specific devid function in ITS
and remove redundant spaces by the way.

Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
2015-07-21 17:14:24 +00:00
Zbigniew Bodek
9920b3aa95 Don't allow malloc() to wait for resource while holding a lock in ITS
malloc() should not go to sleep in case of lack of resource while
the kernel thread is holding a non-sleepable lock.

- change malloc() flags to M_NOWAIT in such cases implement
  lpi_free_chunk() routine as it will be needed when ITT
  allocation fails in its_device_alloc_locked()
- do not increase verbosity of this code since upper layers will
  communicate an error if the interrupt setup fails

Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3121
2015-07-21 15:28:07 +00:00
Zbigniew Bodek
1fe6a1a25a Add support for vendor specific function for PCI devid acquisition in ITS
It is possible that some HW will use different PCI devids,
hence allow to replace the default domain🚌slot:func schema
by implementing and registering custom function.

Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3118
2015-07-21 14:47:23 +00:00
Zbigniew Bodek
52b584bc15 Implement get_cyclecount() on ARM64
Use Vritual Counter register associated with Generic Timer to
read the cyclecount.

Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3134
2015-07-21 12:50:45 +00:00
Zbigniew Bodek
13aaea2fd7 Improve ARM64 CPU_MATCH
Add a method to identify CPU based on RAW MIDR value.

Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3117
2015-07-21 12:15:00 +00:00
Zbigniew Bodek
b8bbefed30 Fix possible coherency issues between PEs related to I-cache
Basing on B.2.3.4:
Synchronization and coherency issues between data and
instruction accesses.

To ensure that modified instructions are visible to all PEs
(Processing Elements) in a shareability domain one need to
perform following sequence:
    1. Clean D-cache
    2. Ensure the visibility of data cleaned from cache
    3. Invalidate I-cache
    4. Ensure completion
    5. In SMP system PE must issue isb to ensure execution of the
       modified instructions

Reviewed by:   andrew
Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3106
2015-07-17 14:33:47 +00:00
Zbigniew Bodek
ab89029bd0 Fix secondary stacks calculation on ARM64
Secondary stack calculation is modified to provide
stack_top = secondary_stacks + (cpu_id) * PAGE_SIZE * KSTACK_PAGES
because on ARM64 the stack grows to lower memory addresses.

Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3107
2015-07-17 14:08:08 +00:00
Zbigniew Bodek
d5dfc8ad00 Increase DMAP (Direct Map) size on ARM64
Previous DMAP size was too small for systems with more than 64GB
of RAM. Increase it to 128GB to support ThunderX CRB.

Reviewed by:   andrew
Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3113
2015-07-17 13:58:00 +00:00
Zbigniew Bodek
721555e7ee Fix KSTACK_PAGES issue when the default value was changed in KERNCONF
If KSTACK_PAGES was changed to anything alse than the default,
the value from param.h was taken instead in some places and
the value from KENRCONF in some others. This resulted in
inconsistency which caused corruption in SMP envorinment.

Ensure all places where KSTACK_PAGES are used the opt_kstack_pages.h
is included.

The file opt_kstack_pages.h could not be included in param.h
because was breaking the toolchain compilation.

Reviewed by:   kib
Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3094
2015-07-16 10:46:52 +00:00
Zbigniew Bodek
1038d102c4 Set-up proper TCR values for memory related to Translation Table Walking
This commit adds proper cache and shareability attributes to
the TCR register.
Set memory attributes to Normal, outer and inner cacheable WBWA.
Set shareability to inner and outer shareable when SMP is enabled.

Reviewed by:   andrew
Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3093
2015-07-16 10:22:57 +00:00
Zbigniew Bodek
b49baf8065 Add identify_cpu() to ARM64 init_secondary routine
Identify current CPU. This is necessary to setup
affinity registers and to provide support for
runtime chip identification.

Reviewed by:   andrew
Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3095
2015-07-15 09:24:45 +00:00
Andrew Turner
b7fbd410ab Set memory to be inner-sharable. This isn't needed on device memory as the
MMU will ignore the attribute there, howeverit simplifies to code to alwas
set it.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2015-07-14 12:37:47 +00:00
Zbigniew Bodek
d1be8e59e2 Fix secondary PIC initialization order
Call arm_init_secondary before any other PIC-related functions
are called. This is necessary for GICv3 where PIC_INIT_SECONDARY
allocates resources needed for all further operations.

Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3066
2015-07-14 12:02:56 +00:00
Zbigniew Bodek
b7ac293f44 Fix intr_machdep.c for ARM64
On ARMv8 IPIs are mapped to 0-15. Incrementing the number by 16
is wrong, because it sets a reserved bit in the IPI register.
This patch removes all "+16" to comply with specs.

Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3029
2015-07-14 11:59:43 +00:00
Christian Brueffer
f4c1eac7cd Spell crypto correctly. 2015-07-14 10:47:56 +00:00
Zbigniew Bodek
686836faca Add ARM64TODO comments to ACPI PCI stubs
This will make searching for missing functionalities easier.
2015-07-12 18:32:16 +00:00
Zbigniew Bodek
e7c14c38ba Implement stubs for ACPI PCI routines
ACPI driver requires special functions to be provided by machdep code.
Add temporary stubs to satisfy the compiler when both "pci" and "acpi"
are enabled in the kernel configuration file.

Reviewed by:   andrew
Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3028
2015-07-12 17:28:31 +00:00
Andrew Turner
bf1717e566 Clear the carry bit on the saved program state register when asked to
clear the return value, it's used to indicate an error.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2015-07-09 17:26:56 +00:00
Andrew Turner
b2b5507779 Add support for SMP. This uses the FDT data to find the CPUs to start on,
and psci to start them. I expect ACPI support to be added later.

This has been tested on qemu with 2 cpus as that is the current value of
MAXCPUS. This is expected to be increased in the future as FreeBSD has
been tested on 48 cores on the Cavium ThunderX hardware.

Partially based on a patch from Robin Randhawa from ARM.

Approved by:	ABT Systems Ltd
Relnotes:	yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D3024
2015-07-09 13:23:29 +00:00
Andrew Turner
3ad7e84ef5 Add logging of synchronous exceptions.
Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2015-07-09 13:07:12 +00:00
Andrew Turner
7df38eabdc Add the definition of the shareable bits in the pagetables
Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2015-07-09 12:56:09 +00:00
Andrew Turner
144aa0b7f5 Clean up the types used in <machine/ucontext.h> on arm64. As some ports
include this file without first including the headers needed for uint32_t
and the like use the __foo type.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2015-07-09 12:51:50 +00:00
Zbigniew Bodek
6c03ba71f8 Rework CPU identification on ARM64
This commit reworks the code responsible for identification of
the CPUs during runtime.
It is necessary to provide a way for workarounds and erratums
to be applied only for certain HW versions.

The copy of MIDR is now stored in pcpu to provide a fast and
convenient way for assambly code to read it (pcpu is used quite often
so there is a chance it's inside the cache).
The MIDR is also better way of identification than using user-friendly
cpu_desc structure, because it can be compiled into comparision of
single u32 with only one access to the memory - this is crucial
for some erratums which are called from performance-critical
places.

Changes in cpu_identify makes this function safe to be called
on non-boot CPUs.

New function CPU_MATCH was implemented which returns boolean
value based on mathing masked MIDR with chip identification.
Example of usage:

printf("is thunder: %d\n", CPU_MATCH(CPU_IMPL_MASK | CPU_PART_MASK,
        CPU_IMPL_CAVIUM, CPU_PART_THUNDER, 0, 0));
printf("is generic: %d\n", CPU_MATCH(CPU_IMPL_MASK | CPU_PART_MASK,
        CPU_IMPL_ARM, CPU_PART_FOUNDATION, 0, 0));

Reviewed by:   andrew
Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3030
2015-07-09 11:32:29 +00:00
Konstantin Belousov
8954a9a4e6 Add the atomic_thread_fence() family of functions with intent to
provide a semantic defined by the C11 fences with corresponding
memory_order.

atomic_thread_fence_acq() gives r | r, w, where r and w are read and
write accesses, and | denotes the fence itself.

atomic_thread_fence_rel() is r, w | w.

atomic_thread_fence_acq_rel() is the combination of the acquire and
release in single operation.  Note that reads after the acq+rel fence
could be made visible before writes preceeding the fence.

atomic_thread_fence_seq_cst() orders all accesses before/after the
fence, and the fence itself is globally ordered against other
sequentially consistent atomic operations.

Reviewed by:	alc
Discussed with:	bde
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
2015-07-08 18:12:24 +00:00
Andrew Turner
6bae05d951 Correctly set __WCHAR_MIN, there is no __UINT_MIN, it's 0.
Sponsored by:	ABT Systems Ltd
2015-07-08 16:18:28 +00:00
Andrew Turner
ded32d88f1 Add support for ipi_all_but_self on arm64.
Obtained from:	ABT Systems Ltd
Sponsored by:	The freeBSD Foundation
2015-07-08 15:32:59 +00:00
Andrew Turner
80ad08a3e9 Add an implementation of savectx that doesn't just call panic.
Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2015-07-08 14:07:06 +00:00
Andrew Turner
cb02f6b942 Send the correct signal when vm_fault fails. While here also set the code
and address fields.

Sponsored by:	ABT Systems Ltd
2015-07-08 12:42:44 +00:00
Zbigniew Bodek
1ae9c994c8 Introduce ITS support for ARM64
Add ARM ITS (Interrupt Translation Services) support required
to bring-up message signalled interrupts on some ARM64 platforms.

Obtained from: Semihalf
Sponsored by:  The FreeBSD Foundation
2015-07-06 18:27:41 +00:00
Andrew Turner
b67d1aad6f Add more tlb invalidations. We currently invalidate when we may not need
to, but with this I can boot on a simulator that models the tlb.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2015-07-06 18:27:18 +00:00
Andrew Turner
5f8583891f Add the kernel functions needed to enable threading.
Sponsored by:	ABT Systems Ltd
2015-07-05 18:16:06 +00:00
George V. Neville-Neil
0661a7c224 Fix up tabs vs. spaces 2015-07-04 20:31:06 +00:00
George V. Neville-Neil
3839369c03 Enable IPSEC in all GENERIC kernels.
Universe and kernel build tests passed 4 July 2015

PR:		128030
Sponsored by:	Rubicon Communications (Netgate)
2015-07-04 17:37:00 +00:00
Andrew Turner
d2676f552e Remove an unneeded define and old comment referencing amd64. 2015-07-02 16:13:29 +00:00
Andrew Turner
b9b3574474 Remove an old comment, the cache is enabled.
Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2015-07-02 15:26:40 +00:00
Andrew Turner
40fc1dffc3 Use pmap_load to load table entries. This simplifies finding places where
we access the tables.

Obtained from:	ABT Systems Ltd
Sponsored by:	The fReeBSD Foundation
2015-07-02 15:17:30 +00:00
Andrew Turner
a380ef6a02 Enable kernel debugging on arm64, other than GDB as it fails to build.
Sponsored by:	ABT Systems Ltd
2015-07-02 14:35:30 +00:00
Andrew Turner
c950fb6b67 Fix the logic for when to restore the VFP registers. It should restore
them when a different thread last used them, or when the thread was last
run on a different cpu.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2015-07-01 17:27:44 +00:00
Ruslan Bukin
b78ee15e9f First cut of DTrace for AArch64.
Reviewed by:	andrew, emaste
Sponsored by:	ARM Limited
Differential Revision:	https://reviews.freebsd.org/D2738
2015-07-01 15:51:11 +00:00
Konstantin Belousov
773554f79e Remove sv_sigtbl handling from the arm64 sendsig(). There is no ABI
emulators on arm64.

Reviewed by:	andrew
Review:	https://reviews.freebsd.org/D2889
Sponsored by:	The FreeBSD Foundation
2015-06-29 10:31:12 +00:00
Ed Maste
ae1860cb89 add floatingpoint.h for arm64
On other architectures floatingpoint.h is a symlink to
machine/floatingpoint.h which in turn includes machine/ieeefp.h.
Do this on arm64 as well for now.

Sponsored by:	The FreeBSD Foundation
2015-06-24 14:51:53 +00:00
Andrew Turner
e2def8eae3 Fix the floating-point exception values to line up with the hardware
register bits. Nothing in base uses these as they are deprecated, however
third-party applications, such as perl, expect some of these functions to
exist.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2015-06-24 12:19:49 +00:00
Andrew Turner
617994efc7 Add basic support for ACPI. It splits out the nexus driver to two new
drivers, one for fdt, one for acpi. It then uses this to decide if it will
use fdt or acpi.

The GICv2 (interrupt controller) and Generic Timer drivers have been
updated to handle both cases.

As this is early code we still need FDT to find the kernel console, and
some parts are still missing, including PCI support.

Differential Revision:	https://reviews.freebsd.org/D2463
Reviewed by:	jhb, jkim, emaste
Obtained from:	ABT Systems Ltd
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2015-06-11 15:45:33 +00:00
Ruslan Bukin
3f66bd5036 Split out db_unwind_frame() so it can be used by DTrace.
Sponsored by:	ARM Ltd.
Differential Revision:	https://reviews.freebsd.org/D2741
2015-06-11 12:47:13 +00:00
Zbigniew Bodek
458f2175ca Add options to dmb() and dsb() macros on ARM64
Using plain dsb()/dmb() as full system barriers is usually to much.
Adding proper options to those barriers (instead of full system - sy)
will most likely reduce the cost of the instructions and will benefit
in performance improvement.
This commit adds options to barrier macro definitions.

Obtained from: Semihalf
Reviewed by:   andrew, ian
Sponsored by:  The FreeBSD Foundation
2015-06-09 23:54:20 +00:00
Alan Cox
966272ca33 Retire VM_FREEPOOL_CACHE as the next step in eliminating PG_CACHE pages.
Differential Revision:	https://reviews.freebsd.org/D2712
Reviewed by:	kib
Sponsored by:	EMC / Isilon Storage Division
2015-06-08 04:59:32 +00:00
Andrew Turner
284743a867 Rework exception entry to help with DTrace. We now store the stack pointer
before adjusting it to store any registers. This is needed as DTrace may
need to adjust the kernel stack pointer, and previously the new stack
pointer would have needed to be checked incase it was changed.
2015-06-06 21:52:46 +00:00
Pedro F. Giffuni
cd508278c1 ddb: finish converting boolean values.
The replacement started at r283088 was necessarily incomplete without
replacing boolean_t with bool.  This also involved cleaning some type
mismatches and ansifying old C function declarations.

Pointed out by:	bde
Discussed with:	bde, ian, jhb
2015-05-21 15:16:18 +00:00
Ruslan Bukin
bc88bb2bf3 Add Performance Monitoring Counters support for AArch64.
Family-common and CPU-specific counters implemented.

Supported CPUs: ARM Cortex A53/57/72.

Reviewed by:	andrew, bz, emaste, gnn, jhb
Sponsored by:	ARM Limited
Differential Revision:	https://reviews.freebsd.org/D2555
2015-05-19 15:25:47 +00:00