| edebefbc | 11-Oct-2023 |
Arvind Ram Prakash <arvind.ramprakash@arm.com> |
fix(mpam): refine MPAM initialization and enablement process
Restricts MPAM to only NS world and enables trap to EL3 for access of MPAM registers from lower ELs of Secure and Realm world.
This patc
fix(mpam): refine MPAM initialization and enablement process
Restricts MPAM to only NS world and enables trap to EL3 for access of MPAM registers from lower ELs of Secure and Realm world.
This patch removes MPAM enablement from global context and adds it to EL3 State context which enables/disables MPAM during world switches. Renamed ENABLE_MPAM_FOR_LOWER_ELS to ENABLE_FEAT_MPAM and removed mpam_init_el3() as RESET behaviour is trapping.
Signed-off-by: Arvind Ram Prakash <arvind.ramprakash@arm.com> Change-Id: I131f9dba5df236a71959b2d425ee11af7f3c38c4
show more ...
|
| 85bebe18 | 11-Oct-2023 |
Sandrine Bailleux <sandrine.bailleux@arm.com> |
refactor(console): disable getc() by default
The ability to read a character from the console constitutes an attack vector into TF-A, as it gives attackers a means to inject arbitrary data into TF-A
refactor(console): disable getc() by default
The ability to read a character from the console constitutes an attack vector into TF-A, as it gives attackers a means to inject arbitrary data into TF-A. It is dangerous to keep that feature enabled if not strictly necessary, especially in production firmware builds.
Thus, we need a way to disable this feature. Moreover, when it is disabled, all related code should be eliminated from the firmware binaries, such that no remnant/dead getc() code remains in memory, which could otherwise be used as a gadget as part of a bigger security attack.
This patch disables getc() feature by default. For legitimate getc() use cases [1], it can be explicitly enabled by building TF-A with ENABLE_CONSOLE_GETC=1.
The following changes are introduced when getc() is disabled:
- The multi-console framework no longer provides the console_getc() function.
- If the console driver selected by the platform attempts to register a getc() callback into the multi-console framework then TF-A will now fail to build.
If registered through the assembly function finish_console_register(): - On AArch64, you'll get: Error: undefined symbol CONSOLE_T_GETC used as an immediate value. - On AArch32, you'll get: Error: internal_relocation (type: OFFSET_IMM) not fixed up
If registered through the C function console_register(), this requires populating a struct console with a getc field, which will trigger: error: 'console_t' {aka 'struct console'} has no member named 'getc'
- All console drivers which previously registered a getc() callback have been modified to do so only when ENABLE_CONSOLE_GETC=1.
[1] Example of such use cases would be: - Firmware recovery: retrieving a golden BL2 image over the console in order to repair a broken firmware on a bricked board. - Factory CLI tool: Drive some soak tests through the console.
Discussed on TF-A mailing list here: https://lists.trustedfirmware.org/archives/list/tf-a@lists.trustedfirmware.org/thread/YS7F6RCNTWBTEOBLAXIRTXWIOYINVRW7/
Change-Id: Icb412304cd23dbdd7662df7cf8992267b7975cc5 Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com> Acked-by: Baruch Siach <baruch@tkos.co.il>
show more ...
|
| 5c52d7e5 | 22-May-2023 |
Boyan Karatotev <boyan.karatotev@arm.com> |
refactor(cm): remove world differentiation for EL2 context restore
The EL2 context save/restore functions have an optimisation to not bother with the EL2 context when SEL2 is not in use. However, th
refactor(cm): remove world differentiation for EL2 context restore
The EL2 context save/restore functions have an optimisation to not bother with the EL2 context when SEL2 is not in use. However, this decision is made on the current value of SCR_EL3.EEL2, which is not the value for the selected security state, but rather, for the security state that came before it. This relies on the EEL2 bit's value to propagate identically to all worlds.
This has an unintended side effect that for the first entry into secure world, the restoring of the context is fully skipped, because SCR_EL3 is only initialized after the call to the restoring routine which means the EEL2 bit is not initialized (except when FEAT_RME is present). This is inconsistent with normal and realm worlds which always get their EL2 registers zeroed.
Remove this optimization to remove all the complexity with managing the EEL2 bit's value. Instead unconditionally save/restore all registers. It is worth noting that there is no performance penalty in the case where SEL2 is empty with this change. This is because SEL2 will never be entered, and as such no secure save/restore will happen anyway, while normal world remains unchanged.
Removing the value management of the EEL2 bit causes the CTX_ICC_SRE_EL2 register to be inaccessible in Secure world for some configurations. Make the SCR_EL3.NS workaround in cm_prepare_el3_exit_ns() generic on every access to the register.
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com> Change-Id: I1f56d85814c5897b468e82d4bd4a08e3a90a7f8f
show more ...
|
| f0c96a2e | 20-Apr-2023 |
Boyan Karatotev <boyan.karatotev@arm.com> |
refactor(cm): clean up SCR_EL3 and CPTR_EL3 initialization
As with MDCR_EL3, setting some bits of these registers is redundant at reset since they do not matter for EL3 execution and the registers g
refactor(cm): clean up SCR_EL3 and CPTR_EL3 initialization
As with MDCR_EL3, setting some bits of these registers is redundant at reset since they do not matter for EL3 execution and the registers get context switched so they get overwritten anyway.
The SCR_EL3.{TWE, TWI, SMD, API, APK} bits only affect lower ELs so their place is in context management. The API and APK bits are a bit special as they would get implicitly unset for secure world when CTX_INCLUDE_PAUTH_REGS is unset. This is now explicit with their normal world values being always set as PAuth defaults to enabled. The same sequence is also added to realm world too. The reasoning is the same as for Secure world - PAuth will be enabled for NS, and unless explicitly handled by firmware, it should not leak to realm.
The CPTR_EL3.{ESM, EZ, TAM} bits are set by the relevant feat_enable()s in lib/extensions so they can be skipped too.
CPTR_EL3.TFP is special as it's needed for access to generic floating point registers even when SVE is not present. So keep it but move to context management.
This leaves CPTR_EL3.TCPAC which affects several extensions. This bit was set centrally at reset, however the earliest need for it is in BL2. So set it in cm_setup_context_common(). However, this CPTR_EL3 is only restored for BL31 which is clearly not the case. So always restore it.
Finally, setting CPTR_EL3 to a fresh RESET_VAL for each security state prevents any bits from leaking between them.
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com> Signed-off-by: Jayanth Dodderi Chidanand <jayanthdodderi.chidanand@arm.com> Change-Id: Ie7095e967bd4a6d6ca6acf314c7086d89fec8900
show more ...
|
| 278beb89 | 13-Sep-2023 |
Jacky Bai <ping.bai@nxp.com> |
feat(cpufeat): add memory retention bit define for CLUSTERPWRDN
Bit1 in the CLUSTERPWRDN register is used to indicate on CLUSTERPACTIVE that memory retention is required or not. It can be used for L
feat(cpufeat): add memory retention bit define for CLUSTERPWRDN
Bit1 in the CLUSTERPWRDN register is used to indicate on CLUSTERPACTIVE that memory retention is required or not. It can be used for L3 cache memory retention support.
Signed-off-by: Jacky Bai <ping.bai@nxp.com> Change-Id: I1c53c90ae3dfbed3be7e5b2b79f2c3565db81012
show more ...
|
| 6a62ddff | 30-Aug-2023 |
Manish Pandey <manish.pandey2@arm.com> |
Merge "feat(cpufeat): initialize HFG*_EL2 registers" into integration |
| 0bbd4329 | 14-Aug-2023 |
Juan Pablo Conde <juanpablo.conde@arm.com> |
fix(cpus): check for SME presence in Gelas
The original powerdown function for Gelas included SME disabling instructions but did not check for the presence of SME before disabling. This could lead t
fix(cpus): check for SME presence in Gelas
The original powerdown function for Gelas included SME disabling instructions but did not check for the presence of SME before disabling. This could lead to unexpected beaviors. This patch adds that check so the feature is disabled only if it is present.
Change-Id: I582db53a6669317620e4f72a3eac87525897d3d0 Signed-off-by: Juan Pablo Conde <juanpablo.conde@arm.com>
show more ...
|
| 29440a2f | 17-Aug-2023 |
Manish V Badarkhe <manish.badarkhe@arm.com> |
Merge "refactor(cm): move remaining EL2 save/restore into C" into integration |
| ac58e574 | 15-May-2023 |
Boyan Karatotev <boyan.karatotev@arm.com> |
refactor(cm): move remaining EL2 save/restore into C
MTE and common system registers are the last remaining EL2 save/restores in assembly. Convert them to C, like all the others.
Signed-off-by: Boy
refactor(cm): move remaining EL2 save/restore into C
MTE and common system registers are the last remaining EL2 save/restores in assembly. Convert them to C, like all the others.
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com> Change-Id: If690f792e70b97fd4b4cd5f43847a71719b128f1
show more ...
|
| a8d5d3d5 | 18-Apr-2023 |
Andre Przywara <andre.przywara@arm.com> |
refactor(cpufeat): introduce wrapper macro for read_feat_...() functions
At the moment we have some elaborate, but very schematic functions to allow checking for CPU feature enablement. Adding some
refactor(cpufeat): introduce wrapper macro for read_feat_...() functions
At the moment we have some elaborate, but very schematic functions to allow checking for CPU feature enablement. Adding some more becomes tedious and is also error-prone.
Provide two wrapper macros that reduce most of the features to a single line: - CREATE_FEATURE_FUNCS(name, idreg, idfield, guard) creates two functions read_<name>_id_field() and is_<name>_supported(), that check the 4-bit CPU ID field starting at bit <idfield> in <idreg> for being not 0, and compares it against the build time <guard> symbol. For the usual feature (like PAN) this looks like: CREATE_FEATURE_FUNCS(feat_pan, id_aa64mmfr1_el1, ID_AA64MMFR1_EL1_PAN_SHIFT, ENABLE_FEAT_PAN)
- CREATE_FEATURE_FUNCS_VER(name, read_func, idvalue, guard) creates one function to check for a certain CPU ID field *value*, so when "!= 0" is not sufficient. It's meant to be used in addition to the above macro, since that generates the CPU ID field accessor function: CREATE_FEATURE_FUNCS(feat_amu, id_aa64pfr0_el1, ID_AA64PFR0_AMU_SHIFT, ENABLE_FEAT_AMU) CREATE_FEATURE_FUNCS_VER(feat_amuv1p1, read_feat_amu_id_field, ID_AA64PFR0_AMU_V1P1, ENABLE_FEAT_AMUv1p1)
Describe the existing feature accessor functions using those new macros, to reduce the size of the file, improve readability and decrease the possibility of (copy&paste) bugs.
Change-Id: Ib136a875b4857058ff561c4635ace344006f29bf Signed-off-by: Andre Przywara <andre.przywara@arm.com>
show more ...
|
| 4a530b4c | 10-Jul-2023 |
Juan Pablo Conde <juanpablo.conde@arm.com> |
feat(cpufeat): initialize HFG*_EL2 registers
HFG*_EL2 registers control the fine-grained traps introduced by FEAT_FGT. These traps come enabled by default so old systems unaware of this feature can
feat(cpufeat): initialize HFG*_EL2 registers
HFG*_EL2 registers control the fine-grained traps introduced by FEAT_FGT. These traps come enabled by default so old systems unaware of this feature can be trapped to EL3, not being able to handle the trap correctly. This patch disables all fine-grained traps by default to prevent such unexpected behavior.
Change-Id: If2ae97accbeed2bea51ae03b5225ce762ecffb25 Signed-off-by: Juan Pablo Conde <juanpablo.conde@arm.com>
show more ...
|
| ece8f7d7 | 13-Feb-2023 |
Boyan Karatotev <boyan.karatotev@arm.com> |
refactor(cm): set MDCR_EL3/CPTR_EL3 bits in respective feat_init_el3() only
These bits (MDCR_EL3.{NSTB, NSTBE, TTRF, TPM}, CPTR_EL3.TTA) only affect EL2 (and lower) execution. Each feat_init_el3() i
refactor(cm): set MDCR_EL3/CPTR_EL3 bits in respective feat_init_el3() only
These bits (MDCR_EL3.{NSTB, NSTBE, TTRF, TPM}, CPTR_EL3.TTA) only affect EL2 (and lower) execution. Each feat_init_el3() is called long before any lower EL has had a chance to execute, so setting the bits at reset is redundant. Removing them from reset code also improves readability of the immutable EL3 state.
Preserve the original intention for the TTA bit of "enabled for NS and disabled everywhere else" (inferred from commit messages d4582d3088 and 2031d6166a and the comment). This is because CPTR_EL3 will be contexted and so everyone will eventually get whatever NS has anyway.
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com> Change-Id: I3d24b45d3ea80882c8e450b2d9db9d5531facec1
show more ...
|
| 99506fac | 13-Feb-2023 |
Boyan Karatotev <boyan.karatotev@arm.com> |
fix(cm): set MDCR_EL3.{NSPBE, STE} explicitly
With the introduction of FEAT_RME MDCR_EL3 bits NSPB and NSPBE depend on each other. The enable code relies on the register being initialised to zero an
fix(cm): set MDCR_EL3.{NSPBE, STE} explicitly
With the introduction of FEAT_RME MDCR_EL3 bits NSPB and NSPBE depend on each other. The enable code relies on the register being initialised to zero and omits to reset NSPBE. However, this is not obvious. Reset the bit explicitly to document this.
Similarly, reset the STE bit , since it's part of the feature enablement.
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com> Change-Id: I3714507bae10042cdccd2b7bc713b31d4cdeb02f
show more ...
|
| 4d0b6632 | 24-Mar-2023 |
Maksims Svecovs <maksims.svecovs@arm.com> |
feat(mte): adds feature detection for MTE_PERM
Adds feature detection for v8.9 feature FEAT_MTE_PERM. Adds respective ID_AA64PFR2_EL1 definitions and ENABLE_FEAT_MTE_PERM define.
Change-Id: If24b42
feat(mte): adds feature detection for MTE_PERM
Adds feature detection for v8.9 feature FEAT_MTE_PERM. Adds respective ID_AA64PFR2_EL1 definitions and ENABLE_FEAT_MTE_PERM define.
Change-Id: If24b42f1207154e639016b0b840b2d91c6ee13d4 Signed-off-by: Maksims Svecovs <maksims.svecovs@arm.com> Signed-off-by: Harrison Mutai <harrison.mutai@arm.com>
show more ...
|
| 83a4dae1 | 16-Feb-2023 |
Boyan Karatotev <boyan.karatotev@arm.com> |
refactor(pmu): convert FEAT_MTPMU to C and move to persistent register init
The FEAT_MTPMU feature disable runs very early after reset. This means, it needs to be written in assembly, since the C ru
refactor(pmu): convert FEAT_MTPMU to C and move to persistent register init
The FEAT_MTPMU feature disable runs very early after reset. This means, it needs to be written in assembly, since the C runtime has not been initialised yet.
However, there is no need for it to be initialised so soon. The PMU state is only relevant after TF-A has relinquished control. The code to do this is also very verbose and difficult to read. Delaying the initialisation allows for it to happen with the rest of the PMU. Align with FEAT_STATE in the process.
BREAKING CHANGE: This patch explicitly breaks the EL2 entry path. It is currently unsupported.
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com> Change-Id: I2aa659d026fbdb75152469f6d19812ece3488c6f
show more ...
|
| c73686a1 | 15-Feb-2023 |
Boyan Karatotev <boyan.karatotev@arm.com> |
feat(pmu): introduce pmuv3 lib/extensions folder
The enablement code for the PMU is scattered and difficult to track down. Factor out the feature into its own lib/extensions folder and consolidate t
feat(pmu): introduce pmuv3 lib/extensions folder
The enablement code for the PMU is scattered and difficult to track down. Factor out the feature into its own lib/extensions folder and consolidate the implementation. Treat it is as an architecturally mandatory feature as it is currently.
Additionally, do some cleanup on AArch64. Setting overflow bits in PMCR_EL0 is irrelevant for firmware so don't do it. Then delay the PMU initialisation until the context management stage which simplifies the early environment assembly. One side effect is that the PMU might count before this happens so reset all counters to 0 to prevent any leakage.
Finally, add an enable to manage_extensions_realm() as realm world uses the pmu. This introduces the HPMN fixup to realm world.
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com> Change-Id: Ie13a8625820ecc5fbfa467dc6ca18025bf6a9cd3
show more ...
|
| 33815eb7 | 15-Jun-2023 |
Boyan Karatotev <boyan.karatotev@arm.com> |
fix(pmu): make MDCR_EL3.MTPME=1 out of reset
Make the default value for MTPME always be 1 to preserve the reset behaviour on newer revisions and on older revisions where the bit is RES0 it doesn't m
fix(pmu): make MDCR_EL3.MTPME=1 out of reset
Make the default value for MTPME always be 1 to preserve the reset behaviour on newer revisions and on older revisions where the bit is RES0 it doesn't matter.
Before its introduction MDCR_EL3.MTPME was RES0. Upon its introduction the field resets to 1, making the MTPMU architecturally "enabled". As such, the logical action on TF-A's part is to "disable" it, which led to the introduction of DISABLE_MTPMU.
This hinges on the assumption that MDCR_EL3.MTPME will always be 1 unless the above flag is set. Unfortunately this is not the case, as the reset value is overwritten at reset with a macro that sets this bit to 0.
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com> Change-Id: Ie570774972f246b3aa41dc016ecbcc6fc2f581f6
show more ...
|
| c64681d0 | 08-Jun-2023 |
Manish V Badarkhe <manish.badarkhe@arm.com> |
Merge "feat(aarch64): add stack debug information to assembly routines" into integration |
| 6e1ae307 | 07-Jun-2023 |
Manish Pandey <manish.pandey2@arm.com> |
Merge "fix(qemu): fix 32-bit builds with stack protector" into integration |
| e1c0a472 | 06-Jun-2023 |
Manish Pandey <manish.pandey2@arm.com> |
Merge changes from topic "dummy_feat_aa32" into integration
* changes: feat(cpufeat): deny AArch64-only features when building for AArch32 feat(cpufeat): add AArch32 PAN detection support |
| f8328853 | 10-Mar-2023 |
Boyan Karatotev <boyan.karatotev@arm.com> |
feat(aarch64): add stack debug information to assembly routines
Debugging assembly is painful as it is, and having no useful stack trace does not help. Code must emit CFI directives whenever the sta
feat(aarch64): add stack debug information to assembly routines
Debugging assembly is painful as it is, and having no useful stack trace does not help. Code must emit CFI directives whenever the stack moves to enable stack traces. Otherwise, the layout of the stack frame is ambiguous, the debugger gives up, and shows nothing. The compiler does this automatically for C but not assembly.
Add this information to the (currently unused) func_prologue macro.
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com> Change-Id: Ief5fd672285df8d9d90fa6a2214b5c6e45eddd81
show more ...
|
| bff074dd | 03-May-2023 |
Javier Almansa Sobrino <javier.almansasobrino@arm.com> |
feat(xlat): detect 4KB and 16KB page support when FEAT_LPA2 is present
At the moment, TF-A does not need to access VAs or PAs larger than 48 bits, so this patch just enables proper detection of supp
feat(xlat): detect 4KB and 16KB page support when FEAT_LPA2 is present
At the moment, TF-A does not need to access VAs or PAs larger than 48 bits, so this patch just enables proper detection of support for 4KB and 16KB granularity with 52 bits address support.
Signed-off-by: Javier Almansa Sobrino <javier.almansasobrino@arm.com> Change-Id: Iccebbd5acc21f09dbb234ef21a802300e290ec18
show more ...
|
| 007433d8 | 25-Jan-2023 |
Boyan Karatotev <boyan.karatotev@arm.com> |
refactor(cpus): move cpu_ops field defines to a header
The cpu_macros.S file is loaded with lots of definitions for the cpu_ops structure. However, since they are defined as .equ directives they are
refactor(cpus): move cpu_ops field defines to a header
The cpu_macros.S file is loaded with lots of definitions for the cpu_ops structure. However, since they are defined as .equ directives they are inaccessible for C code. Convert them to #defines, put them into order, refactor them for readability, and extract them to a separate file to make this possible.
This has the benefit of removing some Aarch differences and a lot of duplicate code.
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com> Change-Id: I72861794b6c9131285a9297d5918822ed718b228
show more ...
|
| e57ca899 | 23-May-2023 |
Andre Przywara <andre.przywara@arm.com> |
fix(qemu): fix 32-bit builds with stack protector
When using the ENABLE_STACK_PROTECTOR=strong build option, the QEMU code will try to use the RNDR CPU instructions to initialise the stack canary. S
fix(qemu): fix 32-bit builds with stack protector
When using the ENABLE_STACK_PROTECTOR=strong build option, the QEMU code will try to use the RNDR CPU instructions to initialise the stack canary. Since the instructions are defined for AArch64 only, this will fail to build for AArch32.
And even though we now always return "false" when asked about the availability of the RNDR instruction, the compiler will still leave the reference to read_rdnr() in, if optimisations are turned off (-O0).
Avoid this by providing a dummy read_rndr() implementation, that makes the linker happy in any case.
This fixes the QEMU build for AArch32 with ENABLE_STACK_PROTECTOR=strong
Change-Id: Ibf450ba4a46167fdf3a14a527d338350ced8b5ba Signed-off-by: Andre Przywara <andre.przywara@arm.com>
show more ...
|
| 733d112f | 23-May-2023 |
Andre Przywara <andre.przywara@arm.com> |
feat(cpufeat): deny AArch64-only features when building for AArch32
Many newer architecture features are defined for AArch64 only, so cannot be used in an AArch32 build.
To avoid #ifdef-ing every s
feat(cpufeat): deny AArch64-only features when building for AArch32
Many newer architecture features are defined for AArch64 only, so cannot be used in an AArch32 build.
To avoid #ifdef-ing every single user, just provide trivial implementations of the feature check functions is_feat_xxx_supported(), which always return "false" in AArch32. The compiler will then optimise out the dependent code automatically.
Change-Id: I1e7d653fca0e676a11858efd953c2d623f2d5c9e Signed-off-by: Andre Przywara <andre.przywara@arm.com>
show more ...
|