Commit graph

91 commits

Author SHA1 Message Date
Adrian Danis
4857dcb000 x86: Separate header for TLB bitmap definitions
Having a separate header allows for them to be included into the platform hardware
definition without causing a circular include
2018-01-16 14:51:26 +11:00
Adrian Danis
b851560cf7 x64: Restrict user to non sign extended vaddr
This simplifies the kernel preventing the need to validate that addresses are canonical
on the return from syscalls and interrupts.
2018-01-16 11:33:29 +11:00
Adrian Danis
c8eb525782 pc99: Make hardware.h usable from assembly
Rearranges hardware.h and makes use of the UL_CONST macro so that the header can be
included into assmebly files for its definitions
2018-01-09 14:13:41 +11:00
Alexander Boettcher
a4a52c5dcb pc99: Explicitly declare sizes for different versions of ACPI RSDP 2017-11-28 16:25:07 +11:00
Anna Lyons
cddc4e6ef5 Inline resetTimer for all platforms
- for arm generic timer platforms, we remove resetTimer ->
resetGenericTimer indirection and simply include generic_timer.h
- this reduces boiler plate for platforms that share timer drivers, as
  they simply include the one header
- there is far more timer code in the RT kernel, which motivates this
change
2017-11-28 10:21:46 +11:00
Joel Beeren
092042f7c5 x64: add MODIFIES statements for extern functions
The CParser can't deduce modifies rules for functions without
definitions (like in8, out8 et al and interrupt handler functions).
This adds explicit modifies rules for these functions.
2017-11-09 12:18:31 +11:00
Adrian Danis
e8625c6d81 pc99: Provide public function for validating an RSDP
RSDP validation was previously done directly in acpi_init. This splits the validation
into a seperate, publicly useable, function. The intention is for this to be used in
boot scenarios where an RSDP is given and does not need to be searched for.
2017-10-06 10:08:46 +11:00
Adrian Danis
ee380609c6 x86: Copy RSDP table in acpi_init instead of returning physical address of rsdt
The full RSDP is useful beyond just extracting the RSDT address out of it. In particular
this prepares us for being able to pass a copy of the RSDP to the rootserver.

The previous function signature might lead a user to believe that they were getting a
pointer to a useable acpi_rsdt_t structure. This was in fact not the case and was
actually returning the physical address, that may or may not be mapped in, of the rsdt
table. All of the other acpi *_scan functions would therefore immediately map in the physical
rsdt pointer they were given.

This commit changes acpi_init to return a boolean indicating whether it found a valid
rsdp, and then fills in a copy of the rsdp data. The copy is necessary as the rsdp
data may be at a temporary mapping.

As a result of changing acpi_init the boot code and state is changed to have a acpi_rsdt_t
instance that can be filled out.
2017-10-06 10:08:40 +11:00
Adrian Danis
95b505bee2 pc99: Make irq_t a uint8_t type instead of an enum type
This renames the previous irq_t enum into a platform_irq_t enum and provides irq_t
as a 'well defined' uint8_t typedef. Having irq_t be an integer type, and not an enum,
is necessary for consistency with verification. As part of explicitly defining irq_t
as an unsigned integer type the definition of irqInvalid is changed to prevent sign
extension leading to unexpected invalid comparisons.
2017-09-26 16:57:10 +10:00
Adrian Danis
2bf586fe3d x86: Correct return type of servicePendingIRQ
This function returns an interrupt_t, and its call sites expect an interrupt_t,
despite the types being written as irq_t.

Closes #66
2017-08-29 10:56:43 +10:00
Adrian Danis
a9e1f51713 SELFOUR-1062: Hide all IOMMU related code behind #ifdef guards
The IOMMU implementation is not going to be verified at the moment, and so the code for
it needs to be hidden from verification, which we do by #ifdef'ing it out if the IOMMU
is not enabled. As a result the IOMMU configuration depends on a non verification target
2017-08-21 16:44:58 +10:00
Adrian Danis
8c8b53a5f7 pc99: Define PCI helpers in a pci header instead of iospace header
These helpers are generic PCI and are used outside of the iospace code
2017-08-21 16:44:58 +10:00
Hesham Almatary
57fa0e0f85 Share linker.h between architectures 2017-08-10 08:38:36 +10:00
Hesham Almatary
ee28936d48 SMP: Introduce ENABLE_SMP_SUPPORT
- Make it more readable and less confusing compared to the 'CONFIG_MAX_NUM_NODES > 1' check
2017-06-29 16:23:39 +10:00
Anna Lyons
40c61e5c18 Fix licenses (the rest) 2017-06-22 15:29:12 +10:00
Jonas Claeson
d8c31a8583 Removed unnecessary comparison in updateIRQState
./kernel/include/plat/pc99/plat/machine/interrupt.h:115:14:
error: comparison of unsigned expression >= 0
      is always true [-Werror,-Wtautological-compare]
    if(!(irq >= 0 && irq <= maxIRQ)) _assert_fail(...
         ~~~ ^  ~
2017-06-13 16:50:43 +02: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
amrzar
dea3d9819d X64: add CONFIG_HAVE_FPU to autoconf.h 2017-02-27 14:25:08 +11:00
amrzar
195e5a0db8 pcc99: move max restore config value to main Kconfig 2017-02-27 12:52:18 +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
3e57e647e9 SELFOUR-501: x86 - Remove PAE support 2017-02-17 13:13:43 +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
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
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
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
Adrian Danis
654e92e37c pc99: Update autoconf.h to have stack size definition 2017-01-13 15:22:34 +11:00
Adrian Danis
8221326a07 pc99: Update standalone build config 2016-11-24 15:25:52 +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
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
amrzar
27afc1bd92 x86: add logical id mapping for x2APIC IPI boradcasting 2016-11-22 09:40:31 +11:00
amrzar
2955bd46b2 add x2apic to x86-64 autoconfig 2016-11-18 07:26:12 +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
828a14d853 SELFOUR-222: Configure IRQ cnode size per platform 2016-11-08 11:48:31 +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
amrzar
a228c492a6 Incuede TLBBitmap in PD to keep track of cores currently accessing this PD 2016-11-01 10:07:57 +11:00
amrzar
f050e6a9c5 implement layout of ipi interrupt handling 2016-10-23 12:21:14 +11:00
Adrian Danis
b90238d089 Replace #pragma once with include guards 2016-10-21 12:05:02 +11:00
Adrian Danis
a3c88cfc5b pc99: Update autoconf.h for standalone builds 2016-10-12 14:18:55 +11:00
Adrian Danis
48df6d3ab4 x64: Define kernelBase for breakpoint code 2016-10-12 12:22:32 +11:00
Adrian Danis
7f9970e5e2 x64: Add x86_64 support 2016-10-12 12:22:31 +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
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
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