fix(cpus): workaround for Cortex-X2 erratum 2267065

Cortex-X2 erratum 2267065 is a Cat B erratum that applies to
revisions r0p0, r1p0 and r2p0 and is fixed in r2p1.

The workaround is to set CPUACTLR_EL1[22].

SDEN documentation:
https://developer.arm.com/documentation/SDEN-1775100/latest

Change-Id: I540e113f209ef11ec7103d4ef4e48ffb52416b4e
Signed-off-by: John Powell <john.powell@arm.com>
diff --git a/docs/design/cpu-specific-build-macros.rst b/docs/design/cpu-specific-build-macros.rst
index 430dc04..77549ac 100644
--- a/docs/design/cpu-specific-build-macros.rst
+++ b/docs/design/cpu-specific-build-macros.rst
@@ -786,6 +786,10 @@
    CPU. This needs to be enabled only for revision r2p0 of the CPU, it is fixed
    in r2p1.
 
+-  ``ERRATA_X2_2267065``: This applies errata 2267065 workaround to Cortex-X2
+   CPU. This needs to be enabled only for revisions r0p0, r1p0 and r2p0 of the
+   CPU, it is fixed in r2p1.
+
 -  ``ERRATA_X2_2282622``: This applies errata 2282622 workaround to Cortex-X2
    CPU. This needs to be enabled for revisions r0p0, r1p0, r2p0 and r2p1 of the
    CPU and is still open.
diff --git a/lib/cpus/aarch64/cortex_x2.S b/lib/cpus/aarch64/cortex_x2.S
index bcee06f..264a035 100644
--- a/lib/cpus/aarch64/cortex_x2.S
+++ b/lib/cpus/aarch64/cortex_x2.S
@@ -163,6 +163,12 @@
 
 check_erratum_ls cortex_x2, ERRATUM(2216384), CPU_REV(2, 0)
 
+workaround_reset_start cortex_x2, ERRATUM(2267065), ERRATA_X2_2267065
+	sysreg_bit_set CORTEX_X2_CPUACTLR_EL1, BIT(22)
+workaround_reset_end cortex_x2, ERRATUM(2267065)
+
+check_erratum_ls cortex_x2, ERRATUM(2267065), CPU_REV(2, 0)
+
 workaround_reset_start cortex_x2, ERRATUM(2282622), ERRATA_X2_2282622
 	/* Apply the workaround */
 	sysreg_bit_set CORTEX_X2_CPUACTLR2_EL1, BIT(0)
diff --git a/lib/cpus/cpu-ops.mk b/lib/cpus/cpu-ops.mk
index d9a136b..1a47738 100644
--- a/lib/cpus/cpu-ops.mk
+++ b/lib/cpus/cpu-ops.mk
@@ -794,6 +794,11 @@
 # only to revision r2p0 of the Cortex-X2 cpu, it is fixed in r2p1.
 CPU_FLAG_LIST += ERRATA_X2_2147715
 
+# Flag to apply erratum 2267065 workaround during reset. This erratum applies
+# only to revisions r0p0, r1p0 and r2p0 of the Cortex-X2 cpu, it is fixed in
+# r2p1.
+CPU_FLAG_LIST += ERRATA_X2_2267065
+
 # Flag to apply erratum 2282622 workaround during reset. This erratum applies
 # to revision r0p0, r1p0, r2p0 and r2p1 of the Cortex-X2 cpu and is still
 # open.