Compare commits

...

6 Commits

Author SHA1 Message Date
Rafal Kolanski
f473021686 aarch32: tune user_context struct for verification
Verification requires packed structures for reasoning (no implicit
padding).

The FPU context starts with 64-bit words, which the C parser assumes
have 8-byte alignment. Unfortunately, for this version of the kernel,
aarch32 has an odd number of word_t (32-bit) registers, resulting in an
extra word of implicit padding.

This type of manual padding is naturally fragile and will break as soon
as a user register is added or removed from the user context.

Signed-off-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
2020-12-16 04:43:43 +11:00
Rafal Kolanski
271701f2c3 cmake: allow FPU on aarch32 verified configuration
"ARM" verification target now includes FPU.

Signed-off-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
2020-12-16 01:07:02 +11:00
Rafal Kolanski
a6cf33bf60 switch ARM verified config to iMX8 + FPU
ARM_verified.cmake (used for verification target "ARM") now enables FPU
and targets iMX8.

Signed-off-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
2020-12-16 01:06:55 +11:00
Rafal Kolanski
d82b9f0434 arm: DONT_TRANSLATE isIRQPending for GIC v3
This is a shortcut for dealing with the inline assembly inside to
prevent the modifies analysis from picking up every part of the state.

For any future binary correctness analysis, this will need to be
removed, and instead an appeal made to inline assembly being unable to
modify the heap.

Signed-off-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
2020-12-16 01:06:27 +11:00
Rafal Kolanski
39a4d68d84 arm: remove binary literals in GIC v3 code
C parser used by verification does not allow binary literals as they are
not part of the C99 standard.

Signed-off-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
2020-12-16 01:06:19 +11:00
Siwei Zhuang
fae5379c41 arm: give away FPU on thread delete
The ownership of FPU would only be updated when a thread causes FPU
exception. If the thread being deleted owns the FPU, the ownership needs
to be given away proactively to avoid memory corruption.

Reported-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
Signed-off-by: Siwei Zhuang <siwei.zhuang@data61.csiro.au>
2020-12-16 01:06:12 +11:00
7 changed files with 22 additions and 6 deletions

View File

@@ -15,7 +15,9 @@
include(${CMAKE_CURRENT_LIST_DIR}/../tools/helpers.cmake)
cmake_script_build_kernel()
set(KernelPlatform "imx6" CACHE STRING "")
set(KernelPlatform "imx8mm-evk" CACHE STRING "")
set(KernelSel4Arch "aarch32" CACHE STRING "")
set(KernelAArch32FPUEnableContextSwitch ON CACHE BOOL "")
set(KernelVerificationBuild ON CACHE BOOL "")
set(KernelIPCBufferLocation "threadID_register" CACHE STRING "")
set(KernelMaxNumNodes "1" CACHE STRING "")

View File

@@ -232,6 +232,12 @@ typedef struct user_fpu_state {
*/
struct user_context {
word_t registers[n_contextRegisters];
/* user_fpu_state_t is 64-bit aligned, and we have an odd number of
* registers in the user context. This results in a verified configuration
* with padding. Verification requires packed structures without implicit
* padding, so we pad manually.
*/
word_t odd_n_contextRegisters_padding;
#ifdef ARM_BASE_CP14_SAVE_AND_RESTORE
user_breakpoint_state_t breakpointState;
#endif /* CONFIG_HARDWARE_DEBUG_API */

View File

@@ -257,6 +257,8 @@ static inline interrupt_t getActiveIRQ(void)
* seL4 expects two states: active->inactive.
* We ignore the active state in GIC to conform
*/
/** MODIFIES: phantom_machine_state */
/** DONT_TRANSLATE */
static inline bool_t isIRQPending(void)
{
uint32_t val = 0;

View File

@@ -566,12 +566,14 @@ exception_t Arch_decodeInvocation(word_t invLabel, word_t length, cptr_t cptr,
void
Arch_prepareThreadDelete(tcb_t * thread) {
#ifdef CONFIG_HAVE_FPU
fpuThreadDelete(thread);
#endif
#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT
if (thread->tcbArch.tcbVCPU) {
dissociateVCPUTCB(thread->tcbArch.tcbVCPU, thread);
}
#else /* CONFIG_ARM_HYPERVISOR_SUPPORT */
/* No action required on ARM. */
#endif /* CONFIG_ARM_HYPERVISOR_SUPPORT */
}

View File

@@ -415,6 +415,10 @@ exception_t Arch_decodeInvocation(word_t label, word_t length, cptr_t cptr,
void
Arch_prepareThreadDelete(tcb_t * thread) {
#ifdef CONFIG_HAVE_FPU
fpuThreadDelete(thread);
#endif
#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT
if (thread->tcbArch.tcbVCPU) {
dissociateVCPUTCB(thread->tcbArch.tcbVCPU, thread);

View File

@@ -160,7 +160,7 @@ config_option(
operations in a multithreading environment, instead of relying on \
software emulation of FPU/VFP from the C library (e.g. mfloat-abi=soft)."
DEFAULT ON
DEPENDS "KernelSel4ArchAarch32;NOT KernelArchArmV6;NOT KernelVerificationBuild"
DEPENDS "KernelSel4ArchAarch32;NOT KernelArchArmV6"
DEFAULT_DISABLED OFF
)

View File

@@ -313,9 +313,9 @@ void setIRQTrigger(irq_t irq, bool_t trigger)
}
if (trigger) {
icfgr |= (0b10 << bit);
icfgr |= (2 << bit);
} else {
icfgr &= ~(0b11 << bit);
icfgr &= ~(3 << bit);
}
if (HW_IRQ_IS_PPI(hw_irq)) {