Commit graph

580 commits

Author SHA1 Message Date
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