Commit graph

919 commits

Author SHA1 Message Date
amrzar
40e89b5d67 ARM: Move fastpath_restore to mode specific folder 2017-02-09 15:47:39 +11:00
amrzar
28f09e2e73 ARM: Move timer.h to mode specific folder 2017-02-09 15:47:39 +11:00
Jack Suann
ebf593561c x86: Add missing memory clobber in receivePendingIRQ
In receivePendingIRQ() the global variable x86KSPendingInterrupt may be
updated but compiler was previously unaware of this.
2017-02-08 12:48:46 +11:00
Adrian Danis
f10efc6047 x86: Use lower memory region for AP boot code
Change AP boot code to use a memory region that is lower down, although also
smaller. As long as the boot code can fit in this smaller region booting is
more reliable as depending on the machine, bios, firmware and bootloader
varying amounts of the low memory will be available.
2017-02-08 09:56:06 +11:00
Anna Lyons
45f20d56b4 trivial: print kernel entry reason on halt
It is generally useful to know what operation was occuring
when the kernel halted, as this is usually called from assert.
2017-02-07 16:52:50 +11:00
Adrian Danis
4f52aca5b1 Remove multiple stack definitions
This commit changes the stack so that it is declared a single time in stack.c,
with the correct attributes and alignment, instead of being declared in stack.h
and relying on the linker to collapse the multiple declarations.
2017-02-06 15:42:37 +11:00
Adrian Danis
b40d95ed89 x86: Send explicit TCB when handling remote VMs withs pending notifications
Previously if the `ksCurThread` of the destination core is not the thread that is
receiving the notification in `sendSignal` then the notification would be delayed
until the VMM for that VM next did a `seL4_VMEnter`. This adds a `tcb_t*` parameter
to `VMCheckBoundNotification` instead of having it implicitly talk about `ksCurThread`.
A TCB parameter is safe to send here as the `doRemoteVMCheckBoundNotification`
happens synchronously and so the TCB is guaranteed to still exist.
2017-02-06 15:04:43 +11:00
Amirreza Zarrabi
ff6942570c Merge pull request #642 in SEL4/sel4 from ~AZARRABI/sel4:unify_bf to master
* commit 'efb28fec20ad1b22b4476a25b92ec1f5fb59a41f':
  Unify arch_shared_types.bf from the libsel
2017-02-06 09:35:13 +11:00
amrzar
efb28fec20 Unify arch_shared_types.bf from the libsel 2017-02-06 09:08:35 +11:00
Bamboo
dcaff678db [STYLE_FIX] 2017-02-05 22:03:00 +00:00
Adrian Danis
331e97962b x86: Implement safe rdmsr function
Implements a safe version of `x86_rdmsr` that can return success or failure depending
on if the rdmsr caused a GP fault
2017-02-06 09:02:19 +11:00
Adrian Danis
4fe72d09f5 x86: Mechanism for catching GP faults and returning to an error handler
Provides a mechanism where if af GP fault is potentially expected it can be caught
and the calling code returned to. The GP happening can be detected by setting
a specific return to handler and additionally by the return to handler being
cleared if a GP happened.
2017-02-06 09:02:19 +11:00
Jack Suann
cea45cd1bd x86: Handling pending interrupts in kernel mode
This commit allows x86 to completely handle a pending interrupt without switching
out to user mode. To handle an interrupt on x86 the APIC *must* generate an exception,
prior to you being able to acknowledge it. Previously we only allow exceptions (i.e.
interrupts) to be generated outside of kernel mode when we are in user mode.

This change allows us to 'poll' for an interrupt and transition the APIC whilst in kernel
mode by enabling and taking interrupts at carefully defined points. A pending interrupt
will be stored by the exception handler, allowing us to then handle the interrupt and
acknowledge the hardware APIC. Handling is done by waiting until after we have 'left' the
kernel and are about to switch to user mode and then 'entering' the kernel again by jumping
to the interrupt entry point.

Handling interrupts entirely in kernel mode provides two advantages
 * It will allow, in the future, the ability to handle kernel interrupts in situations
   where we need to handle the interrupt before actually performing the hardware switch
   back to user mode. This case happens where the user thread is using vt-x and so
   pending interrupts do not generate an interrupt exception, but rather cause an exception
   to be generated telling the system that there is a pending interrupt
 * Where there are multiple pending interrupts it is more efficient to avoid additional
   switches in and out of the user thread

Whilst this change does not enable pre-emption points to handle the interrupt before
returning out of `handleSyscall` it should be easily implementable with what is provided.
2017-02-01 12:44:14 +11:00
Kofi Doku Atuah
3cfcb676bc hikey: Add the rest of the dual timers for hi6220 2017-02-01 11:17:46 +11:00
Kofi Doku Atuah
6f953bf826 hi6220: Add RTC0 and RTC1 device UTs 2017-02-01 06:58:37 +11:00
Adrian Danis
d492e767f4 arm: save/restore banked registers in VCPUs
Adds space in the vcpu_t struct for the registers from the different operating modes
and saves/restores these registers as part of saving and restoring the VCPU
2017-01-30 09:47:51 +11:00
Adrian Danis
f709e49481 arm: SELFOUR-781: Only allow threads with VCPU to run outside user mode
Previously any thread could be set to run in any mode (except HYP mode).
Whilst this causes no security issues for the kernel, different execution
modes in ARM have different banked registers. These registers are not
currently saved and restored allowing for threads to manipulate registers
that will be seen (or potentially are being actively used) by other threads.

Saving and restoring these banked registers for all threads is a performance
cost (even if only done for the actual mode the thread runs in) for no real
benefit, as there is no clear reason to run a thread in other modes if you
do not have a vcpu. Therefore this commit restricts being in modes other than
user to threads that have a vcpu. When multiple VCPUs are properly supported
the switching of VCPUs will then save/restore these banked registers.
2017-01-30 09:47:51 +11:00
Adrian Danis
4cfbb68c62 x64: Correct ASID pool definition after f6d367e8df 2017-01-27 15:11:18 +11:00
Adrian Danis
f6d367e8df x64: Allow full 48bits of virtual address space to be used
Prior to this commit virtual addresses in the bitfield were considered
to be 48-bits, with sign extension to 64-bits. This meant that we were
actually sign extended bit number 47. Whilst this gives correct cannonical
addresses it prevents a portion of the address space from being used.

This commit changes the bitfield to use 49-bit virtual addresses, so that
after the bit 48 is used for sign extension there is still 48-bits of
usable address.
2017-01-27 12:21:07 +11:00
Adrian Danis
8da27f40c6 arm: Always restore TPIDRURW register if it exists
This register should be restored even if we are not using it at as the IPC buffer
location
2017-01-23 09:45:49 +11:00
Adrian Danis
d5bafdc74b arm: SELFOUR-779: Remove ARM_MPCORE config
The ARM_MPCORE configuration was added to capture which systems have the additional
ThreadID registers. This was an unneeded indirection as any arm version from v7 and
beyond has these registers. For the purposes of seL4 this means any arm version
except v6. This change scrubs ARM_MPCORE and replaces it with negated usages of
ARCH_ARM_V6. Additionally the IPC buffer config defaults were updated as the
ARM_MPCORE config was explicitly selecting the optimal one.
2017-01-23 09:45:34 +11:00
Hesham Almatary
668a04630e Merge pull request #616 in SEL4/sel4 from ~HALMATARY/sel4:ARMStackRefactor to master
* commit '6803155e1777b93b17b9aa30827783daf296efc2':
  ARM: discard 4K-alignment constraint
  ARM: Refactor how we get/set seL4 kernel stack
2017-01-20 14:38:22 +11:00
Hesham Almatary
3b33d2f9bd Benchmark/TK1: add missing include benchmark_overflowHandler.h 2017-01-20 13:57:17 +11:00
Kent McLeod
80d32b1609 SELFOUR-780: Add reserved entry to TK1 SMMU struct
This missing entry caused later entries to be offset from the actual
registers in hardware.
2017-01-20 10:20:28 +11:00
Hesham Almatary
6803155e17 ARM: discard 4K-alignment constraint 2017-01-19 19:38:14 +11:00
Hesham Almatary
5d14646343 ARM: Refactor how we get/set seL4 kernel stack
This commit makes seL4 hold the stack address on TPIDRPRW register (PL1 only
Thread ID Register, VMSA, see B4.1.150 section of ARMv7-A and ARMv7-R
edition reference manual).

Originally, the kernel stack was (re-)mapped to a fixed kernel virtual address and
on traps sp is loaded with this virtual address. Reason is to shave up some
cycles/instructions on (fast) traps path instead of having two instructions
(loading global variable pointer and then memory-load stack address from
it).

With ARM pipelining getting smart/complex (from ARMv7 onwards), there is
no noticeable difference in performance between the two implementations.
Furthermore, this change makes it easy for SMP to load different stacks
for each core and do CPU ID arithmetic efficiently. It also avoids the
issues involving (re-)mapping stacks for different cores if we
followed the original design.

Note: the main side-effect to this change is that the kernel stack for
ARM is no longer mapped with execute-never attribute.
2017-01-19 19:38:10 +11:00
Hesham Almatary
1d8be141af Fix compilation error when benchmark utilisation enabled for KZM/ARMv-6 2017-01-19 10:16:48 +11:00
Hesham Almatary
c156c9dddd Merge pull request #607 in SEL4/sel4 from ~HALMATARY/sel4:KernelStacks to master
* commit 'be77963e5bb4c5c28ad3ebd8746c292e7b5876f6':
  Define CONFIG_MAX_NUM_NODES and CONFIG_KERNEL_STACK_BITS in plat/autoconf.h
  Unify kernel stack definition/declaration and share it between architecures/modes
2017-01-18 12:43:34 +11:00
Adrian Danis
f653dfaa64 x86: Support 52-bit physical addresses in IOMMU when in 64-bit mode
Defines the vtd structures to be their full 52-bit size when in 64-bit mode by
making the hardware.bf per mode in the pc99 platform.

Updates some variables in iospace.c that were hard defined to be 32-bit
2017-01-18 10:48:20 +11:00
Adrian Danis
ce96b41db1 pc99: Remove unused PCI definitions 2017-01-18 10:48:20 +11:00
Hesham Almatary
be77963e5b Define CONFIG_MAX_NUM_NODES and CONFIG_KERNEL_STACK_BITS in plat/autoconf.h
For the sake of verification and standalone kernel builds
2017-01-17 17:03:07 +11:00
Hesham Almatary
e9922b7456 Unify kernel stack definition/declaration and share it between architecures/modes
Rather than defining a kernel stack in random places for each
architecure for each mode (32/64) and for single/SMP modes, make the
stack definition shareable between all of the above. This is also useful
for the future ARM SMP work.
2017-01-17 15:52:58 +11:00
Hesham Almatary
dcc0c0f785 Merge pull request #611 in SEL4/sel4 from ~HALMATARY/sel4:VER/FIX to master
* commit 'd5f8fe01274ffb70eeb2964ab5afd9a6c71f1468':
  SMP: guard arch_pause() with #ifdef for verification purposes
2017-01-17 15:52:02 +11:00
Kent Mcleod
76f83bd4f5 Merge pull request #609 in SEL4/sel4 from ~KMCLEOD/sel4:tk1-interrupts to master
* commit 'c2b9d7b3e4a07c9b78d540992692fe6ee8987c52':
  SELFOUR-775: Fix tk1 interrupt off-by-one error
2017-01-17 14:58:29 +11:00
Hesham Almatary
d5f8fe0127 SMP: guard arch_pause() with #ifdef for verification purposes 2017-01-17 14:49:31 +11:00
Kent McLeod
c2b9d7b3e4 SELFOUR-775: Fix tk1 interrupt off-by-one error 2017-01-17 12:01:22 +11:00
Bamboo
5845659ea0 [STYLE_FIX] 2017-01-16 22:32:08 +00:00
Hesham Almatary
ffc18fe880 SMP: use C++11 __atomic builtins instead of legacy __sync buitins 2017-01-16 16:27:16 +11:00
Hesham Almatary
af02927b69 SMP: move lock.h to architecture-independent include/smp
s/__sync_lock_test_and_set/__atomic_exchange_n in lock.h
2017-01-16 15:21:50 +11:00
Hesham Almatary
4bd07b9d2f Merge pull request #601 in SEL4/sel4 from ~HALMATARY/sel4:SMP to master
* commit '53c6b52438ea29241c8a75a4c4cb5de99313022f':
  SMP: Abstract architecture/platform independent parts of smp.h  and ipi.h
2017-01-13 17:22:10 +11:00
Hesham Almatary
53c6b52438 SMP: Abstract architecture/platform independent parts of smp.h and ipi.h
This commit is a re-arrangement of SMP directory structure to make it
easier for other architectures/platforms (in general) and ARM (in
particular) to add SMP support.

* new include/smp directory to act as a centralised container of
"shared" architecture-independent SMP headers.
This makes it clearer what's needed for other architecture/platform to
support SMP.
* Each platform can define its own unique ipi.[h|c] that make sense,
since ipi implementation is SoC/platform dependent.
2017-01-13 15:35:41 +11:00
Adrian Danis
654e92e37c pc99: Update autoconf.h to have stack size definition 2017-01-13 15:22:34 +11:00
Adrian Danis
5037717cde x86: Explicitly define kernel stack size
This commit changes the previous hard coded 4K kernel stack size
to being a configurable power of 2 sized stack
2017-01-13 15:20:14 +11:00
Donny Yang
0ad0c4cded Merge pull request #594 in SEL4/sel4 from ~KOTA/sel4:cap-edits to master
* commit 'df977382f03a82ba46f6d25eb41fb260a061b482':
  x64: Rearrange endpoint_cap structure to improve fastpath speed
  x64: Rearrange cnode_cap structure to improve fastpath speed
  x64: Rearrange pml4_cap structure to improve fastpath speed
  x64: Parallelise isValidVTableRoot_fp() check
2017-01-12 11:08:08 +11:00
Hesham Almatary
530852bbdc Benchmark: ARM - extern benchmark_log_utilisation_enabled
Circular dependency prevents extern definition of benchmark_log_utilisation_enabled from
getting included in include/arch/arm/arch/benchmark_overflowHandler.h.
arch-level headers shouldn't depend on arch-independent headers to avoid
such circular dependency issues (in the future).
2017-01-11 14:59:41 +11:00
Hesham Almatary
2f866d91b3 Benchmark: Define benchmark_util_t in a separate file to avoid circular dependency 2017-01-11 14:19:34 +11:00
Donny Yang
df977382f0 x64: Rearrange endpoint_cap structure to improve fastpath speed
This looks like we're just swapping the positions of capEPBadge and capEPPtr,
but it turns out that the bitwise op being performed on capEPPtr to set the
high bits were part of the data dependency critical path, so this actually
does improve the speed by moving the bitwise op to capEPBadge (albeit it's
now an AND instead of an OR)

I initially set the field size to 32 bits, but it turns out that causes gcc
to emit an instruction (mov r32, r32) that causes the instruction decoder
to switch to the legacy decode path for the rest of the fast path for some
reason.
2017-01-10 17:17:20 +11:00
Donny Yang
c68a69f82a x64: Rearrange cnode_cap structure to improve fastpath speed 2017-01-10 16:57:57 +11:00
Donny Yang
20e6ec6e8e x64: Rearrange pml4_cap structure to improve fastpath speed 2017-01-10 16:57:57 +11:00
Donny Yang
7842e0ddea x64: Parallelise isValidVTableRoot_fp() check 2017-01-10 16:56:42 +11:00
Adrian Danis
cca128ead9 ia32: Always use IRET instead of sysexit when single stepping
Previous code to return to user level performed
popf
sysexit
The popf was just before the sysexit as there is a one instruction
delay on the trap flag taking effect and ensured we did not attempt
to single step the kernel. Unfortunately there is not a one instruction
delay on enabling the interrupt flag, and as a result an interrupt
can be taken prior to executing the sysexit instruction. It is
possible to exploit this to escalate a user level thread such that
it is running with CPL0
This commit changes the restore paths to perform
sti
sysexit
Which will correctly delay interrupts until the completion of sysexit.
As the popf is now being done earlier to prevent single stepping the
kernel we return via an iret, instead of sysexit, for threads that
have single stepping enabled. To achieve this we
* When loading debug state if we enable the Trap flag we also manipulate
  the register state such that the iret return path will be picked
* As fastpath_restore does not have an iret return path we forbid
  the fastpath from switching to threads that have single stepping
  enabled
2017-01-05 16:49:19 +11:00
Bamboo
8361da838d [STYLE_FIX] 2017-01-04 22:57:29 +00:00
Frank Li
58b28649aa Merge pull request #574 in SEL4/sel4 from ~FRANKLI/sel4:prefetch2 to master
Hikey L1D prefetcher

* commit '88eef11c46c6917818626c0763ac143b58fc7d2f':
  Implemented prefetcher for arm: Hikey
2017-01-05 09:57:11 +11:00
Frank
88eef11c46 Implemented prefetcher for arm: Hikey
Fixed typo
2017-01-03 12:08:49 +11:00
Adrian Danis
017d786317 x64: VT-x related cap and object definitions
* Adds object and cap definitions for VT-x structures (VCPU and EPT).
* Extends the asid_map implementation to support ASIDs in the EPT
* Adds size definitions for VCPU and EPT objects
2016-12-16 10:39:40 +11:00
Donny Yang
a720e6245e Merge pull request #571 in SEL4/sel4 from ~KOTA/sel4:skylake to master
* commit '6cd485204f0b3ca09a42770c545f0724189e7b78':
  x86: Add Skylake-related info
  x86: Add support for more architectures in reading the TSC frequency
2016-12-13 16:49:36 +11:00
Donny Yang
6cd485204f x86: Add Skylake-related info 2016-12-13 15:42:02 +11:00
Adrian Danis
a63632a02b x86: Extract common parts of sanitiseRegister
Creates a `Mode_sanitiseRegister` and factors out the common parts
of the 32 and 64 `sanitiseRegister` into a general x86 one
2016-12-13 14:58:45 +11:00
Thomas Sewell
97bac2345f Remove many MODIFIES annotations.
These are redundant for any function which the C-to-Isabelle parser
actually analyses, which is now the vast majority of functions.
2016-12-12 17:30:51 +11:00
Thomas Sewell
117785483a Mark halt as no-inline and no-return.
This actually leads to better code. Copies of the halt loop inlined
in various places will instead be single instructions 'bl halt'. It's
also important for the translation validation to avoid having
pointless loops everywhere, especially inside the bodies of other
loops.
2016-12-12 17:30:50 +11:00
Thomas Sewell
f658276abb Remove many DONT_TRANSLATE markers.
The vast majority of the DONT_TRANSLATE markers in the kernel are used
to hide __asm__ statements and builtin functions
(e.g. __builtin_unreachable ()) from the C-to-Isabelle parser.

The parser now supports underscore identifiers and many __asm__ statements,
and the builtin functions are prototyped, meaning the vast majority of the
DONT_TRANSLATE markers can be dropped. The remaining markers cover functions
that must be treated specially.
2016-12-12 17:30:50 +11:00
Thomas Sewell
9b7435718f Prototype compiler builtins.
Add compatible prototypes for compiler builtins
__builtin_unreachable, __builtin_ctzl, __builtin_clzl,
and __builtin_popcountl.

The compiler ignores these, but they are necessary for the Isabelle
C parser to handle them. This is needed to drop DONT_TRANSLATE markers
from various functions which call these builtins.
2016-12-12 17:30:49 +11:00
Adrian Danis
f99ce0e2d4 x86: Load actual EFER MSR on vmexit
Previously we threw away any modifications the kernel may have made
to the EFER when a VM exit happens. In x86-64 there are modifications
to the EFER that must be preserved
2016-12-12 11:39:25 +11:00
Adrian Danis
a138c6fe7c x86: Make vmread/vmwrite functions public
It is useful (largely for debugging/logging code) to be able to access
these functions outside of the internal VCPU implementation
2016-12-12 11:39:25 +11:00
Adrian Danis
c2b67c95c9 ia32: Add getCurrentCR3
This unifies the interface provided by ia32 and x86-64. This interface
is neccessary as it is not always sufficient to talk about the current
PD (or vspace root), as CR3 can contain more than just the root.
2016-12-12 11:39:25 +11:00
Adrian Danis
513061150b ia32: VCPU only needs kernelSP on ia32
x86-64 has better ways (`swapgs`) of managing per core kernel stacks.
This commit hides the `kernelSP` member of a `vcpu_t` under x86-64
so as not to cause confusion and accidental attempted usage
2016-12-12 11:39:25 +11:00
Adrian Danis
5c7bd1df5c x86: Explicitly define VCPU general purpose registers
Previously the GP registers for a VCPU were defined in the 32-bit
arch registerset. This does not actually make sense as the mode
for the VCPU should be decoupled (and well defined) regardless of
the execution mode of the kernel. This commit provides an explicit
definition and register order for VCPU GP registers.
2016-12-12 11:39:25 +11:00
Donny Yang
564b983940 x86: Avoid writing the fs/gs base if we don't have to 2016-12-07 15:48:20 +11:00
Adrian Danis
3ba3f2de54 x86: Add BSS regions for BOOT and PHYS code
Uninitialized data structures in BOOT and PHYS code currently get
placed in sections that are allocated in the file of the final image.
Whilst these sections will get reclaimed during kernel boot, so no
runtime memory is being wasted, it results in kernel images that
are much larger to load and transport than necesary.

This change adds explicit BSS regions for both BOOT and PHYS code
and moves all appropriate data structures into them
2016-12-05 14:34:00 +11:00
Donny Yang
d5f9edb812 Merge pull request #547 in SEL4/sel4 from ~KOTA/sel4:master to master
* commit 'fbafb777b0569e31a6dee60c6b3898ca1b3a99c3':
  x64: Always set the high bits of certain pointers in the fastpath
2016-12-01 14:13:40 +11:00
amrzar
125bc17149 SELFOUR-723: kernel config for the hikey platform
Also:
- cleanup unused Cortex A57
- Cortex A53 is v8 so removing 'ARM_CORTEX_A53' form v7 files
- define rpi3 as v8
2016-12-01 08:07:44 +11:00
Adrian Danis
78009dd245 SELFOUR-675: x64: Increase message registers from 2 to 4 2016-11-30 12:04:54 +11:00
Donny Yang
fbafb777b0 x64: Always set the high bits of certain pointers in the fastpath
seL4 is always in the top of memory, so the high bits of pointers are always 1.
The autogenerated unpacking code doesn't know that, however, so will try to
conditionally sign extend (in 64-bit mode), which wastes cycles in the fast
path. Instead, we can do the unpacking ourselves and explicitly set the high
bits.
2016-11-30 11:25:05 +11:00
Adrian Danis
d73d0e8f05 x86: Write FS and GS base when restoring user context
This commit moves the write to FS and GS base, allowing for a much
more efficient write to GS base under x86-64 SMP. When writing
GS base was in Arch_switchToThread it was neccessary to write to
an MSR such that when swapgs was performed on kernel exit the new
value of GS base would be retrieved. Unfortunately writing to an
MSR is very expensive and we would much prefer to use the writegsbase
instructions instead. By moving this code to restore user context
we are able to call swapgs earlier and then use the normal
writegsbase instruction
2016-11-28 16:46:27 +11:00
amrzar
a529810e5a x86: Initialize store area when using XSAVE variant instructions
When using, SSE (and other variants), mxcsr would assume similar role as
control word in i387 FPU. When initializing the FPU, it should have valid value.
2016-11-28 11:42:14 +11:00
Adrian Danis
37a5eedb01 bcm2837: Add missing include for printf 2016-11-25 16:30:31 +11:00
Adrian Danis
85b4cc1fa3 x86: FORCE_INLINE lazyFPURestore
In the common case this function expands to a single check, with a blank
body. Whilst forcively inling will cause code bloat, will be code bloat
in the uncommon code path, which we do not care about
2016-11-25 16:26:24 +11:00
Adrian Danis
811800da3e x64: Efficiently pack objects for fastpath
Improves the packing of structures used in the fastpath
2016-11-25 16:26:24 +11:00
Adrian Danis
e7d0a88664 x86: Rewrite config_default as config_ternary for FPU
config_default was intended to either evaluated to the passed configuration
value, or the a default value if the config didn't exist. For integer values
this does not actually work, and the default value always gets returned.
This commit reimplements the desired functionality as config_ternary, which
takes 3 arguments, a config to switch on and a desired true and false expansion
2016-11-25 14:44:08 +11:00
Adrian Danis
859100e0a1 Merge pull request #288 in SEL4/sel4 from ~ALYONS/sel4:arch-fault to master
* commit 'ed95f84a438aea6365762a180cc493113e9282e0':
  SELFOUR-413: changes for verification
  SELFOUR-567: use seL4_CapRights_t from libsel4
  SELFOUR-413: refactor libsel4 fault API
  Split fault types into arch/generic
2016-11-25 14:31:09 +11:00
amrzar
08bc937f21 add DONT_TRANSLATE for popcount builtin 2016-11-25 14:04:46 +11:00
Anna Lyons
ed95f84a43 SELFOUR-413: changes for verification
Avoid using ptrs to arrays at all

Another macrofull change brought to your by verification. This should
avoid nasty proofs about const pointers.
2016-11-25 12:30:29 +11:00
Anna Lyons
2fea9a0fe2 SELFOUR-567: use seL4_CapRights_t from libsel4
This change

* changes seL4_CapRights from the kernel to be seL4_CapRights_t in
libsel4
* deprecates the duplicated seL4_CapRights in libsel4, which is
  now the bitfield generated type seL4_CapRights_t.
* fixes all usages in kernel and libsel4

Impact: for verification, this will require the type to change name
from cap_rights to seL4_CapRights_t.
This is a breaking libsel4 API change, although most code uses
seL4_AllRights or similar constants, which will not break
at a source level as these constants have been updated.
2016-11-25 12:29:07 +11:00
Anna Lyons
b827ad37ba SELFOUR-413: refactor libsel4 fault API
This is a *breaking API change*

This commit:

* makes seL4_Fault_tag_t common between the kernel and libsel4
* deprecates the existing functions from sel4/messages.h includes
* introduces a new fault API in sel4/faults.h and
* sel4/sel4_arch/faults.h
* deprecates seL4_GetTag(), as the function did not work without
  the user calling seL4_SetTag() first (seL4_MessageInfo is passed
  in registers and not set in the IPC buffer)
* removes previously deprecated functions (deprecated prior to 3.0.0)
* updates the seL4 manual to reflect the changes
2016-11-25 12:29:07 +11:00
Anna Lyons
33a771d3cb Split fault types into arch/generic
Prior to this commit faults were separate
per architecture. This commit extracts the common
fault types and introduces arch specific faults,
reducing code duplication across architectures.
2016-11-25 12:29:07 +11:00
amrzar
b3b7e3cbf9 x86: use popcount for IPIs 2016-11-24 15:56:35 +11:00
Adrian Danis
8221326a07 pc99: Update standalone build config 2016-11-24 15:25:52 +11:00
Adrian Danis
1c312610e9 x86: Switch to NULL FPU state if suspect no one using it
Adds a heuristic to switch to a NULL fpu state if we think the FPU
is not presently in use. A NULL fpu state is more efficient as
we do not have to enable/disable the FPU when switching threads
2016-11-24 15:22:39 +11:00
Adrian Danis
cc6853017d Remove unneeded usages of VISIBLE
Using `VISIBLE` where it is not needed limits the ability for the
compiler to optimize, especially when using whole program optimizations
2016-11-24 14:46:01 +11:00
Bamboo
b9a8bfabb5 [STYLE_FIX] 2016-11-23 23:54:39 +00:00
Adrian Danis
f0d599f54b x86: Add FORCE_INLINE to some fastpath functions
The compiler fails to realize that inlining these functions is
a performance benefit due to fact that after inlining their
bodies can be optimized with other inlined functions.
2016-11-24 10:54:13 +11:00
Adrian Danis
dd2675b0f5 x86: Improve performance of getCurrentCPUIndex
The use of 'volatile' on the asm blocks used by getCurrentCPUIndex
resulted in an inability for the compiler to elide repeated invocations
of getCurrentCPUIndex when inlining. The volatile is not needed
as we already want to claim that these functions are CONST and so
the asm block can be move/reordered/deleted as the compiler wishes
2016-11-24 10:54:13 +11:00
Adrian Danis
7252ab185b x86: Avoid modifying thread running on different core in sendSignal
When sending a signal to a notification object that has a bound thread that is
in the 'runningVM' start we, ordinarily, want to deliver it by switching back
to the native execution of that thread and delivering the message. If the thread
is in the 'runningVM' state on a different core, then we must not modify its
thread state. Previously we would modify the thread state (changing it to
Running) and then attemptSwitchTo. Switching would fail, as its affinity would
be for a different core, resulting in us enqueing the thread into the
scheduling queue, despite the thread also presently running.

This commit both adds a check to prevent us manipulating a thread that
is actively running on a different core, as well as a remote operation
to tell that core that if it is running a VM it should recheck its
endpoint for a message.
2016-11-23 16:49:08 +11:00
Adrian Danis
bdf10bb4c1 Refactor includes so trace point support builds
benchmark.h requires a definition of KS_LOG_PPTR, but its previous
placement in machine.h resulted in a circular include. This commit
factors out KS_LOG_PPTR and related definitions to a separate header,
creates the corresponding header for x86, and prevents circular
includes in the x86 builds
2016-11-23 14:29:00 +11:00
Kent McLeod
6e5cb27835 Fix KS_LOG_PPTR incorrect naming 2016-11-23 11:59:13 +11:00
Adrian Danis
5340bb790f Correct constant type in userError 2016-11-22 17:22:50 +11:00
Adrian Danis
28d21e68a2 Print current CPU in debug messages 2016-11-22 17:14:09 +11:00
Bamboo
008f9ae24b [STYLE_FIX] 2016-11-22 17:13:02 +11:00
Adrian Danis
d6d8fb54b9 x64: Multicore TLB coherency 2016-11-22 16:56:33 +11:00
Adrian Danis
09356a3e46 x64: Release lock when returning from kernel 2016-11-22 16:56:33 +11:00
Adrian Danis
a0cb9e6703 x64: Support multiple kernel stacks
Adds support for per-core kernel stacks through the use of
thread local storage and swapgs. In addition to the main
kernel stack the IRQ stack also needs to be made per core
2016-11-22 16:56:33 +11:00
Adrian Danis
fc56575ea6 x64: Define TLB bitmap region
Defines the TLB bitmap to be located, virtually, just below the kernel
window. To get an initialized bitmap in each new address space we
change copyGlobalMappings to copy from USER_TOP (which includes the
initialized TLB bitmap in the global address space) instead of just
the kernel window base
2016-11-22 14:05:55 +11:00
Adrian Danis
d14a973a3d x86: Pass address space when invalidating ASID
For efficient TLB coherency on x86-64 it will be useful to know
the address space that the ASID being invalidated was last assigned to
2016-11-22 13:58:44 +11:00
amrzar
135b320b3b x86: extend APIC to support cluster IPIs 2016-11-22 13:43:37 +11:00
Adrian Danis
117c53e583 imx32: Update autoconf.h for standalone build 2016-11-22 11:53:29 +11:00
Adrian Danis
febe070a28 x86: increase IPI words to 3 2016-11-22 11:51:15 +11:00
Adrian Danis
d393278c0c ia32: Use wrappers for remote ops 2016-11-22 11:51:15 +11:00
Adrian Danis
db0a8184e7 SELFOUR-553: Update standalone kernel configurations
This changes the kernel configurations for the verified platform to
not use the globals frame.
2016-11-22 11:49:52 +11:00
Adrian Danis
e78cdf9b64 SELFOUR-553: Support alternate IPC buffer locations without globals frame
This commit adds support for using the ThreadID registers of the ARM MPCore
platforms for storing the address of the IPC buffer instead of the globals
frame. The choice of using the user readable/writeable ThreadID register
is chosen, even though it means the user cannot use it for its own
purposes, as it leaves room in the future for doing TLS support in the
user read only register, where compilers expect it.
2016-11-22 11:49:52 +11:00
Adrian Danis
9f99e77c38 SELFOUR-553: Support ARM MPCore registers
This commit adds support for saving/restoring an additional register
that exists on ARM MPCore platforms. As this register is user wrieable,
as well as readable, it must saved and restored by the kernel to
prevent gross information channels.
2016-11-22 11:49:52 +11:00
Bamboo
1875861937 [STYLE_FIX] 2016-11-22 11:13:46 +11:00
amrzar
27afc1bd92 x86: add logical id mapping for x2APIC IPI boradcasting 2016-11-22 09:40:31 +11:00
Amirreza Zarrabi
becdb483a8 Merge pull request #506 in SEL4/sel4 from ~AZARRABI/sel4:x2apic_fence to master
* commit 'b216c194faacfa070ee963ede54c8020d6494f24':
  x86: add mfence as X2APIC MSRs are not serializing
2016-11-21 09:58:38 +11:00
Adrian Danis
51a0fad68c Merge pull request #505 in SEL4/sel4 from ~ADANIS/sel4:likely to master
* commit 'edc811a872e5d709c2ff78fadf85573cb51b6304':
  x86: Add likely to isValidVTableRoot_fp
2016-11-21 09:53:26 +11:00
amrzar
b216c194fa x86: add mfence as X2APIC MSRs are not serializing 2016-11-21 08:20:38 +11:00
Adrian Danis
edc811a872 x86: Add likely to isValidVTableRoot_fp
Although this function is called from the fastpath inside of an
`unlikely` macro and the function itself gets inlined, the knowledge
that this conjunction is unlikely is somehow lost. Explicitly putting
a `likely` here fixes it
2016-11-18 16:36:40 +11:00
Anna Lyons
8452068cc3 Move migration logic to own function
This makes it easier to port to the RT branch, where
migration can happen in several different places.
2016-11-18 16:34:13 +11:00
Adrian Danis
31628d9a58 Remove recycle
Removes the recycle operation and adds an operation
to cancel any badged sends on and endpoint. Calling
Revoke + CancelBadgedSend is equivalent to Recycle
on a badged endpoint
2016-11-18 14:10:01 +11:00
amrzar
2955bd46b2 add x2apic to x86-64 autoconfig 2016-11-18 07:26:12 +11:00
Amirreza Zarrabi
af81bb0fd5 Merge pull request #499 in SEL4/sel4 from ~AZARRABI/sel4:x2apic to master
* commit 'd746cc9cf61b6f50aee6aacf89e91b1f555b1a88':
  x86: enable support for x2APIC
2016-11-18 07:13:15 +11:00
amrzar
d746cc9cf6 x86: enable support for x2APIC 2016-11-17 16:32:57 +11:00
Adrian Danis
8a6936ff1d Remove incorrect CONST usage
This removes usages of CONST Arch_activateIdleThread. According to
gcc 'a function that has pointer arguments and examines the data
pointed to must not be declared const'. Whilst these functions do
not presently examine their tcb_t pointer argument, it seems
pointless to pass something that can never be safely looked at.

Further a function that returns void and is CONST is utterly meaningless
2016-11-17 11:51:46 +11:00
Adrian Danis
7f76749448 Revert SELFOUR-242
This reverts commits
3aee0ab7b3
6b6b965528
a1421832ac
2016-11-16 14:02:11 +11:00
Anna Lyons
a1421832ac SELFOUR-242: invert bitfield scheduler & optimise
This commit does the following:

* invert the bit field scheduler for better cache performance for high priority threads
* peeks into the bitfield scheduler to allow fastpath to be leveraged when IPC occurs from lo --> hi priority threads if correct
2016-11-15 09:45:48 +11:00
Adrian Danis
90f6a9863b x86: Initial support for SMP vt-x
Enables vt-x code to compile when CONFIG_MAX_NUM_NODES is set to
greater than 1 and adds code to manage VMCS state on different cores
2016-11-11 14:04:39 +11:00
Adrian Danis
2c49729da5 x86: Refactor tlb_bitmap to be mode generic
Refactors the TLB bitmap code to be generic across ia32 and x86-64.
2016-11-09 15:24:17 +11:00
Adrian Danis
9c91fc8f42 x86: Refactor generic x86 pte/pde manipulation
Previously generic functions for manipulating page table and page
directory entries were placed in mode/structures.h. These are moved
to a mode/vspace.h instead so that they can use existing functions
defined in arch/vspace.h.

The x86_make_pde_mapping function is dropped in this move as it is
not used. Instead it is replaced with a function for creating an
empty mapping for whatever is the vspace root.
2016-11-09 15:23:40 +11:00
amrzar
ffd0f34b39 Clean up x86KScurInterrupt:
1. Remove the locking dependancy on the value of x86KScurInterrupt
2. Remove confusing set/unset of x86KScurInterrupt
2016-11-09 14:22:04 +11:00
amrzar
b46e98c10e smp: solve bug in tlb_bitmap
1. Missing loop counter when accessing to PD in 'tlb_bitmap_get'.
2. Missing 'TLBBITMAP_PD_INDEX' in 'TLBBITMAP_PD_MAKE_INDEX'. The index generated by 'TLBBITMAP_PD_MAKE_INDEX' should be valid in PD while the original one used to generate just 0, 1, etc. The correct index is '0 + TLBBITMAP_PD_INDEX', '1 + TLBBITMAP_PD_INDEX' and so on.
2016-11-09 10:00:56 +11:00
Bamboo
846254be1f [STYLE_FIX] 2016-11-08 05:55:43 +00:00
Anna Lyons
c86669df43 x86: export tsc freq in bootinfo
We read the frequency from the platform info MSR and export it to the
user for accurate timing (for platforms that support platform into)
2016-11-08 14:46:18 +11:00
Adrian Danis
828a14d853 SELFOUR-222: Configure IRQ cnode size per platform 2016-11-08 11:48:31 +11:00
Adrian Danis
808f68e1be x64: Mode specific IPI definitions 2016-11-07 15:02:29 +11:00
Adrian Danis
9899c60c8b x86: Reduce number of irqs to 128
On x86-64 the irq cnode will be larger than a page if there is more
than 128 irqs.
2016-11-07 14:58:46 +11:00
Adrian Danis
1173e19aa6 x86: kernelSP only needed for ia32 2016-11-07 14:58:46 +11:00
Adrian Danis
6f908324f8 x64: Access core local state correctly 2016-11-07 14:58:46 +11:00
Adrian Danis
8b5ec01626 x86: Split IPIs into arch and mode portions 2016-11-07 14:53:46 +11:00
amrzar
44fc989cc5 Store remote FPU state 2016-11-07 14:41:25 +11:00
Bamboo
b90b715818 [STYLE_FIX] 2016-11-07 13:27:52 +11:00
Adrian Danis
61c1a4c4ff x64: Mode specific smp file 2016-11-07 12:18:43 +11:00
Adrian Danis
a726b4bea5 x86: Split CPU ID management into mode and general
This moves getCurrentCPUIndex into a mode specific smp header, and
moves wrappers that use it into the generap smp header
2016-11-07 11:46:08 +11:00
Adrian Danis
76b9441eee x86: Remove unused function 2016-11-07 11:44:57 +11:00
amrzar
056dbf811b SELFOUR-634: support for TLB and cache management 2016-11-07 10:55:05 +11:00
Anna Lyons
4a82597b7a trivial: change remoteTCBStall to take tcb
Instead of cap_t. This allows the function to be used from other
functions that have the tcb pointer and not the cap.
2016-11-07 10:37:17 +11:00
Adrian Danis
ab91c11a4f Merge pull request #459 in SEL4/sel4 from ~ADANIS/sel4:smmu to master
* commit '858fa717c6a30fe1f0514c4ad8bbbe1003016864':
  tk1: Remove temporary SMMU memory mapping support
  arm: Remove lookup error message
  arm: Correctly mask SMMU PT addresses
  tk1: Correct SMMU PD and PT indexing
2016-11-03 05:05:38 +00:00
Adrian Danis
a85472a951 x86: Always consider FPU owernship of threads core
When checking if a thread is using the FPU or not we now check on that
threads core, under the assumption that if a thread migrates its FPU
state is explicitly (and not lazily) migrated.
2016-11-03 10:18:24 +11:00
Adrian Danis
858fa717c6 tk1: Remove temporary SMMU memory mapping support 2016-11-02 15:12:56 +11:00
Adrian Danis
e3be5fa8e4 tk1: Correct SMMU PD and PT indexing 2016-11-02 15:12:56 +11:00
amrzar
3b19198bf4 Include vspace remote call support 2016-11-02 15:00:19 +11:00
amrzar
658eb090db Extend IPI for two function parameters 2016-11-02 13:47:29 +11:00
Thomas Sewell
03c71b63e1 SELFOUR-444: Preemptible zeroing for retype.
Change to the order of operations and timing behaviour of
invokeUntyped_Retype. The Retype operation now zeroes the
entire range of the Untyped cap (if it is being used for
the first time) before installing any objects. This avoids
the need for long-running initialisation of large objects,
whose initial contents are always zero. The initial zeroing
phase is preemptible, and may take multiple timeslices to
complete.
2016-11-01 17:05:36 +11:00
Bamboo
061f1b8d49 [STYLE_FIX] 2016-11-01 02:56:15 +00:00
amrzar
a228c492a6 Incuede TLBBitmap in PD to keep track of cores currently accessing this PD 2016-11-01 10:07:57 +11:00
Amirreza Zarrabi
b2295ea036 Merge pull request #434 in SEL4/sel4 from ~AZARRABI/sel4:sceduler_multicore to master
* commit '25bb94372fe4afce072959af88c1afe9ff1c67d3':
  SELFOUR-635: support for TCB operations This will update TCB invocations to consider multicore environment, this may include: - adds the affinity invocation to transfer TCB between different cores and update TCB structure for core ID - checking the thread/core state before performing TCB operation, e.g. deleting the runnable TCB, etc
2016-10-30 23:11:25 +00:00
Kent Mcleod
436b214ec6 Merge pull request #444 in SEL4/sel4 from ~KMCLEOD/sel4:pr to master
* commit '66dfc2e786614a34c18ad2d7c20c04c69e589a97':
  Change ia32 to use fs register for IPC buffer
2016-10-30 23:00:44 +00:00
amrzar
25bb94372f SELFOUR-635: support for TCB operations
This will update TCB invocations to consider multicore environment, this may include:
- adds the affinity invocation to transfer TCB between different cores and update TCB structure for core ID
- checking the thread/core state before performing TCB operation, e.g. deleting the runnable TCB, etc
2016-10-30 08:59:32 +11:00
Kent McLeod
66dfc2e786 Change ia32 to use fs register for IPC buffer
gs register is used by gcc for TLS and the IPC buffer gets in the way
2016-10-28 16:40:38 +11:00
Anna Lyons
40383a9882 Fix arm builds broken in 44ed6adb6 2016-10-28 16:16:04 +11:00
Anna Lyons
f0cb354755 Merge pull request #410 in SEL4/sel4 from ~ALYONS/sel4:cache to master
* commit '44ed6adb616590a0f6ae8b0ad8c442afed625457':
  add seL4_BenchmarkFlushCaches() for arm and ia32
2016-10-28 04:21:25 +00:00
Anna Lyons
44ed6adb61 add seL4_BenchmarkFlushCaches() for arm and ia32
Available when CONFIG_ENABLE_BENCHMARKS is set, flushes caches for
running cold-cache benchmarks
2016-10-28 15:09:03 +11:00
Adrian Danis
261d1f536c arm: Use #define for tcbArchCNodeEntries
Using a #define allows the post processed C code to be identical
for the purposes of verification
2016-10-28 13:58:22 +11:00
Adrian Danis
30f1d1fa7b x86: Comment #endif blocks for clarity 2016-10-28 13:51:21 +11:00
Bamboo
120a5e5496 [STYLE_FIX] 2016-10-28 01:34:31 +00:00
Adrian Danis
0012ea3e2e x86: fix FPU under SMP builds 2016-10-28 12:20:17 +11:00
Adrian Danis
da409659d0 x64: Match ASID changes on ia32 2016-10-28 12:14:16 +11:00
Adrian Danis
e83769322f x64: Update IO port cap type to match ia32 2016-10-28 12:13:42 +11:00
Adrian Danis
f8e6b4d9d6 x64: Guard vt-x that is not yet implemented
These guards are needed because vt-x is not yet properly supported
in x86-64 builds. Once it is these guards can be removed again
2016-10-28 12:12:46 +11:00
Adrian Danis
679d28c992 x64: Correct FPU handling code 2016-10-28 12:12:04 +11:00
Bamboo
6a86cbf5c7 [STYLE_FIX] 2016-10-27 05:34:49 +00:00
Adrian Danis
7fbde1bbcb SELFOUR-287: 32-bit vt-x implementation
This is an implementation of vt-x for x86 kernels running in
ia32 mode.
2016-10-27 16:20:30 +11:00
amrzar
f050e6a9c5 implement layout of ipi interrupt handling 2016-10-23 12:21:14 +11:00
Adrian Danis
ea47c2d4a4 Remove self include 2016-10-21 12:05:02 +11:00
Adrian Danis
ccb2e4b446 Remove circular include
machine/hardware.h is already including machine/interrupt.h
2016-10-21 12:05:02 +11:00
Adrian Danis
80dbdf5ed0 Remove unused include 2016-10-21 12:05:02 +11:00
Adrian Danis
7c08bc25e9 Remove include of basic_types
arm/arch/types.h does not require any definitions from basic_types
(other than those from stdint, which is already directly included)
2016-10-21 12:05:02 +11:00
Adrian Danis
63649f2636 Remove arch/machine.h include from statedata.h
statedata.h gets included from arch/machine.h, and statedata
does not require any of the machine.h definitions.

As a result of removing this various other, previously missing,
includes need to be added
2016-10-21 12:05:02 +11:00
Adrian Danis
b90238d089 Replace #pragma once with include guards 2016-10-21 12:05:02 +11:00
Adrian Danis
d6eafad1a5 Move cap definitions from objecttype into header 2016-10-20 15:45:06 +11:00
Adrian Danis
325643ac19 Remove circular include between debug and benchmark_track
benchmark_track.h does not depend upon anything in debug.h and
so it does not need to include it. Once this include is removed
debug.h can pull its definition of ksKernelEntry from benchmark_track.h
2016-10-20 15:45:06 +11:00
Adrian Danis
c3370f770b x86: Remove circular include
x86/arch/machine/hardware.h gets include via types.h (through the
compound_types.h header). As this header is defining compound types
it really only needs access to the basic types (i.e. stdint.h)
2016-10-20 15:45:06 +11:00
Anna Lyons
49f26d5c84 Fix benchmark_debug_syscall_start
The lowest syscall number is -8, which doesnt' fit in 3 bits -> change
to 4.
Also, we were storing the -ve number, which also doesn't fit into 3
bits -> invert it when we store it.
2016-10-20 15:07:49 +11:00
Adrian Danis
1c50cec9e8 arm: Remove duplicate definitions
PPTR_TOP and KS_LOG_PPTR are defined in the mode headers, this commit
removes the duplicate definitions in the general arm header
2016-10-20 14:12:03 +11:00
Hesham Almatary
423f3eaf4a Merge pull request #423 in SEL4/sel4 from ~HALMATARY/sel4:benchmarkRefine to master
* commit 'e3f764a65be484d89e29ebc22ea406f1438ae3d3':
  Benchmark: move arch-dependent benchmark.c from api/ to new benchmark/ directory
  Benchmark: Pack arch-independent benchmark-related files into separate directories
2016-10-20 02:23:29 +00:00
Hesham Almatary
5f7fa2fcc8 Benchmark: Pack arch-independent benchmark-related files into separate directories 2016-10-20 11:42:04 +11:00
Adrian Danis
59f50c7183 x86: use vspace_root_t type
switchToThread_fp is passed variables of type vspace_root_t, not
pde_t, this commit brings the two into line
2016-10-20 11:07:55 +11:00
Adrian Danis
9396783741 am335x: Prevent out of bounds array access 2016-10-20 10:56:58 +11:00
amrzar
2d462d4ad9 add basic api for setting affinity 2016-10-19 08:35:37 +11:00
Anna Lyons
3a185a5c32 debug: generate list of syscall names 2016-10-18 14:05:41 +11:00
Rafal Kolanski
01e0ed7d9a Merge pull request #406 in SEL4/sel4 from ~ADANIS/sel4:lazyvcpu to master
* commit 'cdc869309b69d04c8682f166755c26cc7a401667':
  arm_hyp: Used cached value for num LRs
  arm_hyp: Add lazy vcpu switching
  arm_hyp: Declare armHSCurVCPU in header
  arm_hyp: Correctly destroy armHSCurVCPU
  arm_hyp: Move hype state into correct statedata header
2016-10-17 04:25:01 +00:00
Adrian Danis
cfe0f8e9db x64: Support for hardware debugging when using SYSENTER
Hardware debugging was already supported if using SYSCALL for kernel
invocations, this adds support for when using SYSENTER. SYSENTER
is special because when entering the kernel the TF flag is not masked,
so the case of taking a debug exception in the kernel needs to be
handled. Also, unlike ia32, there is a race between performing
popf and calling sysexit where interrupts can be received. This race
is avoided by performing a full state restore with iret if a thread
is single stepping.
2016-10-14 15:47:16 +11:00
Adrian Danis
2a1d1e94d7 arm_hyp: Add lazy vcpu switching 2016-10-14 14:24:12 +11:00
Adrian Danis
04612f16c6 arm_hyp: Declare armHSCurVCPU in header 2016-10-14 14:24:12 +11:00
Adrian Danis
fdad50853a arm_hyp: Move hype state into correct statedata header
The hypervisor state is declared in arch/32/statedata.c, but is
defined in arch/statedata.h. This commit moves the definitions to
arch/32/statedata.h to match all the other state in arch/32/statedata.c
2016-10-14 14:24:12 +11:00
Amirreza Zarrabi
36e5db7aac Merge pull request #399 in SEL4/sel4 from ~AZARRABI/sel4:smp_idle to master
* commit '1887ae9dce65c3a32df244c19b635cbe5e3d72bf':
  Update SMP idle thread handling
2016-10-14 00:22:46 +00:00
amrzar
1887ae9dce Update SMP idle thread handling 2016-10-14 11:15:39 +11:00
Adrian Danis
235a02ec4e x86: Use FLAGS_* defines instead of magic numbers 2016-10-13 16:58:27 +11:00
Adrian Danis
b01cf7f0d7 x86: Make stack.h a mode specific header
The functionality of setKernelEntryStackPointer is all ia32 specific and
this commit moves this to a mode specific include location
2016-10-13 16:49:11 +11:00
Adrian Danis
a4c014ca8e x64: Missing c_exit_hook 2016-10-13 15:26:37 +11:00
Adrian Danis
d1d4568114 x86: Define FLAGS bits instead of having magic numbers 2016-10-12 14:38:00 +11:00
Adrian Danis
a3c88cfc5b pc99: Update autoconf.h for standalone builds 2016-10-12 14:18:55 +11:00
Bamboo
f062dcdcf9 [STYLE_FIX] 2016-10-12 03:07:32 +00:00
Adrian Danis
6d07c44329 x64: Partial hardware breakpoint support
This only implementes debug support if using the SYSCALL kernel invocation
method, will not work yet with SYSENTER
2016-10-12 13:38:37 +11:00
Adrian Danis
6294225ca7 x86: Rename [ER]FLAGS to FLAGS
Having a different name for the FLAGS register creates an unnecessary difference
between ia32 and x86_64 code since regardless of the name/size the bits in the
register mean exactly the same thing
2016-10-12 13:38:35 +11:00
Adrian Danis
e2bf4881c8 x64: Refactor Arch_initContext
Split Arch_initContext into mode and arch portions
2016-10-12 13:38:26 +11:00
Adrian Danis
48df6d3ab4 x64: Define kernelBase for breakpoint code 2016-10-12 12:22:32 +11:00
Adrian Danis
600fe2bc09 x86: Move hardware debug state
Assembly traps rely on the registers and kernel stack being at a
known offset
2016-10-12 12:22:32 +11:00
Adrian Danis
9c1d204eaf x64: Correctly invalidate PCIDs 2016-10-12 12:22:32 +11:00
Adrian Danis
4f09f9c42d x86: Refactor elf code 2016-10-12 12:22:32 +11:00
Adrian Danis
7d50c439a8 Defined untyped size ranges in libsel4 2016-10-12 12:22:32 +11:00
Adrian Danis
4c94f43c51 x64: Fastpath 2016-10-12 12:22:32 +11:00
Adrian Danis
f3094f2e86 x64: extend message_info_t to 64-bit 2016-10-12 12:22:32 +11:00
Adrian Danis
067b71cad4 x64/libsel4: Add x64 libsel4 implementation 2016-10-12 12:22:32 +11:00
Adrian Danis
7f9970e5e2 x64: Add x86_64 support 2016-10-12 12:22:31 +11:00
Adrian Danis
726f5edaf5 x64: Check size of unsigned long 2016-10-12 12:06:22 +11:00
Adrian Danis
03ec049d6b x64: 64-bit elf loading 2016-10-12 12:06:22 +11:00
Bamboo
e1d4ffd13e [STYLE_FIX] 2016-10-12 00:17:10 +00:00
amrzar
f80be7055b Add VISIBLE attrubute to UP states 2016-10-12 10:11:51 +11:00
amrzar
3f9eb7c873 SELFOUR-632: implement cores non-architecture dependent structres 2016-10-10 16:33:48 +11:00
Kofi Doku Atuah
bebfcf6d27 SELFOUR-499: X86, ARM: Add userspace invocations for hardware debugging
This commit implements the body of SELFOUR-499. The API exposes the x86 DR0-7
and ARM coprocessor 14 features to userspace by virtualizing them as context-
switched registers in the TCB. Implemented as TCB invocations. This feature is
only built when CONFIG_HARDWARE_DEBUG_API is selected.

* Add low-level support routines for setting, unsetting, getting, enabling
  and disabling breakpoints.
* Add support for single-stepping as well.
  ^ Single-stepping is not supported on ARMv6 since the hardware
    doesn't have support.
  ^ ARM implements single-stepping as instruction breakpoints
    configured to fault on every instruction -- this is achieved through
    the "mismatch" mode, which is only supported from ARMv7 onwards.
* Also support explicit software break requests, a la "BKPT" and "INT $3".

* New invocations:
  * seL4_TCB_SetBreakpoint().
  * seL4_TCB_GetBreakpoint().
  * seL4_TCB_UnsetBreakpoint().
  * seL4_TCB_ConfigureSingleStepping().
* New constants:
  ^ Event types:
    ^ seL4_InstructionBreakpoint.
    ^ seL4_DataBreakpoint.
    ^ seL4_SoftwareBreakRequest.
  ^ Access types:
    ^ seL4_BreakOnRead.
    ^ seL4_BreakOnWrite.
    ^ seL4_BreakOnReadWrite.
  ^ Exports:
    ^ seL4_NumHWBreakpoints.
    ^ seL4_NumExclusiveBreakpoints.
    ^ seL4_NumExclusiveWatchpoints.
    ^ seL4_NumDualFunctionMonitors.
    ^ seL4_FirstBreakpoint.
    ^ seL4_FirstWatchpoint.
    ^ seL4_FirstDualFunctionMonitor.

See documentation in the seL4 API manual.
2016-10-10 13:53:21 +11:00
Kofi Doku Atuah
8b39c73544 Define kernelBase for 32-bit x86. 2016-10-06 16:03:04 +11:00
Bamboo
e3974daac1 [STYLE_FIX] 2016-10-06 01:10:16 +00:00
amrzar
e63be664c6 SELFOUR-631: implement CLH lock and barrier infrastructure 2016-10-06 11:50:57 +11:00
Adrian Danis
45622671de x86: Define large frame types 2016-10-06 07:39:25 +11:00
Adrian Danis
602836a21b x86: Generic setCurrentVSpaceRoot
Defines a generic setCurrentVSpaceRoot to replace setCurrentPD in
mode generic code
2016-10-06 07:39:25 +11:00
Adrian Danis
74cb86c202 x86: Support for syscall
syscall/sysret is an additional way of performing kernel entry/exits.
Whilst the instructions themselves are not supported when running
in 32-bit mode, this commit provides the config choice for them as
well as the generic support code for them.
2016-10-06 07:39:24 +11:00
Adrian Danis
d72cd75136 x86: Rename invalidateTLBentry->invalidateTLBEntry 2016-10-05 16:40:43 +11:00
Anna Lyons
7336303b7f SELFOUR-276: Add MCP field to threads.
Where MCP = Maximum Controlled Priority

This commit adds:

* seL4_TCB_SetMCPriority

and changes the arguments to

* seL4_TCB_Configure

As of this commit, a thread cannot create or set a threads
priority (including itself) above its mcp. Previously the kernel
did this check against a threads priority, which prevented a thread
from setting it's own priority down and then up again.
2016-10-05 11:11:19 +11:00
Adrian Danis
43772b2dc2 x86: Rename decodeIA32PortOperation->decodeX86PortOperation 2016-10-04 11:17:35 +11:00
Adrian Danis
2320d90904 x86: Fixup IOMMU implementation
Adds a mapping type to frame caps that tracks
what kind of hierarchy the cap is mapped into;
an MMU, IOMMU and in the future an EPT structure.

Additionally the IOMMU code is updated to
have correct functionality and be verification
friendly.
2016-09-29 16:11:11 +10:00
Kofi Doku Atuah
b1f8d21e96 TK1: Split the mux controller from the misc region
The TK1 manual's address map has a 16K MMIO region called the "Misc" region,
where they lump together several controllers that aren't all page aligned,
including a USB controller and a SATA controller of some kind.

They also lump the pinmux controller into this "misc" region, but the
pinmux controller is at a page aligned boundary, and has no other devices
sharing that page, so it can be split off into its own device untyped.

This also makes it easier to request that mapping from userspace.
2016-09-29 15:13:16 +10:00
amrzar
2cbc7123b6 SELFOUR-630:preliminary booting application processors
- update core detection code and Kconfig file
    - update kernel stack managment so that BSP does not use boot stack before IPI APs
    - move arch dependant data to a single structure
    - add cache line size to Kconfig
    - add cpu indexing and apic id mapping
    - boot APs to halting state
    - add guard for kernel stack if there is only one core
2016-09-28 16:10:25 +10:00
Adrian Danis
017cb20b78 arm: Move ACTLR functions out of pl2 headers
The ACTLR register is not a PL2 exclusive register, and is architecturally
defined to exist (although the contents of the register are implementation defined).
2016-09-27 09:34:29 +10:00
Anna Lyons
6f00118314 trivial: move ksKernelEntry definition
so debug builds can see it. Not sure how this built previously?
2016-09-23 15:13:38 +10:00
Adrian Danis
2a84b7d792 Merge pull request #120 in SEL4/sel4 from ~ADANIS/sel4:deviceuntyped to master
* commit '8e77cdb5e91e971f49747492a3350c2b443a3827':
  SELFOUR-421: Add padding for untyped in bootinfo
  SELFOUR-421: minor changes for c-refine
  SELFOUR-421: fix up boolean equality in Arch_sameObjectAs
  SELFOUR-421: added device check to sameObjectAs
  SELFOUR-421: Arch_createObject changed to use new user_data_device in ghostupdates for device pages
  SELFOUR-421 Introduce explicit device frames and untypeds
2016-09-23 04:16:22 +00:00
Joel Beeren
2d74ae7eb8 SELFOUR-421: Arch_createObject changed to use new user_data_device in ghostupdates for device pages 2016-09-23 14:15:09 +10:00
Adrian Danis
d507b2d39e SELFOUR-421 Introduce explicit device frames and untypeds
Kernel objects cannot be created from device untypeds, with the
exception of frames, which do not get zeroed and cannot be used
as an IPC buffer. Device untypeds additionally cannot be used
in the construction of ASID pools.

This then changes the API to the rootserver (i.e. bootinfo) to
send device untypeds instead of device frames. On ARM these
device untypeds are the same as the previously exported device
frame regions. On x86 PCI scanning is removed and all physical
memory addresses (that are not important for kernel integrity)
are released to the user.

In order to have bits in the frame and untyped caps on ARM the
number of software ASIDs had to be reduced from 2^18 to 2^17,
and the maximum untyped size reduced from 2^31 to 2^30
2016-09-23 14:15:08 +10:00
Kofi Doku Atuah
97a9b9ab9e Fix TCB Max-name-length macro
The previous macro computed to (0 - sizeof(tcb_t)). Basically a negative
number, which is just a really big unsigned number, so this macro was
basically allowing TCB naming of any length.
2016-09-22 15:37:34 +10:00
Adrian Danis
4044e20412 Revert "Merge pull request #358 in SEL4/sel4 from ~AZARRABI/sel4:multicore to master"
This reverts commit ce2f666bb8, reversing
changes made to dc183f96b8.
2016-09-22 14:22:18 +10:00
Adrian Danis
8ffc353172 Revert "[STYLE_FIX]"
This reverts commit d29f743bbc.
2016-09-22 14:22:08 +10:00
Adrian Danis
7f4694ec3e pc99: Update standalone config with CACHE_LN_SZ 2016-09-22 14:10:08 +10:00
Bamboo
d29f743bbc [STYLE_FIX] 2016-09-22 04:01:23 +00:00
Amirreza Zarrabi
ce2f666bb8 Merge pull request #358 in SEL4/sel4 from ~AZARRABI/sel4:multicore to master
* commit 'fbc071b4f11b3d7d423e26908a661f416b07cda2':
  SELFOUR-630:preliminary booting application processors - update core detection code and Kconfig file - update kernel stack managment so that BSP does not use boot stack before IPI APs - move arch dependant data to a single structure - add cache line size to Kconfig - add cpu indexing and apic id mapping - boot APs to halting state - add guard for kernel stack if there is only one core
2016-09-22 03:59:32 +00:00
Kofi Doku Atuah
df6fe18acf Link libsel4's macros.h into the kernel
Also, include libsel4 macros.h link in types.h.
2016-09-21 13:57:44 +10:00
amrzar
fbc071b4f1 SELFOUR-630:preliminary booting application processors
- update core detection code and Kconfig file
- update kernel stack managment so that BSP does not use boot stack before IPI APs
- move arch dependant data to a single structure
- add cache line size to Kconfig
- add cpu indexing and apic id mapping
- boot APs to halting state
- add guard for kernel stack if there is only one core
2016-09-21 12:14:10 +10:00
Hesham Almatary
9e104c1626 Merge pull request #353 in SEL4/sel4 from ~HALMATARY/sel4:BenchmarkReset to master
* commit '8808ba7fa00591528c1c730c6cfeb4ee6ef82e8b':
  Benchmark: Implement per-thread reset syscall
2016-09-20 00:22:49 +00:00
Kent McLeod
41ec5cf754 SELFOUR-537: Support for raspberry pi3 2016-09-19 15:53:53 +10:00
Stephen Sherratt
5a0bdb7480 Store active irq in global variable on kzm
The first time the irq number is read from the controller, the interrupt
is acknowledged. Subsequent reads of the irq number result in an invalid
irq number being read.

This modifies the kzm interrupt controller driver to save the current irq
number when it's first read from the interrupt controller, preventing the
need for future reads from the controller until the next interrupt arrives.
2016-09-14 13:43:35 +10:00
Hesham Almatary
8808ba7fa0 Benchmark: Implement per-thread reset syscall 2016-09-12 13:54:12 +10:00
Adrian Danis
4491cae521 SELFOUR-556: Rationalize BITS vs INDEX_BITS
s/PGD_BITS/PGD_INDEX_BITS
Current convention is to say that X_BITS is the log base 2
size of an object, not the log base 2 number of indices
2016-08-31 09:24:47 +10:00
Adrian Danis
35c50cfdaf SELFOUR-556: Rationalize BITS vs INDEX_BITS
s/PD_BITS/PD_INDEX_BITS
Current convention is to say that X_BITS is the log base 2
size of an object, not the log base 2 number of indices
2016-08-31 09:24:47 +10:00
Adrian Danis
3cde4fa8f3 SELFOUR-556: Rationalize BITS vs INDEX_BITS
s/SMMU_PD_BITS/SMMU_PD_INDEX_BITS
Current convention is to say that X_BITS is the log base 2
size of an object, not the log base 2 number of indices
2016-08-31 09:24:47 +10:00
Adrian Danis
f251953f60 SELFOUR-556: Rationalize BITS vs INDEX_BITS
s/PT_BITS/PT_INDEX_BITS
Current convention is to say that X_BITS is the log base 2
size of an object, not the log base 2 number of indices
2016-08-31 09:24:47 +10:00
Adrian Danis
1103e5a30b SELFOUR-556: Rationalize BITS vs INDEX_BITS
s/ASID_POOL_BITS/ASID_POOL_INDEX_BITS
Current convention is to say that X_BITS is the log base 2
size of an object, not the log base 2 number of indices
2016-08-31 09:24:47 +10:00
Adrian Danis
bbc98573e7 SELFOUR-556: Rationalize BITS vs INDEX_BITS
s/VTD_PT_BITS/VTD_PT_INDEX_BITS
Current convention is to say that X_BITS is the log base 2
size of an object, not the log base 2 number of indices
2016-08-31 09:24:47 +10:00
Adrian Danis
935b055c5e SELFOUR-556: Rationalize BITS vs INDEX_BITS
s/PDT_BITS/PDPT_INDEX_BITS
Current convention is to say that X_BITS is the log base 2
size of an object, not the log base 2 number of indices
2016-08-31 09:24:47 +10:00
Bamboo
f4188c6cd3 [STYLE_FIX] 2016-08-31 08:59:24 +10:00
Amirreza Zarrabi
92c95c8f0e Merge pull request #335 in SEL4/sel4 from ~AZARRABI/sel4:halt_recur to master
* commit '57f1352ff70cb2de18768174d257d151e4fd12e8':
  SELFOUR-614: calling halt() on the hikey platform results in infinite data abort SELFOUR-408: halt does not halt
2016-08-30 22:19:00 +00:00
Thomas Sewell
702f8c6902 Fix prototyping for constant address pointers.
Previous change adf91d4be0
introduces const inconsistently for two pointers.
2016-08-29 13:58:43 +10:00
Hesham Almatary
fb19c78e12 Benchmark: Share trace point log structure with the user 2016-08-26 11:13:05 +10:00
Hesham Almatary
5ef4cbfa7f Benchmark: Fix bug when trace points enabled with user-level log buffer
After the user-level log buffer addition, any code that writes to the log must
check if the user has already set a log buffer properly.
2016-08-25 10:54:11 +10:00
Bamboo
362e41f285 [STYLE_FIX] 2016-08-24 11:40:27 +10:00
Anna Lyons
ada2fc5f14 SELFOUR-624: fix ia32 debug build
- separate putDebugChar and putConsoleChar
- this only has effect on x86 where 2 serial ports are initialised by
  the kernel
- for arm, putConsoleChar just calls putDebugChar
2016-08-24 11:10:12 +10:00
Anna Lyons
e2bc428df4 style 2016-08-24 10:42:36 +10:00
Anna Lyons
ef00e98689 SELFOUR-615: arm entry point stubs 2016-08-24 10:42:36 +10:00
Adrian Danis
e0f8111faa move benchmark code from arch hooks 2016-08-24 10:42:36 +10:00
Adrian Danis
5466105cb9 call arch entry hook from C entry hook 2016-08-24 10:42:36 +10:00
Adrian Danis
4c57e6e577 define arch entry hooks instead 2016-08-24 10:42:36 +10:00
Adrian Danis
a217102b4e Consolidate benchmark entry/exit
Move the benchmark pre/post ambles into the now existing entry/exit
hook functions
2016-08-24 10:42:36 +10:00
Adrian Danis
3c05b79a6e Provide generic C entry/exit hook routines
It can be deseriable to run code before/after user mode, but
not have to write it in assembly. This commit adds such stubs
that get called as the first/last C code when coming in
and out of the kernel
2016-08-24 10:42:36 +10:00
amrzar
57f1352ff7 SELFOUR-614: calling halt() on the hikey platform results in infinite data abort
SELFOUR-408: halt does not halt

Remove assembly files for halt and idle thread and add wfi in armv.
2016-08-23 14:49:30 +10:00
Anna Lyons
c0817f4979 Merge pull request #339 in SEL4/sel4 from ~ALYONS/sel4:bye-lcok to master
* commit '5bd050f42fa6957a43db4ab20735f10d11f60bcd':
  trivial: x86 remove unused lock.[c|h]
2016-08-23 03:11:52 +00:00
Anna Lyons
5bd050f42f trivial: x86 remove unused lock.[c|h] 2016-08-23 11:41:26 +10:00
Anna Lyons
04e7eba3d0 Merge pull request #338 in SEL4/sel4 from ~ALYONS/sel4:SELFOUR-624 to master
* commit '49510f9df47ae75c764ac317f2d63abda7b2c784':
  SELFOUR-624: remove redundancy in io.[c|h]
2016-08-23 01:38:56 +00:00
Anna Lyons
49510f9df4 SELFOUR-624: remove redundancy in io.[c|h]
And clean up a bit while we are there
2016-08-23 08:00:47 +10:00
Kofi Doku Atuah
d33e48540c Use UNREACHABLE() instead of while(1) 2016-08-22 09:25:02 +10:00
Kofi Doku Atuah
2576eef364 x86: POPF immediately before SYSEXIT.
* Change restore_user_context() and fastpath_restore() to call POPF
  just before SYSEXIT.
* Also change the way registers are loaded such that we don't access
  memory that is not guarded by the current position of the stack pointer.

The reason for this change is that EFLAGS.TF, the Trap Flag, only takes
effect on the instruction AFTER the instruction that sets EFLAGS.TF. The
reason Intel/AMD did it this way is to allow the kernel to enable EFLAGS.TF
for userspace, without it taking effect on kernel instructions BEFORE
the CPU actually has returned to userspace.

EFLAGS.TF enables single-stepping. So the full picture is that since we
executed other instructions between POPF and SYSRET, those instructions
were triggering single-stepping IN the kernel. To solve this, we must
put POPF immediately before SYSRET.
2016-08-22 09:25:02 +10:00
Hesham Almatary
c3826e0efe SELFOUR-518: Benchmark - User-level log buffer, delete dump and size system calls
Given that the log buffer is now
(79291252a8) in user-level, the kernel doesn't have
to dump and send the size for users. Users have to take care of this.
2016-08-19 12:57:03 +10:00
Anna Lyons
f34f354a5d SELFOUR-617: one source of memory object sizes
Adds the following constants to libsel4
and uses them in the kernel.

seL4_SectionSize (arm)
seL4_SuperSectionSize (arm)
seL4_HugePageSize (x86 - pae)
seL4_LargePageSize (arm)
seL4_DataFault
seL4_InstructionFault
2016-08-17 12:42:38 +10:00
Hesham Almatary
79291252a8 Merge pull request #304 in SEL4/sel4 from ~HALMATARY/sel4:SELFOUR-518/UserLevelLogBuffer to master
* commit '16c3481109e2024d6fd65365ea94265ead37dcca':
  SELFOUR-518: User-level log buffer
  Benchmark: share and use KS_LOG_PPTR and PPTR_TOP for x86 and ARM
2016-08-16 00:34:21 +00:00
Hesham Almatary
16c3481109 SELFOUR-518: User-level log buffer
Remove global ksLog and use KS_LOG_PPTR instead

Benchmark - Log buffer: use global page table
2016-08-15 15:06:38 +10:00
Hesham Almatary
90628a75a7 Benchmark: share and use KS_LOG_PPTR and PPTR_TOP for x86 and ARM 2016-08-12 11:14:04 +10:00
Adrian Danis
7090a30e9a Merge pull request #325 in SEL4/sel4 from ~ADANIS/sel4:idle to master
* commit 'b727ede2c5c054277bf386566d4d966254883620':
  arm: Restore CPSR_IDLETHREAD usage
2016-08-10 05:56:17 +00:00
Adrian Danis
b727ede2c5 arm: Restore CPSR_IDLETHREAD usage
CPSR_IDLETHREAD was introduced in a5f61c7 to mask FIQs and asynchronous
aborts. Usage of this was lost in a merge, this commit restores the
usages in Arch_configureIdleThread, and updates CPSR_IDLETHREAD to
use the correct PMODE depending on whether the kernel is running
in hypervisor mode or not
2016-08-10 14:18:03 +10:00
Anna Lyons
dd7644f687 trivial: remove unused prototype 2016-08-10 13:48:01 +10:00
Anna Lyons
f33ae44e13 SELFOUR-612: one generic timer impl
This commit unifies 3 implementations of the arm
generic timer and cleans up existing code.
2016-08-10 07:16:46 +10:00
Anna Lyons
872cd4923a Fix problem in omap irq code
If an irq over max IRQ came in (unlikely) then it would result in an
array bounds over flow. gcc detected this as a result of the inlining of
the irq functions.
2016-08-09 16:18:34 +10:00
Anna Lyons
ce2c058f3d SELFOUR-607: inline remaining irq path functions 2016-08-09 16:18:34 +10:00
Adrian Danis
3b85582e7b SELFOUR-609: Introduce virq type in bitfield
Introduces a bitfield defined virq type that is then used to replace
manual bit packing of virtual irqs in the vcpu/vgic LR registers
2016-08-09 13:57:02 +10:00
Adrian Danis
adb0c08e23 arm/tk1: Explicitly define device region sizes
ARMSectionBits is variable depending on the current virtual addres space
scheme
2016-08-09 11:21:34 +10:00
Anna Lyons
0fd41318f1 trivial: fix tk1 release build 2016-08-09 09:52:26 +10:00
Anna Lyons
d727922b97 trivial: fix a few arm builds 2016-08-09 09:52:26 +10:00
Anna Lyons
652cafd729 trivial: fix beagle release build 2016-08-08 11:53:52 +10:00
Anna Lyons
4a486779ac SELFOUR-519: remove map_kernel_devices duplication
* move devices to static array in hardware.h
* use one higher level function to map them in.
2016-08-06 17:53:04 +10:00
Anna Lyons
ed61b3030c SELFOUR-607: remove stray irqInvalid def 2016-08-06 17:53:03 +10:00
Anna Lyons
9456b3e690 SELFOUR-519: remove more duplication in hardware.c
* move p_reg functions up a level
* move p_reg definitions to hardware.h
2016-08-06 17:53:03 +10:00
Anna Lyons
859091b414 SELFOUR-519: remove duplicated constants
* rename physBaseMapping to BASE_OFFSET
* because physBaseMapping was only used explicity in a few places
* move duplicated arm definions up a level
    - PPTR_TOP
    - PADDR_TOP
    - BASE_OFFSET
2016-08-05 17:08:21 +10:00
Rafal Kolanski
e105053581 Update prototype of maskInterrupt to match implementations.
The prototype will ultimately be removed, but the mismatch is presently
breaking verification.
2016-08-05 16:42:04 +10:00
Anna Lyons
6859e3bbd9 SELFOUR-607: unify irqInvalid for arm gic_pl390.h 2016-08-05 10:45:32 +10:00
Anna Lyons
ef2fca4bc1 SELFOUR-607: gic_pl390: inline and cleanup.
Inline non-boot irq functions called on the irq path.
This improves performance of interrupt paths through code locality.

Additionally, remove unused functions and use the BIT macro
rather than redefining it.
2016-08-04 16:10:11 +10:00
Adrian Danis
28175f77f9 x86: Split some arch functions in mode headers into arch and mode portions 2016-08-01 11:43:59 +10:00
Hesham Almatary
36a419eafe Merge pull request #302 in SEL4/sel4 from ~HALMATARY/sel4:SELFOUR-526 to master
* commit 'c6247d36a36d211ecb26ff906c37fcfbda0e4f99':
  SELFOUR-526: Refactor benchmark/debug syscall kernel entry
2016-07-28 04:06:05 +00:00
Hesham Almatary
c6247d36a3 SELFOUR-526: Refactor benchmark/debug syscall kernel entry 2016-07-28 10:29:42 +10:00
Adrian Danis
a5690c444b SELFOUR-551: Prevent vcpu_boot_init appearing to verification
When hypervisor extensions are not enabled the boot code cannot
actually call vcpu_boot_init as the symbol names do not even
exist. This is fixed be defining macros that expand to nothing
2016-07-28 09:01:22 +10:00
Adrian Danis
6d891b0a48 SELFOUR-551: Remove direct accesses to machine data structures
This commit wraps accesses to the vgic in functions that are marked as
DONT_TRANSLATE and uses a global constant (that is determined at boot time)
for the number of LR registers to prevent loops that have undefined bounds
2016-07-27 12:03:06 +10:00
Adrian Danis
8e0315f443 SELFOUR-551: Standardize VCPU capitalization
For acronyms seL4 other does CAPS or caps, this changes some functions
that were doing Caps
2016-07-27 11:23:36 +10:00
Adrian Danis
e4a732d53c SELFOUR-551: Remove unused arguments from decodeVCPUSetTCB 2016-07-26 16:01:18 +10:00
Adrian Danis
a185335e62 SELFOUR-551: Swap argument order of [di|a]ssociateVcpuTcb
Attempts to create some consistently across other functions that have
VCPU first in the name and also VCPU first in the argument list
2016-07-26 15:57:16 +10:00
Adrian Danis
2399465494 SELFOUR-561: s/ARM_HYP/CONFIG_ARM_HYPERVISOR_SUPPORT/ 2016-07-26 15:31:34 +10:00
Hesham Almatary
c4de796da1 Merge pull request #292 in SEL4/sel4 from ~HALMATARY/sel4:fix/ARMHypTraps to master
* commit '3ffa58aa1fb75c65fac4d1351bc6e014bdda2b64':
  Verification: don't translate functions that are re-implemented from assembly to C
  ARM Hyp: Fix fastpath_restore on ARM Hyp and implement slowpath and restore in C
  SELFOUR-526: ARM - Implement slowpath and restore_user_context in C
2016-07-23 04:06:01 +00:00
Adrian Danis
9c7f178f9f Merge pull request #274 in SEL4/sel4 from ~MFERNANDEZ/sel4:8dafd43a-daa8-4d38-ad7e-3ac425d50087 to master
* commit 'd36447b35f88705f796e17f47bf9033918fd2ed0':
  Mark strncmp as a pure function.
  Fix: Make VISIBLE expand to nothing for Clang.
2016-07-21 05:03:02 +00:00
Hesham Almatary
778043a73c ARM Hyp: Fix fastpath_restore on ARM Hyp and implement slowpath and restore in C 2016-07-19 15:27:26 +10:00
Kofi Doku Atuah
56030fc3cc x86: Fix cpuid family/model composition
Fixes a bug where previously MODEL_ID() was defined as:
    `#define MODEL_ID(x) ( ((x & 0xf0000) >> 16) + (x & 0xf0) )`

This was incorrect because (1) it didn't take into account the conditional
nature of the extended_model_ID, and (2) it's actually shifting the
extended_model_ID into the low bits and keeping the model_ID in the high bits,
when it should be the other way around.

This patch also introduces a foundation for more sane testing of CPU vendor,
family, model and brand_ID.
2016-07-15 17:12:25 +10:00
Hesham Almatary
d97603bd84 SELFOUR-566: Decouble seL4_DebugNameThread from CONFIG_PRINTING 2016-07-15 12:30:17 +10:00
Anna Lyons
bb4bda4b7f Merge pull request #286 in SEL4/sel4 from ~ALYONS/sel4:29e0070 to master
* commit '69f140a2268532523b4f52f26d2692963e61b468':
  trivial: remove duplicated setMRs_syscall_error
2016-07-13 01:33:13 +00:00
Anna Lyons
69f140a226 trivial: remove duplicated setMRs_syscall_error 2016-07-12 14:44:14 +10:00
Hesham Almatary
11916d7601 Merge pull request #278 in SEL4/sel4 from ~HALMATARY/sel4:UnifiedCEntry to master
* commit 'cee1268e9bf9619b60bd85cfda0a5d5306e8cf8a':
  [VER-619] Pass verification related to newly added built-in unreachable
  SELFOUR-545: x86 - cleanup c_traps.c file and use new traps.h
  SELFOUR-526: ARM - dummy unreachable statements after fastpath calls
  SELFOUR-526: ARM - Unify C entry point for system calls
2016-07-12 04:37:44 +00:00
Alejandro Gomez-Londono
cee1268e9b [VER-619] Pass verification related to newly added built-in unreachable 2016-07-12 14:32:47 +10:00
Adrian Danis
2b3a305ef8 SELFOUR-560: Remove unused io_page_directory cap 2016-07-08 16:55:33 +10:00
Adrian Danis
c50926b505 SELFOUR-559: Cleanup ARMPageUnmap for IO mappings
This commit moves setThreadState outside the 'perform' stage of the
invocation, and renames decodeARMIOUnmapInvocation to
performPageInvocationUnmapIO as it is actually doing a perform
and not a decode
2016-07-08 16:50:08 +10:00
Adrian Danis
5ca374b34c SELFOUR-558: Consistently name Unmap instead of UnMap 2016-07-08 16:27:02 +10:00
Adrian Danis
75299d05a9 SELFOUR-557: s/isIOSpaceFrame/isIOSpaceFrameCap/ 2016-07-08 16:17:09 +10:00
Adrian Danis
382dc2d60e SELFOUR-554: Update archCapIsPhysical
VCPU and IO page table caps were not added to archCapisPhysical,
this commit fixes that and marks them as physical objects
2016-07-08 15:38:33 +10:00
Adrian Danis
9bedaaa873 SELFOUR-552: Translate IO-ASIDs->PDs by table
Previously looking up the page directory base for a SysteMMU was
done by writing the ASID into the hardware and reading out the
currently set page directory for that ASID. This is confusing for
verification so this commit introduces a global translation table
for converting an ASID to a page directory.
2016-07-08 15:38:33 +10:00
Hesham Almatary
f9ea6383f3 SELFOUR-545: x86 - cleanup c_traps.c file and use new traps.h
Closes SELFOUR-545
2016-07-08 10:39:17 +10:00
Hesham Almatary
39c692cc35 SELFOUR-526: ARM - Unify C entry point for system calls 2016-07-06 10:32:26 +10:00
Matthew Fernandez
d36447b35f Mark strncmp as a pure function.
Simply a performance optimisation. This has no effect on functional behaviour.
2016-06-29 17:04:28 +10:00
Matthew Fernandez
fee3af3dd3 Fix: Make VISIBLE expand to nothing for Clang.
The `VISIBLE` macro is designed to selectively inhibit the effects of GCC's
whole program and link-time optimisations. This is necessary when a C function
is only referenced from a context outside the compiler's visibility, e.g. an
assembly file. As far as I can determine, Clang's link-time optimisations
already account for this possibility and do not need to have this information
manually indicated to them (see, for example, Linux's compiler support headers).

In any event, `__attribute__((visibility("default")))` is not equivalent to
`__attribute__((externally_visible))`, but is instead for controlling symbol
visibility in a library-like setting. This commit removes this incorrect
expansion.
2016-06-29 16:58:47 +10:00
Adrian Danis
e450377a6f Remove #include <stdbool.h>
seL4 has no stdbool.h and #including this is simply causing gcc to
pull in some 'random' stdbool outside of our control
2016-06-24 15:05:44 +10:00
Hesham Almatary
935e8054a6 SELFOUR-448 Benchmark: Add PMU IRQ support to ARM platforms
Currently supported boards are:
- imx6 (sabre)
- tk1 (Jeston)
- kzm
2016-06-24 12:44:09 +10:00
Hesham Almatary
09358f9b6a SELFOUR-448 Benchmark: Track thread's CPU utilisation time 2016-06-24 12:43:09 +10:00
Hesham Almatary
b986bbfccb Benchmark: armv6 implement armv_handleOverflowIRQ 2016-06-23 14:55:14 +10:00
Rafal Kolanski
b92d3f3caa Merge pull request #264 in SEL4/sel4 from arm_hyp to master
* commit 'e38288f805a434faf9052ecf96dd12838f8bf2bd': (76 commits)
  arm-hyp: Rearrange registerset to add compile_asserts
  arm-hyp: Simplify return conditions
  arm-hyp: Use BIT macro
  arm-hyp: Add preprocessor guard comments
  arm-hyp: Rearrange #ifdef
  arm-hyp: Comment on SCTLR_DEFAULT
  arm-hyp: Remove EXPECTED_TCB_SIZE
  trivial: style
  trivial: fix previous merge
  arm-hyp: Hide more definitions
  arm-hyp: Hide ARMPageMapIO invocation
  arm-hyp: Add conditions to invocations
  arm-hyp: Push ARM_HYP config check into traps.S
  arm-hyp: Hide more calls to isIOSpaceFrame
  arm-hyp: Hide calls to isIOSpaceFrame
  arm-hyp: Rename pd->pd_val in some instances
  arm-hyp: Pander to the C parser
  arm-hyp: Correct previous merge with master
  arm-hyp: Hide iospace caps being #ifdef
  arm-hyp: Remove unneccessary cast
  ...
2016-06-22 12:40:05 +00:00
Adrian Danis
2b347793e7 arm-hyp: Rearrange registerset to add compile_asserts 2016-06-22 16:25:06 +10:00
Adrian Danis
0830533513 arm-hyp: Add preprocessor guard comments 2016-06-22 16:25:06 +10:00
Adrian Danis
71bd25249e arm-hyp: Rearrange #ifdef 2016-06-22 16:25:05 +10:00
Adrian Danis
7a113a200d arm-hyp: Remove EXPECTED_TCB_SIZE
This definition was removed from master
2016-06-22 16:25:05 +10:00
Hesham Almatary
f488e25e51 SELFOUR-448: Benchmark: implement ccnt on armv6 2016-06-22 13:40:34 +10:00
Adrian Danis
cd96226421 Merge branch master into arm_hyp
Conflicts:
	include/arch/arm/arch/32/mode/object/structures.h
2016-06-21 14:39:32 +10:00
Hesham Almatary
8541b87326 SELFOUR-516 Remove EXPECTED_TCB_SIZE 2016-06-21 14:25:26 +10:00
Adrian Danis
82034bbc02 Merge branch master with arm_hyp 2016-06-17 09:57:07 +10:00
Adrian Danis
fd2f5ec85b Explicitly check if a capability is physical or not
Previously the return value of cap_get_capPtr was compared to 0 in
sameRegionAs to emulate a check in the abstract specification that
tests if the cap is a physical cap or not. Overloading 0 results
in a scenario where a legitimate deviceUntyped's children do not
get considered to be children because they have a capPtr of 0.

This change adds and explicit function that returns whether or not
a capability is physical or not, and uses that in sameRegionAs
2016-06-16 16:42:30 +10:00
Adrian Danis
11c665f53a arm-hyp: Hide more definitions 2016-06-16 15:34:07 +10:00
Matthew Fernandez
06041ab0ed Merge pull request #252 in SEL4/sel4 from ~MFERNANDEZ/sel4:3ce5c4cb-dbf7-4f3b-bb0d-a33908959c3f to master
* commit '7ad7cfba0a539a6a08b437e368fc67d92b0b7bac':
  Fix standalone debug compilation on ARMv6.
2016-06-16 04:48:07 +00:00
Adrian Danis
9a3a450419 x86: Use IO page table size defined in libsel4 2016-06-16 14:20:51 +10:00
Matthew Fernandez
7ad7cfba0a Fix standalone debug compilation on ARMv6.
This commit moves a declaration of `ksKernelEntry` such that it is now only
guarded by `DEBUG`, not additionally `CONFIG_PRINTING`. This allows the kernel
to be built standalone with debugging enabled using the following invocation:

    DEBUG=1 TOOLPREFIX=arm-none-eabi- CPU=arm1136jf-s PLAT=imx31 ARCH=arm \
      ARMV=armv6 make
2016-06-16 12:09:17 +10:00
Adrian Danis
9b7d6e9ce7 arm-hyp: Rename pd->pd_val in some instances
To aid the C parser any variable named 'pd' should be pde_t*, this
renames usages of pd where it is a word_t to be pd_val
2016-06-14 10:52:31 +10:00
Adrian Danis
1d777adbe4 arm-hyp: Correct previous merge with master 2016-06-08 15:11:16 +10:00
Adrian Danis
e67be6acee Merge branch master into arm_hyp
Conflicts:
	src/plat/exynos5/machine/hardware.c
	src/plat/tk1/machine/hardware.c
2016-06-08 15:04:03 +10:00
Adrian Danis
48555c3864 arm-hyp: Hide iospace caps being #ifdef
These cap type existing, even if unused, break the original verification
2016-06-08 14:53:24 +10:00
Adrian Danis
2b90ed467b Merge pull request #236 in SEL4/sel4 from ~ADANIS/sel4:x86 to master
* commit 'b1e7e073df53639c81cb7b9ae4b2f568afa8eb16':
  x86: Move xsetbv to general header
2016-06-08 01:31:48 +00:00