Browse Source
* changes: feat(fvp): allow SIMD context to be put in TZC DRAM docs(simd): introduce CTX_INCLUDE_SVE_REGS build flag feat(fvp): add Cactus partition manifest for EL3 SPMC chore(simd): remove unused macros and utilities for FP feat(el3-spmc): support simd context management upon world switch feat(trusty): switch to simd_ctx_save/restore apis feat(pncd): switch to simd_ctx_save/restore apis feat(spm-mm): switch to simd_ctx_save/restore APIs feat(simd): add rules to rationalize simd ctxt mgmt feat(simd): introduce simd context helper APIs feat(simd): add routines to save, restore sve state feat(simd): add sve state to simd ctxt struct feat(simd): add data struct for simd ctxt managementpull/2005/merge
Manish V Badarkhe
3 months ago
committed by
TrustedFirmware Code Review
18 changed files with 636 additions and 195 deletions
@ -0,0 +1,97 @@ |
|||
/*
|
|||
* Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. |
|||
* Copyright (c) 2022, Google LLC. All rights reserved. |
|||
* |
|||
* SPDX-License-Identifier: BSD-3-Clause |
|||
*/ |
|||
|
|||
#ifndef SIMD_CTX_H |
|||
#define SIMD_CTX_H |
|||
|
|||
/*******************************************************************************
|
|||
* Constants that allow assembler code to access members of and the 'simd_context' |
|||
* structure at their correct offsets. |
|||
******************************************************************************/ |
|||
|
|||
#if CTX_INCLUDE_FPREGS || CTX_INCLUDE_SVE_REGS |
|||
#if CTX_INCLUDE_SVE_REGS |
|||
#define SIMD_VECTOR_LEN_BYTES (SVE_VECTOR_LEN / 8) /* Length of vector in bytes */ |
|||
#elif CTX_INCLUDE_FPREGS |
|||
#define SIMD_VECTOR_LEN_BYTES U(16) /* 128 bits fixed vector length for FPU */ |
|||
#endif /* CTX_INCLUDE_SVE_REGS */ |
|||
|
|||
#define CTX_SIMD_VECTORS U(0) |
|||
/* there are 32 vector registers, each of size SIMD_VECTOR_LEN_BYTES */ |
|||
#define CTX_SIMD_FPSR (CTX_SIMD_VECTORS + (32 * SIMD_VECTOR_LEN_BYTES)) |
|||
#define CTX_SIMD_FPCR (CTX_SIMD_FPSR + 8) |
|||
|
|||
#if CTX_INCLUDE_FPREGS && CTX_INCLUDE_AARCH32_REGS |
|||
#define CTX_SIMD_FPEXC32 (CTX_SIMD_FPCR + 8) |
|||
#define CTX_SIMD_PREDICATES (CTX_SIMD_FPEXC32 + 16) |
|||
#else |
|||
#define CTX_SIMD_PREDICATES (CTX_SIMD_FPCR + 8) |
|||
#endif /* CTX_INCLUDE_FPREGS && CTX_INCLUDE_AARCH32_REGS */ |
|||
|
|||
/*
|
|||
* Each predicate register is 1/8th the size of a vector register and there are 16 |
|||
* predicate registers |
|||
*/ |
|||
#define CTX_SIMD_FFR (CTX_SIMD_PREDICATES + (16 * (SIMD_VECTOR_LEN_BYTES / 8))) |
|||
|
|||
#ifndef __ASSEMBLER__ |
|||
|
|||
#include <stdint.h> |
|||
#include <lib/cassert.h> |
|||
|
|||
/*
|
|||
* Please don't change order of fields in this struct as that may violate |
|||
* alignment requirements and affect how assembly code accesses members of this |
|||
* struct. |
|||
*/ |
|||
typedef struct { |
|||
uint8_t vectors[32][SIMD_VECTOR_LEN_BYTES]; |
|||
uint8_t fpsr[8]; |
|||
uint8_t fpcr[8]; |
|||
#if CTX_INCLUDE_FPREGS && CTX_INCLUDE_AARCH32_REGS |
|||
/* 16 bytes to align to next 16 byte boundary when CTX_INCLUDE_SVE_REGS is 0 */ |
|||
uint8_t fpexc32_el2[16]; |
|||
#endif |
|||
#if CTX_INCLUDE_SVE_REGS |
|||
/* FFR and each of predicates is one-eigth of the SVE vector length */ |
|||
uint8_t predicates[16][SIMD_VECTOR_LEN_BYTES / 8]; |
|||
uint8_t ffr[SIMD_VECTOR_LEN_BYTES / 8]; |
|||
/* SMCCCv1.3 FID[16] hint bit state recorded on EL3 entry */ |
|||
bool hint; |
|||
#endif /* CTX_INCLUDE_SVE_REGS */ |
|||
} __aligned(16) simd_regs_t; |
|||
|
|||
CASSERT(CTX_SIMD_VECTORS == __builtin_offsetof(simd_regs_t, vectors), |
|||
assert_vectors_mismatch); |
|||
|
|||
CASSERT(CTX_SIMD_FPSR == __builtin_offsetof(simd_regs_t, fpsr), |
|||
assert_fpsr_mismatch); |
|||
|
|||
CASSERT(CTX_SIMD_FPCR == __builtin_offsetof(simd_regs_t, fpcr), |
|||
assert_fpcr_mismatch); |
|||
|
|||
#if CTX_INCLUDE_FPREGS && CTX_INCLUDE_AARCH32_REGS |
|||
CASSERT(CTX_SIMD_FPEXC32 == __builtin_offsetof(simd_regs_t, fpexc32_el2), |
|||
assert_fpex32_mismtatch); |
|||
#endif |
|||
|
|||
#if CTX_INCLUDE_SVE_REGS |
|||
CASSERT(CTX_SIMD_PREDICATES == __builtin_offsetof(simd_regs_t, predicates), |
|||
assert_predicates_mismatch); |
|||
|
|||
CASSERT(CTX_SIMD_FFR == __builtin_offsetof(simd_regs_t, ffr), |
|||
assert_ffr_mismatch); |
|||
#endif |
|||
|
|||
void simd_ctx_save(uint32_t security_state, bool hint_sve); |
|||
void simd_ctx_restore(uint32_t security_state); |
|||
|
|||
#endif /* __ASSEMBLER__ */ |
|||
|
|||
#endif /* CTX_INCLUDE_FPREGS || CTX_INCLUDE_SVE_REGS */ |
|||
|
|||
#endif /* SIMD_CTX_H */ |
@ -0,0 +1,81 @@ |
|||
/*
|
|||
* Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. |
|||
* Copyright (c) 2022, Google LLC. All rights reserved. |
|||
* |
|||
* SPDX-License-Identifier: BSD-3-Clause |
|||
*/ |
|||
|
|||
#include <stdint.h> |
|||
|
|||
#include <common/debug.h> |
|||
#include <lib/el3_runtime/aarch64/context.h> |
|||
#include <lib/el3_runtime/context_mgmt.h> |
|||
#include <lib/el3_runtime/cpu_data.h> |
|||
#include <lib/el3_runtime/simd_ctx.h> |
|||
#include <lib/extensions/sve.h> |
|||
#include <plat/common/platform.h> |
|||
|
|||
#if CTX_INCLUDE_FPREGS || CTX_INCLUDE_SVE_REGS |
|||
|
|||
/* SIMD context managed for Secure and Normal Worlds. */ |
|||
#define SIMD_CTXT_COUNT 2 |
|||
|
|||
#if SEPARATE_SIMD_SECTION |
|||
__section(".simd_context") |
|||
#else |
|||
__section(".bss.simd_context") |
|||
#endif |
|||
static simd_regs_t simd_context[SIMD_CTXT_COUNT][PLATFORM_CORE_COUNT]; |
|||
|
|||
void simd_ctx_save(uint32_t security_state, bool hint_sve) |
|||
{ |
|||
simd_regs_t *regs; |
|||
|
|||
if (security_state != NON_SECURE && security_state != SECURE) { |
|||
ERROR("Unsupported security state specified for SIMD context: %u\n", |
|||
security_state); |
|||
panic(); |
|||
} |
|||
|
|||
regs = &simd_context[security_state][plat_my_core_pos()]; |
|||
|
|||
#if CTX_INCLUDE_SVE_REGS |
|||
regs->hint = hint_sve; |
|||
|
|||
if (hint_sve) { |
|||
/*
|
|||
* Hint bit denoting absence of SVE live state. Hence, only |
|||
* save FP context. |
|||
*/ |
|||
fpregs_context_save(regs); |
|||
} else { |
|||
sve_context_save(regs); |
|||
} |
|||
#elif CTX_INCLUDE_FPREGS |
|||
fpregs_context_save(regs); |
|||
#endif |
|||
} |
|||
|
|||
void simd_ctx_restore(uint32_t security_state) |
|||
{ |
|||
simd_regs_t *regs; |
|||
|
|||
if (security_state != NON_SECURE && security_state != SECURE) { |
|||
ERROR("Unsupported security state specified for SIMD context: %u\n", |
|||
security_state); |
|||
panic(); |
|||
} |
|||
|
|||
regs = &simd_context[security_state][plat_my_core_pos()]; |
|||
|
|||
#if CTX_INCLUDE_SVE_REGS |
|||
if (regs->hint) { |
|||
fpregs_context_restore(regs); |
|||
} else { |
|||
sve_context_restore(regs); |
|||
} |
|||
#elif CTX_INCLUDE_FPREGS |
|||
fpregs_context_restore(regs); |
|||
#endif |
|||
} |
|||
#endif /* CTX_INCLUDE_FPREGS || CTX_INCLUDE_SVE_REGS */ |
@ -0,0 +1,28 @@ |
|||
/* |
|||
* Copyright (c) 2024, Arm Limited. All rights reserved. |
|||
* |
|||
* SPDX-License-Identifier: BSD-3-Clause |
|||
* |
|||
* This file is a Partition Manifest (PM) for a minimal Secure Partition (SP) |
|||
* that will be consumed by EL3 SPMC. |
|||
* |
|||
*/ |
|||
|
|||
/dts-v1/; |
|||
|
|||
/ { |
|||
compatible = "arm,ffa-manifest-1.0"; |
|||
#address-cells = <2>; |
|||
#size-cells = <1>; |
|||
|
|||
/* Properties */ |
|||
ffa-version = <0x00010001>; /* 31:16 - Major, 15:0 - Minor */ |
|||
id = <0x8001>; |
|||
uuid = <0x1e67b5b4 0xe14f904a 0x13fb1fb8 0xcbdae1da>; |
|||
messaging-method = <3>; /* Direct messaging only */ |
|||
exception-level = <2>; /* S-EL1 */ |
|||
execution-state = <0>; /* AARCH64 */ |
|||
execution-ctx-count = <8>; |
|||
/* Boot protocol */ |
|||
gp-register-num = <0>; |
|||
}; |
Loading…
Reference in new issue