Commit 85df7e44 authored by danh-arm's avatar danh-arm
Browse files

Merge pull request #523 from jcastillo-arm/jc/genfw-791

ARM platforms: rationalise memory attributes of shared memory
parents 87959907 74eb26e4
...@@ -194,6 +194,8 @@ DEFINE_SYSOP_FUNC(wfe) ...@@ -194,6 +194,8 @@ DEFINE_SYSOP_FUNC(wfe)
DEFINE_SYSOP_FUNC(sev) DEFINE_SYSOP_FUNC(sev)
DEFINE_SYSOP_TYPE_FUNC(dsb, sy) DEFINE_SYSOP_TYPE_FUNC(dsb, sy)
DEFINE_SYSOP_TYPE_FUNC(dmb, sy) DEFINE_SYSOP_TYPE_FUNC(dmb, sy)
DEFINE_SYSOP_TYPE_FUNC(dmb, st)
DEFINE_SYSOP_TYPE_FUNC(dmb, ld)
DEFINE_SYSOP_TYPE_FUNC(dsb, ish) DEFINE_SYSOP_TYPE_FUNC(dsb, ish)
DEFINE_SYSOP_TYPE_FUNC(dmb, ish) DEFINE_SYSOP_TYPE_FUNC(dmb, ish)
DEFINE_SYSOP_FUNC(isb) DEFINE_SYSOP_FUNC(isb)
......
...@@ -151,14 +151,10 @@ ...@@ -151,14 +151,10 @@
#define ARM_G0_IRQS ARM_IRQ_SEC_SGI_0, \ #define ARM_G0_IRQS ARM_IRQ_SEC_SGI_0, \
ARM_IRQ_SEC_SGI_6 ARM_IRQ_SEC_SGI_6
#define ARM_SHARED_RAM_ATTR ((PLAT_ARM_SHARED_RAM_CACHED ? \
MT_MEMORY : MT_DEVICE) \
| MT_RW | MT_SECURE)
#define ARM_MAP_SHARED_RAM MAP_REGION_FLAT( \ #define ARM_MAP_SHARED_RAM MAP_REGION_FLAT( \
ARM_SHARED_RAM_BASE, \ ARM_SHARED_RAM_BASE, \
ARM_SHARED_RAM_SIZE, \ ARM_SHARED_RAM_SIZE, \
ARM_SHARED_RAM_ATTR) MT_DEVICE | MT_RW | MT_SECURE)
#define ARM_MAP_NS_DRAM1 MAP_REGION_FLAT( \ #define ARM_MAP_NS_DRAM1 MAP_REGION_FLAT( \
ARM_NS_DRAM1_BASE, \ ARM_NS_DRAM1_BASE, \
......
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
/************************************************************************* /*************************************************************************
* Definitions common to all ARM Compute SubSystems (CSS) * Definitions common to all ARM Compute SubSystems (CSS)
*************************************************************************/ *************************************************************************/
#define MHU_PAYLOAD_CACHED 0
#define NSROM_BASE 0x1f000000 #define NSROM_BASE 0x1f000000
#define NSROM_SIZE 0x00001000 #define NSROM_SIZE 0x00001000
...@@ -141,8 +139,6 @@ ...@@ -141,8 +139,6 @@
#define SCP_BL2U_BASE BL31_BASE #define SCP_BL2U_BASE BL31_BASE
#endif /* CSS_LOAD_SCP_IMAGES */ #endif /* CSS_LOAD_SCP_IMAGES */
#define PLAT_ARM_SHARED_RAM_CACHED MHU_PAYLOAD_CACHED
/* Load address of Non-Secure Image for CSS platform ports */ /* Load address of Non-Secure Image for CSS platform ports */
#define PLAT_ARM_NS_IMAGE_OFFSET 0xE0000000 #define PLAT_ARM_NS_IMAGE_OFFSET 0xE0000000
......
...@@ -64,8 +64,6 @@ ...@@ -64,8 +64,6 @@
#define PLAT_ARM_DRAM2_SIZE MAKE_ULL(0x780000000) #define PLAT_ARM_DRAM2_SIZE MAKE_ULL(0x780000000)
#define PLAT_ARM_SHARED_RAM_CACHED 1
/* /*
* Load address of BL33 for this platform port * Load address of BL33 for this platform port
*/ */
......
...@@ -192,11 +192,6 @@ void arm_program_trusted_mailbox(uintptr_t address) ...@@ -192,11 +192,6 @@ void arm_program_trusted_mailbox(uintptr_t address)
assert((PLAT_ARM_TRUSTED_MAILBOX_BASE >= ARM_SHARED_RAM_BASE) && assert((PLAT_ARM_TRUSTED_MAILBOX_BASE >= ARM_SHARED_RAM_BASE) &&
((PLAT_ARM_TRUSTED_MAILBOX_BASE + sizeof(*mailbox)) <= \ ((PLAT_ARM_TRUSTED_MAILBOX_BASE + sizeof(*mailbox)) <= \
(ARM_SHARED_RAM_BASE + ARM_SHARED_RAM_SIZE))); (ARM_SHARED_RAM_BASE + ARM_SHARED_RAM_SIZE)));
/* Flush data cache if the mail box shared RAM is cached */
#if PLAT_ARM_SHARED_RAM_CACHED
flush_dcache_range((uintptr_t) mailbox, sizeof(*mailbox));
#endif
} }
/******************************************************************************* /*******************************************************************************
......
...@@ -77,10 +77,10 @@ static void scp_boot_message_start(void) ...@@ -77,10 +77,10 @@ static void scp_boot_message_start(void)
static void scp_boot_message_send(size_t payload_size) static void scp_boot_message_send(size_t payload_size)
{ {
/* Make sure payload can be seen by SCP */ /* Ensure that any write to the BOM payload area is seen by SCP before
if (MHU_PAYLOAD_CACHED) * we write to the MHU register. If these 2 writes were reordered by
flush_dcache_range(BOM_SHARED_MEM, * the CPU then SCP would read stale payload data */
sizeof(bom_cmd_t) + payload_size); dmbst();
/* Send command to SCP */ /* Send command to SCP */
mhu_secure_message_send(BOM_MHU_SLOT_ID); mhu_secure_message_send(BOM_MHU_SLOT_ID);
...@@ -99,9 +99,10 @@ static uint32_t scp_boot_message_wait(size_t size) ...@@ -99,9 +99,10 @@ static uint32_t scp_boot_message_wait(size_t size)
panic(); panic();
} }
/* Make sure we see the reply from the SCP and not any stale data */ /* Ensure that any read to the BOM payload area is done after reading
if (MHU_PAYLOAD_CACHED) * the MHU register. If these 2 reads were reordered then the CPU would
inv_dcache_range(BOM_SHARED_MEM, size); * read invalid payload data */
dmbld();
return *(uint32_t *) BOM_SHARED_MEM; return *(uint32_t *) BOM_SHARED_MEM;
} }
......
...@@ -56,10 +56,10 @@ static void scpi_secure_message_start(void) ...@@ -56,10 +56,10 @@ static void scpi_secure_message_start(void)
static void scpi_secure_message_send(size_t payload_size) static void scpi_secure_message_send(size_t payload_size)
{ {
/* Make sure payload can be seen by SCP */ /* Ensure that any write to the SCPI payload area is seen by SCP before
if (MHU_PAYLOAD_CACHED) * we write to the MHU register. If these 2 writes were reordered by
flush_dcache_range(SCPI_SHARED_MEM_AP_TO_SCP, * the CPU then SCP would read stale payload data */
sizeof(scpi_cmd_t) + payload_size); dmbst();
mhu_secure_message_send(SCPI_MHU_SLOT_ID); mhu_secure_message_send(SCPI_MHU_SLOT_ID);
} }
...@@ -79,9 +79,10 @@ static void scpi_secure_message_receive(scpi_cmd_t *cmd) ...@@ -79,9 +79,10 @@ static void scpi_secure_message_receive(scpi_cmd_t *cmd)
panic(); panic();
} }
/* Make sure we don't read stale data */ /* Ensure that any read to the SCPI payload area is done after reading
if (MHU_PAYLOAD_CACHED) * the MHU register. If these 2 reads were reordered then the CPU would
inv_dcache_range(SCPI_SHARED_MEM_SCP_TO_AP, sizeof(*cmd)); * read invalid payload data */
dmbld();
memcpy(cmd, (void *) SCPI_SHARED_MEM_SCP_TO_AP, sizeof(*cmd)); memcpy(cmd, (void *) SCPI_SHARED_MEM_SCP_TO_AP, sizeof(*cmd));
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment