Commit graph

919 commits

Author SHA1 Message Date
Adrian Danis
a5fa9570fc Change hasVCPU to generic archInfo boolean in public interfaces
The Arch_hasVCPU function instead of cheaking for whether a thread has a VCPU was
specifically checking for whether a thread on aarch32 had a VCPU, as that was the
condition needed to be passed into sanitiseRegister. This made the implementation
on x86 extremely confusing as Arch_hasVCPU was implemented to return false due to
there being no need for sanitiseRegister on x86 to know whether there was a vcpu.

This commit changes hasVCPU variables to be an abstract archInfo boolean that can
be used arbitrarily by an architecture. Arch_hasVCPU function was also changed to
become Arch_getSanitiseRegisterInfo whose result only passed to sanitiseRegister.
2017-05-04 11:18:03 +10:00
Adrian Danis
8523406990 Use unverified_compile_assert in cases where OFFSETOF is used
OFFSETOF is not supported by the C parser, and so regular compile_assert may not be used
2017-05-04 11:13:31 +10:00
Adrian Danis
038018be65 Use OFFSETOF instead of directly using __builtin_offsetof 2017-05-04 11:13:31 +10:00
Adrian Danis
019f965e7d arm: Use unverified_compile_assert instead of manual #ifdef wrapping 2017-05-04 11:13:31 +10:00
Adrian Danis
ae0937a053 Add unverified_compile_assert
This version of compile_assert is not expanded during verification builds and
can be used in cases where you would like an assertion that contains syntax
that is not supported by the C parser
2017-05-04 11:13:31 +10:00
Adrian Danis
52834951dc Add missing include in assert.h 2017-05-04 11:13:31 +10:00
Adrian Danis
0a0c27227e x86: Remove trailing semicolons in asm statements
These semicolons are not actually necessary, and cause problems for the C parser
2017-05-04 11:13:31 +10:00
Kent McLeod
d13544c737 SELFOUR-865: Pass memory map information to user 2017-05-03 16:17:03 +10:00
Adrian Danis
551e73f22f Check for configuration variables being 'defined' instead of 'true'
This is to conform with existing style of checking configuration options
2017-05-03 10:35:44 +10:00
Anna Lyons
beddca16cd libsel4: Add seL4_FastMessageRegisters
This allows benchmarks and utility code to only set registers in the ipc
buffer as required.
2017-05-02 11:08:11 +10:00
Rafal Kolanski
0f0680835c arm fastpath: reorder vcpu_switch / armv_contextSwitch_HWASID
In the original slow path, armv_contextSwitch_HWASID shoots first.

Verification can't reorder machine operations on hardware state we don't
model. This puts the fastpath into the same order as the slow path.
2017-04-29 19:53:32 +10:00
Joel Beeren
d7cf973002 Refactor sanitiseRegister to take a bool rather than a (tcb_t *).
This involves adding a function to determine if a tcb has a vcpu, and
makes verification a lot easier for arm-hyp.
2017-04-27 15:50:22 +10:00
Adrian Danis
b861f28498 Move isRunnable from thread.c to thread.h
This helper function is useful beyond just thread.c
2017-04-26 09:36:43 +10:00
Adrian Danis
353f05747f arm: Pass 'call' down to invokeVCPUReadReg
invokeVCPUReadReg should not be setting message registers for the return message unless
the user performed a call. In doing so we must refactor the call to readVCPUReg to
outside the introduced `if` condition since, as it performs machine operations, it
should always happen
2017-04-24 15:54:32 +10:00
Adrian Danis
43dea0680c x86: Correct multiboot info definition
The fields in the multiboot_info structure have precise sizes and should not use pointers
types as these sizes change between ia32 and x86_64 builds. This commit changes such
fields to be the correct fixed size uint32_t
2017-04-20 16:22:52 +10:00
Anna Lyons
8c02bc1301 x64: implement seL4_BenchmarkFlushCaches
by moving the ia32 implementation up a level to x86
and implementing the syscall stub.
2017-04-11 14:14:10 +10:00
Anna Lyons
37fef55a27 trivial: remove unused 'bound' field from ntfn 2017-04-11 13:59:54 +10:00
Adrian Danis
4e3839e315 Move standalone autoconf.h files out of include directories
When performing non standalone builds a separate autoconf.h file is generated and defines
the configuration of the kernel. Currently the directory with that file as well as the
kernels include/plat/${PLAT} directory are both listed as include directories to the
compiler. Due to the directory with the generated autoconf.h being earlier in the -I
list the generated autoconf.h will be used in preference to the standalone autoconf.h.

Relying on the order of -I directives is too unstable and so this commit moves the
autoconf.h files to a dedicated configs directory, which is only added as a -I
directive if a standalone build is being performed.
2017-04-10 11:16:57 +10:00
Rafal Kolanski
73db41687e arm hyp: make invokeVCPUInjectIRQ index arg unsigned long
Argument passed to it comes directly from a word_t so it shouldn't be
signed. Also, verification.
2017-04-06 13:45:43 +10:00
Adrian Danis
0abc720277 s/DEBUG/CONFIG_DEBUG_BUILD/
DEBUG definition is not supposed to be used in the kernel, rather CONFIG_DEBUG_BUILD,
which can be toggled separately to user notion of DEBUG
2017-04-06 10:43:24 +10:00
Stephen Sherratt
b70374eb48 Add debug_printUserState 2017-04-05 16:54:50 +10:00
Rafal Kolanski
7680bab494 tk1: disable SMMU in autoconf.h
This is overwritten by KConfig but used on verified platform where the
SMMU is likely to come much later.
2017-04-05 09:50:52 +10:00
Rafal Kolanski
9b17e8afca tk1: maxIRQ off-by-one w.r.t. N_INTERRUPTS 2017-04-04 15:59:40 +10:00
Rafal Kolanski
9098528719 tk1: set CONFIG_NUM_DOMAINS=16 for verified kernel 2017-04-04 11:55:07 +10:00
Bamboo
c5b52b044c [STYLE_FIX] 2017-04-03 05:17:15 +00:00
Kofi Doku Atuah
4b491dcf0c SELFOUR-836: arm-hyp: Config option for saving/loading vs trapping debug state
Provides a configuration option for enabling HDCR.TD* traps, or saving and loading debug
state on VCPU switches. Currently verification only plans to support the trap setting.

As this option complicates all of the #ifdef's related to debug registers even further,
abstractions for enabling/disabling each individual piece of the debug code for different
configuration options are also implemented.

Part of these refactored #ifdef guards was to remove the guards completely from libsel4
around the definitions of the number of breakpoints and watchpoints.
2017-04-03 14:21:27 +10:00
Kofi Doku Atuah
3cbe825a6f SELFOUR-836: arm: Correctly trap all debug events
We were previously using UNPREDICTABLE behaviour, because we were setting
HDCR.TDE without setting the other debug-related bits in HDCR.

Also, don't duplicate code: just call setHDCRTrapDebugExceptionState
within initHDCR().
2017-04-03 14:20:43 +10:00
Adrian Danis
67b829df1b SELFOUR-836: arm: Move Arch_initBreakpointContext prototype
This prototype was previously intermingled with struct definitions, so this moves it
to be located with the other function prototypes
2017-04-03 14:14:46 +10:00
Kofi Doku Atuah
3f90fad605 SELFOUR-836: Hardware debug API functions should take tcb_t and not arch_tcb_t
Touches files all throughout x86 (32 and 64) and ARM.
2017-04-03 14:14:00 +10:00
Kofi Doku Atuah
4e5cc369ff SELFOUR-836: Debug-API: setup initial debug context in BOOT_CODE
A more efficient way of setting up threads' initial context is implemented
by this patch: essentially instead of reading the debug coprocessor everytime
we create a thread, we read the coprocessor once at boot and then assign
those pre-read values when initializing threads.
2017-04-03 13:51:23 +10:00
Rafal Kolanski
084649c787 split asm read in addressTranslateS1CPR on arm-hyp
Previous implementation read a 64-bit value from two registers in one go
and implicitly cast down to paddr_t.

C Parser cannot handle an asm register read into anything other than a
word.

Workaround: perform two 32-bit reads instead, returning one of them.
2017-03-31 01:51:17 +11:00
Rafal Kolanski
de6d4772ee rename arch_tcb.vcpu -> arch_tcb.tcbVCPU, vcpu.tcb -> vcpu.vcpuTCB
struct vcpu { struct tcb* tcb; ...
struct arch_tcb { struct vcpu* vcpu; ...
and
struct tcb { struct arch_tcb tcbArch; ...

These conspire to generate a type error on verification side due to
assumptions about non-colliding names.
2017-03-31 00:57:47 +11:00
amrzar
93cc22b289 smp: fix bugs when stalling remote core
- Restart TCB from inside the lock if it is waiting for anything other than IRQ
- Only replace the TCB with idle thread if it is in ThreadState_RunningVM state

Also, this makes the design generic to be shared with arm.
2017-03-30 09:46:43 +11:00
Adrian Danis
8f7f8502e7 SELFOUR-712: arm: enable user level PMU event counter on v7 2017-03-28 12:10:51 +11:00
Adrian Danis
c104c82f5a arm: Refactor constants from debug API
This removes some duplicated constants and moves some constants into debug.h such that
they are visible without the user debugging API enabled. These constants are useful
for configuring other debugging/performance monitoring features.
2017-03-28 12:10:31 +11:00
Kofi Doku Atuah
725d0dacfd SELFOUR-836: Disable debug context save/restore between VMs
This patch disables the debug register state save and restore on ARM-hyp,
such that Guest VMs can now interfere with one another and trigger
one another for certain limited scenarios. This will be undone later on.
2017-03-21 15:31:23 +11:00
Hesham Almatary
26c81b9ff4 x86: move pdpte_t to 64/mode and delete it for ia32 2017-03-17 09:50:52 +11:00
Hesham Almatary
2cd909b2e9 ia32: remove unsued ia32KSGlobalPDPT and PDPT defines 2017-03-17 09:50:52 +11:00
Anna Lyons
f42d63631b refactor: initialise common core state in one place 2017-03-16 11:15:04 +11:00
Bamboo
9601f0fdfe [STYLE_FIX] 2017-03-09 02:36:15 +00:00
Kent McLeod
adeb341f48 tk1: Add missing device regions 2017-03-09 12:40:56 +11:00
Hesham Almatary
e8d3672c9a SELFOUR-745: ARM/SMP - Add lock/unlock code to kernel entry/exit points 2017-03-08 09:31:32 +11:00
Hesham Almatary
d5bd84e00f SELFOUR-744: Add utililty function to read MPIDR register (CPU ID) 2017-03-06 15:00:11 +11:00
Hesham Almatary
33da2e0f37 ARM/Stack: Add utililty function to get seL4 top stack pointer from HW register 2017-03-06 15:00:11 +11:00
Adrian Danis
ccd9020b6a Pass tcb_t to sanitiseRegister instead of arch_tcb_t 2017-03-06 13:42:33 +11:00
Kofi Doku Atuah
f12f0477c0 Add PL0 debug-API support for hyp-mode kernel
This patch enables the hype-mode kernel to intercept non-secure PL0
debug exceptions. Since it uses the HDCR register to do this (and not the SDCR),
it consequentially has no effect on any secure-monitor that may be executing
alongside the hypmode kernel.

For native seL4-hyp user threads, when the CPU sees a need to raise a debug
exception that was taken from PL0 (user), it will naturally try to raise that
exception to PL1 (supervisor).

But since seL4 is in PL2 and not PL1, seL4 has not set up an exception vector
table (VBAR) for PL1. So when the CPU attempts to vector into the PL1 VBAR,
it just gets a data abort, which it then delivers to PL2.

This patch causes the PL2 seL4 hypervisor to directly catch the debug exception
straight from PL0 and process the debug exception directly, for native threads.

Guest VM VCPUs are unaffected by this change. Their debug exceptions are delivered
to the Guest VM's PL1 VBAR as per usual.
2017-03-01 10:49:27 +11:00
Kofi Doku Atuah
469bdd6156 ARM-HYP: Add support for save/restore of debug registers
As things are now, the Guest VMs can modify the debug registers at will
from non-secure PL1, and the kernel does nothing to ensure that guest VM
debug coprocessor registers are preserved.

This is a preliminary patch that simply hooks into vcpu_save and saves the
CPU's debug coprocessor registers when saving VCPU state.

For restoring the debug registers on switching to a VCPU, we just re-use
restore_user_debug_context, which is already called in restore_user_context.
(Restore_user_context is called by c_handle_vcpu_fault()). Specifically,
we modify the used_breakpoints_bf so that restore_user_debug_context()
will always pop all the debug context.

This patch only covers the breakpoint and watchpoint registers,
and it doesn't cover the entire debug coprocessor, which is another
conversation.
2017-03-01 10:23:29 +11:00
Hesham Almatary
ecb54e09e6 Merge pull request #708 in SEL4/sel4 from ~HALMATARY/sel4:SELFOUR-746 to master
* commit '5253dca8b1e6a5cda3b6c7adce55f398ee3274fe':
  SELFOUR-746: ARM/SMP - Reserve the first two SGI IDs for seL4 IPI
  SELFOUR-746: ARM/GIC - Provide IPI support
  SELFOUR-746: ARM/GIC - bank active_irq for each core
2017-03-01 10:07:46 +11:00
Hesham Almatary
bf9d02f3ca Merge pull request #709 in SEL4/sel4 from ~HALMATARY/sel4:ARM/IRQ to master
* commit 'b8f9dcac64603debc2d1e235f8032ee504cd4845':
  ARM/IRQ: add a function to initialise local IRQ controller for CPUs
2017-03-01 09:55:44 +11:00
Adrian Danis
256c30ae02 x86: Pass VBE information from multiboot through bootinfo 2017-02-28 16:35:50 +11:00
Hesham Almatary
5253dca8b1 SELFOUR-746: ARM/SMP - Reserve the first two SGI IDs for seL4 IPI 2017-02-28 15:56:27 +11:00
Hesham Almatary
b8f9dcac64 ARM/IRQ: add a function to initialise local IRQ controller for CPUs
Similar to initIRQController(), cpu_initLocalIRQController() has to
be implemented for each platform. For those that are gonna support
SMP, it should be implemented proprely (if required), otherwise
it can be stubbed for single core implementations.
2017-02-28 13:39:49 +11:00
Hesham Almatary
b95dec2f7b SELFOUR-746: ARM/GIC - Provide IPI support 2017-02-28 10:13:43 +11:00
Hesham Almatary
8f859a7d32 SELFOUR-746: ARM/GIC - bank active_irq for each core 2017-02-28 10:03:15 +11:00
Hesham Almatary
db15ec7c46 Merge pull request #704 in SEL4/sel4 from ~HALMATARY/sel4:ARMSMP3 to master
* commit '03c323c18ef5ecf82fa962bc9e441870e6ed290f':
  ARM/Boot: initialise private timer, user access and benchmark in CPU context
2017-02-28 09:47:42 +11:00
Adrian Danis
c43954252c Remove assumption on 32-bit memory offsets
On 64-bit platforms physical address could be >2^32 offset from a virtual address. This
changes offsets to match the word size of the target architecture
2017-02-28 08:28:01 +11:00
Bamboo
4d54476621 [STYLE_FIX] 2017-02-27 06:26:58 +00:00
Hesham Almatary
03c323c18e ARM/Boot: initialise private timer, user access and benchmark in CPU context
In SMP context, init_cpu is meant to be called for each CPU, where
initialising private timer, user access and benchmarks (basically CCNT)
are per-CPU operations and involve per-CPU hardware
resources/interrupts.
2017-02-27 15:05:21 +11:00
amrzar
dea3d9819d X64: add CONFIG_HAVE_FPU to autoconf.h 2017-02-27 14:25:08 +11:00
amrzar
8610061aa9 aarch64: FPU lazy context switch 2017-02-27 14:25:01 +11:00
amrzar
0707ae874b Move arch independent functions to generic files and HAVE_FPU config 2017-02-27 12:52:18 +11:00
amrzar
ae8f2c99d7 x86: move current active FPU owner to node state 2017-02-27 12:52:18 +11:00
amrzar
323e60a749 x86: define number of restore since switch as node state 2017-02-27 12:52:18 +11:00
amrzar
195e5a0db8 pcc99: move max restore config value to main Kconfig 2017-02-27 12:52:18 +11:00
Kent McLeod
325db51cb1 Fix type error in benchmark.h 2017-02-27 09:31:11 +11:00
Hesham Almatary
35e4811572 Verification: Guard getCurrentCPUIndex() with SMP #define 2017-02-23 11:44:42 +11:00
Hesham Almatary
f97d6f3d14 Merge pull request #683 in SEL4/sel4 from ~HALMATARY/sel4:ARMSMP to master
* commit 'c1407c55216deba425fe32079ca786d213c5509e':
  [SELFOUR-744]: Modify head.S to load stacks for each core and implement getCurrentCPUIndex
2017-02-23 11:23:11 +11:00
Adrian Danis
712efa63cb arm_hyp: Use an explicitly invalid PD when there is no user one
When the user has no PD in order to schedule them we must still set something as
the active PD, just so that they can then fault. Previously when hypervisor was
enabled `0` was at as the PD. This worked as platforms typically do not have
anything valid, and certainly nothing resembling a page directory, at physical
address 0. This assumption is not very clean and unknown physical addresses
should not be accessed, so this change adds an explicit PD that is empty that
can be switched to.
2017-02-22 17:23:09 +11:00
Adrian Danis
f8606c86ad Provide spec for CTZL
Provides a spec for the __builtin_ctzl function and changes existing
code to use this wrapper
2017-02-22 17:22:17 +11:00
Hesham Almatary
34fe58a334 Fix: add pdpt stuff removed from shared x86 code to x86_64 2017-02-22 15:20:15 +11:00
Adrian Danis
4632e77d85 Correctly indent license headers 2017-02-21 16:39:07 +11:00
Adrian Danis
eccaae51dc s/D61/DATA61/ in license headers for consistency 2017-02-21 16:38:51 +11:00
Hesham Almatary
bca46830e9 Merge pull request #420 in SEL4/sel4 from ~HALMATARY/sel4:x86RemovePAE to master
* commit '3e57e647e9a882fc7ba07329bcfe41ff87af5bdb':
  SELFOUR-501: x86 - Remove PAE support
2017-02-21 16:14:34 +11:00
Hesham Almatary
c1407c5521 [SELFOUR-744]: Modify head.S to load stacks for each core and implement getCurrentCPUIndex 2017-02-21 09:48:08 +11:00
Hesham Almatary
3e57e647e9 SELFOUR-501: x86 - Remove PAE support 2017-02-17 13:13:43 +11:00
Hesham Almatary
ba14b5fa7d Merge pull request #682 in SEL4/sel4 from ~HALMATARY/sel4:fixAARCH64 to master
* commit 'e0e49db0ece32af40cdcc5dd81d210078bf2b1d9':
  trivial: add place holder smp.h file for aarch64
2017-02-17 11:33:11 +11:00
Hesham Almatary
e0e49db0ec trivial: add place holder smp.h file for aarch64 2017-02-17 11:28:42 +11:00
Jack Suann
75ff2cd2e0 Merge pull request #677 in SEL4/sel4 from ~JSUANN/sel4:pendirq-sc to master
* commit '50995b4c5f5bfd88c0ae049966f58f5cdcd6d8df':
  Replace Arch_handleInterrupt with Arch_finaliseInterrupt
2017-02-17 11:20:17 +11:00
Bamboo
e45ee8b135 [STYLE_FIX] 2017-02-16 23:57:13 +00:00
Hesham Almatary
0ef7c693ce x86: define L1_CACHE_LINE_SIZE_BITS as with ARM 2017-02-16 15:28:05 +11:00
Hesham Almatary
67cdff7b68 SMP: Move/rename migrateTCB() arch tcb.c 2017-02-16 15:28:05 +11:00
Hesham Almatary
48d17e1f58 ARM/SMP: Prepare for ARM SMP adding stubs
Currently building ARM/SMP is broken. This commit:
1- Makes it possible to build ARM/SMP with stubs. Run-time SMP for ARM
DOES NOT WORK.
2- Can be a reference for future SMP targets to follow in order to
layout/add the minimal required files and functions needed to support SMP.
3- Builds for Sabre only. In order to support other platforms, ipi
interrupt ID should be defined in machine.h
2017-02-16 15:28:00 +11:00
Hesham Almatary
4cca9968fe Merge pull request #678 in SEL4/sel4 from ~HALMATARY/sel4:UserContext to master
* commit 'd17615aa6c66e43cfbb20c5afc9fadb486edf776':
  ARM: use restore_user_context() in head.S
2017-02-16 15:23:29 +11:00
Amirreza Zarrabi
98e6c9c060 Merge pull request #669 in SEL4/sel4 from ~AZARRABI/sel4:init_freemem to master
* commit '22f9d7b953247f62cae6df97dd4e765535be2349':
  Update init_freemem to check for mode dependant reserve regions
2017-02-16 15:22:19 +11:00
Hesham Almatary
d17615aa6c ARM: use restore_user_context() in head.S 2017-02-16 14:38:44 +11:00
Adrian Danis
c574f4fc48 Helper for allocating the extra boot info region 2017-02-16 14:34:52 +11:00
Jack Suann
50995b4c5f Replace Arch_handleInterrupt with Arch_finaliseInterrupt 2017-02-16 12:51:14 +11:00
amrzar
22f9d7b953 Update init_freemem to check for mode dependant reserve regions 2017-02-16 07:21:05 +11:00
Jack Suann
9f67d21c3d x86: Handle pending interrupt before scheduling thread in handleSyscall
In handleSyscall the current thread may be preempted to handle a pending interrupt.
With kernel mode interrupts in x86 this handling was delayed until we were about
to switch back to user mode. This change unifies the handling with ARM, where the
interrupt is handled prior to calling the thread scheduler.
2017-02-15 14:31:55 +11:00
Bamboo
d691d637d3 [STYLE_FIX] 2017-02-15 03:13:44 +00:00
amrzar
2e250fcce5 plat: add tx1 support 2017-02-15 12:35:13 +11:00
Adrian Danis
7dd53f12d5 Add missing seL4_Uint16 type in the kernel
This type is provided by libsel4 and should be provided by the kernel in the future event
that shared headers actually use the seL4_Uint16 type
2017-02-14 13:59:34 +11:00
Hesham Almatary
671c353b6c Merge pull request #619 in SEL4/sel4 from ~HALMATARY/sel4:BenchmarkFixTK1 to master
* commit '3b33d2f9bd76b4af519a85051770a64f18245ae7':
  Benchmark/TK1: add missing include benchmark_overflowHandler.h
2017-02-14 09:57:47 +11:00
amrzar
08ecacb013 KZM: add aarch32 config variable to autoconf.h 2017-02-13 07:24:53 +11:00
amrzar
0b2fe8d605 aarch64: Initial implementation 2017-02-10 16:43:55 +11:00
amrzar
149e42bfee aarch64: Check size of unsigned long 2017-02-10 16:43:55 +11:00
amrzar
fac16fe89e aarch64: add preliminary folders and Makefiles 2017-02-10 16:43:55 +11:00
amrzar
1d537ac721 ARM: Move vspace.h to mode specific folder 2017-02-10 16:43:55 +11:00
amrzar
19b89ed119 ARM: Add 32 bit directory for armv8-a 2017-02-10 16:43:55 +11:00
amrzar
acea60e3d6 ARM: Prepare hikey for aarch64 2017-02-10 16:43:55 +11:00
amrzar
40e89b5d67 ARM: Move fastpath_restore to mode specific folder 2017-02-09 15:47:39 +11:00
amrzar
28f09e2e73 ARM: Move timer.h to mode specific folder 2017-02-09 15:47:39 +11:00
Jack Suann
ebf593561c x86: Add missing memory clobber in receivePendingIRQ
In receivePendingIRQ() the global variable x86KSPendingInterrupt may be
updated but compiler was previously unaware of this.
2017-02-08 12:48:46 +11:00
Adrian Danis
f10efc6047 x86: Use lower memory region for AP boot code
Change AP boot code to use a memory region that is lower down, although also
smaller. As long as the boot code can fit in this smaller region booting is
more reliable as depending on the machine, bios, firmware and bootloader
varying amounts of the low memory will be available.
2017-02-08 09:56:06 +11:00
Anna Lyons
45f20d56b4 trivial: print kernel entry reason on halt
It is generally useful to know what operation was occuring
when the kernel halted, as this is usually called from assert.
2017-02-07 16:52:50 +11:00
Adrian Danis
4f52aca5b1 Remove multiple stack definitions
This commit changes the stack so that it is declared a single time in stack.c,
with the correct attributes and alignment, instead of being declared in stack.h
and relying on the linker to collapse the multiple declarations.
2017-02-06 15:42:37 +11:00
Adrian Danis
b40d95ed89 x86: Send explicit TCB when handling remote VMs withs pending notifications
Previously if the `ksCurThread` of the destination core is not the thread that is
receiving the notification in `sendSignal` then the notification would be delayed
until the VMM for that VM next did a `seL4_VMEnter`. This adds a `tcb_t*` parameter
to `VMCheckBoundNotification` instead of having it implicitly talk about `ksCurThread`.
A TCB parameter is safe to send here as the `doRemoteVMCheckBoundNotification`
happens synchronously and so the TCB is guaranteed to still exist.
2017-02-06 15:04:43 +11:00
Amirreza Zarrabi
ff6942570c Merge pull request #642 in SEL4/sel4 from ~AZARRABI/sel4:unify_bf to master
* commit 'efb28fec20ad1b22b4476a25b92ec1f5fb59a41f':
  Unify arch_shared_types.bf from the libsel
2017-02-06 09:35:13 +11:00
amrzar
efb28fec20 Unify arch_shared_types.bf from the libsel 2017-02-06 09:08:35 +11:00
Bamboo
dcaff678db [STYLE_FIX] 2017-02-05 22:03:00 +00:00
Adrian Danis
331e97962b x86: Implement safe rdmsr function
Implements a safe version of `x86_rdmsr` that can return success or failure depending
on if the rdmsr caused a GP fault
2017-02-06 09:02:19 +11:00
Adrian Danis
4fe72d09f5 x86: Mechanism for catching GP faults and returning to an error handler
Provides a mechanism where if af GP fault is potentially expected it can be caught
and the calling code returned to. The GP happening can be detected by setting
a specific return to handler and additionally by the return to handler being
cleared if a GP happened.
2017-02-06 09:02:19 +11:00
Jack Suann
cea45cd1bd x86: Handling pending interrupts in kernel mode
This commit allows x86 to completely handle a pending interrupt without switching
out to user mode. To handle an interrupt on x86 the APIC *must* generate an exception,
prior to you being able to acknowledge it. Previously we only allow exceptions (i.e.
interrupts) to be generated outside of kernel mode when we are in user mode.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This commit:

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

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

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

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

The x86_make_pde_mapping function is dropped in this move as it is
not used. Instead it is replaced with a function for creating an
empty mapping for whatever is the vspace root.
2016-11-09 15:23:40 +11:00
amrzar
ffd0f34b39 Clean up x86KScurInterrupt:
1. Remove the locking dependancy on the value of x86KScurInterrupt
2. Remove confusing set/unset of x86KScurInterrupt
2016-11-09 14:22:04 +11:00
amrzar
b46e98c10e smp: solve bug in tlb_bitmap
1. Missing loop counter when accessing to PD in 'tlb_bitmap_get'.
2. Missing 'TLBBITMAP_PD_INDEX' in 'TLBBITMAP_PD_MAKE_INDEX'. The index generated by 'TLBBITMAP_PD_MAKE_INDEX' should be valid in PD while the original one used to generate just 0, 1, etc. The correct index is '0 + TLBBITMAP_PD_INDEX', '1 + TLBBITMAP_PD_INDEX' and so on.
2016-11-09 10:00:56 +11:00
Bamboo
846254be1f [STYLE_FIX] 2016-11-08 05:55:43 +00:00
Anna Lyons
c86669df43 x86: export tsc freq in bootinfo
We read the frequency from the platform info MSR and export it to the
user for accurate timing (for platforms that support platform into)
2016-11-08 14:46:18 +11:00
Adrian Danis
828a14d853 SELFOUR-222: Configure IRQ cnode size per platform 2016-11-08 11:48:31 +11:00
Adrian Danis
808f68e1be x64: Mode specific IPI definitions 2016-11-07 15:02:29 +11:00
Adrian Danis
9899c60c8b x86: Reduce number of irqs to 128
On x86-64 the irq cnode will be larger than a page if there is more
than 128 irqs.
2016-11-07 14:58:46 +11:00
Adrian Danis
1173e19aa6 x86: kernelSP only needed for ia32 2016-11-07 14:58:46 +11:00
Adrian Danis
6f908324f8 x64: Access core local state correctly 2016-11-07 14:58:46 +11:00
Adrian Danis
8b5ec01626 x86: Split IPIs into arch and mode portions 2016-11-07 14:53:46 +11:00
amrzar
44fc989cc5 Store remote FPU state 2016-11-07 14:41:25 +11:00
Bamboo
b90b715818 [STYLE_FIX] 2016-11-07 13:27:52 +11:00
Adrian Danis
61c1a4c4ff x64: Mode specific smp file 2016-11-07 12:18:43 +11:00
Adrian Danis
a726b4bea5 x86: Split CPU ID management into mode and general
This moves getCurrentCPUIndex into a mode specific smp header, and
moves wrappers that use it into the generap smp header
2016-11-07 11:46:08 +11:00
Adrian Danis
76b9441eee x86: Remove unused function 2016-11-07 11:44:57 +11:00
amrzar
056dbf811b SELFOUR-634: support for TLB and cache management 2016-11-07 10:55:05 +11:00
Anna Lyons
4a82597b7a trivial: change remoteTCBStall to take tcb
Instead of cap_t. This allows the function to be used from other
functions that have the tcb pointer and not the cap.
2016-11-07 10:37:17 +11:00
Adrian Danis
ab91c11a4f Merge pull request #459 in SEL4/sel4 from ~ADANIS/sel4:smmu to master
* commit '858fa717c6a30fe1f0514c4ad8bbbe1003016864':
  tk1: Remove temporary SMMU memory mapping support
  arm: Remove lookup error message
  arm: Correctly mask SMMU PT addresses
  tk1: Correct SMMU PD and PT indexing
2016-11-03 05:05:38 +00:00
Adrian Danis
a85472a951 x86: Always consider FPU owernship of threads core
When checking if a thread is using the FPU or not we now check on that
threads core, under the assumption that if a thread migrates its FPU
state is explicitly (and not lazily) migrated.
2016-11-03 10:18:24 +11:00
Adrian Danis
858fa717c6 tk1: Remove temporary SMMU memory mapping support 2016-11-02 15:12:56 +11:00
Adrian Danis
e3be5fa8e4 tk1: Correct SMMU PD and PT indexing 2016-11-02 15:12:56 +11:00
amrzar
3b19198bf4 Include vspace remote call support 2016-11-02 15:00:19 +11:00
amrzar
658eb090db Extend IPI for two function parameters 2016-11-02 13:47:29 +11:00