Sync patch files with internal CI

Sync patch files with platform-ci commit:
539c151d0cd99a5e6ca6c0e6966f6d8579fe864e

Signed-off-by: Zelalem <zelalem.aweke@arm.com>
Change-Id: I42e7b190f143e942bb01106939a3385f13c3c3f3
diff --git a/patch/fault_inject/.explicit-events.patch.swp b/patch/fault_inject/.explicit-events.patch.swp
new file mode 100644
index 0000000..a9b34f3
--- /dev/null
+++ b/patch/fault_inject/.explicit-events.patch.swp
Binary files differ
diff --git a/patch/fault_inject/explicit-events.patch b/patch/fault_inject/explicit-events.patch
index 7b6e72f..80acc20 100644
--- a/patch/fault_inject/explicit-events.patch
+++ b/patch/fault_inject/explicit-events.patch
@@ -1,7 +1,7 @@
 --- a/plat/arm/common/aarch64/arm_sdei.c
 +++ b/plat/arm/common/aarch64/arm_sdei.c
-@@ -12,7 +12,12 @@
- 
+@@ -48,7 +48,12 @@ void plat_sdei_setup(void)
+ #else
  /* Private event mappings */
  static sdei_ev_map_t arm_sdei_private[] = {
 -	PLAT_ARM_PRIVATE_SDEI_EVENTS
diff --git a/patch/fault_inject/injected-fault-in-absence-of-ras.patch b/patch/fault_inject/injected-fault-in-absence-of-ras.patch
new file mode 100644
index 0000000..f50b04d
--- /dev/null
+++ b/patch/fault_inject/injected-fault-in-absence-of-ras.patch
@@ -0,0 +1,16 @@
+--- a/Makefile
++++ b/Makefile
+@@ -533,13 +533,6 @@ ifeq ($(RAS_EXTENSION),1)
+     endif
+ endif
+
+-# When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled
+-ifeq ($(FAULT_INJECTION_SUPPORT),1)
+-    ifneq ($(RAS_EXTENSION),1)
+-        $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1)
+-    endif
+-endif
+-
+ # DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
+ ifeq ($(DYN_DISABLE_AUTH), 1)
+     ifeq (${TRUSTED_BOARD_BOOT}, 0)
diff --git a/patch/readonly_xlat_tables/arm_bl31_setup_write_after_readonly.patch b/patch/readonly_xlat_tables/arm_bl31_setup_write_after_readonly.patch
new file mode 100644
index 0000000..b6869d6
--- /dev/null
+++ b/patch/readonly_xlat_tables/arm_bl31_setup_write_after_readonly.patch
@@ -0,0 +1,10 @@
+--- a/plat/arm/common/arm_bl31_setup.c
++++ b/plat/arm/common/arm_bl31_setup.c
+@@ -256,6 +256,7 @@ void arm_bl31_plat_runtime_setup(void)
+
+ #if PLAT_RO_XLAT_TABLES
+ 	arm_xlat_make_tables_readonly();
++	arm_free_init_memory();
+ #endif
+ }
+
diff --git a/patch/readonly_xlat_tables/arm_sp_min_setup_write_after_readonly.patch b/patch/readonly_xlat_tables/arm_sp_min_setup_write_after_readonly.patch
new file mode 100644
index 0000000..70c751b
--- /dev/null
+++ b/patch/readonly_xlat_tables/arm_sp_min_setup_write_after_readonly.patch
@@ -0,0 +1,17 @@
+--- a/plat/arm/common/sp_min/arm_sp_min_setup.c
++++ b/plat/arm/common/sp_min/arm_sp_min_setup.c
+@@ -171,6 +171,14 @@ void arm_sp_min_plat_runtime_setup(void)
+
+ #if PLAT_RO_XLAT_TABLES
+ 	arm_xlat_make_tables_readonly();
++	int rc = xlat_change_mem_attributes(BL_CODE_BASE,
++					    BL_CODE_END - BL_CODE_BASE,
++					    MT_RW_DATA);
++	if (rc == 0) {
++		ERROR("Memory attributes were successfully changed after xlat tables were made read-only.\n");
++	}
++	ERROR("We should not have returned from xlat_change_mem_attributes().\n");
++	panic();
+ #endif
+ }
+
diff --git a/patch/readonly_xlat_tables/arm_tsp_setup_write_after_readonly.patch b/patch/readonly_xlat_tables/arm_tsp_setup_write_after_readonly.patch
new file mode 100644
index 0000000..cdb190e
--- /dev/null
+++ b/patch/readonly_xlat_tables/arm_tsp_setup_write_after_readonly.patch
@@ -0,0 +1,16 @@
+--- a/plat/arm/common/tsp/arm_tsp_setup.c
++++ b/plat/arm/common/tsp/arm_tsp_setup.c
+@@ -82,5 +82,13 @@ void tsp_plat_arch_setup(void)
+
+ #if PLAT_RO_XLAT_TABLES
+ 	arm_xlat_make_tables_readonly();
++	int rc = xlat_change_mem_attributes(BL_CODE_BASE,
++					    BL_CODE_END - BL_CODE_BASE,
++					    MT_RW_DATA);
++	if (rc == 0) {
++		ERROR("Memory attributes were successfully changed after xlat tables were made read-only.\n");
++	}
++	ERROR("We should not have returned from xlat_change_mem_attributes().\n");
++	panic();
+ #endif
+ }
diff --git a/patch/readonly_xlat_tables/sp_min_data_abort_print_panic_message.patch b/patch/readonly_xlat_tables/sp_min_data_abort_print_panic_message.patch
new file mode 100644
index 0000000..c1ba3d8
--- /dev/null
+++ b/patch/readonly_xlat_tables/sp_min_data_abort_print_panic_message.patch
@@ -0,0 +1,11 @@
+--- a/bl32/sp_min/aarch32/entrypoint.S
++++ b/bl32/sp_min/aarch32/entrypoint.S
+@@ -50,7 +50,7 @@ vector_base sp_min_vector_table
+ 	b	plat_panic_handler	/* Undef */
+ 	b	sp_min_handle_smc	/* Syscall */
+ 	b	plat_panic_handler	/* Prefetch abort */
+-	b	plat_panic_handler	/* Data abort */
++	b	do_panic		/* Data abort */
+ 	b	plat_panic_handler	/* Reserved */
+ 	b	plat_panic_handler	/* IRQ */
+ 	b	sp_min_handle_fiq	/* FIQ */
diff --git a/patch/readonly_xlat_tables/tsp_sync_exception_print_panic_message.patch b/patch/readonly_xlat_tables/tsp_sync_exception_print_panic_message.patch
new file mode 100644
index 0000000..8c20dfd
--- /dev/null
+++ b/patch/readonly_xlat_tables/tsp_sync_exception_print_panic_message.patch
@@ -0,0 +1,11 @@
+--- a/bl32/tsp/aarch64/tsp_exceptions.S
++++ b/bl32/tsp/aarch64/tsp_exceptions.S
+@@ -102,7 +102,7 @@ end_vector_entry serror_sp_el0
+ 	 * -----------------------------------------------------
+ 	 */
+ vector_entry sync_exception_sp_elx
+-	b	plat_panic_handler
++	b	do_panic
+ end_vector_entry sync_exception_sp_elx
+
+ vector_entry irq_sp_elx
diff --git a/patch/tbb_dyn_auth/disable_dyn_auth.patch b/patch/tbb_dyn_auth/disable_dyn_auth.patch
new file mode 100644
index 0000000..841cc23
--- /dev/null
+++ b/patch/tbb_dyn_auth/disable_dyn_auth.patch
@@ -0,0 +1,28 @@
+diff --git a/common/bl_common.c b/common/bl_common.c
+index 03ebb3a64..524fc4720 100644
+--- a/common/bl_common.c
++++ b/common/bl_common.c
+@@ -29,7 +29,7 @@ static int disable_auth;
+  *****************************************************************************/
+ void dyn_disable_auth(void)
+ {
+-	INFO("Disabling authentication of images dynamically\n");
++	NOTICE("Disabling authentication of images dynamically\n");
+ 	disable_auth = 1;
+ }
+ # endif /* DYN_DISABLE_AUTH */
+diff --git a/plat/arm/board/fvp/fdts/fvp_tb_fw_config.dts b/plat/arm/board/fvp/fdts/fvp_tb_fw_config.dts
+index 576eded93..ec49225e8 100644
+--- a/plat/arm/board/fvp/fdts/fvp_tb_fw_config.dts
++++ b/plat/arm/board/fvp/fdts/fvp_tb_fw_config.dts
+@@ -11,7 +11,7 @@
+ 		compatible = "arm,tb_fw";
+ 
+ 		/* Disable authentication for development */
+-		disable_auth = <0x0>;
++		disable_auth = <0x1>;
+ 
+ 		/*
+ 		 * The following two entries are placeholders for Mbed TLS
+--
+2.20.1
diff --git a/patch/ubsan/ubsan_test.patch b/patch/ubsan/ubsan_test.patch
new file mode 100644
index 0000000..70af5e9
--- /dev/null
+++ b/patch/ubsan/ubsan_test.patch
@@ -0,0 +1,48 @@
+From 080e004b7ba917bd88d9f9c51d077e32a959d8fa Mon Sep 17 00:00:00 2001
+From: Zelalem <zelalem.aweke@arm.com>
+Date: Fri, 6 Dec 2019 10:29:13 -0600
+Subject: [PATCH] Add UBSAN test patch
+
+Change-Id: Ib2c78d9da0f214957dcad0d1d9a89089c10c9b48
+---
+ bl31/bl31_main.c | 17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
+
+diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c
+index 92a2027dd..46cbed65e 100644
+--- a/bl31/bl31_main.c
++++ b/bl31/bl31_main.c
+@@ -85,6 +85,19 @@ void bl31_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
+ #endif /* CTX_INCLUDE_PAUTH_REGS */
+ }
+ 
++/*
++* UBSAN test function. This is used to test whether CI handles
++* undefined behaviour errors correctly.
++*/
++#include <limits.h>
++
++static int ubsan_test_add_overflow(void)
++{
++        static int32_t val = INT_MAX;
++        val += 0x1;
++        return val;
++}
++
+ /*******************************************************************************
+  * BL31 is responsible for setting up the runtime services for the primary cpu
+  * before passing control to the bootloader or an Operating System. This
+@@ -147,6 +160,10 @@ void bl31_main(void)
+ 	 * from BL31
+ 	 */
+ 	bl31_plat_runtime_setup();
++
++	/* Run UBSAN Test */
++        INFO("BL31: Running UBSAN test\n");
++        ubsan_test_add_overflow();
+ }
+ 
+ /*******************************************************************************
+-- 
+2.17.1
+