Commit Graph
764 Commits
Author SHA1 Message Date
Ian Lepore fa43f3adc7 MFC r321489:
Use the MD __size_t to avoid a dependency on/include of non-MD header files.
This should fix the compilation of the lua 5.3.4 port, among others.
2017-09-11 03:24:50 +00:00
Mark Johnston 2fa3ff061d MFC r311204:
Add some missing atomic_*_ptr #defines for arm.
2017-07-16 00:25:00 +00:00
Michal Meloun d75b39b014 MFC r318021,r318251:
r318021:
    Introduce pmap_remap_vm_attr(), it allows to remap one VM memattr class to
    another.
  r318251:
    Clarify usage rules for pmap_remap_vm_attr().  Not a functional change.
2017-05-23 12:03:59 +00:00
Michal Meloun 16dbc488d1 MFC r318530:
Increase maximum text segment size.  LLVM binaries are huge...
2017-05-22 12:35:31 +00:00
Konstantin Belousov 39345e967b MFC efivar(8) (by imp):
List of revisions merged:
r307070
r307071
r307072
r307074
r307189
r307224
r307339
r307390
r307391
r309776
r314231
r314232
r314615
r314616
r314617
r314618
r314619
r314620
r314621
r314623
r314890
r314925
r314926
r314927
r314928
r315770
r315771

Discussed with:	gjb (re), imp
Sponsored by:	The FreeBSD Foundation
2017-05-20 16:12:44 +00:00
Michal Meloun 5a0fc01c17 MFC r315900,r315973,r315974:
r315900:
    Cleanup structures related to VFP and/or mcontext_t.  - in mcontext_t,
    rename newer used 'union __vfp' to equaly sized 'mc_spare'.
      Space allocated by 'union __vfp' is too small and cannot hold full VFP
      context.
    - move structures defined in fp.h to more appropriate headers.  - remove
    all unused VFP structures.
  r315973:
    Save VFP state on fork().  Update the copy of VFP state in PCB before it is
    cloned for new process.
  r315974:
    Preserve VFP state across signal delivery.
2017-04-16 07:33:47 +00:00
Michal Meloun b1de364c17 MFC r303261,r315059:
r303261:
    Add more UEFI/e820 memory types from latest specifications.
  r315059:
    Split overbloated machep.c to multiple files and do basic cleanup of these
    fragments.
2017-04-16 07:21:20 +00:00
Michal Meloun dc11fd3c62 MFC r306704,r308406:
r306704:
    ARM: Remove next bunch of unused cpu_functions from ARMv6.
  r308406:
    Only include sys/boot.h if LINUX_BOOT_ABI is defined
2017-04-16 06:51:06 +00:00
Michal Meloun 4d93d08344 MFC r306631,r306640,r306641,r306650,r306656:
r306631:
    Use C99 designated initializers to create the armv6 cpu_functions structs.
    This will help with a later cleanup of what functions we implement.
  r306640:
    Only define the CF_* macros on ARMv4/v5. They are unused on armv6.
  r306641:
    Remove the parts of cpu_functions from armv6 that are unused on that
    architecture.
  r306650:
    Add the Cortex-A{53,57,72} ID register values. These can all run 32-bit
    code so could run a 32-bit kernel.
  r306656:
    Use the cortex functions when booting on one of the Cortex-A ARMv8 CPUs.
    This list is incomplete, however we don't have the ID values for the
    missing Cortex-A32 or A35.
2017-04-16 06:35:09 +00:00
Mateusz Guzik 6787678c6c MFC r312932,r312933,r312949,r313141
(by cognet)

Use strexeq instead of needlessly branch.

==

(by cognet)

Remove useless labels.

==

(by cognet)

Correct the IT instruction in atomic_fcmpset_64().

==

(by andrew)

Only define atomic_fcmpset_long in the kernel. We may include
machine/atomic.h in userspace, however atomic_fcmpset_32 is unimplemented
there.
2017-03-23 22:22:24 +00:00
Mateusz Guzik 101f14fc01 MFC r311169,r311898,r312925,r312973,r312975,r313007,r313040,r313080,
r313254,r313341

amd64: add atomic_fcmpset

==

sparc64: add atomic_fcmpset

==

Implement atomic_fcmpset_* for arm and arm64.

==

Add atomic_fcmpset_*() inlines for powerpc

Summary:
atomic_fcmpset_*() is analogous to atomic_cmpset(), but saves off the read value
from the target memory location into the 'old' pointer in the case of failure.

==

i386: add atomic_fcmpset

==

Don't retry a lost reservation in atomic_fcmpset()

The desired behavior of atomic_fcmpset_() is to always exit on error.  Instead
of retrying on lost reservation, leave the retry to the caller, and return

==

Add atomic_fcmpset_*() inlines for MIPS

atomic_fcmpset_*() is analogous to atomic_cmpset(), but saves off the
read value from the target memory location into the 'old' pointer.

==

i386: fixup fcmpset

An incorrect output specifier was used which worked with clang by accident,
but breaks with the in-tree gcc version.

While here plug a whitespace nit.

==

Implement atomic_fcmpset_*() for RISC-V.

==

Use 64bit store instruction in atomic_fcmpset_64.
2017-03-16 06:00:27 +00:00
Ian Lepore 8fe59ff648 MFC r312292, r313573:
Stop including sys/types.h from arm's machine/atomic.h, fix the places
  where atomic.h was being included without ensuring that types.h (via
  param.h) was included first, as required by atomic(9).

  Remove arm's cpuconf.h, and references to it, after moving a few lines from
  it into pmap-v4.h where they are used.  Other than those few lines of
  support for different MMU types, nothing in cpuconf.h has been used in our
  code for quite a while.
  The file existed to set up a variety of symbols to describe the
  architecture.  Over the past few years we have converted all of our source
  to use the new architecture symbols standardized by ARM Inc, and predefined
  by both clang and gcc.
2017-03-02 01:18:46 +00:00
Ian Lepore 94ca919653 MFC r306901:
ARM: Split identify_arm_cpu() into ARMv4 and ARMv6 variant.
  On ARMv6, be more verbose about supported CPU features and/or
  optional instructions.
2017-03-01 22:45:12 +00:00
Ian Lepore df1e6d5061 MFC r306262, r306267, r310021: (needed to avoid conflicts on later merges)
Remove bus_dma_get_range and bus_dma_get_range_nb on armv6. We only need
  this on a few earlier arm SoCs.

  Restrict where we need to define fdt_fixup_table to just PowerPC and
  Marvell.

  Add the missing void to function signatures in much of the arm code.
2017-03-01 19:55:04 +00:00
Konstantin Belousov e389a328a8 MFC r313345:
Update arm and arm64 counters MD bits.

MFC r313394 (by manu):
subr_sfbus.c need sys/proc.h for struct thread definition.
2017-02-20 10:44:24 +00:00
Jason A. Harmening c6ab8ecfb3 MFC r312610, r312792
r312610:
 Like r310481 for i386, move the objects used to create temporary
 mappings for armv6 pmap zero and copy operations to the MD PCPU region.
 Change sysmap initialization to only allocate KVA pages for CPUs that
 are actually present.

 While here, collapse CMAP3 into CMAP2 (their use was mutually exclusive
 anyway) and "recover" some space in PCPU padding that has always been
 available due to 64-byte cacheline padding.

r312792:
 Further cleanup of per-CPU armv6 pmap data:

 - Replace pcpu_find(curcpu) with get_pcpu(), which is much more direct.

 - Remove armv4 pcpu fields which I added in r286296 but never needed
   to use.

 - armv6 pc_qmap_addr was leftover from the old armv6 pmap
   implementation.  Rename it and put it to use in the new one.
2017-02-15 10:35:46 +00:00
Konstantin Belousov 4519d20f59 MFC r313194:
Define the vm_ooffset_t and vm_pindex_t types as machine-independend.
2017-02-11 02:00:56 +00:00
Michal Meloun e0d35e9965 MFC r306667,r306668:
r306667:
    ARM: Add atomic_swap_64(). It's need by linuxkpi and drm-next-4.7.
  r306668:
    ARM: Add mising early clobber modifier in atomic_swap_32().
2016-11-05 04:36:12 +00:00
Michal Meloun b4db52d05a MFC r306756:
ARM: SEV/WFE instructions are implemented starting from ARMv6K, use it
  directly.
2016-10-15 08:27:54 +00:00
Michal Meloun eee7ea04cf MFC r306755:
ARM: Add identifiers for ARM Cortex v8 and Marvell Sheeva v7 cores.  Not a
  functional change.
2016-10-15 07:38:27 +00:00
Ed Schouten daddad7250 MFC r306162:
Make it possible to safely use TPIDRURW from userspace.

  On amd64, arm64 and i386, we have the possibility to switch between TLS
  areas in userspace. The nice thing about this is that it makes it easier
  to do light-weight threading, if we ever feel like doing that. On armv6,
  let's go into the same direction by making it possible to safely use the
  TPIDRURW register, which is intended for this purpose.

  Clean up the ARMv6 code to remove md_tp entirely. Simply add a dedicated
  field to the PCB to hold the value of TPIDRURW across context switches,
  like we do for any other register. As userspace currently uses the
  read-only TPIDRURO register, simply ensure that we keep both values in
  sync where possible. The system calls for modifying the read-only
  register will simply write the intended value into both registers, so
  that it lazily ends up in the PCB during the next context switch.

  Approved by:    andrew
  Reviewed by:    imp
  Differential Revision:  https://reviews.freebsd.org/D7951
2016-10-12 09:17:41 +00:00
Konstantin Belousov 5683d20fd0 MFC r306091:
Add a way for the architecture to specify the calling ABI for methods
in the EFI Runtime Services Table.  On amd64, the calling conventions
are MS.
2016-09-28 09:48:39 +00:00
Konstantin Belousov 0abcae4411 MFC r304285:
Implement userspace gettimeofday(2) with HPET timecounter.
2016-09-16 10:04:28 +00:00
Ed Maste 5cd13f2b54 MFC r303677: Move/add ARM ELF PHDR types to elf_common.h 2016-09-15 17:37:30 +00:00
Ian Lepore 45cd4c8cef Revert the recent armv6 changes to ALIGNED_POINTER(), restoring the
fully-pessimized implementation that requires a type to be aligned to
its natural size.

On armv6+ the compiler might generate load-/store-multiple instructions
which require 4-byte alignment even though the source code is only
accessing individual uint32_t values in a way that doesn't require any
particular alignment at all.  The compiler apparently feels free to
combine multiple accesses into a single instruction that requires a
more-strict alignment, and no set of compiler flags seems to disable
this behavior (at least in clang 3.8).

This fixes alignment faults on arm systems using wifi adapters.  The
wifi code uses ALIGNED_POINTER(p, uint32_t) to decide whether it needs
to copy-align tcp headers.  Because clang is combining several uint32_t
accesses into a single ldm instruction, we need to say that accessing a
uint32_t requires 4-byte alignment.

Approved by:	re(gjb)
2016-06-21 17:53:42 +00:00
Ian Lepore e2a03c1fe5 Do not define __NO_STRICT_ALIGNMENT for armv6. While the requirements
are no longer natural-alignment strict, there are still some restrictions.

FreeBSD network code assumes data is naturally-aligned or is running
on a platform with no restrictions; pointers are not annotated to
indicate the data pointed to may be packed or unaligned.  The clang
optimizer can sometimes combine the load or store of a pair of adjacent
32-bit values into a single doubleword load/store, and that operation
requires at least 4-byte alignment.  __NO_STRICT_ALIGNMENT can lead
to tcp headers being only 2-byte aligned.

Note that alignment faults remain disabled on armv6, this change reverts
only the defining of the symbol which leads to some overly-agressive code
shortcuts when building common/shared drivers and network code for arm.

Approved by:	re(kib)
2016-06-13 16:48:27 +00:00
Andrew Turner 4a9fc96001 Remove the ARMv4/ARMv5 userland atomic support from struct proc on armv6.
Nothing should use this on armv6 as we use the atomic instructions added in
ARMv6k.

Sponsored by:	ABT Systems Ltd
2016-06-08 22:29:30 +00:00
Andrew Turner 8a77146289 Start to clean MIDR values using the CPUID scheme. We don't need to know
the exact CPU we are running on to set the cpu functions. Relax the check
to ignore the CPU revision. Even so this may still be too specific.

Reviewed by:	mmel
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D6504
2016-06-07 18:50:36 +00:00
Zbigniew Bodek 01ed3219b9 Improve ARM debug_monitor for SMP machines
- Reset debug architecture and enable monitor for secondary
  CPUs in init_secondary() rather than when configuring watchpoint, etc.
- Disable HW debugging capabilities when one of the CPU cores fails
  to set up.
- Use dbg_capable() in a more atomic manner to avoid any mismatch
  between CPUs.

Differential Revision: https://reviews.freebsd.org/D6009
2016-05-29 17:35:38 +00:00
Ian Lepore 40cb6df5f3 Disable alignment faults on armv6, adjust various alignment-related macros
to match the new state of affairs.  The hardware we support has always been
able to do unaligned accesses, we've just never enabled it until now.

This brings FreeBSD into line with all the other major OSes, and should help
with the growing volume of 3rd-party software that assumes unaligned access
will just work on armv6 and armv7.
2016-05-26 00:03:23 +00:00
Ian Lepore a66dc0c52b Include machine/acle-compat.h in cdefs.h on arm if the compiler doesn't
have ACLE support built in.  The ACLE (ARM C Language Extensions) defines
a set of standardized symbols which indicate the architecture version and
features available.  ACLE support is built in to modern compilers (both
clang and gcc), but absent from gcc prior to 4.4.

ARM (the company) provides the acle-compat.h header file to define the
right symbols for older versions of gcc.  Basically, acle-compat.h does
for arm about the same thing cdefs.h does for freebsd: defines
standardized macros that work no matter which compiler you use.  If ARM
hadn't provided this file we would have ended up with a big #ifdef __arm__
section in cdefs.h with our own compatibility shims.

Remove #include <machine/acle-compat.h> from the zillion other places (an
ever-growing list) that it appears.  Since style(9) requires sys/types.h
or sys/param.h early in the include list, and both of those lead to
including cdefs.h, only a couple special cases still need to include
acle-compat.h directly.

Loves it:     imp
2016-05-25 19:44:26 +00:00
Ian Lepore 2c96ac7a39 Use the new(-ish) CP15_SCTLR macro to generate system control reg accesses
where possible.  In the places that doesn't work (multi-line inline asm,
and places where the old armv4 cpufuncs mechanism is used), annotate the
accesses with a comment that includes SCTLR.  Now a grep -i sctlr can find
all the system control register manipulations.

No functional changes.
2016-05-23 20:07:17 +00:00
Ian Lepore da6da1575b Adjust _ALIGNBYTES to the proper value for arm and armv6 arches. Modern
compilers can emit arm instructions that require 8-byte alignment.  The
alignment-sensitive instructions were added in armv5, which has to be
supported by our combined v4/v5 kernels, so the value is set uncoditionally
for all arm architecture versions.

Also adjust the comment to explain in more detail why the macros have the
form and values they do.

Per advice from bde@, maintain the unsignedness of the value of _ALIGNBYTES
(but do so using his second choice of allowing sizeof() to supply the
unsignedness, rather than just hardcoding '8U', which in my mind would
require an even more verbose comment to explain why it's right).  Also
explain in the comment that the resulting type of _ALIGN() is equivelent
to uinptr_t on arm (32-bit unsigned int), but it's purposely spelled as
"unsigned" to avoid problems with including other header files.  Even
including machine/_types.h to allow use of __uintptr_t causes compilation
failures because of this header being included (indirectly) in asm code.

The discussion that led to this change (albeit at a glacial pace) is at
https://lists.freebsd.org/pipermail/svn-src-head/2014-November/064593.html
2016-05-21 16:52:38 +00:00
Warner Losh 1761914298 Remove hf appending code from param.h for machine arch name.
Submitted by: ian@ andyt@
2016-05-20 19:18:32 +00:00
Andrew Turner cda142c5b9 Implement atomic_cmpset_acq_64 and atomic_cmpset_rel_64 on arm and armeb.
This should allow r300113 to build there.

Sponsored by:	ABT Systems Ltd
2016-05-18 13:09:52 +00:00
Eitan Adler cef367e6a1 Don't repeat the the word 'the'
(one manual change to fix grammar)

Confirmed With: db
Approved by: secteam (not really, but this is a comment typo fix)
2016-05-17 12:52:31 +00:00
Andrew Turner cca48a59de Add a MULTIDELAY option to allow the ARM kernel to have multiple DELAY
implementations. Early in the boot the kernel will use an approximate,
however after the timer has been probed it will switch to a more accurate
implementation.

Reviewed by:	manu
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D5762
2016-04-30 17:27:33 +00:00
Ruslan Bukin 30b72b6871 Move arm's devmap to some generic place, so it can be used
by other architectures.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D6091
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-04-26 11:53:37 +00:00
Svatopluk Kraus 3d69163ace Don't use atomic operations for page table entries and handle access
and R/W emulation aborts under pmap lock.

There were two reasons for using of atomic operations:
(1) the pmap code is based on i386 one where they are used,
(2) there was an idea that access and R/W emulation aborts should be
    handled as quick as possible, without pmap locking.

However, the atomic operations in i386 pmap code are used only because
page table entries may be modified by hardware. At the beginning, we
were not sure that it's the only reason. So even if arm hardware does
not modify them, we did not risk to not use them at that time. Further,
it turns out after some testing that using of pmap lock for access and
R/W emulation aborts does not bring any extra cost and there was no
measurable difference. Thus, we have decided finally to use pmap lock
for all operations on page table entries and so, there is no reason for
atomic operations on them. This makes the code cleaner and safer.

This decision introduce a question if it's safe to use pmap lock for
access and R/W emulation aborts. Anyhow, there may happen two cases in
general:
(A) Aborts while the pmap lock is locked already - this should not
happen as pmap lock is not recursive. However, under pmap lock only
internal kernel data should be accessed and such data should be mapped
with A bit set and NM bit cleared. If double abort happens, then
a mapping of data which has caused it must be fixed.
(B) Aborts while another lock(s) is/are locked - this already can
happen. There is no difference here if it's either access or R/W
emulation abort, or if it's some other abort.

Reviewed by:	kib
2016-04-22 06:32:27 +00:00
Svatopluk Kraus e4a93d1bb7 Add four functions which check a virtual address for stage 1 privileged
(PL1) and unprivileged (PL0) read/write access. As cp15 virtual to
physical address translation operations are used, interrupts must be
disabled to get consistent result when they are called.

These functions should be used only in very specific occasions like
during abort handling or kernel debugging. One of them is going to be
used in pmap_fault(). However, complete function set is added. It cost
nothing, as they are inlined.

While here, fix comment of #endif.

Reviewed by:	kib
2016-04-22 06:26:45 +00:00
Andrew Turner 59c3cb81c1 Rename ARM_INTRNG and MIPS_INTRNG to INTRNG. This will help with machine
independent code that needs to know about INTRNG such as PCI drivers.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-04-15 16:05:41 +00:00
Svatopluk Kraus bff6be3e9b Remove FDT specific parts from INTRNG. Change its interface to make it
universal.

(1) New struct intr_map_data is defined as a container for arbitrary
description of an interrupt used by a device. Typically, an interrupt
number and configuration relevant to an interrupt controller is encoded
in such description. However, any additional information may be encoded
too like a set of cpus on which an interrupt should be enabled or vendor
specific data needed for setup of an interrupt in controller. The struct
intr_map_data itself is meant to be opaque for INTRNG.

(2) An intr_map_irq() function is created which takes an interrupt
controller identification and struct intr_map_data as arguments and
returns global interrupt number which identifies an interrupt.

(3) A set of functions to be used by bus drivers is created as well as
a corresponding set of methods for interrupt controller drivers. These
sets take both struct resource and struct intr_map_data as one of the
arguments. There is a goal to keep struct intr_map_data in struct
resource, however, this way a final solution is not limited to that.

(4) Other small changes are done to reflect new situation.

This is only first step aiming to create stable interface for interrupt
controller drivers. Thus, some temporary solution is taken. Interrupt
descriptions for devices are stored in INTRNG and two specific mapping
function are created to be temporary used by bus drivers. That's why
the struct intr_map_data is not opaque for INTRNG now. This temporary
solution will be replaced by final one in next step.

Differential Revision:	https://reviews.freebsd.org/D5730
2016-04-04 09:15:25 +00:00
Michal Meloun f5c06c61e4 ARM: Fix ATAG handling in LINUX_BOOT_API:
- Don't convert atags address passed from U-Boot. It's real physical
   address (and we have 1:1 mapping).
 - Size of tags is encoded in words, not in bytes
2016-03-26 06:57:36 +00:00
Michal Meloun fda16d46fe ARM: Teach LINUX_BOOT_ABI to recognize DT blob.
This allow us to boot FreeBSD kernel (using uImage encapsulation) directly
from U-boot using 'bootm' command or by Android fastboot loader.
For now, kernel uImage must be marked as Linux, but we can add support for
FreeBSD into U-Boot later.
2016-03-26 06:55:55 +00:00
Svatopluk Kraus 61c8fde5d6 Generalize IPI support for ARM intrng and use it for interrupt
controller IPI provider.

New struct intr_ipi is defined which keeps all info about an IPI:
its name, counter, send and dispatch methods. Generic intr_ipi_setup(),
intr_ipi_send() and intr_ipi_dispatch() functions are implemented.

An IPI provider must implement two functions:
(1) an intr_ipi_send_t function which is able to send an IPI,
(2) a setup function which initializes itself for an IPI and
    calls intr_ipi_setup() with appropriate arguments.

Differential Revision:	https://reviews.freebsd.org/D5700
2016-03-24 09:55:11 +00:00
Svatopluk Kraus 5b70c08cdf Move IPI related parts back to (ARM) machine specific file now, when
the interrupt framework is also going to be used by another (MIPS)
architecture. IPI implementations may vary much across different
architectures.

An IPI implementation should still define INTR_IPI_COUNT and use
intr_ipi_setup_counters() to setup IPI counters which are inside of
intrcnt[] and intrnames[] arrays. Those are used for sysctl and ddb.
Then, intr_ipi_increment_count() should be used to increment obtained
counter.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D5459
2016-02-27 12:03:07 +00:00
Andrew Turner 7133fe0f33 Almost all copies of platform_mp_init_secondary just called
intr_pic_init_secondary. Replace them with a direct call. On BCM2836
and ARMADA XP we need to add this function, but it can be empty.

Reviewed by:	ian, imp
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D5460
2016-02-26 16:04:47 +00:00
Andrew Turner 3210b87554 Remove platform_mp_probe as it's almost identical on most ARM SoCs, and
slightly wrong on the others. We should just check if mp_ncpus is set to
more than one CPU as we may wish to run on a single core even when SMP is
available.

Reviewed by:	ian
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D5458
2016-02-26 15:54:34 +00:00
Andrew Turner 243b36c321 Remove platform_ipi_send, it's an unneeded as all implementations are
identical.

Sponsored by:	 ABT Systems Ltd
2016-02-25 20:48:23 +00:00
Svatopluk Kraus fe6928058c Remove redundant __ARM_ARCH >= 6 check in armv6 specific files. 2016-02-23 10:12:50 +00:00