Commit graph

510 commits

Author SHA1 Message Date
Adrian Danis
1f2f6b98bb Use CONFIG_ variables instead of configuration definitions 2017-05-29 17:04:47 +10:00
Hesham Almatary
7ec01d0992 ARM32: typedef vspace_root_t
Similar to x86, and avoid #ifdefs in fastpath.c arch-independent code
2017-05-18 13:35:33 +10:00
Anna Lyons
9ca253a3d0 SELFOUR-879: expose index and entry constants 2017-05-09 11:35:52 +10:00
Bamboo
8ce9513d7a [STYLE_FIX] 2017-05-04 01:48:32 +00:00
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
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
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
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
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
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
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
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
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
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