fix(rmmd/sve): enable/disable SVE/FPU for Realms
This patch enable/disable SVE/FPU for Realms depending upon it's state in NS. When this feature is enabled, traps to EL3 on SVE/FPU access from Realms are disabled. However, RMM must ensure that the Realm <-> NS SVE/FPU registers are not corrupted by each other and Realms do not leak information to NS. Change-Id: I0a27a055787976507017b72879ba6458f066624e Signed-off-by: Subhasish Ghosh <subhasish.ghosh@arm.com>
This commit is contained in:
parent
0628fe3fff
commit
a4cc85c129
|
@ -30,6 +30,7 @@
|
||||||
#include <services/rmi_svc.h>
|
#include <services/rmi_svc.h>
|
||||||
#include <services/rmmd_svc.h>
|
#include <services/rmmd_svc.h>
|
||||||
#include <smccc_helpers.h>
|
#include <smccc_helpers.h>
|
||||||
|
#include <lib/extensions/sve.h>
|
||||||
#include "rmmd_initial_context.h"
|
#include "rmmd_initial_context.h"
|
||||||
#include "rmmd_private.h"
|
#include "rmmd_private.h"
|
||||||
|
|
||||||
|
@ -111,6 +112,26 @@ static void rmm_el2_context_init(el2_sysregs_t *regs)
|
||||||
regs->ctx_regs[CTX_SCTLR_EL2 >> 3] = SCTLR_EL2_RES1;
|
regs->ctx_regs[CTX_SCTLR_EL2 >> 3] = SCTLR_EL2_RES1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Enable architecture extensions on first entry to Realm world.
|
||||||
|
******************************************************************************/
|
||||||
|
static void manage_extensions_realm(cpu_context_t *ctx)
|
||||||
|
{
|
||||||
|
#if ENABLE_SVE_FOR_NS
|
||||||
|
/*
|
||||||
|
* Enable SVE and FPU in realm context when it is enabled for NS.
|
||||||
|
* Realm manager must ensure that the SVE and FPU register
|
||||||
|
* contexts are properly managed.
|
||||||
|
*/
|
||||||
|
sve_enable(ctx);
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* Disable SVE and FPU in realm context when it is disabled for NS.
|
||||||
|
*/
|
||||||
|
sve_disable(ctx);
|
||||||
|
#endif /* ENABLE_SVE_FOR_NS */
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Jump to the RMM for the first time.
|
* Jump to the RMM for the first time.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
@ -124,6 +145,9 @@ static int32_t rmm_init(void)
|
||||||
INFO("RMM init start.\n");
|
INFO("RMM init start.\n");
|
||||||
ctx->state = RMM_STATE_RESET;
|
ctx->state = RMM_STATE_RESET;
|
||||||
|
|
||||||
|
/* Enable architecture extensions */
|
||||||
|
manage_extensions_realm(&ctx->cpu_ctx);
|
||||||
|
|
||||||
/* Initialize RMM EL2 context. */
|
/* Initialize RMM EL2 context. */
|
||||||
rmm_el2_context_init(&ctx->cpu_ctx.el2_sysregs_ctx);
|
rmm_el2_context_init(&ctx->cpu_ctx.el2_sysregs_ctx);
|
||||||
|
|
||||||
|
@ -281,6 +305,9 @@ static void *rmmd_cpu_on_finish_handler(const void *arg)
|
||||||
/* Initialise RMM context with this entry point information */
|
/* Initialise RMM context with this entry point information */
|
||||||
cm_setup_context(&ctx->cpu_ctx, rmm_ep_info);
|
cm_setup_context(&ctx->cpu_ctx, rmm_ep_info);
|
||||||
|
|
||||||
|
/* Enable architecture extensions */
|
||||||
|
manage_extensions_realm(&ctx->cpu_ctx);
|
||||||
|
|
||||||
/* Initialize RMM EL2 context. */
|
/* Initialize RMM EL2 context. */
|
||||||
rmm_el2_context_init(&ctx->cpu_ctx.el2_sysregs_ctx);
|
rmm_el2_context_init(&ctx->cpu_ctx.el2_sysregs_ctx);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue