Commit graph

919 commits

Author SHA1 Message Date
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
Adrian Danis
c4dcc75c56 arm-hyp: Remove unneccessary cast
This cast causes problems for the C parser
2016-06-08 08:59:52 +10:00
Adrian Danis
b1e7e073df x86: Move xsetbv to general header
The xsetbv and write_xcr0 wrapper are not 32-bit specific and were
placed in the wrong location originally.
2016-06-07 15:31:49 +10:00
Adrian Danis
6d6b047b2d Minor fixes for other ARM platforms 2016-06-07 13:35:55 +10:00
Anna Lyons
c5b6a6a58a Refactor duplicated code in hardware.h
One copy to rule them all.
2016-06-07 12:01:14 +10:00
Anna Lyons
c9684b964f trivial: consolidate timer function declarations
This moves all timer function declarations to a single
header instead of duplication them for each platform
2016-06-07 11:50:11 +10:00
Anna Lyons
0ec5e93771 SELFOUR-402: remove isReservedIRQ
While provided by each hardware platform this function is never called.
2016-06-07 11:50:11 +10:00
Hesham Almatary
efde16c864 fix: kernel debug build fails without ksKernelEntry there 2016-06-07 10:17:46 +10:00
Hesham Almatary
8a159d70cd Merge pull request #228 in SEL4/sel4 from ~HALMATARY/sel4:BenchmarkSharedUser to master
* commit 'a84964ba4cd8e6ca4a9527041a8cfddae27a0c3c':
  SELFOUR-446 Benchmark: Share kernel entry types with user-level
2016-06-06 23:32:48 +00:00
Hesham Almatary
a84964ba4c SELFOUR-446 Benchmark: Share kernel entry types with user-level 2016-06-07 09:19:31 +10:00
Adrian Danis
5f0ae410f4 arm-hyp: Minor cleanups
Cleanup some small licensing, whitespace and configuration details
2016-06-06 11:51:58 +10:00
Adrian Danis
c64ae63e5c Merge branch master into arm_hyp 2016-06-06 11:51:46 +10:00
Adrian Danis
6915cf03be x86: Update autoconf.h for standalone builds 2016-06-03 09:42:37 +10:00
Adrian Danis
93bca86e40 x86: Introduce support for XSAVE feature set
The XSAVE feature set is the future proof way for x86 CPUs to
manage extended CPU state. Extended state is MMX, FPU, SSE, AVX etc
registers. This is a replacement for the current FXSAVE and the
512 byte FPU region.

XSAVE introduces a few problems that this commit has to address

* The alignment of the XSAVE region is 64bytes, instead of the 16
  bytes of the FXSAVE region
* XSAVE region size is dependent on the desired features, which
  are detected at run time
* There are multiple variants of the XSAVE instruction that have
  different potential optimizations, but are not always supported

The solutions to these are

* Re-order the FPU state and user registers in the user context
  struct so that the new XSAVE region is first, and is thus
  aligned to 64bytes without needing lots of padding
* Provide config options for desired features (including XSAVE
  instruction variant) and required XSAVE region size. These
  are checked at boot time to ensure the CPU meets these
  requirements
2016-06-02 11:06:37 +10:00
Adrian Danis
96bcba168b x86: Add functions for writing to the extended control registers 2016-06-02 11:06:37 +10:00
Adrian Danis
1cb58c1f37 Add config_default macro
This macro allows for using the value of a CONFIG_ variable in situations
where it may not be defined. This could be due to it being a dependency
on another CONFIG_ variable that is not currently defined. This arrises
from code blocks like

if (config_set(CONFIG_FOO)) {
    return CONFIG_VAR_DEPENDS_ON_FOO;
}

This will not compile when CONFIG_FOO is not set. Using

return config_default(CONFIG_VAR_DEPENDS_ON_FOO, 42);

Provides a way for this to be built
2016-06-02 11:06:07 +10:00
Adrian Danis
e667a7e04b x86: Add missing CR4 bit definition 2016-06-02 11:06:07 +10:00
Adrian Danis
58f26d2f30 x86: Add missing CPUID functions 2016-06-02 11:06:07 +10:00
Adrian Danis
2516e65cfa x86: Add XSS MSR definition 2016-06-02 11:06:07 +10:00
Adrian Danis
4d76c71e31 x86: Calculate register offset from structures
The address being calculated is the end of the user context array.
There is no need for this to be done as a magic number offset
from the tcb_t, this commit takes an index into the actual array,
using the constant that is defined as the length of that array.
2016-06-02 11:06:07 +10:00
Adrian Danis
b001bc4489 Merge branch 'master' into 'arm_hyp'
Conflicts:
	Kconfig
	libsel4/tools/syscall_stub_gen.py
	src/plat/exynos5/machine/hardware.c
	src/plat/tk1/machine/Makefile
	src/plat/tk1/machine/hardware.c
2016-06-02 10:57:12 +10:00
Hesham Almatary
46698d5383 Merge pull request #192 in SEL4/sel4 from ~HALMATARY/sel4:feature/syscall_bench2 to master
* commit 'bcf0a235b114fe8c24c3a187f55c67c373f259d3':
  SELFOUR-446 Unify code base for trace points and track feature
  SELFOUR-446 Benchmark: Track interrupts and user/vm faults
  Fix: move seL4_LogBufferSize to the correct file
  SELFOUR-446 Benchmark: Track syscall feature
2016-06-02 00:53:20 +00:00
Hesham Almatary
bcf0a235b1 SELFOUR-446 Unify code base for trace points and track feature 2016-06-02 10:49:25 +10:00
amrzar
128768edac Add support for armV8 and Hikey 32bit 2016-06-01 14:15:29 +10:00
Hesham Almatary
7cbaeb8ed0 SELFOUR-446 Benchmark: Track interrupts and user/vm faults 2016-05-31 08:54:57 +10:00
Yanyan Shen
dfb3551eef arm-hyp/tk1: address review comment 2016-05-30 16:33:28 +10:00
Yanyan Shen
c85094bb75 arm-hyp/tk1: add guards so other plats can compile. 2016-05-30 15:37:22 +10:00
Yanyan Shen
55f8b14417 arm-hyp/tk1: address review comments. 2016-05-27 11:00:01 +10:00
Yanyan Shen
27ecdffe3c arm-hyp/tk1: address review comments. 2016-05-27 00:16:53 +10:00
Adrian Danis
16b1bcf0a8 SELFOUR-489: Remove 'bound' field from TCBs
Its probable this was meant to be a boolean flag to represent
whether or not the TCB had a bound notification object. However,
this field is unused and its presence is confusing.
2016-05-26 10:17:19 +10:00
Yanyan Shen
5650a8fa84 arm-hyp/tk1: make style 2016-05-25 16:35:02 +10:00
Yanyan Shen
bb9e84e6ec arm-hyp/tk1: add default SMMU translation for VM 2016-05-25 16:31:26 +10:00
Hesham Almatary
fc1feb670e SELFOUR-446 Benchmark: Track syscall feature
Benchmark feature that currently:
- Keeps track of system calls info
- Start time
- Duration
- Capability type
- Invocation tag
- Log the number of invocations of each system call*
- Log the number of invocations for each capability type per syscall.
- Has 3 new syscalls (dump, reset, get size).
- This new feature uses the existing log buffer (which is 1MiB for x86
and ARM). Since the number of syscall invocations is not
deterministic, the logged number of invocations is limited by the size
of the buffer. I suggested to enable the users to pass their own
user-level buffer, to enable more flexibility, later.
- ENABLE_BENCHMARKS is now a parent config option of trace points and
system call track features, they can't be used at the same time.
2016-05-25 13:47:49 +10:00
Adrian Danis
9aeee98792 SELFOUR-449 Implement user stack trace on double fault 2016-05-25 12:07:23 +10:00
Adrian Danis
bbdf7a89a7 Mark tlbLockCount as visible so it is not discarded
This variable is referenced in assembler and needs to not get discarded
by the optimizer prior to linking.
2016-05-24 08:46:54 +10:00
Felix Kam
39a2c4f108 Merge pull request #181 in SEL4/sel4 from ~FKAM/sel4:lockTLBEntryPatch to master
* commit 'b9a7f3c9a13ff7e997e28b63676a1dd2a1b7f381':
  Make lockTLBEntry comply with the decompiler
2016-05-23 06:30:42 +00:00
Adrian Danis
0c1d959b0e x86: Define Additional MSRs
Define these MSRs in preparation for their use on the x86_64 port
2016-05-23 14:17:36 +10:00
Yanyan Shen
17ec138bf2 arm-hyp/tk1: enable SMMU interrupts 2016-05-20 17:05:44 +10:00
Yanyan Shen
a56c5ff16e Merge branch 'feature/arm_hyp_tk1' of ssh://bitbucket:7999/~yshen/sel4k into feature/arm_hyp_tk1 2016-05-20 12:24:52 +10:00
Yanyan Shen
b1e4f92fbd arm-hyp/tk1: reserve the SMMU interrupt 2016-05-20 12:23:51 +10:00
Yanyan Shen
11720f23ad arm-hyp/tk1: fix bugs found during testing 2016-05-20 00:00:46 +10:00
Adrian Danis
086b5192c5 Merge pull request #180 in SEL4/sel4 from ~ADANIS/sel4:printing to master
* commit '1287590e9736f48e30b42fe678f2bf081a8c1874':
  Correct separation of printing and debug builds
2016-05-19 00:17:03 +00:00
Felix Kam
b9a7f3c9a1 Make lockTLBEntry comply with the decompiler
lockTLBEntry, an assembly function, had tlb_lock_count as a symbol that
needed to be placed sufficiently close to be loaded and stored with
offset-from-pc addressing. When assembled, the symbol would turn up
between functions, as opposed to within a literal pool (it's a variable,
not a constant) or the .bss / data sections. The decompiler doesn't
handle that use case, and likely won't.  This change turns
tlb_lock_count into a C global variable (so that it will be placed in
the .bss / data sections), and splits lockTLBEntry into two parts so the
critical section will still fit in a 64-byte aligned region, and
therefore be guaranteed to live within a single page.
2016-05-18 16:53:13 +10:00
Adrian Danis
1c1e976de2 x86: Improve translation invalidation
x86_64 (with PCIDs enabled) supports a more fine grained invalidation
approach for the TLB and Page Structure Cache. This change expands
the number and kinds of information passed for certain invalidations,
and provides an implementation of this for ia32.
2016-05-18 13:49:28 +10:00
Adrian Danis
1287590e97 Correct separation of printing and debug builds
Fixes some build issues with 541289a326
as well as further allowing debugging (via the capdl interface) to
happen when printing is turned off.
2016-05-17 15:10:08 +10:00
Yanyan Shen
508e87477f arm/tk1: connect objects with SMMU invocations 2016-05-17 12:16:34 +10:00
Adrian Danis
541289a326 Further separate 'release' and 'verification' builds
Originally building the kernel was largely considered to be done in
one of two ways
1. Release build with no assertions, no debug symbols and no printing.
   This was generally considered to be a 'verified' build
2. Debug build with assertions, debug symbols and printing

Since then various options were added, such as the 'code injection'
option, which we wanted on builds that did not have assertions or
other options that affected performance. As such it did not depend
upon a debug build and had large warning signs saying that enabling
this in a release build would not give you a verified or trusted
kernel.

Most recently the ability to print from the kernel in release mode
was added. For the same reason that tying the ability to print with
the performance reduction of various debugging was not always desireable.

This change attempts to unify the current state and have a single top
level option to enable a 'verification friendly' build. All other
options (assertions, printing, code injection) then depend upon
this configuration not being set.
2016-05-17 10:51:55 +10:00
Yanyan Shen
55e58e1a41 arm/tk1: a checkpoint for iospace.c 2016-05-13 22:40:13 +10:00
Yanyan Shen
879d9724c1 arm/tk1: a checkpoint for SMMU implementation 2016-05-13 16:42:53 +10:00
Yanyan Shen
c4692926a8 arm_hyp/tk1: address review comments 2016-05-10 13:15:08 +10:00
Yanyan Shen
454efecbcf Merge branch 'feature/arm_hyp_tk1' of ssh://bitbucket:7999/~yshen/sel4k into feature/arm_hyp_tk1 2016-05-04 17:05:34 +10:00
Yanyan Shen
fa9b6e4312 arm/tk1: addresses/interrupts for hyp mode 2016-05-04 16:53:27 +10:00
Yanyan Shen
c13eeffddc arm/tk1: add system MMU structures for TK1 2016-05-04 16:42:35 +10:00
Yanyan Shen
4d8f933aba arm/arm_hyp: replace macros with explicit inline 2016-03-24 12:52:38 +11:00
Yanyan Shen
67bcf2357c arm_hyp: rm ARM_HYP ifdefs; func inline assembly
vcpu.c:
encapsulate inline assembly into inline functions that added to
device_pl2.h file.

other files:
replace #ifdef ARM_HYP with config_set(ARM_HYP)
2016-03-24 12:42:19 +11:00
Yanyan Shen
d195a02b91 arm_hyp: remove unused function declaration.
remove map_hypervisor_devices function declaration.
2016-03-24 12:42:19 +11:00
Yanyan Shen
cbb6bf15d1 arm_hyp: add file to contain hyp mode inline funcs
machine_pl2.h:
new place for hyp mode inline functions.

boot.c:
replace #ifdef ARM_HYP with config_set(ARM_HYP).

vcpu.h, machine_pl2.h:
add empty functions when ARM_HYP is not defined to
pass compilation.
2016-03-24 12:42:19 +11:00
Adrian Danis
6932e6a725 Merge branch master into arm_hyp 2016-03-22 16:48:52 +11:00
Yanyan Shen
cc729fab45 Merge pull request #145 in SEL4/sel4 from ~YSHEN/sel4k:feature/tk1 to master
* commit 'b9410822c17886309021671ac547589f4f76db05':
  arm/tk1: add support for Nvidia Tegra K1 board
2016-03-22 05:31:49 +00:00
Yanyan Shen
b9410822c1 arm/tk1: add support for Nvidia Tegra K1 board 2016-03-22 16:23:37 +11:00
Anna Lyons
9ae867cbf2 SELFOUR-435: change kernel timer from GPT11 to 9
GPT1-9 are configured by uboot to run at 13Mhz,
while GPT10-11 are not and run with a much slower clock.
2016-03-17 09:54:40 +11:00
Yanyan Shen
3287bb0e2d Merge branch 'arm_hyp' into feature/arm_hyp_tk1 2016-03-14 16:49:30 +11:00
Yanyan Shen
4178a9e79f arm/arm_hyp: replace macros with explicit inline 2016-03-14 16:47:40 +11:00
Yanyan Shen
6b2c9ade2a Merge branch 'feature/tk1' into feature/arm_hyp_tk1 2016-03-14 16:45:28 +11:00
Yanyan Shen
b0b5d5aaab arm/tk1: add support for Nvidia Tegra K1 board 2016-03-14 16:01:20 +11:00
Yanyan Shen
8e2e8db976 arm_hyp: rm ARM_HYP ifdefs; func inline assembly
vcpu.c:
encapsulate inline assembly into inline functions that added to
device_pl2.h file.

other files:
replace #ifdef ARM_HYP with config_set(ARM_HYP)
2016-03-03 16:03:22 +11:00
Yanyan Shen
1cdc450cb3 arm_hyp: remove unused function declaration.
remove map_hypervisor_devices function declaration.
2016-03-03 15:57:13 +11:00
Yanyan Shen
3abf177c5b arm_hyp: add file to contain hyp mode inline funcs
machine_pl2.h:
new place for hyp mode inline functions.

boot.c:
replace #ifdef ARM_HYP with config_set(ARM_HYP).

vcpu.h, machine_pl2.h:
add empty functions when ARM_HYP is not defined to
pass compilation.
2016-03-03 13:49:45 +11:00
Joel Beeren
702930246a Merge pull request #53 in SEL4/sel4 from ~ALYONS/sel4:reduce-dup-bi to master
* commit '289bf92bf0713f9060f3a43c0ee91f2a06d9e4d7':
  SELFOUR-114: remove bootinfo.h duplication
2016-03-02 23:47:20 +00:00
Adrian Danis
602f536940 x86: Change some PHYS_CODE to BOOT_CODE
The functions pit_init and pit_wait_wraparound were previously marked as
PHYS_CODE, despite being called from BOOT_CODE elsewhere. This bug has
been present for some time but can be masked by the compiler inlining
all the involved functions, which is what typically happens.
2016-03-02 11:11:48 +11:00
Anna Lyons
289bf92bf0 SELFOUR-114: remove bootinfo.h duplication 2016-03-01 17:25:22 +11:00
Yanyan Shen
81fe0a7fa6 arm/imx7: add support for iMX7-based Sabre board 2016-02-25 15:07:53 +11:00
Adrian Danis
e61a1056cc SELFOUR-56: Remove diminish rights from IPC
Diminish rights were to prevent a user from sending a writeable
cap over a read only endpoint. It turns out this 'security' can
be worked around without difficulty (by putting caps in a cnode
and sending the cnode) making the current diminish rights
implementation functionally useless.

Removing diminish rights has the benefit of simplifying all the
IPC paths.
2016-02-23 13:58:48 +11:00
Adrian Danis
22623be2f8 Merge branch master into arm_hyp
Conflicts:
	include/arch/arm/arch/32/mode/object/structures.h
	libsel4/sel4_arch_include/aarch32/sel4/sel4_arch/types.h
	src/arch/arm/32/model/statedata.c
2016-02-22 15:55:31 +11:00
Adrian Danis
d9329d6ba3 Merge commit '417e3e1ccf57f046dcd1e5f5e775f362ddf8bca0' into arm_hyp
Conflicts:
	src/arch/arm/32/kernel/vspace.c
2016-02-22 15:55:10 +11:00
Adrian Danis
d0a42bbf49 Merge commit '812a73a9f58670cb18c36694d505dcd742c2ba8b' into arm_hyp 2016-02-22 15:02:12 +11:00
Adrian Danis
9e35b398cc x86: Refactor vspace code to have verification friendly invocations 2016-02-17 09:43:54 +11:00
Adrian Danis
dd59353944 x86: More portable user mode IO port restriction
For x86-64, to disable IO instructions in user mode requires a
IO permission map being set up properly in TSS. Setting the
IO map base field of TSS larger than the TSS works for 32-bit, but
not 64-bit. This commit sets up a IO permission map usable for both
32-bit and 64-bit kernel and changes the TSS to use the mapping.
The IO permission bitmap is appened to the bitfield generated tss_t,
resulting the tss_io_t structure.
2016-02-15 16:08:51 +11:00
Adrian Danis
775ca8c929 x86: Fix clflush invocation in flushCacheLine
This fixes flushCacheLine to flush the line pointer to be vaddr,
not the cache line of the stack location holding the vaddr pointer
2016-02-15 15:57:45 +11:00
Adrian Danis
1ca0fa1fc2 imx6: Update autconf.h for standalone kernel compile 2016-02-12 14:08:08 +11:00
Robert Kaiser
c0bc7d8fc1 Added changes for Wandboard 2016-02-12 11:54:36 +11:00
Adrian Danis
d20ca20a13 x86: Rename ia32->x86
This is a stylistic commit to make names of variables/constants and
functions in the kernel more consistent. That is, things that are
not IA32 specific, but are generic x86, get renamed to having an
x86 name
2016-02-10 17:02:06 +11:00
Adrian Danis
eb5b792bca trivial: style 2016-02-10 11:48:31 +11:00
Adrian Danis
cfcaf49c2d SELFOUR-399: object sizes and globals frame addr should come from the same source 2016-02-10 09:13:16 +11:00
Adrian Danis
3c9f304a40 x86: Update autoconf.h for standalone kernel builds 2016-02-04 15:00:49 +11:00
Adrian Danis
be6b6be119 x86: FS/GS base MSRs
when FS/GS_BASE_MSR are used to set the base addreses,
user applications should not touch FS/GS regiters; so
the kernel should load proper selectors once, establishing
limits and other attributes for the segments.
2016-02-04 13:39:16 +11:00
Adrian Danis
fa3989eff6 trivial: style 2016-02-04 12:12:36 +11:00
Adrian Danis
91b38f371e x86: Rename mistake usage of x86->ia32 to fix build errors 2016-02-04 11:32:05 +11:00
Adrian Danis
d53aa04fd8 x86: Abstractions for setting up benchmarking log 2016-02-04 10:30:55 +11:00
Adrian Danis
9b7a8405c2 Change bootinfo to have generic slot region for paging structures
Current bootinfo defines two slot regions for paging structures,
one for page directories and one for page tables. This does not
easily generalise for N levels of paging structures. This change
uses a single region that has a known order of objects for however
many levels exist
2016-02-03 16:16:00 +11:00
Robert Kaiser
a2f414dc18 Run idle thread in system mode (rather than supervisor)
Add platform dependent code (using macros from autoconf.h)
to make idle thread run in low power mode on all ARMv7
and ARMv6 except for the KZM board: That board does not
seem to support low power mode although the chip should,
according to he manual

Part of SELFOUR-419
2016-02-03 16:07:55 +11:00
Adrian Danis
417e3e1ccf Merge pull request #103 in SEL4/sel4 from ~AZARRABI/sel4:aarch32 to master
* commit '3959ced3418c08d174e3c7533fc7459d2286fe15':
  Remove mode dependant codes for initial thread from architecture dependant boot codes
2016-02-03 04:14:34 +00:00
Adrian Danis
bddd804a6e x86: IOAPIC/MSI syscalls
Restructure the x86 interrupt handling to allow for a more flexible
method of using IOAPIC and MSI interrupts. The essence of this change
is to allow for the user to pick, for both IOAPIC and MSIs, which
CPU vector to use. Additionally there is future support, in the API,
for seL4 to eventually protect MSI interrupts with the vt-d interrupt
routing tables.

API behaviour for legacy systems using the PIC is preserved

Part of SELFOUR-281
2016-02-02 15:58:18 +11:00
amrzar
3959ced341 Remove mode dependant codes for initial thread from architecture dependant boot codes 2016-02-02 15:48:42 +11:00
Adrian Danis
95c33147c0 Merge branch master into arm_hyp
Conflicts:
	Kconfig
	include/arch/arm/arch/fastpath/fastpath.h
	include/arch/arm/arch/machine.h
	include/arch/arm/arch/machine/hardware.h
	include/arch/arm/arch/machine/registerset.h
	include/arch/arm/arch/model/statedata.h
	include/arch/arm/arch/object/structures.bf
	include/arch/arm/arch/object/structures.h
	libsel4/arch_include/arm/sel4/arch/exIPC.h
	libsel4/arch_include/arm/sel4/arch/types.h
2016-02-01 14:57:37 +11:00
Adrian Danis
0107e60169 ia32: Reduce total number of ASIDs from 16bits to 12bits
This change brings the ia32 api in line with the planned x64 api,
which will have 12bits of ASID. Aside from providing a consistent
API, this change also frees up bits in the frame cap that will
allow further x64 changes to be unified.
2016-01-29 15:46:51 +11:00
Adrian Danis
4f7ac5e196 Merge pull request #95 in SEL4/sel4 from ~ADANIS/sel4:used to master
* commit '21d9f7aeabce0c47033b402c07ec78a36c69c2f4':
  Add 'used' attribute to memcpy to prevent optimizing out
2016-01-27 23:39:01 +00:00
Adrian Danis
21d9f7aeab Add 'used' attribute to memcpy to prevent optimizing out
Some versions of GCC replace a struct copy with a call to 'memcpy',
which it is fully in its rights to do. Unfortunately on ARM platforms,
that have no direct calls to memcpy, the optimizer (in the presence
of -fwhole-program) drops the implementation of memcpy, even as it
is outputting calls to it.

Add the USED attribute prevents the optimizer from dropping the
function eagerly.
2016-01-28 10:36:24 +11:00
amrzar
3fc76c25f6 Rearranging headers for aarch32 to 32/mode/* 2016-01-27 16:32:48 +11:00
Adrian Danis
915a404d5c libsel4: Provide a layer of indirection around types.bf and shared_types.bf to allow for 64-bit variants 2016-01-21 13:31:54 +11:00
Adrian Danis
a701481095 Merge pull request #85 in SEL4/sel4 from ~AZARRABI/sel4:aarch32 to master
* commit '1a1110a0949c76a2d372e2bba6b2526898c51a68':
  Modify Kconfig and Makefile for aach32 as sel4_arch libsel4: updates to include aarch32 as sel4_arch
2016-01-19 05:17:46 +00:00