12179 Commits

Author SHA1 Message Date
Liju-Clr Chen
a321337bd2 refactor(mediatek): add new LPM API for further extension
Add new LPM API `mt_lp_rm_find_constraint` and `mt_lp_rm_run_constraint`
for further extension.

Signed-off-by: Liju-Clr Chen <liju-clr.chen@mediatek.com>
Change-Id: I8298811e03227285a7d086166edf9e87471f74b4
2023-01-11 13:37:51 +08:00
Liju-Clr Chen
b0208c73af refactor(mediatek): change the parameters of LPM API
Change the parameters of the LPM API for further extension.

Change-Id: Id8897c256c2118d00c6b9f3e7424ebc6100f02eb
Signed-off-by: Liju-Clr Chen <liju-clr.chen@mediatek.com>
2023-01-11 13:37:50 +08:00
Liju-Clr Chen
1c5fc9a254 refactor(mediatek): change LPM header file path for further extension
Move `mt_lp_rm.h` to `plat/mediatek/include/lpm` for further extension.

Change-Id: If377ce6791ce80f82643b0f2466eb0f1aa5aa40b
Signed-off-by: Liju-Clr Chen <liju-clr.chen@mediatek.com>
2023-01-11 13:37:48 +08:00
Shaocheng Wang
e56a939cab feat(mt8188): keep infra and peri on when system suspend
In order to wake up system from USB devices, keep infra and peri on
when system suspend.

Change-Id: I0a0eb2e72709b0cc1bf11b36241a50cb5d85d9b8
Signed-off-by: Shaocheng Wang <shaocheng.wang@mediatek.corp-partner.google.com>
2023-01-11 13:37:47 +08:00
James Liao
380f64b2e3 feat(mt8188): enable SPM and LPM
Enable SPM and LPM features for MT8188.

Signed-off-by: James Liao <jamesjj.liao@mediatek.com>
Change-Id: Ib3e2b305e9e3cf5a67e6e787ff942831b5ff28cd
2023-01-11 13:37:45 +08:00
James Liao
f299efbea6 feat(mt8188): add SPM feature support
Add SPM low power functions, such as system suspend.

Change-Id: I6d1ad847a81ba9c347ab6fb8a8cb8c69004b7add
Signed-off-by: James Liao <jamesjj.liao@mediatek.com>
2023-01-11 13:37:43 +08:00
James Liao
45d507599e feat(mt8188): add MT8188 SPM support
Add SPM basic functions including SPM init.

Signed-off-by: James Liao <jamesjj.liao@mediatek.com>
Change-Id: I5d4860685c15f3b8d555e697837862287f0c303e
2023-01-11 13:37:42 +08:00
James Liao
c234ad17d7 feat(mediatek): add SPM's SSPM notifier
The notifier is used to notify SSPM to sleep when system suspend or
notify SSPM to wakeup when system resume.

Change-Id: I027ca356a84ea1e58be54a8a5eb302b3b96c2e22
Signed-off-by: James Liao <jamesjj.liao@mediatek.com>
2023-01-11 13:37:40 +08:00
James Liao
1a64689df5 feat(mt8188): add the register definitions accessed by SPM
SPM needs to access some modules' registers to decide its sleep
behavior. This patch add these register definitions to platform_def.h.

Signed-off-by: James Liao <jamesjj.liao@mediatek.com>
Change-Id: I3bebe74e367d5f6a7b59563036e18a83a3ef31e9
2023-01-11 13:37:38 +08:00
James Liao
917abdd990 feat(mediatek): add new features of LPM
Add new functions and intefaces of LPM to support more interactions
between LPM providers and users.

Signed-off-by: James Liao <jamesjj.liao@mediatek.com>
Change-Id: I8ebbda0c0ef5be3a7a388a38c09424ebf785996f
2023-01-11 13:37:36 +08:00
Manish Pandey
76a91d8769 refactor(el3_runtime): remove unnecessary assembly macros
Following macros removed
  - handle_async_ea : It duplicates "check_and_unmask_ea" functionality
  - check_if_serror_from_EL3: This macro is small and called only once,
    replace this macro with instructions at the caller.

Signed-off-by: Manish Pandey <manish.pandey2@arm.com>
Change-Id: Id7eec6263ec23cc8792139f491c563f616fd3618
2023-01-10 18:02:36 +00:00
Yann Gautier
03bd48102b fix(console): correct scopes for console symbols
console_state is only used in multi_console.c, it is then declared as
static. console_list is used by several files, declare it as extern.
This corrects the 2 sparse warnings:
drivers/console/multi_console.c:13:11: warning: symbol 'console_list'
 was not declared. Should it be static?
drivers/console/multi_console.c:14:9: warning: symbol 'console_state'
 was not declared. Should it be static?

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: Id1891595906c258e8cb8aa325226f0a43723ca0e
2023-01-10 18:59:58 +01:00
Yann Gautier
654b65b36d fix(auth): use NULL instead of 0 for pointer check
This was triggered by sparse tool:
drivers/auth/mbedtls/mbedtls_x509_parser.c:481:42: warning:
 Using plain integer as NULL pointer

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I392316c2a81ef8da7597e35f136e038f152d19d1
2023-01-10 18:59:58 +01:00
Yann Gautier
06d223cb4f fix(io): compare function pointers with NULL
The ops->read and ops->write existence was checked with 0, change it
to NULL.
This corrects sparse issues:
drivers/io/io_block.c:272:9: warning:
 Using plain integer as NULL pointer
drivers/io/io_block.c:384:9: warning:
 Using plain integer as NULL pointer
drivers/io/io_block.c:384:9: warning:
 Using plain integer as NULL pointer

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I039050a645107523d8263ddf820e539c260d956c
2023-01-10 18:59:58 +01:00
Yann Gautier
e0c56fd71f fix(fdt-wrappers): use correct prototypes
These issues were triggered by sparse tool:
common/fdt_wrappers.c:209:36:
 warning: incorrect type in assignment (different base types)
  expected unsigned long long [usertype]
  got restricted fdt64_t
common/fdt_wrappers.c:211:36:
 warning: incorrect type in assignment (different base types)
  expected unsigned int [usertype]
  got restricted fdt32_t
common/fdt_wrappers.c:401:45:
 warning: incorrect type in argument 1 (different base types)
  expected restricted fdt32_t const [usertype] *prop
  got unsigned int const [usertype] *value
common/fdt_wrappers.c:402:52:
 warning: incorrect type in argument 1 (different base types)
  expected restricted fdt32_t const [usertype] *prop
  got unsigned int const [usertype] *
common/fdt_wrappers.c:404:66:
 warning: incorrect type in argument 1 (different base types)
  expected restricted fdt32_t const [usertype] *prop
  got unsigned int const [usertype] *

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I32067607cd4da1897f0ce5d8e1e2d51e044ab815
2023-01-10 18:59:58 +01:00
Demi Marie Obenour
f5c51855d3 fix(auth): properly validate X.509 extensions
get_ext() does not check the return value of the various mbedtls_*
functions, as cert_parse() is assumed to have guaranteed that they will
always succeed.  However, it passes the end of an extension as the end
pointer to these functions, whereas cert_parse() passes the end of the
TBSCertificate.  Furthermore, cert_parse() does *not* check that the
contents of the extension have the same length as the extension itself.
Before fd37982a19a4a291 ("fix(auth): forbid junk after extensions"),
cert_parse() also does not check that the extension block extends to the
end of the TBSCertificate.

This is a problem, as mbedtls_asn1_get_tag() leaves *p and *len
undefined on failure.  In practice, this results in get_ext() continuing
to parse at different offsets than were used (and validated) by
cert_parse(), which means that the in-bounds guarantee provided by
cert_parse() no longer holds.

This patch fixes the remaining flaw by enforcing that the contents of an
extension are the same length as the extension itself.

Change-Id: Id4570f911402e34d5d6c799ae01a01f184c68d7c
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
2023-01-10 14:52:45 +01:00
Demi Marie Obenour
abb8f936fd fix(auth): avoid out-of-bounds read in auth_nvctr()
auth_nvctr() does not check that the buffer provided is long enough to
hold an ASN.1 INTEGER, or even that the buffer is non-empty.  Since
auth_nvctr() will only ever read 6 bytes, it is possible to read up to
6 bytes past the end of the buffer.

This out-of-bounds read turns out to be harmless.  The only caller of
auth_nvctr() always passes a pointer into an X.509 TBSCertificate, and
all in-tree chains of trust require that the certificate’s signature has
already been validated.  This means that the signature algorithm
identifier is at least 4 bytes and the signature itself more than that.
Therefore, the data read will be from the certificate itself.  Even if
the certificate signature has not been validated, an out-of-bounds read
is still not possible.  Since there are at least two bytes (tag and
length) in both the signature algorithm ID and the signature itself, an
out-of-bounds read would require that the tag byte of the signature
algorithm ID would need to be either the tag or length byte of the
DER-encoded nonvolatile counter.  However, this byte must be
(MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE) (0x30), which is
greater than 4 and not equal to MBEDTLS_ASN1_INTEGER (2).  Therefore,
auth_nvctr() will error out before reading the integer itself,
preventing an out-of-bounds read.

Change-Id: Ibdf1af702fbeb98a94c0c96456ebddd3d392ad44
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-01-10 14:32:52 +01:00
Manish Pandey
601e2d4325 Merge changes from topic "bk/warnings" into integration
* changes:
  docs: describe the new warning levels
  build: add -Wunused-const-variable=2 to W=2
  build: include -Wextra in generic builds
  docs(porting-guide): update a reference
  fix(st-usb): replace redundant checks with asserts
  fix(brcm): add braces around bodies of conditionals
  fix(renesas): align incompatible function pointers
  fix(zynqmp): remove redundant api_version check
  fix: remove old-style declarations
  fix: unify fallthrough annotations
2023-01-10 11:56:42 +01:00
Jay Buddhabhatti
39fffe552f fix(versal-net): enable wake interrupt during client suspend
Wakeup interrupt should be set during power down sequence to wake
processor. So enable wakeup interrupt during power down sequence.

Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Change-Id: I1154495c25e0468496f6e112996fd182aa516d88
2023-01-10 02:19:33 -08:00
Jay Buddhabhatti
e663f09b3c fix(versal-net): disable wakeup interrupt during client wakeup
Clear and disable wakeup interrupt during client wakeup to avoid
multiple wakeup events.

Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Change-Id: Iebc644ae582da03001830b96e3190fce10dbac42
2023-01-10 02:19:33 -08:00
Jay Buddhabhatti
5f0f7e47e0 fix(versal-net): clear power down bit during wakeup
Power down bit and power down interrupt needs to be cleared once core
is wakeup to avoid unnecessary power down events. So disable power down
interrupt and clear power down bit during client wakeup.

Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Change-Id: I3445991692c441831e4ea8dae112e23b19f185a9
2023-01-10 02:19:33 -08:00
Jay Buddhabhatti
1f79bdfd9a fix(versal-net): fix setting power down state
Versal NET is supporting max power state to AFF_LVL_2 so set power state
for all affinity level instead of setting for only AFF_LVL_0.

Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Change-Id: I55a91e798b7566d2f34d7cb1fe28ca25993a7d8e
2023-01-10 02:19:33 -08:00
Jay Buddhabhatti
2d056db4e4 fix(versal-net): clear power down interrupt status before enable
Currently power down interrupt status is set by default before its
getting enabled. Because of that Linux is getting crashed since its
triggering interrupt before core goes to WFI state. So clear interrupt
status before enabling power down interrupt.

Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Change-Id: Ia8d047b6078a49ab3dbe3e0bf24422357f0138c2
2023-01-10 02:19:33 -08:00
Jay Buddhabhatti
21d1966a23 fix(versal-net): resolve misra rule 20.7 warnings
Fix below MISRA violation from versal_net_def.h:
 - MISRA Violation: MISRA-C:2012 R.10.6:
   - Macro parameter expands into an expression without being wrapped
     by parentheses.

Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Change-Id: Ie365d24c02bb38163005a3c073642d5c96412e2d
2023-01-10 02:16:19 -08:00
Jay Buddhabhatti
8c23775e88 fix(versal-net): resolve misra 10.6 warnings
Fix below MISRA violation from versal_net_def.h:
 - MISRA Violation: MISRA-C:2012 R.10.6
  - The value of a composite expression shall not be assigned to an
    object with wider essential type

Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Change-Id: I74f8e5d63523f33d245a21f8e4f04d30e40b05e7
2023-01-09 21:58:35 -08:00
Bipin Ravi
89d85ad0aa fix(cpus): workaround for Cortex-A710 erratum 2282622
Cortex-A710 erratum 2282622 is a Cat B erratum that applies to
all revisions <=r2p1 and is still open. The workaround was earlier
applied to all revisions <= r2p0, this patch extends it to r2p1.
This was thought to have been fixed in r2p1 which is not the case.

SDEN documentation:
https://developer.arm.com/documentation/SDEN1775101/latest

Signed-off-by: Bipin Ravi <bipin.ravi@arm.com>
Change-Id: Iad38a7fe57bec3f2d8977995acd601dcd9ae69c0
2023-01-09 23:17:48 -06:00
Sylwester Garncarek
5d68e8913e fix(gicv3): fixed bug in the initialization of GICv3 SGIs/(E)PPIs interrupt priorities
Default priority was not being set for all interrupts (gicr_write_ipriorityr takes INTID, not register number). The fix makes the loop to pass INTID in range 0, 4, 8, 12, ...

Signed-off-by: Sylwester Garncarek <sylwester.garncarek@sciopta.com>
Change-Id: Iaa975f6af49f5826c2811161f55242844c28ea81
2023-01-10 08:27:08 +07:00
Rohit Mathew
0e0bd250ef fix(mpam): remove unwanted param for "endfunc" macro
"endfunc" macro is used to mark the end of a function. It takes the
function label as an argument. For el2_sysregs_context_save_mpam
function, "endfunc" has been called with an assumed typo, "func", along
with the function label. Remove this unwanted param to fix the endfunc
call.

Signed-off-by: Rohit Mathew <rohit.mathew@arm.com>
Change-Id: I05f958a285f936df579f01500b6fd7cb2b7753a8
2023-01-09 17:25:01 +01:00
Madhukar Pappireddy
0e4655f828 Merge "docs(changelog): add console scope" into integration 2023-01-09 16:45:52 +01:00
Madhukar Pappireddy
bacfff8bb0 Merge "fix(libc): properly define SCHAR_MIN" into integration 2023-01-09 16:14:42 +01:00
Manish V Badarkhe
c9c752e9ff Merge "docs(maintainers): update maintainers for total compute" into integration 2023-01-09 15:32:16 +01:00
Rupinderjit Singh
08f439f417 docs(maintainers): update maintainers for total compute
Signed-off-by: Rupinderjit Singh <rupinderjit.singh@arm.com>
Change-Id: I64e7b036f404da110339d9013aa5c17ed8bf100f
2023-01-09 13:44:14 +00:00
Manish V Badarkhe
36ec4c7541 Merge "fix(plat/tc): increase TC_TZC_DRAM1_SIZE" into integration 2023-01-09 14:15:49 +01:00
Yann Gautier
3c78829035 docs(changelog): add console scope
Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: Ie9426509ee4f0a4c4f0fe0296d7a7378cc8828f5
2023-01-06 17:06:10 +01:00
Madhukar Pappireddy
51920f0f36 Merge "fix(fconf): make struct fconf_populator static" into integration 2023-01-06 16:44:20 +01:00
Yann Gautier
06c01b085f fix(libc): properly define SCHAR_MIN
SCHAR_MIN definition should use SCHAR_MAX, and not itself.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: If8c1751a381dac50fe3ec5fdf19d6a4918470b58
2023-01-06 14:22:09 +01:00
Yann Gautier
40e740dc14 fix(fconf): make struct fconf_populator static
In FCONF_REGISTER_POPULATOR macro, add static for the fconf_populator
struct. This avoids this kind of sparse warning:
plat/st/common/stm32mp_fconf_io.c:181:1: warning:
 symbol 'stm32mp_io__populator' was not declared. Should it be static?

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: Icaa7da3079e82497e112585150f6348ef2ebf5e6
2023-01-06 10:39:11 +01:00
Olivier Deprez
be737af7c8 Merge "feat(mt8188): update INFRA IOMMU enable flow" into integration 2023-01-06 09:38:25 +01:00
Chengci.Xu
98415e1a80 feat(mt8188): update INFRA IOMMU enable flow
IOMMU kernel driver has changed the function parameters, so update
IOMMU TF-A driver to be consistent with it.

Change-Id: I2adda69bdbdc31833781fac5e6c1f4b10da161be
Signed-off-by: Chengci.Xu <chengci.xu@mediatek.com>
2023-01-06 09:42:33 +08:00
Manish Pandey
0c6a085402 Merge changes from topic "fvp_trap_rng" into integration
* changes:
  feat(fvp): emulate trapped RNDR
  feat(el3-runtime): introduce system register trap handler
2023-01-04 18:51:40 +01:00
Yann Gautier
0e51db5ab3 refactor(stm32mp15-fdts): remove unused PMIC nodes
The onkey and watchdog features of the PMIC are not used in TF-A for
STM32MP15 boards. Remove the nodes from DT.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I2933e0bdc5843fcb549a817742106d9c66097869
2023-01-04 18:08:02 +01:00
Yann Gautier
600c8f7d95 fix(stm32mp15-fdts): use interrupts-extended for i2c2
Update SoC DT file STM32MP151 to use interrupts-extended instead of
interrupts for i2c2. This correct a compilation warning:
build/stm32mp1/debug/fdts/stm32mp157c-ev1-bl2.pre.dts:23.3-26:
 Warning (interrupts_property): /soc/i2c@40013000:#interrupt-cells:
  size is (28), expected multiple of 12

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: If512807cd23c72f95e1e02b15f30d20a849d8412
2023-01-04 18:08:02 +01:00
Yann Gautier
04339c5efb style(stm32mp15-fdts): remove extra spaces on vbus
Remove extra spaces before the closing brace of vbus_otg node in
stm32mp157c-ed1 DT file, before the vbus_sw label, and before the
closing brace of vbus_sw node.

Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I2e77e0a043594876551ed8d77ed3d13f6a098c81
2023-01-04 18:07:55 +01:00
Yann Gautier
992dba08f1 refactor(st): move board info in common code
Create a function stm32_display_board_info() that will display ST
board information, from a parameter taken from OTP fuse. The code
is just moved from STM32MP1 part to common directory.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I9e12fe98b5aabc7791cf2c9d48a38fbf2b219f9e
2023-01-04 16:46:07 +01:00
Yann Gautier
c27d8c00fd refactor(st): move GIC code to common directory
The GIC v2 initialization code could be shared to other ST platforms.
The stm32mp1_gic.c file is then moved to common directory, and renamed
stm32mp_gic.c.
The functions are also prefixed with stm32mp_gic.

Change-Id: I60820823b470217d3a95cc569f941c2cb923dfa9
Signed-off-by: Yann Gautier <yann.gautier@st.com>
2023-01-04 16:43:12 +01:00
Yann Gautier
d8da13e543 refactor(st): move boot backup register management
This backup register used to pass boot information to BL33, has the
same mapping for ST platforms. Its management can then be moved to
common directory.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: Ic873f099c1f87c6ba2825b4946365ae6a9687798
2023-01-04 16:42:49 +01:00
Manish Pandey
e2dcf8b4fe Merge "refactor(trng): discarding the used entropy bits" into integration 2023-01-04 11:41:46 +01:00
Arunachalam Ganapathy
7e3f6a87d7 fix(plat/tc): increase TC_TZC_DRAM1_SIZE
Increase TC_TZC_DRAM1_SIZE for Trusty image and its memory size.
Update OP-TEE reserved memory range in DTS

Change-Id: Iad433c3c155f28860b15bde2398df653487189dd
Signed-off-by: Arunachalam Ganapathy <arunachalam.ganapathy@arm.com>
Signed-off-by: Davidson K <davidson.kumaresan@arm.com>
2023-01-04 15:03:51 +05:30
Sandrine Bailleux
ef27dd231e Merge "refactor(auth): avoid parsing signature algorithm twice" into integration 2023-01-04 10:16:10 +01:00
Sandrine Bailleux
40fd1c024d Merge changes I794d2927,Ie33205fb,Ifdbe3b4c into integration
* changes:
  refactor(auth): do not include SEQUENCE tag in saved extensions
  fix(auth): reject junk after certificates
  fix(auth): require bit strings to have no unused bits
2023-01-03 17:55:02 +01:00