[app][hwcrypto] Rearrange request/response buffers
Make sure that request/response buffers are not crossing page boundary.
Reduce heap size to 2 pages.
Change-Id: I6ca8b86ddc93905e857ca46bcb36f395d23e5db8
diff --git a/app/hwcrypto/hwkey_srv.c b/app/hwcrypto/hwkey_srv.c
index 1ee09b0..7fac6b1 100644
--- a/app/hwcrypto/hwkey_srv.c
+++ b/app/hwcrypto/hwkey_srv.c
@@ -48,8 +48,12 @@
.proc = hwkey_port_handler,
};
-static uint8_t req_data[HWKEY_MAX_PAYLOAD_SIZE+1];
-static uint8_t key_data[HWKEY_MAX_PAYLOAD_SIZE];
+/* Make sure that key_data and reg_data buffers are not crossing page boundary so it is
+ * safe to pass them to DMA. An extra byte for req_data buf is used to zero terminate string
+ * so it is OK to have it on separate page as it will never be accesed by DMA engine.
+ */
+static uint8_t key_data[HWKEY_MAX_PAYLOAD_SIZE] __attribute__((aligned(HWKEY_MAX_PAYLOAD_SIZE)));
+static uint8_t req_data[HWKEY_MAX_PAYLOAD_SIZE+1] __attribute__((aligned(HWKEY_MAX_PAYLOAD_SIZE)));
static uint key_slot_cnt;
static const struct hwkey_keyslot *key_slots;
diff --git a/app/hwcrypto/manifest.c b/app/hwcrypto/manifest.c
index f792cd6..74a63f8 100644
--- a/app/hwcrypto/manifest.c
+++ b/app/hwcrypto/manifest.c
@@ -28,7 +28,7 @@
.config_options = {
/* Max HEAP size */
- TRUSTY_APP_CONFIG_MIN_HEAP_SIZE(6 * 4096),
+ TRUSTY_APP_CONFIG_MIN_HEAP_SIZE(2 * 4096),
/* MMIO regions */
TRUSTY_APP_CONFIG_MAP_MEM(CAAM_MMIO_ID, CAAM_PHY_BASE_ADDR, CAAM_REG_SIZE),
TRUSTY_APP_CONFIG_MAP_MEM(CAAM_SEC_RAM_MMIO_ID, CAAM_PHY_ARB_BASE_ADDR, CAAM_SEC_RAM_SIZE),