fix: use write instead of read to generate SError

With sha 19297eb it was expected that read to invalid device memory
will cause SError in EL3 but it was causing sync exception. Change the
read to write for proper behaviour.

Signed-off-by: Manish Pandey <manish.pandey2@arm.com>
Change-Id: I933aa3a80d40795a339cdf2160ebdcad976ab9e2
diff --git a/tftf/tests/misc_tests/test_inject_serror.c b/tftf/tests/misc_tests/test_inject_serror.c
index f0d7406..d02cd4e 100644
--- a/tftf/tests/misc_tests/test_inject_serror.c
+++ b/tftf/tests/misc_tests/test_inject_serror.c
@@ -16,8 +16,8 @@
  *
  * This test never returns, it ends up with a crash in EL3.
  *
- * This test maps a non-existent memory as Device memory and access it. Memory
- * is mapped as device and cause an error on bus and trap as an SError.
+ * This test maps a non-existent memory as Device memory and write to it.
+ * Memory is mapped as device and cause an error on bus and trap as an SError.
  * This test is used in conjunction with HANDLE_EA_EL3_FIRST_NS feature
  * (trapping EA in lower ELs to EL3) in TF-A.
  * SError caused by this error will be trapped in EL3 and eventually cause a
@@ -25,22 +25,20 @@
  */
 test_result_t test_inject_serror(void)
 {
-	unsigned int rc;
+	int rc;
 	const uintptr_t test_address = 0x7FFFF000;
 
 	rc = mmap_add_dynamic_region(test_address, test_address, PAGE_SIZE,
-						MT_DEVICE | MT_RO | MT_NS);
+						MT_DEVICE | MT_RW | MT_NS);
 	if (rc != 0) {
 		tftf_testcase_printf("%d: mapping address %lu(%d) failed\n",
 				      __LINE__, test_address, rc);
 		return TEST_RESULT_FAIL;
 	}
 
-	/* Try to read invalid address */
-	rc = mmio_read_32(test_address);
+	/* Try writing to invalid address */
+	mmio_write_32(test_address, 1);
 
-	/* Should not come this far, print rc to avoid compiler optimization */
-	ERROR("Reading invalid address did not cause SError, rc = %u\n", rc);
-
+	/* Should not come this far */
 	return TEST_RESULT_FAIL;
 }