Commit graph

654 commits

Author SHA1 Message Date
Olivier Deprez
abe80629fc Merge "fix(el3-spmc): fix incorrect CASSERT" into integration 2023-07-25 15:32:54 +02:00
Bipin Ravi
fbc90e0fdd Merge "fix(cpus): workaround for Neoverse V2 erratum 2801372" into integration 2023-07-25 15:00:29 +02:00
Demi Marie Obenour
1dd79f9e23 fix(el3-spmc): fix incorrect CASSERT
Check that the size of desc->emad_count is 4, not that sizeof(int) is
nonzero.  Also improve a comment.

Change-Id: I8bf69b637158ddffe2d08aed3d9879a4d7fd3514
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-07-25 09:29:47 +02:00
Boyan Karatotev
ece8f7d734 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
2023-07-24 11:04:44 +01:00
Moritz Fischer
40c81ed533 fix(cpus): workaround for Neoverse V2 erratum 2801372
Neoverse V2 erratum 2801372 is a Cat B erratum that applies to
all revisions <=r0p1 and is fixed in r0p2. The workaround is to
insert a dsb before the isb in the power down sequence.

This errata is explained in SDEN 2332927 available at:
https://developer.arm.com/documentation/SDEN2332927

Change-Id: I8716b9785a67270a72ae329dc49a2f2239dfabff
Signed-off-by: Moritz Fischer <moritzf@google.com>
2023-07-21 16:52:36 +02:00
Madhukar Pappireddy
6c91fc4458 fix(spmd): perform G0 interrupt acknowledge and deactivation
Prior to delegating handling of Group0 secure interrupt to platform
handler, SPMD framework must acknowledge the highest pending interrupt.
Moreover, once the platform has handled the interrupt successfully,
SPMD must deactivate the interrupt.

The rationale behind this decision is SPMD framework is well suited to
perform interrupt management at GIC boundary while the platform handler
is well equipped to deal with the device interface related to the
interrupt.

This patch also fixes a bug in the error code returned upon invocation
of FFA_EL3_INTR_HANDLE from normal world.

Change-Id: If8fef51899e25f966038cc01ec58c84ee25e88eb
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
2023-07-17 13:35:43 -05:00
Boyan Karatotev
c73686a11c 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
2023-06-29 09:59:06 +01:00
Manish Pandey
0ad935f72a Merge changes from topic "ffa_el3_spmc_fixes" into integration
* changes:
  fix(tsp): fix destination ID in direct request
  fix(el3-spm): fix LSP direct message response
  fix(el3-spm): improve direct messaging validation
2023-06-22 16:49:55 +02:00
Marc Bonnici
48fe24c50c fix(el3-spm): improve direct messaging validation
Perform additional validation of the source and destination
IDs of direct messages.
Additionally track the sender of a direct request to allow
validating the target of the corresponding direct response.

Signed-off-by: Marc Bonnici <marc.bonnici@arm.com>
Change-Id: I8d39d53a02b8333246f1500c79ba04f149459c16
2023-06-21 22:11:44 +01:00
Demi Marie Obenour
95c56cb189 refactor(el3-spmc): add comments and cleanup code
No functional change intended.

Change-Id: I08300ec4cb2e11d26c4a108769919d0c474292ff
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-06-20 11:18:05 -04:00
Demi Marie Obenour
b8007bebea refactor(el3-spmc): avoid extra loop
Using one loop for the duplicate partition ID check is both simpler and
faster.

Change-Id: I0f6fa9ceb1aadf4383fa9be16605c39ad8643a43
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-06-20 11:18:05 -04:00
Demi Marie Obenour
327b5b8b74 fix(el3-spmc): validate memory address alignment
This ensures that addresses shared using FF-A are 4K aligned, as
required by the specification.

Change-Id: I8f0a659a095fdb9391398757141d613ac9bf9b42
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-06-20 11:18:05 -04:00
Olivier Deprez
e779c1afe2 Merge changes Ic58f4966,Ib7b438b8,I400f0f1f into integration
* changes:
  refactor(el3-spmc): add comments
  refactor(el3-spmc): move checks after loop
  refactor(el3-spmc): validate alignment earlier
2023-06-20 16:07:36 +02:00
Olivier Deprez
bb6d0a174f fix(spmd): relax use of EHF with SPMC at S-EL2
Follow up to [1] and [2], for systems implementing the SPMC at S-EL2,
it is necessary to leave the option for handling Group0 interrupts
(while the normal world runs) through the EHF by the use of the
EL3_EXCEPTION_HANDLING option.
Specifically for RAS, the handling through EHF is still required because
the platform function provided by the SPMD doesn't provide the facility
to link back to the RAS handling framework.

[1] https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/16047
[2] https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/19897

Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Change-Id: Idf8741887904a286fb3f5ab2d754afd2fc78d3b0
2023-06-13 08:59:17 +02:00
Demi Marie Obenour
794c409f48 refactor(el3-spmc): add comments
Change-Id: Ic58f4966159cafa83eec8e6b18a96b0a8b2ce781
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-06-12 12:21:05 -04:00
Demi Marie Obenour
966c63e6b2 refactor(el3-spmc): move checks after loop
This makes the code cleaner.  No functional change intended.

Change-Id: Ib7b438b830e8e3b7ac6e30d688f5172cbaa58121
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-06-12 12:21:05 -04:00
Demi Marie Obenour
27ac582ae0 refactor(el3-spmc): validate alignment earlier
Future changes will cause spmc_shmem_obj_get_comp_mrd to panic instead
of returning NULL, so be sure that comp_mrd_offset has been validated
already.  The existing code checks for 8-byte alignment, but comments in
el3_spmc_ffa_memory.h indicate that 16-byte alignment is expected, so
require 16-byte alignment.

Change-Id: I400f0f1f163522cb5ea77d4811c91e8b7e655c18
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-06-12 12:21:05 -04:00
Demi Marie Obenour
a0239da987 refactor(el3-spmc): add emad_advance()
This will be needed later.

Change-Id: I396b5e1410268d98cf6bf00cd553a5d01123847c
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-06-05 13:22:21 -04:00
Demi Marie Obenour
dd94372d77 fix(el3-spmc): validate shmem descriptor alignment
If the size of a shmem descriptor is not a multiple of 16, the
descriptor would be unusable, but the problem would be caught much
later.

Change-Id: I907f3862b55c6341e39a6b8b2e24784127230478
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-06-05 13:22:21 -04:00
Demi Marie Obenour
91567c3843 refactor(el3-spmc): avoid using EINVAL
Use proper FF-A return code instead.

Change-Id: Ie749ff06339bc137d3baa96f06f0a6160b35abed
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-06-05 13:22:21 -04:00
Demi Marie Obenour
27c0242508 fix(el3-spmc): avoid descriptor size calc overflow
This ensures that descriptor size calculation does not overflow and
removes a bounds check that does not actually work.

Change-Id: If8da2bb1b312941b7f9d0debf3149b984fc3809a
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-06-05 13:22:21 -04:00
Demi Marie Obenour
43318e4a4d fix(el3-spmc): use uint64_t for 64-bit type
Using uint64_t is cleaner, even though size_t is 64 bits on all
platforms el3-spmc supports.

Change-Id: I457deb0b7f3df0749cb5368cceda1bb530d039de
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-06-05 13:22:21 -04:00
Demi Marie Obenour
1198ff8424 refactor(el3-spmc): avoid unneeded function call
The information is already available inline.  No functional change
intended.

Change-Id: I13d2ad62a9315b233d7a5fd3ffcaac3dd01b055c
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-06-05 13:22:21 -04:00
Demi Marie Obenour
48ffc74c97 refactor(el3-spmc): move function call out of loop
Hopefully this will be a tiny speedup.  No functional change intended.

Change-Id: Ia052c7f9b24d5ece6209a6fa2903b1271215ece7
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-06-05 13:22:21 -04:00
Demi Marie Obenour
9526282a7d refactor(el3-spmc): crash instead of reading OOB
If it is called on an invalid mtd, out-of-bounds memory reads are
likely.  Checks elsewhere in the code ensure that the mtd has been
validated before calling this function.

Change-Id: If598680a5b79e1786a6e0a213779ec80cbf37494
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-06-05 13:22:21 -04:00
Demi Marie Obenour
2d4da8e265 fix(el3-spmc): prevent total_page_count overflow
size_t is not guaranteed to be 64 bits, although it happens to be 64
bits on all systems that el3-spmc supports.

Change-Id: Ieae11722a15448641de50233597ac35869eab574
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-06-05 13:22:21 -04:00
Manish Pandey
a0f3b552cf Merge "chore: rename Makalu to Cortex-A715" into integration 2023-06-05 16:21:47 +02:00
Harrison Mutai
15889d1332 chore: rename Makalu to Cortex-A715
Change-Id: I017c955cb643e2befb6b01e1b5a07c22172b08b9
Signed-off-by: Harrison Mutai <harrison.mutai@arm.com>
2023-05-30 09:52:14 +01:00
Boyan Karatotev
6bb96fa6d6 refactor(cpus): rename errata_report.h to errata.h
The ERRATA_XXX macros, used in cpu_helpers.S, are necessary for the
check_errata_xxx family of functions. The CPU_REV should be used in the
cpu files but for whatever reason the values have been hard-coded so far
(at the cost of readability). It's evident this file is not strictly for
status reporting.

The new purpose of this file is to make it a one-stop-shop for all
things errata.

Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
Change-Id: I1ce22dd36df5aa0bcfc5f2772251f91af8703dfb
2023-05-30 09:31:15 +01:00
Manish Pandey
4bb0cdc159 Merge changes I31ec0001,Ib06cd024,I7c11f15d,Ie0d5d4c8,I285f3b59, ... into integration
* changes:
  fix(el3-spmc): correctly account for emad_offset
  refactor(el3-spmc): avoid unnecessarily revalidating offset
  fix(el3-spmc): only call spmc_shm_check_obj() on complete objects
  refactor(spmc): assert on out-of-bounds emad access
  refactor(el3-spmc): spmc_shmem_obj_get_emad() will never fail
  fix(el3-spmc): validate descriptor headers
  fix(el3-spmc): use version-dependent minimum descriptor length
  refactor(el3-spmc): check emad_count offset
2023-05-25 12:35:46 +02:00
Jeffrey Kardatzke
f4bbf43555 feat(optee): add device tree for coreboot table
This adds creation of a device tree that will be passed to OP-TEE.
Currently that device tree only contains the coreboot table per the
Linux coreboot device tree specification. This device tree is then
passed to OP-TEE so it can extract the CBMEM console information from
the coreboot table for logging purposes.

Signed-off-by: Jeffrey Kardatzke <jkardatzke@google.com>
Change-Id: I6a26d335e16f7226018c56ad571cca77b81b0f6a
2023-05-11 10:46:57 +02:00
Manish Pandey
4bd8c929b4 Merge changes I1bfa797e,I0ec7a70e into integration
* changes:
  fix(tree): correct some typos
  fix(rockchip): use semicolon instead of comma
2023-05-09 22:05:52 +02:00
Elyes Haouas
1b491eead5 fix(tree): correct some typos
found using codespell (https://github.com/codespell-project/codespell).

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Change-Id: I1bfa797e3460adddeefa916bb68e22beddaf6373
2023-05-09 15:57:12 +01:00
Sona Mathew
ab062f0510 fix(cpus): workaround platforms non-arm interconnect
The workarounds for these below mentioned errata are not implemented
in EL3, but the flags can be enabled/disabled at a platform level
based on arm/non-arm interconnect IP. The ABI helps assist the Kernel
in the process of mitigation for the following errata:

Cortex-A715:   erratum 2701951
Neoverse V2:   erratum 2719103
Cortex-A710:   erratum 2701952
Cortex-X2:     erratum 2701952
Neoverse N2:   erratum 2728475
Neoverse V1:   erratum 2701953
Cortex-A78:    erratum 2712571
Cortex-A78AE:  erratum 2712574
Cortex-A78C:   erratum 2712575

EL3 provides an appropriate return value via errata ABI when the
kernel makes an SMC call using the EM_CPU_ERRATUM_FEATURES FID with the
appropriate erratum ID.

Change-Id: I35bd69d812dba37410dd8bc2bbde20d4955b0850
Signed-off-by: Sona Mathew <SonaRebecca.Mathew@arm.com>
2023-05-05 13:23:10 -05:00
Sona Mathew
ef63f5be6d refactor(errata_abi): factor in non-arm interconnect
Workaround to help enable the kernel to query errata status using the
errata abi feature for platforms with a non-arm interconnect.

Change-Id: I47b03eaee5a0a763056ae71883fa30dfacb9b3f7
Signed-off-by: Sona Mathew <SonaRebecca.Mathew@arm.com>
2023-05-05 13:23:10 -05:00
Sona Mathew
ffea3844c0 feat(errata_abi): errata management firmware interface
This patch adds the errata management firmware interface for lower ELs
to discover details about CPU erratum. Based on the CPU erratum
identifier the interface enables the OS to find the mitigation of an
erratum in EL3.

The ABI can only be present in a system that is compliant with SMCCCv1.1
or higher. This implements v1.0 of the errata ABI spec.

For details on all possible return values, refer the design
documentation below:

ABI design documentation:
https://developer.arm.com/documentation/den0100/1-0?lang=en

Signed-off-by: Sona Mathew <SonaRebecca.Mathew@arm.com>
Change-Id: I70f0e2569cf92e6e02ad82e3e77874546232b89a
2023-05-05 13:23:10 -05:00
Demi Marie Obenour
0c2583c6fb fix(el3-spmc): correctly account for emad_offset
Use the address of emad 0 instead of the size of the MRD.

Change-Id: I31ec0001b4474e78caa9dfb468f63122a3708781
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-05-03 10:39:53 -04:00
Demi Marie Obenour
46d6b370f0 refactor(el3-spmc): avoid unnecessarily revalidating offset
The offset has been validated on the first loop iteration.  Subsequent
iterations can assume it is valid.

Change-Id: Ib06cd0240220b8aa42bcd34c3c40b69d2d86aa72
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-05-03 10:39:53 -04:00
Demi Marie Obenour
d781959f81 fix(el3-spmc): only call spmc_shm_check_obj() on complete objects
When called on incomplete objects, it might fail or access uninitialized
memory. This allows simplifying spmc_shm_check_obj().

Change-Id: I7c11f15d4c8ebe8cd15e7d8c37a0d0f3daa83675
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-05-03 10:39:53 -04:00
Demi Marie Obenour
77acde4c35 refactor(spmc): assert on out-of-bounds emad access
This always indicates a bug.

Change-Id: Ie0d5d4c84d9fb615ba6cdf0e6d46eab778fc7e94
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-05-03 10:39:53 -04:00
Demi Marie Obenour
cbbb8a03d6 refactor(el3-spmc): spmc_shmem_obj_get_emad() will never fail
Earlier validation ensures spmc_shmem_obj_get_emad() will never fail, so
trip an assertion instead of returning NULL.

Change-Id: I285f3b59150773b2404db5719753fdb240e9ed63
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-05-03 10:39:53 -04:00
Demi Marie Obenour
56c052d311 fix(el3-spmc): validate descriptor headers
This avoids out-of-bounds reads later.

Change-Id: Iee4245a393f1fde63d8ebada25ea2568cf984871
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-05-03 10:39:53 -04:00
Demi Marie Obenour
52d8d506e7 fix(el3-spmc): use version-dependent minimum descriptor length
A v1.1 descriptor has a minimum length exceeding that of a v1.0
descriptor.

Change-Id: I06265d58f53eccb0d39927fe9ff396b73735df97
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-05-03 10:39:53 -04:00
Madhukar Pappireddy
f0b64e507e feat(spmd): introduce platform handler for Group0 interrupt
This patch introduces a handler for FVP platform to triage Group0
secure interrupts. Currently, it is empty but serves as a
placeholder for future Group0 interrupt sources.

Moreover, this patch also provides a dummy implementation of the
above mentioned platform hook for QEMU, corstone100, n1sdp and
hikey960 ports.

Change-Id: I01d3451408f47ac313b0af74046cce89f89b85bb
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
2023-05-01 13:29:46 -05:00
Madhukar Pappireddy
6671b3d822 feat(spmd): add support for FFA_EL3_INTR_HANDLE_32 ABI
When Group0 Secure interrupts in secure world get trapped to S-EL2
SPMC, FFA_EL3_INTR_HANDLE ABI is invoked by SPMC to delegate
interrupt handling to EL3 firmware (i.e., SPMD).

SPMD further delegates to platform handler which successfully handles
the Group0 secure interrupt before returning control to SPMC.

Change-Id: I8cc0fec20803b96c81582910ad2668e38b167fb8
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
2023-05-01 13:29:12 -05:00
Madhukar Pappireddy
a1e0e871f1 feat(spmd): register handler for group0 interrupt from NWd
SPMD registers a generic handler with the interrupt management
framework to handle Group0 secure interrupt from normal world.
The handler further delegates to the platform for successful
handling of the interrupt.

Change-Id: I9cdc721810b09e01190cdcab42c50830792a26e2
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
2023-05-01 13:29:12 -05:00
Chris Kay
2ed0936dd0 build(trp): sort sections by alignment by default
This change forces LD to sort all input sections by alignment when
allocating them within an output section. This is done in some places
explicitly in the linker scripts today, but this makes sure we don't
miss any easy targets.

Change-Id: Ife89a8bb9e592b55c761d9a3dfefc2aeeb07802f
Signed-off-by: Chris Kay <chris.kay@arm.com>
2023-04-17 17:15:35 +01:00
Julius Werner
1845957132 Merge "fix(optee): return UUID for image loading service" into integration 2023-03-29 22:22:44 +02:00
Jayanth Dodderi Chidanand
2b0bc4e028 feat(cpufeat): enable FEAT_SVE for FEAT_STATE_CHECKED
Add support for runtime detection (ENABLE_SVE_FOR_NS=2), by splitting
sve_supported() into an ID register reading function and a
second function to report the support status. That function considers
both build time settings and runtime information (if needed), and is
used before we do SVE specific setup.

Change the FVP platform default to the now supported dynamic
option (=2), so the right decision can be made by the code at runtime.

Change-Id: I1caaba2216e8e2a651452254944a003607503216
Signed-off-by: Jayanth Dodderi Chidanand <jayanthdodderi.chidanand@arm.com>
2023-03-28 17:19:13 +02:00
Jayanth Dodderi Chidanand
45007acd46 feat(cpufeat): enable FEAT_SME for FEAT_STATE_CHECKED
Add support for runtime detection (ENABLE_SME_FOR_NS=2), by splitting
feat_sme_supported() into an ID register reading function and a
second function to report the support status. That function considers
both build time settings and runtime information (if needed), and is
used before we do SME specific setup.

Change the FVP platform default to the now supported dynamic option
(=2),so the right decision can be made by the code at runtime.

Change-Id: Ida9ccf737db5be20865b84f42b1f9587be0626ab
Signed-off-by: Jayanth Dodderi Chidanand <jayanthdodderi.chidanand@arm.com>
2023-03-28 17:19:07 +02:00